Contract
0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e
4
Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Source Code Verified (Exact Match)
Contract Name:
Vyper_contract
Compiler Version
vyper:0.2.16
Contract Source Code (Vyper language format)
# @version 0.2.16
"""
@title "Zap" Depositer for permissionless factory metapools
@author Curve.Fi
@license Copyright (c) Curve.Fi, 2021 - all rights reserved
"""
interface ERC20:
def approve(_spender: address, _amount: uint256): nonpayable
def balanceOf(_owner: address) -> uint256: view
interface CurveMeta:
def add_liquidity(amounts: uint256[N_COINS], min_mint_amount: uint256, _receiver: address) -> uint256: nonpayable
def remove_liquidity(_amount: uint256, min_amounts: uint256[N_COINS]): nonpayable
def remove_liquidity_one_coin(_token_amount: uint256, i: int128, min_amount: uint256, _receiver: address) -> uint256: nonpayable
def remove_liquidity_imbalance(amounts: uint256[N_COINS], max_burn_amount: uint256) -> uint256: nonpayable
def exchange_underlying(i: int128, j: int128, dx: uint256, min_dy: uint256, receiver: address) -> uint256: nonpayable
def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256: view
def calc_token_amount(amounts: uint256[N_COINS], deposit: bool) -> uint256: view
def coins(i: uint256) -> address: view
interface CurveBase:
def add_liquidity(amounts: uint256[BASE_N_COINS], min_mint_amount: uint256, use_underlying: bool): nonpayable
def remove_liquidity(_amount: uint256, min_amounts: uint256[BASE_N_COINS], use_underlying: bool): nonpayable
def remove_liquidity_one_coin(_token_amount: uint256, i: int128, min_amount: uint256, use_underlying: bool): nonpayable
def remove_liquidity_imbalance(amounts: uint256[BASE_N_COINS], max_burn_amount: uint256, use_underlying: bool): nonpayable
def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256: view
def calc_token_amount(amounts: uint256[BASE_N_COINS], deposit: bool) -> uint256: view
def coins(i: uint256) -> address: view
def fee() -> uint256: view
interface LendingPool:
def withdraw(_underlying_asset: address, _amount: uint256, _receiver: address): nonpayable
# USD Pool
BASE_N_COINS: constant(int128) = 3
BASE_POOL: constant(address) = 0x7f90122BF0700F9E7e1F688fe926940E8839F353
BASE_LP_TOKEN: constant(address) = 0x1337BedC9D22ecbe766dF105c9623922A27963EC
BASE_COINS: constant(address[BASE_N_COINS]) = [0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a, 0x46A51127C3ce23fb7AB1DE06226147F446e4a857, 0x532E6537FEA298397212F09A61e03311686f548e]
UNDERLYING_COINS: constant(address[BASE_N_COINS]) = [0xd586E7F844cEa2F87f50152665BCbc2C279D8d70, 0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664, 0xc7198437980c041c805A1EDcbA50c1Ce5db95118]
LENDING_POOL: constant(address) = 0x4F01AeD16D97E3aB5ab2B501154DC9bb0F1A5A2C
N_COINS: constant(int128) = 2
MAX_COIN: constant(int128) = N_COINS-1
N_ALL_COINS: constant(int128) = N_COINS + BASE_N_COINS - 1
FEE_DENOMINATOR: constant(uint256) = 10 ** 10
FEE_IMPRECISION: constant(uint256) = 100 * 10 ** 8 # % of the fee
# coin -> pool -> is approved to transfer?
is_approved: HashMap[address, HashMap[address, bool]]
@external
def __init__():
"""
@notice Contract constructor
"""
for coin in BASE_COINS:
ERC20(coin).approve(BASE_POOL, MAX_UINT256)
for coin in UNDERLYING_COINS:
ERC20(coin).approve(BASE_POOL, MAX_UINT256)
@external
def add_liquidity(
_pool: address,
_deposit_amounts: uint256[N_ALL_COINS],
_min_mint_amount: uint256,
_receiver: address = msg.sender,
_use_underlying: bool = True
) -> uint256:
"""
@notice Wrap underlying coins and deposit them into `_pool`
@param _pool Address of the pool to deposit into
@param _deposit_amounts List of amounts of underlying coins to deposit
@param _min_mint_amount Minimum amount of LP tokens to mint from the deposit
@param _receiver Address that receives the LP tokens
@param _use_underlying Flag determining the usage of underlying coins for deposit
@return Amount of LP tokens received by depositing
"""
meta_amounts: uint256[N_COINS] = empty(uint256[N_COINS])
base_amounts: uint256[BASE_N_COINS] = empty(uint256[BASE_N_COINS])
deposit_base: bool = False
base_coins: address[BASE_N_COINS] = empty(address[BASE_N_COINS])
if _use_underlying:
base_coins = UNDERLYING_COINS
else:
base_coins = BASE_COINS
if _deposit_amounts[0] != 0:
coin: address = CurveMeta(_pool).coins(0)
if not self.is_approved[coin][_pool]:
ERC20(coin).approve(_pool, MAX_UINT256)
self.is_approved[coin][_pool] = True
response: Bytes[32] = raw_call(
coin,
_abi_encode(
msg.sender,
self,
_deposit_amounts[0],
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
# handle fee on transfer
meta_amounts[0] = ERC20(coin).balanceOf(self)
for i in range(1, N_ALL_COINS):
amount: uint256 = _deposit_amounts[i]
if amount == 0:
continue
deposit_base = True
base_idx: uint256 = i - 1
coin: address = base_coins[base_idx]
response: Bytes[32] = raw_call(
coin,
_abi_encode(
msg.sender,
self,
amount,
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
# Handle potential transfer fees (i.e. Tether/renBTC)
base_amounts[base_idx] = ERC20(coin).balanceOf(self)
# Deposit to the base pool
if deposit_base:
coin: address = BASE_LP_TOKEN
CurveBase(BASE_POOL).add_liquidity(base_amounts, 0, _use_underlying)
meta_amounts[MAX_COIN] = ERC20(coin).balanceOf(self)
if not self.is_approved[coin][_pool]:
ERC20(coin).approve(_pool, MAX_UINT256)
self.is_approved[coin][_pool] = True
# Deposit to the meta pool
return CurveMeta(_pool).add_liquidity(meta_amounts, _min_mint_amount, _receiver)
@external
def remove_liquidity(
_pool: address,
_burn_amount: uint256,
_min_amounts: uint256[N_ALL_COINS],
_receiver: address = msg.sender,
_use_underlying: bool = True
) -> uint256[N_ALL_COINS]:
"""
@notice Withdraw and unwrap coins from the pool
@dev Withdrawal amounts are based on current deposit ratios
@param _pool Address of the pool to deposit into
@param _burn_amount Quantity of LP tokens to burn in the withdrawal
@param _min_amounts Minimum amounts of underlying coins to receive
@param _receiver Address that receives the LP tokens
@return List of amounts of underlying coins that were withdrawn
"""
response: Bytes[32] = raw_call(
_pool,
_abi_encode(
msg.sender,
self,
_burn_amount,
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
min_amounts_base: uint256[BASE_N_COINS] = empty(uint256[BASE_N_COINS])
amounts: uint256[N_ALL_COINS] = empty(uint256[N_ALL_COINS])
# Withdraw from meta
meta_received: uint256[N_COINS] = empty(uint256[N_COINS])
CurveMeta(_pool).remove_liquidity(_burn_amount, [_min_amounts[0], convert(0, uint256)])
coins: address[N_COINS] = empty(address[N_COINS])
for i in range(N_COINS):
coin: address = CurveMeta(_pool).coins(i)
coins[i] = coin
# Handle fee on transfer for the first coin
meta_received[i] = ERC20(coin).balanceOf(self)
# Withdraw from base
for i in range(BASE_N_COINS):
min_amounts_base[i] = _min_amounts[MAX_COIN+i]
CurveBase(BASE_POOL).remove_liquidity(meta_received[MAX_COIN], min_amounts_base, _use_underlying)
# Transfer all coins out
response = raw_call(
coins[0], # metapool coin 0
_abi_encode(
_receiver,
meta_received[0],
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
amounts[0] = meta_received[0]
base_coins: address[BASE_N_COINS] = empty(address[BASE_N_COINS])
if _use_underlying:
base_coins = UNDERLYING_COINS
else:
base_coins = BASE_COINS
for i in range(1, N_ALL_COINS):
coin: address = base_coins[i-1]
# handle potential fee on transfer
amounts[i] = ERC20(coin).balanceOf(self)
response = raw_call(
coin,
_abi_encode(
_receiver,
amounts[i],
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
return amounts
@external
def remove_liquidity_one_coin(
_pool: address,
_burn_amount: uint256,
i: int128,
_min_amount: uint256,
_receiver: address = msg.sender,
_use_underlying: bool = True,
) -> uint256:
"""
@notice Withdraw and unwrap a single coin from the pool
@param _pool Address of the pool to deposit into
@param _burn_amount Amount of LP tokens to burn in the withdrawal
@param i Index value of the coin to withdraw
@param _min_amount Minimum amount of underlying coin to receive
@param _receiver Address that receives the LP tokens
@return Amount of underlying coin received
"""
response: Bytes[32] = raw_call(
_pool,
_abi_encode(
msg.sender,
self,
_burn_amount,
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
coin_amount: uint256 = 0
if i == 0:
coin_amount = CurveMeta(_pool).remove_liquidity_one_coin(_burn_amount, i, _min_amount, _receiver)
else:
base_coins: address[BASE_N_COINS] = empty(address[BASE_N_COINS])
if _use_underlying:
base_coins = UNDERLYING_COINS
else:
base_coins = BASE_COINS
coin: address = base_coins[i - MAX_COIN]
# Withdraw a base pool coin
coin_amount = CurveMeta(_pool).remove_liquidity_one_coin(_burn_amount, MAX_COIN, 0, self)
CurveBase(BASE_POOL).remove_liquidity_one_coin(coin_amount, i-MAX_COIN, _min_amount, _use_underlying)
coin_amount = ERC20(coin).balanceOf(self)
response = raw_call(
coin,
_abi_encode(
_receiver,
coin_amount,
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
return coin_amount
@external
def remove_liquidity_imbalance(
_pool: address,
_amounts: uint256[N_ALL_COINS],
_max_burn_amount: uint256,
_receiver: address = msg.sender,
_use_underlying: bool = True
) -> uint256:
"""
@notice Withdraw coins from the pool in an imbalanced amount
@param _pool Address of the pool to deposit into
@param _amounts List of amounts of underlying coins to withdraw
@param _max_burn_amount Maximum amount of LP token to burn in the withdrawal
@param _receiver Address that receives the LP tokens
@return Actual amount of the LP token burned in the withdrawal
"""
fee: uint256 = CurveBase(BASE_POOL).fee() * BASE_N_COINS / (4 * (BASE_N_COINS - 1))
fee += fee * FEE_IMPRECISION / FEE_DENOMINATOR # Overcharge to account for imprecision
# Transfer the LP token in
response: Bytes[32] = raw_call(
_pool,
_abi_encode(
msg.sender,
self,
_max_burn_amount,
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
withdraw_base: bool = False
amounts_base: uint256[BASE_N_COINS] = empty(uint256[BASE_N_COINS])
amounts_meta: uint256[N_COINS] = empty(uint256[N_COINS])
# determine amounts to withdraw from base pool
for i in range(BASE_N_COINS):
amount: uint256 = _amounts[MAX_COIN + i]
if amount != 0:
amounts_base[i] = amount
withdraw_base = True
# determine amounts to withdraw from metapool
amounts_meta[0] = _amounts[0]
if withdraw_base:
amounts_meta[MAX_COIN] = CurveBase(BASE_POOL).calc_token_amount(amounts_base, False)
amounts_meta[MAX_COIN] += amounts_meta[MAX_COIN] * fee / FEE_DENOMINATOR + 1
# withdraw from metapool and return the remaining LP tokens
burn_amount: uint256 = CurveMeta(_pool).remove_liquidity_imbalance(amounts_meta, _max_burn_amount)
response = raw_call(
_pool,
_abi_encode(
msg.sender,
_max_burn_amount - burn_amount,
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
# withdraw from base pool
if withdraw_base:
CurveBase(BASE_POOL).remove_liquidity_imbalance(amounts_base, amounts_meta[MAX_COIN], _use_underlying)
coin: address = BASE_LP_TOKEN
leftover: uint256 = ERC20(coin).balanceOf(self)
if leftover > 0:
# if some base pool LP tokens remain, re-deposit them for the caller
if not self.is_approved[coin][_pool]:
ERC20(coin).approve(_pool, MAX_UINT256)
self.is_approved[coin][_pool] = True
burn_amount -= CurveMeta(_pool).add_liquidity([convert(0, uint256), leftover], 0, msg.sender)
# transfer withdrawn base pool tokens to caller
base_coins: address[BASE_N_COINS] = empty(address[BASE_N_COINS])
if _use_underlying:
base_coins = UNDERLYING_COINS
else:
base_coins = BASE_COINS
for i in range(BASE_N_COINS):
response = raw_call(
base_coins[i],
_abi_encode(
_receiver,
ERC20(base_coins[i]).balanceOf(self), # handle potential transfer fees
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
# transfer withdrawn metapool tokens to caller
if _amounts[0] > 0:
coin: address = CurveMeta(_pool).coins(0)
response = raw_call(
coin,
_abi_encode(
_receiver,
ERC20(coin).balanceOf(self), # handle potential fees
method_id=method_id("transfer(address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
return burn_amount
@view
@external
def calc_withdraw_one_coin(_pool: address, _token_amount: uint256, i: int128) -> uint256:
"""
@notice Calculate the amount received when withdrawing and unwrapping a single coin
@param _pool Address of the pool to deposit into
@param _token_amount Amount of LP tokens to burn in the withdrawal
@param i Index value of the underlying coin to withdraw
@return Amount of coin received
"""
if i < MAX_COIN:
return CurveMeta(_pool).calc_withdraw_one_coin(_token_amount, i)
else:
_base_tokens: uint256 = CurveMeta(_pool).calc_withdraw_one_coin(_token_amount, MAX_COIN)
return CurveBase(BASE_POOL).calc_withdraw_one_coin(_base_tokens, i-MAX_COIN)
@view
@external
def calc_token_amount(_pool: address, _amounts: uint256[N_ALL_COINS], _is_deposit: bool) -> uint256:
"""
@notice Calculate addition or reduction in token supply from a deposit or withdrawal
@dev This calculation accounts for slippage, but not fees.
Needed to prevent front-running, not for precise calculations!
@param _pool Address of the pool to deposit into
@param _amounts Amount of each underlying coin being deposited
@param _is_deposit set True for deposits, False for withdrawals
@return Expected amount of LP tokens received
"""
meta_amounts: uint256[N_COINS] = empty(uint256[N_COINS])
base_amounts: uint256[BASE_N_COINS] = empty(uint256[BASE_N_COINS])
meta_amounts[0] = _amounts[0]
for i in range(BASE_N_COINS):
base_amounts[i] = _amounts[i + MAX_COIN]
base_tokens: uint256 = CurveBase(BASE_POOL).calc_token_amount(base_amounts, _is_deposit)
meta_amounts[MAX_COIN] = base_tokens
return CurveMeta(_pool).calc_token_amount(meta_amounts, _is_deposit)
@external
def exchange_underlying(
_pool: address,
_i: int128,
_j: int128,
_dx: uint256,
_min_dy: uint256,
_receiver: address = msg.sender,
_use_underlying: bool = True
) -> uint256:
base_coins: address[BASE_N_COINS] = BASE_COINS
underlying_coins: address[BASE_N_COINS] = UNDERLYING_COINS
input_coin: address = ZERO_ADDRESS
should_wrap: bool = False
if _i == 0:
input_coin = CurveMeta(_pool).coins(0)
# approve the input coin for exchange
if not self.is_approved[input_coin][_pool]:
ERC20(input_coin).approve(_pool, MAX_UINT256)
self.is_approved[input_coin][_pool] = True
else:
base_i: int128 = _i - MAX_COIN
base_coin: address = base_coins[base_i]
if _use_underlying:
underlying_coin: address = underlying_coins[base_i]
# if the base and underlying coin are equal we can't wrap
should_wrap = base_coin != underlying_coin
input_coin = underlying_coin
else:
input_coin = base_coin
# approve the base coin to be exchanged irregardless of underlying/base status
if not self.is_approved[base_coin][_pool]:
ERC20(base_coin).approve(_pool, MAX_UINT256)
self.is_approved[base_coin][_pool] = True
response: Bytes[32] = raw_call(
input_coin,
_abi_encode(
msg.sender,
self,
_dx,
method_id=method_id("transferFrom(address,address,uint256)"),
),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
# we are using base coins so this will work simply
if not _use_underlying:
return CurveMeta(_pool).exchange_underlying(_i, _j, _dx, _min_dy, _receiver)
# we are using underlying so we potentially have to wrap
if should_wrap:
# approve for wrapping
if not self.is_approved[input_coin][LENDING_POOL]:
ERC20(input_coin).approve(LENDING_POOL, MAX_UINT256)
self.is_approved[input_coin][LENDING_POOL] = True
raw_call(
LENDING_POOL,
# deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)
_abi_encode(input_coin, _dx, self, convert(0, uint256), method_id=method_id("deposit(address,uint256,address,uint16)"))
)
dy: uint256 = CurveMeta(_pool).exchange_underlying(_i, _j, _dx, _min_dy, self)
# need to potentially unwrap now
output_coin: address = ZERO_ADDRESS
if _j == 0:
# we don't wrap the 0th token
output_coin = CurveMeta(_pool).coins(0)
should_wrap = False
else:
# we for sure are operating on underlying coins
base_j: int128 = _j - MAX_COIN
base_coin: address = base_coins[base_j]
underlying_coin: address = underlying_coins[base_j]
# if the base and underlying coin are equal we can't wrap
should_wrap = base_coin != underlying_coin
output_coin = underlying_coin
if should_wrap:
LendingPool(LENDING_POOL).withdraw(output_coin, dy, _receiver)
else:
response = raw_call(
output_coin,
_abi_encode(_receiver, dy, method_id=method_id("transfer(address,uint256)")),
max_outsize=32
)
if len(response) != 0:
assert convert(response, bool)
return dy[{"stateMutability":"nonpayable","type":"constructor","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_deposit_amounts","type":"uint256[4]"},{"name":"_min_mint_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_deposit_amounts","type":"uint256[4]"},{"name":"_min_mint_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_deposit_amounts","type":"uint256[4]"},{"name":"_min_mint_amount","type":"uint256"},{"name":"_receiver","type":"address"},{"name":"_use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[4]"}],"outputs":[{"name":"","type":"uint256[4]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[4]"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256[4]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[4]"},{"name":"_receiver","type":"address"},{"name":"_use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256[4]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_pool","type":"address"},{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_amount","type":"uint256"},{"name":"_receiver","type":"address"},{"name":"_use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_pool","type":"address"},{"name":"_amounts","type":"uint256[4]"},{"name":"_max_burn_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_pool","type":"address"},{"name":"_amounts","type":"uint256[4]"},{"name":"_max_burn_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_pool","type":"address"},{"name":"_amounts","type":"uint256[4]"},{"name":"_max_burn_amount","type":"uint256"},{"name":"_receiver","type":"address"},{"name":"_use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_withdraw_one_coin","inputs":[{"name":"_pool","type":"address"},{"name":"_token_amount","type":"uint256"},{"name":"i","type":"int128"}],"outputs":[{"name":"","type":"uint256"}],"gas":5753},{"stateMutability":"view","type":"function","name":"calc_token_amount","inputs":[{"name":"_pool","type":"address"},{"name":"_amounts","type":"uint256[4]"},{"name":"_is_deposit","type":"bool"}],"outputs":[{"name":"","type":"uint256"}],"gas":6666},{"stateMutability":"nonpayable","type":"function","name":"exchange_underlying","inputs":[{"name":"_pool","type":"address"},{"name":"_i","type":"int128"},{"name":"_j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"exchange_underlying","inputs":[{"name":"_pool","type":"address"},{"name":"_i","type":"int128"},{"name":"_j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"exchange_underlying","inputs":[{"name":"_pool","type":"address"},{"name":"_i","type":"int128"},{"name":"_j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"},{"name":"_receiver","type":"address"},{"name":"_use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]}]Contract Creation Code
7347afa96cdc9fab46904a55a6ad4bf6660b53c38a610180527346a51127c3ce23fb7ab1de06226147f446e4a8576101a05273532e6537fea298397212f09a61e03311686f548e6101c05261016060006003818352015b60206101605102610180015161014052610140513b1561282f5760006000604463095ea7b36101e052737f90122bf0700f9e7e1f688fe926940e8839f353610200527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610220526101fc6000610140515af11561282f575b8151600101808352811415610056575b505073d586e7f844cea2f87f50152665bcbc2c279d8d706101805273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646101a05273c7198437980c041c805a1edcba50c1ce5db951186101c05261016060006003818352015b60206101605102610180015161014052610140513b1561282f5760006000604463095ea7b36101e052737f90122bf0700f9e7e1f688fe926940e8839f353610200527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610220526101fc6000610140515af11561282f575b8151600101808352811415610137575b505061281756600436101561000d57612646565b600035601c526000513461264c5763384e03db8114156100375733610140526001610160526100a0565b63d0b951e88114156100635760016101605260c43560a01c61264c57602060c4610140376000506100a0565b631f5013bf81141561009b5760c43560a01c61264c57602060c46101403760e43560011c61264c57602060e4610160376000506100a0565b6106bb565b60043560a01c61264c576101203661018037610160511561010b5773d586e7f844cea2f87f50152665bcbc2c279d8d706102405273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646102605273c7198437980c041c805a1edcba50c1ce5db9511861028052610157565b7347afa96cdc9fab46904a55a6ad4bf6660b53c38a610240527346a51127c3ce23fb7ab1de06226147f446e4a8576102605273532e6537fea298397212f09a61e03311686f548e610280525b60006024351815610353576020610340602463c66106576102c05260006102e0526102dc6004355afa1561264c57601f3d111561264c57600050610340516102a05260006102a05160e05260c052604060c02060043560e05260c052604060c02054610235576102a0513b1561264c5760006000604463095ea7b36102c0526004356102e0527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610300526102dc60006102a0515af11561264c57600160006102a05160e05260c052604060c02060043560e05260c052604060c020555b6323b872dd61032452600461034480808033815250506020810190508080308152505060208101905080806024358152505060609050905001610320526103208051602001806103c08284600060045af11561264c57505060206104806103c0516103e060006102a0515af11561264c5760203d808211156102b757806102b9565b815b90509050610460526104608051602001806102c08284600060045af11561264c57505060006102c051181561031b576102c0806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b60206103a060246370a0823161032052306103405261033c6102a0515afa1561264c57601f3d111561264c576000506103a051610180525b6102a060016003818352015b60246102a051600481101561264c5760200201356102c0526102c051610384576104eb565b6001610220526102a051600180821061264c57808203905090506102e0526102406102e051600381101561264c576020020151610300526323b872dd6103845260046103a480808033815250506020810190508080308152505060208101905080806102c0518152505060609050905001610380526103808051602001806104208284600060045af11561264c57505060206104e0610420516104406000610300515af11561264c5760203d8082111561043e5780610440565b815b905090506104c0526104c08051602001806103208284600060045af11561264c57505060006103205118156104a257610320806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b602061040060246370a0823161038052306103a05261039c610300515afa1561264c57601f3d111561264c57600050610400516101c06102e051600381101561264c5760200201525b815160010180835281141561035f575b5050610220511561066457731337bedc9d22ecbe766df105c9623922a27963ec6102a052737f90122bf0700f9e7e1f688fe926940e8839f3533b1561264c576000600060a4632b6e993a6102c0526101c0516102e0526101e05161030052610200516103205260006103405261016051610360526102dc6000737f90122bf0700f9e7e1f688fe926940e8839f3535af11561264c57602061034060246370a082316102c052306102e0526102dc6102a0515afa1561264c57601f3d111561264c57600050610340516101a05260006102a05160e05260c052604060c02060043560e05260c052604060c02054610663576102a0513b1561264c5760006000604463095ea7b36102c0526004356102e0527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610300526102dc60006102a0515af11561264c57600160006102a05160e05260c052604060c02060043560e05260c052604060c020555b5b60206103806084630c3e4b546102a052610180516102c0526101a0516102e05260a4356103005261014051610320526102bc60006004355af11561264c57601f3d111561264c576000506103805160005260206000f35b63ad5cc9188114156106d7573361014052600161016052610740565b63cbc399e58114156107035760016101605260c43560a01c61264c57602060c461014037600050610740565b6341f5055981141561073b5760c43560a01c61264c57602060c46101403760e43560011c61264c57602060e461016037600050610740565b610d1d565b60043560a01c61264c576323b872dd6101e4526004610204808080338152505060208101905080803081525050602081019050808060243581525050606090509050016101e0526101e08051602001806102808284600060045af11561264c5750506020610340610280516102a060006004355af11561264c5760203d808211156107cb57806107cd565b815b90509050610320526103208051602001806101808284600060045af11561264c575050600061018051181561082f57610180806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b610120366101e0376004353b1561264c57600060006064635b36389c610320526024356103405260006103005260443561036052610300516103805261033c60006004355af11561264c576040366103003761034060006002818352015b6020610400602463c661065761038052610340516103a05261039c6004355afa1561264c57601f3d111561264c5760005061040051610360526103605161030061034051600281101561264c576020020152602061040060246370a0823161038052306103a05261039c610360515afa1561264c57601f3d111561264c57600050610400516102c061034051600281101561264c5760200201525b815160010180835281141561088d575b505061034060006003818352015b6044600161034051818183011061264c5780820190509050600481101561264c5760200201356101e061034051600381101561264c5760200201525b8151600101808352811415610946575b5050737f90122bf0700f9e7e1f688fe926940e8839f3533b1561264c576000600060a463fce64736610340526102e051610360526101e05161038052610200516103a052610220516103c052610160516103e05261035c6000737f90122bf0700f9e7e1f688fe926940e8839f3535af11561264c5763a9059cbb610344526004610364808080610140518152505060208101905080806102c0518152505060409050905001610340526103408051602001806103c08284600060045af11561264c57505060206104606103c0516103e06000610300515af11561264c5760203d80821115610a805780610a82565b815b90509050610440526104408051602001806101808284600060045af11561264c5750506000610180511815610ae457610180806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b6102c05161024052606036610340376101605115610b4c5773d586e7f844cea2f87f50152665bcbc2c279d8d706103405273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646103605273c7198437980c041c805a1edcba50c1ce5db9511861038052610b98565b7347afa96cdc9fab46904a55a6ad4bf6660b53c38a610340527346a51127c3ce23fb7ab1de06226147f446e4a8576103605273532e6537fea298397212f09a61e03311686f548e610380525b6103a060016003818352015b6103406103a051600180821061264c5780820390509050600381101561264c5760200201516103c052602061046060246370a082316103e05230610400526103fc6103c0515afa1561264c57601f3d111561264c57600050610460516102406103a051600481101561264c57602002015263a9059cbb6103e4526004610404808080610140518152505060208101905080806102406103a051600481101561264c57602002015181525050604090509050016103e0526103e08051602001806104608284600060045af11561264c57505060206105006104605161048060006103c0515af11561264c5760203d80821115610c9f5780610ca1565b815b905090506104e0526104e08051602001806101808284600060045af11561264c5750506000610180511815610d0357610180806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b5b8151600101808352811415610ba4575b50506080610240f35b6329ed2862811415610d39573361014052600161016052610da2565b631e700cbb811415610d655760016101605260843560a01c61264c576020608461014037600050610da2565b633ff1bd66811415610d9d5760843560a01c61264c57602060846101403760a43560011c61264c57602060a461016037600050610da2565b6111c9565b60043560a01c61264c5760443580607f1d8160801d141561264c57809050506323b872dd6101e4526004610204808080338152505060208101905080803081525050602081019050808060243581525050606090509050016101e0526101e08051602001806102808284600060045af11561264c5750506020610340610280516102a060006004355af11561264c5760203d80821115610e425780610e44565b815b90509050610320526103208051602001806101808284600060045af11561264c5750506000610180511815610ea657610180806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b60006101e052604435610efb5760206102e0608463081579a5610200526060602461022037610140516102805261021c60006004355af11561264c57601f3d111561264c576000506102e0516101e0526111bc565b606036610200376101605115610f5b5773d586e7f844cea2f87f50152665bcbc2c279d8d706102005273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646102205273c7198437980c041c805a1edcba50c1ce5db9511861024052610fa7565b7347afa96cdc9fab46904a55a6ad4bf6660b53c38a610200527346a51127c3ce23fb7ab1de06226147f446e4a8576102205273532e6537fea298397212f09a61e03311686f548e610240525b610200604435600180820380607f1d8160801d141561264c5780905090509050600381101561264c576020020151610260526020610360608463081579a5610280526024356102a05260016102c05260006102e052306103005261029c60006004355af11561264c57601f3d111561264c57600050610360516101e052737f90122bf0700f9e7e1f688fe926940e8839f3533b1561264c5760006000608463517a55a3610280526101e0516102a052604435600180820380607f1d8160801d141561264c57809050905090506102c0526064356102e052610160516103005261029c6000737f90122bf0700f9e7e1f688fe926940e8839f3535af11561264c57602061030060246370a0823161028052306102a05261029c610260515afa1561264c57601f3d111561264c57600050610300516101e05263a9059cbb6102845260046102a4808080610140518152505060208101905080806101e0518152505060409050905001610280526102808051602001806103008284600060045af11561264c57505060206103a0610300516103206000610260515af11561264c5760203d808211156111575780611159565b815b90509050610380526103808051602001806101808284600060045af11561264c57505060006101805118156111bb57610180806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b5b6101e05160005260206000f35b63ac24f7718114156111e557336101405260016101605261124e565b634329c8cc8114156112115760016101605260c43560a01c61264c57602060c46101403760005061124e565b63a7b43c398114156112495760c43560a01c61264c57602060c46101403760e43560011c61264c57602060e46101603760005061124e565b611b91565b60043560a01c61264c576020610200600463ddca3f436101a0526101bc737f90122bf0700f9e7e1f688fe926940e8839f3535afa1561264c57601f3d111561264c5760005061020051600380820282158284830414171561264c5780905090509050600880820490509050610180526101808051610180516402540be40080820282158284830414171561264c57809050905090506402540be40080820490509050818183011061264c57808201905090508152506323b872dd610204526004610224808080338152505060208101905080803081525050602081019050808060a4358152505060609050905001610200526102008051602001806102a08284600060045af11561264c57505060206103606102a0516102c060006004355af11561264c5760203d808211156113845780611386565b815b90509050610340526103408051602001806101a08284600060045af11561264c57505060006101a05118156113e8576101a0806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b60c036610200376102c060006003818352015b602460016102c051818183011061264c5780820190509050600481101561264c5760200201356102e05260006102e0511815611451576102e0516102206102c051600381101561264c5760200201526001610200525b5b81516001018083528114156113fb575b505060243561028052610200511561152c5760206103a06084633883e1196102c052610220516102e052610240516103005261026051610320526000610340526102dc737f90122bf0700f9e7e1f688fe926940e8839f3535afa1561264c57601f3d111561264c576000506103a0516102a0526102a080516102a0516101805180820282158284830414171561264c57809050905090506402540be400808204905090506001818183011061264c5780820190509050818183011061264c57808201905090508152505b60206103a0606463e31032736102e05261028051610300526102a0516103205260a435610340526102fc60006004355af11561264c57601f3d111561264c576000506103a0516102c05263a9059cbb6102e45260046103048080803381525050602081019050808060a4356102c05180821061264c578082039050905081525050604090509050016102e0526102e08051602001806103608284600060045af11561264c57505060206104006103605161038060006004355af11561264c5760203d808211156115fc57806115fe565b815b905090506103e0526103e08051602001806101a08284600060045af11561264c57505060006101a0511815611660576101a0806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b6102005115611a3557737f90122bf0700f9e7e1f688fe926940e8839f3533b1561264c576000600060a4635b8369f56102e0526102205161030052610240516103205261026051610340526102a0516103605261016051610380526102fc6000737f90122bf0700f9e7e1f688fe926940e8839f3535af11561264c57731337bedc9d22ecbe766df105c9623922a27963ec6102e05260206103a060246370a0823161032052306103405261033c6102e0515afa1561264c57601f3d111561264c576000506103a05161030052600061030051111561183b5760006102e05160e05260c052604060c02060043560e05260c052604060c020546117d4576102e0513b1561264c5760006000604463095ea7b361032052600435610340527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103605261033c60006102e0515af11561264c57600160006102e05160e05260c052604060c02060043560e05260c052604060c020555b6102c0805160206104206084630c3e4b54610340526000610320526103205161036052610300516103805260006103a052336103c05261035c60006004355af11561264c57601f3d111561264c576000506104205180821061264c57808203905090508152505b60603661032037610160511561189b5773d586e7f844cea2f87f50152665bcbc2c279d8d706103205273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646103405273c7198437980c041c805a1edcba50c1ce5db95118610360526118e7565b7347afa96cdc9fab46904a55a6ad4bf6660b53c38a610320527346a51127c3ce23fb7ab1de06226147f446e4a8576103405273532e6537fea298397212f09a61e03311686f548e610360525b61038060006003818352015b63a9059cbb61044452600461046480808061014051815250506020810190508080602061042060246370a082316103a052306103c0526103bc61032061038051600381101561264c5760200201515afa1561264c57601f3d111561264c57600050610420518152505060409050905001610440526104408051602001806104c08284600060045af11561264c57505060206105606104c0516104e0600061032061038051600381101561264c5760200201515af11561264c5760203d808211156119bd57806119bf565b815b90509050610540526105408051602001806101a08284600060045af11561264c57505060006101a0511815611a21576101a0806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b5b81516001018083528114156118f3575b50505b60006024351115611b84576020610380602463c66106576103005260006103205261031c6004355afa1561264c57601f3d111561264c57600050610380516102e05263a9059cbb6103a45260046103c480808061014051815250506020810190508080602061038060246370a0823161030052306103205261031c6102e0515afa1561264c57601f3d111561264c576000506103805181525050604090509050016103a0526103a08051602001806104208284600060045af11561264c57505060206104c06104205161044060006102e0515af11561264c5760203d80821115611b1f5780611b21565b815b905090506104a0526104a08051602001806101a08284600060045af11561264c57505060006101a0511815611b83576101a0806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b5b6102c05160005260206000f35b6341b028f3811415611cba5760043560a01c61264c5760443580607f1d8160801d141561264c578090505060016044351215611c095760206101e0604463cc2b27d761014052604060246101603761015c6004355afa1561264c57601f3d111561264c576000506101e05160005260206000f3611cb8565b6020610200604463cc2b27d7610160526024356101805260016101a05261017c6004355afa1561264c57601f3d111561264c5760005061020051610140526020610200604463cc2b27d7610160526101405161018052604435600180820380607f1d8160801d141561264c57809050905090506101a05261017c737f90122bf0700f9e7e1f688fe926940e8839f3535afa1561264c57601f3d111561264c576000506102005160005260206000f35b005b63861cdef0811415611df95760043560a01c61264c5760a43560011c61264c5760a03661014037602435610140526101e060006003818352015b60246101e0516001818183011061264c5780820190509050600481101561264c5760200201356101806101e051600381101561264c5760200201525b8151600101808352811415611cf4575b505060206102e06084633883e1196102005261018051610220526101a051610240526101c0516102605260a4356102805261021c737f90122bf0700f9e7e1f688fe926940e8839f3535afa1561264c57601f3d111561264c576000506102e0516101e0526101e0516101605260206102c0606463ed8e84f3610200526101405161022052610160516102405260a4356102605261021c6004355afa1561264c57601f3d111561264c576000506102c05160005260206000f35b637981c43e811415611e15573361014052600161016052611e7e565b63a3220db8811415611e415760016101605260a43560a01c61264c57602060a461014037600050611e7e565b63e0286ab2811415611e795760a43560a01c61264c57602060a46101403760c43560011c61264c57602060c461016037600050611e7e565b612644565b60043560a01c61264c5760243580607f1d8160801d141561264c578090505060443580607f1d8160801d141561264c57809050507347afa96cdc9fab46904a55a6ad4bf6660b53c38a610180527346a51127c3ce23fb7ab1de06226147f446e4a8576101a05273532e6537fea298397212f09a61e03311686f548e6101c05273d586e7f844cea2f87f50152665bcbc2c279d8d706101e05273a7d7079b0fead91f3e65f86e8915cb59c1a4c6646102005273c7198437980c041c805a1edcba50c1ce5db95118610220526040366102403760243561202e576020610300602463c66106576102805260006102a05261029c6004355afa1561264c57601f3d111561264c57600050610300516102405260006102405160e05260c052604060c02060043560e05260c052604060c0205461202957610240513b1561264c5760006000604463095ea7b3610280526004356102a0527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6102c05261029c6000610240515af11561264c57600160006102405160e05260c052604060c02060043560e05260c052604060c020555b61214b565b602435600180820380607f1d8160801d141561264c57809050905090506102805261018061028051600381101561264c5760200201516102a05261016051156120a5576101e061028051600381101561264c5760200201516102c0526102c0516102a0511415610260526102c051610240526120ae565b6102a051610240525b60006102a05160e05260c052604060c02060043560e05260c052604060c0205461214a576102a0513b1561264c5760006000604463095ea7b36102c0526004356102e0527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610300526102dc60006102a0515af11561264c57600160006102a05160e05260c052604060c02060043560e05260c052604060c020555b5b6323b872dd6102e4526004610304808080338152505060208101905080803081525050602081019050808060643581525050606090509050016102e0526102e08051602001806103808284600060045af11561264c5750506020610440610380516103a06000610240515af11561264c5760203d808211156121cd57806121cf565b815b90509050610420526104208051602001806102808284600060045af11561264c575050600061028051181561223157610280806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b610160516122815760206103e060a46344ee19866102e052608060246103003761014051610380526102fc60006004355af11561264c57601f3d111561264c576000506103e05160005260206000f35b61026051156123ef5760006102405160e05260c052604060c020734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c60e05260c052604060c0205461235c57610240513b1561264c5760006000604463095ea7b36102e052734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c610300527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610320526102fc6000610240515af11561264c57600160006102405160e05260c052604060c020734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c60e05260c052604060c020555b63e8eda9df6102e45260046103048080806102405181525050602081019050808060643581525050602081019050808030815250506020810190508080600081525050608090509050016102e0526102e08051602001806103a08284600060045af11561264c575050600060006103a0516103c06000734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c5af11561264c575b602061040060a46344ee1986610300526080602461032037306103a05261031c60006004355af11561264c57601f3d111561264c57600050610400516102e05260006103005260443561247e5760206103a0602463c66106576103205260006103405261033c6004355afa1561264c57601f3d111561264c576000506103a051610300526000610260526124e8565b604435600180820380607f1d8160801d141561264c57809050905090506103205261018061032051600381101561264c576020020151610340526101e061032051600381101561264c57602002015161036052610360516103405114156102605261036051610300525b610260511561255957734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c3b1561264c576000600060646369328dec6103205261030051610340526102e05161036052610140516103805261033c6000734f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c5af11561264c57612637565b63a9059cbb610324526004610344808080610140518152505060208101905080806102e0518152505060409050905001610320526103208051602001806103a08284600060045af11561264c57505060206104406103a0516103c06000610300515af11561264c5760203d808211156125d257806125d4565b815b90509050610420526104208051602001806102808284600060045af11561264c575050600061028051181561263657610280806020015160008251806020901361264c578091901261264c57806020036101000a82049050905090501561264c575b5b6102e05160005260206000f35b505b60006000fd5b600080fd5b6101c6612817036101c66000396101c6612817036000f35b600080fd
| 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.