Uniswap V2/V3
Join
- class uniswappy.process.join.Join
Process to join x and y amounts to pool
- apply(lp, user_nm, amount0, amount1, lwr_tick=None, upr_tick=None)
Join x and y amounts to pool
- lpExchange
LP exchange
- user_nmstr
account name
- amount0float
x token amount
- amount1float
y token amount
- lwr_tickint
Lower tick of the position in which to add liquidity
- upr_tickint
Upper tick of the position in which to add liquidity
- outdictionary
join output
Swap
- class uniswappy.process.swap.Swap(ev=None, tDel=None)
Process to swap token X for token Y (and vice verse)
- evEventSelectionModel
EventSelectionModel object to randomly generate buy vs sell events
- tDelTokenDeltaModel
TokenDeltaModel to randomly generate token amounts
- apply(lp, token_in, user_nm, amount_in, sqrt_price_limit=None)
Swap token X for token Y (and vice verse)
- lpExchange
LP exchange
- token_inERC20
specified ERC20 token
- user_nmstr
account name
- amount_infloat
token amount to be swap
- lwr_tickint
lower tick of the position in which to add liquidity
- upr_tickint
upper tick of the position in which to add liquidity
- amount_out_expectedfloat
exchanged token amount
Withdraw
- class uniswappy.process.swap.WithdrawSwap(ev=None, tDel=None)
Process to withdraw liquidity from LP and swap opposing token which is added to specifed token to receive a single amount of specified token
- evEventSelectionModel
EventSelectionModel object to randomly generate buy vs sell events
- tDelTokenDeltaModel
TokenDeltaModel to randomly generate token amounts
- apply(lp, token_out, user_nm, amount_out, lwr_tick=None, upr_tick=None)
Withdraw liquidity from LP and swap opposing token which is added to specifed token to receive a single amount of specified token
- lpExchange
LP exchange
- token_outERC20
specified ERC20 token
- user_nmstr
account name
- amount_outfloat
token amount to be swap
- lwr_tickint
lower tick of the position in which to add liquidity
- upr_tickint
upper tick of the position in which to add liquidity
- amount_outfloat
amount of withdrawn token
- get_trading_token(lp, token)
Get opposing token from specified token
- lpExchange
LP exchange
- tokenERC20
specified ERC20 token
- trading_tokenERC20
opposing ERC20 token
Deposit
- class uniswappy.process.deposit.SwapDeposit(ev=None, tDel=None)
Process to swap approx. half of single token X for token Y (and vice verse) and deposit proceeds plus remaining other approximated half
- evEventSelectionModel
EventSelectionModel object to randomly generate buy vs sell events
- tDelTokenDeltaModel
TokenDeltaModel to randomly generate token amounts
- apply(lp, token_in, user_nm, amount_in, lwr_tick=None, upr_tick=None)
Swap approx. half of single token X for token Y (and vice verse) and deposit proceeds plus remaining other approximated half
- lpExchange
LP exchange
- token_inERC20
specified ERC20 token
- user_nmstr
account name
- amount_infloat
token amount to be swap
- lwr_tickint
lower tick of the position in which to add liquidity
- upr_tickint
upper tick of the position in which to add liquidity
- (amount_in, amount_out)float, float
token swap amounts
- get_trading_token(lp, token)
Get opposing token from specified token
- lpExchange
LP exchange
- tokenERC20
specified ERC20 token
- trading_tokenERC20
opposing ERC20 token
Liquidity
- class uniswappy.process.liquidity.AddLiquidity(init_price=None, ev=None, tDel=None)
Add liquidity process
- evEventSelectionModel
EventSelectionModel object to randomly generate buy vs sell events
- tDelTokenDeltaModel
TokenDeltaModel to randomly generate token amounts
- apply(lp, token_in, user_nm, amount_in, lwr_tick=None, upr_tick=None)
Adds liquidity using only X or Y amounts
- lpExchange
LP exchange
- token_inERC20
specified ERC20 token
- user_nmstr
account name
- amount_infloat
token amount to be add to liquidity
- lwr_tickint
lower tick of the position in which to add liquidity
- upr_tickint
upper tick of the position in which to add liquidity
- (amount_in, amount_out)float, float
token swap amounts
- class uniswappy.process.liquidity.RemoveLiquidity(ev=None, tDel=None)
Remove liquidity process
- evEventSelectionModel
EventSelectionModel object to randomly generate buy vs sell events
- tDelTokenDeltaModel
TokenDeltaModel to randomly generate token amounts
- apply(lp, token_in, user_nm, amount_in, lwr_tick=None, upr_tick=None)
Removes liquidity using only X or Y amounts
- lpExchange
LP exchange
- token_inERC20
specified ERC20 token
- user_nmstr
account name
- amount_infloat
token amount to be add to liquidity
- lwr_tickint
lower tick of the position in which to add liquidity
- upr_tickint
upper tick of the position in which to add liquidity
- reserve amountsdictionary
dictionary of reserve amounts
Quote
- class uniswappy.cpt.quote.IndexTokenQuote(lwr_tick=None, upr_tick=None, quote_native_tokens=True)
Index token quotes
- quote_native_tokensboolean
Quote LP amount of base pool, otherwise quote indexed pool
- base_x_asset(lp)
Get x base asset in x*y CPT pairing
- lpUniswapExchange
Uniswap liquidity pool (LP) exchange
- token: ERC20
x base asset from CPT pair
- base_y_asset(lp)
Get y base asset in x*y CPT pairing
- lpUniswapExchange
Uniswap liquidity pool (LP) exchange
- token: ERC20
y base asset from CPT pair
- get_base_lp(lp, tkn)
Return the parent LP, given a child LP and one of its reserve tokens,
- lpUniswapExchange
Child Uniswap liquidity pool (LP) exchange
- tknERC20
Child ERC20 token in x*y CPT pairing
- lp: UniswapExchange
Parent liquidity pool (LP) exchange
- get_native_x(lp, tkn_x, x_amt)
Get x base asset amount in x*y CPT pairing
- lpUniswapExchange
Uniswap liquidity pool (LP) exchange
- tkn_xERC20
ERC20 x token in x*y CPT pairing
- x_amtfloat
Amount of x token
- reserve: float
Amount of x reserve from CPT pair
- get_native_y(lp, tkn_y, y_amt)
Get y base asset amount in x*y CPT pairing
- lpUniswapExchange
Uniswap liquidity pool (LP) exchange
- tkn_yERC20
ERC20 y token in x*y CPT pairing
- y_amtfloat
Amount of x token
- reserve: float
Amount of y reserve from CPT pair
- get_x(lp, amt_lp)
Given an amount of LP holdings, get x reserve of CPT pair (ie, xy = k)
- lpUniswapExchange
Uniswap LP
- amt_lpfloat
Amount of LP holdings
- reserve: float
Amount of x reserve from CPT pair
- get_y(lp, amt_lp)
Given an amount of LP holdings, get y reserve of CPT pair (ie, x*y = k)
- lpUniswapExchange
Uniswap liquidity pool (LP) exchange
- amt_lpfloat
Amount of LP holdings
- reserve: float
Amount of y reserve from CPT pair
- class uniswappy.cpt.quote.LPQuote(quote_opposing=True, include_fee=False)
Liquidity pool token quotes (ie, price, reserve and liquidity)
- quote_opposingboolean
Quote the opposing token amount by default, given LP and a token
- get_amount(lp, tkn, amount_in, lwr_tick=None, upr_tick=None)
Get amount of reserve for opposing token, given an amount of reserve of input token
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- amount_in: float
Amount of reserve token
- amt_out: float
Amount of reserve for opposing token
- get_amount_from_lp(lp, tkn, amount_lp_in, lwr_tick=None, upr_tick=None)
Get amount of opposing token, given an amount priced in liquidity
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- amount_lp_in: float
Amount of liquidity
- amt_out: float
Amount of opposing token
- get_liquidity(lp, tkn, amount_in)
Get liquidity amount given amount of one of the tokens in x*y CPT pair
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- amount_in: float
Amount of liquidity
- amt_out: float
Liquidity amount given amount of one of the tokens in x*y CPT pair
- get_lp_from_amount(lp, tkn, amount_in, lwr_tick=None, upr_tick=None)
Get amount of liquidity, given an amount reserve token
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- amount_lp_in: float
Amount of reserve token
- amt_out: float
Amount of liquidity
- get_opposing_token(lp, tkn)
get_x
Get opposing token given LP exchange and one of its token assetes
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- tkn: ERC20
Opposing token from CPT pair
- get_price(lp, tkn, lwr_tick=None, upr_tick=None)
Get price of token given LP exchange
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- price: float
Token price with respect to opposing token
- get_reserve(lp, token, lwr_tick=None, upr_tick=None)
Get reserve amount of token given LP exchange
- lpUniswapExchange
Uniswap LP
- token: ERC20
Token asset from CPT pair
- reserve: float
Reserve amount from token asset
- class uniswappy.cpt.index.RebaseIndexToken
Determine rebase amount of index token given a certain amount of liquidity from LP (inverse of SettlementLPToken)
- apply(lp, tkn, liq_amt, lwr_tick=None, upr_tick=None)
Apply rebase token calculation settlement; given liquidity amount, what is the reserve amount
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- liq_amt: float
Liquidity amount to be priced in in terms of reserve token
- rebase_amount: float
Reserve token amount, given liquidity amount
- class uniswappy.cpt.index.SettlementLPToken
Determine settlement amount of LP token given a certain amount of token
- apply(lp, tkn, itkn_amt, lwr_tick=None, upr_tick=None)
Apply LP calculation settlement; given token amount, what is the liquidity amount
- lpUniswapExchange
Uniswap LP
- tkn: ERC20
Token asset from CPT pair
- itkn_amt: float
Token reserve amount to be priced in terms of liquidity
- lp_amount: float
Liquidity amount given reserve token amount