View Source: contracts/mock/MockFlashBorrower.sol
↗ Extends: IERC3156FlashBorrower
MockFlashBorrower
Constants & Variables
contract IERC20 private _stablecoin;
contract IERC3156FlashLender private _provider;
bytes32 private _returnValue;
bool private _createsApproval;
- constructor(IERC20 stablecoin, IERC3156FlashLender provider)
- setStablecoin(IERC20 value)
- setReturnValue(bytes32 value)
- setCreateApproval(bool value)
- borrow(uint256 amount, bytes data)
- onFlashLoan(address initiator, address , uint256 , uint256 , bytes )
function (IERC20 stablecoin, IERC3156FlashLender provider) public nonpayable
Arguments
Name | Type | Description |
---|---|---|
stablecoin | IERC20 | |
provider | IERC3156FlashLender |
Source Code
constructor(IERC20 stablecoin, IERC3156FlashLender provider) {
_stablecoin = stablecoin;
_provider = provider;
}
function setStablecoin(IERC20 value) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
value | IERC20 |
Source Code
function setStablecoin(IERC20 value) external {
_stablecoin = value;
}
function setReturnValue(bytes32 value) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
value | bytes32 |
Source Code
function setReturnValue(bytes32 value) external {
_returnValue = value;
}
function setCreateApproval(bool value) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
value | bool |
Source Code
function setCreateApproval(bool value) external {
_createsApproval = value;
}
function borrow(uint256 amount, bytes data) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
amount | uint256 | |
data | bytes |
Source Code
function borrow(uint256 amount, bytes calldata data) external {
uint256 allowance = _stablecoin.allowance(address(this), address(_provider));
uint256 fee = _provider.flashFee(address(_stablecoin), amount);
uint256 repayment = amount + fee;
if (_createsApproval) {
_stablecoin.approve(address(_provider), allowance + repayment);
}
_provider.flashLoan(this, address(_stablecoin), amount, data);
}
function onFlashLoan(address initiator, address , uint256 , uint256 , bytes ) external view
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
initiator | address | |
address | ||
uint256 | ||
uint256 | ||
bytes |
Source Code
function onFlashLoan(
address initiator,
address, /*token*/
uint256, /*amount*/
uint256, /*fee*/
bytes calldata /*data*/
) external view override returns (bytes32) {
require(msg.sender == address(_provider), "FlashBorrower: Untrusted lender");
require(initiator == address(this), "FlashBorrower: Untrusted loan initiator"); // solhint-disable-line
return _returnValue;
}
- AaveStrategy
- AccessControl
- AccessControlLibV1
- Address
- BaseLibV1
- BokkyPooBahsDateTimeLibrary
- BondPool
- BondPoolBase
- BondPoolLibV1
- CompoundStrategy
- Context
- Cover
- CoverBase
- CoverLibV1
- CoverReassurance
- CoverStake
- CoverUtilV1
- cxToken
- cxTokenFactory
- cxTokenFactoryLibV1
- Delayable
- Destroyable
- ERC165
- ERC20
- FakeAaveLendingPool
- FakeCompoundStablecoinDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundStablecoinDelegator
- Finalization
- ForceEther
- Governance
- GovernanceUtilV1
- IAaveV2LendingPoolLike
- IAccessControl
- IBondPool
- IClaimsProcessor
- ICompoundERC20DelegatorLike
- ICover
- ICoverReassurance
- ICoverStake
- ICxToken
- ICxTokenFactory
- IERC165
- IERC20
- IERC20Detailed
- IERC20Metadata
- IERC3156FlashBorrower
- IERC3156FlashLender
- IFinalization
- IGovernance
- ILendingStrategy
- ILiquidityEngine
- IMember
- INeptuneRouterV1
- InvalidStrategy
- IPausable
- IPolicy
- IPolicyAdmin
- IPriceOracle
- IProtocol
- IRecoverable
- IReporter
- IResolution
- IResolvable
- IStakingPools
- IStore
- IStoreLike
- IUniswapV2FactoryLike
- IUniswapV2PairLike
- IUniswapV2RouterLike
- IUnstakable
- IVault
- IVaultDelegate
- IVaultFactory
- IWitness
- LiquidityEngine
- MaliciousToken
- MockAccessControlUser
- MockCoverUtilUser
- MockCxToken
- MockCxTokenPolicy
- MockCxTokenStore
- MockFlashBorrower
- MockLiquidityEngineUser
- MockProcessorStore
- MockProcessorStoreLib
- MockProtocol
- MockRegistryClient
- MockStore
- MockStoreKeyUtilUser
- MockValidationLibUser
- MockVault
- MockVaultLibUser
- NeptuneRouterV1
- NPM
- NpmDistributor
- NTransferUtilV2
- NTransferUtilV2Intermediate
- Ownable
- Pausable
- Policy
- PolicyAdmin
- PolicyHelperV1
- PoorMansERC20
- POT
- PriceLibV1
- Processor
- ProtoBase
- Protocol
- ProtoUtilV1
- Recoverable
- ReentrancyGuard
- RegistryLibV1
- Reporter
- Resolution
- Resolvable
- RoutineInvokerLibV1
- SafeERC20
- StakingPoolBase
- StakingPoolCoreLibV1
- StakingPoolInfo
- StakingPoolLibV1
- StakingPoolReward
- StakingPools
- Store
- StoreBase
- StoreKeyUtil
- StrategyLibV1
- Strings
- TimelockController
- Unstakable
- ValidationLibV1
- Vault
- VaultBase
- VaultDelegate
- VaultDelegateBase
- VaultDelegateWithFlashLoan
- VaultFactory
- VaultFactoryLibV1
- VaultLibV1
- VaultLiquidity
- VaultStrategy
- WithFlashLoan
- WithPausability
- WithRecovery
- Witness