Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 121 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw With Fl... | 19752161 | 89 days ago | IN | 0 ETH | 0.01236239 | ||||
Withdraw With Fl... | 19714198 | 94 days ago | IN | 0 ETH | 0.01522266 | ||||
Withdraw With Fl... | 19428934 | 134 days ago | IN | 0 ETH | 0.13514894 | ||||
Withdraw With Fl... | 19102576 | 180 days ago | IN | 0 ETH | 0.0270353 | ||||
Withdraw With Fl... | 19090323 | 182 days ago | IN | 0 ETH | 0.04556736 | ||||
Withdraw With Fl... | 18537478 | 259 days ago | IN | 0 ETH | 0.13378266 | ||||
Withdraw With Fl... | 17911871 | 347 days ago | IN | 0 ETH | 0.02986971 | ||||
Zap Leverage Wit... | 17911263 | 347 days ago | IN | 0 ETH | 0.02055002 | ||||
Zap Leverage Wit... | 17890296 | 350 days ago | IN | 0 ETH | 0.02671247 | ||||
Withdraw With Fl... | 17877134 | 352 days ago | IN | 0 ETH | 0.04008731 | ||||
Withdraw With Fl... | 17809440 | 361 days ago | IN | 0 ETH | 0.03081465 | ||||
Withdraw With Fl... | 17727624 | 373 days ago | IN | 0 ETH | 0.00485716 | ||||
Withdraw With Fl... | 17727623 | 373 days ago | IN | 0 ETH | 0.05448399 | ||||
Withdraw With Fl... | 17725923 | 373 days ago | IN | 0 ETH | 0.04314609 | ||||
Withdraw With Fl... | 17714619 | 374 days ago | IN | 0 ETH | 0.05490991 | ||||
Withdraw With Fl... | 17714261 | 374 days ago | IN | 0 ETH | 0.07780038 | ||||
Withdraw With Fl... | 17703971 | 376 days ago | IN | 0 ETH | 0.04540469 | ||||
Withdraw With Fl... | 17703495 | 376 days ago | IN | 0 ETH | 0.0279923 | ||||
Withdraw With Fl... | 17698669 | 377 days ago | IN | 0 ETH | 0.04075581 | ||||
Withdraw With Fl... | 17697666 | 377 days ago | IN | 0 ETH | 0.03265533 | ||||
Withdraw With Fl... | 17694866 | 377 days ago | IN | 0 ETH | 0.03691474 | ||||
Withdraw With Fl... | 17694313 | 377 days ago | IN | 0 ETH | 0.03193098 | ||||
Withdraw With Fl... | 17694261 | 377 days ago | IN | 0 ETH | 0.03410633 | ||||
Withdraw With Fl... | 17460859 | 410 days ago | IN | 0 ETH | 0.03417396 | ||||
Withdraw With Fl... | 17460832 | 410 days ago | IN | 0 ETH | 0.03320992 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19752161 | 89 days ago | 0.26528249 ETH | ||||
19752161 | 89 days ago | 0.26528249 ETH | ||||
19752161 | 89 days ago | 3.28365695 ETH | ||||
19752161 | 89 days ago | 3.28365695 ETH | ||||
19714198 | 94 days ago | 0.10675235 ETH | ||||
19714198 | 94 days ago | 0.10675235 ETH | ||||
19714198 | 94 days ago | 0.93394474 ETH | ||||
19714198 | 94 days ago | 0.93394474 ETH | ||||
19428934 | 134 days ago | 20.55564765 ETH | ||||
19428934 | 134 days ago | 20.55564765 ETH | ||||
19428934 | 134 days ago | 128.96230463 ETH | ||||
19428934 | 134 days ago | 128.96230463 ETH | ||||
19102576 | 180 days ago | 0.19514527 ETH | ||||
19102576 | 180 days ago | 0.19514527 ETH | ||||
19102576 | 180 days ago | 2.38605981 ETH | ||||
19102576 | 180 days ago | 2.38605981 ETH | ||||
19090323 | 182 days ago | 2.09721833 ETH | ||||
19090323 | 182 days ago | 2.09721833 ETH | ||||
19090323 | 182 days ago | 20.6686016 ETH | ||||
19090323 | 182 days ago | 20.6686016 ETH | ||||
18537478 | 259 days ago | 15.09321561 ETH | ||||
18537478 | 259 days ago | 15.09321561 ETH | ||||
18537478 | 259 days ago | 111.8688342 ETH | ||||
18537478 | 259 days ago | 111.8688342 ETH | ||||
17911871 | 347 days ago | 0.00099604 ETH |
Loading...
Loading
Contract Name:
ETHSTETHLevSwap
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {GeneralLevSwap} from '../GeneralLevSwap.sol'; import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {SafeERC20} from '../../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {IWETH} from '../../../misc/interfaces/IWETH.sol'; import {PercentageMath} from '../../libraries/math/PercentageMath.sol'; import {Errors} from '../../libraries/helpers/Errors.sol'; interface ICurvePool { function coins(uint256) external view returns (address); function add_liquidity(uint256[2] memory amounts, uint256 _min_mint_amount) external payable; function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256); function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 _min_amount ) external returns (uint256); } contract ETHSTETHLevSwap is GeneralLevSwap { using SafeERC20 for IERC20; using PercentageMath for uint256; ICurvePool public constant ETHSTETH = ICurvePool(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022); address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; /** * @dev Receive ETH */ receive() external payable {} constructor( address _asset, address _vault, address _provider ) GeneralLevSwap(_asset, _vault, _provider) { ENABLED_BORROWING_ASSET[WETH] = true; } function getAvailableBorrowingAssets() external pure override returns (address[] memory assets) { assets = new address[](1); assets[0] = WETH; } /// borrowing asset -> ETHSTETH function _swapTo( address _borrowingAsset, uint256 _amount, uint256 _slippage ) internal override returns (uint256) { require(_borrowingAsset == WETH, Errors.LS_INVALID_CONFIGURATION); // WETH -> ETH IWETH(WETH).withdraw(_amount); uint256[2] memory amountsAdded; amountsAdded[0] = _amount; ETHSTETH.add_liquidity{value: _amount}(amountsAdded, 0); uint256 collateralAmount = IERC20(COLLATERAL).balanceOf(address(this)); require( collateralAmount >= _getMinAmount(_amount, _slippage, 1e18, _getAssetPrice(COLLATERAL)), Errors.LS_SUPPLY_NOT_ALLOWED ); return collateralAmount; } /// ETHSTETH -> borrowing asset function _swapFrom(address _borrowingAsset, uint256 _slippage) internal override returns (uint256) { require(_borrowingAsset == WETH, Errors.LS_INVALID_CONFIGURATION); uint256 collateralAmount = IERC20(COLLATERAL).balanceOf(address(this)); uint256 minAmount = ETHSTETH.calc_withdraw_one_coin(collateralAmount, 0); require( minAmount >= _getMinAmount(collateralAmount, _slippage, _getAssetPrice(COLLATERAL), 1e18), Errors.LS_SUPPLY_NOT_ALLOWED ); uint256 ethAmount = ETHSTETH.remove_liquidity_one_coin(collateralAmount, 0, minAmount); // ETH -> WETH IWETH(WETH).deposit{value: ethAmount}(); return ethAmount; } function _getMinAmount( uint256 _amountToSwap, uint256 _slippage, uint256 _fromAssetPrice, uint256 _toAssetPrice ) internal view returns (uint256) { return ((_amountToSwap * _fromAssetPrice) / _toAssetPrice).percentMul( PercentageMath.PERCENTAGE_FACTOR - _slippage ); } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance'); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(''); require(success, 'Address: unable to send value, recipient may have reverted'); } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {IERC20} from './IERC20.sol'; interface IERC20Detailed is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, 'ReentrancyGuard: reentrant call'); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC20} from './IERC20.sol'; import {Address} from './Address.sol'; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require( (value == 0) || (token.allowance(address(this), spender) == 0), 'SafeERC20: approve from non-zero to non-zero allowance' ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), 'SafeERC20: call to non-contract'); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, 'SafeERC20: low-level call failed'); if (returndata.length != 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), 'SafeERC20: ERC20 operation did not succeed'); } } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @title IFlashLoanReceiver interface * @notice Interface for the IFlashLoanReceiver. * @author Sturdy * @dev implement this interface to develop a flashloan-compatible flashLoanReceiver contract **/ interface IFlashLoanReceiver { function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; /** * @title IFlashLoanRecipient interface * @notice Interface for the IFlashLoanRecipient. * @author Sturdy * @dev implement this interface to develop a flashloan-compatible IFlashLoanRecipient contract **/ interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; interface IAaveFlashLoan { /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; import {IInitializableAToken} from './IInitializableAToken.sol'; import {ISturdyIncentivesController} from './ISturdyIncentivesController.sol'; interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken { /** * @dev Emitted after the mint action * @param from The address performing the mint * @param value The amount being * @param index The new liquidity index of the reserve **/ event Mint(address indexed from, uint256 value, uint256 index); /** * @dev Mints `amount` aTokens to `user` * @param user The address receiving the minted tokens * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve * @return `true` if the the previous balance of the user was 0 */ function mint( address user, uint256 amount, uint256 index ) external payable returns (bool); /** * @dev Emitted after aTokens are burned * @param from The owner of the aTokens, getting them burned * @param target The address that will receive the underlying * @param value The amount being burned * @param index The new liquidity index of the reserve **/ event Burn(address indexed from, address indexed target, uint256 value, uint256 index); /** * @dev Emitted during the transfer action * @param from The user whose tokens are being transferred * @param to The recipient * @param value The amount being transferred * @param index The new liquidity index of the reserve **/ event BalanceTransfer(address indexed from, address indexed to, uint256 value, uint256 index); /** * @dev Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * @param user The owner of the aTokens, getting them burned * @param receiverOfUnderlying The address that will receive the underlying * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn( address user, address receiverOfUnderlying, uint256 amount, uint256 index ) external payable; /** * @dev Mints aTokens to the reserve treasury * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve */ function mintToTreasury(uint256 amount, uint256 index) external payable; /** * @dev Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken * @param from The address getting liquidated, current owner of the aTokens * @param to The recipient * @param value The amount of tokens getting transferred **/ function transferOnLiquidation( address from, address to, uint256 value ) external payable; /** * @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer * assets in borrow(), withdraw() and flashLoan() * @param user The recipient of the underlying * @param amount The amount getting transferred * @return The amount transferred **/ function transferUnderlyingTo(address user, uint256 amount) external payable returns (uint256); /** * @dev Invoked to execute actions on the aToken side after a repayment. * @param user The user executing the repayment * @param amount The amount getting repaid **/ function handleRepayment(address user, uint256 amount) external; /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (ISturdyIncentivesController); /** * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) **/ function UNDERLYING_ASSET_ADDRESS() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; interface IBalancerVault { // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; address assetIn; address assetOut; uint256 amount; bytes userData; } /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { address[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT } function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { address[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT } function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); function getPoolTokens(bytes32 poolId) external view returns ( address[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, address[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); function flashLoan( address recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; interface IGeneralVault { function pricePerShare() external view returns (uint256); function withdrawOnLiquidation(address _asset, uint256 _amount) external returns (uint256); function convertOnLiquidation(address _assetOut, uint256 _amountIn) external; function processYield() external; function setTreasuryInfo(address _treasury, uint256 _fee) external; function depositCollateral(address _asset, uint256 _amount) external payable; function depositCollateralFrom( address _asset, uint256 _amount, address _user ) external payable; function withdrawCollateral( address _asset, uint256 _amount, uint256 _slippage, address _to ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {ILendingPool} from './ILendingPool.sol'; import {ISturdyIncentivesController} from './ISturdyIncentivesController.sol'; /** * @title IInitializableAToken * @notice Interface for the initialize function on AToken * @author Sturdy, inspiration from Aave **/ interface IInitializableAToken { /** * @dev Emitted when an aToken is initialized * @param underlyingAsset The address of the underlying asset * @param pool The address of the associated lending pool * @param treasury The address of the treasury * @param incentivesController The address of the incentives controller for this aToken * @param aTokenDecimals the decimals of the underlying * @param aTokenName the name of the aToken * @param aTokenSymbol the symbol of the aToken * @param params A set of encoded parameters for additional initialization **/ event Initialized( address indexed underlyingAsset, address indexed pool, address treasury, address incentivesController, uint8 aTokenDecimals, string aTokenName, string aTokenSymbol, bytes params ); /** * @dev Initializes the aToken * @param pool The address of the lending pool where this aToken will be used * @param treasury The address of the Sturdy treasury, receiving the fees on this aToken * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) * @param incentivesController The smart contract managing potential incentives distribution * @param aTokenDecimals The decimals of the aToken, same as the underlying asset's * @param aTokenName The name of the aToken * @param aTokenSymbol The symbol of the aToken */ function initialize( ILendingPool pool, address treasury, address underlyingAsset, ISturdyIncentivesController incentivesController, uint8 aTokenDecimals, string calldata aTokenName, string calldata aTokenSymbol, bytes calldata params ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; interface ILendingPool { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount ); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * - Caller is anyone. * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Deposits an `amount` of underlying asset into the reserve for supplier from vault * - Caller is only Vault which is registered in this contract * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited **/ function depositYield(address asset, uint256 amount) external; /** * @dev Grab an Yield `amount` of underlying asset into the vault * - Caller is only Vault which is registered in this contract * @param asset The address of the underlying asset to get yield * @param amount The yield amount **/ function getYield(address asset, uint256 amount) external; /** * @dev Get underlying asset and aToken's total balance * @param asset The address of the underlying asset **/ function getTotalBalanceOfAssetPair(address asset) external view returns (uint256, uint256); /** * @dev Get total underlying asset which is borrowable * and also list of underlying asset **/ function getBorrowingAssetAndVolumes() external view returns ( uint256, uint256[] memory, address[] memory, uint256 ); /** * @dev Register the vault address * - To check if the caller is vault for some functions * - Caller is only LendingPoolConfigurator * @param _vaultAddress The address of the Vault **/ function registerVault(address _vaultAddress) external payable; /** * @dev Unregister the vault address * - To check if the caller is vault for some functions * - Caller is only LendingPoolConfigurator * @param _vaultAddress The address of the Vault **/ function unregisterVault(address _vaultAddress) external payable; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * - Caller is anyone * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * - Caller is anyone * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param from The address of user who is depositor of underlying asset * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdrawFrom( address asset, uint256 amount, address from, address to ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * - Caller is anyone * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * - Caller is anyone * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external returns (uint256); /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * - Caller is anyone * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); /** * @dev Initializes a reserve, activating it, assigning an aToken and debt tokens and an * interest rate strategy * - Only callable by the LendingPoolConfigurator contract * - Caller is only LendingPoolConfigurator * @param reserve The address of the underlying asset of the reserve * @param yieldAddress The address of the underlying asset's yield contract of the reserve * @param aTokenAddress The address of the aToken that will be assigned to the reserve * @param stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve * @param variableDebtAddress The address of the VariableDebtToken that will be assigned to the reserve * @param interestRateStrategyAddress The address of the interest rate strategy contract **/ function initReserve( address reserve, address yieldAddress, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external payable; /** * @dev Updates the address of the interest rate strategy contract * - Caller is only LendingPoolConfigurator * @param reserve The address of the underlying asset of the reserve * @param rateStrategyAddress The address of the interest rate strategy contract **/ function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external payable; /** * @dev Sets the configuration bitmap of the reserve as a whole * - Caller is only LendingPoolConfigurator * @param reserve The address of the underlying asset of the reserve * @param configuration The new configuration bitmap **/ function setConfiguration(address reserve, uint256 configuration) external payable; /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); /** * @dev Validates and finalizes an aToken transfer * - Only callable by the overlying aToken of the `asset` * - Caller is only aToken contract which is storing the underlying asset of depositors * @param asset The address of the underlying asset of the aToken * @param from The user from which the aTokens are transferred * @param to The user receiving the aTokens * @param amount The amount being transferred/withdrawn * @param balanceFromAfter The aToken balance of the `from` user before the transfer * @param balanceToBefore The aToken balance of the `to` user before the transfer */ function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; /** * @dev Returns the list of the initialized reserves **/ function getReservesList() external view returns (address[] memory); /** * @dev Returns the cached LendingPoolAddressesProvider connected to this contract **/ function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); /** * @dev Set the _pause state of a reserve * - Caller is only LendingPoolConfigurator * @param val `true` to pause the reserve, `false` to un-pause it */ function setPause(bool val) external payable; /** * @dev Returns if the LendingPool is paused */ function paused() external view returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Sturdy Governance * @author Sturdy, inspiration from Aave **/ interface ILendingPoolAddressesProvider { event MarketIdSet(string newMarketId); event LendingPoolUpdated(address indexed newAddress); event IncentiveControllerUpdated(address indexed newAddress); event IncentiveTokenUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external payable; function setAddress(bytes32 id, address newAddress) external payable; function setAddressAsProxy(bytes32 id, address impl) external payable; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external payable; function getIncentiveController() external view returns (address); function setIncentiveControllerImpl(address incentiveController) external payable; function getIncentiveToken() external view returns (address); function setIncentiveTokenImpl(address incentiveToken) external payable; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external payable; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external payable; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external payable; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external payable; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external payable; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external payable; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @title IPriceOracleGetter interface * @notice Interface for the Sturdy price oracle. **/ interface IPriceOracleGetter { /** * @dev returns the asset price in ETH * @param asset the address of the asset * @return the ETH price of the asset **/ function getAssetPrice(address asset) external view returns (uint256); /** * @dev Validate the oracle * @param asset the address of the asset **/ function checkOracle(address asset) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; interface IScaledBalanceToken { /** * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the * updated stored balance divided by the reserve's liquidity index at the moment of the update * @param user The user whose balance is calculated * @return The scaled balance of the user **/ function scaledBalanceOf(address user) external view returns (uint256); /** * @dev Returns the scaled balance of the user and the scaled total supply. * @param user The address of the user * @return The scaled balance of the user * @return The scaled balance and the scaled total supply **/ function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256); /** * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) * @return The scaled total supply **/ function scaledTotalSupply() external view returns (uint256); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; interface ISturdyIncentivesController { event RewardsAccrued(address indexed user, uint256 amount); event RewardsClaimed(address indexed user, address indexed to, uint256 amount); event RewardsClaimed( address indexed user, address indexed to, address indexed claimer, uint256 amount ); event ClaimerSet(address indexed user, address indexed claimer); /* * @dev Returns the configuration of the distribution for a certain asset * @param asset The address of the reference asset of the distribution * @return The asset index, the emission per second and the last updated timestamp **/ function getAssetData(address asset) external view returns ( uint256, uint256, uint256 ); /** * @dev Whitelists an address to claim the rewards on behalf of another address * @param user The address of the user * @param claimer The address of the claimer */ function setClaimer(address user, address claimer) external payable; /** * @dev Returns the whitelisted claimer for a certain address (0x0 if not set) * @param user The address of the user * @return The claimer address */ function getClaimer(address user) external view returns (address); /** * @dev Configure assets for a certain rewards emission * @param assets The assets to incentivize * @param emissionsPerSecond The emission for each asset */ function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond) external payable; /** * @dev Called by the corresponding asset on any update that affects the rewards distribution * @param user The address of the user * @param userBalance The balance of the user of the asset in the lending pool * @param totalSupply The total supply of the asset in the lending pool **/ function handleAction( address user, uint256 totalSupply, uint256 userBalance ) external; /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. The caller must * be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager * @param amount Amount of rewards to claim * @param user Address to check and claim rewards * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewardsOnBehalf( address[] calldata assets, uint256 amount, address user, address to ) external returns (uint256); /** * @dev returns the unclaimed rewards of the user * @param user the address of the user * @return the unclaimed user rewards */ function getUserUnclaimedRewards(address user) external view returns (uint256); /** * @dev returns the unclaimed rewards of the user * @param user the address of the user * @param asset The asset to incentivize * @return the user index for the asset */ function getUserAssetData(address user, address asset) external view returns (uint256); /** * @dev for backward compatibility with previous implementation of the Incentives controller */ function REWARD_TOKEN() external view returns (address); /** * @dev for backward compatibility with previous implementation of the Incentives controller */ function PRECISION() external view returns (uint8); /** * @dev Gets the distribution end timestamp of the emissions */ function DISTRIBUTION_END() external view returns (uint256); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function withdraw(uint256) external; function approve(address guy, uint256 wad) external returns (bool); function transferFrom( address src, address dst, uint256 wad ) external returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {ReentrancyGuard} from '../../dependencies/openzeppelin/contracts/ReentrancyGuard.sol'; import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; import {ILendingPool} from '../../interfaces/ILendingPool.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; import {PercentageMath} from '../libraries/math/PercentageMath.sol'; import {IGeneralVault} from '../../interfaces/IGeneralVault.sol'; import {IAToken} from '../../interfaces/IAToken.sol'; import {IFlashLoanReceiver} from '../../flashloan/interfaces/IFlashLoanReceiver.sol'; import {IFlashLoanRecipient} from '../../flashloan/interfaces/IFlashLoanRecipient.sol'; import {IAaveFlashLoan} from '../../interfaces/IAaveFlashLoan.sol'; import {IBalancerVault} from '../../interfaces/IBalancerVault.sol'; import {DataTypes} from '../libraries/types/DataTypes.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; import {Math} from '../../dependencies/openzeppelin/contracts/Math.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; abstract contract GeneralLevSwap is IFlashLoanReceiver, IFlashLoanRecipient, ReentrancyGuard { using SafeERC20 for IERC20; using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; using WadRayMath for uint256; enum FlashLoanType { AAVE, BALANCER } uint256 private constant SAFE_BUFFER = 5000; uint256 private constant USE_VARIABLE_DEBT = 2; address private constant AAVE_LENDING_POOL_ADDRESS = 0x7937D4799803FbBe595ed57278Bc4cA21f3bFfCB; address internal constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; address public immutable COLLATERAL; // The address of external asset uint256 public immutable DECIMALS; // The collateral decimals address public immutable VAULT; // The address of vault ILendingPoolAddressesProvider internal immutable PROVIDER; IPriceOracleGetter internal immutable ORACLE; ILendingPool internal immutable LENDING_POOL; mapping(address => bool) internal ENABLED_BORROWING_ASSET; //1 == not inExec //2 == inExec; //setting default to 1 to save some gas. uint256 private _balancerFlashLoanLock = 1; /** * @param _asset The external asset ex. wFTM * @param _vault The deployed vault address * @param _provider The deployed AddressProvider */ constructor( address _asset, address _vault, address _provider ) { require( _asset != address(0) && _provider != address(0) && _vault != address(0), Errors.LS_INVALID_CONFIGURATION ); COLLATERAL = _asset; DECIMALS = IERC20Detailed(_asset).decimals(); VAULT = _vault; PROVIDER = ILendingPoolAddressesProvider(_provider); ORACLE = IPriceOracleGetter(PROVIDER.getPriceOracle()); LENDING_POOL = ILendingPool(PROVIDER.getLendingPool()); } /** * Get available assets to borrow */ function getAvailableBorrowingAssets() external pure virtual returns (address[] memory) { return new address[](0); } function _getAssetPrice(address _asset) internal view returns (uint256) { return ORACLE.getAssetPrice(_asset); } /** * This function is called after your contract has received the flash loaned amount * overriding executeOperation() in IFlashLoanReceiver */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override returns (bool) { require(initiator == address(this), Errors.LS_INVALID_CONFIGURATION); require(msg.sender == AAVE_LENDING_POOL_ADDRESS, Errors.LS_INVALID_CONFIGURATION); require(assets.length == amounts.length, Errors.LS_INVALID_CONFIGURATION); require(assets.length == premiums.length, Errors.LS_INVALID_CONFIGURATION); require(amounts[0] > 0, Errors.LS_INVALID_CONFIGURATION); require(assets[0] != address(0), Errors.LS_INVALID_CONFIGURATION); _executeOperation(assets[0], amounts[0], premiums[0], params); // approve the Aave LendingPool contract allowance to *pull* the owed amount IERC20(assets[0]).safeApprove(AAVE_LENDING_POOL_ADDRESS, 0); IERC20(assets[0]).safeApprove(AAVE_LENDING_POOL_ADDRESS, amounts[0] + premiums[0]); return true; } /** * This function is called after your contract has received the flash loaned amount * overriding receiveFlashLoan() in IFlashLoanRecipient */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external override { require(msg.sender == BALANCER_VAULT, Errors.LS_INVALID_CONFIGURATION); require(_balancerFlashLoanLock == 2, Errors.LS_INVALID_CONFIGURATION); require(tokens.length == amounts.length, Errors.LS_INVALID_CONFIGURATION); require(tokens.length == feeAmounts.length, Errors.LS_INVALID_CONFIGURATION); require(amounts[0] > 0, Errors.LS_INVALID_CONFIGURATION); require(address(tokens[0]) != address(0), Errors.LS_INVALID_CONFIGURATION); _balancerFlashLoanLock = 1; _executeOperation(address(tokens[0]), amounts[0], feeAmounts[0], userData); // send tokens to Balancer vault contract IERC20(tokens[0]).safeTransfer(msg.sender, amounts[0] + feeAmounts[0]); } function _executeOperation( address asset, uint256 borrowAmount, uint256 fee, bytes memory params ) internal { // parse params (bool isEnterPosition, uint256 slippage, uint256 amount, address user, address sAsset) = abi .decode(params, (bool, uint256, uint256, address, address)); require(slippage > 0, Errors.LS_INVALID_CONFIGURATION); require(amount > 0, Errors.LS_INVALID_CONFIGURATION); require(user != address(0), Errors.LS_INVALID_CONFIGURATION); if (isEnterPosition) { _enterPositionWithFlashloan(slippage, amount, user, asset, borrowAmount, fee); } else { require(sAsset != address(0), Errors.LS_INVALID_CONFIGURATION); _withdrawWithFlashloan(slippage, amount, user, sAsset, asset, borrowAmount); } } /** * @param _principal - The amount of collateral * @param _leverage - Extra leverage value and must be greater than 0, ex. 300% = 300_00 * _principal + _principal * _leverage should be used as collateral * @param _slippage - Slippage valule to borrow enough asset by flashloan, * Must be greater than 0%. * Borrowing amount = _principal * _leverage * _slippage * @param _borrowingAsset - The borrowing asset address when leverage works */ function enterPositionWithFlashloan( uint256 _principal, uint256 _leverage, uint256 _slippage, address _borrowingAsset, FlashLoanType _flashLoanType ) external nonReentrant { require(_principal != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_leverage != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_slippage != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_leverage < 900_00, Errors.LS_INVALID_CONFIGURATION); require(_borrowingAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require(ENABLED_BORROWING_ASSET[_borrowingAsset], Errors.LS_BORROWING_ASSET_NOT_SUPPORTED); require(IERC20(COLLATERAL).balanceOf(msg.sender) >= _principal, Errors.LS_SUPPLY_NOT_ALLOWED); IERC20(COLLATERAL).safeTransferFrom(msg.sender, address(this), _principal); _leverageWithFlashloan( msg.sender, _principal, _leverage, _slippage, _borrowingAsset, _flashLoanType ); } /** * @param _repayAmount - The amount of repay * @param _requiredAmount - The amount of collateral * @param _slippage - The slippage of the every withdrawal amount. 1% = 100 * @param _borrowingAsset - The borrowing asset address when leverage works * @param _sAsset - staked asset address of collateral internal asset */ function withdrawWithFlashloan( uint256 _repayAmount, uint256 _requiredAmount, uint256 _slippage, address _borrowingAsset, address _sAsset, FlashLoanType _flashLoanType ) external nonReentrant { require(_repayAmount > 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_requiredAmount > 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_slippage > 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_borrowingAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require(ENABLED_BORROWING_ASSET[_borrowingAsset], Errors.LS_BORROWING_ASSET_NOT_SUPPORTED); require(_sAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require( _sAsset == LENDING_POOL.getReserveData(IAToken(_sAsset).UNDERLYING_ASSET_ADDRESS()).aTokenAddress, Errors.LS_INVALID_CONFIGURATION ); uint256 debtAmount = _getDebtAmount( LENDING_POOL.getReserveData(_borrowingAsset).variableDebtTokenAddress, msg.sender ); uint256[] memory amounts = new uint256[](1); amounts[0] = Math.min(_repayAmount, debtAmount); bytes memory params = abi.encode( false, /*leavePosition*/ _slippage, _requiredAmount, msg.sender, _sAsset ); if (_flashLoanType == FlashLoanType.AAVE) { // 0 means revert the transaction if not validated uint256[] memory modes = new uint256[](1); modes[0] = 0; address[] memory assets = new address[](1); assets[0] = _borrowingAsset; IAaveFlashLoan(AAVE_LENDING_POOL_ADDRESS).flashLoan( address(this), assets, amounts, modes, address(this), params, 0 ); } else { require(_balancerFlashLoanLock == 1, Errors.LS_INVALID_CONFIGURATION); IERC20[] memory assets = new IERC20[](1); assets[0] = IERC20(_borrowingAsset); _balancerFlashLoanLock = 2; IBalancerVault(BALANCER_VAULT).flashLoan(address(this), assets, amounts, params); } // remaining borrowing asset -> collateral _swapTo(_borrowingAsset, IERC20(_borrowingAsset).balanceOf(address(this)), _slippage); uint256 collateralAmount = IERC20(COLLATERAL).balanceOf(address(this)); if (collateralAmount > _requiredAmount) { _supply(collateralAmount - _requiredAmount, msg.sender); collateralAmount = _requiredAmount; } // finally deliver the collateral to user IERC20(COLLATERAL).safeTransfer(msg.sender, collateralAmount); } function _enterPositionWithFlashloan( uint256 _slippage, uint256 _minAmount, address _user, address _borrowingAsset, uint256 _borrowedAmount, uint256 _fee ) internal { //swap borrowing asset to collateral uint256 collateralAmount = _swapTo(_borrowingAsset, _borrowedAmount, _slippage); require(collateralAmount >= _minAmount, Errors.LS_SUPPLY_FAILED); //deposit collateral _supply(collateralAmount, _user); //borrow borrowing asset _borrow(_borrowingAsset, _borrowedAmount + _fee, _user); } function _withdrawWithFlashloan( uint256 _slippage, uint256 _requiredAmount, address _user, address _sAsset, address _borrowingAsset, uint256 _borrowedAmount ) internal { // repay _repay(_borrowingAsset, _borrowedAmount, _user); // withdraw collateral // get internal asset address address internalAsset = IAToken(_sAsset).UNDERLYING_ASSET_ADDRESS(); // get reserve info of internal asset DataTypes.ReserveConfigurationMap memory configuration = LENDING_POOL.getConfiguration( internalAsset ); (, uint256 assetLiquidationThreshold, , , ) = configuration.getParamsMemory(); require(assetLiquidationThreshold != 0, Errors.LS_INVALID_CONFIGURATION); // get user info ( uint256 totalCollateralETH, uint256 totalDebtETH, , uint256 currentLiquidationThreshold, , ) = LENDING_POOL.getUserAccountData(_user); uint256 withdrawalAmountETH = (((totalCollateralETH * currentLiquidationThreshold) / PercentageMath.PERCENTAGE_FACTOR - totalDebtETH) * PercentageMath.PERCENTAGE_FACTOR) / assetLiquidationThreshold; uint256 withdrawalAmount = Math.min( IERC20(_sAsset).balanceOf(_user), (withdrawalAmountETH * (10**DECIMALS)) / _getAssetPrice(COLLATERAL) ); require(withdrawalAmount >= _requiredAmount, Errors.LS_SUPPLY_NOT_ALLOWED); IERC20(_sAsset).safeTransferFrom(_user, address(this), withdrawalAmount); _remove(withdrawalAmount, _slippage); // collateral -> borrowing asset _swapFrom(_borrowingAsset, _slippage); } function _supply(uint256 _amount, address _user) internal { IERC20(COLLATERAL).safeApprove(VAULT, _amount); IGeneralVault(VAULT).depositCollateralFrom(COLLATERAL, _amount, _user); } function _remove(uint256 _amount, uint256 _slippage) internal { IGeneralVault(VAULT).withdrawCollateral(COLLATERAL, _amount, _slippage, address(this)); } function _getDebtAmount(address _variableDebtTokenAddress, address _user) internal view returns (uint256) { return IERC20(_variableDebtTokenAddress).balanceOf(_user); } function _borrow( address _borrowingAsset, uint256 _amount, address borrower ) internal { LENDING_POOL.borrow(_borrowingAsset, _amount, USE_VARIABLE_DEBT, 0, borrower); } function _repay( address _borrowingAsset, uint256 _amount, address borrower ) internal { IERC20(_borrowingAsset).safeApprove(address(LENDING_POOL), 0); IERC20(_borrowingAsset).safeApprove(address(LENDING_POOL), _amount); uint256 paybackAmount = LENDING_POOL.repay( _borrowingAsset, _amount, USE_VARIABLE_DEBT, borrower ); require(paybackAmount > 0, Errors.LS_REPAY_FAILED); } function _swapTo( address, uint256, uint256 ) internal virtual returns (uint256); function _swapFrom(address, uint256) internal virtual returns (uint256); /** * @param _zappingAsset - The borrowable asset address which will zap into lp token * @param _principal - The amount of collateral * @param _slippage - Slippage value to zap deposit, Must be greater than 0%. */ function zapDeposit( address _zappingAsset, uint256 _principal, uint256 _slippage ) external nonReentrant { require(_principal != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_zappingAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require(ENABLED_BORROWING_ASSET[_zappingAsset], Errors.LS_BORROWING_ASSET_NOT_SUPPORTED); require( IERC20(_zappingAsset).balanceOf(msg.sender) >= _principal, Errors.LS_SUPPLY_NOT_ALLOWED ); IERC20(_zappingAsset).safeTransferFrom(msg.sender, address(this), _principal); uint256 suppliedAmount = _swapTo(_zappingAsset, _principal, _slippage); // supply to LP _supply(suppliedAmount, msg.sender); } /** * @param _zappingAsset - The borrowable asset address which will zap into lp token * @param _principal - The amount of the borrowable asset * @param _leverage - Extra leverage value and must be greater than 0, ex. 300% = 300_00 * principal + principal * leverage should be used as collateral * @param _slippage - Slippage value to borrow enough asset by flashloan, * Must be greater than 0%. * Borrowing amount = principal * leverage * slippage * @param _borrowAsset - The borrowing asset address when leverage works */ function zapLeverageWithFlashloan( address _zappingAsset, uint256 _principal, uint256 _leverage, uint256 _slippage, address _borrowAsset, FlashLoanType _flashLoanType ) external nonReentrant { require(_principal != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_leverage != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_slippage != 0, Errors.LS_SWAP_AMOUNT_NOT_GT_0); require(_leverage < 900_00, Errors.LS_INVALID_CONFIGURATION); require(_borrowAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require(_zappingAsset != address(0), Errors.LS_INVALID_CONFIGURATION); require(ENABLED_BORROWING_ASSET[_zappingAsset], Errors.LS_BORROWING_ASSET_NOT_SUPPORTED); require(ENABLED_BORROWING_ASSET[_borrowAsset], Errors.LS_BORROWING_ASSET_NOT_SUPPORTED); require( IERC20(_zappingAsset).balanceOf(msg.sender) >= _principal, Errors.LS_SUPPLY_NOT_ALLOWED ); IERC20(_zappingAsset).safeTransferFrom(msg.sender, address(this), _principal); uint256 collateralAmount = _swapTo(_zappingAsset, _principal, _slippage); _leverageWithFlashloan( msg.sender, collateralAmount, _leverage, _slippage, _borrowAsset, _flashLoanType ); } function _leverageWithFlashloan( address _user, uint256 _principal, uint256 _leverage, uint256 _slippage, address _borrowAsset, FlashLoanType _flashLoanType ) internal { uint256 borrowAssetDecimals = IERC20Detailed(_borrowAsset).decimals(); uint256[] memory amounts = new uint256[](1); amounts[0] = ((((_principal * _getAssetPrice(COLLATERAL)) / 10**DECIMALS) * 10**borrowAssetDecimals) / _getAssetPrice(_borrowAsset)).percentMul(_leverage).percentMul( PercentageMath.PERCENTAGE_FACTOR + _slippage ); uint256 minCollateralAmount = _principal.percentMul( PercentageMath.PERCENTAGE_FACTOR + _leverage ); bytes memory params = abi.encode( true, /*enterPosition*/ _slippage, minCollateralAmount, _user, address(0) ); if (_flashLoanType == FlashLoanType.AAVE) { // 0 means revert the transaction if not validated uint256[] memory modes = new uint256[](1); modes[0] = 0; address[] memory assets = new address[](1); assets[0] = _borrowAsset; IAaveFlashLoan(AAVE_LENDING_POOL_ADDRESS).flashLoan( address(this), assets, amounts, modes, address(this), params, 0 ); } else { require(_balancerFlashLoanLock == 1, Errors.LS_INVALID_CONFIGURATION); IERC20[] memory assets = new IERC20[](1); assets[0] = IERC20(_borrowAsset); _balancerFlashLoanLock = 2; IBalancerVault(BALANCER_VAULT).flashLoan(address(this), assets, amounts, params); } } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {Errors} from '../helpers/Errors.sol'; import {DataTypes} from '../types/DataTypes.sol'; /** * @title ReserveConfiguration library * @author Sturdy, inspiration from Aave * @notice Implements the bitmap logic to handle the reserve configuration */ library ReserveConfiguration { uint256 constant LTV_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000; // prettier-ignore uint256 constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFF; // prettier-ignore uint256 constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF; // prettier-ignore uint256 constant DECIMALS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF; // prettier-ignore uint256 constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF; // prettier-ignore uint256 constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF; // prettier-ignore uint256 constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore uint256 constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore uint256 constant COLLATERAL_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFF; // prettier-ignore /// @dev For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16; uint256 constant LIQUIDATION_BONUS_START_BIT_POSITION = 32; uint256 constant RESERVE_DECIMALS_START_BIT_POSITION = 48; uint256 constant IS_ACTIVE_START_BIT_POSITION = 56; uint256 constant IS_FROZEN_START_BIT_POSITION = 57; uint256 constant BORROWING_ENABLED_START_BIT_POSITION = 58; uint256 constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59; uint256 constant COLLATERAL_ENABLED_START_BIT_POSITION = 60; uint256 constant RESERVE_FACTOR_START_BIT_POSITION = 64; uint256 constant MAX_VALID_LTV = 65535; uint256 constant MAX_VALID_LIQUIDATION_THRESHOLD = 65535; uint256 constant MAX_VALID_LIQUIDATION_BONUS = 65535; uint256 constant MAX_VALID_DECIMALS = 255; uint256 constant MAX_VALID_RESERVE_FACTOR = 65535; /** * @dev Sets the Loan to Value of the reserve * @param self The reserve configuration * @param ltv the new ltv **/ function setLtv(DataTypes.ReserveConfigurationMap memory self, uint256 ltv) internal pure { require(ltv <= MAX_VALID_LTV, Errors.RC_INVALID_LTV); self.data = (self.data & LTV_MASK) | ltv; } /** * @dev Gets the Loan to Value of the reserve * @param self The reserve configuration * @return The loan to value **/ function getLtv(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return self.data & ~LTV_MASK; } /** * @dev Sets the liquidation threshold of the reserve * @param self The reserve configuration * @param threshold The new liquidation threshold **/ function setLiquidationThreshold(DataTypes.ReserveConfigurationMap memory self, uint256 threshold) internal pure { require(threshold <= MAX_VALID_LIQUIDATION_THRESHOLD, Errors.RC_INVALID_LIQ_THRESHOLD); self.data = (self.data & LIQUIDATION_THRESHOLD_MASK) | (threshold << LIQUIDATION_THRESHOLD_START_BIT_POSITION); } /** * @dev Gets the liquidation threshold of the reserve * @param self The reserve configuration * @return The liquidation threshold **/ function getLiquidationThreshold(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION; } /** * @dev Sets the liquidation bonus of the reserve * @param self The reserve configuration * @param bonus The new liquidation bonus **/ function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus) internal pure { require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS); self.data = (self.data & LIQUIDATION_BONUS_MASK) | (bonus << LIQUIDATION_BONUS_START_BIT_POSITION); } /** * @dev Gets the liquidation bonus of the reserve * @param self The reserve configuration * @return The liquidation bonus **/ function getLiquidationBonus(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION; } /** * @dev Sets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @param decimals The decimals **/ function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals) internal pure { require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS); self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION); } /** * @dev Gets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @return The decimals of the asset **/ function getDecimals(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION; } /** * @dev Sets the active state of the reserve * @param self The reserve configuration * @param active The active state **/ function setActive(DataTypes.ReserveConfigurationMap memory self, bool active) internal pure { self.data = (self.data & ACTIVE_MASK) | (uint256(active ? 1 : 0) << IS_ACTIVE_START_BIT_POSITION); } /** * @dev Gets the active state of the reserve * @param self The reserve configuration * @return The active state **/ function getActive(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~ACTIVE_MASK) != 0; } /** * @dev Sets the frozen state of the reserve * @param self The reserve configuration * @param frozen The frozen state **/ function setFrozen(DataTypes.ReserveConfigurationMap memory self, bool frozen) internal pure { self.data = (self.data & FROZEN_MASK) | (uint256(frozen ? 1 : 0) << IS_FROZEN_START_BIT_POSITION); } /** * @dev Gets the frozen state of the reserve * @param self The reserve configuration * @return The frozen state **/ function getFrozen(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~FROZEN_MASK) != 0; } /** * @dev Enables or disables borrowing on the reserve * @param self The reserve configuration * @param enabled True if the borrowing needs to be enabled, false otherwise **/ function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure { self.data = (self.data & BORROWING_MASK) | (uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION); } /** * @dev Gets the borrowing state of the reserve * @param self The reserve configuration * @return The borrowing state **/ function getBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~BORROWING_MASK) != 0; } /** * @dev Sets the collateral state of the reserve * @param self The reserve configuration * @param enabled The collateral state **/ function setCollateralEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure { self.data = (self.data & COLLATERAL_MASK) | (uint256(enabled ? 1 : 0) << COLLATERAL_ENABLED_START_BIT_POSITION); } /** * @dev Gets the collateral state of the reserve * @param self The reserve configuration * @return The collateral state **/ function getCollateralEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~COLLATERAL_MASK) != 0; } /** * @dev Enables or disables stable rate borrowing on the reserve * @param self The reserve configuration * @param enabled True if the stable rate borrowing needs to be enabled, false otherwise **/ function setStableRateBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self, bool enabled ) internal pure { self.data = (self.data & STABLE_BORROWING_MASK) | (uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION); } /** * @dev Gets the stable rate borrowing state of the reserve * @param self The reserve configuration * @return The stable rate borrowing state **/ function getStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~STABLE_BORROWING_MASK) != 0; } /** * @dev Sets the reserve factor of the reserve * @param self The reserve configuration * @param reserveFactor The reserve factor **/ function setReserveFactor(DataTypes.ReserveConfigurationMap memory self, uint256 reserveFactor) internal pure { require(reserveFactor <= MAX_VALID_RESERVE_FACTOR, Errors.RC_INVALID_RESERVE_FACTOR); self.data = (self.data & RESERVE_FACTOR_MASK) | (reserveFactor << RESERVE_FACTOR_START_BIT_POSITION); } /** * @dev Gets the reserve factor of the reserve * @param self The reserve configuration * @return The reserve factor **/ function getReserveFactor(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION; } /** * @dev Gets the configuration flags of the reserve * @param self The reserve configuration * @return The state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled, collateral enabled **/ function getFlags(DataTypes.ReserveConfigurationMap storage self) internal view returns ( bool, bool, bool, bool, bool ) { uint256 dataLocal = self.data; return ( (dataLocal & ~ACTIVE_MASK) != 0, (dataLocal & ~FROZEN_MASK) != 0, (dataLocal & ~BORROWING_MASK) != 0, (dataLocal & ~STABLE_BORROWING_MASK) != 0, (dataLocal & ~COLLATERAL_MASK) != 0 ); } /** * @dev Gets the configuration paramters of the reserve * @param self The reserve configuration * @return The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals **/ function getParams(DataTypes.ReserveConfigurationMap storage self) internal view returns ( uint256, uint256, uint256, uint256, uint256 ) { uint256 dataLocal = self.data; return ( dataLocal & ~LTV_MASK, (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); } /** * @dev Gets the configuration paramters of the reserve from a memory object * @param self The reserve configuration * @return The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals **/ function getParamsMemory(DataTypes.ReserveConfigurationMap memory self) internal pure returns ( uint256, uint256, uint256, uint256, uint256 ) { return ( self.data & ~LTV_MASK, (self.data & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (self.data & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); } /** * @dev Gets the configuration flags of the reserve from a memory object * @param self The reserve configuration * @return The state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled, collateral enabled **/ function getFlagsMemory(DataTypes.ReserveConfigurationMap memory self) internal pure returns ( bool, bool, bool, bool, bool ) { return ( (self.data & ~ACTIVE_MASK) != 0, (self.data & ~FROZEN_MASK) != 0, (self.data & ~BORROWING_MASK) != 0, (self.data & ~STABLE_BORROWING_MASK) != 0, (self.data & ~COLLATERAL_MASK) != 0 ); } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; /** * @title Errors library * @author Sturdy, inspiration from Aave * @notice Defines the error messages emitted by the different contracts of the Sturdy protocol * @dev Error messages prefix glossary: * - VL = ValidationLogic * - MATH = Math libraries * - CT = Common errors between tokens (AToken, VariableDebtToken and StableDebtToken) * - AT = AToken * - SDT = StableDebtToken * - VDT = VariableDebtToken * - LP = LendingPool * - LPAPR = LendingPoolAddressesProviderRegistry * - LPC = LendingPoolConfiguration * - RL = ReserveLogic * - LPCM = LendingPoolCollateralManager * - P = Pausable */ library Errors { //common errors string internal constant CALLER_NOT_POOL_ADMIN = '33'; // 'The caller must be the pool admin' string internal constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small //contract specific errors string internal constant VL_INVALID_AMOUNT = '1'; // 'Amount must be greater than 0' string internal constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve' string internal constant VL_RESERVE_FROZEN = '3'; // 'Action cannot be performed because the reserve is frozen' string internal constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough' string internal constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance' string internal constant VL_TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.' string internal constant VL_BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled' string internal constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected' string internal constant VL_COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0' string internal constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold' string internal constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow' string internal constant VL_STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled string internal constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed string internal constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode string internal constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string internal constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed' string internal constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve' string internal constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve' string internal constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0' string internal constant VL_DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral' string internal constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve' string internal constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met' string internal constant LP_LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed' string internal constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow' string internal constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.' string internal constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent' string internal constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The caller of the function is not the lending pool configurator' string internal constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28'; string internal constant CT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool' string internal constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string internal constant CT_TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' string internal constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // 'Reserve has already been initialized' string internal constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_ATOKEN_POOL_ADDRESS = '35'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '36'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '37'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0' string internal constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve' string internal constant LPC_CALLER_NOT_EMERGENCY_ADMIN = '76'; // 'The caller must be the emergency admin' string internal constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered' string internal constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold' string internal constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated' string internal constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '44'; // 'User did not borrow the specified currency' string internal constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '45'; // "There isn't enough liquidity available to liquidate" string internal constant LPCM_NO_ERRORS = '46'; // 'No errors' string internal constant LP_INVALID_FLASHLOAN_MODE = '47'; //Invalid flashloan mode selected string internal constant MATH_MULTIPLICATION_OVERFLOW = '48'; string internal constant MATH_ADDITION_OVERFLOW = '49'; string internal constant MATH_DIVISION_BY_ZERO = '50'; string internal constant RL_LIQUIDITY_INDEX_OVERFLOW = '51'; // Liquidity index overflows uint128 string internal constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '52'; // Variable borrow index overflows uint128 string internal constant RL_LIQUIDITY_RATE_OVERFLOW = '53'; // Liquidity rate overflows uint128 string internal constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '54'; // Variable borrow rate overflows uint128 string internal constant RL_STABLE_BORROW_RATE_OVERFLOW = '55'; // Stable borrow rate overflows uint128 string internal constant CT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint string internal constant LP_FAILED_REPAY_WITH_COLLATERAL = '57'; string internal constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn string internal constant LP_FAILED_COLLATERAL_SWAP = '60'; string internal constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string internal constant LP_REENTRANCY_NOT_ALLOWED = '62'; string internal constant LP_CALLER_MUST_BE_AN_ATOKEN = '63'; string internal constant LP_IS_PAUSED = '64'; // 'Pool is paused' string internal constant LP_NO_MORE_RESERVES_ALLOWED = '65'; string internal constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66'; string internal constant RC_INVALID_LTV = '67'; string internal constant RC_INVALID_LIQ_THRESHOLD = '68'; string internal constant RC_INVALID_LIQ_BONUS = '69'; string internal constant RC_INVALID_DECIMALS = '70'; string internal constant RC_INVALID_RESERVE_FACTOR = '71'; string internal constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72'; string internal constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73'; string internal constant LP_INCONSISTENT_PARAMS_LENGTH = '74'; string internal constant UL_INVALID_INDEX = '77'; string internal constant LP_NOT_CONTRACT = '78'; string internal constant SDT_STABLE_DEBT_OVERFLOW = '79'; string internal constant SDT_BURN_EXCEEDS_BALANCE = '80'; string internal constant VT_COLLATERAL_DEPOSIT_REQUIRE_ETH = '81'; //Only accept ETH for collateral deposit string internal constant VT_COLLATERAL_DEPOSIT_INVALID = '82'; //Collateral deposit failed string internal constant VT_LIQUIDITY_DEPOSIT_INVALID = '83'; //Only accept USDC, USDT, DAI for liquidity deposit string internal constant VT_COLLATERAL_WITHDRAW_INVALID = '84'; //Collateral withdraw failed string internal constant VT_COLLATERAL_WITHDRAW_INVALID_AMOUNT = '85'; //Collateral withdraw has not enough amount string internal constant VT_CONVERT_ASSET_BY_CURVE_INVALID = '86'; //Convert asset by curve invalid string internal constant VT_PROCESS_YIELD_INVALID = '87'; //Processing yield is invalid string internal constant VT_TREASURY_INVALID = '88'; //Treasury is invalid string internal constant LP_ATOKEN_INIT_INVALID = '89'; //aToken invalid init string internal constant VT_FEE_TOO_BIG = '90'; //Fee is too big string internal constant VT_COLLATERAL_DEPOSIT_VAULT_UNAVAILABLE = '91'; string internal constant LP_LIQUIDATION_CONVERT_FAILED = '92'; string internal constant VT_DEPLOY_FAILED = '93'; // Vault deploy failed string internal constant VT_INVALID_CONFIGURATION = '94'; // Invalid vault configuration string internal constant VL_OVERFLOW_MAX_RESERVE_CAPACITY = '95'; // overflow max capacity of reserve string internal constant VT_WITHDRAW_AMOUNT_MISMATCH = '96'; // not performed withdraw 100% string internal constant VT_SWAP_MISMATCH_RETURNED_AMOUNT = '97'; //Returned amount is not enough string internal constant CALLER_NOT_YIELD_PROCESSOR = '98'; // 'The caller must be the pool admin' string internal constant VT_EXTRA_REWARDS_INDEX_INVALID = '99'; // Invalid extraRewards index string internal constant VT_SWAP_PATH_LENGTH_INVALID = '100'; // Invalid token or fee length string internal constant VT_SWAP_PATH_TOKEN_INVALID = '101'; // Invalid token information string internal constant CLAIMER_UNAUTHORIZED = '102'; // 'The claimer is not authorized' string internal constant YD_INVALID_CONFIGURATION = '103'; // 'The yield distribution's invalid configuration' string internal constant CALLER_NOT_EMISSION_MANAGER = '104'; // 'The caller must be emission manager' string internal constant CALLER_NOT_INCENTIVE_CONTROLLER = '105'; // 'The caller must be incentive controller' string internal constant YD_VR_ASSET_ALREADY_IN_USE = '106'; // Vault is already registered string internal constant YD_VR_INVALID_VAULT = '107'; // Invalid vault is used for an asset string internal constant YD_VR_INVALID_REWARDS_AMOUNT = '108'; // Rewards amount should be bigger than before string internal constant YD_VR_REWARD_TOKEN_NOT_VALID = '109'; // The reward token must be same with configured address string internal constant YD_VR_ASSET_NOT_REGISTERED = '110'; string internal constant YD_VR_CALLER_NOT_VAULT = '111'; // The caller must be same with configured vault address string internal constant LS_INVALID_CONFIGURATION = '112'; // Invalid Leverage Swapper configuration string internal constant LS_SWAP_AMOUNT_NOT_GT_0 = '113'; // Collateral amount needs to be greater than zero string internal constant LS_BORROWING_ASSET_NOT_SUPPORTED = '114'; // Doesn't support swap for the borrowing asset string internal constant LS_SUPPLY_NOT_ALLOWED = '115'; // no sufficient funds string internal constant LS_SUPPLY_FAILED = '116'; // Deposit fails when leverage works string internal constant LS_REPAY_FAILED = '117'; // Repay fails when leverage works string internal constant O_WRONG_PRICE = '118'; // not correct price oracle enum CollateralManagerErrors { NO_ERROR, NO_COLLATERAL_AVAILABLE, COLLATERAL_CANNOT_BE_LIQUIDATED, CURRRENCY_NOT_BORROWED, HEALTH_FACTOR_ABOVE_THRESHOLD, NOT_ENOUGH_LIQUIDITY, NO_ACTIVE_RESERVE, HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD, INVALID_EQUAL_ASSETS_TO_SWAP, FROZEN_RESERVE } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {Errors} from '../helpers/Errors.sol'; /** * @title PercentageMath library * @author Sturdy, inspiration from Aave * @notice Provides functions to perform percentage calculations * @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR * @dev Operations are rounded half up **/ library PercentageMath { uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2; /** * @dev Executes a percentage multiplication * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The percentage of value **/ function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) { if (value == 0 || percentage == 0) { return 0; } return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR; } /** * @dev Executes a percentage division * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The value divided the percentage **/ function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) { uint256 halfPercentage = percentage / 2; return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage; } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; import {Errors} from '../helpers/Errors.sol'; /** * @title WadRayMath library * @author Sturdy, inspiration from Aave * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits) **/ library WadRayMath { uint256 internal constant WAD = 1e18; uint256 internal constant halfWAD = WAD / 2; uint256 internal constant RAY = 1e27; uint256 internal constant halfRAY = RAY / 2; uint256 internal constant WAD_RAY_RATIO = 1e9; /** * @return One ray, 1e27 **/ function ray() internal pure returns (uint256) { return RAY; } /** * @return One wad, 1e18 **/ function wad() internal pure returns (uint256) { return WAD; } /** * @return Half ray, 1e27/2 **/ function halfRay() internal pure returns (uint256) { return halfRAY; } /** * @return Half ray, 1e18/2 **/ function halfWad() internal pure returns (uint256) { return halfWAD; } /** * @dev Multiplies two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a*b, in wad **/ function wadMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } return (a * b + halfWAD) / WAD; } /** * @dev Divides two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a/b, in wad **/ function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) { uint256 halfB = b / 2; return (a * WAD + halfB) / b; } /** * @dev Multiplies two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a*b, in ray **/ function rayMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } return (a * b + halfRAY) / RAY; } /** * @dev Divides two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a/b, in ray **/ function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) { uint256 halfB = b / 2; return (a * RAY + halfB) / b; } /** * @dev Casts ray down to wad * @param a Ray * @return a casted to wad, rounded half up to the nearest wad **/ function rayToWad(uint256 a) internal pure returns (uint256) { uint256 halfRatio = WAD_RAY_RATIO / 2; uint256 result = halfRatio + a; return result / WAD_RAY_RATIO; } /** * @dev Converts wad up to ray * @param a Wad * @return a converted in ray **/ function wadToRay(uint256 a) internal pure returns (uint256) { uint256 result = a * WAD_RAY_RATIO; return result; } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.8.0; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //address of the yield contract address yieldAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_provider","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"COLLATERAL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETHSTETH","outputs":[{"internalType":"contract ICurvePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VAULT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_principal","type":"uint256"},{"internalType":"uint256","name":"_leverage","type":"uint256"},{"internalType":"uint256","name":"_slippage","type":"uint256"},{"internalType":"address","name":"_borrowingAsset","type":"address"},{"internalType":"enum GeneralLevSwap.FlashLoanType","name":"_flashLoanType","type":"uint8"}],"name":"enterPositionWithFlashloan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"premiums","type":"uint256[]"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"executeOperation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAvailableBorrowingAssets","outputs":[{"internalType":"address[]","name":"assets","type":"address[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"feeAmounts","type":"uint256[]"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"receiveFlashLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_repayAmount","type":"uint256"},{"internalType":"uint256","name":"_requiredAmount","type":"uint256"},{"internalType":"uint256","name":"_slippage","type":"uint256"},{"internalType":"address","name":"_borrowingAsset","type":"address"},{"internalType":"address","name":"_sAsset","type":"address"},{"internalType":"enum GeneralLevSwap.FlashLoanType","name":"_flashLoanType","type":"uint8"}],"name":"withdrawWithFlashloan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_zappingAsset","type":"address"},{"internalType":"uint256","name":"_principal","type":"uint256"},{"internalType":"uint256","name":"_slippage","type":"uint256"}],"name":"zapDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_zappingAsset","type":"address"},{"internalType":"uint256","name":"_principal","type":"uint256"},{"internalType":"uint256","name":"_leverage","type":"uint256"},{"internalType":"uint256","name":"_slippage","type":"uint256"},{"internalType":"address","name":"_borrowAsset","type":"address"},{"internalType":"enum GeneralLevSwap.FlashLoanType","name":"_flashLoanType","type":"uint8"}],"name":"zapLeverageWithFlashloan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
61014060405260016002553480156200001757600080fd5b5060405162004090380380620040908339810160408190526200003a91620002b0565b60016000558282826001600160a01b038316158015906200006357506001600160a01b03811615155b80156200007857506001600160a01b03821615155b6040518060400160405280600381526020016218989960e91b81525090620000be5760405162461bcd60e51b8152600401620000b59190620002fa565b60405180910390fd5b506001600160a01b03831660808190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa1580156200010a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000130919062000352565b60ff1660a0526001600160a01b0380831660c052811660e081905260408051631f94a27560e31b8152905163fca513a8916004808201926020929091908290030181865afa15801562000187573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001ad91906200037e565b6001600160a01b0316610100816001600160a01b03168152505060e0516001600160a01b0316630261bf8b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000208573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200022e91906200037e565b6001600160a01b031661012052505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26000525050600160208190527f49e349d4f386739afdf8e55db7675b584d46c3b2a603eef62554e21dc437b5db805460ff19169091179055506200039c9050565b80516001600160a01b0381168114620002ab57600080fd5b919050565b600080600060608486031215620002c657600080fd5b620002d18462000293565b9250620002e16020850162000293565b9150620002f16040850162000293565b90509250925092565b600060208083528351808285015260005b8181101562000329578581018301518582016040015282016200030b565b818111156200033c576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156200036557600080fd5b815160ff811681146200037757600080fd5b9392505050565b6000602082840312156200039157600080fd5b620003778262000293565b60805160a05160c05160e0516101005161012051613bf96200049760003960008181610c7e01528181610def015281816126d3015281816127dd01528181612a5501528181612abc01528181612af10152612b4e015260006124f20152600050506000818161019301528181611b5b01528181611bce0152612c5701526000818161015101528181611cea015261293401526000818160e001528181610635015281816106f2015281816111b50152818161125501528181611a3201528181611abc01528181611b3901528181611b9701528181611d150152818161290b01528181612c1b01528181612cf90152612df80152613bf96000f3fe6080604052600436106100a05760003560e01c806349d790081161006457806349d79008146101b55780636b1d110b146101d757806374f89afb146101f7578063920f5c841461021757806396008ad714610247578063f04f27071461026f57600080fd5b80630197bfc4146100ac57806324bbab8b146100ce5780632d5a1c261461011f5780632e0f26251461013f578063411557d11461018157600080fd5b366100a757005b600080fd5b3480156100b857600080fd5b506100cc6100c7366004612f99565b61028f565b005b3480156100da57600080fd5b506101027f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012b57600080fd5b506100cc61013a366004612fe2565b610473565b34801561014b57600080fd5b506101737f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610116565b34801561018d57600080fd5b506101027f000000000000000000000000000000000000000000000000000000000000000081565b3480156101c157600080fd5b506101ca610734565b6040516101169190613078565b3480156101e357600080fd5b506100cc6101f236600461308b565b6107a1565b34801561020357600080fd5b506100cc6102123660046130ee565b610acd565b34801561022357600080fd5b50610237610232366004613183565b61128d565b6040519015158152602001610116565b34801561025357600080fd5b5061010273dc24316b9ae028f1497c275eb9192a3ea0f6702281565b34801561027b57600080fd5b506100cc61028a3660046133f8565b6115c4565b600260005414156102bb5760405162461bcd60e51b81526004016102b290613503565b60405180910390fd5b600260005560408051808201909152600381526231313360e81b6020820152826102f85760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b03841661033a5760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03831660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff166103925760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015282906001600160a01b038516906370a0823190602401602060405180830381865afa1580156103d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fd91906135a5565b10156040518060400160405280600381526020016231313560e81b815250906104395760405162461bcd60e51b81526004016102b29190613592565b5061044f6001600160a01b038416333085611878565b600061045c8484846118e3565b90506104688133611b2c565b505060016000555050565b600260005414156104965760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b6020820152856104d35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b60208201528461050c5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b6020820152836105455760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015262015f9085106105835760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166105c55760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03821660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff1661061d5760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015285907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a891906135a5565b10156040518060400160405280600381526020016231313560e81b815250906106e45760405162461bcd60e51b81526004016102b29190613592565b5061071a6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333088611878565b610728338686868686611c2f565b50506001600055505050565b6040805160018082528183019092526060916020808301908036833701905050905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160008151811061077e5761077e6135be565b60200260200101906001600160a01b031690816001600160a01b03168152505090565b600260005414156107c45760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b6020820152856108015760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b60208201528461083a5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b6020820152836108735760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015262015f9085106108b15760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166108f35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0387166109355760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03861660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff1661098d5760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03821660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff166109e55760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015285906001600160a01b038816906370a0823190602401602060405180830381865afa158015610a2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5091906135a5565b10156040518060400160405280600381526020016231313560e81b81525090610a8c5760405162461bcd60e51b81526004016102b29190613592565b50610aa26001600160a01b038716333088611878565b6000610aaf8787866118e3565b9050610abf338287878787611c2f565b505060016000555050505050565b60026000541415610af05760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b602082015286610b2d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b602082015285610b665760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b602082015284610b9f5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b038416610be15760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03831660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff16610c395760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b038316610c7b5760405162461bcd60e51b81526004016102b29190613592565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166335ea6a75836001600160a01b031663b16a19de6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ce9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0d91906135df565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016101a060405180830381865afa158015610d52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d76919061368b565b60e001516001600160a01b0316826001600160a01b0316146040518060400160405280600381526020016218989960e91b81525090610dc85760405162461bcd60e51b81526004016102b29190613592565b506040516335ea6a7560e01b81526001600160a01b038481166004830152600091610e66917f000000000000000000000000000000000000000000000000000000000000000016906335ea6a75906024016101a060405180830381865afa158015610e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5b919061368b565b61012001513361201e565b6040805160018082528183019092529192506000919060208083019080368337019050509050610e968883612095565b81600081518110610ea957610ea96135be565b602090810291909101810191909152604080516000928101839052908101889052606081018990523360808201526001600160a01b03861660a082015260c00160408051601f1981840301815291905290506000846001811115610f0f57610f0f61378a565b14156110245760408051600180825281830190925260009160208083019080368337019050509050600081600081518110610f4c57610f4c6135be565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508781600081518110610f8f57610f8f6135be565b6001600160a01b039092166020928302919091019091015260405163ab9c4b5d60e01b8152737937d4799803fbbe595ed57278bc4ca21f3bffcb9063ab9c4b5d90610feb90309085908990889084908b906000906004016137d0565b600060405180830381600087803b15801561100557600080fd5b505af1158015611019573d6000803e3d6000fd5b505050505050611128565b6002546001146040518060400160405280600381526020016218989960e91b815250906110645760405162461bcd60e51b81526004016102b29190613592565b5060408051600180825281830190925260009160208083019080368337019050509050868160008151811061109b5761109b6135be565b6001600160a01b039092166020928302919091019091015260028055604051632e1c224f60e11b815273ba12222222228d8ba445958a75a0704d566bf2c890635c38449e906110f490309085908890889060040161384e565b600060405180830381600087803b15801561110e57600080fd5b505af1158015611122573d6000803e3d6000fd5b50505050505b6040516370a0823160e01b815230600482015261119c9087906001600160a01b038216906370a0823190602401602060405180830381865afa158015611172573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119691906135a5565b896118e3565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611204573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122891906135a5565b9050888111156112485761124561123f8a836138e8565b33611b2c565b50875b61127c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633836120ab565b505060016000555050505050505050565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03851630146112d35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015233737937d4799803fbbe595ed57278bc4ca21f3bffcb146113225760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015289881461135d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201528986146113985760405162461bcd60e51b81526004016102b29190613592565b506000888860008181106113ae576113ae6135be565b90506020020135116040518060400160405280600381526020016218989960e91b815250906113f05760405162461bcd60e51b81526004016102b29190613592565b5060008a8a8281611403576114036135be565b905060200201602081019061141891906138ff565b6001600160a01b031614156040518060400160405280600381526020016218989960e91b8152509061145d5760405162461bcd60e51b81526004016102b29190613592565b506114f98a8a6000818110611474576114746135be565b905060200201602081019061148991906138ff565b8989600081811061149c5761149c6135be565b90506020020135888860008181106114b6576114b66135be565b9050602002013586868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120e092505050565b61154b737937d4799803fbbe595ed57278bc4ca21f3bffcb60008c8c6000818110611526576115266135be565b905060200201602081019061153b91906138ff565b6001600160a01b03169190612234565b6115b4737937d4799803fbbe595ed57278bc4ca21f3bffcb87876000818110611576576115766135be565b905060200201358a8a6000818110611590576115906135be565b905060200201356115a1919061391c565b8c8c6000818110611526576115266135be565b5060019998505050505050505050565b60408051808201909152600381526218989960e91b60208201523373ba12222222228d8ba445958a75a0704d566bf2c8146116125760405162461bcd60e51b81526004016102b29190613592565b506002546002146040518060400160405280600381526020016218989960e91b815250906116535760405162461bcd60e51b81526004016102b29190613592565b5082518451146040518060400160405280600381526020016218989960e91b815250906116935760405162461bcd60e51b81526004016102b29190613592565b5081518451146040518060400160405280600381526020016218989960e91b815250906116d35760405162461bcd60e51b81526004016102b29190613592565b506000836000815181106116e9576116e96135be565b6020026020010151116040518060400160405280600381526020016218989960e91b8152509061172c5760405162461bcd60e51b81526004016102b29190613592565b5060006001600160a01b03168460008151811061174b5761174b6135be565b60200260200101516001600160a01b031614156040518060400160405280600381526020016218989960e91b815250906117985760405162461bcd60e51b81526004016102b29190613592565b5060016002819055506117fb846000815181106117b7576117b76135be565b6020026020010151846000815181106117d2576117d26135be565b6020026020010151846000815181106117ed576117ed6135be565b6020026020010151846120e0565b6118723383600081518110611812576118126135be565b60200260200101518560008151811061182d5761182d6135be565b602002602001015161183f919061391c565b86600081518110611852576118526135be565b60200260200101516001600160a01b03166120ab9092919063ffffffff16565b50505050565b6040516001600160a01b03808516602483015283166044820152606481018290526118729085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612349565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21461193d5760405162461bcd60e51b81526004016102b29190613592565b50604051632e1a7d4d60e01b81526004810184905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b15801561198b57600080fd5b505af115801561199f573d6000803e3d6000fd5b505050506119ab612f63565b838152604051630b4c7e4d60e01b815273dc24316b9ae028f1497c275eb9192a3ea0f6702290630b4c7e4d9086906119ea908590600090600401613934565b6000604051808303818588803b158015611a0357600080fd5b505af1158015611a17573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600093507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031692506370a082319150602401602060405180830381865afa158015611a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa791906135a5565b9050611ae58585670de0b6b3a7640000611ae07f00000000000000000000000000000000000000000000000000000000000000006124d0565b61255f565b8110156040518060400160405280600381526020016231313560e81b81525090611b225760405162461bcd60e51b81526004016102b29190613592565b5095945050505050565b611b806001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000084612234565b60405163259f2d0160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905282811660448301527f0000000000000000000000000000000000000000000000000000000000000000169063259f2d01906064015b600060405180830381600087803b158015611c1357600080fd5b505af1158015611c27573d6000803e3d6000fd5b505050505050565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c93919061396c565b60408051600180825281830190925260ff9290921692506000919060208083019080368337019050509050611d67611ccd8661271061391c565b611d6188611cda886124d0565b611ce587600a613a6b565b611d107f0000000000000000000000000000000000000000000000000000000000000000600a613a6b565b611d397f00000000000000000000000000000000000000000000000000000000000000006124d0565b611d43908f613a77565b611d4d9190613a96565b611d579190613a77565b611d619190613a96565b90612584565b81600081518110611d7a57611d7a6135be565b60209081029190910101526000611d9d611d968861271061391c565b8990612584565b6040805160016020820152908101889052606081018290526001600160a01b038b166080820152600060a0820181905291925060c00160408051601f1981840301815291905290506000856001811115611df957611df961378a565b1415611f0e5760408051600180825281830190925260009160208083019080368337019050509050600081600081518110611e3657611e366135be565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508781600081518110611e7957611e796135be565b6001600160a01b039092166020928302919091019091015260405163ab9c4b5d60e01b8152737937d4799803fbbe595ed57278bc4ca21f3bffcb9063ab9c4b5d90611ed590309085908a90889084908b906000906004016137d0565b600060405180830381600087803b158015611eef57600080fd5b505af1158015611f03573d6000803e3d6000fd5b505050505050612012565b6002546001146040518060400160405280600381526020016218989960e91b81525090611f4e5760405162461bcd60e51b81526004016102b29190613592565b50604080516001808252818301909252600091602080830190803683370190505090508681600081518110611f8557611f856135be565b6001600160a01b039092166020928302919091019091015260028055604051632e1c224f60e11b815273ba12222222228d8ba445958a75a0704d566bf2c890635c38449e90611fde90309085908990889060040161384e565b600060405180830381600087803b158015611ff857600080fd5b505af115801561200c573d6000803e3d6000fd5b50505050505b50505050505050505050565b6040516370a0823160e01b81526001600160a01b038281166004830152600091908416906370a0823190602401602060405180830381865afa158015612068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208c91906135a5565b90505b92915050565b60008183106120a4578161208c565b5090919050565b6040516001600160a01b0383166024820152604481018290526120db90849063a9059cbb60e01b906064016118ac565b505050565b6000806000806000858060200190518101906120fc9190613ac8565b94509450945094509450600084116040518060400160405280600381526020016218989960e91b815250906121445760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201528361217d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166121bf5760405162461bcd60e51b81526004016102b29190613592565b5084156121d9576121d48484848c8c8c6125ca565b612229565b60408051808201909152600381526218989960e91b60208201526001600160a01b03821661221a5760405162461bcd60e51b81526004016102b29190613592565b50612229848484848d8d61263f565b505050505050505050565b8015806122ae5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ac91906135a5565b155b6123195760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016102b2565b6040516001600160a01b0383166024820152604481018290526120db90849063095ea7b360e01b906064016118ac565b61235b826001600160a01b03166129dd565b6123a75760405162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740060448201526064016102b2565b600080836001600160a01b0316836040516123c29190613b26565b6000604051808303816000865af19150503d80600081146123ff576040519150601f19603f3d011682016040523d82523d6000602084013e612404565b606091505b5091509150816124565760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016102b2565b80511561187257808060200190518101906124719190613b42565b6118725760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102b2565b60405163b3596f0760e01b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063b3596f0790602401602060405180830381865afa15801561253b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208f91906135a5565b600061257b612570856127106138e8565b83611d578689613a77565b95945050505050565b6000821580612591575081155b1561259e5750600061208f565b6127106125ac600282613a96565b6125b68486613a77565b6125c0919061391c565b61208c9190613a96565b60006125d78484896118e3565b9050858110156040518060400160405280600381526020016218989b60e91b815250906126175760405162461bcd60e51b81526004016102b29190613592565b506126228186611b2c565b61263684612630848661391c565b87612a19565b50505050505050565b61264a828286612aad565b6000836001600160a01b031663b16a19de6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561268a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ae91906135df565b60405163c44b11f760e01b81526001600160a01b0380831660048301529192506000917f0000000000000000000000000000000000000000000000000000000000000000169063c44b11f790602401602060405180830381865afa15801561271a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273e9190613b5d565b90506000612771825161ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b50505091505080600014156040518060400160405280600381526020016218989960e91b815250906127b65760405162461bcd60e51b81526004016102b29190613592565b50604051632fe4a15f60e21b81526001600160a01b038881166004830152600091829182917f00000000000000000000000000000000000000000000000000000000000000009091169063bf92857c9060240160c060405180830381865afa158015612826573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284a9190613b79565b5050935050925092506000846127108461271085886128699190613a77565b6128739190613a96565b61287d91906138e8565b6128879190613a77565b6128919190613a96565b6040516370a0823160e01b81526001600160a01b038d8116600483015291925060009161297391908d16906370a0823190602401602060405180830381865afa1580156128e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290691906135a5565b61292f7f00000000000000000000000000000000000000000000000000000000000000006124d0565b61295a7f0000000000000000000000000000000000000000000000000000000000000000600a613a6b565b6129649086613a77565b61296e9190613a96565b612095565b90508c8110156040518060400160405280600381526020016231313560e81b815250906129b35760405162461bcd60e51b81526004016102b29190613592565b506129c96001600160a01b038c168d3084611878565b6129d3818f612c04565b61200c8a8f612c86565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590612a1157508115155b949350505050565b60405163a415bcad60e01b81526001600160a01b03848116600483015260248201849052600260448301526000606483015282811660848301527f0000000000000000000000000000000000000000000000000000000000000000169063a415bcad9060a401600060405180830381600087803b158015612a9957600080fd5b505af1158015612636573d6000803e3d6000fd5b612ae26001600160a01b0384167f00000000000000000000000000000000000000000000000000000000000000006000612234565b612b166001600160a01b0384167f000000000000000000000000000000000000000000000000000000000000000084612234565b60405163573ade8160e01b81526001600160a01b038481166004830152602482018490526002604483015282811660648301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063573ade81906084016020604051808303816000875af1158015612b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bbd91906135a5565b9050600081116040518060400160405280600381526020016231313760e81b81525090612bfd5760405162461bcd60e51b81526004016102b29190613592565b5050505050565b60405163a5fdfc6360e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260248201849052604482018390523060648301527f0000000000000000000000000000000000000000000000000000000000000000169063a5fdfc6390608401611bf9565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214612ce05760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015612d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6c91906135a5565b60405163cc2b27d760e01b81526004810182905260006024820181905291925073dc24316b9ae028f1497c275eb9192a3ea0f670229063cc2b27d790604401602060405180830381865afa158015612dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dec91906135a5565b9050612e2a8285612e1c7f00000000000000000000000000000000000000000000000000000000000000006124d0565b670de0b6b3a764000061255f565b8110156040518060400160405280600381526020016231313560e81b81525090612e675760405162461bcd60e51b81526004016102b29190613592565b50604051630d2680e960e11b815260048101839052600060248201819052604482018390529073dc24316b9ae028f1497c275eb9192a3ea0f6702290631a4d01d2906064016020604051808303816000875af1158015612ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eef91906135a5565b905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612f4057600080fd5b505af1158015612f54573d6000803e3d6000fd5b50939998505050505050505050565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b0381168114612f9657600080fd5b50565b600080600060608486031215612fae57600080fd5b8335612fb981612f81565b95602085013595506040909401359392505050565b803560028110612fdd57600080fd5b919050565b600080600080600060a08688031215612ffa57600080fd5b853594506020860135935060408601359250606086013561301a81612f81565b915061302860808701612fce565b90509295509295909350565b600081518084526020808501945080840160005b8381101561306d5781516001600160a01b031687529582019590820190600101613048565b509495945050505050565b60208152600061208c6020830184613034565b60008060008060008060c087890312156130a457600080fd5b86356130af81612f81565b955060208701359450604087013593506060870135925060808701356130d481612f81565b91506130e260a08801612fce565b90509295509295509295565b60008060008060008060c0878903121561310757600080fd5b863595506020870135945060408701359350606087013561312781612f81565b925060808701356130d481612f81565b60008083601f84011261314957600080fd5b50813567ffffffffffffffff81111561316157600080fd5b6020830191508360208260051b850101111561317c57600080fd5b9250929050565b600080600080600080600080600060a08a8c0312156131a157600080fd5b893567ffffffffffffffff808211156131b957600080fd5b6131c58d838e01613137565b909b50995060208c01359150808211156131de57600080fd5b6131ea8d838e01613137565b909950975060408c013591508082111561320357600080fd5b61320f8d838e01613137565b909750955060608c0135915061322482612f81565b90935060808b0135908082111561323a57600080fd5b818c0191508c601f83011261324e57600080fd5b81358181111561325d57600080fd5b8d602082850101111561326f57600080fd5b6020830194508093505050509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff811182821017156132c2576132c2613288565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156132f1576132f1613288565b604052919050565b600067ffffffffffffffff82111561331357613313613288565b5060051b60200190565b600082601f83011261332e57600080fd5b8135602061334361333e836132f9565b6132c8565b82815260059290921b8401810191818101908684111561336257600080fd5b8286015b8481101561337d5780358352918301918301613366565b509695505050505050565b600082601f83011261339957600080fd5b813567ffffffffffffffff8111156133b3576133b3613288565b6133c6601f8201601f19166020016132c8565b8181528460208386010111156133db57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561340e57600080fd5b843567ffffffffffffffff8082111561342657600080fd5b818701915087601f83011261343a57600080fd5b8135602061344a61333e836132f9565b82815260059290921b8401810191818101908b84111561346957600080fd5b948201945b8386101561349057853561348181612f81565b8252948201949082019061346e565b985050880135925050808211156134a657600080fd5b6134b28883890161331d565b945060408701359150808211156134c857600080fd5b6134d48883890161331d565b935060608701359150808211156134ea57600080fd5b506134f787828801613388565b91505092959194509250565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60005b8381101561355557818101518382015260200161353d565b838111156118725750506000910152565b6000815180845261357e81602086016020860161353a565b601f01601f19169290920160200192915050565b60208152600061208c6020830184613566565b6000602082840312156135b757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b8051612fdd81612f81565b6000602082840312156135f157600080fd5b81516135fc81612f81565b9392505050565b60006020828403121561361557600080fd5b6040516020810181811067ffffffffffffffff8211171561363857613638613288565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff81168114612fdd57600080fd5b805164ffffffffff81168114612fdd57600080fd5b805160ff81168114612fdd57600080fd5b60006101a0828403121561369e57600080fd5b6136a661329e565b6136b08484613603565b81526136be60208401613645565b60208201526136cf60408401613645565b60408201526136e060608401613645565b60608201526136f160808401613645565b608082015261370260a08401613645565b60a082015261371360c08401613665565b60c082015261372460e084016135d4565b60e08201526101006137378185016135d4565b908201526101206137498482016135d4565b9082015261014061375b8482016135d4565b9082015261016061376d8482016135d4565b9082015261018061377f84820161367a565b908201529392505050565b634e487b7160e01b600052602160045260246000fd5b600081518084526020808501945080840160005b8381101561306d578151875295820195908201906001016137b4565b600060018060a01b03808a16835260e060208401526137f260e084018a613034565b8381036040850152613804818a6137a0565b9050838103606085015261381881896137a0565b9050818716608085015283810360a08501526138348187613566565b9250505061ffff831660c083015298975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b8181101561389c57855185168352948301949183019160010161387e565b505085810360408701526138b081896137a0565b935050505082810360608401526138c78185613566565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156138fa576138fa6138d2565b500390565b60006020828403121561391157600080fd5b81356135fc81612f81565b6000821982111561392f5761392f6138d2565b500190565b60608101818460005b600281101561395c57815183526020928301929091019060010161393d565b5050508260408301529392505050565b60006020828403121561397e57600080fd5b61208c8261367a565b600181815b808511156139c25781600019048211156139a8576139a86138d2565b808516156139b557918102915b93841c939080029061398c565b509250929050565b6000826139d95750600161208f565b816139e65750600061208f565b81600181146139fc5760028114613a0657613a22565b600191505061208f565b60ff841115613a1757613a176138d2565b50506001821b61208f565b5060208310610133831016604e8410600b8410161715613a45575081810a61208f565b613a4f8383613987565b8060001904821115613a6357613a636138d2565b029392505050565b600061208c83836139ca565b6000816000190483118215151615613a9157613a916138d2565b500290565b600082613ab357634e487b7160e01b600052601260045260246000fd5b500490565b80518015158114612fdd57600080fd5b600080600080600060a08688031215613ae057600080fd5b613ae986613ab8565b945060208601519350604086015192506060860151613b0781612f81565b6080870151909250613b1881612f81565b809150509295509295909350565b60008251613b3881846020870161353a565b9190910192915050565b600060208284031215613b5457600080fd5b61208c82613ab8565b600060208284031215613b6f57600080fd5b61208c8383613603565b60008060008060008060c08789031215613b9257600080fd5b865195506020870151945060408701519350606087015192506080870151915060a08701519050929550929550929556fea2646970667358221220ee5bb7c1397cc26bf3ad79edda3d7078a1549168c6df7035733b06369348594364736f6c634300080a003300000000000000000000000006325440d014e39736583c165c2963ba99faf14e000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc00000000000000000000000040ea6e14800f6040d25a9a5a1e9cc0f5cb6d1066
Deployed Bytecode
0x6080604052600436106100a05760003560e01c806349d790081161006457806349d79008146101b55780636b1d110b146101d757806374f89afb146101f7578063920f5c841461021757806396008ad714610247578063f04f27071461026f57600080fd5b80630197bfc4146100ac57806324bbab8b146100ce5780632d5a1c261461011f5780632e0f26251461013f578063411557d11461018157600080fd5b366100a757005b600080fd5b3480156100b857600080fd5b506100cc6100c7366004612f99565b61028f565b005b3480156100da57600080fd5b506101027f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012b57600080fd5b506100cc61013a366004612fe2565b610473565b34801561014b57600080fd5b506101737f000000000000000000000000000000000000000000000000000000000000001281565b604051908152602001610116565b34801561018d57600080fd5b506101027f000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc81565b3480156101c157600080fd5b506101ca610734565b6040516101169190613078565b3480156101e357600080fd5b506100cc6101f236600461308b565b6107a1565b34801561020357600080fd5b506100cc6102123660046130ee565b610acd565b34801561022357600080fd5b50610237610232366004613183565b61128d565b6040519015158152602001610116565b34801561025357600080fd5b5061010273dc24316b9ae028f1497c275eb9192a3ea0f6702281565b34801561027b57600080fd5b506100cc61028a3660046133f8565b6115c4565b600260005414156102bb5760405162461bcd60e51b81526004016102b290613503565b60405180910390fd5b600260005560408051808201909152600381526231313360e81b6020820152826102f85760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b03841661033a5760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03831660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff166103925760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015282906001600160a01b038516906370a0823190602401602060405180830381865afa1580156103d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fd91906135a5565b10156040518060400160405280600381526020016231313560e81b815250906104395760405162461bcd60e51b81526004016102b29190613592565b5061044f6001600160a01b038416333085611878565b600061045c8484846118e3565b90506104688133611b2c565b505060016000555050565b600260005414156104965760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b6020820152856104d35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b60208201528461050c5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b6020820152836105455760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015262015f9085106105835760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166105c55760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03821660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff1661061d5760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015285907f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6001600160a01b0316906370a0823190602401602060405180830381865afa158015610684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a891906135a5565b10156040518060400160405280600381526020016231313560e81b815250906106e45760405162461bcd60e51b81526004016102b29190613592565b5061071a6001600160a01b037f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e16333088611878565b610728338686868686611c2f565b50506001600055505050565b6040805160018082528183019092526060916020808301908036833701905050905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160008151811061077e5761077e6135be565b60200260200101906001600160a01b031690816001600160a01b03168152505090565b600260005414156107c45760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b6020820152856108015760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b60208201528461083a5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b6020820152836108735760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015262015f9085106108b15760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166108f35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0387166109355760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03861660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff1661098d5760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03821660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff166109e55760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b815233600482015285906001600160a01b038816906370a0823190602401602060405180830381865afa158015610a2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5091906135a5565b10156040518060400160405280600381526020016231313560e81b81525090610a8c5760405162461bcd60e51b81526004016102b29190613592565b50610aa26001600160a01b038716333088611878565b6000610aaf8787866118e3565b9050610abf338287878787611c2f565b505060016000555050505050565b60026000541415610af05760405162461bcd60e51b81526004016102b290613503565b600260005560408051808201909152600381526231313360e81b602082015286610b2d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b602082015285610b665760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526231313360e81b602082015284610b9f5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b038416610be15760405162461bcd60e51b81526004016102b29190613592565b506001600160a01b03831660009081526001602090815260409182902054825180840190935260038352620c4c4d60ea1b9183019190915260ff16610c395760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b038316610c7b5760405162461bcd60e51b81526004016102b29190613592565b507f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b6576001600160a01b03166335ea6a75836001600160a01b031663b16a19de6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ce9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0d91906135df565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016101a060405180830381865afa158015610d52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d76919061368b565b60e001516001600160a01b0316826001600160a01b0316146040518060400160405280600381526020016218989960e91b81525090610dc85760405162461bcd60e51b81526004016102b29190613592565b506040516335ea6a7560e01b81526001600160a01b038481166004830152600091610e66917f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b65716906335ea6a75906024016101a060405180830381865afa158015610e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5b919061368b565b61012001513361201e565b6040805160018082528183019092529192506000919060208083019080368337019050509050610e968883612095565b81600081518110610ea957610ea96135be565b602090810291909101810191909152604080516000928101839052908101889052606081018990523360808201526001600160a01b03861660a082015260c00160408051601f1981840301815291905290506000846001811115610f0f57610f0f61378a565b14156110245760408051600180825281830190925260009160208083019080368337019050509050600081600081518110610f4c57610f4c6135be565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508781600081518110610f8f57610f8f6135be565b6001600160a01b039092166020928302919091019091015260405163ab9c4b5d60e01b8152737937d4799803fbbe595ed57278bc4ca21f3bffcb9063ab9c4b5d90610feb90309085908990889084908b906000906004016137d0565b600060405180830381600087803b15801561100557600080fd5b505af1158015611019573d6000803e3d6000fd5b505050505050611128565b6002546001146040518060400160405280600381526020016218989960e91b815250906110645760405162461bcd60e51b81526004016102b29190613592565b5060408051600180825281830190925260009160208083019080368337019050509050868160008151811061109b5761109b6135be565b6001600160a01b039092166020928302919091019091015260028055604051632e1c224f60e11b815273ba12222222228d8ba445958a75a0704d566bf2c890635c38449e906110f490309085908890889060040161384e565b600060405180830381600087803b15801561110e57600080fd5b505af1158015611122573d6000803e3d6000fd5b50505050505b6040516370a0823160e01b815230600482015261119c9087906001600160a01b038216906370a0823190602401602060405180830381865afa158015611172573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119691906135a5565b896118e3565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6001600160a01b0316906370a0823190602401602060405180830381865afa158015611204573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122891906135a5565b9050888111156112485761124561123f8a836138e8565b33611b2c565b50875b61127c6001600160a01b037f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e1633836120ab565b505060016000555050505050505050565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03851630146112d35760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015233737937d4799803fbbe595ed57278bc4ca21f3bffcb146113225760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b602082015289881461135d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201528986146113985760405162461bcd60e51b81526004016102b29190613592565b506000888860008181106113ae576113ae6135be565b90506020020135116040518060400160405280600381526020016218989960e91b815250906113f05760405162461bcd60e51b81526004016102b29190613592565b5060008a8a8281611403576114036135be565b905060200201602081019061141891906138ff565b6001600160a01b031614156040518060400160405280600381526020016218989960e91b8152509061145d5760405162461bcd60e51b81526004016102b29190613592565b506114f98a8a6000818110611474576114746135be565b905060200201602081019061148991906138ff565b8989600081811061149c5761149c6135be565b90506020020135888860008181106114b6576114b66135be565b9050602002013586868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120e092505050565b61154b737937d4799803fbbe595ed57278bc4ca21f3bffcb60008c8c6000818110611526576115266135be565b905060200201602081019061153b91906138ff565b6001600160a01b03169190612234565b6115b4737937d4799803fbbe595ed57278bc4ca21f3bffcb87876000818110611576576115766135be565b905060200201358a8a6000818110611590576115906135be565b905060200201356115a1919061391c565b8c8c6000818110611526576115266135be565b5060019998505050505050505050565b60408051808201909152600381526218989960e91b60208201523373ba12222222228d8ba445958a75a0704d566bf2c8146116125760405162461bcd60e51b81526004016102b29190613592565b506002546002146040518060400160405280600381526020016218989960e91b815250906116535760405162461bcd60e51b81526004016102b29190613592565b5082518451146040518060400160405280600381526020016218989960e91b815250906116935760405162461bcd60e51b81526004016102b29190613592565b5081518451146040518060400160405280600381526020016218989960e91b815250906116d35760405162461bcd60e51b81526004016102b29190613592565b506000836000815181106116e9576116e96135be565b6020026020010151116040518060400160405280600381526020016218989960e91b8152509061172c5760405162461bcd60e51b81526004016102b29190613592565b5060006001600160a01b03168460008151811061174b5761174b6135be565b60200260200101516001600160a01b031614156040518060400160405280600381526020016218989960e91b815250906117985760405162461bcd60e51b81526004016102b29190613592565b5060016002819055506117fb846000815181106117b7576117b76135be565b6020026020010151846000815181106117d2576117d26135be565b6020026020010151846000815181106117ed576117ed6135be565b6020026020010151846120e0565b6118723383600081518110611812576118126135be565b60200260200101518560008151811061182d5761182d6135be565b602002602001015161183f919061391c565b86600081518110611852576118526135be565b60200260200101516001600160a01b03166120ab9092919063ffffffff16565b50505050565b6040516001600160a01b03808516602483015283166044820152606481018290526118729085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612349565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21461193d5760405162461bcd60e51b81526004016102b29190613592565b50604051632e1a7d4d60e01b81526004810184905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b15801561198b57600080fd5b505af115801561199f573d6000803e3d6000fd5b505050506119ab612f63565b838152604051630b4c7e4d60e01b815273dc24316b9ae028f1497c275eb9192a3ea0f6702290630b4c7e4d9086906119ea908590600090600401613934565b6000604051808303818588803b158015611a0357600080fd5b505af1158015611a17573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600093507f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6001600160a01b031692506370a082319150602401602060405180830381865afa158015611a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa791906135a5565b9050611ae58585670de0b6b3a7640000611ae07f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6124d0565b61255f565b8110156040518060400160405280600381526020016231313560e81b81525090611b225760405162461bcd60e51b81526004016102b29190613592565b5095945050505050565b611b806001600160a01b037f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e167f000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc84612234565b60405163259f2d0160e01b81526001600160a01b037f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e811660048301526024820184905282811660448301527f000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc169063259f2d01906064015b600060405180830381600087803b158015611c1357600080fd5b505af1158015611c27573d6000803e3d6000fd5b505050505050565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c93919061396c565b60408051600180825281830190925260ff9290921692506000919060208083019080368337019050509050611d67611ccd8661271061391c565b611d6188611cda886124d0565b611ce587600a613a6b565b611d107f0000000000000000000000000000000000000000000000000000000000000012600a613a6b565b611d397f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6124d0565b611d43908f613a77565b611d4d9190613a96565b611d579190613a77565b611d619190613a96565b90612584565b81600081518110611d7a57611d7a6135be565b60209081029190910101526000611d9d611d968861271061391c565b8990612584565b6040805160016020820152908101889052606081018290526001600160a01b038b166080820152600060a0820181905291925060c00160408051601f1981840301815291905290506000856001811115611df957611df961378a565b1415611f0e5760408051600180825281830190925260009160208083019080368337019050509050600081600081518110611e3657611e366135be565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508781600081518110611e7957611e796135be565b6001600160a01b039092166020928302919091019091015260405163ab9c4b5d60e01b8152737937d4799803fbbe595ed57278bc4ca21f3bffcb9063ab9c4b5d90611ed590309085908a90889084908b906000906004016137d0565b600060405180830381600087803b158015611eef57600080fd5b505af1158015611f03573d6000803e3d6000fd5b505050505050612012565b6002546001146040518060400160405280600381526020016218989960e91b81525090611f4e5760405162461bcd60e51b81526004016102b29190613592565b50604080516001808252818301909252600091602080830190803683370190505090508681600081518110611f8557611f856135be565b6001600160a01b039092166020928302919091019091015260028055604051632e1c224f60e11b815273ba12222222228d8ba445958a75a0704d566bf2c890635c38449e90611fde90309085908990889060040161384e565b600060405180830381600087803b158015611ff857600080fd5b505af115801561200c573d6000803e3d6000fd5b50505050505b50505050505050505050565b6040516370a0823160e01b81526001600160a01b038281166004830152600091908416906370a0823190602401602060405180830381865afa158015612068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208c91906135a5565b90505b92915050565b60008183106120a4578161208c565b5090919050565b6040516001600160a01b0383166024820152604481018290526120db90849063a9059cbb60e01b906064016118ac565b505050565b6000806000806000858060200190518101906120fc9190613ac8565b94509450945094509450600084116040518060400160405280600381526020016218989960e91b815250906121445760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201528361217d5760405162461bcd60e51b81526004016102b29190613592565b5060408051808201909152600381526218989960e91b60208201526001600160a01b0383166121bf5760405162461bcd60e51b81526004016102b29190613592565b5084156121d9576121d48484848c8c8c6125ca565b612229565b60408051808201909152600381526218989960e91b60208201526001600160a01b03821661221a5760405162461bcd60e51b81526004016102b29190613592565b50612229848484848d8d61263f565b505050505050505050565b8015806122ae5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ac91906135a5565b155b6123195760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016102b2565b6040516001600160a01b0383166024820152604481018290526120db90849063095ea7b360e01b906064016118ac565b61235b826001600160a01b03166129dd565b6123a75760405162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740060448201526064016102b2565b600080836001600160a01b0316836040516123c29190613b26565b6000604051808303816000865af19150503d80600081146123ff576040519150601f19603f3d011682016040523d82523d6000602084013e612404565b606091505b5091509150816124565760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016102b2565b80511561187257808060200190518101906124719190613b42565b6118725760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102b2565b60405163b3596f0760e01b81526001600160a01b0382811660048301526000917f000000000000000000000000e5d78eb340627b8d5bcff63590ebec1ef9118c899091169063b3596f0790602401602060405180830381865afa15801561253b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208f91906135a5565b600061257b612570856127106138e8565b83611d578689613a77565b95945050505050565b6000821580612591575081155b1561259e5750600061208f565b6127106125ac600282613a96565b6125b68486613a77565b6125c0919061391c565b61208c9190613a96565b60006125d78484896118e3565b9050858110156040518060400160405280600381526020016218989b60e91b815250906126175760405162461bcd60e51b81526004016102b29190613592565b506126228186611b2c565b61263684612630848661391c565b87612a19565b50505050505050565b61264a828286612aad565b6000836001600160a01b031663b16a19de6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561268a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ae91906135df565b60405163c44b11f760e01b81526001600160a01b0380831660048301529192506000917f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b657169063c44b11f790602401602060405180830381865afa15801561271a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273e9190613b5d565b90506000612771825161ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b50505091505080600014156040518060400160405280600381526020016218989960e91b815250906127b65760405162461bcd60e51b81526004016102b29190613592565b50604051632fe4a15f60e21b81526001600160a01b038881166004830152600091829182917f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b6579091169063bf92857c9060240160c060405180830381865afa158015612826573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284a9190613b79565b5050935050925092506000846127108461271085886128699190613a77565b6128739190613a96565b61287d91906138e8565b6128879190613a77565b6128919190613a96565b6040516370a0823160e01b81526001600160a01b038d8116600483015291925060009161297391908d16906370a0823190602401602060405180830381865afa1580156128e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290691906135a5565b61292f7f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6124d0565b61295a7f0000000000000000000000000000000000000000000000000000000000000012600a613a6b565b6129649086613a77565b61296e9190613a96565b612095565b90508c8110156040518060400160405280600381526020016231313560e81b815250906129b35760405162461bcd60e51b81526004016102b29190613592565b506129c96001600160a01b038c168d3084611878565b6129d3818f612c04565b61200c8a8f612c86565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590612a1157508115155b949350505050565b60405163a415bcad60e01b81526001600160a01b03848116600483015260248201849052600260448301526000606483015282811660848301527f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b657169063a415bcad9060a401600060405180830381600087803b158015612a9957600080fd5b505af1158015612636573d6000803e3d6000fd5b612ae26001600160a01b0384167f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b6576000612234565b612b166001600160a01b0384167f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b65784612234565b60405163573ade8160e01b81526001600160a01b038481166004830152602482018490526002604483015282811660648301526000917f0000000000000000000000009f72dc67cec672bb99e3d02cbea0a21536a2b6579091169063573ade81906084016020604051808303816000875af1158015612b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bbd91906135a5565b9050600081116040518060400160405280600381526020016231313760e81b81525090612bfd5760405162461bcd60e51b81526004016102b29190613592565b5050505050565b60405163a5fdfc6360e01b81526001600160a01b037f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e8116600483015260248201849052604482018390523060648301527f000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc169063a5fdfc6390608401611bf9565b60408051808201909152600381526218989960e91b60208201526000906001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214612ce05760405162461bcd60e51b81526004016102b29190613592565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6001600160a01b0316906370a0823190602401602060405180830381865afa158015612d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6c91906135a5565b60405163cc2b27d760e01b81526004810182905260006024820181905291925073dc24316b9ae028f1497c275eb9192a3ea0f670229063cc2b27d790604401602060405180830381865afa158015612dc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dec91906135a5565b9050612e2a8285612e1c7f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e6124d0565b670de0b6b3a764000061255f565b8110156040518060400160405280600381526020016231313560e81b81525090612e675760405162461bcd60e51b81526004016102b29190613592565b50604051630d2680e960e11b815260048101839052600060248201819052604482018390529073dc24316b9ae028f1497c275eb9192a3ea0f6702290631a4d01d2906064016020604051808303816000875af1158015612ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eef91906135a5565b905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612f4057600080fd5b505af1158015612f54573d6000803e3d6000fd5b50939998505050505050505050565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b0381168114612f9657600080fd5b50565b600080600060608486031215612fae57600080fd5b8335612fb981612f81565b95602085013595506040909401359392505050565b803560028110612fdd57600080fd5b919050565b600080600080600060a08688031215612ffa57600080fd5b853594506020860135935060408601359250606086013561301a81612f81565b915061302860808701612fce565b90509295509295909350565b600081518084526020808501945080840160005b8381101561306d5781516001600160a01b031687529582019590820190600101613048565b509495945050505050565b60208152600061208c6020830184613034565b60008060008060008060c087890312156130a457600080fd5b86356130af81612f81565b955060208701359450604087013593506060870135925060808701356130d481612f81565b91506130e260a08801612fce565b90509295509295509295565b60008060008060008060c0878903121561310757600080fd5b863595506020870135945060408701359350606087013561312781612f81565b925060808701356130d481612f81565b60008083601f84011261314957600080fd5b50813567ffffffffffffffff81111561316157600080fd5b6020830191508360208260051b850101111561317c57600080fd5b9250929050565b600080600080600080600080600060a08a8c0312156131a157600080fd5b893567ffffffffffffffff808211156131b957600080fd5b6131c58d838e01613137565b909b50995060208c01359150808211156131de57600080fd5b6131ea8d838e01613137565b909950975060408c013591508082111561320357600080fd5b61320f8d838e01613137565b909750955060608c0135915061322482612f81565b90935060808b0135908082111561323a57600080fd5b818c0191508c601f83011261324e57600080fd5b81358181111561325d57600080fd5b8d602082850101111561326f57600080fd5b6020830194508093505050509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff811182821017156132c2576132c2613288565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156132f1576132f1613288565b604052919050565b600067ffffffffffffffff82111561331357613313613288565b5060051b60200190565b600082601f83011261332e57600080fd5b8135602061334361333e836132f9565b6132c8565b82815260059290921b8401810191818101908684111561336257600080fd5b8286015b8481101561337d5780358352918301918301613366565b509695505050505050565b600082601f83011261339957600080fd5b813567ffffffffffffffff8111156133b3576133b3613288565b6133c6601f8201601f19166020016132c8565b8181528460208386010111156133db57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561340e57600080fd5b843567ffffffffffffffff8082111561342657600080fd5b818701915087601f83011261343a57600080fd5b8135602061344a61333e836132f9565b82815260059290921b8401810191818101908b84111561346957600080fd5b948201945b8386101561349057853561348181612f81565b8252948201949082019061346e565b985050880135925050808211156134a657600080fd5b6134b28883890161331d565b945060408701359150808211156134c857600080fd5b6134d48883890161331d565b935060608701359150808211156134ea57600080fd5b506134f787828801613388565b91505092959194509250565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60005b8381101561355557818101518382015260200161353d565b838111156118725750506000910152565b6000815180845261357e81602086016020860161353a565b601f01601f19169290920160200192915050565b60208152600061208c6020830184613566565b6000602082840312156135b757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b8051612fdd81612f81565b6000602082840312156135f157600080fd5b81516135fc81612f81565b9392505050565b60006020828403121561361557600080fd5b6040516020810181811067ffffffffffffffff8211171561363857613638613288565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff81168114612fdd57600080fd5b805164ffffffffff81168114612fdd57600080fd5b805160ff81168114612fdd57600080fd5b60006101a0828403121561369e57600080fd5b6136a661329e565b6136b08484613603565b81526136be60208401613645565b60208201526136cf60408401613645565b60408201526136e060608401613645565b60608201526136f160808401613645565b608082015261370260a08401613645565b60a082015261371360c08401613665565b60c082015261372460e084016135d4565b60e08201526101006137378185016135d4565b908201526101206137498482016135d4565b9082015261014061375b8482016135d4565b9082015261016061376d8482016135d4565b9082015261018061377f84820161367a565b908201529392505050565b634e487b7160e01b600052602160045260246000fd5b600081518084526020808501945080840160005b8381101561306d578151875295820195908201906001016137b4565b600060018060a01b03808a16835260e060208401526137f260e084018a613034565b8381036040850152613804818a6137a0565b9050838103606085015261381881896137a0565b9050818716608085015283810360a08501526138348187613566565b9250505061ffff831660c083015298975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b8181101561389c57855185168352948301949183019160010161387e565b505085810360408701526138b081896137a0565b935050505082810360608401526138c78185613566565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156138fa576138fa6138d2565b500390565b60006020828403121561391157600080fd5b81356135fc81612f81565b6000821982111561392f5761392f6138d2565b500190565b60608101818460005b600281101561395c57815183526020928301929091019060010161393d565b5050508260408301529392505050565b60006020828403121561397e57600080fd5b61208c8261367a565b600181815b808511156139c25781600019048211156139a8576139a86138d2565b808516156139b557918102915b93841c939080029061398c565b509250929050565b6000826139d95750600161208f565b816139e65750600061208f565b81600181146139fc5760028114613a0657613a22565b600191505061208f565b60ff841115613a1757613a176138d2565b50506001821b61208f565b5060208310610133831016604e8410600b8410161715613a45575081810a61208f565b613a4f8383613987565b8060001904821115613a6357613a636138d2565b029392505050565b600061208c83836139ca565b6000816000190483118215151615613a9157613a916138d2565b500290565b600082613ab357634e487b7160e01b600052601260045260246000fd5b500490565b80518015158114612fdd57600080fd5b600080600080600060a08688031215613ae057600080fd5b613ae986613ab8565b945060208601519350604086015192506060860151613b0781612f81565b6080870151909250613b1881612f81565b809150509295509295909350565b60008251613b3881846020870161353a565b9190910192915050565b600060208284031215613b5457600080fd5b61208c82613ab8565b600060208284031215613b6f57600080fd5b61208c8383613603565b60008060008060008060c08789031215613b9257600080fd5b865195506020870151945060408701519350606087015192506080870151915060a08701519050929550929550929556fea2646970667358221220ee5bb7c1397cc26bf3ad79edda3d7078a1549168c6df7035733b06369348594364736f6c634300080a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000006325440d014e39736583c165c2963ba99faf14e000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc00000000000000000000000040ea6e14800f6040d25a9a5a1e9cc0f5cb6d1066
-----Decoded View---------------
Arg [0] : _asset (address): 0x06325440D014e39736583c165C2963BA99fAf14E
Arg [1] : _vault (address): 0xa36BE47700C079BD94adC09f35B0FA93A55297bc
Arg [2] : _provider (address): 0x40ea6e14800F6040D25A9a5a1E9cC0F5Cb6D1066
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000006325440d014e39736583c165c2963ba99faf14e
Arg [1] : 000000000000000000000000a36be47700c079bd94adc09f35b0fa93a55297bc
Arg [2] : 00000000000000000000000040ea6e14800f6040d25a9a5a1e9cc0f5cb6d1066
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.