Address Contract Partially Verified
Address
0x0959158b6040D32d04c301A72CBFD6b39E21c9AE
Balance
0 ETH
Nonce
114
Code Size
6444 bytes
Creator
0x7EeAC6CD...289a at tx 0x9a0ed31d...8df8d2
Indexed Transactions
0
Contract Bytecode
6444 bytes
0x341561000a57600080fd5b600436101561001857611926565b600035601c526f7fffffffffffffffffffffffffffffff60405263a87df06c600051141561004b57600061014052610071565b636982eb0b6000511415610069576020604461014037600050610071565b6000156100d7575b60043560a01c1561008157600080fd5b60243560a01c1561009157600080fd5b60243560043518610160526101405164010000000081106100b157600080fd5b60086101605160e05260c052604060c02060c052602060c020015460005260206000f350005b63940494f160005114156101725760043560a01c156100f557600080fd5b600460043560e05260c052604060c02060c052602060c02054610140526101608080806002815250506020810190508080600460076101405160e05260c052604060c02060c052602060c0200154600181818301101561015457600080fd5b808201905090508152505060409050905060c05260c051610160f350005b639ac90d3d60005114156101d45760043560a01c1561019057600080fd5b6001600460043560e05260c052604060c02060c052602060c020018060c052602060c020546101605260018160c052602060c020015461018052506040610160f350005b63a77576ef60005114156103005760043560a01c156101f257600080fd5b61010036610140376001600460043560e05260c052604060c02060c052602060c0200160c052602060c0205461014052600460043560e05260c052604060c02060c052602060c020546102405261026060016007818352015b6102605160018082038080600081121561026157195b607f1c1561026e57600080fd5b9050905090506008811061028157600080fd5b600260076102405160e05260c052604060c02060c052602060c0200160c052602060c020015461014061026051600881106102bb57600080fd5b602002015261014061026051600881106102d457600080fd5b602002015115156102e4576102f5565b5b815160010180835281141561024b575b5050610100610140f3005b6352b5155560005114156103525760043560a01c1561031e57600080fd5b6000610140526012610160526002600460043560e05260c052604060c02060c052602060c0200154610140526040610140f3005b634cb088f160005114156104c55760043560a01c1561037057600080fd5b61010036610140376002600460043560e05260c052604060c02060c052602060c020015461014052600460043560e05260c052604060c02060c052602060c0205461024052600360076102405160e05260c052604060c02060c052602060c02001546102605261028060006008818352015b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8610280518082028080600081121561041757195b607f1c1561042457600080fd5b90509050905060008112156104415761026051816000031c610448565b61026051811b5b9050610100808206905090506102a0526102a0511515610467576104ba565b6102a0516101406102805160018082018080600081121561048457195b607f1c1561049157600080fd5b905090509050600881106104a457600080fd5b60200201525b81516001018083528114156103e2575b5050610100610140f3005b63ce99e45a600051141561054d5760043560a01c156104e357600080fd5b670de0b6b3a76400006101405260006101605260206101e0600463bb7b8b806101805261019c600460043560e05260c052604060c02060c052602060c020545afa61052d57600080fd5b601f3d1161053a57600080fd5b6000506101e051610160526040610140f3005b6392e3cc2d60005114156105f25760043560a01c1561056b57600080fd5b60206101c06024634903b0d16101405260006101605261015c6004355afa61059257600080fd5b601f3d1161059f57600080fd5b6000506101c0516102a05260206102606024634903b0d16101e0526001610200526101fc6004355afa6105d157600080fd5b601f3d116105de57600080fd5b600050610260516102c05260406102a0f350005b6359f4f351600051141561085e5760043560a01c1561061057600080fd5b610100366101403760206102c06024634903b0d16102405260006102605261025c6004355afa61063f57600080fd5b601f3d1161064c57600080fd5b6000506102c0516101405260206102c060046318160ddd6102605261027c60016001600460043560e05260c052604060c02060c052602060c0200160c052602060c02001545afa61069c57600080fd5b601f3d116106a957600080fd5b6000506102c0516102405260006102405111156108555760206103006024634903b0d16102805260016102a05261029c6004355afa6106e757600080fd5b601f3d116106f457600080fd5b600050610300516ec097ce7bc90715b34b9f1000000000808202821582848304141761071f57600080fd5b8090509050905061024051808061073557600080fd5b82049050905061026052600460043560e05260c052604060c02060c052602060c0205461028052600460076102805160e05260c052604060c02060c052602060c02001546102a0526102c060006008818352015b6102a0516102c051141561079c57610852565b60206103606024634903b0d16102e0526102c051610300526102fc610280515afa6107c657600080fd5b601f3d116107d357600080fd5b600050610360516102605180820282158284830414176107f257600080fd5b809050905090506ec097ce7bc90715b34b9f1000000000808204905090506101406102c051600181818301101561082857600080fd5b808201905090506008811061083c57600080fd5b60200201525b8151600101808352811415610789575b50505b610100610140f3005b6355b30b1960005114156108bc5760043560a01c1561087c57600080fd5b60206101a0600463f446c1d06101405261015c6004355afa61089d57600080fd5b601f3d116108aa57600080fd5b6000506101a05160005260206000f350005b637cdb72b0600051141561097d5760043560a01c156108da57600080fd5b60206101a0600463ddca3f436101405261015c6004355afa6108fb57600080fd5b601f3d1161090857600080fd5b6000506101a0516101c0526020610240600463fee3f7f96101e0526101fc6004355afa61093457600080fd5b601f3d1161094157600080fd5b60005061024051610260526102808080806101c051815250506020810190508080610260518152505060409050905060c05260c051610280f350005b63c11e45b86000511415610a225760043560a01c1561099b57600080fd5b60206101c0602463e2e7d2646101405260006101605261015c6004355afa6109c257600080fd5b601f3d116109cf57600080fd5b6000506101c0516102a0526020610260602463e2e7d2646101e0526001610200526101fc6004355afa610a0157600080fd5b601f3d11610a0e57600080fd5b600050610260516102c05260406102a0f350005b63eb85226d6000511415610d545760043560a01c15610a4057600080fd5b60243560a01c15610a5057600080fd5b60443560a01c15610a6057600080fd5b6001600460043560e05260c052604060c02060c052602060c0200160c052602060c0205461014052602435610180526044356101a05260006101605261016061012060006002818352015b610120516020026101800151610140511415610aca5760018352610adb565b5b8151600101808352811415610aab575b5050506101605115610bc85760016001600460043560e05260c052604060c02060c052602060c0200160c052602060c02001546101c052602435610200526044356102205260006101e0526101e061012060006002818352015b6101205160200261020001516101c0511415610b545760018352610b65565b5b8151600101808352811415610b35575b5050506101e05115610bc757610140516044351461024052610140516024351461026052610280808080610240518152505060208101905080806102605181525050602081019050808060008152505060609050905060c05260c051610280f3505b5b600460043560e05260c052604060c02060c052602060c0205461016052606036610180376101e060006008818352015b60006101e0511815610c65576101e051600180820380806000811215610c1a57195b607f1c15610c2757600080fd5b90509050905060088110610c3a57600080fd5b600260076101605160e05260c052604060c02060c052602060c0200160c052602060c0200154610140525b610140511515610cb4576308c379a06102e0526020610300526013610320527f4e6f20617661696c61626c65206d61726b657400000000000000000000000000610340526103205060646102fcfd5b602435610140511415610cce576101e0516101a052610cee565b604435610140511415610ce8576101e0516101c052610ced565b610d03565b5b6101805115610cfc57610d13565b6001610180525b8151600101808352811415610bf8575b50506102e08080806101a0518152505060208101905080806101c05181525050602081019050808060018152505060609050905060c05260c0516102e0f350005b63640ada5060005114156111845760043560a01c15610d7257600080fd5b60243560a01c15610d8257600080fd5b60443560a01c15610d9257600080fd5b6000543314610da057600080fd5b6002600760043560e05260c052604060c02060c052602060c0200160c052602060c0205415610dce57600080fd5b60206101c0600463a262904b6101605261017c6f22d53366457f9d5e68ec105046fc43835afa610dfd57600080fd5b601f3d11610e0a57600080fd5b6000506101c051610140526020610200602463940494f1610180526004356101a05261019c610140515afa610e3e57600080fd5b601f3d11610e4b57600080fd5b600050610200516101605260065461018052600435610180516401000000008110610e7557600080fd5b600560c052602060c0200155610180516001818183011015610e9657600080fd5b80820190509050600655602435600760043560e05260c052604060c02060c052602060c020556020610220602463379510496101a0526004356101c0526101bc610140515afa610ee557600080fd5b601f3d11610ef257600080fd5b600050610220516001600760043560e05260c052604060c02060c052602060c0200155610160516004600760043560e05260c052604060c02060c052602060c020015560006101a0526101006103406024639ac90d3d6102c0526004356102e0526102dc610140515afa610f6557600080fd5b60ff3d11610f7257600080fd5b60005061034080516101c05280602001516101e0528060400151610200528060600151610220528060800151610240528060a00151610260528060c00151610280528060e001516102a052506102c060006008818352015b610160516102c0511415610fdd57611117565b6101c06102c05160088110610ff157600080fd5b60200201516102e0526102e0516102c0516008811061100f57600080fd5b6002600760043560e05260c052604060c02060c052602060c0200160c052602060c02001556101a080516102c0516008808202821582848304141761105357600080fd5b8090509050905060405181111561106957600080fd5b60008112156110b2576020610360600463313ce5676103005261031c6102e0515afa61109457600080fd5b601f3d116110a157600080fd5b60005061036051816000031c6110eb565b6020610360600463313ce5676103005261031c6102e0515afa6110d457600080fd5b601f3d116110e157600080fd5b60005061036051811b5b90508181830110156110fc57600080fd5b808201905090508152505b8151600101808352811415610fca575b50506101a0516003600760043560e05260c052604060c02060c052602060c0200155604435600a60043560e05260c052604060c020556004356102c0526024356102e0527fd1951e19788b24c3c75b3c6c19a795cd312b1523d09076fc41e432cd3ccdc14c60406102c0a1005b63e339eb4f60005114156116415760043560a01c156111a257600080fd5b60406024356004016101403760206024356004013511156111c257600080fd5b602a6044356004016101a037600a6044356004013511156111e257600080fd5b60643560a01c156111f257600080fd5b600760043560e05260c052604060c02060c052602060c02054610200526000610200511861121f57600080fd5b60206102a0600463313ce5676102405261025c6064355afa61124057600080fd5b601f3d1161124d57600080fd5b6000506102a051610220527f6033600c60003960336000f33660006000376110006000366000730000000000610260526c01000000000000000000000000610200510261027b527f5af4602c57600080fd5b6110006000f30000000000000000000000000000000061028f5260606102606000f0806112cb57600080fd5b61024052610240513b6112dd57600080fd5b6000600061016460e063d178231c6102605280610280526101408080516020018084610280018284600060045af161131457600080fd5b50508051820160206001820306601f8201039050602001915050806102a0526101a08080516020018084610280018284600060045af161135357600080fd5b5050506064356102c052610220516102e0526084356103005260a435610320526000546103405261027c90506000610240515af161139057600080fd5b6064353b61139d57600080fd5b60006000604463095ea7b36102605261024051610280527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6102a05261027c60006064355af16113ec57600080fd5b600354610260526102405161026051640100000000811061140c57600080fd5b600260c052602060c020015561026051600181818301101561142d57600080fd5b808201905090506003556001600760043560e05260c052604060c02060c052602060c02001546102805261022051600260046102405160e05260c052604060c02060c052602060c020015560043560046102405160e05260c052604060c02060c052602060c02055600160046102405160e05260c052604060c02060c052602060c0200160c052602060c02060643581556001600760043560e05260c052604060c02060c052602060c020015460018201555060006102a0526102c060006008818352015b6102c0516008811061150357600080fd5b6002600760043560e05260c052604060c02060c052602060c0200160c052602060c02001546102e0526102e05115156115455760016102a052610280516102e0525b6102e051606435186103005260096103005160e05260c052604060c02054610260526102405161026051640100000000811061158057600080fd5b60086103005160e05260c052604060c02060c052602060c02001556102605160018181830110156115b057600080fd5b8082019050905060096103005160e05260c052604060c020556102a051156115d7576115e8565b5b81516001018083528114156114f2575b50506064356102c0526004356102e0526084356103005260a4356103205233610340527f01f31cd2abdeb4e5e10ba500f2db0f937d9e8c735ab04681925441b4ea37eda560a06102c0a16102405160005260206000f350005b636b441a4060005114156116755760043560a01c1561165f57600080fd5b600054331461166d57600080fd5b600435600155005b63e5ea47b860005114156116a7576001546101405261014051331461169957600080fd5b610140516000556000600155005b6336d2b77a60005114156116f95760043560a01c156116c557600080fd5b60243560a01c156116d557600080fd5b60005433146116e357600080fd5b602435600a60043560e05260c052604060c02055005b63dc125577600051141561180957600160043360e05260c052604060c02060c052602060c0200160c052602060c02054610140526000610140511861173d57600080fd5b602061020060246370a0823161018052306101a05261019c610140515afa61176457600080fd5b601f3d1161177157600080fd5b6000506102005161016052600a60043360e05260c052604060c02060c052602060c0205460e05260c052604060c020546101805260206102a060a463ddc1f59d6101a05260006101c05260016101e052610160516102005260006102205261018051610240526101bc6000335af16117e857600080fd5b601f3d116117f557600080fd5b6000506102a050600160005260206000f350005b63f851a44060005114156118255760005460005260206000f350005b6317f7182a60005114156118415760015460005260206000f350005b633a1d5d8e600051141561187a57600435640100000000811061186357600080fd5b600260c052602060c020015460005260206000f350005b63956aae3a60005114156118965760035460005260206000f350005b6322fe567160005114156118cf5760043564010000000081106118b857600080fd5b600560c052602060c020015460005260206000f350005b63de5e4a3b60005114156118eb5760065460005260206000f350005b6372b38d9860005114156119255760043560a01c1561190957600080fd5b600a60043560e05260c052604060c0205460005260206000f350005b5b60006000fd
Verified Source Code Partial Match
Compiler: v0.2.8+commit.069936f
Vyper_contract.vy 469 lines
# @version 0.2.8
"""
@title Curve Factory
@license MIT
@author Curve.Fi
@notice Permissionless pool deployer and registry
"""
struct PoolArray:
base_pool: address
coins: address[2]
decimals: uint256
struct BasePoolArray:
implementation: address
lp_token: address
coins: address[MAX_COINS]
decimals: uint256
n_coins: uint256
interface AddressProvider:
def admin() -> address: view
def get_registry() -> address: view
interface Registry:
def get_lp_token(pool: address) -> address: view
def get_n_coins(pool: address) -> uint256: view
def get_coins(pool: address) -> address[MAX_COINS]: view
interface ERC20:
def balanceOf(_addr: address) -> uint256: view
def decimals() -> uint256: view
def totalSupply() -> uint256: view
def approve(_spender: address, _amount: uint256): nonpayable
interface CurvePool:
def A() -> uint256: view
def fee() -> uint256: view
def admin_fee() -> uint256: view
def balances(i: uint256) -> uint256: view
def admin_balances(i: uint256) -> uint256: view
def get_virtual_price() -> uint256: view
def initialize(
_name: String[32],
_symbol: String[10],
_coin: address,
_decimals: uint256,
_A: uint256,
_fee: uint256,
_owner: address,
): nonpayable
def exchange(
i: int128,
j: int128,
dx: uint256,
min_dy: uint256,
_receiver: address,
) -> uint256: nonpayable
event BasePoolAdded:
base_pool: address
implementat: address
event MetaPoolDeployed:
coin: address
base_pool: address
A: uint256
fee: uint256
deployer: address
MAX_COINS: constant(int128) = 8
ADDRESS_PROVIDER: constant(address) = 0x0000000022D53366457F9d5E68Ec105046FC4383
admin: public(address)
future_admin: public(address)
pool_list: public(address[4294967296]) # master list of pools
pool_count: public(uint256) # actual length of pool_list
pool_data: HashMap[address, PoolArray]
base_pool_list: public(address[4294967296]) # master list of pools
base_pool_count: public(uint256) # actual length of pool_list
base_pool_data: HashMap[address, BasePoolArray]
# mapping of coins -> pools for trading
# a mapping key is generated for each pair of addresses via
# `bitwise_xor(convert(a, uint256), convert(b, uint256))`
markets: HashMap[uint256, address[4294967296]]
market_counts: HashMap[uint256, uint256]
# base pool -> address to transfer admin fees to
fee_receiver: public(HashMap[address, address])
@external
def __init__():
self.admin = msg.sender
@view
@external
def find_pool_for_coins(_from: address, _to: address, i: uint256 = 0) -> address:
"""
@notice Find an available pool for exchanging two coins
@param _from Address of coin to be sent
@param _to Address of coin to be received
@param i Index value. When multiple pools are available
this value is used to return the n'th address.
@return Pool address
"""
key: uint256 = bitwise_xor(convert(_from, uint256), convert(_to, uint256))
return self.markets[key][i]
@view
@external
def get_n_coins(_pool: address) -> (uint256, uint256):
"""
@notice Get the number of coins in a pool
@param _pool Pool address
@return Number of wrapped coins, number of underlying coins
"""
base_pool: address = self.pool_data[_pool].base_pool
return 2, self.base_pool_data[base_pool].n_coins + 1
@view
@external
def get_coins(_pool: address) -> address[2]:
"""
@notice Get the coins within a pool
@param _pool Pool address
@return List of coin addresses
"""
return self.pool_data[_pool].coins
@view
@external
def get_underlying_coins(_pool: address) -> address[MAX_COINS]:
"""
@notice Get the underlying coins within a pool
@param _pool Pool address
@return List of coin addresses
"""
coins: address[MAX_COINS] = empty(address[MAX_COINS])
coins[0] = self.pool_data[_pool].coins[0]
base_pool: address = self.pool_data[_pool].base_pool
for i in range(1, MAX_COINS):
coins[i] = self.base_pool_data[base_pool].coins[i - 1]
if coins[i] == ZERO_ADDRESS:
break
return coins
@view
@external
def get_decimals(_pool: address) -> uint256[2]:
"""
@notice Get decimal places for each coin within a pool
@param _pool Pool address
@return uint256 list of decimals
"""
decimals: uint256[2] = [0, 18]
decimals[0] = self.pool_data[_pool].decimals
return decimals
@view
@external
def get_underlying_decimals(_pool: address) -> uint256[MAX_COINS]:
"""
@notice Get decimal places for each underlying coin within a pool
@param _pool Pool address
@return uint256 list of decimals
"""
# decimals are tightly packed as a series of uint8 within a little-endian bytes32
# the packed value is stored as uint256 to simplify unpacking via shift and modulo
decimals: uint256[MAX_COINS] = empty(uint256[MAX_COINS])
decimals[0] = self.pool_data[_pool].decimals
base_pool: address = self.pool_data[_pool].base_pool
packed_decimals: uint256 = self.base_pool_data[base_pool].decimals
for i in range(MAX_COINS):
unpacked: uint256 = shift(packed_decimals, -8 * i) % 256
if unpacked == 0:
break
decimals[i+1] = unpacked
return decimals
@view
@external
def get_rates(_pool: address) -> uint256[2]:
"""
@notice Get rates for coins within a pool
@param _pool Pool address
@return Rates for each coin, precision normalized to 10**18
"""
rates: uint256[2] = [10**18, 0]
rates[1] = CurvePool(self.pool_data[_pool].base_pool).get_virtual_price()
return rates
@view
@external
def get_balances(_pool: address) -> uint256[2]:
"""
@notice Get balances for each coin within a pool
@dev For pools using lending, these are the wrapped coin balances
@param _pool Pool address
@return uint256 list of balances
"""
return [CurvePool(_pool).balances(0), CurvePool(_pool).balances(1)]
@view
@external
def get_underlying_balances(_pool: address) -> uint256[MAX_COINS]:
"""
@notice Get balances for each underlying coin within a pool
@param _pool Pool address
@return uint256 list of underlying balances
"""
underlying_balances: uint256[MAX_COINS] = empty(uint256[MAX_COINS])
underlying_balances[0] = CurvePool(_pool).balances(0)
base_total_supply: uint256 = ERC20(self.pool_data[_pool].coins[1]).totalSupply()
if base_total_supply > 0:
underlying_pct: uint256 = CurvePool(_pool).balances(1) * 10**36 / base_total_supply
base_pool: address = self.pool_data[_pool].base_pool
n_coins: uint256 = self.base_pool_data[base_pool].n_coins
for i in range(MAX_COINS):
if i == n_coins:
break
underlying_balances[i + 1] = CurvePool(base_pool).balances(i) * underlying_pct / 10**36
return underlying_balances
@view
@external
def get_A(_pool: address) -> uint256:
"""
@notice Get the amplfication co-efficient for a pool
@param _pool Pool address
@return uint256 A
"""
return CurvePool(_pool).A()
@view
@external
def get_fees(_pool: address) -> (uint256, uint256):
"""
@notice Get the fees for a pool
@dev Fees are expressed as integers
@return Pool fee as uint256 with 1e10 precision
"""
return CurvePool(_pool).fee(), CurvePool(_pool).admin_fee()
@view
@external
def get_admin_balances(_pool: address) -> uint256[2]:
"""
@notice Get the current admin balances (uncollected fees) for a pool
@param _pool Pool address
@return List of uint256 admin balances
"""
return [CurvePool(_pool).admin_balances(0), CurvePool(_pool).admin_balances(1)]
@view
@external
def get_coin_indices(
_pool: address,
_from: address,
_to: address
) -> (int128, int128, bool):
"""
@notice Convert coin addresses to indices for use with pool methods
@param _from Coin address to be used as `i` within a pool
@param _to Coin address to be used as `j` within a pool
@return int128 `i`, int128 `j`, boolean indicating if `i` and `j` are underlying coins
"""
coin: address = self.pool_data[_pool].coins[0]
if coin in [_from, _to]:
base_lp_token: address = self.pool_data[_pool].coins[1]
if base_lp_token in [_from, _to]:
# True and False convert to 1 and 0 - a bit of voodoo that
# works because we only ever have 2 non-underlying coins
return convert(_to == coin, int128), convert(_from == coin, int128), False
base_pool: address = self.pool_data[_pool].base_pool
found_market: bool = False
i: int128 = 0
j: int128 = 0
for x in range(MAX_COINS):
if x != 0:
coin = self.base_pool_data[base_pool].coins[x-1]
if coin == ZERO_ADDRESS:
raise "No available market"
if coin == _from:
i = x
elif coin == _to:
j = x
else:
continue
if found_market:
# the second time we find a match, break out of the loop
break
# the first time we find a match, set `found_market` to True
found_market = True
return i, j, True
@external
def add_base_pool(
_base_pool: address,
_metapool_implementation: address,
_fee_receiver: address,
):
"""
@notice Add a pool to the registry
@dev Only callable by admin
@param _base_pool Pool address to add
@param _metapool_implementation Implementation address to use when deploying metapools
@param _fee_receiver Admin fee receiver address for metapools using this base pool
"""
assert msg.sender == self.admin # dev: admin-only function
assert self.base_pool_data[_base_pool].coins[0] == ZERO_ADDRESS # dev: pool exists
registry: address = AddressProvider(ADDRESS_PROVIDER).get_registry()
n_coins: uint256 = Registry(registry).get_n_coins(_base_pool)
# add pool to pool_list
length: uint256 = self.base_pool_count
self.base_pool_list[length] = _base_pool
self.base_pool_count = length + 1
self.base_pool_data[_base_pool].implementation = _metapool_implementation
self.base_pool_data[_base_pool].lp_token = Registry(registry).get_lp_token(_base_pool)
self.base_pool_data[_base_pool].n_coins = n_coins
decimals: uint256 = 0
coins: address[MAX_COINS] = Registry(registry).get_coins(_base_pool)
for i in range(MAX_COINS):
if i == n_coins:
break
coin: address = coins[i]
self.base_pool_data[_base_pool].coins[i] = coin
decimals += shift(ERC20(coin).decimals(), convert(i*8, int128))
self.base_pool_data[_base_pool].decimals = decimals
self.fee_receiver[_base_pool] = _fee_receiver
log BasePoolAdded(_base_pool, _metapool_implementation)
@external
def deploy_metapool(
_base_pool: address,
_name: String[32],
_symbol: String[10],
_coin: address,
_A: uint256,
_fee: uint256,
) -> address:
"""
@notice Deploy a new metapool
@param _base_pool Address of the base pool to use
within the metapool
@param _name Name of the new metapool
@param _symbol Symbol for the new metapool - will be
concatenated with the base pool symbol
@param _coin Address of the coin being used in the metapool
@param _A Amplification co-efficient - a higher value here means
less tolerance for imbalance within the pool's assets.
Suggested values include:
* Uncollateralized algorithmic stablecoins: 5-10
* Non-redeemable, collateralized assets: 100
* Redeemable assets: 200-400
@param _fee Trade fee, given as an integer with 1e10 precision. The
minimum fee is 0.04% (4000000), the maximum is 1% (100000000).
50% of the fee is distributed to veCRV holders.
@return Address of the deployed pool
"""
implementation: address = self.base_pool_data[_base_pool].implementation
assert implementation != ZERO_ADDRESS
decimals: uint256 = ERC20(_coin).decimals()
pool: address = create_forwarder_to(implementation)
CurvePool(pool).initialize(_name, _symbol, _coin, decimals, _A, _fee, self.admin)
ERC20(_coin).approve(pool, MAX_UINT256)
# add pool to pool_list
length: uint256 = self.pool_count
self.pool_list[length] = pool
self.pool_count = length + 1
base_lp_token: address = self.base_pool_data[_base_pool].lp_token
self.pool_data[pool].decimals = decimals
self.pool_data[pool].base_pool = _base_pool
self.pool_data[pool].coins = [_coin, self.base_pool_data[_base_pool].lp_token]
is_finished: bool = False
for i in range(MAX_COINS):
swappable_coin: address = self.base_pool_data[_base_pool].coins[i]
if swappable_coin == ZERO_ADDRESS:
is_finished = True
swappable_coin = base_lp_token
key: uint256 = bitwise_xor(convert(_coin, uint256), convert(swappable_coin, uint256))
length = self.market_counts[key]
self.markets[key][length] = pool
self.market_counts[key] = length + 1
if is_finished:
break
log MetaPoolDeployed(_coin, _base_pool, _A, _fee, msg.sender)
return pool
@external
def commit_transfer_ownership(addr: address):
"""
@notice Transfer ownership of this contract to `addr`
@param addr Address of the new owner
"""
assert msg.sender == self.admin # dev: admin only
self.future_admin = addr
@external
def accept_transfer_ownership():
"""
@notice Accept a pending ownership transfer
@dev Only callable by the new owner
"""
_admin: address = self.future_admin
assert msg.sender == _admin # dev: future admin only
self.admin = _admin
self.future_admin = ZERO_ADDRESS
@external
def set_fee_receiver(_base_pool: address, _fee_receiver: address):
assert msg.sender == self.admin # dev: admin only
self.fee_receiver[_base_pool] = _fee_receiver
@external
def convert_fees() -> bool:
coin: address = self.pool_data[msg.sender].coins[0]
assert coin != ZERO_ADDRESS # dev: unknown pool
amount: uint256 = ERC20(coin).balanceOf(self)
receiver: address = self.fee_receiver[self.pool_data[msg.sender].base_pool]
CurvePool(msg.sender).exchange(0, 1, amount, 0, receiver)
return True
Read Contract
admin 0xf851a440 → address
base_pool_count 0xde5e4a3b → uint256
base_pool_list 0x22fe5671 → address
fee_receiver 0x72b38d98 → address
find_pool_for_coins 0xa87df06c → address
find_pool_for_coins 0x6982eb0b → address
future_admin 0x17f7182a → address
get_A 0x55b30b19 → uint256
get_admin_balances 0xc11e45b8 → uint256[2]
get_balances 0x92e3cc2d → uint256[2]
get_coin_indices 0xeb85226d → int128, int128, bool
get_coins 0x9ac90d3d → address[2]
get_decimals 0x52b51555 → uint256[2]
get_fees 0x7cdb72b0 → uint256, uint256
get_n_coins 0x940494f1 → uint256, uint256
get_rates 0xce99e45a → uint256[2]
get_underlying_balances 0x59f4f351 → uint256[8]
get_underlying_coins 0xa77576ef → address[8]
get_underlying_decimals 0x4cb088f1 → uint256[8]
pool_count 0x956aae3a → uint256
pool_list 0x3a1d5d8e → address
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
accept_transfer_ownership 0xe5ea47b8
No parameters
add_base_pool 0x640ada50
address _base_pool
address _metapool_implementation
address _fee_receiver
commit_transfer_ownership 0x6b441a40
address addr
convert_fees 0xdc125577
No parameters
returns: bool
deploy_metapool 0xe339eb4f
address _base_pool
string _name
string _symbol
address _coin
uint256 _A
uint256 _fee
returns: address
set_fee_receiver 0x36d2b77a
address _base_pool
address _fee_receiver
Recent Transactions
No transactions found for this address