StableSwap

Composable Stable Trading

class manual_stableswap.StableswapExchange(factory_struct: FactoryData, exchg_struct: StableswapExchangeData)

How Stableswap calls liquidity pools and uses the constant weighted product automated market maker

self.factory_structFactoryData

Factory data

self.exchg_structStableswapExchangeData

Stableswap exchange data

add_liquidity(tkn_amt_in, tkn_in, to)

Add token amounts for LP token

amt_shares_infloat

Amount of pool shares coming in

tkn_inERC20

Input token

tostr

User name/address

burn(liquidity_out, tkn_out_amt, tkn_out, _from)

Burn liquidity from token based on amount of liquidity and amount of token

liquidity_outfloat

Amount of liquidity requested for burn

amt_tkn_outfloat

Amount of token requested for burn

tkn_outERC20

Output token

_fromstr

User name/address

get_amount_out(amt_tkn_in, tkn_in, tkn_out)

Given some amount of an asset, quotes an equivalent amount of the other asset

amt_tkn_infloat

Amount of token requested for quote

tkn_inERC20

Input token

tkn_outERC20

Output token

get_math_pool()

Get underlying StableswapPoolMath object

math_poolStableswapPoolMath

Stableswap math implementation from curveresearch github repos

get_price(base_tkn, opp_tkn, fee=False)

Get price of select token in the exchange pair

base_tknfloat

Base token request for price quote

opp_tknERC20

Denomination token of price quote

get_reserve(token)

Get reserve amount of select token in the pool

tokenERC20

ERC20 token

join_pool(vault: StableswapVault, ampl_coeff: float, to: str)

Initialize a Stableswap pool, and add liquidity for all asset deposit

vaultStableswapERC20Group

Group of ERC20 objects

amt_shares_infloat

Amount of pool shares in

tostr

User name/address

mint(new_liquidity, amt_tkn_in, tkn_in, to)

Update reserve amount for specific token in the pool

new_sharesfloat

Amount of new pool shares requested for minting

amt_tkn_infloat

Input token

tkn_inERC20

Output token

tostr

User name/address

remove_liquidity(liquidity_amt_out, tkn_out, to, use_fee=True)

Remove liquidity from specified token in the pool based on lp amount

tostr

receiving user address

liquidity_amt_outfloat

lp amount to removed

tkn_outERC20

Output token

summary()

Print-out summary on current liquidity pool state

swap(amt_tkn_in, tkn_in, tkn_out, to)

Swap output token given input token

amt_tkn_infloat

Amount of input token requested for swaping

tkn_inERC20

Input token

tkn_outERC20

Output token

tostr

User name/address

class manual_stableswap.StableswapFactory(name: str, address: str)

Create Stableswap liquidity pools for given token sets

self.namestr

Token name

self.addressstr

Address name

deploy(exchg_data: StableswapExchangeData)

Deploy a Stableswap liquidity pool (LP) exchange

exchg_dataStableswapExchangeData

Exchange initialization data

exchangeStableswapExchange

Newly created exchange that is also a LP token

get_exchange(token)

Get exchange from given token

tokenERC20

receiving user address

exchangeStableswapExchange

exchange from mapped token

get_token(exchange)

Get token set from exchange

exchangeStableswapExchange

receiving user address

tokenERC20

token from mapped exchange

Vault

class stableswappy.vault.StableswapVault

Create Stableswap vault for pool token management

self.tknslist

List of ERC20 tokens within vault

self.tkn_dicdictionary

Dictionary of ERC20 tokens within vault referenced by token name

add_token(tkn: ERC20)

Deploy a Stableswap liquidity pool (LP) exchange

tknERC20

ERC20 token

amt2dec(tkn_amt, decimal)

Convert token amount to decimal

tkn_amtfloat

Token amount

decimalint

Decimals

check_tkn(tkn)

Check if ERC20 token is in vault

tknERC20

ERC20 token

containsboolean

Indicator of whether token is contained in vault

get_balances()

Get dictionary of token balances referened by token name

tkn_balancesdict

Dictionary of token balances

get_decimal_amts()

Get dictionary of token amounts in decimal format

decimal_amtsdict

Dictionary of token amounts in decimal format

get_decimals()

Get dictionary of token decimals referenced by token name

norm_wts_dictdict

Dictionary of token decimals

get_dict()

Get dictionary of tokens referened by token name

tkn_dictdict

Dictionary of tokens

get_name()

Get token names

tkn_nmsstr

Token names delimited by hyphen

get_names()

Get token string names

tkn_nmslist

Token string names

get_rates()

Get dictionary of token rates referenced by token name

tkn_ratesdict

Dictionary of token rates

get_token(tkn_name)

Get token from vault given its name symbol

tkn_namestr

Token name symbol

tknERC20

Retrieved ERC20 token

get_tokens()

Get list of tokens

tknslist

List of tokens

Quoting

class manual_stableswap.CSQuote

Composable stable liquidity pool token quotes (ie, price, reserve and liquidity)

get_lp_from_amount(lp, tkn, tkn_amt_in)

Get amount of liquidity, given an amount of input token

lpUniswapExchange

Uniswap LP

tkn: ERC20

Token asset from CWPT set

amount_in: float

Amount of input token

lp_amt: float

Amount of liquidity

Tokens

class stableswappy.erc.ERC20(name: str, addr: str, decimal: int = None)

ERC20 token

self.token_namestr

Token name

self.token_addrstr

Token address

self.token_totalfloat

Token holdings

deposit(_from, value)

Reset token LP

_fromstr

user address

valuestr

delta to add to total

transfer(_to, value)

Reset token LP

_tostr

user address

valuestr

delta to remove from total