[web3] Fei Protocol Flashloan Vulnerability Postmortem. This is a postmortem of a vulnerability… | by Immunefi | Aug, 2021 | Medium
A vulnerability in Fei Protocol allowed an attacker to use a flash loan to manipulate the Uniswap ETH/FEI pool and then call the allocate function to deposit protocol-controlled ETH at a distorted rate, potentially draining up to 60,000 ETH. The bug was fixed by changing where bonding curve ETH is deposited and by adding slippage tolerance to the Uniswap deposit.
medium.com
Published on medium.com
Fei Protocol
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Fei Protocol is a decentralised, algorithmic stablecoin that keeps the price of FEI at its peg through several mechanisms. One of them is Protocol Controlled Value (PCV): the protocol itself holds a substantial amount of the liquidity provider tokens (LP tokens) in the Uniswap V2 pool for the ETH/FEI pair. An LP token represents a pro rata share of each pool of tokens that are deposited.
The feature at the centre of this report is allocate(), a function anyone can call. It takes the protocol-controlled value, the ETH controlled by the protocol, and puts it into the Uniswap pool at the prevailing market rate rather than at the ETH/USD oracle price, which is what the design intends. The function cannot be called during the Genesis period, which is now over, and cannot be called during a pause.
A second relevant piece of the design is the guard meant to stop price manipulation of FEI during the allocate operation: Address.isContract together with the nonContract modifier.
Setup
The report describes no accounts, tooling versions or environment beyond the following. The whitehat is Alexander Schlindwein, who had previously received the largest ever bug bounty payout after finding a critical bug in ArmorFi. He reported this bug to Immunefi on May 2. Concurrently and independently, Fei Protocol's security team, led by Joey Santoro, also discovered the bug and immediately paused the contract. Alexander wrote a Python program using GEKKO to choose the optimal split of the available flashloaned funds, and a proof-of-concept exploit to demonstrate the attack. The precondition for the attack is a flash loan: the report notes that the drain would have been limited by the roughly 1m in ETH available across the ecosystem for flash loans.
Finding it
The overview of the vulnerability is that flash loan-driven market manipulation can drain Fei Protocol of protocol-controlled funds.
The issue is that anyone can call allocate(), which takes the PCV and puts it into the Uniswap pool at the prevailing market rate, not at the ETH/USD oracle price as designed. Address.isContract and the nonContract modifier are designed to prevent price manipulation of FEI during the allocate operation, but this guard as written does not work. It can be bypassed if invoked by a contract's constructor.
Exploitation
The exploit can be illustrated in the following steps.
Step 1: Take a flash loan
- Take a flashloan in WETH
Step 2: Distort the Uniswap pool
- Dump the ETH into the Uniswap ETH/FEI pool. This makes FEI very expensive and ETH very cheap
Step 3: Buy FEI on the bonding curve
- Call the ETH bonding curve
purchaseto buy FEI at the protocol-established price of $1.01, even though the FEI market price is now much higher in the Uniswap pool
Step 4: Build a constructor-based caller
- Construct a dummy contract whose only purpose is to invoke
allocatefrom the constructor in order to bypass thenonContractmodifier
Step 5: Call allocate from the constructor
- Call
allocate(from the constructor of the dummy contract), which eventually invokesaddLiquidityETHat the ETH/USD oracle price, but with 100% slippage tolerance. This deposits the PCV (in ETH) into the Uniswap V2 pool. The counterpart quantity of FEI is minted/burned directly by the protocol. Because the market is currently distorted by the flash loan, much more ETH is deposited (relative to FEI) as would be dictated by the prevailing, non-distorted market conditions
Step 6: Swap the FEI back
- Take the newly bought FEI and swap it back into the pool. This takes advantage of the excess of ETH deposited in step 5. This gets back the original ETH swapped, and, according to calculations by Alexander, additional gains of up to 60,000 ETH
Step 7: Return the flash loan
- Return flash loan
The correct choice of how much ETH to dump into the Uniswap pool versus how much ETH to purchase on the bonding curve is a complicated optimisation problem. Alexander Schlindwein wrote a Python program using GEKKO to choose the optimal split of the available flashloaned funds, and a proof-of-concept exploit to demonstrate the attack.
Root cause
Two weaknesses combine.
First, allocate() deposits PCV into the Uniswap pool at the prevailing market rate instead of the ETH/USD oracle price, and the call to addLiquidityETH carries 100% slippage tolerance. Without an oracle price enforced by slippage tolerance, there is no way to know whether the price reported by the Uniswap pool reflects prevailing market conditions.
Second, the guard intended to keep contracts out of the allocate path does not work. Checks using extcodesize, such as OpenZeppelin's Address.isContract, are only sufficient if you intend to include only smart contracts, not to exclude them. Address.isContract returns false for some contracts, such as those that are currently being constructed, which is why invoking allocate from a constructor bypasses the nonContract modifier. Currently, Solidity does not provide a future-proof method for testing whether an address is a contract. require(msg.sender == tx.origin) works for the current Berlin EVM, but Vitalik has publicly stated that tx.origin may not continue to be meaningful in future versions.
Impact
If this vulnerability had been exploited, it could have drained the protocol of 60,000 ETH via a flash loan attack, limited by the roughly 1m in ETH available across the ecosystem for flash loans. The vulnerability was not exploited and no funds were lost. Fei Protocol awarded Alexander Schlindwein an $800,000 bounty, paid in TRIBE, in recognition of his contributions to the fix and as a demonstration of the protocol's commitment to whitehat hacking and to the broader Ethereum ecosystem. The report describes this as one of the largest awards ever paid out in DeFi history.
Fix
Fei Protocol temporarily paused the affected contract, EthBondingCurve.sol, and jointly developed a fix with Alexander Schlindwein and OpenZeppelin. The pause was lifted when it was discovered that a pause in EthUniswapPCVDeposit.sol was sufficient to mitigate the bug until a more permanent fix was developed. After review by OpenZeppelin and Immunefi, Fei deployed two fixes, each of which would independently prevent this kind of attack.
- Bonding curve ETH no longer reaches the pool. ETH deposited to the protocol through the bonding curve is no longer supplied to the ETH/FEI Uniswap pool, which completely removes the vector used by this attack. Instead, that ETH is directed to the reserve stabilizer, a mechanism for maintaining the price of FEI below the peg. The reserve stabilizer allows anyone to purchase ETH from the protocol at $0.95, placing a hard floor on the price of FEI.
- Slippage relative to the oracle. The slippage parameter in the
EthUniswapPCVDepositcontract was addressed. The fix sets the slippage of the call toaddLiquidityETHto a configurable percentage of the ETH/USD oracle price. The contractUniswapPCVDepositgot a new method,_getMinLiquidity, which computes a configurable ratio from the deposited amount to set theamountTokenMinandamountETHMinarguments toaddLiquidityETH. BecauseEthUniswapPCVDepositalways deposits at the oracle price, this sets the slippage relative to the oracle, not relative to the current market ETH/FEI price. Currently the slippage is set to 1%: if the market is distorted by more than 1% relative to the oracle price, the deposit/allocation transaction reverts.
This second fix also protects Fei from market manipulation due to a sandwich attack. Merely fixing Address.isContract or the nonContract modifier would not protect against a sandwich attack on its own.
Variants to test
- Constructor bypass of contract checks. Look for privileged or price-sensitive functions guarded by
extcodesize-based checks such as OpenZeppelin'sAddress.isContractor anonContractmodifier. A positive result is a call to the guarded function succeeding from a contract's constructor, where a direct call from a deployed contract is rejected. - Liquidity provision with loose slippage. Find calls to
addLiquidityETHor similar DEX entry points that pass a 100% (or otherwise very loose) slippage tolerance while depositing protocol-owned funds. A positive result is a deposit executing at a rate far from the oracle price while the pool is distorted. - Market-rate versus oracle-rate deposits. Check whether protocol funds are deposited at the pool's prevailing rate rather than an oracle price. A positive result is a deposit whose size changes materially when the pool is moved with borrowed capital, with the protocol absorbing the difference.
- Sandwich exposure on deposits. Even where a contract check is fixed, test whether a deposit can be sandwiched. A positive result is a deposit that executes at a price moved by a transaction immediately before it, with no oracle-anchored minimum.
tx.originguards. Whererequire(msg.sender == tx.origin)is used as the anti-contract guard, test whether the protected path can still be reached in a way that defeats the intent, keeping in mind the report's note thattx.originmay not remain meaningful in future EVM versions.
What happened, in plain words
Fei Protocol is a piece of software that lives on a blockchain (a shared, public record of transactions that many computers keep copies of). It issues its own digital money, called FEI, and its goal is to keep one FEI worth about one US dollar. To do that it holds a large pile of funds that the software itself controls, rather than any person. That pile is called Protocol Controlled Value, or PCV.
A security researcher, Alexander Schlindwein, found a way that someone could have tricked the protocol into handing over most of that pile. He reported it to Immunefi, a company that runs bug bounty programmes (a scheme where a project pays people for reporting security problems instead of exploiting them). At almost the same moment, Fei Protocol's own security team, led by Joey Santoro, found the same problem and paused the affected contract. The bug was never used against the protocol and no funds were lost. Fei paid Alexander an $800,000 bounty, in the project's own TRIBE token, and the report calls this one of the largest awards ever paid out in DeFi history.
If the bug had been exploited, the report says it could have drained 60,000 ETH from the protocol. ETH is the cryptocurrency of the Ethereum network. The amount was limited by roughly 1m in ETH that was available across the ecosystem for flash loans at the time.

