Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xb7106e52fbf01777fc6b26305ca12d817b6d4ff1cfefbd905e01953d4487f827 | 0x60806040 | 16875066 | 565 days 19 hrs ago | 0xb0dd96118594903bacb2746eb228550c10b2b1da | IN | Create: CurveLogic | 0 MATIC | 0.001068895106 |
[ Download CSV Export ]
Contract Name:
CurveLogic
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT 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: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../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; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @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, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ 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 substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ 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. * * _Available since v3.4._ */ 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. * * _Available since v3.4._ */ 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. * * _Available since v3.4._ */ 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 addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 0x445fe580ef8d70ff569ab36e80c647af338db351 interface ICurvePool { event TokenExchangeUnderlying( address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought ); // solium-disable-next-line mixedcase function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 minDy ) external returns (uint256); function add_liquidity( uint256[3] calldata amounts, uint256 min_mint_amount, bool use_underlying ) external returns (uint256); function remove_liquidity_imbalance( uint256[3] calldata amounts, uint256 max_burn_amount, bool use_underlying ) external; function remove_liquidity_one_coin( uint256 token_amount, int128 i, uint256 min_amount, bool use_underlying ) external returns (uint256); function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256); function calc_token_amount(uint256[3] calldata amounts, bool is_deposit) external view returns (uint256); function get_virtual_price() external view returns (uint256); function underlying_coins(uint256) external view returns (address); function lp_token() external view returns (address); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IMemory { function getUint(uint256) external view returns (uint256); function setUint(uint256 id, uint256 value) external; function getAToken(address asset) external view returns (address); function setAToken(address asset, address _aToken) external; function getCrToken(address asset) external view returns (address); function setCrToken(address asset, address _crToken) external; }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title RegistryInterface Interface */ interface IRegistry { function logic(address logicAddr) external view returns (bool); function implementation(bytes32 key) external view returns (address); function notAllowed(address erc20) external view returns (bool); function deployWallet() external returns (address); function wallets(address user) external view returns (address); function getFee() external view returns (uint256); function feeRecipient() external view returns (address); function memoryAddr() external view returns (address); function distributionContract(address token) external view returns (address); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IWallet { event LogMint(address indexed erc20, uint256 tokenAmt); event LogRedeem(address indexed erc20, uint256 tokenAmt); event LogBorrow(address indexed erc20, uint256 tokenAmt); event LogPayback(address indexed erc20, uint256 tokenAmt); event LogDeposit(address indexed erc20, uint256 tokenAmt); event LogWithdraw(address indexed erc20, uint256 tokenAmt); event LogSwap(address indexed src, address indexed dest, uint256 amount); event LogLiquidityAdd( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event LogLiquidityRemove( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event VaultDeposit(address indexed erc20, uint256 tokenAmt); event VaultWithdraw(address indexed erc20, uint256 tokenAmt); event VaultClaim(address indexed erc20, uint256 tokenAmt); event DelegateAdded(address delegate); event DelegateRemoved(address delegate); function executeMetaTransaction(bytes memory sign, bytes memory data) external; function execute(address[] calldata targets, bytes[] calldata datas) external payable; function owner() external view returns (address); function registry() external view returns (address); function DELEGATE_ROLE() external view returns (bytes32); function hasRole(bytes32, address) external view returns (bool); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; library UniversalERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private constant ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000); IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); function universalTransfer( IERC20 token, address to, uint256 amount ) internal returns (bool success) { if (amount == 0) { return true; } if (isETH(token)) { payable(to).transfer(amount); } else { token.safeTransfer(to, amount); return true; } } function universalTransferFrom( IERC20 token, address from, address to, uint256 amount ) internal { if (amount == 0) { return; } if (isETH(token)) { require( from == msg.sender && msg.value >= amount, "Wrong useage of ETH.universalTransferFrom()" ); if (to != address(this)) { payable(to).transfer(amount); } if (msg.value > amount) { payable(msg.sender).transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(from, to, amount); } } function universalTransferFromSenderToThis(IERC20 token, uint256 amount) internal { if (amount == 0) { return; } if (isETH(token)) { if (msg.value > amount) { // Return remainder if exist payable(msg.sender).transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(msg.sender, address(this), amount); } } function universalApprove( IERC20 token, address to, uint256 amount ) internal { if (!isETH(token)) { if (amount == 0) { token.safeApprove(to, 0); return; } uint256 allowance = token.allowance(address(this), to); if (allowance < amount) { if (allowance > 0) { token.safeApprove(to, 0); } token.safeApprove(to, amount); } } } function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) { if (isETH(token)) { return who.balance; } else { return token.balanceOf(who); } } function universalDecimals(IERC20 token) internal view returns (uint256) { if (isETH(token)) { return 18; } (bool success, bytes memory data) = address(token).staticcall{gas: 10000}( abi.encodeWithSignature("decimals()") ); if (!success || data.length == 0) { (success, data) = address(token).staticcall{gas: 10000}( abi.encodeWithSignature("DECIMALS()") ); } return (success && data.length > 0) ? abi.decode(data, (uint256)) : 18; } function isETH(IERC20 token) internal pure returns (bool) { return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS)); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../libs/UniversalERC20.sol"; import "../interfaces/ICurvePool.sol"; import "./Helpers.sol"; contract CurveLogic is Helpers { using UniversalERC20 for IERC20; using SafeMath for uint256; // EVENTS event LogSwap(address indexed src, address indexed dest, uint256 amount); event LogLiquidityAdd( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event LogLiquidityRemove( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); function toInt128(uint256 num) internal pure returns (int128) { return int128(int256(num)); } /** * @notice add liquidity to Curve Pool * @param getId read value from memory contract * @param setId set dest tokens received to memory contract */ function swap( ICurvePool pool, address src, address dest, uint256 tokenAmt, uint256 getId, uint256 setId, uint256 divider ) external payable { uint256 realAmt = getId > 0 ? getUint(getId).div(divider) : tokenAmt; uint256 i; uint256 j; for (uint256 x = 1; x <= 3; x++) { if (pool.underlying_coins(x - 1) == src) i = x; if (pool.underlying_coins(x - 1) == dest) j = x; } require(i != 0 && j != 0); IERC20(src).universalApprove(address(pool), realAmt); uint256 received = pool.exchange_underlying( toInt128(i - 1), toInt128(j - 1), realAmt, 0 ); // set j tokens received if (setId > 0) { setUint(setId, received); } emit LogSwap( pool.underlying_coins(i - 1), pool.underlying_coins(j - 1), realAmt ); } /** * @notice add liquidity to Curve Pool * @param tokenId id of the token to remove liq. Should be 0, 1 or 2 * @param getId read value from memory contract * @param setId set LP tokens received to memory contract */ function addLiquidity( ICurvePool pool, uint256 tokenAmt, uint256 tokenId, // 0, 1 or 2 uint256 getId, uint256 setId, uint256 divider ) external payable { IERC20 token; try pool.underlying_coins(tokenId) returns (address _token) { token = IERC20(_token); } catch { revert("!TOKENID"); } uint256 realAmt = getId > 0 ? getUint(getId).div(divider) : tokenAmt; uint256[3] memory tokenAmts; tokenAmts[tokenId] = realAmt; IERC20(token).universalApprove(address(pool), realAmt); uint256 liquidity = pool.add_liquidity(tokenAmts, 0, true); // set LP tokens received if (setId > 0) { setUint(setId, liquidity); } emit LogLiquidityAdd(address(token), address(0), realAmt, 0); } /** * @notice remove liquidity from Curve Pool * @param tokenAmt amount of pool Tokens to burn * @param tokenId id of the token to remove liq. Should be 0, 1 or 2 * @param getId read value of amount from memory contract * @param setId set value of tokens received in memory contract */ function removeLiquidity( ICurvePool pool, uint256 tokenAmt, uint256 tokenId, uint256 getId, uint256 setId, uint256 divider ) external payable { uint256 realAmt = getId > 0 ? getUint(getId).div(divider) : tokenAmt; require(realAmt > 0, "ZERO AMOUNT"); require(tokenId <= 2, "INVALID TOKEN"); IERC20 poolToken = IERC20(pool.lp_token()); poolToken.universalApprove(address(pool), realAmt); uint256 amountReceived = pool.remove_liquidity_one_coin( realAmt, int128(int256(tokenId)), 1, true ); // set tokens received if (setId > 0) { setUint(setId, amountReceived); } emit LogLiquidityRemove( pool.underlying_coins(tokenId), address(0), amountReceived, 0 ); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IMemory.sol"; import "../interfaces/IRegistry.sol"; import "../interfaces/IWallet.sol"; contract Helpers { /** * @dev Return Memory Variable Address */ function getMemoryAddr() public view returns (address) { return IRegistry(IWallet(address(this)).registry()).memoryAddr(); } /** * @dev Get Uint value from Memory Contract. */ function getUint(uint256 id) internal view returns (uint256) { return IMemory(getMemoryAddr()).getUint(id); } /** * @dev Set Uint value in Memory Contract. */ function setUint(uint256 id, uint256 val) internal { IMemory(getMemoryAddr()).setUint(id, val); } /** * @dev Get aToken address from Memory Contract. */ function getAToken(address asset) internal view returns (address) { return IMemory(getMemoryAddr()).getAToken(asset); } /** * @dev Get crToken address from Memory Contract. */ function getCrToken(address asset) internal view returns (address) { return IMemory(getMemoryAddr()).getCrToken(asset); } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenA","type":"address"},{"indexed":true,"internalType":"address","name":"tokenB","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountB","type":"uint256"}],"name":"LogLiquidityAdd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenA","type":"address"},{"indexed":true,"internalType":"address","name":"tokenB","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountB","type":"uint256"}],"name":"LogLiquidityRemove","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"dest","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LogSwap","type":"event"},{"inputs":[{"internalType":"contract ICurvePool","name":"pool","type":"address"},{"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getMemoryAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ICurvePool","name":"pool","type":"address"},{"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ICurvePool","name":"pool","type":"address"},{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dest","type":"address"},{"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"swap","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50611260806100206000396000f3fe60806040526004361061003f5760003560e01c80631e4cdf61146100445780632563e426146100595780634846220e1461006c578063fa821c9b1461007f575b600080fd5b61005761005236600461108b565b6100b0565b005b61005761006736600461108b565b61035a565b61005761007a36600461101e565b610551565b34801561008b57600080fd5b5061009461092d565b6040516001600160a01b03909116815260200160405180910390f35b60008084116100bf57856100d2565b6100d2826100cc86610a15565b90610aa2565b9050600081116101175760405162461bcd60e51b815260206004820152600b60248201526a16915493c8105353d5539560aa1b60448201526064015b60405180910390fd5b60028511156101585760405162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a2102a27a5a2a760991b604482015260640161010e565b6000876001600160a01b03166382c630666040518163ffffffff1660e01b815260040160206040518083038186803b15801561019357600080fd5b505afa1580156101a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cb9190610fe2565b90506101e16001600160a01b0382168984610ab5565b60405163517a55a360e01b815260048101839052600f87900b602482015260016044820181905260648201526000906001600160a01b038a169063517a55a390608401602060405180830381600087803b15801561023e57600080fd5b505af1158015610252573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027691906110d6565b90508415610288576102888582610ba3565b604051630b9947eb60e41b8152600481018890526000906001600160a01b038b169063b9947eb09060240160206040518083038186803b1580156102cb57600080fd5b505afa1580156102df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103039190610fe2565b6001600160a01b03167f45f6d7544bb29446542d65c92e426535ed61bd26d0faca61c7137df272e3636f836000604051610347929190918252602082015260400190565b60405180910390a3505050505050505050565b604051630b9947eb60e41b8152600481018590526000906001600160a01b0388169063b9947eb09060240160206040518083038186803b15801561039d57600080fd5b505afa9250505080156103cd575060408051601f3d908101601f191682019092526103ca91810190610fe2565b60015b6104045760405162461bcd60e51b8152602060048201526008602482015267085513d2d153925160c21b604482015260640161010e565b905060008085116104155786610422565b610422836100cc87610a15565b905061042c610fc4565b8181886003811061044d57634e487b7160e01b600052603260045260246000fd5b60200201526104666001600160a01b0384168a84610ab5565b6040516315b74c9d60e11b81526000906001600160a01b038b1690632b6e993a9061049a908590859060019060040161110a565b602060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ec91906110d6565b905085156104fe576104fe8682610ba3565b60408051848152600060208201819052916001600160a01b038716917f1a51391fad825e66369b29a1916819cb01e8d05cade4f39bfe7c6ea4edabb80a910160405180910390a350505050505050505050565b6000808411610560578461056d565b61056d826100cc86610a15565b905060008060015b600381116106cd576001600160a01b03808b16908c1663b9947eb061059b60018561119e565b6040518263ffffffff1660e01b81526004016105b991815260200190565b60206040518083038186803b1580156105d157600080fd5b505afa1580156105e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106099190610fe2565b6001600160a01b0316141561061c578092505b6001600160a01b03808a16908c1663b9947eb061063a60018561119e565b6040518263ffffffff1660e01b815260040161065891815260200190565b60206040518083038186803b15801561067057600080fd5b505afa158015610684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a89190610fe2565b6001600160a01b031614156106bb578091505b806106c5816111e1565b915050610575565b5081158015906106dc57508015155b6106e557600080fd5b6106f96001600160a01b038a168b85610ab5565b60006001600160a01b038b1663a6417ed661071b61071860018761119e565b90565b61072961071860018761119e565b6040516001600160e01b031960e085901b168152600f92830b6004820152910b60248201526044810187905260006064820152608401602060405180830381600087803b15801561077957600080fd5b505af115801561078d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b191906110d6565b905085156107c3576107c38682610ba3565b6001600160a01b038b1663b9947eb06107dd60018561119e565b6040518263ffffffff1660e01b81526004016107fb91815260200190565b60206040518083038186803b15801561081357600080fd5b505afa158015610827573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084b9190610fe2565b6001600160a01b03168b6001600160a01b031663b9947eb0600186610870919061119e565b6040518263ffffffff1660e01b815260040161088e91815260200190565b60206040518083038186803b1580156108a657600080fd5b505afa1580156108ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108de9190610fe2565b6001600160a01b03167f97a2ac50c3be9b01862011d786db2a0db9e7ebff678bccfc2c8ed1698f2b09138660405161091891815260200190565b60405180910390a35050505050505050505050565b6000306001600160a01b0316637b1039996040518163ffffffff1660e01b815260040160206040518083038186803b15801561096857600080fd5b505afa15801561097c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a09190610fe2565b6001600160a01b031663f54ad35f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109d857600080fd5b505afa1580156109ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a109190610fe2565b905090565b6000610a1f61092d565b6001600160a01b031663a9c70eaa836040518263ffffffff1660e01b8152600401610a4c91815260200190565b60206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c91906110d6565b92915050565b6000610aae828461117e565b9392505050565b610abe83610c12565b610adc5780610ae157610adc6001600160a01b038416836000610c4b565b505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b158015610b2c57600080fd5b505afa158015610b40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6491906110d6565b905081811015610b9d578015610b8957610b896001600160a01b038516846000610c4b565b610b9d6001600160a01b0385168484610c4b565b50505050565b610bab61092d565b604051631878f25160e21b815260048101849052602481018390526001600160a01b0391909116906361e3c94490604401600060405180830381600087803b158015610bf657600080fd5b505af1158015610c0a573d6000803e3d6000fd5b505050505050565b60006001600160a01b0382161580610a9c57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b801580610cd45750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015610c9a57600080fd5b505afa158015610cae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd291906110d6565b155b610d3f5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161010e565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663095ea7b360e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656490840152610adc92869291600091610dcf918516908490610e4c565b805190915015610adc5780806020019051810190610ded9190610ffe565b610adc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161010e565b6060610e5b8484600085610e63565b949350505050565b606082471015610ec45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161010e565b843b610f125760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161010e565b600080866001600160a01b03168587604051610f2e91906110ee565b60006040518083038185875af1925050503d8060008114610f6b576040519150601f19603f3d011682016040523d82523d6000602084013e610f70565b606091505b5091509150610f80828286610f8b565b979650505050505050565b60608315610f9a575081610aae565b825115610faa5782518084602001fd5b8160405162461bcd60e51b815260040161010e919061114b565b60405180606001604052806003906020820280368337509192915050565b600060208284031215610ff3578081fd5b8151610aae81611212565b60006020828403121561100f578081fd5b81518015158114610aae578182fd5b600080600080600080600060e0888a031215611038578283fd5b873561104381611212565b9650602088013561105381611212565b9550604088013561106381611212565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b60008060008060008060c087890312156110a3578182fd5b86356110ae81611212565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b6000602082840312156110e7578081fd5b5051919050565b600082516111008184602087016111b5565b9190910192915050565b60a08101818560005b6003811015611132578151835260209283019290910190600101611113565b5050508360608301528215156080830152949350505050565b602081526000825180602084015261116a8160408501602087016111b5565b601f01601f19169190910160400192915050565b60008261119957634e487b7160e01b81526012600452602481fd5b500490565b6000828210156111b0576111b06111fc565b500390565b60005b838110156111d05781810151838201526020016111b8565b83811115610b9d5750506000910152565b60006000198214156111f5576111f56111fc565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461122757600080fd5b5056fea26469706673582212209d7ec260e95a93b49095639eebf58e0f93e4d3a2654dff5f57c3a2b5a57f459664736f6c63430008040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.