pools

package
v0.0.0-...-0bc6137 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PoolInfo

func PoolInfo(ctx context.Context, ac *algod.Client, validatorAppID, asset1ID, asset2ID uint64) (*types.PoolInfo, error)

PoolInfo returns pool information for the given asset1 and asset2

Types

type Pool

type Pool struct {
	ValidatorAppID                  uint64
	LiquidityAsset                  *types.Asset
	Asset1                          *types.Asset
	Asset2                          *types.Asset
	AlgoBalance                     uint64
	Asset1Reserves                  uint64
	Asset2Reserves                  uint64
	IssuedLiquidity                 uint64
	MinBalance                      uint64
	UnclaimedProtocolFee            uint64
	OutstandingAsset1Amount         uint64
	OutstandingAsset2Amount         uint64
	OutstandingLiquidityAssetAmount uint64
	LastRefreshedRound              uint64
	UserAddress                     string
	// contains filtered or unexported fields
}

Pool represents a liquidity pool

func FromAccountInfo

func FromAccountInfo(ctx context.Context, account models.Account, ac *algod.Client, userAddress string) (*Pool, error)

FromAccountInfo create a pool from an account

func NewPool

func NewPool(
	ctx context.Context,
	ac *algod.Client,
	assetA,
	assetB *types.Asset,
	info *types.PoolInfo,
	validatorAppID uint64,
	userAddress string,
	fetch bool,
) (*Pool, error)

func (*Pool) Address

func (p *Pool) Address() (string, error)

Address returns a logic signature address

func (*Pool) Asset1Price

func (p *Pool) Asset1Price() float64

Asset1Price returns asset1 price

func (*Pool) Asset2Price

func (p *Pool) Asset2Price() float64

Asset2Price returns asset2 price

func (*Pool) Convert

func (p *Pool) Convert(amount *types.AssetAmount) (*types.AssetAmount, error)

Convert converts one asset to another

func (*Pool) FetchBurnQuote

func (p *Pool) FetchBurnQuote(ctx context.Context, liquidityAsset *types.AssetAmount, slippage float64) (*types.BurnQuote, error)

FetchBurnQuote returns a burn quote

func (*Pool) FetchFixedInputSwapQuote

func (p *Pool) FetchFixedInputSwapQuote(ctx context.Context, amountIn *types.AssetAmount, slippage float64) (*types.SwapQuote, error)

FetchFixedInputSwapQuote returns a fixed input swap quote

func (*Pool) FetchFixedOutputSwapQuote

func (p *Pool) FetchFixedOutputSwapQuote(ctx context.Context, amountOut *types.AssetAmount, slippage float64) (*types.SwapQuote, error)

FetchFixedOutputSwapQuote returns a fixed input swap quote

func (*Pool) FetchMintQuote

func (p *Pool) FetchMintQuote(
	ctx context.Context,
	amountA *types.AssetAmount,
	amountB *types.AssetAmount,
	slippage float64,
) (*types.MintQuote, error)

FetchMintQuote returns a mint quote

func (*Pool) FetchPoolPosition

func (p *Pool) FetchPoolPosition(ctx context.Context, userAddress string) (*types.PoolPosition, error)

FetchPoolPosition fetches pool position of a user

func (*Pool) FetchStateBytes

func (p *Pool) FetchStateBytes(ctx context.Context, key string) ([]byte, error)

FetchStateBytes returns an application state bytes value of the pool by a given key

func (*Pool) FetchStateInt

func (p *Pool) FetchStateInt(ctx context.Context, key string) (uint64, error)

FetchStateInt returns an application state int value of the pool by a given key

func (*Pool) FilterRedeemQuotes

func (p *Pool) FilterRedeemQuotes(quotes []types.RedeemQuote) ([]types.RedeemQuote, error)

FilterRedeemQuotes filters redeem quotes belonging to this pool

func (*Pool) GetRedeemQuoteMatchesAssetID

func (p *Pool) GetRedeemQuoteMatchesAssetID(assetID uint64, quotes []types.RedeemQuote) (*types.RedeemQuote, error)

GetRedeemQuoteMatchesAssetID filters redeem quote belonging to this pool which matches an asset id