The image is the header of the bugfix review, showing the title "Fei Protocol Flashloan Vulnerability Bugfix Review" with the Immunefi branding and the publication date, May 13, 2021.
Before the steps, a few ideas need explaining, because the whole attack depends on them.
A smart contract is a small program that runs on the blockchain. Once deployed it runs exactly as written, and anyone can send it instructions by sending a transaction. Fei Protocol is a collection of such contracts.
A function is a named action inside a program. Calling a function means asking the program to perform that action. Some functions are meant to be called by anyone; others are meant to be restricted.
A token is a digital asset tracked by a contract. FEI is a token, ETH is the native currency of Ethereum, WETH is a wrapped form of ETH that behaves like a token, and TRIBE is Fei's own governance token.
A stablecoin is a token designed to hold a steady price, usually one US dollar. Fei is an algorithmic stablecoin: software rules, rather than a pile of dollars in a bank, are supposed to keep it at the peg (the target price).
Uniswap is a decentralised exchange: a contract that lets people swap one token for another. Instead of an order book with buyers and sellers, it holds pools of tokens. A pool for the ETH/FEI pair holds some ETH and some FEI, and the price is set by the ratio between the two amounts in the pool. If someone dumps a lot of ETH into the pool, ETH becomes cheap there and FEI becomes expensive, because the ratio shifts. That is the lever the attacker pulls.
A liquidity provider token, or LP token, is a receipt you get for putting tokens into a Uniswap pool. It represents a pro rata share of everything deposited in that pool: if you own 10% of the LP tokens, you own a claim on 10% of the pool. Fei Protocol holds a substantial amount of the LP tokens for the ETH/FEI pool, which is one way it controls value.
An oracle is a service that reports a price from outside the blockchain, for example the ETH/USD price. The distinction that matters throughout this report is between the oracle price (what ETH is worth in dollars according to the oracle) and the market rate or prevailing rate (whatever the Uniswap pool currently says, which anyone with enough capital can push around for a moment).
Slippage is the gap between the price you expected and the price you actually get. When a contract adds funds to a pool, it can set a slippage tolerance: a limit on how far the executed price may drift from the expected one. A tolerance of 100% means, in effect, no minimum at all: the transaction will go through at whatever price the pool gives.
A flash loan is a loan that must be borrowed and repaid within a single transaction. A transaction is one bundle of actions that either all succeed or all fail, so the lender is safe: if the borrower cannot repay in the same bundle, the whole thing is undone as if it never happened. This lets someone borrow enormous sums for a few seconds with no collateral of their own. It is also why flash loans are a favourite tool for market manipulation: the attacker can move a market a long way, take a profit, and put the borrowed money back, all in one go.
A constructor is the special piece of code that runs once, at the moment a contract is created. Code that runs inside a constructor is running while the contract is still being built.
extcodesize is an instruction that reports the size of the code stored at an address. A normal wallet address has no code, so its size is zero. A deployed contract has code, so its size is greater than zero. Contracts use this to try to tell humans and contracts apart. The catch, which is central here, is that a contract still under construction reports a code size of zero.
A modifier is a reusable check attached to a function, a bit like a door guard that runs before the function body. nonContract is the name of a guard in this codebase that is supposed to reject callers that are contracts.
A revert means a transaction is cancelled and its effects undone. Contracts revert when a check fails, for example when a price has moved too far.
A sandwich attack is a way to profit from someone else's trade by placing transactions immediately before and after it. The first transaction moves the price against the victim, the victim's trade executes at the worse price, and the second transaction moves the price back and pockets the difference. No flash loan is needed for this; it is a separate risk that the same fix happens to address.
The feature at the centre of it
The report focuses on a function called allocate(). Anyone can call it. Its job is to take the protocol-controlled ETH and put it into the Uniswap pool. The design intends this to happen at the ETH/USD oracle price, but as written it happens at the prevailing market rate, meaning whatever the pool currently says. The function cannot be called during the Genesis period, a launch phase that is now over, and it cannot be called while the protocol is paused.
A second piece of the design is the guard meant to stop price manipulation of FEI during the allocate operation: Address.isContract together with the nonContract modifier. Address.isContract is a helper, from the OpenZeppelin library of reusable contract code, that answers the question "is this address a contract?" by looking at extcodesize. The nonContract modifier uses that answer to reject contract callers. The report's finding is that this guard, as written, does not work.
Who found it, and with what
The whitehat is Alexander Schlindwein, who had previously received the largest ever bug bounty payout after finding a critical bug in ArmorFi. He reported this bug to Immunefi on May 2. Concurrently and independently, Fei Protocol's security team, led by Joey Santoro, also discovered the bug and immediately paused the contract.
To work out the attack, Alexander wrote a Python program using GEKKO, a library for solving optimisation problems, to choose the best split of the borrowed funds between the two moves: how much ETH to dump into the Uniswap pool and how much to spend buying FEI on the bonding curve. He also wrote a proof-of-concept exploit, a working demonstration, to show the attack.
The precondition for the attack is a flash loan. The report notes that the drain would have been limited by the roughly 1m in ETH available across the ecosystem for flash loans.
Finding it
The overview of the vulnerability is that flash loan-driven market manipulation can drain Fei Protocol of protocol-controlled funds.
The issue is that anyone can call allocate(), which takes the PCV and puts it into the Uniswap pool at the prevailing market rate, not at the ETH/USD oracle price as designed. Address.isContract and the nonContract modifier are designed to prevent price manipulation of FEI during the allocate operation, but this guard as written does not work. It can be bypassed if invoked by a contract's constructor.
In plain terms: the protocol has a function that moves its own money into a market whose price an outsider can push around, and the one guard that was supposed to stop outsiders from calling it can be stepped around by calling it from inside a constructor. Those two facts together are the bug.
Exploitation
The exploit can be illustrated in the following steps.
Step 1: Take a flash loan
- Take a flashloan in WETH
This supplies the capital for the manipulation without requiring the attacker to own it. WETH is wrapped ETH: the same value, in a form that behaves like a token, which is what the lending and swapping contracts expect. The attacker needs a large amount only for the duration of one transaction, and a flash loan provides exactly that.
Step 2: Distort the Uniswap pool
- Dump the ETH into the Uniswap ETH/FEI pool. This makes FEI very expensive and ETH very cheap
Why: the pool sets its price from the ratio of the two tokens it holds. Selling a large amount of ETH into it shifts that ratio hard, so within the pool FEI now looks very expensive and ETH very cheap. This distorted price is temporary and artificial, but every contract that reads the pool during this transaction will see it.
Step 3: Buy FEI on the bonding curve
- Call the ETH bonding curve
purchaseto buy FEI at the protocol-established price of $1.01, even though the FEI market price is now much higher in the Uniswap pool
A bonding curve is a rule that sets the price at which the protocol itself will sell its token, here $1.01. It does not read the Uniswap pool, so the distortion from step 2 does not affect it. The attacker therefore buys FEI from the protocol cheaply, while the manipulated market says FEI is worth much more.
Step 4: Build a constructor-based caller
- Construct a dummy contract whose only purpose is to invoke
allocatefrom the constructor in order to bypass thenonContractmodifier
Why this works: the nonContract guard asks Address.isContract whether the caller is a contract, and that check reads extcodesize. A contract that is still being constructed has no code stored at its address yet, so the check reports zero and concludes the caller is not a contract.
Step 5: Call allocate from the constructor
- Call
allocate(from the constructor of the dummy contract), which eventually invokesaddLiquidityETHat the ETH/USD oracle price, but with 100% slippage tolerance. This deposits the PCV (in ETH) into the Uniswap V2 pool. The counterpart quantity of FEI is minted/burned directly by the protocol. Because the market is currently distorted by the flash loan, much more ETH is deposited (relative to FEI) as would be dictated by the prevailing, non-distorted market conditions
addLiquidityETH is the Uniswap function for adding ETH and its paired token to a pool at the same time. So the deposit goes through even though the pool is badly distorted, and because the pool is distorted, it accepts far more ETH relative to FEI than a normal market would. The FEI side of the deposit is minted or burned by the protocol itself, so the attacker does not need to supply it.
Step 6: Swap the FEI back
- Take the newly bought FEI and swap it back into the pool. This takes advantage of the excess of ETH deposited in step 5. This gets back the original ETH swapped, and, according to calculations by Alexander, additional gains of up to 60,000 ETH
Why: the pool now contains an outsized amount of ETH, put there by the protocol in step 5. Selling the FEI bought in step 3 back into that pool lets the attacker take that ETH out. The swap returns the ETH the attacker originally dumped in step 2, and, on Alexander's calculations, up to 60,000 ETH more. That extra is the protocol's money.
Step 7: Return the flash loan
- Return flash loan
What is left over is profit.
The correct choice of how much ETH to dump into the Uniswap pool versus how much ETH to purchase on the bonding curve is a complicated optimisation problem. Alexander Schlindwein wrote a Python program using GEKKO to choose the optimal split of the available flashloaned funds, and a proof-of-concept exploit to demonstrate the attack.
Root cause
Two weaknesses combine.
First, allocate() deposits PCV into the Uniswap pool at the prevailing market rate instead of the ETH/USD oracle price, and the call to addLiquidityETH carries 100% slippage tolerance. Without an oracle price enforced by slippage tolerance, there is no way to know whether the price reported by the Uniswap pool reflects prevailing market conditions. An attacker who distorts the pool with a flash loan therefore controls the rate at which protocol funds are deposited.
Second, the guard intended to keep contracts out of the allocate path does not work. Checks using extcodesize, such as OpenZeppelin's Address.isContract, are only sufficient if you intend to include only smart contracts, not to exclude them. Address.isContract returns false for some contracts, such as those that are currently being constructed, which is why invoking allocate from a constructor bypasses the nonContract modifier. Currently, Solidity, the language these contracts are written in, does not provide a future-proof method for testing whether an address is a contract. require(msg.sender == tx.origin) works for the current Berlin EVM, but Vitalik has publicly stated that tx.origin may not continue to be meaningful in future versions. In plain terms: the usual trick for telling a person from a program has a hole in it, and the hole is exactly the moment a program is being born.
Impact
If this vulnerability had been exploited, it could have drained the protocol of 60,000 ETH via a flash loan attack, limited by the roughly 1m in ETH available across the ecosystem for flash loans. The vulnerability was not exploited and no funds were lost. Fei Protocol awarded Alexander Schlindwein an $800,000 bounty, paid in TRIBE, in recognition of his contributions to the fix and as a demonstration of the protocol's commitment to whitehat hacking and to the broader Ethereum ecosystem. The report describes this as one of the largest awards ever paid out in DeFi history.
Fix
Fei Protocol temporarily paused the affected contract, EthBondingCurve.sol, and jointly developed a fix with Alexander Schlindwein and OpenZeppelin. The pause was lifted when it was discovered that a pause in EthUniswapPCVDeposit.sol was sufficient to mitigate the bug until a more permanent fix was developed. After review by OpenZeppelin and Immunefi, Fei deployed two fixes, each of which would independently prevent this kind of attack.
- Bonding curve ETH no longer reaches the pool. ETH deposited to the protocol through the bonding curve is no longer supplied to the ETH/FEI Uniswap pool, which completely removes the vector used by this attack. Instead, that ETH is directed to the reserve stabilizer, a mechanism for maintaining the price of FEI below the peg. The reserve stabilizer allows anyone to purchase ETH from the protocol at $0.95, placing a hard floor on the price of FEI.
- Slippage relative to the oracle. The slippage parameter in the
EthUniswapPCVDepositcontract was addressed. The fix sets the slippage of the call toaddLiquidityETHto a configurable percentage of the ETH/USD oracle price. The contractUniswapPCVDepositgot a new method,_getMinLiquidity, which computes a configurable ratio from the deposited amount to set theamountTokenMinandamountETHMinarguments toaddLiquidityETH. BecauseEthUniswapPCVDepositalways deposits at the oracle price, this sets the slippage relative to the oracle, not relative to the current market ETH/FEI price. Currently the slippage is set to 1%: if the market is distorted by more than 1% relative to the oracle price, the deposit/allocation transaction reverts.
This second fix also protects Fei from market manipulation due to a sandwich attack. Merely fixing Address.isContract or the nonContract modifier would not protect against a sandwich attack on its own.
Variants to test
These are the patterns a bug hunter would look for in other projects, based on what this report teaches.
- Constructor bypass of contract checks. Look for privileged or price-sensitive functions guarded by
extcodesize-based checks such as OpenZeppelin'sAddress.isContractor anonContractmodifier. A positive result is a call to the guarded function succeeding from a contract's constructor, where a direct call from a deployed contract is rejected. - Liquidity provision with loose slippage. Find calls to
addLiquidityETHor similar DEX entry points that pass a 100% (or otherwise very loose) slippage tolerance while depositing protocol-owned funds. A positive result is a deposit executing at a rate far from the oracle price while the pool is distorted. - Market-rate versus oracle-rate deposits. Check whether protocol funds are deposited at the pool's prevailing rate rather than an oracle price. A positive result is a deposit whose size changes materially when the pool is moved with borrowed capital, with the protocol absorbing the difference.
- Sandwich exposure on deposits. Even where a contract check is fixed, test whether a deposit can be sandwiched. A positive result is a deposit that executes at a price moved by a transaction immediately before it, with no oracle-anchored minimum.
tx.originguards. Whererequire(msg.sender == tx.origin)is used as the anti-contract guard, test whether the protected path can still be reached in a way that defeats the intent, keeping in mind the report's note thattx.originmay not remain meaningful in future EVM versions.
Glossary
- Blockchain: a shared, public record of transactions kept by many computers at once.
- Smart contract: a program that runs on a blockchain and executes exactly as written.
- Function: a named action inside a program that can be called to make it do something.
- Token: a digital asset tracked by a contract, such as FEI, WETH or TRIBE.
- ETH: the native cryptocurrency of the Ethereum network.
- WETH: wrapped ETH, the same value in a form that behaves like a token.
- TRIBE: Fei Protocol's own governance token, used to pay the bounty in this case.
- Stablecoin: a token designed to hold a steady price, usually one US dollar.
- Peg: the target price a stablecoin tries to hold.
- Algorithmic stablecoin: a stablecoin kept at its peg by software rules rather than by reserves of dollars in a bank.
- Protocol Controlled Value (PCV): funds that the protocol's own contracts control, rather than any person.
- Uniswap: a decentralised exchange made of token pools, where prices come from the ratio of tokens in each pool.
- Pool: the pot of two tokens held by a Uniswap pair, from which swaps are priced.
- Liquidity provider token (LP token): a receipt for a share of a Uniswap pool, representing a pro rata claim on what is deposited there.
- Pro rata: in proportion to your share.
- Oracle: a service that reports a price from outside the blockchain, such as ETH/USD.
- Oracle price: the price reported by the oracle, as opposed to whatever a pool currently says.
- Market rate / prevailing rate: the price a market currently shows, which can be pushed around by large trades.
- Slippage: the gap between the expected price and the price actually obtained.
- Slippage tolerance: the limit on how far the executed price may drift before a transaction is cancelled; 100% means effectively no limit.
- Flash loan: a loan borrowed and repaid within a single transaction, requiring no collateral of the borrower's own.
- Transaction: one bundle of actions on a blockchain that either all succeed or all fail.
- Constructor: the code that runs once when a contract is created.
extcodesize: an instruction reporting the size of the code stored at an address; zero for wallets and for contracts still being constructed.- Modifier: a reusable check attached to a function that runs before the function body.
nonContractmodifier: the guard in this codebase meant to reject callers that are contracts.Address.isContract: an OpenZeppelin helper that usesextcodesizeto decide whether an address is a contract.- OpenZeppelin: a widely used library of reusable smart contract code.
- Solidity: the programming language these contracts are written in.
- EVM: the Ethereum Virtual Machine, the environment that runs smart contracts.
- Berlin EVM: the version of that environment current at the time of the report.
tx.origin: the original sender of a transaction, as opposed to the immediate caller of a function.- Revert: cancel a transaction and undo its effects when a check fails.
- Bonding curve: a rule that sets the price at which the protocol itself buys or sells its token.
addLiquidityETH: the Uniswap function that adds ETH and its paired token to a pool together.amountTokenMin/amountETHMin: the minimum amounts of token and ETH that a liquidity deposit will accept, which is how slippage is enforced._getMinLiquidity: the new method that computes those minimums from a configurable ratio.- Reserve stabilizer: the mechanism that maintains the price of FEI below the peg, to which bonding curve ETH is now directed.
- Sandwich attack: profiting from someone else's trade by placing transactions immediately before and after it to move the price.
- Bug bounty: a scheme where a project pays people for reporting security problems instead of exploiting them.
- Whitehat: a security researcher who reports vulnerabilities to help fix them.
- Proof of concept: a working demonstration that an attack is possible.
- GEKKO: a Python library for solving optimisation problems, used here to choose the best split of borrowed funds.
- DeFi: decentralised finance, financial software built on blockchains.