Source Code
Latest 6 from a total of 6 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Set Proxy Contra... | 16316172 | 348 days ago | IN | 0 FRAX | 0.00000009 | ||||
| Set Proxy Contra... | 16316154 | 348 days ago | IN | 0 FRAX | 0.0000001 | ||||
| Set Proxy Contra... | 16316077 | 348 days ago | IN | 0 FRAX | 0.0000001 | ||||
| Set Proxy Contra... | 16315968 | 348 days ago | IN | 0 FRAX | 0.0000001 | ||||
| Set Proxy Contra... | 16315902 | 348 days ago | IN | 0 FRAX | 0.00000009 | ||||
| Set Proxy Contra... | 16315648 | 348 days ago | IN | 0 FRAX | 0.00000011 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
FlashMintLiquidatorAaveBorrowRepayCurve
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity 0.8.20;
import {FlashMintLiquidatorAaveBorrowRepayBase, SafeTransferLib, ERC20, IERC3156FlashLender, ILendingPoolAddressesProvider, ILendingPool, IAToken} from "./FlashMintLiquidatorAaveBorrowRepayBase.sol";
import {CurveHelper} from "contracts/curve/CurveHelper.sol";
import {ICurveRouterNgPoolsOnlyV1} from "contracts/curve/interfaces/ICurveRouterNgPoolsOnlyV1.sol";
import {ICurveRouterWrapper} from "contracts/curve/interfaces/ICurveRouterWrapper.sol";
import {Strings} from "@openzeppelin/contracts-5/utils/Strings.sol";
contract FlashMintLiquidatorAaveBorrowRepayCurve is
FlashMintLiquidatorAaveBorrowRepayBase
{
using SafeTransferLib for ERC20;
error NotSupportedCustomSwapData(
address _inputToken,
address _outputToken,
bytes _swapData
);
struct CurveSwapExtraParamsDefaultConfig {
address inputToken;
address outputToken;
CurveHelper.CurveSwapExtraParams swapExtraParams;
CurveHelper.CurveSwapExtraParams reverseSwapExtraParams;
}
ICurveRouterNgPoolsOnlyV1 public immutable curveRouter;
uint256 public immutable maxSlippageSurplusSwapBps;
mapping(string => CurveHelper.CurveSwapExtraParams)
public defaultSwapParams;
mapping(string => bool) public isSwapParamsSet;
constructor(
IERC3156FlashLender _flashMinter,
ILendingPoolAddressesProvider _addressesProvider,
ILendingPool _liquidateLender,
IAToken _aDUSD,
uint256 _slippageTolerance,
ICurveRouterNgPoolsOnlyV1 _curveRouter,
uint256 _maxSlippageSurplusSwapBps,
CurveSwapExtraParamsDefaultConfig[] memory _defaultSwapParamsList
)
FlashMintLiquidatorAaveBorrowRepayBase(
_flashMinter,
_addressesProvider,
_liquidateLender,
_aDUSD,
_slippageTolerance
)
{
curveRouter = ICurveRouterNgPoolsOnlyV1(payable(address(_curveRouter)));
maxSlippageSurplusSwapBps = _maxSlippageSurplusSwapBps;
for (uint256 i = 0; i < _defaultSwapParamsList.length; i++) {
// Set for forward swap
string memory key = _getSwapExtraParamsKey(
_defaultSwapParamsList[i].inputToken,
_defaultSwapParamsList[i].outputToken
);
if (isSwapParamsSet[key]) {
revert ICurveRouterWrapper.DuplicateKeyForSwapExtraParams(
_defaultSwapParamsList[i].inputToken,
_defaultSwapParamsList[i].outputToken,
key
);
}
isSwapParamsSet[key] = true;
defaultSwapParams[key] = _defaultSwapParamsList[i].swapExtraParams;
// Set for reverse swap
string memory reverseKey = _getSwapExtraParamsKey(
_defaultSwapParamsList[i].outputToken,
_defaultSwapParamsList[i].inputToken
);
if (isSwapParamsSet[reverseKey]) {
revert ICurveRouterWrapper.DuplicateKeyForSwapExtraParams(
_defaultSwapParamsList[i].outputToken,
_defaultSwapParamsList[i].inputToken,
reverseKey
);
}
isSwapParamsSet[reverseKey] = true;
defaultSwapParams[reverseKey] = _defaultSwapParamsList[i]
.reverseSwapExtraParams;
}
}
function setSwapExtraParams(
CurveSwapExtraParamsDefaultConfig memory _swapExtraParamsConfig
) external onlyOwner {
string memory key = _getSwapExtraParamsKey(
_swapExtraParamsConfig.inputToken,
_swapExtraParamsConfig.outputToken
);
isSwapParamsSet[key] = true;
defaultSwapParams[key] = _swapExtraParamsConfig.swapExtraParams;
string memory reverseKey = _getSwapExtraParamsKey(
_swapExtraParamsConfig.outputToken,
_swapExtraParamsConfig.inputToken
);
isSwapParamsSet[reverseKey] = true;
defaultSwapParams[reverseKey] = _swapExtraParamsConfig
.reverseSwapExtraParams;
}
function _getSwapExtraParamsKey(
address _inputToken,
address _outputToken
) internal pure returns (string memory) {
string memory key = string.concat(
Strings.toHexString(uint160(_inputToken), 20),
"-",
Strings.toHexString(uint160(_outputToken), 20)
);
return key;
}
function _getSwapExtraParams(
address _inputToken,
address _outputToken
) internal view returns (CurveHelper.CurveSwapExtraParams memory) {
string memory key = _getSwapExtraParamsKey(_inputToken, _outputToken);
// If the key is not found, revert
if (!isSwapParamsSet[key]) {
revert ICurveRouterWrapper.NotFoundKeyForSwapExtraParams(
_inputToken,
_outputToken,
key
);
}
return defaultSwapParams[key];
}
/// @inheritdoc FlashMintLiquidatorAaveBorrowRepayBase
function _swapExactOutput(
address _inputToken,
address _outputToken,
bytes memory _swapData,
uint256 _amount,
uint256 _maxIn
) internal override returns (uint256 amountIn) {
// If _swapData is not empty, revert (TODO: need to fix this)
if (_swapData.length != 0) {
revert NotSupportedCustomSwapData(
_inputToken,
_outputToken,
_swapData
);
}
// As Curve does not support exact output swaps, we need to calculate the required input amount
// and add a buffer to account for potential slippage. Then swapping back the surplus amount
CurveHelper.CurveSwapExtraParams
memory extraParams = _getSwapExtraParams(_inputToken, _outputToken);
CurveHelper.CurveSwapExtraParams
memory reverseExtraParams = _getSwapExtraParams(
_outputToken,
_inputToken
);
// Double check _inputToken is the first token in the route
if (_inputToken != extraParams.route[0]) {
revert ICurveRouterWrapper.InvalidInputTokenInRoute(
_inputToken,
extraParams.route
);
}
return
CurveHelper.swapExactOutput(
curveRouter,
extraParams.route,
extraParams.swapParams,
reverseExtraParams.route,
reverseExtraParams.swapParams,
extraParams.swapSlippageBufferBps,
maxSlippageSurplusSwapBps,
_amount,
_maxIn
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
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 making 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
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20, IERC20Metadata, ERC20} from "../ERC20.sol";
import {SafeERC20} from "../utils/SafeERC20.sol";
import {IERC4626} from "../../../interfaces/IERC4626.sol";
import {Math} from "../../../utils/math/Math.sol";
/**
* @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in
* https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].
*
* This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for
* underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends
* the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this
* contract and not the "assets" token which is an independent contract.
*
* [CAUTION]
* ====
* In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
* with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
* attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
* deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
* similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
* verifying the amount received is as expected, using a wrapper that performs these checks such as
* https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
*
* Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`
* corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault
* decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself
* determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset
* (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's
* donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more
* expensive than it is profitable. More details about the underlying math can be found
* xref:erc4626.adoc#inflation-attack[here].
*
* The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
* to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
* will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
* bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
* `_convertToShares` and `_convertToAssets` functions.
*
* To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
* ====
*/
abstract contract ERC4626 is ERC20, IERC4626 {
using Math for uint256;
IERC20 private immutable _asset;
uint8 private immutable _underlyingDecimals;
/**
* @dev Attempted to deposit more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
/**
* @dev Attempted to mint more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
/**
* @dev Attempted to withdraw more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
/**
* @dev Attempted to redeem more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
/**
* @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).
*/
constructor(IERC20 asset_) {
(bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);
_underlyingDecimals = success ? assetDecimals : 18;
_asset = asset_;
}
/**
* @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
*/
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {
(bool success, bytes memory encodedDecimals) = address(asset_).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
if (success && encodedDecimals.length >= 32) {
uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));
if (returnedDecimals <= type(uint8).max) {
return (true, uint8(returnedDecimals));
}
}
return (false, 0);
}
/**
* @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This
* "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the
* asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.
*
* See {IERC20Metadata-decimals}.
*/
function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {
return _underlyingDecimals + _decimalsOffset();
}
/** @dev See {IERC4626-asset}. */
function asset() public view virtual returns (address) {
return address(_asset);
}
/** @dev See {IERC4626-totalAssets}. */
function totalAssets() public view virtual returns (uint256) {
return _asset.balanceOf(address(this));
}
/** @dev See {IERC4626-convertToShares}. */
function convertToShares(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/** @dev See {IERC4626-convertToAssets}. */
function convertToAssets(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/** @dev See {IERC4626-maxDeposit}. */
function maxDeposit(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxMint}. */
function maxMint(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxWithdraw}. */
function maxWithdraw(address owner) public view virtual returns (uint256) {
return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
}
/** @dev See {IERC4626-maxRedeem}. */
function maxRedeem(address owner) public view virtual returns (uint256) {
return balanceOf(owner);
}
/** @dev See {IERC4626-previewDeposit}. */
function previewDeposit(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/** @dev See {IERC4626-previewMint}. */
function previewMint(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Ceil);
}
/** @dev See {IERC4626-previewWithdraw}. */
function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Ceil);
}
/** @dev See {IERC4626-previewRedeem}. */
function previewRedeem(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/** @dev See {IERC4626-deposit}. */
function deposit(uint256 assets, address receiver) public virtual returns (uint256) {
uint256 maxAssets = maxDeposit(receiver);
if (assets > maxAssets) {
revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
}
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares);
return shares;
}
/** @dev See {IERC4626-mint}.
*
* As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.
* In this case, the shares will be minted without requiring any assets to be deposited.
*/
function mint(uint256 shares, address receiver) public virtual returns (uint256) {
uint256 maxShares = maxMint(receiver);
if (shares > maxShares) {
revert ERC4626ExceededMaxMint(receiver, shares, maxShares);
}
uint256 assets = previewMint(shares);
_deposit(_msgSender(), receiver, assets, shares);
return assets;
}
/** @dev See {IERC4626-withdraw}. */
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {
uint256 maxAssets = maxWithdraw(owner);
if (assets > maxAssets) {
revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);
}
uint256 shares = previewWithdraw(assets);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return shares;
}
/** @dev See {IERC4626-redeem}. */
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {
uint256 maxShares = maxRedeem(owner);
if (shares > maxShares) {
revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);
}
uint256 assets = previewRedeem(shares);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return assets;
}
/**
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*/
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {
return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);
}
/**
* @dev Internal conversion function (from shares to assets) with support for rounding direction.
*/
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {
return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);
}
/**
* @dev Deposit/mint common workflow.
*/
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {
// If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the
// `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the
// assets are transferred and before the shares are minted, which is a valid state.
// slither-disable-next-line reentrancy-no-eth
SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);
_mint(receiver, shares);
emit Deposit(caller, receiver, assets, shares);
}
/**
* @dev Withdraw/redeem common workflow.
*/
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal virtual {
if (caller != owner) {
_spendAllowance(owner, caller, shares);
}
// If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
// `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the
// shares are burned and after the assets are transferred, which is a valid state.
_burn(owner, shares);
SafeERC20.safeTransfer(_asset, receiver, assets);
emit Withdraw(caller, receiver, owner, assets, shares);
}
function _decimalsOffset() internal view virtual returns (uint8) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/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;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
require(success, "TRANSFER_FROM_FAILED");
}
function safeTransfer(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "TRANSFER_FAILED");
}
function safeApprove(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "APPROVE_FAILED");
}
}// SPDX-License-Identifier: GNU AGPLv3
pragma solidity 0.8.20;
import {ICurveRouterNgPoolsOnlyV1} from "contracts/curve/interfaces/ICurveRouterNgPoolsOnlyV1.sol";
import {ICurveRouterWrapper} from "contracts/curve/interfaces/ICurveRouterWrapper.sol";
import {Constants} from "contracts/shared/Constants.sol";
import {ERC20} from "@rari-capital/solmate/src/tokens/ERC20.sol";
library CurveHelper {
/// @notice Get the last non-zero token in the route
function getLastTokenInRoute(
address[11] memory route
) public pure returns (address) {
for (uint256 i = route.length - 1; i >= 0; i--) {
if (route[i] != address(0)) {
return route[i];
}
}
revert("No token in route");
}
struct CurveSwapExtraParams {
address[11] route;
uint256[4][5] swapParams;
uint256 swapSlippageBufferBps;
}
function decodeCurveSwapExtraParams(
bytes memory data
) public pure returns (CurveSwapExtraParams memory _swapExtraParams) {
(
_swapExtraParams.route,
_swapExtraParams.swapParams,
_swapExtraParams.swapSlippageBufferBps
) = abi.decode(data, (address[11], uint256[4][5], uint256));
}
function swapExactOutput(
ICurveRouterNgPoolsOnlyV1 _curveRouter,
address[11] memory _route,
uint256[4][5] memory _swapParams,
address[11] memory _reverseRoute,
uint256[4][5] memory _reverseSwapParams,
uint256 swapSlippageBufferBps,
uint256 maxSlippageSurplusSwapBps,
uint256 _amountOutput,
uint256 _maxInputAmount
) public returns (uint256) {
// As Curve does not support exact output swaps, we need to calculate the required input amount
// and add a buffer to account for potential slippage. Then swapping back the surplus amount
address inputToken = _route[0];
// Calculate the required input amount
uint256 estimatedAmountIn = _curveRouter.get_dx(
_route,
_swapParams,
_amountOutput
);
// Add a buffer to account for potential slippage
uint256 amountIn = (estimatedAmountIn *
(Constants.ONE_HUNDRED_PERCENT_BPS + swapSlippageBufferBps)) /
Constants.ONE_HUNDRED_PERCENT_BPS;
// amountIn cannot exceed current balance of input token
uint256 inputTokenBalance = ERC20(inputToken).balanceOf(address(this));
if (amountIn > inputTokenBalance) {
amountIn = inputTokenBalance;
}
if (amountIn > _maxInputAmount) {
revert ICurveRouterWrapper.InputAmountExceedsMaximum(
amountIn,
_maxInputAmount
);
}
// Input token balance before the swap
uint256 inputTokenBalanceBefore = ERC20(inputToken).balanceOf(
address(this)
);
// Approve the router to spend our tokens
ERC20(inputToken).approve(address(_curveRouter), _maxInputAmount);
// Execute the swap
uint256 actualAmountOut = _curveRouter.exchange(
_route,
_swapParams,
amountIn,
_amountOutput, // This is now our minimum expected output
address(this) // The receiver of the output tokens
);
// Get the difference between the actual and expected output
uint256 redundantAmount = actualAmountOut - _amountOutput;
// Swap the redundant amount back to the input token with the reverse route
if (redundantAmount > 0) {
// Calculate estimated amount out for the swap back
uint256 estimatedSwapBackAmountOut = _curveRouter.get_dy(
_reverseRoute,
_reverseSwapParams,
redundantAmount
);
// Calculate minimum output amount using maxSlippageSurplusSwapBps
uint256 minSwapBackAmountOut = (estimatedSwapBackAmountOut *
(Constants.ONE_HUNDRED_PERCENT_BPS -
maxSlippageSurplusSwapBps)) /
Constants.ONE_HUNDRED_PERCENT_BPS;
address outputToken = getLastTokenInRoute(_route);
ERC20(outputToken).approve(address(_curveRouter), redundantAmount);
_curveRouter.exchange(
_reverseRoute,
_reverseSwapParams,
redundantAmount,
minSwapBackAmountOut,
address(this)
);
}
// Input token balance after the swap
uint256 inputTokenBalanceAfter = ERC20(inputToken).balanceOf(
address(this)
);
if (inputTokenBalanceAfter < inputTokenBalanceBefore) {
uint256 usedInputAmount = inputTokenBalanceBefore -
inputTokenBalanceAfter;
return usedInputAmount;
} else {
return 0;
}
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
/**
* @dev Interface for Curve.Fi RouterNG contract (pools-only version 1).
* @dev Generated from original ABI: https://fraxscan.com/address/0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db#code
*/
interface ICurveRouterNgPoolsOnlyV1 {
event Exchange(
address indexed sender,
address indexed receiver,
address[11] route,
uint256[4][5] swap_params,
uint256 in_amount,
uint256 out_amount
);
function exchange(
address[11] calldata _route,
uint256[4][5] calldata _swap_params,
uint256 _amount,
uint256 _min_dy
) external payable returns (uint256);
function exchange(
address[11] calldata _route,
uint256[4][5] calldata _swap_params,
uint256 _amount,
uint256 _min_dy,
address _receiver
) external payable returns (uint256);
function get_dy(
address[11] calldata _route,
uint256[4][5] calldata _swap_params,
uint256 _amount
) external view returns (uint256);
function get_dx(
address[11] calldata _route,
uint256[4][5] calldata _swap_params,
uint256 _out_amount
) external view returns (uint256);
function version() external view returns (string memory);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "./IRouterNG.sol";
interface ICurveRouterWrapper {
error InsufficientOutputAmount(uint256 amountOut, uint256 minAmountOut);
error InputAmountExceedsMaximum(uint256 amountIn, uint256 maxAmountIn);
error InvalidRouteLength(address[11] route);
error InvalidInputTokenInRoute(address tokenIn, address[11] route);
error NotFoundKeyForSwapExtraParams(
address inputToken,
address outputToken,
string key
);
error DuplicateKeyForSwapExtraParams(
address inputToken,
address outputToken,
string key
);
function router() external view returns (ICurveRouterNG);
/**
* @dev Executes a token swap on Curve with exact input
* @param route The route of the swap
* @param swapParams The swap parameters
* @param amountIn The exact amount of input tokens
* @param minAmountOut The minimum amount of output tokens to receive
* @param pools The pools to use for the swap
* @param tokenIn The address of the input token
* @return The amount of output tokens received
*/
function swapExactIn(
address[11] calldata route,
uint256[5][5] calldata swapParams,
uint256 amountIn,
uint256 minAmountOut,
address[5] calldata pools,
address tokenIn
) external returns (uint256);
/**
* @dev Executes a token swap on Curve with exact output
* @param route The route of the swap
* @param swapParams The swap parameters
* @param amountOut The exact amount of output tokens to receive
* @param maxAmountIn The maximum amount of input tokens to spend
* @param pools The pools to use for the swap
* @param tokenIn The address of the input token
* @return The amount of input tokens spent
*/
function swapExactOutput(
address[11] calldata route,
uint256[5][5] calldata swapParams,
uint256 amountOut,
uint256 maxAmountIn,
address[5] calldata pools,
address tokenIn
) external returns (uint256);
/**
* @dev Gets the expected output amount for a swap
* @param route The route of the swap
* @param swapParams The swap parameters
* @param amountIn The amount of input tokens
* @param pools The pools to use for the swap
* @return The expected amount of output tokens
*/
function getExpectedOutput(
address[11] calldata route,
uint256[5][5] calldata swapParams,
uint256 amountIn,
address[5] calldata pools
) external view returns (uint256);
/**
* @dev Gets the expected input amount for a desired output amount
* @param route The route of the swap
* @param swapParams The swap parameters
* @param amountOut The desired amount of output tokens
* @param pools The pools to use for the swap
* @return The expected amount of input tokens required
*/
function getExpectedInput(
address[11] calldata route,
uint256[5][5] calldata swapParams,
uint256 amountOut,
address[5] calldata pools
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
/**
* @dev Interface for Curve.Fi RouterNG contract.
* @dev See original implementation in official repository:
* https://github.com/curvefi/curve-router-ng/blob/master/contracts/Router.vy
* ABI: https://etherscan.io/address/0x16C6521Dff6baB339122a0FE25a9116693265353#code
*/
interface ICurveRouterNG {
event Exchange(
address indexed sender,
address indexed receiver,
address[11] route,
uint256[5][5] swap_params,
address[5] pools,
uint256 in_amount,
uint256 out_amount
);
fallback() external payable;
receive() external payable;
function exchange(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _amount,
uint256 _min_dy
) external payable returns (uint256);
function exchange(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _amount,
uint256 _min_dy,
address[5] calldata _pools
) external payable returns (uint256);
function exchange(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _amount,
uint256 _min_dy,
address[5] calldata _pools,
address _receiver
) external payable returns (uint256);
function get_dy(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _amount
) external view returns (uint256);
function get_dy(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _amount,
address[5] calldata _pools
) external view returns (uint256);
function get_dx(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _out_amount,
address[5] calldata _pools
) external view returns (uint256);
function get_dx(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _out_amount,
address[5] calldata _pools,
address[5] calldata _base_pools
) external view returns (uint256);
function get_dx(
address[11] calldata _route,
uint256[5][5] calldata _swap_params,
uint256 _out_amount,
address[5] calldata _pools,
address[5] calldata _base_pools,
address[5] calldata _base_tokens
) external view returns (uint256);
function version() external view returns (string memory);
}// SPDX-License-Identifier: GPL-2.0-or-later
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity >=0.7.5;
pragma abicoder v2;
import "contracts/dex/core/interfaces/callback/IUniswapV3SwapCallback.sol";
/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(
ExactInputSingleParams calldata params
) external payable returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(
ExactInputParams calldata params
) external payable returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(
ExactOutputSingleParams calldata params
) external payable returns (uint256 amountIn);
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(
ExactOutputParams calldata params
) external payable returns (uint256 amountIn);
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity 0.8.20;
import "../interface/IERC3156FlashLender.sol";
import "../interface/IERC3156FlashBorrower.sol";
import "../interface/IWETH.sol";
import "../interface/aave-v3/aave/ILendingPoolAddressesProvider.sol";
import "../interface/aave-v3/aave/IPriceOracleGetter.sol";
import "../../lending/core/interfaces/IAToken.sol";
import "../interface/aave-v3/ILiquidator.sol";
import "../interface/aave-v3/libraries/aave/ReserveConfiguration.sol";
import "../libraries/PercentageMath.sol";
import "../interface/aave-v3/aave/ILendingPool.sol";
import "@openzeppelin/contracts-4-6/security/ReentrancyGuard.sol";
import "../common/SharedLiquidator.sol";
import {ERC4626} from "@openzeppelin/contracts-5/token/ERC20/extensions/ERC4626.sol";
abstract contract FlashMintLiquidatorAaveBase is
ReentrancyGuard,
SharedLiquidator,
IERC3156FlashBorrower
{
using SafeTransferLib for ERC20;
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using PercentageMath for uint256;
struct FlashLoanParams {
address collateralUnderlying;
address borrowedUnderlying;
address poolTokenCollateral;
address poolTokenBorrowed;
address liquidator;
address borrower;
uint256 toLiquidate;
bool isUnstakeCollateralToken;
bytes swapData;
}
struct LiquidateParams {
ERC20 collateralUnderlying;
ERC20 borrowedUnderlying;
IAToken poolTokenCollateral;
IAToken poolTokenBorrowed;
address liquidator;
address borrower;
uint256 toRepay;
bool isUnstakeCollateralToken;
}
error InvalidSlippageTolerance(uint256 value);
error UnknownLender();
error UnknownInitiator();
error NoProfitableLiquidation();
event Liquidated(
address indexed liquidator,
address borrower,
address indexed poolTokenBorrowedAddress,
address indexed poolTokenCollateralAddress,
uint256 amount,
uint256 seized,
bool usingFlashLoan
);
event FlashLoan(address indexed initiator, uint256 amount);
bytes32 public constant FLASHLOAN_CALLBACK =
keccak256("ERC3156FlashBorrower.onFlashLoan");
IERC3156FlashLender public immutable flashMinter;
ILendingPool public immutable liquidateLender;
ILendingPoolAddressesProvider public immutable addressesProvider;
IAToken public immutable aDUSD;
ERC20 public immutable dusd;
uint256 public immutable DUSD_DECIMALS;
constructor(
IERC3156FlashLender _flashMinter,
ILendingPool _liquidateLender,
ILendingPoolAddressesProvider _addressesProvider,
IAToken _aDUSD
) SharedLiquidator() {
flashMinter = _flashMinter;
liquidateLender = _liquidateLender;
addressesProvider = _addressesProvider;
aDUSD = _aDUSD;
dusd = ERC20(_aDUSD.UNDERLYING_ASSET_ADDRESS());
DUSD_DECIMALS = dusd.decimals();
}
function _liquidateInternal(
LiquidateParams memory _liquidateParams
) internal returns (uint256 seized_) {
uint256 balanceBefore = _liquidateParams.collateralUnderlying.balanceOf(
address(this)
);
_liquidateParams.borrowedUnderlying.safeApprove(
address(liquidateLender),
_liquidateParams.toRepay
);
liquidateLender.liquidationCall(
address(
_getUnderlying(address(_liquidateParams.poolTokenCollateral))
),
address(
_getUnderlying(address(_liquidateParams.poolTokenBorrowed))
),
_liquidateParams.borrower,
_liquidateParams.toRepay,
false
);
seized_ =
_liquidateParams.collateralUnderlying.balanceOf(address(this)) -
balanceBefore;
emit Liquidated(
msg.sender,
_liquidateParams.borrower,
address(_liquidateParams.poolTokenBorrowed),
address(_liquidateParams.poolTokenCollateral),
_liquidateParams.toRepay,
seized_,
false
);
}
function redeemERC4626Token(
address _collateralERC4626Token,
uint256 _amount,
address _recipient
) public returns (uint256) {
return
ERC4626(_collateralERC4626Token).redeem(
_amount,
_recipient,
_recipient
);
}
function _liquidateWithFlashLoan(
FlashLoanParams memory _flashLoanParams
) internal returns (uint256 seized_, address actualCollateralToken_) {
bytes memory data = _encodeData(_flashLoanParams);
uint256 dusdToFlashLoan = _getDUSDToFlashloan(
_flashLoanParams.borrowedUnderlying,
_flashLoanParams.toLiquidate
);
dusd.safeApprove(
address(flashMinter),
dusdToFlashLoan +
flashMinter.flashFee(address(dusd), dusdToFlashLoan)
);
(actualCollateralToken_, ) = getActualCollateralToken(
_flashLoanParams.collateralUnderlying,
_flashLoanParams.isUnstakeCollateralToken
);
uint256 balanceBefore = ERC20(actualCollateralToken_).balanceOf(
address(this)
);
// The liquidation is done in the callback at onFlashLoan()
// - contracts/lending_liquidator/aave-v3/FlashMintLiquidatorAaveBorrowRepayUniswapV3.sol
// - The flashLoan() of the minter will call the onFlashLoan() function of the receiver (IERC3156FlashBorrower)
flashMinter.flashLoan(this, address(dusd), dusdToFlashLoan, data);
uint256 balanceAfter = ERC20(actualCollateralToken_).balanceOf(
address(this)
);
if (balanceAfter > balanceBefore) {
seized_ = balanceAfter - balanceBefore;
} else {
// As there is no profit, the seized amount is 0
seized_ = 0;
}
emit FlashLoan(msg.sender, dusdToFlashLoan);
}
/**
* @dev Get the actual collateral token address
* @param _collateralUnderlying The underlying collateral token address
* @param _isUnstakeCollateralToken Whether the collateral token is unstaked
* @return actualCollateralToken_ The actual collateral token address
* @return proxyContract_ The proxy contract address
*/
function getActualCollateralToken(
address _collateralUnderlying,
bool _isUnstakeCollateralToken
)
public
view
virtual
returns (address actualCollateralToken_, address proxyContract_);
function _getDUSDToFlashloan(
address,
uint256
) internal view returns (uint256 amountToFlashLoan_) {
// As there is no fee for flash minting DUSD, we can flash mint the maximum amount
// Maximum value of uint256
amountToFlashLoan_ = flashMinter.maxFlashLoan(address(dusd));
// This is the old way of calculating the amount to flash loan
//
// if (_underlyingToRepay == address(dusd)) {
// amountToFlashLoan_ = _amountToRepay;
// } else {
// IPriceOracleGetter oracle = IPriceOracleGetter(
// addressesProvider.getPriceOracle()
// );
// (uint256 loanToValue, , , , ) = lendingPool
// .getConfiguration(address(dusd))
// .getParamsMemory();
// uint256 dusdPrice = oracle.getAssetPrice(address(dusd));
// uint256 borrowedTokenPrice = oracle.getAssetPrice(
// _underlyingToRepay
// );
// uint256 underlyingDecimals = ERC20(_underlyingToRepay).decimals();
// amountToFlashLoan_ =
// (((_amountToRepay * borrowedTokenPrice * 10 ** DUSD_DECIMALS) /
// dusdPrice /
// 10 ** underlyingDecimals) * ONE_HUNDER_PCT_BPS) /
// loanToValue +
// 1e18; // for rounding errors of supply/borrow on aave
// }
}
function _encodeData(
FlashLoanParams memory _flashLoanParams
) internal pure returns (bytes memory data) {
data = abi.encode(
_flashLoanParams.collateralUnderlying,
_flashLoanParams.borrowedUnderlying,
_flashLoanParams.poolTokenCollateral,
_flashLoanParams.poolTokenBorrowed,
_flashLoanParams.liquidator,
_flashLoanParams.borrower,
_flashLoanParams.toLiquidate,
_flashLoanParams.isUnstakeCollateralToken,
_flashLoanParams.swapData
);
}
function _decodeData(
bytes calldata data
) internal pure returns (FlashLoanParams memory _flashLoanParams) {
// Need to split the decode because of stack too deep error
(
_flashLoanParams.collateralUnderlying,
_flashLoanParams.borrowedUnderlying,
_flashLoanParams.poolTokenCollateral,
_flashLoanParams.poolTokenBorrowed,
,
,
,
,
) = abi.decode(
data,
(
address,
address,
address,
address,
address,
address,
uint256,
bool,
bytes
)
);
(
,
,
,
,
_flashLoanParams.liquidator,
_flashLoanParams.borrower,
_flashLoanParams.toLiquidate,
_flashLoanParams.isUnstakeCollateralToken,
_flashLoanParams.swapData
) = abi.decode(
data,
(
address,
address,
address,
address,
address,
address,
uint256,
bool,
bytes
)
);
}
function _getUnderlying(
address _poolToken
) internal view returns (ERC20 underlying_) {
underlying_ = ERC20(IAToken(_poolToken).UNDERLYING_ASSET_ADDRESS());
}
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity 0.8.20;
import "../../dex/periphery/interfaces/ISwapRouter.sol";
import "./FlashMintLiquidatorAaveBase.sol";
import {Constants} from "../../shared/Constants.sol";
abstract contract FlashMintLiquidatorAaveBorrowRepayBase is
FlashMintLiquidatorAaveBase
{
using SafeTransferLib for ERC20;
using PercentageMath for uint256;
uint256 public slippageTolerance; // in basis points units
event SlippageToleranceSet(uint256 newTolerance);
error NotSupportingNonDUSD(address borrowedToken, string symbol);
mapping(address => address) private proxyContractMap;
constructor(
IERC3156FlashLender _flashMinter,
ILendingPoolAddressesProvider _addressesProvider,
ILendingPool _liquidateLender,
IAToken _aDUSD,
uint256 _slippageTolerance
)
FlashMintLiquidatorAaveBase(
_flashMinter,
_liquidateLender,
_addressesProvider,
_aDUSD
)
{
slippageTolerance = _slippageTolerance;
emit SlippageToleranceSet(_slippageTolerance);
}
function setProxyContract(
address _collateralUnderlying,
address _proxyContract
) external onlyOwner {
proxyContractMap[_collateralUnderlying] = _proxyContract;
}
function getProxyContract(
address _collateralUnderlying
) public view returns (address) {
address proxyContract = proxyContractMap[_collateralUnderlying];
if (proxyContract != address(0)) {
return proxyContract;
}
return _collateralUnderlying;
}
function setSlippageTolerance(uint256 _newTolerance) external onlyOwner {
if (_newTolerance > Constants.ONE_HUNDRED_PERCENT_BPS)
revert InvalidSlippageTolerance(_newTolerance);
slippageTolerance = _newTolerance;
emit SlippageToleranceSet(_newTolerance);
}
function liquidate(
address _poolTokenBorrowedAddress,
address _poolTokenCollateralAddress,
address _borrower,
uint256 _repayAmount,
bool _stakeTokens,
bool _isUnstakeCollateralToken,
bytes memory _swapData
) external nonReentrant {
LiquidateParams memory liquidateParams = LiquidateParams(
_getUnderlying(_poolTokenCollateralAddress),
_getUnderlying(_poolTokenBorrowedAddress),
IAToken(_poolTokenCollateralAddress),
IAToken(_poolTokenBorrowedAddress),
msg.sender,
_borrower,
_repayAmount,
_isUnstakeCollateralToken
);
uint256 seized;
address actualCollateralToken;
if (
liquidateParams.borrowedUnderlying.balanceOf(address(this)) >=
_repayAmount
)
// we can liquidate without flash loan by using the contract balance
seized = _liquidateInternal(liquidateParams);
else {
FlashLoanParams memory params = FlashLoanParams(
address(liquidateParams.collateralUnderlying),
address(liquidateParams.borrowedUnderlying),
address(liquidateParams.poolTokenCollateral),
address(liquidateParams.poolTokenBorrowed),
liquidateParams.liquidator,
liquidateParams.borrower,
liquidateParams.toRepay,
_isUnstakeCollateralToken,
_swapData
);
(seized, actualCollateralToken) = _liquidateWithFlashLoan(params);
}
if (!_stakeTokens)
ERC20(actualCollateralToken).safeTransfer(msg.sender, seized);
}
/// @dev ERC-3156 Flash loan callback
function onFlashLoan(
address _initiator,
address,
uint256, // flashloan amount
uint256,
bytes calldata data
) external override returns (bytes32) {
if (msg.sender != address(flashMinter)) revert UnknownLender();
if (_initiator != address(this)) revert UnknownInitiator();
FlashLoanParams memory flashLoanParams = _decodeData(data);
_flashLoanInternal(flashLoanParams);
return FLASHLOAN_CALLBACK;
}
function _flashLoanInternal(
FlashLoanParams memory _flashLoanParams
) internal {
if (_flashLoanParams.borrowedUnderlying != address(dusd)) {
revert NotSupportingNonDUSD(
_flashLoanParams.borrowedUnderlying,
ERC20(_flashLoanParams.borrowedUnderlying).symbol()
);
}
LiquidateParams memory liquidateParams = LiquidateParams(
ERC20(_flashLoanParams.collateralUnderlying),
ERC20(_flashLoanParams.borrowedUnderlying),
IAToken(_flashLoanParams.poolTokenCollateral),
IAToken(_flashLoanParams.poolTokenBorrowed),
_flashLoanParams.liquidator,
_flashLoanParams.borrower,
_flashLoanParams.toLiquidate,
_flashLoanParams.isUnstakeCollateralToken
);
uint256 seized = _liquidateInternal(liquidateParams);
if (
_flashLoanParams.borrowedUnderlying !=
_flashLoanParams.collateralUnderlying
) {
(
address actualCollateralToken,
address proxyContract
) = getActualCollateralToken(
_flashLoanParams.collateralUnderlying,
_flashLoanParams.isUnstakeCollateralToken
);
uint256 actualCollateralAmount = seized;
// If isUnstakeCollateralToken is true, we need to unstake the collateral to its underlying token
if (_flashLoanParams.isUnstakeCollateralToken) {
// Approve to burn the shares
ERC20(_flashLoanParams.collateralUnderlying).approve(
proxyContract,
actualCollateralAmount
);
actualCollateralAmount = redeemERC4626Token(
proxyContract,
actualCollateralAmount,
address(this)
);
}
// need a swap
// we use aave oracle
IPriceOracleGetter oracle = IPriceOracleGetter(
addressesProvider.getPriceOracle()
);
uint256 maxIn = (((actualCollateralAmount *
10 ** ERC20(actualCollateralToken).decimals() *
oracle.getAssetPrice(_flashLoanParams.borrowedUnderlying)) /
oracle.getAssetPrice(actualCollateralToken) /
10 ** liquidateParams.borrowedUnderlying.decimals()) *
(Constants.ONE_HUNDRED_PERCENT_BPS + slippageTolerance)) /
Constants.ONE_HUNDRED_PERCENT_BPS;
_swapExactOutput(
actualCollateralToken,
_flashLoanParams.borrowedUnderlying,
_flashLoanParams.swapData,
_flashLoanParams.toLiquidate,
maxIn
);
}
emit Liquidated(
_flashLoanParams.liquidator,
_flashLoanParams.borrower,
_flashLoanParams.poolTokenBorrowed,
_flashLoanParams.poolTokenCollateral,
_flashLoanParams.toLiquidate,
seized,
true
);
}
function getActualCollateralToken(
address _collateralUnderlying,
bool _isUnstakeCollateralToken
)
public
view
override
returns (address actualCollateralToken_, address proxyContract_)
{
if (_isUnstakeCollateralToken) {
proxyContract_ = getProxyContract(_collateralUnderlying);
actualCollateralToken_ = ERC4626(proxyContract_).asset();
} else {
actualCollateralToken_ = _collateralUnderlying;
}
// If not unstake, the proxyContract_ is zero address
return (actualCollateralToken_, proxyContract_);
}
/// @dev Swap exact output amount of tokens (need to override this method)
/// @param _inputToken address of the token to swap
/// @param _outputToken address of the token to swap
/// @param _swapData swap data
/// @param _amount amount of tokens to swap
/// @param _maxIn maximum amount of input tokens
/// @return amountIn amount of input tokens
function _swapExactOutput(
address _inputToken,
address _outputToken,
bytes memory _swapData,
uint256 _amount,
uint256 _maxIn
) internal virtual returns (uint256 amountIn);
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity 0.8.20;
import "@rari-capital/solmate/src/utils/SafeTransferLib.sol";
import "@openzeppelin/contracts-4-6/access/Ownable.sol";
contract SharedLiquidator is Ownable {
using SafeTransferLib for ERC20;
mapping(address => bool) public isLiquidator;
error OnlyLiquidator();
event LiquidatorAdded(address indexed _liquidatorAdded);
event LiquidatorRemoved(address indexed _liquidatorRemoved);
event Withdrawn(
address indexed sender,
address indexed receiver,
address indexed underlyingAddress,
uint256 amount
);
modifier onlyLiquidator() {
if (!isLiquidator[msg.sender]) revert OnlyLiquidator();
_;
}
constructor() {
isLiquidator[msg.sender] = true;
emit LiquidatorAdded(msg.sender);
}
function addLiquidator(address _newLiquidator) external onlyOwner {
isLiquidator[_newLiquidator] = true;
emit LiquidatorAdded(_newLiquidator);
}
function removeLiquidator(address _liquidatorToRemove) external onlyOwner {
isLiquidator[_liquidatorToRemove] = false;
emit LiquidatorRemoved(_liquidatorToRemove);
}
function withdraw(
address _underlyingAddress,
address _receiver,
uint256 _amount
) external onlyOwner {
uint256 amountMax = ERC20(_underlyingAddress).balanceOf(address(this));
uint256 amount = _amount > amountMax ? amountMax : _amount;
ERC20(_underlyingAddress).safeTransfer(_receiver, amount);
emit Withdrawn(msg.sender, _receiver, _underlyingAddress, amount);
}
}// SPDX-License-Identifier: agpl-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from "./ILendingPoolAddressesProvider.sol";
import "../../../../lending/core/interfaces/IPool.sol";
interface ILendingPool is IPool {}// SPDX-License-Identifier: agpl-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
import "../../../../lending/core/interfaces/IPoolAddressesProvider.sol";
/**
* @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 Aave Governance
* @author Aave
**/
interface ILendingPoolAddressesProvider is IPoolAddressesProvider {}// SPDX-License-Identifier: UNLICENSED
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/************
@title IPriceOracleGetter interface
@notice Interface for the Aave price oracle.*/
interface IPriceOracleGetter {
/***********
@dev returns the asset price in ETH
*/
function getAssetPrice(address _asset) external view returns (uint256);
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
interface ILiquidator {
function liquidate(
address _poolTokenBorrowed,
address _poolTokenCollateral,
address _borrower,
uint256 _amount
) external;
}// SPDX-License-Identifier: agpl-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title Errors library
* @author Aave
* @notice Defines the error messages emitted by the different contracts of the Aave 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 public constant CALLER_NOT_POOL_ADMIN = "33"; // 'The caller must be the pool admin'
string public constant BORROW_ALLOWANCE_NOT_ENOUGH = "59"; // User borrows on behalf, but allowance are too small
//contract specific errors
string public constant VL_INVALID_AMOUNT = "1"; // 'Amount must be greater than 0'
string public constant VL_NO_ACTIVE_RESERVE = "2"; // 'Action requires an active reserve'
string public constant VL_RESERVE_FROZEN = "3"; // 'Action cannot be performed because the reserve is frozen'
string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = "4"; // 'The current liquidity is not enough'
string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = "5"; // 'User cannot withdraw more than the available balance'
string public constant VL_TRANSFER_NOT_ALLOWED = "6"; // 'Transfer cannot be allowed.'
string public constant VL_BORROWING_NOT_ENABLED = "7"; // 'Borrowing is not enabled'
string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = "8"; // 'Invalid interest rate mode selected'
string public constant VL_COLLATERAL_BALANCE_IS_0 = "9"; // 'The collateral balance is 0'
string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD =
"10"; // 'Health factor is lesser than the liquidation threshold'
string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = "11"; // 'There is not enough collateral to cover a new borrow'
string public constant VL_STABLE_BORROWING_NOT_ENABLED = "12"; // stable borrowing not enabled
string public constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = "13"; // collateral is (mostly) the same currency that is being borrowed
string public 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 public 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 public 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 public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = "17"; // 'User does not have a stable rate loan in progress on this reserve'
string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = "18"; // 'User does not have a variable rate loan in progress on this reserve'
string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = "19"; // 'The underlying balance needs to be greater than 0'
string public constant VL_DEPOSIT_ALREADY_IN_USE = "20"; // 'User deposit is already being used as collateral'
string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = "21"; // 'User does not have any stable rate loan for this reserve'
string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = "22"; // 'Interest rate rebalance conditions were not met'
string public constant LP_LIQUIDATION_CALL_FAILED = "23"; // 'Liquidation call failed'
string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = "24"; // 'There is not enough liquidity available to borrow'
string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = "25"; // 'The requested amount is too small for a FlashLoan.'
string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = "26"; // 'The actual balance of the protocol is inconsistent'
string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = "27"; // 'The caller of the function is not the lending pool configurator'
string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = "28";
string public constant CT_CALLER_MUST_BE_LENDING_POOL = "29"; // 'The caller of this function must be a lending pool'
string public constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = "30"; // 'User cannot give allowance to himself'
string public constant CT_TRANSFER_AMOUNT_NOT_GT_0 = "31"; // 'Transferred amount needs to be greater than zero'
string public constant RL_RESERVE_ALREADY_INITIALIZED = "32"; // 'Reserve has already been initialized'
string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = "34"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_ATOKEN_POOL_ADDRESS = "35"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = "36"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = "37"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS =
"38"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS =
"39"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = "40"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_CONFIGURATION = "75"; // 'Invalid risk parameters for the reserve'
string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = "76"; // 'The caller must be the emergency admin'
string public constant LPAPR_PROVIDER_NOT_REGISTERED = "41"; // 'Provider is not registered'
string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = "42"; // 'Health factor is not below the threshold'
string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = "43"; // 'The collateral chosen cannot be liquidated'
string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = "44"; // 'User did not borrow the specified currency'
string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = "45"; // "There isn't enough liquidity available to liquidate"
string public constant LPCM_NO_ERRORS = "46"; // 'No errors'
string public constant LP_INVALID_FLASHLOAN_MODE = "47"; //Invalid flashloan mode selected
string public constant MATH_MULTIPLICATION_OVERFLOW = "48";
string public constant MATH_ADDITION_OVERFLOW = "49";
string public constant MATH_DIVISION_BY_ZERO = "50";
string public constant RL_LIQUIDITY_INDEX_OVERFLOW = "51"; // Liquidity index overflows uint128
string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = "52"; // Variable borrow index overflows uint128
string public constant RL_LIQUIDITY_RATE_OVERFLOW = "53"; // Liquidity rate overflows uint128
string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = "54"; // Variable borrow rate overflows uint128
string public constant RL_STABLE_BORROW_RATE_OVERFLOW = "55"; // Stable borrow rate overflows uint128
string public constant CT_INVALID_MINT_AMOUNT = "56"; //invalid amount to mint
string public constant LP_FAILED_REPAY_WITH_COLLATERAL = "57";
string public constant CT_INVALID_BURN_AMOUNT = "58"; //invalid amount to burn
string public constant LP_FAILED_COLLATERAL_SWAP = "60";
string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = "61";
string public constant LP_REENTRANCY_NOT_ALLOWED = "62";
string public constant LP_CALLER_MUST_BE_AN_ATOKEN = "63";
string public constant LP_IS_PAUSED = "64"; // 'Pool is paused'
string public constant LP_NO_MORE_RESERVES_ALLOWED = "65";
string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = "66";
string public constant RC_INVALID_LTV = "67";
string public constant RC_INVALID_LIQ_THRESHOLD = "68";
string public constant RC_INVALID_LIQ_BONUS = "69";
string public constant RC_INVALID_DECIMALS = "70";
string public constant RC_INVALID_RESERVE_FACTOR = "71";
string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = "72";
string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = "73";
string public constant LP_INCONSISTENT_PARAMS_LENGTH = "74";
string public constant UL_INVALID_INDEX = "77";
string public constant LP_NOT_CONTRACT = "78";
string public constant SDT_STABLE_DEBT_OVERFLOW = "79";
string public constant SDT_BURN_EXCEEDS_BALANCE = "80";
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
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
import {Errors} from "./Errors.sol";
import {DataTypes} from "../../../../../lending/core/protocol/libraries/types/DataTypes.sol";
/**
* @title ReserveConfiguration library
* @author 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
/// @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 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 memory self
) internal pure 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 memory self
) internal pure returns (bool) {
return (self.data & ~BORROWING_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
**/
function getFlags(
DataTypes.ReserveConfigurationMap storage self
) internal view returns (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
);
}
/**
* @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
**/
function getFlagsMemory(
DataTypes.ReserveConfigurationMap memory self
) internal pure returns (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
);
}
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity 0.8.20;
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity 0.8.20;
import "./IERC3156FlashBorrower.sol";
interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lent.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(
address token,
uint256 amount
) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}// SPDX-License-Identifier: GNU AGPLv3
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
interface IWETH {
function deposit() external payable;
function withdraw(uint256) external;
}// SPDX-License-Identifier: BUSL-1.1
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title PercentageMath library
* @author 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. If a value is >=.5, will be rounded up, otherwise rounded down.
**/
library PercentageMath {
// Maximum percentage factor (100.00%)
uint256 internal constant PERCENTAGE_FACTOR = 1e4;
// Half percentage factor (50.00%)
uint256 internal constant HALF_PERCENTAGE_FACTOR = 0.5e4;
/**
* @notice Executes a percentage multiplication
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return result value percentmul percentage
**/
function percentMul(
uint256 value,
uint256 percentage
) internal pure returns (uint256 result) {
// to avoid overflow, value <= (type(uint256).max - HALF_PERCENTAGE_FACTOR) / percentage
assembly {
if iszero(
or(
iszero(percentage),
iszero(
gt(
value,
div(sub(not(0), HALF_PERCENTAGE_FACTOR), percentage)
)
)
)
) {
revert(0, 0)
}
result := div(
add(mul(value, percentage), HALF_PERCENTAGE_FACTOR),
PERCENTAGE_FACTOR
)
}
}
/**
* @notice Executes a percentage division
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return result value percentdiv percentage
**/
function percentDiv(
uint256 value,
uint256 percentage
) internal pure returns (uint256 result) {
// to avoid overflow, value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR
assembly {
if or(
iszero(percentage),
iszero(
iszero(
gt(
value,
div(
sub(not(0), div(percentage, 2)),
PERCENTAGE_FACTOR
)
)
)
)
) {
revert(0, 0)
}
result := div(
add(mul(value, PERCENTAGE_FACTOR), div(percentage, 2)),
percentage
)
}
}
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
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
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title IAaveIncentivesController
* @author Aave
* @notice Defines the basic interface for an Aave Incentives Controller.
* @dev It only contains one single function, needed as a hook on aToken and debtToken transfers.
*/
interface IAaveIncentivesController {
/**
* @dev Called by the corresponding asset on transfer hook in order to update the rewards distribution.
* @dev The units of `totalSupply` and `userBalance` should be the same.
* @param user The address of the user whose asset balance has changed
* @param totalSupply The total supply of the asset prior to user balance change
* @param userBalance The previous user balance prior to balance change
*/
function handleAction(
address user,
uint256 totalSupply,
uint256 userBalance
) external;
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
import {IERC20} from "../dependencies/openzeppelin/contracts/IERC20.sol";
import {IScaledBalanceToken} from "./IScaledBalanceToken.sol";
import {IInitializableAToken} from "./IInitializableAToken.sol";
/**
* @title IAToken
* @author Aave
* @notice Defines the basic interface for an AToken.
*/
interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken {
/**
* @dev Emitted during the transfer action
* @param from The user whose tokens are being transferred
* @param to The recipient
* @param value The scaled amount being transferred
* @param index The next liquidity index of the reserve
*/
event BalanceTransfer(
address indexed from,
address indexed to,
uint256 value,
uint256 index
);
/**
* @notice Mints `amount` aTokens to `user`
* @param caller The address performing the mint
* @param onBehalfOf The address of the user that will receive the minted aTokens
* @param amount The amount of tokens getting minted
* @param index The next liquidity index of the reserve
* @return `true` if the the previous balance of the user was 0
*/
function mint(
address caller,
address onBehalfOf,
uint256 amount,
uint256 index
) external returns (bool);
/**
* @notice Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying`
* @dev In some instances, the mint event could be emitted from a burn transaction
* if the amount to burn is less than the interest that the user accrued
* @param from The address from which the aTokens will be burned
* @param receiverOfUnderlying The address that will receive the underlying
* @param amount The amount being burned
* @param index The next liquidity index of the reserve
*/
function burn(
address from,
address receiverOfUnderlying,
uint256 amount,
uint256 index
) external;
/**
* @notice Mints aTokens to the reserve treasury
* @param amount The amount of tokens getting minted
* @param index The next liquidity index of the reserve
*/
function mintToTreasury(uint256 amount, uint256 index) external;
/**
* @notice 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;
/**
* @notice Transfers the underlying asset to `target`.
* @dev Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()
* @param target The recipient of the underlying
* @param amount The amount getting transferred
*/
function transferUnderlyingTo(address target, uint256 amount) external;
/**
* @notice Handles the underlying received by the aToken after the transfer has been completed.
* @dev The default implementation is empty as with standard ERC20 tokens, nothing needs to be done after the
* transfer is concluded. However in the future there may be aTokens that allow for example to stake the underlying
* to receive LM rewards. In that case, `handleRepayment()` would perform the staking of the underlying asset.
* @param user The user executing the repayment
* @param onBehalfOf The address of the user who will get his debt reduced/removed
* @param amount The amount getting repaid
*/
function handleRepayment(
address user,
address onBehalfOf,
uint256 amount
) external;
/**
* @notice Allow passing a signed message to approve spending
* @dev implements the permit function as for
* https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
* @param owner The owner of the funds
* @param spender The spender
* @param value The amount
* @param deadline The deadline timestamp, type(uint256).max for max deadline
* @param v Signature param
* @param s Signature param
* @param r Signature param
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @notice Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
* @return The address of the underlying asset
*/
function UNDERLYING_ASSET_ADDRESS() external view returns (address);
/**
* @notice Returns the address of the Aave treasury, receiving the fees on this aToken.
* @return Address of the Aave treasury
*/
function RESERVE_TREASURY_ADDRESS() external view returns (address);
/**
* @notice Get the domain separator for the token
* @dev Return cached value if chainId matches cache, otherwise recomputes separator
* @return The domain separator of the token at current chain
*/
function DOMAIN_SEPARATOR() external view returns (bytes32);
/**
* @notice Returns the nonce for owner.
* @param owner The address of the owner
* @return The nonce of the owner
*/
function nonces(address owner) external view returns (uint256);
/**
* @notice Rescue and transfer tokens locked in this contract
* @param token The address of the token
* @param to The address of the recipient
* @param amount The amount of token to transfer
*/
function rescueTokens(address token, address to, uint256 amount) external;
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
import {IAaveIncentivesController} from "./IAaveIncentivesController.sol";
import {IPool} from "./IPool.sol";
/**
* @title IInitializableAToken
* @author Aave
* @notice Interface for the initialize function on AToken
*/
interface IInitializableAToken {
/**
* @dev Emitted when an aToken is initialized
* @param underlyingAsset The address of the underlying asset
* @param pool The address of the associated 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
);
/**
* @notice Initializes the aToken
* @param pool The pool contract that is initializing this contract
* @param treasury The address of the Aave 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
* @param params A set of encoded parameters for additional initialization
*/
function initialize(
IPool pool,
address treasury,
address underlyingAsset,
IAaveIncentivesController incentivesController,
uint8 aTokenDecimals,
string calldata aTokenName,
string calldata aTokenSymbol,
bytes calldata params
) external;
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
import {IPoolAddressesProvider} from "./IPoolAddressesProvider.sol";
import {DataTypes} from "../protocol/libraries/types/DataTypes.sol";
/**
* @title IPool
* @author Aave
* @notice Defines the basic interface for an Aave Pool.
*/
interface IPool {
/**
* @dev Emitted on mintUnbacked()
* @param reserve The address of the underlying asset of the reserve
* @param user The address initiating the supply
* @param onBehalfOf The beneficiary of the supplied assets, receiving the aTokens
* @param amount The amount of supplied assets
* @param referralCode The referral code used
*/
event MintUnbacked(
address indexed reserve,
address user,
address indexed onBehalfOf,
uint256 amount,
uint16 indexed referralCode
);
/**
* @dev Emitted on backUnbacked()
* @param reserve The address of the underlying asset of the reserve
* @param backer The address paying for the backing
* @param amount The amount added as backing
* @param fee The amount paid in fees
*/
event BackUnbacked(
address indexed reserve,
address indexed backer,
uint256 amount,
uint256 fee
);
/**
* @dev Emitted on supply()
* @param reserve The address of the underlying asset of the reserve
* @param user The address initiating the supply
* @param onBehalfOf The beneficiary of the supply, receiving the aTokens
* @param amount The amount supplied
* @param referralCode The referral code used
*/
event Supply(
address indexed reserve,
address user,
address indexed onBehalfOf,
uint256 amount,
uint16 indexed referralCode
);
/**
* @dev Emitted on withdraw()
* @param reserve The address of the underlying asset being withdrawn
* @param user The address initiating the withdrawal, owner of aTokens
* @param to The 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 interestRateMode The rate mode: 1 for Stable, 2 for Variable
* @param borrowRate The numeric rate at which the user has borrowed, expressed in ray
* @param referralCode The referral code used
*/
event Borrow(
address indexed reserve,
address user,
address indexed onBehalfOf,
uint256 amount,
DataTypes.InterestRateMode interestRateMode,
uint256 borrowRate,
uint16 indexed referralCode
);
/**
* @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
* @param useATokens True if the repayment is done using aTokens, `false` if done with underlying asset directly
*/
event Repay(
address indexed reserve,
address indexed user,
address indexed repayer,
uint256 amount,
bool useATokens
);
/**
* @dev Emitted on swapBorrowRateMode()
* @param reserve The address of the underlying asset of the reserve
* @param user The address of the user swapping his rate mode
* @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable
*/
event SwapBorrowRateMode(
address indexed reserve,
address indexed user,
DataTypes.InterestRateMode interestRateMode
);
/**
* @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets
* @param asset The address of the underlying asset of the reserve
* @param totalDebt The total isolation mode debt for the reserve
*/
event IsolationModeTotalDebtUpdated(
address indexed asset,
uint256 totalDebt
);
/**
* @dev Emitted when the user selects a certain asset category for eMode
* @param user The address of the user
* @param categoryId The category id
*/
event UserEModeSet(address indexed user, uint8 categoryId);
/**
* @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 rebalanceStableBorrowRate()
* @param reserve The address of the underlying asset of the reserve
* @param user The address of the user for which the rebalance has been executed
*/
event RebalanceStableBorrowRate(
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 interestRateMode The flashloan mode: 0 for regular flashloan, 1 for Stable debt, 2 for Variable debt
* @param premium The fee flash borrowed
* @param referralCode The referral code used
*/
event FlashLoan(
address indexed target,
address initiator,
address indexed asset,
uint256 amount,
DataTypes.InterestRateMode interestRateMode,
uint256 premium,
uint16 indexed referralCode
);
/**
* @dev Emitted when a borrower is liquidated.
* @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 liquidator
* @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.
* @param reserve The address of the underlying asset of the reserve
* @param liquidityRate The next liquidity rate
* @param stableBorrowRate The next stable borrow rate
* @param variableBorrowRate The next variable borrow rate
* @param liquidityIndex The next liquidity index
* @param variableBorrowIndex The next variable borrow index
*/
event ReserveDataUpdated(
address indexed reserve,
uint256 liquidityRate,
uint256 stableBorrowRate,
uint256 variableBorrowRate,
uint256 liquidityIndex,
uint256 variableBorrowIndex
);
/**
* @dev Emitted when the protocol treasury receives minted aTokens from the accrued interest.
* @param reserve The address of the reserve
* @param amountMinted The amount minted to the treasury
*/
event MintedToTreasury(address indexed reserve, uint256 amountMinted);
/**
* @notice Mints an `amount` of aTokens to the `onBehalfOf`
* @param asset The address of the underlying asset to mint
* @param amount The amount to mint
* @param onBehalfOf The address that will receive the aTokens
* @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 mintUnbacked(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @notice Back the current unbacked underlying with `amount` and pay `fee`.
* @param asset The address of the underlying asset to back
* @param amount The amount to back
* @param fee The amount paid in fees
* @return The backed amount
*/
function backUnbacked(
address asset,
uint256 amount,
uint256 fee
) external returns (uint256);
/**
* @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User supplies 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to supply
* @param amount The amount to be supplied
* @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 supply(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @notice Supply with transfer approval of asset to be supplied done via permit function
* see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
* @param asset The address of the underlying asset to supply
* @param amount The amount to be supplied
* @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 deadline The deadline timestamp that the permit is valid
* @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 permitV The V parameter of ERC712 permit sig
* @param permitR The R parameter of ERC712 permit sig
* @param permitS The S parameter of ERC712 permit sig
*/
function supplyWithPermit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external;
/**
* @notice 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
* @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 The 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);
/**
* @notice Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
* already supplied 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`
* @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 The 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 The 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
* @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 interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
* @param onBehalfOf The 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 interestRateMode,
address onBehalfOf
) external returns (uint256);
/**
* @notice Repay with transfer approval of asset to be repaid done via permit function
* see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
* @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 interestRateMode 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
* @param deadline The deadline timestamp that the permit is valid
* @param permitV The V parameter of ERC712 permit sig
* @param permitR The R parameter of ERC712 permit sig
* @param permitS The S parameter of ERC712 permit sig
* @return The final amount repaid
*/
function repayWithPermit(
address asset,
uint256 amount,
uint256 interestRateMode,
address onBehalfOf,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external returns (uint256);
/**
* @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the
* equivalent debt tokens
* - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable/stable debt tokens
* @dev Passing uint256.max as amount will clean up any residual aToken dust balance, if the user aToken
* balance is not enough to cover the whole debt
* @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 interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
* @return The final amount repaid
*/
function repayWithATokens(
address asset,
uint256 amount,
uint256 interestRateMode
) external returns (uint256);
/**
* @notice Allows a borrower to swap his debt between stable and variable mode, or vice versa
* @param asset The address of the underlying asset borrowed
* @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable
*/
function swapBorrowRateMode(
address asset,
uint256 interestRateMode
) external;
/**
* @notice Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.
* - Users can be rebalanced if the following conditions are satisfied:
* 1. Usage ratio is above 95%
* 2. the current supply APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too
* much has been borrowed at a stable rate and suppliers are not earning enough
* @param asset The address of the underlying asset borrowed
* @param user The address of the user to be rebalanced
*/
function rebalanceStableBorrowRate(address asset, address user) external;
/**
* @notice Allows suppliers to enable/disable a specific supplied asset as collateral
* @param asset The address of the underlying asset supplied
* @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise
*/
function setUserUseReserveAsCollateral(
address asset,
bool useAsCollateral
) external;
/**
* @notice 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
* @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;
/**
* @notice Allows smartcontracts to access the liquidity of the pool within one transaction,
* as long as the amount taken plus a fee is returned.
* @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept
* into consideration. For further details please visit https://docs.aave.com/developers/
* @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanReceiver interface
* @param assets The addresses of the assets being flash-borrowed
* @param amounts The amounts of the assets being flash-borrowed
* @param interestRateModes 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 The 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 interestRateModes,
address onBehalfOf,
bytes calldata params,
uint16 referralCode
) external;
/**
* @notice Allows smartcontracts to access the liquidity of the pool within one transaction,
* as long as the amount taken plus a fee is returned.
* @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept
* into consideration. For further details please visit https://docs.aave.com/developers/
* @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanSimpleReceiver interface
* @param asset The address of the asset being flash-borrowed
* @param amount The amount of the asset being flash-borrowed
* @param params Variadic packed params to pass to the receiver as extra information
* @param referralCode The 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 flashLoanSimple(
address receiverAddress,
address asset,
uint256 amount,
bytes calldata params,
uint16 referralCode
) external;
/**
* @notice Returns the user account data across all the reserves
* @param user The address of the user
* @return totalCollateralBase The total collateral of the user in the base currency used by the price feed
* @return totalDebtBase The total debt of the user in the base currency used by the price feed
* @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed
* @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 totalCollateralBase,
uint256 totalDebtBase,
uint256 availableBorrowsBase,
uint256 currentLiquidationThreshold,
uint256 ltv,
uint256 healthFactor
);
/**
* @notice Initializes a reserve, activating it, assigning an aToken and debt tokens and an
* interest rate strategy
* @dev Only callable by the PoolConfigurator contract
* @param asset The address of the underlying asset 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 asset,
address aTokenAddress,
address stableDebtAddress,
address variableDebtAddress,
address interestRateStrategyAddress
) external;
/**
* @notice Drop a reserve
* @dev Only callable by the PoolConfigurator contract
* @param asset The address of the underlying asset of the reserve
*/
function dropReserve(address asset) external;
/**
* @notice Updates the address of the interest rate strategy contract
* @dev Only callable by the PoolConfigurator contract
* @param asset The address of the underlying asset of the reserve
* @param rateStrategyAddress The address of the interest rate strategy contract
*/
function setReserveInterestRateStrategyAddress(
address asset,
address rateStrategyAddress
) external;
/**
* @notice Sets the configuration bitmap of the reserve as a whole
* @dev Only callable by the PoolConfigurator contract
* @param asset The address of the underlying asset of the reserve
* @param configuration The new configuration bitmap
*/
function setConfiguration(
address asset,
DataTypes.ReserveConfigurationMap calldata configuration
) external;
/**
* @notice 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);
/**
* @notice 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);
/**
* @notice Returns the 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);
/**
* @notice Returns the normalized variable debt per unit of asset
* @dev WARNING: This function is intended to be used primarily by the protocol itself to get a
* "dynamic" variable index based on time, current stored index and virtual rate at the current
* moment (approx. a borrower would get if opening a position). This means that is always used in
* combination with variable debt supply/balances.
* If using this function externally, consider that is possible to have an increasing normalized
* variable debt that is not equivalent to how the variable debt index would be updated in storage
* (e.g. only updates with non-zero variable debt supply)
* @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);
/**
* @notice Returns the state and configuration of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The state and configuration data of the reserve
*/
function getReserveData(
address asset
) external view returns (DataTypes.ReserveData memory);
/**
* @notice Validates and finalizes an aToken transfer
* @dev Only callable by the overlying aToken of the `asset`
* @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 balanceFromBefore 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 balanceFromBefore,
uint256 balanceToBefore
) external;
/**
* @notice Returns the list of the underlying assets of all the initialized reserves
* @dev It does not include dropped reserves
* @return The addresses of the underlying assets of the initialized reserves
*/
function getReservesList() external view returns (address[] memory);
/**
* @notice Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct
* @param id The id of the reserve as stored in the DataTypes.ReserveData struct
* @return The address of the reserve associated with id
*/
function getReserveAddressById(uint16 id) external view returns (address);
/**
* @notice Returns the PoolAddressesProvider connected to this contract
* @return The address of the PoolAddressesProvider
*/
function ADDRESSES_PROVIDER()
external
view
returns (IPoolAddressesProvider);
/**
* @notice Updates the protocol fee on the bridging
* @param bridgeProtocolFee The part of the premium sent to the protocol treasury
*/
function updateBridgeProtocolFee(uint256 bridgeProtocolFee) external;
/**
* @notice Updates flash loan premiums. Flash loan premium consists of two parts:
* - A part is sent to aToken holders as extra, one time accumulated interest
* - A part is collected by the protocol treasury
* @dev The total premium is calculated on the total borrowed amount
* @dev The premium to protocol is calculated on the total premium, being a percentage of `flashLoanPremiumTotal`
* @dev Only callable by the PoolConfigurator contract
* @param flashLoanPremiumTotal The total premium, expressed in bps
* @param flashLoanPremiumToProtocol The part of the premium sent to the protocol treasury, expressed in bps
*/
function updateFlashloanPremiums(
uint128 flashLoanPremiumTotal,
uint128 flashLoanPremiumToProtocol
) external;
/**
* @notice Configures a new category for the eMode.
* @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category.
* The category 0 is reserved as it's the default for volatile assets
* @param id The id of the category
* @param config The configuration of the category
*/
function configureEModeCategory(
uint8 id,
DataTypes.EModeCategory memory config
) external;
/**
* @notice Returns the data of an eMode category
* @param id The id of the category
* @return The configuration data of the category
*/
function getEModeCategoryData(
uint8 id
) external view returns (DataTypes.EModeCategory memory);
/**
* @notice Allows a user to use the protocol in eMode
* @param categoryId The id of the category
*/
function setUserEMode(uint8 categoryId) external;
/**
* @notice Returns the eMode the user is using
* @param user The address of the user
* @return The eMode id
*/
function getUserEMode(address user) external view returns (uint256);
/**
* @notice Resets the isolation mode total debt of the given asset to zero
* @dev It requires the given asset has zero debt ceiling
* @param asset The address of the underlying asset to reset the isolationModeTotalDebt
*/
function resetIsolationModeTotalDebt(address asset) external;
/**
* @notice Returns the percentage of available liquidity that can be borrowed at once at stable rate
* @return The percentage of available liquidity to borrow, expressed in bps
*/
function MAX_STABLE_RATE_BORROW_SIZE_PERCENT()
external
view
returns (uint256);
/**
* @notice Returns the total fee on flash loans
* @return The total fee on flashloans
*/
function FLASHLOAN_PREMIUM_TOTAL() external view returns (uint128);
/**
* @notice Returns the part of the bridge fees sent to protocol
* @return The bridge fee sent to the protocol treasury
*/
function BRIDGE_PROTOCOL_FEE() external view returns (uint256);
/**
* @notice Returns the part of the flashloan fees sent to protocol
* @return The flashloan fee sent to the protocol treasury
*/
function FLASHLOAN_PREMIUM_TO_PROTOCOL() external view returns (uint128);
/**
* @notice Returns the maximum number of reserves supported to be listed in this Pool
* @return The maximum number of reserves supported
*/
function MAX_NUMBER_RESERVES() external view returns (uint16);
/**
* @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens
* @param assets The list of reserves for which the minting needs to be executed
*/
function mintToTreasury(address[] calldata assets) external;
/**
* @notice Rescue and transfer tokens locked in this contract
* @param token The address of the token
* @param to The address of the recipient
* @param amount The amount of token to transfer
*/
function rescueTokens(address token, address to, uint256 amount) external;
/**
* @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User supplies 100 USDC and gets in return 100 aUSDC
* @dev Deprecated: Use the `supply` function instead
* @param asset The address of the underlying asset to supply
* @param amount The amount to be supplied
* @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;
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title IPoolAddressesProvider
* @author Aave
* @notice Defines the basic interface for a Pool Addresses Provider.
*/
interface IPoolAddressesProvider {
/**
* @dev Emitted when the market identifier is updated.
* @param oldMarketId The old id of the market
* @param newMarketId The new id of the market
*/
event MarketIdSet(string indexed oldMarketId, string indexed newMarketId);
/**
* @dev Emitted when the pool is updated.
* @param oldAddress The old address of the Pool
* @param newAddress The new address of the Pool
*/
event PoolUpdated(address indexed oldAddress, address indexed newAddress);
/**
* @dev Emitted when the pool configurator is updated.
* @param oldAddress The old address of the PoolConfigurator
* @param newAddress The new address of the PoolConfigurator
*/
event PoolConfiguratorUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the price oracle is updated.
* @param oldAddress The old address of the PriceOracle
* @param newAddress The new address of the PriceOracle
*/
event PriceOracleUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the ACL manager is updated.
* @param oldAddress The old address of the ACLManager
* @param newAddress The new address of the ACLManager
*/
event ACLManagerUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the ACL admin is updated.
* @param oldAddress The old address of the ACLAdmin
* @param newAddress The new address of the ACLAdmin
*/
event ACLAdminUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the price oracle sentinel is updated.
* @param oldAddress The old address of the PriceOracleSentinel
* @param newAddress The new address of the PriceOracleSentinel
*/
event PriceOracleSentinelUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the pool data provider is updated.
* @param oldAddress The old address of the PoolDataProvider
* @param newAddress The new address of the PoolDataProvider
*/
event PoolDataProviderUpdated(
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when a new proxy is created.
* @param id The identifier of the proxy
* @param proxyAddress The address of the created proxy contract
* @param implementationAddress The address of the implementation contract
*/
event ProxyCreated(
bytes32 indexed id,
address indexed proxyAddress,
address indexed implementationAddress
);
/**
* @dev Emitted when a new non-proxied contract address is registered.
* @param id The identifier of the contract
* @param oldAddress The address of the old contract
* @param newAddress The address of the new contract
*/
event AddressSet(
bytes32 indexed id,
address indexed oldAddress,
address indexed newAddress
);
/**
* @dev Emitted when the implementation of the proxy registered with id is updated
* @param id The identifier of the contract
* @param proxyAddress The address of the proxy contract
* @param oldImplementationAddress The address of the old implementation contract
* @param newImplementationAddress The address of the new implementation contract
*/
event AddressSetAsProxy(
bytes32 indexed id,
address indexed proxyAddress,
address oldImplementationAddress,
address indexed newImplementationAddress
);
/**
* @notice Returns the id of the Aave market to which this contract points to.
* @return The market id
*/
function getMarketId() external view returns (string memory);
/**
* @notice Associates an id with a specific PoolAddressesProvider.
* @dev This can be used to create an onchain registry of PoolAddressesProviders to
* identify and validate multiple Aave markets.
* @param newMarketId The market id
*/
function setMarketId(string calldata newMarketId) external;
/**
* @notice Returns an address by its identifier.
* @dev The returned address might be an EOA or a contract, potentially proxied
* @dev It returns ZERO if there is no registered address with the given id
* @param id The id
* @return The address of the registered for the specified id
*/
function getAddressFromID(bytes32 id) external view returns (address);
/**
* @notice General function to update the implementation of a proxy registered with
* certain `id`. If there is no proxy registered, it will instantiate one and
* set as implementation the `newImplementationAddress`.
* @dev IMPORTANT Use this function carefully, only for ids that don't have an explicit
* setter function, in order to avoid unexpected consequences
* @param id The id
* @param newImplementationAddress The address of the new implementation
*/
function setAddressAsProxy(
bytes32 id,
address newImplementationAddress
) external;
/**
* @notice Sets an address for an id replacing the address saved in the addresses map.
* @dev IMPORTANT Use this function carefully, as it will do a hard replacement
* @param id The id
* @param newAddress The address to set
*/
function setAddress(bytes32 id, address newAddress) external;
/**
* @notice Returns the address of the Pool proxy.
* @return The Pool proxy address
*/
function getPool() external view returns (address);
/**
* @notice Updates the implementation of the Pool, or creates a proxy
* setting the new `pool` implementation when the function is called for the first time.
* @param newPoolImpl The new Pool implementation
*/
function setPoolImpl(address newPoolImpl) external;
/**
* @notice Returns the address of the PoolConfigurator proxy.
* @return The PoolConfigurator proxy address
*/
function getPoolConfigurator() external view returns (address);
/**
* @notice Updates the implementation of the PoolConfigurator, or creates a proxy
* setting the new `PoolConfigurator` implementation when the function is called for the first time.
* @param newPoolConfiguratorImpl The new PoolConfigurator implementation
*/
function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external;
/**
* @notice Returns the address of the price oracle.
* @return The address of the PriceOracle
*/
function getPriceOracle() external view returns (address);
/**
* @notice Updates the address of the price oracle.
* @param newPriceOracle The address of the new PriceOracle
*/
function setPriceOracle(address newPriceOracle) external;
/**
* @notice Returns the address of the ACL manager.
* @return The address of the ACLManager
*/
function getACLManager() external view returns (address);
/**
* @notice Updates the address of the ACL manager.
* @param newAclManager The address of the new ACLManager
*/
function setACLManager(address newAclManager) external;
/**
* @notice Returns the address of the ACL admin.
* @return The address of the ACL admin
*/
function getACLAdmin() external view returns (address);
/**
* @notice Updates the address of the ACL admin.
* @param newAclAdmin The address of the new ACL admin
*/
function setACLAdmin(address newAclAdmin) external;
/**
* @notice Returns the address of the price oracle sentinel.
* @return The address of the PriceOracleSentinel
*/
function getPriceOracleSentinel() external view returns (address);
/**
* @notice Updates the address of the price oracle sentinel.
* @param newPriceOracleSentinel The address of the new PriceOracleSentinel
*/
function setPriceOracleSentinel(address newPriceOracleSentinel) external;
/**
* @notice Returns the address of the data provider.
* @return The address of the DataProvider
*/
function getPoolDataProvider() external view returns (address);
/**
* @notice Updates the address of the data provider.
* @param newDataProvider The address of the new DataProvider
*/
function setPoolDataProvider(address newDataProvider) external;
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title IScaledBalanceToken
* @author Aave
* @notice Defines the basic interface for a scaled-balance token.
*/
interface IScaledBalanceToken {
/**
* @dev Emitted after the mint action
* @param caller The address performing the mint
* @param onBehalfOf The address of the user that will receive the minted tokens
* @param value The scaled-up amount being minted (based on user entered amount and balance increase from interest)
* @param balanceIncrease The increase in scaled-up balance since the last action of 'onBehalfOf'
* @param index The next liquidity index of the reserve
*/
event Mint(
address indexed caller,
address indexed onBehalfOf,
uint256 value,
uint256 balanceIncrease,
uint256 index
);
/**
* @dev Emitted after the burn action
* @dev If the burn function does not involve a transfer of the underlying asset, the target defaults to zero address
* @param from The address from which the tokens will be burned
* @param target The address that will receive the underlying, if any
* @param value The scaled-up amount being burned (user entered amount - balance increase from interest)
* @param balanceIncrease The increase in scaled-up balance since the last action of 'from'
* @param index The next liquidity index of the reserve
*/
event Burn(
address indexed from,
address indexed target,
uint256 value,
uint256 balanceIncrease,
uint256 index
);
/**
* @notice Returns the scaled balance of the user.
* @dev 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);
/**
* @notice 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 total supply
*/
function getScaledUserBalanceAndSupply(
address user
) external view returns (uint256, uint256);
/**
* @notice Returns the scaled total supply of the scaled balance token. Represents sum(debt/index)
* @return The scaled total supply
*/
function scaledTotalSupply() external view returns (uint256);
/**
* @notice Returns last index interest was accrued to the user's balance
* @param user The address of the user
* @return The last index interest was accrued to the user's balance, expressed in ray
*/
function getPreviousIndex(address user) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
library DataTypes {
struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//the current stable borrow rate. Expressed in ray
uint128 currentStableBorrowRate;
//timestamp of last update
uint40 lastUpdateTimestamp;
//the id of the reserve. Represents the position in the list of the active reserves
uint16 id;
//aToken address
address aTokenAddress;
//stableDebtToken address
address stableDebtTokenAddress;
//variableDebtToken address
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//the current treasury balance, scaled
uint128 accruedToTreasury;
//the outstanding unbacked aTokens minted through the bridging feature
uint128 unbacked;
//the outstanding debt borrowed against this asset in isolation mode
uint128 isolationModeTotalDebt;
}
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: asset is paused
//bit 61: borrowing in isolation mode is enabled
//bit 62: siloed borrowing enabled
//bit 63: flashloaning enabled
//bit 64-79: reserve factor
//bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap
//bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap
//bit 152-167 liquidation protocol fee
//bit 168-175 eMode category
//bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled
//bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals
//bit 252-255 unused
uint256 data;
}
struct UserConfigurationMap {
/**
* @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset.
* The first bit indicates if an asset is used as collateral by the user, the second whether an
* asset is borrowed by the user.
*/
uint256 data;
}
struct EModeCategory {
// each eMode category has a custom ltv and liquidation threshold
uint16 ltv;
uint16 liquidationThreshold;
uint16 liquidationBonus;
// each eMode category may or may not have a custom oracle to override the individual assets price oracles
address priceSource;
string label;
}
enum InterestRateMode {
NONE,
STABLE,
VARIABLE
}
struct ReserveCache {
uint256 currScaledVariableDebt;
uint256 nextScaledVariableDebt;
uint256 currPrincipalStableDebt;
uint256 currAvgStableBorrowRate;
uint256 currTotalStableDebt;
uint256 nextAvgStableBorrowRate;
uint256 nextTotalStableDebt;
uint256 currLiquidityIndex;
uint256 nextLiquidityIndex;
uint256 currVariableBorrowIndex;
uint256 nextVariableBorrowIndex;
uint256 currLiquidityRate;
uint256 currVariableBorrowRate;
uint256 reserveFactor;
ReserveConfigurationMap reserveConfiguration;
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
uint40 reserveLastUpdateTimestamp;
uint40 stableDebtLastUpdateTimestamp;
}
struct ExecuteLiquidationCallParams {
uint256 reservesCount;
uint256 debtToCover;
address collateralAsset;
address debtAsset;
address user;
bool receiveAToken;
address priceOracle;
uint8 userEModeCategory;
address priceOracleSentinel;
}
struct ExecuteSupplyParams {
address asset;
uint256 amount;
address onBehalfOf;
uint16 referralCode;
}
struct ExecuteBorrowParams {
address asset;
address user;
address onBehalfOf;
uint256 amount;
InterestRateMode interestRateMode;
uint16 referralCode;
bool releaseUnderlying;
uint256 maxStableRateBorrowSizePercent;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address priceOracleSentinel;
}
struct ExecuteRepayParams {
address asset;
uint256 amount;
InterestRateMode interestRateMode;
address onBehalfOf;
bool useATokens;
}
struct ExecuteWithdrawParams {
address asset;
uint256 amount;
address to;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
}
struct ExecuteSetUserEModeParams {
uint256 reservesCount;
address oracle;
uint8 categoryId;
}
struct FinalizeTransferParams {
address asset;
address from;
address to;
uint256 amount;
uint256 balanceFromBefore;
uint256 balanceToBefore;
uint256 reservesCount;
address oracle;
uint8 fromEModeCategory;
}
struct FlashloanParams {
address receiverAddress;
address[] assets;
uint256[] amounts;
uint256[] interestRateModes;
address onBehalfOf;
bytes params;
uint16 referralCode;
uint256 flashLoanPremiumToProtocol;
uint256 flashLoanPremiumTotal;
uint256 maxStableRateBorrowSizePercent;
uint256 reservesCount;
address addressesProvider;
uint8 userEModeCategory;
bool isAuthorizedFlashBorrower;
}
struct FlashloanSimpleParams {
address receiverAddress;
address asset;
uint256 amount;
bytes params;
uint16 referralCode;
uint256 flashLoanPremiumToProtocol;
uint256 flashLoanPremiumTotal;
}
struct FlashLoanRepaymentParams {
uint256 amount;
uint256 totalPremium;
uint256 flashLoanPremiumToProtocol;
address asset;
address receiverAddress;
uint16 referralCode;
}
struct CalculateUserAccountDataParams {
UserConfigurationMap userConfig;
uint256 reservesCount;
address user;
address oracle;
uint8 userEModeCategory;
}
struct ValidateBorrowParams {
ReserveCache reserveCache;
UserConfigurationMap userConfig;
address asset;
address userAddress;
uint256 amount;
InterestRateMode interestRateMode;
uint256 maxStableLoanPercent;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address priceOracleSentinel;
bool isolationModeActive;
address isolationModeCollateralAddress;
uint256 isolationModeDebtCeiling;
}
struct ValidateLiquidationCallParams {
ReserveCache debtReserveCache;
uint256 totalDebt;
uint256 healthFactor;
address priceOracleSentinel;
}
struct CalculateInterestRatesParams {
uint256 unbacked;
uint256 liquidityAdded;
uint256 liquidityTaken;
uint256 totalStableDebt;
uint256 totalVariableDebt;
uint256 averageStableBorrowRate;
uint256 reserveFactor;
address reserve;
address aToken;
}
struct InitReserveParams {
address asset;
address aTokenAddress;
address stableDebtAddress;
address variableDebtAddress;
address interestRateStrategyAddress;
uint16 reservesCount;
uint16 maxNumberReserves;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
library Constants {
// Shared definitions of how we represent percentages and basis points
uint16 public constant ONE_BPS = 100; // 1 basis point with 2 decimals
uint32 public constant ONE_PERCENT_BPS = ONE_BPS * 100;
uint32 public constant ONE_HUNDRED_PERCENT_BPS = ONE_PERCENT_BPS * 100;
uint32 public constant ORACLE_BASE_CURRENCY_UNIT = 1e8;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "london",
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {
"contracts/curve/CurveHelper.sol": {
"CurveHelper": "0xeb609695017aa8597fa9b3db276ec639783351d4"
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IERC3156FlashLender","name":"_flashMinter","type":"address"},{"internalType":"contract ILendingPoolAddressesProvider","name":"_addressesProvider","type":"address"},{"internalType":"contract ILendingPool","name":"_liquidateLender","type":"address"},{"internalType":"contract IAToken","name":"_aDUSD","type":"address"},{"internalType":"uint256","name":"_slippageTolerance","type":"uint256"},{"internalType":"contract ICurveRouterNgPoolsOnlyV1","name":"_curveRouter","type":"address"},{"internalType":"uint256","name":"_maxSlippageSurplusSwapBps","type":"uint256"},{"components":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"components":[{"internalType":"address[11]","name":"route","type":"address[11]"},{"internalType":"uint256[4][5]","name":"swapParams","type":"uint256[4][5]"},{"internalType":"uint256","name":"swapSlippageBufferBps","type":"uint256"}],"internalType":"struct CurveHelper.CurveSwapExtraParams","name":"swapExtraParams","type":"tuple"},{"components":[{"internalType":"address[11]","name":"route","type":"address[11]"},{"internalType":"uint256[4][5]","name":"swapParams","type":"uint256[4][5]"},{"internalType":"uint256","name":"swapSlippageBufferBps","type":"uint256"}],"internalType":"struct CurveHelper.CurveSwapExtraParams","name":"reverseSwapExtraParams","type":"tuple"}],"internalType":"struct FlashMintLiquidatorAaveBorrowRepayCurve.CurveSwapExtraParamsDefaultConfig[]","name":"_defaultSwapParamsList","type":"tuple[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"string","name":"key","type":"string"}],"name":"DuplicateKeyForSwapExtraParams","type":"error"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address[11]","name":"route","type":"address[11]"}],"name":"InvalidInputTokenInRoute","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"InvalidSlippageTolerance","type":"error"},{"inputs":[],"name":"NoProfitableLiquidation","type":"error"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"string","name":"key","type":"string"}],"name":"NotFoundKeyForSwapExtraParams","type":"error"},{"inputs":[{"internalType":"address","name":"_inputToken","type":"address"},{"internalType":"address","name":"_outputToken","type":"address"},{"internalType":"bytes","name":"_swapData","type":"bytes"}],"name":"NotSupportedCustomSwapData","type":"error"},{"inputs":[{"internalType":"address","name":"borrowedToken","type":"address"},{"internalType":"string","name":"symbol","type":"string"}],"name":"NotSupportingNonDUSD","type":"error"},{"inputs":[],"name":"OnlyLiquidator","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"StringsInsufficientHexLength","type":"error"},{"inputs":[],"name":"UnknownInitiator","type":"error"},{"inputs":[],"name":"UnknownLender","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FlashLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"poolTokenBorrowedAddress","type":"address"},{"indexed":true,"internalType":"address","name":"poolTokenCollateralAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"seized","type":"uint256"},{"indexed":false,"internalType":"bool","name":"usingFlashLoan","type":"bool"}],"name":"Liquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_liquidatorAdded","type":"address"}],"name":"LiquidatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_liquidatorRemoved","type":"address"}],"name":"LiquidatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newTolerance","type":"uint256"}],"name":"SlippageToleranceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"underlyingAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"DUSD_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FLASHLOAN_CALLBACK","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aDUSD","outputs":[{"internalType":"contract IAToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newLiquidator","type":"address"}],"name":"addLiquidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressesProvider","outputs":[{"internalType":"contract ILendingPoolAddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveRouter","outputs":[{"internalType":"contract ICurveRouterNgPoolsOnlyV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"defaultSwapParams","outputs":[{"internalType":"uint256","name":"swapSlippageBufferBps","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dusd","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flashMinter","outputs":[{"internalType":"contract IERC3156FlashLender","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralUnderlying","type":"address"},{"internalType":"bool","name":"_isUnstakeCollateralToken","type":"bool"}],"name":"getActualCollateralToken","outputs":[{"internalType":"address","name":"actualCollateralToken_","type":"address"},{"internalType":"address","name":"proxyContract_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralUnderlying","type":"address"}],"name":"getProxyContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isLiquidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"isSwapParamsSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_poolTokenBorrowedAddress","type":"address"},{"internalType":"address","name":"_poolTokenCollateralAddress","type":"address"},{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"uint256","name":"_repayAmount","type":"uint256"},{"internalType":"bool","name":"_stakeTokens","type":"bool"},{"internalType":"bool","name":"_isUnstakeCollateralToken","type":"bool"},{"internalType":"bytes","name":"_swapData","type":"bytes"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquidateLender","outputs":[{"internalType":"contract ILendingPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlippageSurplusSwapBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_initiator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onFlashLoan","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralERC4626Token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"redeemERC4626Token","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidatorToRemove","type":"address"}],"name":"removeLiquidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralUnderlying","type":"address"},{"internalType":"address","name":"_proxyContract","type":"address"}],"name":"setProxyContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTolerance","type":"uint256"}],"name":"setSlippageTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"components":[{"internalType":"address[11]","name":"route","type":"address[11]"},{"internalType":"uint256[4][5]","name":"swapParams","type":"uint256[4][5]"},{"internalType":"uint256","name":"swapSlippageBufferBps","type":"uint256"}],"internalType":"struct CurveHelper.CurveSwapExtraParams","name":"swapExtraParams","type":"tuple"},{"components":[{"internalType":"address[11]","name":"route","type":"address[11]"},{"internalType":"uint256[4][5]","name":"swapParams","type":"uint256[4][5]"},{"internalType":"uint256","name":"swapSlippageBufferBps","type":"uint256"}],"internalType":"struct CurveHelper.CurveSwapExtraParams","name":"reverseSwapExtraParams","type":"tuple"}],"internalType":"struct FlashMintLiquidatorAaveBorrowRepayCurve.CurveSwapExtraParamsDefaultConfig","name":"_swapExtraParamsConfig","type":"tuple"}],"name":"setSwapExtraParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slippageTolerance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_underlyingAddress","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101808060405234620006d657620036f280380380916200002182856200080f565b8339610100828281010312620006d65781516001600160a01b0381168103620006d65760208301516001600160a01b0381168103620006d65760408401516001600160a01b0381168103620006d6576060850151926001600160a01b0384168403620006d657608086015160a0870151949093906001600160a01b0386168603620006d65760c088015160e0890151989097906001600160401b038a11620006d657818101601f8b8301011215620006d657808a0151906001600160401b038211620007dd576040519a620000fd60208460051b018d6200080f565b828c5260208c019084830160206108408602838601010111620006d65790602082840101915b60206108408602828601010183106200073757505050505050602092916004916001600055600154913360018060a01b03198416176001556040519687958694339060018060a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a333600052600288526040600020600160ff19825416179055337fb0a258c58bd721bcb64542ee0e4e4c843ae58242f908c0681ad82d40d688f1fa600080a260805260a05260c05260e08190526358b50cef60e11b82526001600160a01b03165afa908115620006e457600091620006f0575b506001600160a01b031661010081905260405163313ce56760e01b815290602090829060049082905afa908115620006e4576000916200068d575b50600080516020620036d28339815191529160ff602092166101205280600355604051908152a16001600160a01b0316610140526101605260005b8151811015620005eb57620002c06001600160a01b036200029c838562000978565b5151166001600160a01b036020620002b5858762000978565b510151169062000a0e565b60ff6040516020818451620002d98183858901620009a3565b81016006815203019020541662000599576040516020818351620003018183858801620009a3565b81016006815203019020600160ff1982541617905562000342602060406200032a858762000978565b510151928160405193828580945193849201620009a3565b8101600581520301902090805160005b600b81106200057b5750506020810151600b8301906000905b600582106200053c5750505060400151601f9190910155620003be6001600160a01b0360206200039c848662000978565b510151166001600160a01b03620003b4848662000978565b5151169062000a0e565b60ff6040516020818451620003d78183858901620009a3565b810160068152030190205416620004e6576040516020818351620003ff8183858801620009a3565b81016006815203019020600160ff1982541617905562000428602060606200032a858762000978565b8101600581520301902090805160005b600b8110620004c85750506020810151600b83016000915b600583106200048f575050506040601f910151910155600019811462000479576001016200027a565b634e487b7160e01b600052601160045260246000fd5b805160005b60048110620004b3575050600460206001920192019201919062000450565b60019060208351930192818601550162000494565b81516001600160a01b03168185015560209091019060010162000438565b9162000538906200051a6001600160a01b03602062000506868562000978565b51015116936001600160a01b039262000978565b515116926040519384936372b8027f60e01b855260048501620009c8565b0390fd5b809695965160005b600481106200056657505060046020600192019301910190919594956200036b565b60019060208351930192818701550162000544565b81516001600160a01b03168185015560209091019060010162000352565b9162000538906020620005cc6001600160a01b03620005b9868562000978565b515116946001600160a01b039362000978565b51015116926040519384936372b8027f60e01b855260048501620009c8565b604051612abe908162000c148239608051818181610c2701528181611744015281816119730152611ac5015260a0518181816102fc01526113d7015260c051818181610be20152611fd8015260e051816106de015261010051818181610db601528181611702015281816119410152611da501526101205181610789015261014051818181610c6c015261286b0152610160518181816105aa01526128490152f35b90506020813d602011620006db575b81620006ab602093836200080f565b81010312620006d6575160ff81168103620006d657600080516020620036d28339815191526200023f565b600080fd5b3d91506200069c565b6040513d6000823e3d90fd5b90506020813d6020116200072e575b816200070e602093836200080f565b81010312620006d65760206200072660049262000833565b915062000204565b3d9150620006ff565b610840838786010312620006d6576040516080810192906001600160401b03841181851017620007c85760206108409283928296604052620007798862000833565b81526200078883890162000833565b838201526200079d8b8a0160408a0162000848565b6040820152620007b48b8a016104408a0162000848565b606082015281520194019392505062000123565b60246000634e487b7160e01b81526041600452fd5b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117620007dd57604052565b601f909101601f19168101906001600160401b03821190821017620007dd57604052565b51906001600160a01b0382168203620006d657565b919061040083820312620006d657604080519160608301906001600160401b0380831185841017620007dd578496601f91838383011215620006d6576101c0870185811082821117620007dd57865284610160830195858711620006d65783905b8782106200095d57505087528361017f83011215620006d65785519360a0850185811083821117620007dd5787526103e085930195818711620006d657925b86841062000900575050505050602084015251910152565b818585011215620006d6578751608080820182811086821117620007c8578a5281908601848111620006d65786915b8183106200094c57505050816020916080935201930192620008e8565b82518152602092830192016200092f565b602080916200096c8462000833565b815201910190620008a9565b80518210156200098d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b60005b838110620009b75750506000910152565b8181015183820152602001620009a6565b91906080939160018060a01b0380921684521660208301526060604083015262000a028151809281606086015260208686019101620009a3565b601f01601f1916010190565b604080516001600160a01b0392831693909284929162000a2e85620007f3565b602a85526020850193833686378551156200098d57603085538551966001978810156200098d576078602188015360295b88811162000bba575062000b9c57501691829180519262000a8084620007f3565b602a84526020840194823687378451156200098d576030865384518810156200098d576078602186015360295b88811162000b2b575062000b0e57509262000ae2959262000afc62000b0b9693602196519889955180926020880190620009a3565b840191602d60f81b602084015251809387840190620009a3565b0103908101845201826200080f565b90565b604491519063e22e27eb60e01b8252600482015260146024820152fd5b90600f8116601081101562000b87576f181899199a1a9b1b9c1cb0b131b232b360811b901a62000b5c838862000c01565b5360041c90801562000b72576000190162000aad565b60246000634e487b7160e01b81526011600452fd5b60246000634e487b7160e01b81526032600452fd5b60449084519063e22e27eb60e01b8252600482015260146024820152fd5b90600f8116601081101562000b87576f181899199a1a9b1b9c1cb0b131b232b360811b901a62000beb838a62000c01565b5360041c90801562000b72576000190162000a5f565b9081518110156200098d57016020019056fe6080604052600436101561001257600080fd5b60003560e01c8063117da1ee146101c757806323e30c8b146101c25780632a6b0c24146101bd5780632ae18104146101b85780632b4481ca146101b3578063313c9b8d146101ae5780634c4e7f6f146101a957806350686479146101a4578063529a356f1461019f5780636333b5691461019a578063715018a61461019557806373d190db1461019057806382e9dd9e1461018b578063845a9f78146101865780638da5cb5b14610181578063987762881461017c5780639922595514610177578063c72c4d1014610172578063cd955ace1461016d578063cda90b8814610168578063d03153aa14610163578063d9caed121461015e578063de1409ce14610159578063efb7440014610154578063f2fde38b1461014f578063f5a586631461014a5763fc4fdd3d1461014557600080fd5b61116b565b61108b565b610e5b565b610de5565b610da0565b610cb9565b610c9b565b610c56565b610c11565b610bcc565b6108da565b61084f565b610826565b6107da565b6107ac565b610771565b61070d565b6106c8565b610686565b610646565b6105cd565b610592565b61056c565b61032b565b6102e6565b610259565b34610243576020366003190112610243576004356101f060018060a01b036001541633146111a4565b620f4240811161022b576020817f84cb977e2a9a6a9b1fc0d73c4b02cd51695c09eb0d3008d61019a7c0a7406c4c92600355604051908152a1005b6024906040519063295eaa3d60e01b82526004820152fd5b600080fd5b6001600160a01b0381160361024357565b346102435760a03660031901126102435760043561027681610248565b610281602435610248565b6084356001600160401b038082116102435736602383011215610243578160040135908111610243573660248284010111610243576102d79260246102c7930190611aba565b6040519081529081906020820190565b0390f35b600091031261024357565b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102435760003660031901126102435760206040517f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd98152f35b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b0382111761039757604052565b610366565b6001600160401b03811161039757604052565b61012081019081106001600160401b0382111761039757604052565b60a081019081106001600160401b0382111761039757604052565b608081019081106001600160401b0382111761039757604052565b61016081019081106001600160401b0382111761039757604052565b90601f801991011681019081106001600160401b0382111761039757604052565b6040519061010082018281106001600160401b0382111761039757604052565b6040519061046b826103af565b565b6001600160401b03811161039757601f01601f191660200190565b9291926104948261046d565b916104a2604051938461041d565b829481845281830111610243578281602093846000960137010152565b602060031982011261024357600435906001600160401b0382116102435780602383011215610243578160246104fa93600401359101610488565b90565b60005b8381106105105750506000910152565b8181015183820152602001610500565b60206105399181604051938285809451938492016104fd565b8101600681520301902090565b602061055f9181604051938285809451938492016104fd565b8101600581520301902090565b3461024357602060ff610586610581366104bf565b610520565b54166040519015158152f35b346102435760003660031901126102435760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b34610243576020366003190112610243576004356105ea81610248565b6001546001600160a01b03919061060490831633146111a4565b166000818152600260205260408120805460ff19166001179055907fb0a258c58bd721bcb64542ee0e4e4c843ae58242f908c0681ad82d40d688f1fa8280a280f35b3461024357606036600319011261024357602061067e60043561066881610248565b6044359061067582610248565b60243590611253565b604051908152f35b34610243576020366003190112610243576004356106a381610248565b60018060a01b03166000526002602052602060ff604060002054166040519015158152f35b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102435760008060031936011261076e5760015481906001600160a01b0381169061073a3383146111a4565b6001600160a01b0319166001557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346102435760003660031901126102435760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b34610243576020601f6107c66107c1366104bf565b610546565b0154604051908152f35b8015150361024357565b3461024357604036600319011261024357604061080e6004356107fc81610248565b60243590610809826107d0565b61232a565b82516001600160a01b03928316815291166020820152f35b34610243576000366003190112610243576001546040516001600160a01b039091168152602090f35b346102435760403660031901126102435760043561086c81610248565b6024359061087982610248565b6001546001600160a01b0391829161089490831633146111a4565b166000526004602052604060002091166bffffffffffffffffffffffff60a01b825416179055600080f35b9080601f83011215610243578160206104fa93359101610488565b346102435760e0366003190112610243576004356108f781610248565b60243561090381610248565b6044359161091083610248565b60843590606435610920836107d0565b60a4359461092d866107d0565b60c4356001600160401b0381116102435761094c9036906004016108bf565b6000966002885414610b87576002885561096587611a57565b9261096f86611a57565b9561098a61097b61043e565b6001600160a01b039096168652565b6001600160a01b03968716602086018181529988166040870190815291881660608701908152336080880190815293891660a0880190815260c0880189815286151560e08a0152999b998d99949590949193909291906109f1905b6001600160a01b031690565b6040516370a0823160e01b815230600482015290602090829060249082905afa908115610b82578f91610b54575b5010610a615750505050505050610a37919250611375565b915b15610a4d575b83610a4a6001600055565b80f35b610a59923391166112f2565b388080610a3f565b919395975091939551610a799060018060a01b031690565b6001600160a01b031697516001600160a01b03166001600160a01b031694516001600160a01b03166001600160a01b031690516001600160a01b03166001600160a01b031691516001600160a01b031692516001600160a01b0316935194610adf61045e565b6001600160a01b0390991689526001600160a01b031660208901526001600160a01b031660408801526001600160a01b031660608701526001600160a01b031660808601526001600160a01b031660a085015260c0840152151560e0830152610100820152610b4d906116e0565b9091610a39565b610b75915060203d8111610b7b575b610b6d818361041d565b810190611238565b38610a1f565b503d610b63565b611247565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610243576000366003190112610243576020600354604051908152f35b3461024357606036600319011261024357600435610cd681610248565b602435610ce281610248565b6044359160018060a01b038091610cfe826001541633146111a4565b6040516370a0823160e01b8152306004820152911693602082602481885afa908115610b82577fa4195c37c2947bbe89165f03e320b6903116f0b10d8cfdb522330f7ce6f9fa2492600092610d80575b5081811115610d785750915b610d658385876112f2565b60405192835292909216913391602090a4005b905091610d5a565b610d9991925060203d8111610b7b57610b6d818361041d565b9038610d4e565b34610243576000366003190112610243576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461024357602036600319011261024357600435610e0281610248565b6001546001600160a01b039190610e1c90831633146111a4565b166000818152600260205260408120805460ff19169055907f06091797105e9997e06a57873c81a60a419050caf1d0ffedacc53ffc767f84f58280a280f35b3461024357602036600319011261024357600435610e7881610248565b6001546001600160a01b0390610e9190821633146111a4565b811615610ea357610ea1906111ef565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b806105c3121561024357604090815191610f10836103cb565b8261082491838311610243576105a4915b838310610f3057505050505090565b84601f84011215610243578151610f46816103e6565b80608085018781116102435785915b818310610f7057505050816020916080935201920191610f21565b8235815260209283019201610f55565b806101c3121561024357604090815191610f99836103cb565b8261042491838311610243576101a4915b838310610fb957505050505090565b84601f84011215610243578151610fcf816103e6565b80608085018781116102435785915b818310610ff957505050816020916080935201920191610faa565b8235815260209283019201610fde565b9061040061044319830112610243576040516110248161037c565b80928061046312156102435760405161103c81610401565b6105a48183821161024357610444905b82821061107157505050825261106190610ef7565b6020820152604061082435910152565b60208091833561108081610248565b81520191019061104c565b34610243576108403660031901126102435760408051608081018181106001600160401b038211176103975782526004356110c581610248565b8152602435916110d483610248565b60209283830152610400604319360112610243578051906110f48261037c565b366063121561024357805161110881610401565b6101a481368211610243576044905b828210611152575050508252610ea19361113036610f80565b90830152610424358183015282015261114836611009565b606082015261238f565b878091833561116081610248565b815201910190611117565b3461024357602036600319011261024357602061119260043561118d81610248565b6112b3565b6040516001600160a01b039091168152f35b156111ab57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600180546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b90816020910312610243575190565b6040513d6000823e3d90fd5b606460209260006040519586948593635d043b2960e11b8552600485015260018060a01b038092168060248601526044850152165af1908115610b825760009161129b575090565b6104fa915060203d8111610b7b57610b6d818361041d565b6001600160a01b0381811660009081526004602052604090205416806112d7575090565b905090565b634e487b7160e01b600052601160045260246000fd5b600091826044926020956040519363a9059cbb60e01b8552600485015260248401525af13d15601f3d116001600051141617161561132c57565b60405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606490fd5b9190820391821161137057565b6112dc565b805190919061138c906001600160a01b03166109e5565b6040516370a0823160e01b808252306004830152936020928390839060249082905afa918215610b82576000926115c8575b50808301516001600160a01b03169160018060a01b03807f0000000000000000000000000000000000000000000000000000000000000000169661140960c0850195898751916115e7565b604084019561142c6109e56114276109e58a5160018060a01b031690565b611a57565b94606081019561144b6109e56114276109e58a5160018060a01b031690565b60a083018051909c919291906001600160a01b0316908a5193813b156102435760405162a718a960e01b81526001600160a01b0394851660048201529084166024820152919092166044820152606481019290925260006084830181905290829060a490829084905af18015610b825783926114d8926109e5926115af575b50516001600160a01b031690565b604051938452306004850152839060249082905afa938415610b82576109e561154861153a611548937fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e698611556976109e597600092611592575b5050611363565b9b516001600160a01b031690565b96516001600160a01b031690565b9351604080516001600160a01b03909516855260208501919091528301879052600060608401529283169390921691339180608081015b0390a4565b6115a89250803d10610b7b57610b6d818361041d565b3880611533565b806115bc6115c29261039c565b806102db565b386114ca565b6115e0919250833d8511610b7b57610b6d818361041d565b90386113be565b600091826044926020956040519363095ea7b360e01b8552600485015260248401525af13d15601f3d116001600051141617161561162157565b60405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b6044820152606490fd5b90620f424091820180921161137057565b9190820180921161137057565b9081602091031261024357516104fa816107d0565b906020916116a3815180928185528580860191016104fd565b601f01601f1916010190565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526104fa9291019061168a565b906116ea826119a7565b906116f361192a565b604051633676633960e21b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03818116600484018190526024840185905293969095602094937f00000000000000000000000000000000000000000000000000000000000000008816939192908681604481885afa928315610b8257856117936117b9956117999460009161190d575b508d611668565b916115e7565b80516117b39060e0906001600160a01b0316920151151590565b9061232a565b506040516370a0823160e01b80825230600483015291978816928682602481875afa948515610b82578a88936000976118e7575b50600061181496979860405197889586948593632e7ff4ef60e11b855230600486016116af565b03925af1918215610b825785926118ba575b5060405190815230600482015291829060249082905afa928315610b825760009361189b575b5050808211156118915761185f91611363565b925b60405190815233907f134bde118562a60dcf2d8c52965f586e25cf88a371592e44b78c4aa03bcbac8490602090a2565b5050600092611861565b6118b2929350803d10610b7b57610b6d818361041d565b90388061184c565b6118d990833d85116118e0575b6118d1818361041d565b810190611675565b5038611826565b503d6118c7565b611814969750611905600091863d8811610b7b57610b6d818361041d565b9796506117ed565b61192491508b3d8d11610b7b57610b6d818361041d565b3861178c565b60405163613255ab60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602090829060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa908115610b825760009161129b575090565b6104fa60018060a01b0391611a348382511691846020820151169480604083015116918160608201511691806080830151169060a08301511660c08301519160e084015115159461010080950151966040519b8c9a60208c015260408b015260608a0152608089015260a088015260c087015260e08601528401526101208084015261014083019061168a565b03601f19810183528261041d565b9081602091031261024357516104fa81610248565b6040516358b50cef60e11b81526001600160a01b03916020908290600490829086165afa908115610b8257600091611a8e57501690565b611aaf915060203d8111611ab3575b611aa7818361041d565b810190611a42565b1690565b503d611a9d565b6001600160a01b03907f000000000000000000000000000000000000000000000000000000000000000082163303611c0b578130911603611bf95760405192611b02846103af565b60008085528260208601918083528660408101968288526060820197838952846080840199858b5260a0850197868952828060c088019789895260e08101998a52610100019b60608d5287019581611b5a888a611c1d565b50505050509095166001600160a01b03169097529592166001600160a01b03169052166001600160a01b03169052166001600160a01b03168a52611b9d91611c1d565b909c529a151590975298949350611bb392505050565b52166001600160a01b03169052166001600160a01b03169052611bd590611d90565b7f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd990565b604051634ac321c360e11b8152600490fd5b604051631e4a393d60e31b8152600490fd5b9161012083830312610243578235611c3481610248565b926020810135611c4381610248565b926040820135611c5281610248565b926060830135611c6181610248565b926080810135611c7081610248565b9260a0820135611c7f81610248565b9260c08301359260e0810135611c94816107d0565b926101008201356001600160401b038111610243576104fa92016108bf565b602081830312610243578051906001600160401b038211610243570181601f82011215610243578051611ce58161046d565b92611cf3604051948561041d565b81845260208284010111610243576104fa91602080850191016104fd565b6001600160a01b0390911681526040602082018190526104fa9291019061168a565b90816020910312610243575160ff811681036102435790565b60ff16604d811161137057600a0a90565b8181029291811591840414171561137057565b8115611d7a570490565b634e487b7160e01b600052601260045260246000fd5b602081810180516001600160a01b03908116807f0000000000000000000000000000000000000000000000000000000000000000831681036122be57505083516001600160a01b03166001600160a01b031682519091906001600160a01b03166001600160a01b031660408681018051909792949291906001600160a01b03166001600160a01b03166060830180519198909790916001600160a01b03166001600160a01b03166080850180519098906001600160a01b031660a087018051909c919891906001600160a01b03169860c08901998a519160e08b01968751611e7790151590565b94611e8061043e565b6001600160a01b0390971687526001600160a01b03909716868b01908152966001600160a01b0316868c01526001600160a01b031660608601526001600160a01b031660808501526001600160a01b031660a084015260c0830152151560e0820152611eeb90611375565b83519096906001600160a01b031681516001600160a01b0316908a808316911603611fa6575b5050505050509061158d918480611f7461153a611f66611f587fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e69b5160018060a01b031690565b9c516001600160a01b031690565b9a516001600160a01b031690565b95519251968796169a169816968460609194936001936080830196858060a01b03168352602083015260408201520152565b611fb8906117b3859998979951151590565b93519093879161222a575b508551631f94a27560e31b81529088826004817f00000000000000000000000000000000000000000000000000000000000000008f165afa918215610b82578b92839160009161220d575b5016908751908a8260048163313ce56760e01b978882528b165afa918215610b825761204c92612046916000916121f0575b50611d4c565b90611d5d565b8651885163b3596f0760e01b8082526001600160a01b0390921660048201529091908b81602481875afa8015610b82578c92612090926000926121d1575b50611d5d565b89519283526001600160a01b03881660048401529192839060249082905afa908115610b82576120d16120df926109e5928d956000926121b2575b50611d70565b95516001600160a01b031690565b91600488518094819382525afa978815610b82577fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e69b6121788c9788978d61153a9761010061158d9f6120d1612164612159611f749e61215361216d95611f669f611f589f600092612185575b5050611d4c565b90611d70565b612046600354611657565b620f4240900490565b9101519151926127dd565b509b505085969750611f11565b6121a49250803d106121ab575b61219c818361041d565b810190611d33565b388061214c565b503d612192565b6121ca919250863d8811610b7b57610b6d818361041d565b90386120cb565b6121e9919250843d8611610b7b57610b6d818361041d565b903861208a565b61220791508d803d106121ab5761219c818361041d565b38612040565b61222491508b3d8d11611ab357611aa7818361041d565b3861200e565b825160009250899061227b9061224a906109e5906001600160a01b031681565b895163095ea7b360e01b81526001600160a01b0385166004820152602481018c905294859283919082906044820190565b03925af1908115610b825760049261229b926122a1575b50883091611253565b90611fc3565b6122b7908b3d8d116118e0576118d1818361041d565b5038612292565b906000600492604051938480926395d89b4160e01b82525afa918215610b8257600092612307575b50612303604051928392635620c2dd60e01b845260048401611d11565b0390fd5b61232391923d8091833e61231b818361041d565b810190611cb3565b90826122e6565b600092911561238b5761233e9192506112b3565b6040516338d52e0f60e01b81529091906020816004816001600160a01b0387165afa908115610b825760009161237357509190565b61238b915060203d8111611ab357611aa7818361041d565b9190565b9060018060a01b03916001926123a98185541633146111a4565b808251169060206123c181850193838551169061250c565b956123cb87610520565b8160ff198254161790556123e3604086015197610546565b92875160005b600b8110612465575050505061242d61246093606093601f60408a61241b61243e9761046b9c9d0151600b8601612478565b0151910155516001600160a01b031690565b84516001600160a01b03169061250c565b9261245861244b85610520565b805460ff19166001179055565b015191610546565b6124c2565b81518316868201559084019083016123e9565b9060009081905b6005821061248d5750505050565b8051835b600481106124ae575050600460206001920194019101909261247f565b600190602083519301928188015501612491565b90805160005b600b81106124ef5750506040816124e86020601f940151600b8601612478565b0151910155565b81516001600160a01b0316818501556020909101906001016124c8565b6104fa90602190612532906001600160a01b039061252b9082166125eb565b94166125eb565b92604051938161254c8693518092602080870191016104fd565b8201602d60f81b602082015261256b82518093602087850191016104fd565b0103600181018452018261041d565b604051906125878261037c565b602a82526040366020840137565b634e487b7160e01b600052603260045260246000fd5b8051156125b85760200190565b612595565b8051600110156125b85760210190565b9081518110156125b8570160200190565b8015611370576000190190565b806125f461257a565b916030612600846125ab565b53607861260c846125bd565b5360295b600181116126425750612621575090565b60405163e22e27eb60e01b8152600481019190915260146024820152604490fd5b90600f81169060108210156125b85761267f916f181899199a1a9b1b9c1cb0b131b232b360811b901a61267584876125cd565b5360041c916125de565b612610565b6001600160a01b039182168152911660208201526060604082018190526104fa9291019061168a565b6001600160a01b039182168152610180810193926020916000919083015b600b83106126da575050505050565b8380600192878551168152019201920191906126cb565b6000915b600b831061270257505050565b81516001600160a01b0316815260019290920191602091820191016126f5565b9060009182915b600583106127375750505050565b815184825b6004821061275a575050506020608060019201920192019190612729565b60019083518152602080910193019101909161273c565b959261084097946127b16127bc926127a66127c7969e9d9c99959e6108608c019f60018060a01b03168c5260208c01906126f1565b6101808a0190612722565b6104008801906126f1565b610560860190612722565b6107e08401526108008301526108208201520152565b929193909380516128da57506127fd836127f786826129cb565b956129cb565b84518051919490916001600160a01b03908116908216036128be5750509061289360209392855192858701519360408787519701519801516040519889978897633fff811360e01b89527f0000000000000000000000000000000000000000000000000000000000000000947f000000000000000000000000000000000000000000000000000000000000000060048b01612771565b038173eb609695017aa8597fa9b3db276ec639783351d45af4908115610b825760009161129b575090565b61230360405192839263cb709ddd60e01b8452600484016126ad565b604051630f3537b560e31b815290819061230390878760048501612684565b9060408051906129088261037c565b819381518082906000905b600b82106129ab5750505061292781610401565b8352815160a081018181106001600160401b03821117610397578352600b82016000825b60058210612964575050506020840152601f0154910152565b8551600084825b60048310612995575050506020600192826129876004946103e6565b81520193019101909161294b565b600160208192845481520192019201919061296b565b82546001600160a01b031681526001928301929190910190602001612913565b9060409182516129da8161037c565b83516129e581610401565b61016036823781528380516129f9816103cb565b60005b60a08110612a68575060208301526000910152612a19828261250c565b92612a34612a30612a2986610520565b5460ff1690565b1590565b612a4c57505050612a476104fa91610546565b6128f9565b5162acf2cf60e51b815291829161230391859160048501612684565b6020919251612a76816103e6565b608036823781840152019085916129fc56fea26469706673582212209dde6b3f9d4069d63a268ba70cdc38bd3a91988ec2126eaff2ffa5a180011e5d64736f6c6343000814003384cb977e2a9a6a9b1fc0d73c4b02cd51695c09eb0d3008d61019a7c0a7406c4c000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000d9c622d64342b5faceef4d366b974aef6dcb338d000000000000000000000000d76c827ee2ce1e37c37fc2ce91376812d3c9bce200000000000000000000000029d0256fe397f6e442464982c4cba7670646059b000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000009f2fa7709b30c75047980a0d70a106728f0ef2db0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d20000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000008000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c000000000000000000000000fc0000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000008000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000f16f226baa419d9dc9d92c040ccbc8c0e25f36d7000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d20000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c8063117da1ee146101c757806323e30c8b146101c25780632a6b0c24146101bd5780632ae18104146101b85780632b4481ca146101b3578063313c9b8d146101ae5780634c4e7f6f146101a957806350686479146101a4578063529a356f1461019f5780636333b5691461019a578063715018a61461019557806373d190db1461019057806382e9dd9e1461018b578063845a9f78146101865780638da5cb5b14610181578063987762881461017c5780639922595514610177578063c72c4d1014610172578063cd955ace1461016d578063cda90b8814610168578063d03153aa14610163578063d9caed121461015e578063de1409ce14610159578063efb7440014610154578063f2fde38b1461014f578063f5a586631461014a5763fc4fdd3d1461014557600080fd5b61116b565b61108b565b610e5b565b610de5565b610da0565b610cb9565b610c9b565b610c56565b610c11565b610bcc565b6108da565b61084f565b610826565b6107da565b6107ac565b610771565b61070d565b6106c8565b610686565b610646565b6105cd565b610592565b61056c565b61032b565b6102e6565b610259565b34610243576020366003190112610243576004356101f060018060a01b036001541633146111a4565b620f4240811161022b576020817f84cb977e2a9a6a9b1fc0d73c4b02cd51695c09eb0d3008d61019a7c0a7406c4c92600355604051908152a1005b6024906040519063295eaa3d60e01b82526004820152fd5b600080fd5b6001600160a01b0381160361024357565b346102435760a03660031901126102435760043561027681610248565b610281602435610248565b6084356001600160401b038082116102435736602383011215610243578160040135908111610243573660248284010111610243576102d79260246102c7930190611aba565b6040519081529081906020820190565b0390f35b600091031261024357565b34610243576000366003190112610243576040517f000000000000000000000000d76c827ee2ce1e37c37fc2ce91376812d3c9bce26001600160a01b03168152602090f35b346102435760003660031901126102435760206040517f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd98152f35b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b0382111761039757604052565b610366565b6001600160401b03811161039757604052565b61012081019081106001600160401b0382111761039757604052565b60a081019081106001600160401b0382111761039757604052565b608081019081106001600160401b0382111761039757604052565b61016081019081106001600160401b0382111761039757604052565b90601f801991011681019081106001600160401b0382111761039757604052565b6040519061010082018281106001600160401b0382111761039757604052565b6040519061046b826103af565b565b6001600160401b03811161039757601f01601f191660200190565b9291926104948261046d565b916104a2604051938461041d565b829481845281830111610243578281602093846000960137010152565b602060031982011261024357600435906001600160401b0382116102435780602383011215610243578160246104fa93600401359101610488565b90565b60005b8381106105105750506000910152565b8181015183820152602001610500565b60206105399181604051938285809451938492016104fd565b8101600681520301902090565b602061055f9181604051938285809451938492016104fd565b8101600581520301902090565b3461024357602060ff610586610581366104bf565b610520565b54166040519015158152f35b346102435760003660031901126102435760206040517f0000000000000000000000000000000000000000000000000000000000030d408152f35b34610243576020366003190112610243576004356105ea81610248565b6001546001600160a01b03919061060490831633146111a4565b166000818152600260205260408120805460ff19166001179055907fb0a258c58bd721bcb64542ee0e4e4c843ae58242f908c0681ad82d40d688f1fa8280a280f35b3461024357606036600319011261024357602061067e60043561066881610248565b6044359061067582610248565b60243590611253565b604051908152f35b34610243576020366003190112610243576004356106a381610248565b60018060a01b03166000526002602052602060ff604060002054166040519015158152f35b34610243576000366003190112610243576040517f00000000000000000000000029d0256fe397f6e442464982c4cba7670646059b6001600160a01b03168152602090f35b346102435760008060031936011261076e5760015481906001600160a01b0381169061073a3383146111a4565b6001600160a01b0319166001557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346102435760003660031901126102435760206040517f00000000000000000000000000000000000000000000000000000000000000068152f35b34610243576020601f6107c66107c1366104bf565b610546565b0154604051908152f35b8015150361024357565b3461024357604036600319011261024357604061080e6004356107fc81610248565b60243590610809826107d0565b61232a565b82516001600160a01b03928316815291166020820152f35b34610243576000366003190112610243576001546040516001600160a01b039091168152602090f35b346102435760403660031901126102435760043561086c81610248565b6024359061087982610248565b6001546001600160a01b0391829161089490831633146111a4565b166000526004602052604060002091166bffffffffffffffffffffffff60a01b825416179055600080f35b9080601f83011215610243578160206104fa93359101610488565b346102435760e0366003190112610243576004356108f781610248565b60243561090381610248565b6044359161091083610248565b60843590606435610920836107d0565b60a4359461092d866107d0565b60c4356001600160401b0381116102435761094c9036906004016108bf565b6000966002885414610b87576002885561096587611a57565b9261096f86611a57565b9561098a61097b61043e565b6001600160a01b039096168652565b6001600160a01b03968716602086018181529988166040870190815291881660608701908152336080880190815293891660a0880190815260c0880189815286151560e08a0152999b998d99949590949193909291906109f1905b6001600160a01b031690565b6040516370a0823160e01b815230600482015290602090829060249082905afa908115610b82578f91610b54575b5010610a615750505050505050610a37919250611375565b915b15610a4d575b83610a4a6001600055565b80f35b610a59923391166112f2565b388080610a3f565b919395975091939551610a799060018060a01b031690565b6001600160a01b031697516001600160a01b03166001600160a01b031694516001600160a01b03166001600160a01b031690516001600160a01b03166001600160a01b031691516001600160a01b031692516001600160a01b0316935194610adf61045e565b6001600160a01b0390991689526001600160a01b031660208901526001600160a01b031660408801526001600160a01b031660608701526001600160a01b031660808601526001600160a01b031660a085015260c0840152151560e0830152610100820152610b4d906116e0565b9091610a39565b610b75915060203d8111610b7b575b610b6d818361041d565b810190611238565b38610a1f565b503d610b63565b611247565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b34610243576000366003190112610243576040517f000000000000000000000000d9c622d64342b5faceef4d366b974aef6dcb338d6001600160a01b03168152602090f35b34610243576000366003190112610243576040517f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03168152602090f35b34610243576000366003190112610243576040517f0000000000000000000000009f2fa7709b30c75047980a0d70a106728f0ef2db6001600160a01b03168152602090f35b34610243576000366003190112610243576020600354604051908152f35b3461024357606036600319011261024357600435610cd681610248565b602435610ce281610248565b6044359160018060a01b038091610cfe826001541633146111a4565b6040516370a0823160e01b8152306004820152911693602082602481885afa908115610b82577fa4195c37c2947bbe89165f03e320b6903116f0b10d8cfdb522330f7ce6f9fa2492600092610d80575b5081811115610d785750915b610d658385876112f2565b60405192835292909216913391602090a4005b905091610d5a565b610d9991925060203d8111610b7b57610b6d818361041d565b9038610d4e565b34610243576000366003190112610243576040517f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03168152602090f35b3461024357602036600319011261024357600435610e0281610248565b6001546001600160a01b039190610e1c90831633146111a4565b166000818152600260205260408120805460ff19169055907f06091797105e9997e06a57873c81a60a419050caf1d0ffedacc53ffc767f84f58280a280f35b3461024357602036600319011261024357600435610e7881610248565b6001546001600160a01b0390610e9190821633146111a4565b811615610ea357610ea1906111ef565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b806105c3121561024357604090815191610f10836103cb565b8261082491838311610243576105a4915b838310610f3057505050505090565b84601f84011215610243578151610f46816103e6565b80608085018781116102435785915b818310610f7057505050816020916080935201920191610f21565b8235815260209283019201610f55565b806101c3121561024357604090815191610f99836103cb565b8261042491838311610243576101a4915b838310610fb957505050505090565b84601f84011215610243578151610fcf816103e6565b80608085018781116102435785915b818310610ff957505050816020916080935201920191610faa565b8235815260209283019201610fde565b9061040061044319830112610243576040516110248161037c565b80928061046312156102435760405161103c81610401565b6105a48183821161024357610444905b82821061107157505050825261106190610ef7565b6020820152604061082435910152565b60208091833561108081610248565b81520191019061104c565b34610243576108403660031901126102435760408051608081018181106001600160401b038211176103975782526004356110c581610248565b8152602435916110d483610248565b60209283830152610400604319360112610243578051906110f48261037c565b366063121561024357805161110881610401565b6101a481368211610243576044905b828210611152575050508252610ea19361113036610f80565b90830152610424358183015282015261114836611009565b606082015261238f565b878091833561116081610248565b815201910190611117565b3461024357602036600319011261024357602061119260043561118d81610248565b6112b3565b6040516001600160a01b039091168152f35b156111ab57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600180546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b90816020910312610243575190565b6040513d6000823e3d90fd5b606460209260006040519586948593635d043b2960e11b8552600485015260018060a01b038092168060248601526044850152165af1908115610b825760009161129b575090565b6104fa915060203d8111610b7b57610b6d818361041d565b6001600160a01b0381811660009081526004602052604090205416806112d7575090565b905090565b634e487b7160e01b600052601160045260246000fd5b600091826044926020956040519363a9059cbb60e01b8552600485015260248401525af13d15601f3d116001600051141617161561132c57565b60405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606490fd5b9190820391821161137057565b6112dc565b805190919061138c906001600160a01b03166109e5565b6040516370a0823160e01b808252306004830152936020928390839060249082905afa918215610b82576000926115c8575b50808301516001600160a01b03169160018060a01b03807f000000000000000000000000d76c827ee2ce1e37c37fc2ce91376812d3c9bce2169661140960c0850195898751916115e7565b604084019561142c6109e56114276109e58a5160018060a01b031690565b611a57565b94606081019561144b6109e56114276109e58a5160018060a01b031690565b60a083018051909c919291906001600160a01b0316908a5193813b156102435760405162a718a960e01b81526001600160a01b0394851660048201529084166024820152919092166044820152606481019290925260006084830181905290829060a490829084905af18015610b825783926114d8926109e5926115af575b50516001600160a01b031690565b604051938452306004850152839060249082905afa938415610b82576109e561154861153a611548937fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e698611556976109e597600092611592575b5050611363565b9b516001600160a01b031690565b96516001600160a01b031690565b9351604080516001600160a01b03909516855260208501919091528301879052600060608401529283169390921691339180608081015b0390a4565b6115a89250803d10610b7b57610b6d818361041d565b3880611533565b806115bc6115c29261039c565b806102db565b386114ca565b6115e0919250833d8511610b7b57610b6d818361041d565b90386113be565b600091826044926020956040519363095ea7b360e01b8552600485015260248401525af13d15601f3d116001600051141617161561162157565b60405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b6044820152606490fd5b90620f424091820180921161137057565b9190820180921161137057565b9081602091031261024357516104fa816107d0565b906020916116a3815180928185528580860191016104fd565b601f01601f1916010190565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526104fa9291019061168a565b906116ea826119a7565b906116f361192a565b604051633676633960e21b81527f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03818116600484018190526024840185905293969095602094937f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a8816939192908681604481885afa928315610b8257856117936117b9956117999460009161190d575b508d611668565b916115e7565b80516117b39060e0906001600160a01b0316920151151590565b9061232a565b506040516370a0823160e01b80825230600483015291978816928682602481875afa948515610b82578a88936000976118e7575b50600061181496979860405197889586948593632e7ff4ef60e11b855230600486016116af565b03925af1918215610b825785926118ba575b5060405190815230600482015291829060249082905afa928315610b825760009361189b575b5050808211156118915761185f91611363565b925b60405190815233907f134bde118562a60dcf2d8c52965f586e25cf88a371592e44b78c4aa03bcbac8490602090a2565b5050600092611861565b6118b2929350803d10610b7b57610b6d818361041d565b90388061184c565b6118d990833d85116118e0575b6118d1818361041d565b810190611675565b5038611826565b503d6118c7565b611814969750611905600091863d8811610b7b57610b6d818361041d565b9796506117ed565b61192491508b3d8d11610b7b57610b6d818361041d565b3861178c565b60405163613255ab60e01b81526001600160a01b037f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a81166004830152602090829060249082907f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a165afa908115610b825760009161129b575090565b6104fa60018060a01b0391611a348382511691846020820151169480604083015116918160608201511691806080830151169060a08301511660c08301519160e084015115159461010080950151966040519b8c9a60208c015260408b015260608a0152608089015260a088015260c087015260e08601528401526101208084015261014083019061168a565b03601f19810183528261041d565b9081602091031261024357516104fa81610248565b6040516358b50cef60e11b81526001600160a01b03916020908290600490829086165afa908115610b8257600091611a8e57501690565b611aaf915060203d8111611ab3575b611aa7818361041d565b810190611a42565b1690565b503d611a9d565b6001600160a01b03907f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a82163303611c0b578130911603611bf95760405192611b02846103af565b60008085528260208601918083528660408101968288526060820197838952846080840199858b5260a0850197868952828060c088019789895260e08101998a52610100019b60608d5287019581611b5a888a611c1d565b50505050509095166001600160a01b03169097529592166001600160a01b03169052166001600160a01b03169052166001600160a01b03168a52611b9d91611c1d565b909c529a151590975298949350611bb392505050565b52166001600160a01b03169052166001600160a01b03169052611bd590611d90565b7f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd990565b604051634ac321c360e11b8152600490fd5b604051631e4a393d60e31b8152600490fd5b9161012083830312610243578235611c3481610248565b926020810135611c4381610248565b926040820135611c5281610248565b926060830135611c6181610248565b926080810135611c7081610248565b9260a0820135611c7f81610248565b9260c08301359260e0810135611c94816107d0565b926101008201356001600160401b038111610243576104fa92016108bf565b602081830312610243578051906001600160401b038211610243570181601f82011215610243578051611ce58161046d565b92611cf3604051948561041d565b81845260208284010111610243576104fa91602080850191016104fd565b6001600160a01b0390911681526040602082018190526104fa9291019061168a565b90816020910312610243575160ff811681036102435790565b60ff16604d811161137057600a0a90565b8181029291811591840414171561137057565b8115611d7a570490565b634e487b7160e01b600052601260045260246000fd5b602081810180516001600160a01b03908116807f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a831681036122be57505083516001600160a01b03166001600160a01b031682519091906001600160a01b03166001600160a01b031660408681018051909792949291906001600160a01b03166001600160a01b03166060830180519198909790916001600160a01b03166001600160a01b03166080850180519098906001600160a01b031660a087018051909c919891906001600160a01b03169860c08901998a519160e08b01968751611e7790151590565b94611e8061043e565b6001600160a01b0390971687526001600160a01b03909716868b01908152966001600160a01b0316868c01526001600160a01b031660608601526001600160a01b031660808501526001600160a01b031660a084015260c0830152151560e0820152611eeb90611375565b83519096906001600160a01b031681516001600160a01b0316908a808316911603611fa6575b5050505050509061158d918480611f7461153a611f66611f587fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e69b5160018060a01b031690565b9c516001600160a01b031690565b9a516001600160a01b031690565b95519251968796169a169816968460609194936001936080830196858060a01b03168352602083015260408201520152565b611fb8906117b3859998979951151590565b93519093879161222a575b508551631f94a27560e31b81529088826004817f000000000000000000000000d9c622d64342b5faceef4d366b974aef6dcb338d8f165afa918215610b82578b92839160009161220d575b5016908751908a8260048163313ce56760e01b978882528b165afa918215610b825761204c92612046916000916121f0575b50611d4c565b90611d5d565b8651885163b3596f0760e01b8082526001600160a01b0390921660048201529091908b81602481875afa8015610b82578c92612090926000926121d1575b50611d5d565b89519283526001600160a01b03881660048401529192839060249082905afa908115610b82576120d16120df926109e5928d956000926121b2575b50611d70565b95516001600160a01b031690565b91600488518094819382525afa978815610b82577fe96c57864e490909fadd8ddc506e391bc4946ed905e39f7e71321861c798d3e69b6121788c9788978d61153a9761010061158d9f6120d1612164612159611f749e61215361216d95611f669f611f589f600092612185575b5050611d4c565b90611d70565b612046600354611657565b620f4240900490565b9101519151926127dd565b509b505085969750611f11565b6121a49250803d106121ab575b61219c818361041d565b810190611d33565b388061214c565b503d612192565b6121ca919250863d8811610b7b57610b6d818361041d565b90386120cb565b6121e9919250843d8611610b7b57610b6d818361041d565b903861208a565b61220791508d803d106121ab5761219c818361041d565b38612040565b61222491508b3d8d11611ab357611aa7818361041d565b3861200e565b825160009250899061227b9061224a906109e5906001600160a01b031681565b895163095ea7b360e01b81526001600160a01b0385166004820152602481018c905294859283919082906044820190565b03925af1908115610b825760049261229b926122a1575b50883091611253565b90611fc3565b6122b7908b3d8d116118e0576118d1818361041d565b5038612292565b906000600492604051938480926395d89b4160e01b82525afa918215610b8257600092612307575b50612303604051928392635620c2dd60e01b845260048401611d11565b0390fd5b61232391923d8091833e61231b818361041d565b810190611cb3565b90826122e6565b600092911561238b5761233e9192506112b3565b6040516338d52e0f60e01b81529091906020816004816001600160a01b0387165afa908115610b825760009161237357509190565b61238b915060203d8111611ab357611aa7818361041d565b9190565b9060018060a01b03916001926123a98185541633146111a4565b808251169060206123c181850193838551169061250c565b956123cb87610520565b8160ff198254161790556123e3604086015197610546565b92875160005b600b8110612465575050505061242d61246093606093601f60408a61241b61243e9761046b9c9d0151600b8601612478565b0151910155516001600160a01b031690565b84516001600160a01b03169061250c565b9261245861244b85610520565b805460ff19166001179055565b015191610546565b6124c2565b81518316868201559084019083016123e9565b9060009081905b6005821061248d5750505050565b8051835b600481106124ae575050600460206001920194019101909261247f565b600190602083519301928188015501612491565b90805160005b600b81106124ef5750506040816124e86020601f940151600b8601612478565b0151910155565b81516001600160a01b0316818501556020909101906001016124c8565b6104fa90602190612532906001600160a01b039061252b9082166125eb565b94166125eb565b92604051938161254c8693518092602080870191016104fd565b8201602d60f81b602082015261256b82518093602087850191016104fd565b0103600181018452018261041d565b604051906125878261037c565b602a82526040366020840137565b634e487b7160e01b600052603260045260246000fd5b8051156125b85760200190565b612595565b8051600110156125b85760210190565b9081518110156125b8570160200190565b8015611370576000190190565b806125f461257a565b916030612600846125ab565b53607861260c846125bd565b5360295b600181116126425750612621575090565b60405163e22e27eb60e01b8152600481019190915260146024820152604490fd5b90600f81169060108210156125b85761267f916f181899199a1a9b1b9c1cb0b131b232b360811b901a61267584876125cd565b5360041c916125de565b612610565b6001600160a01b039182168152911660208201526060604082018190526104fa9291019061168a565b6001600160a01b039182168152610180810193926020916000919083015b600b83106126da575050505050565b8380600192878551168152019201920191906126cb565b6000915b600b831061270257505050565b81516001600160a01b0316815260019290920191602091820191016126f5565b9060009182915b600583106127375750505050565b815184825b6004821061275a575050506020608060019201920192019190612729565b60019083518152602080910193019101909161273c565b959261084097946127b16127bc926127a66127c7969e9d9c99959e6108608c019f60018060a01b03168c5260208c01906126f1565b6101808a0190612722565b6104008801906126f1565b610560860190612722565b6107e08401526108008301526108208201520152565b929193909380516128da57506127fd836127f786826129cb565b956129cb565b84518051919490916001600160a01b03908116908216036128be5750509061289360209392855192858701519360408787519701519801516040519889978897633fff811360e01b89527f0000000000000000000000000000000000000000000000000000000000030d40947f0000000000000000000000009f2fa7709b30c75047980a0d70a106728f0ef2db60048b01612771565b038173eb609695017aa8597fa9b3db276ec639783351d45af4908115610b825760009161129b575090565b61230360405192839263cb709ddd60e01b8452600484016126ad565b604051630f3537b560e31b815290819061230390878760048501612684565b9060408051906129088261037c565b819381518082906000905b600b82106129ab5750505061292781610401565b8352815160a081018181106001600160401b03821117610397578352600b82016000825b60058210612964575050506020840152601f0154910152565b8551600084825b60048310612995575050506020600192826129876004946103e6565b81520193019101909161294b565b600160208192845481520192019201919061296b565b82546001600160a01b031681526001928301929190910190602001612913565b9060409182516129da8161037c565b83516129e581610401565b61016036823781528380516129f9816103cb565b60005b60a08110612a68575060208301526000910152612a19828261250c565b92612a34612a30612a2986610520565b5460ff1690565b1590565b612a4c57505050612a476104fa91610546565b6128f9565b5162acf2cf60e51b815291829161230391859160048501612684565b6020919251612a76816103e6565b608036823781840152019085916129fc56fea26469706673582212209dde6b3f9d4069d63a268ba70cdc38bd3a91988ec2126eaff2ffa5a180011e5d64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000d9c622d64342b5faceef4d366b974aef6dcb338d000000000000000000000000d76c827ee2ce1e37c37fc2ce91376812d3c9bce200000000000000000000000029d0256fe397f6e442464982c4cba7670646059b000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000009f2fa7709b30c75047980a0d70a106728f0ef2db0000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d20000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000008000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c000000000000000000000000fc0000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc00000000000000000000000000000000000008000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c000000000000000000000000fc00000000000000000000000000000000000005000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3000000000000000000000000fc00000000000000000000000000000000000006000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000f16f226baa419d9dc9d92c040ccbc8c0e25f36d7000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d20000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b000000000000000000000000fc000000000000000000000000000000000000010000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c350
-----Decoded View---------------
Arg [0] : _flashMinter (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [1] : _addressesProvider (address): 0xD9C622d64342B5FaCeef4d366B974AEf6dCB338D
Arg [2] : _liquidateLender (address): 0xD76C827Ee2Ce1E37c37Fc2ce91376812d3c9BCE2
Arg [3] : _aDUSD (address): 0x29d0256fe397F6e442464982C4Cba7670646059b
Arg [4] : _slippageTolerance (uint256): 500000
Arg [5] : _curveRouter (address): 0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db
Arg [6] : _maxSlippageSurplusSwapBps (uint256): 200000
Arg [7] : _defaultSwapParamsList (tuple[]):
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0xFC00000000000000000000000000000000000006
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0xFc00000000000000000000000000000000000001,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFC00000000000000000000000000000000000006,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0xFC00000000000000000000000000000000000006,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0xFC00000000000000000000000000000000000005
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0xFc00000000000000000000000000000000000001,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFC00000000000000000000000000000000000006,0xF2f426Fe123De7b769b2D4F8c911512F065225d3,0xFC00000000000000000000000000000000000005,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0xFC00000000000000000000000000000000000005,0xF2f426Fe123De7b769b2D4F8c911512F065225d3,0xFC00000000000000000000000000000000000006,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0xFc00000000000000000000000000000000000001,0x8b4E5263E8D6cc0bbF31EDF14491fc6077B88229,0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2,0x8b4E5263E8D6cc0bbF31EDF14491fc6077B88229,0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0xfc00000000000000000000000000000000000008
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0xFc00000000000000000000000000000000000001,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFC00000000000000000000000000000000000006,0xF2f426Fe123De7b769b2D4F8c911512F065225d3,0xFC00000000000000000000000000000000000005,0xaCDc85AFCD8B83Eb171AFFCbe29FaD204F6ae45C,0xfc00000000000000000000000000000000000008,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0xfc00000000000000000000000000000000000008,0xaCDc85AFCD8B83Eb171AFFCbe29FaD204F6ae45C,0xFC00000000000000000000000000000000000005,0xF2f426Fe123De7b769b2D4F8c911512F065225d3,0xFC00000000000000000000000000000000000006,0xa0D3911349e701A1F49C1Ba2dDA34b4ce9636569,0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0xFc00000000000000000000000000000000000001
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0xF16f226Baa419d9DC9D92C040CCBC8c0E25F36D7,0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2,0x8b4E5263E8D6cc0bbF31EDF14491fc6077B88229,0xFc00000000000000000000000000000000000001,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [1] : inputToken (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [2] : outputToken (address): 0xF1e2b576aF4C6a7eE966b14C810b772391e92153
Arg [3] : swapExtraParams (tuple):
Arg [1] : route (address[11]): 0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0xFc00000000000000000000000000000000000001,0xeE454138083b9B9714cac3c7cF12560248d76D6B,0xF1e2b576aF4C6a7eE966b14C810b772391e92153,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
Arg [4] : reverseSwapExtraParams (tuple):
Arg [1] : route (address[11]): 0xF1e2b576aF4C6a7eE966b14C810b772391e92153,0xeE454138083b9B9714cac3c7cF12560248d76D6B,0xFc00000000000000000000000000000000000001,0x9CA648D2f51098941688Db9a0beb1DadC2D1B357,0x788D96f655735f52c676A133f4dFC53cEC614d4A,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
Arg [2] : swapParams (uint256[4][5]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [3] : swapSlippageBufferBps (uint256): 50000
-----Encoded View---------------
405 Constructor Arguments found :
Arg [0] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [1] : 000000000000000000000000d9c622d64342b5faceef4d366b974aef6dcb338d
Arg [2] : 000000000000000000000000d76c827ee2ce1e37c37fc2ce91376812d3c9bce2
Arg [3] : 00000000000000000000000029d0256fe397f6e442464982c4cba7670646059b
Arg [4] : 000000000000000000000000000000000000000000000000000000000007a120
Arg [5] : 0000000000000000000000009f2fa7709b30c75047980a0d70a106728f0ef2db
Arg [6] : 0000000000000000000000000000000000000000000000000000000000030d40
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [9] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [10] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [11] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [12] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [13] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [14] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [15] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [18] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [20] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [21] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [22] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [23] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [24] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [25] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [26] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [27] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [28] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [29] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [30] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [31] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [32] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [33] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [34] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [35] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [36] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [37] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [38] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [39] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [40] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [41] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [42] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [43] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [44] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [45] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [46] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [47] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [48] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [49] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [50] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [51] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [52] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [53] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [54] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [55] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [56] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [57] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [58] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [59] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [60] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [61] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [62] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [63] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [64] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [65] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [66] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [67] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [68] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [69] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [70] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [71] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [72] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [73] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [74] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [75] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [76] : 000000000000000000000000fc00000000000000000000000000000000000005
Arg [77] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [78] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [79] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [80] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [81] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [82] : 000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3
Arg [83] : 000000000000000000000000fc00000000000000000000000000000000000005
Arg [84] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [85] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [86] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [87] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [88] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [89] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [90] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [91] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [92] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [93] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [94] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [95] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [96] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [97] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [98] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [99] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [100] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [101] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [102] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [103] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [104] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [105] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [106] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [107] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [108] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [109] : 000000000000000000000000fc00000000000000000000000000000000000005
Arg [110] : 000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3
Arg [111] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [112] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [113] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [114] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [115] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [116] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [117] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [118] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [119] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [120] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [121] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [122] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [123] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [124] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [125] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [126] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [127] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [128] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [129] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [130] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [131] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [132] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [133] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [134] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [135] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [136] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [137] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [138] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [139] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [140] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [141] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [142] : 000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2
Arg [143] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [144] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [145] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [146] : 0000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229
Arg [147] : 000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2
Arg [148] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [149] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [150] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [151] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [152] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [153] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [154] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [155] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [156] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [157] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [158] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [159] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [160] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [161] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [162] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [163] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [164] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [165] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [166] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [167] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [168] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [169] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [170] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [171] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [172] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [173] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [174] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [175] : 000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2
Arg [176] : 0000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229
Arg [177] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [178] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [179] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [180] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [181] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [182] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [183] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [184] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [185] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [186] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [187] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [188] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [189] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [190] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [191] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [192] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [193] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [194] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [195] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [196] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [197] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [198] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [199] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [200] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [201] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [202] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [203] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [204] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [205] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [206] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [207] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [208] : 000000000000000000000000fc00000000000000000000000000000000000008
Arg [209] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [210] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [211] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [212] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [213] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [214] : 000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3
Arg [215] : 000000000000000000000000fc00000000000000000000000000000000000005
Arg [216] : 000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c
Arg [217] : 000000000000000000000000fc00000000000000000000000000000000000008
Arg [218] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [219] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [220] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [221] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [222] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [223] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [224] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [225] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [226] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [227] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [228] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [229] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [230] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [231] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [232] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [233] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [234] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [235] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [236] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [237] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [238] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [239] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [240] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [241] : 000000000000000000000000fc00000000000000000000000000000000000008
Arg [242] : 000000000000000000000000acdc85afcd8b83eb171affcbe29fad204f6ae45c
Arg [243] : 000000000000000000000000fc00000000000000000000000000000000000005
Arg [244] : 000000000000000000000000f2f426fe123de7b769b2d4f8c911512f065225d3
Arg [245] : 000000000000000000000000fc00000000000000000000000000000000000006
Arg [246] : 000000000000000000000000a0d3911349e701a1f49c1ba2dda34b4ce9636569
Arg [247] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [248] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [249] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [250] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [251] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [252] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [253] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [254] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [255] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [256] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [257] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [258] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [259] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [260] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [261] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [262] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [263] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [264] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [265] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [266] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [267] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [268] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [269] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [270] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [271] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [272] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [273] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [274] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [275] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [276] : 000000000000000000000000f16f226baa419d9dc9d92c040ccbc8c0e25f36d7
Arg [277] : 000000000000000000000000211cc4dd073734da055fbf44a2b4667d5e5fe5d2
Arg [278] : 0000000000000000000000008b4e5263e8d6cc0bbf31edf14491fc6077b88229
Arg [279] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [280] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [281] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [282] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [283] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [284] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [285] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [286] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [287] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [288] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [289] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [290] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [291] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [292] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [293] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [294] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [295] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [296] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [297] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [298] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [299] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [300] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [301] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [302] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [303] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [304] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [305] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [306] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [307] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [308] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [309] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [310] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [311] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [312] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [313] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [314] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [315] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [316] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [317] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [318] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [319] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [320] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [321] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [322] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [323] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [324] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [325] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [326] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [327] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [328] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [329] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [330] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [331] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [332] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [333] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [334] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [335] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [336] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [337] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [338] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [339] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [340] : 000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153
Arg [341] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [342] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [343] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [344] : 000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b
Arg [345] : 000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153
Arg [346] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [347] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [348] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [349] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [350] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [351] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [352] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [353] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [354] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [355] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [356] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [357] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [358] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [359] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [360] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [361] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [362] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [363] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [364] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [365] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [366] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [367] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [368] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [369] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [370] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [371] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [372] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [373] : 000000000000000000000000f1e2b576af4c6a7ee966b14c810b772391e92153
Arg [374] : 000000000000000000000000ee454138083b9b9714cac3c7cf12560248d76d6b
Arg [375] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [376] : 0000000000000000000000009ca648d2f51098941688db9a0beb1dadc2d1b357
Arg [377] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [378] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [379] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [380] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [381] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [382] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [383] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [384] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [385] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [386] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [387] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [388] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [389] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [390] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [391] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [392] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [393] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [394] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [395] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [396] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [397] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [398] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [399] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [400] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [401] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [402] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [403] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [404] : 000000000000000000000000000000000000000000000000000000000000c350
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.