pools

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExcessAssetKey

func GetExcessAssetKey(poolAddress string, assetID int) (key []byte, err error)

Types

type BurnQuote

type BurnQuote struct {
	LiquidityAssetAmount *assets.AssetAmount
	Slippage             float64
	// contains filtered or unexported fields
}

func (*BurnQuote) AmountsOutWithSlippage

func (s *BurnQuote) AmountsOutWithSlippage() (amountsOutWithSlippage string, err error)

func (*BurnQuote) GetAmountsOut

func (s *BurnQuote) GetAmountsOut() map[int]string

func (*BurnQuote) GetAmountsOutStr

func (s *BurnQuote) GetAmountsOutStr() (amountsOutStr string, err error)

type MintQuote

type MintQuote struct {
	LiquidityAssetAmount *assets.AssetAmount
	Slippage             float64
	// contains filtered or unexported fields
}

TODO: in python code AmountsIn is dict[AssetAmount]

func (*MintQuote) GetAmountsIn

func (s *MintQuote) GetAmountsIn() map[int]string

func (*MintQuote) GetAmountsInStr

func (s *MintQuote) GetAmountsInStr() (string, error)

func (*MintQuote) LiquidityAssetAmountWithSlippage

func (s *MintQuote) LiquidityAssetAmountWithSlippage() (assetAmount *assets.AssetAmount, err error)

TODO: in python code it return int

type Pool

type Pool struct {
	Client                          *client.TinymanClient
	ValidatorAppId                  int
	Asset1                          *assets.Asset
	Asset2                          *assets.Asset
	Exists                          bool
	LiquidityAsset                  *assets.Asset
	Asset1Reserves                  string
	Asset2Reserves                  string
	IssuedLiquidity                 string
	UnclaimedProtocolFees           string
	OutstandingAsset1Amount         string
	OutstandingAsset2Amount         string
	OutstandingLiquidityAssetAmount string
	LastRefreshedRound              int
	AlgoBalance                     string
	MinBalance                      int
}

func NewPool

func NewPool(client *client.TinymanClient, assetA, assetB *assets.Asset, info *PoolInfo, fetch bool, validatorAppId int) (pool *Pool, err error)

TODO: is validatorID == 0 a valid ID

func NewPoolFromAccountInfo

func NewPoolFromAccountInfo(accountInfo models.Account, client *client.TinymanClient) (pool *Pool, err error)

not compatible with go-mobile

func (*Pool) Address

func (s *Pool) Address() (poolAddress string, err error)

func (*Pool) Asset1Price

func (s *Pool) Asset1Price() float64

func (*Pool) Asset2Price

func (s *Pool) Asset2Price() float64

func (*Pool) Convert

func (s *Pool) Convert(amount *assets.AssetAmount) (assetAmount *assets.AssetAmount)

func (*Pool) FetchBurnQuote

func (s *Pool) FetchBurnQuote(liquidityAssetIn *assets.AssetAmount, slippage float64) (quote *BurnQuote, err error)

func (*Pool) FetchBurnQuoteWithDefaultSlippage

func (s *Pool) FetchBurnQuoteWithDefaultSlippage(liquidityAssetIn *assets.AssetAmount) (quote *BurnQuote, err error)

func (*Pool) FetchExcessAmounts

func (s *Pool) FetchExcessAmounts(userAddress string) (excessAmounts map[int]string, err error)

func (*Pool) FetchExcessAmountsStr

func (s *Pool) FetchExcessAmountsStr(userAddress string) (excessAmountsStr string, err error)

func (*Pool) FetchFixedInputSwapQuote

func (s *Pool) FetchFixedInputSwapQuote(amountIn *assets.AssetAmount, slippage float64) (quote *SwapQuote, err error)

func (*Pool) FetchFixedInputSwapQuoteWithDefaultSlippage

func (s *Pool) FetchFixedInputSwapQuoteWithDefaultSlippage(amountIn *assets.AssetAmount) (quote *SwapQuote, err error)

func (*Pool) FetchFixedOutputSwapQuote

func (s *Pool) FetchFixedOutputSwapQuote(amountOut *assets.AssetAmount, slippage float64) (quote *SwapQuote, err error)

func (*Pool) FetchFixedOutputSwapQuoteWithDefaultSlippage

func (s *Pool) FetchFixedOutputSwapQuoteWithDefaultSlippage(amountOut *assets.AssetAmount) (quote *SwapQuote, err error)

func (*Pool) FetchMintQuote

func (s *Pool) FetchMintQuote(amountA, amountB *assets.AssetAmount, slippage float64) (quote *MintQuote, err error)

func (*Pool) FetchMintQuoteWithDefaultSlippage