func (*Pool) Info

func (p *Pool) Info() (*types.PoolInfo, error)

Info returns pool information

func (*Pool) LogicSig

func (p *Pool) LogicSig() (*crypto.LogicSigAccount, error)

LogicSig returns a logic signature account

func (*Pool) MinimumBalance

func (p *Pool) MinimumBalance() uint64

MinimumBalance calculates minimum balance

func (*Pool) PrepareBootstrapTransactions

func (p *Pool) PrepareBootstrapTransactions(ctx context.Context, bootstrapperAddress string) (*utils.TransactionGroup, error)

PrepareBootstrapTransactions prepares bootstrap transaction and returns a transaction group

func (*Pool) PrepareBurnTransactions

func (p *Pool) PrepareBurnTransactions(
	ctx context.Context,
	assetsOut map[uint64]types.AssetAmount,
	liquidityAssetAmount *types.AssetAmount,
	burnerAddress string,
) (*utils.TransactionGroup, error)

PrepareBurnTransactions prepares burn transaction and returns a transaction group

func (*Pool) PrepareBurnTransactionsFromQuote

func (p *Pool) PrepareBurnTransactionsFromQuote(ctx context.Context, quote *types.BurnQuote, burnerAddress string) (*utils.TransactionGroup, error)

PrepareBurnTransactionsFromQuote prepares burn transaction from a given burn quote and returns a transaction group

func (*Pool) PrepareLiquidityAssetOptInTransactions

func (p *Pool) PrepareLiquidityAssetOptInTransactions(ctx context.Context, userAddress string) (*utils.TransactionGroup, error)

PrepareLiquidityAssetOptInTransactions prepares liquidity asset opt-in transaction and returns a transaction group

func (*Pool) PrepareMintTransactions

func (p *Pool) PrepareMintTransactions(
	ctx context.Context,
	amountsIn map[uint64]types.AssetAmount,
	liquidityAssetAmount *types.AssetAmount,
	minterAddress string,
) (*utils.TransactionGroup, error)

PrepareMintTransactions prepares mint transaction and returns a transaction group

func (*Pool) PrepareMintTransactionsFromQuote

func (p *Pool) PrepareMintTransactionsFromQuote(ctx context.Context, quote *types.MintQuote, minterAddress string) (*utils.TransactionGroup, error)

PrepareMintTransactionsFromQuote prepares mint transaction from a given mint quote and returns a transaction group

func (*Pool) PrepareRedeemTransactions

func (p *Pool) PrepareRedeemTransactions(ctx context.Context, amountOut *types.AssetAmount, redeemerAddress string) (*utils.TransactionGroup, error)

PrepareRedeemTransactions prepares redeem transaction and returns a transaction group

func (*Pool) PrepareRedeemTransactionsFromQuote

func (p *Pool) PrepareRedeemTransactionsFromQuote(ctx context.Context, quote *types.RedeemQuote, redeemerAddress string) (*utils.TransactionGroup, error)

PrepareRedeemTransactionsFromQuote prepares redeem transactions and return a transaction group from quote

func (*Pool) PrepareSwapTransactions

func (p *Pool) PrepareSwapTransactions(
	ctx context.Context,
	assetAmountIn,
	assetAmountOut *types.AssetAmount,
	swapType,
	swapperAddress string,
) (*utils.TransactionGroup, error)

PrepareSwapTransactions prepares swap transaction and returns a transaction group

func (*Pool) PrepareSwapTransactionsFromQuote

func (p *Pool) PrepareSwapTransactionsFromQuote(ctx context.Context, quote *types.SwapQuote, swapperAddress string) (*utils.TransactionGroup, error)

PrepareSwapTransactionsFromQuote prepares swap transaction from a given swap quote and returns a transaction group

func (*Pool) Refresh

func (p *Pool) Refresh(ctx context.Context, info *types.PoolInfo) error

Refresh refreshes pool information

func (*Pool) UpdateFromInfo

func (p *Pool) UpdateFromInfo(ctx context.Context, info *types.PoolInfo) error

UpdateFromInfo updates pool information from a given pool info

Jump to

Keyboard shortcuts

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