func (s *Pool) FetchMintQuoteWithDefaultSlippage(amountA, amountB *assets.AssetAmount) (quote *MintQuote, err error)

func (*Pool) FetchPoolPosition

func (s *Pool) FetchPoolPosition(poolerAddress string) (poolPosition map[string]string, err error)

func (*Pool) FetchPoolPositionStr

func (s *Pool) FetchPoolPositionStr(poolerAddress string) (poolPositionStr string, err error)

func (*Pool) FetchState

func (s *Pool) FetchState() (validatorAppState map[string]models.TealValue, err error)

func (*Pool) FetchStateStr

func (s *Pool) FetchStateStr() (validatorAppStateStr string, err error)

func (*Pool) FetchStateWithKey

func (s *Pool) FetchStateWithKey(key interface{}) (state int, err error)

not compatible with go-mobile

func (*Pool) GetLogicsig

func (s *Pool) GetLogicsig() (poolLogicsig *types.LogicSig, err error)

func (*Pool) GetMinimumBalance

func (s *Pool) GetMinimumBalance() int

func (*Pool) Info

func (s *Pool) Info() (poolInfo *PoolInfo, err error)

func (*Pool) PrepareBootstrapTransactions

func (s *Pool) PrepareBootstrapTransactions(poolerAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareBurnTransactions

func (s *Pool) PrepareBurnTransactions(liquidityAssetAmount *assets.AssetAmount, amountsOutStr, poolerAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareBurnTransactionsFromQuote

func (s *Pool) PrepareBurnTransactionsFromQuote(quote *BurnQuote, poolerAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareLiquidityAssetOptinTransactions

func (s *Pool) PrepareLiquidityAssetOptinTransactions(userAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareMintTransactions

func (s *Pool) PrepareMintTransactions(amountsInStr string, liquidityAssetAmount *assets.AssetAmount, poolerAddress string) (txnGroup *utils.TransactionGroup, err error)

TODO: type dic[Asset] is dict[Asset,AssetAmount] in python code

func (*Pool) PrepareMintTransactionsFromQuote

func (s *Pool) PrepareMintTransactionsFromQuote(quote *MintQuote, poolerAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareRedeemFeesTransactions

func (s *Pool) PrepareRedeemFeesTransactions(amount, creatorAddress, userAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareRedeemTransactions

func (s *Pool) PrepareRedeemTransactions(amountOut *assets.AssetAmount, userAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareSwapTransactions

func (s *Pool) PrepareSwapTransactions(amountIn, amountOut *assets.AssetAmount, swapType string, swapperAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) PrepareSwapTransactionsFromQuote

func (s *Pool) PrepareSwapTransactionsFromQuote(quote *SwapQuote, swapperAddress string) (txnGroup *utils.TransactionGroup, err error)

func (*Pool) Refresh

func (s *Pool) Refresh() (err error)

func (*Pool) UpdateFromInfo

func (s *Pool) UpdateFromInfo(info *PoolInfo)

type PoolInfo

type PoolInfo struct {
	Address                         string
	Asset1Id                        int
	Asset2Id                        int
	Asset1UnitName                  string
	Asset2UnitName                  string
	LiquidityAssetId                int
	LiquidityAssetName              string
	Asset1Reserves                  string
	Asset2Reserves                  string
	IssuedLiquidity                 string
	UnclaimedProtocolFees           string
	OutstandingAsset1Amount         string
	OutstandingAsset2Amount         string
	OutstandingLiquidityAssetAmount string
	ValidatorAppId                  int
	AlgoBalance                     string
	Round                           int
	LastRefreshedRound              int
}

func GetPoolInfo

func GetPoolInfo(client *client.TinymanClient, validatorAppID, asset1ID, asset2ID int) (poolInfo *PoolInfo, err error)

func GetPoolInfoFromAccountInfo

func GetPoolInfoFromAccountInfo(accountInfo models.Account) (poolInfo *PoolInfo, err error)

not compatible with go-mobile

type SwapQuote

type SwapQuote struct {
	SwapType  string
	AmountIn  *assets.AssetAmount
	AmountOut *assets.AssetAmount
	SwapFees  *assets.AssetAmount
	Slippage  float64
}

func (*SwapQuote) AmountInWithSlippage

func (s *SwapQuote) AmountInWithSlippage() (assetAmount *assets.AssetAmount, err error)

func (*SwapQuote) AmountOutWithSlippage

func (s *SwapQuote) AmountOutWithSlippage() (assetAmount *assets.AssetAmount, err error)

func (*SwapQuote) Price

func (s *SwapQuote) Price() float64

func (*SwapQuote) PriceWithSlippage

func (s *SwapQuote) PriceWithSlippage() (priceWithSlippage float64, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL