tinyman

package module
v0.0.0-...-cf2a8c6 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 16 Imported by: 0

README

tinyman

sdk for tinyman

Documentation

Index

Constants

View Source
const (
	AlgoExplorerTestnet = "https://api.testnet.algoexplorer.io"
	AlgoExplorerMainnet = "https://api.algoexplorer.io"

	IndexerTestnet = "https://testnet.algoexplorerapi.io"
	IndexerMainnet = "https://algoexplorerapi.io"

	TestnetValidatorAppIDV0 = 21580889
	MainnetValidatorAppIDV0 = 350338509

	TestnetValidatorAppIDV1 = 62368684
	MainnetValidatorAppIDV1 = 552635992

	BootstrapAppArgument = "Ym9vdHN0cmFw"
	BurnAppArgument      = "YnVybg=="
	MintAppArgument      = "bWludA=="
	RedeemAppArgument    = "cmVkZWVt"
	SwapAppArgument      = "c3dhcA=="

	TestnetValidatorAppID = TestnetValidatorAppIDV1
	MainnetValidatorAppID = MainnetValidatorAppIDV1
)

Variables

This section is empty.

Functions

func PrepareAppOptInTxns

func PrepareAppOptInTxns(validatorAppID uint64, address string, sp types.SuggestedParams) ([]types.Transaction, error)

PrepareAppOptInTxns ...

func PrepareAssetOptIn

func PrepareAssetOptIn(assetID uint64, address string, sp types.SuggestedParams) ([]types.Transaction, error)

PrepareAssetOptInTxns ...

Types

type ASC

type ASC struct {
	Contracts Contracts `json:"contracts"`
}

ASC ...

var TinymanContracts ASC

TinymanContracts ...

type AssetAmount

type AssetAmount struct {
	AssetID uint64
	Amount  uint64
}

AssetAmount ...

type BurnQuote

type BurnQuote struct {
	AmountsOut           map[uint64]AssetAmount
	LiquidityAssetAmount AssetAmount
	Slippage             float64
}

BurnQuote ...

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(ac *algod.Client, validatorAppID uint64, userAddress string) *Client

NewClient ...

func (*Client) IsOptedIn

func (c *Client) IsOptedIn(ctx context.Context, address string) (bool, error)

IsOptedIn ...

func (*Client) Pool

func (c *Client) Pool(ctx context.Context, asset1ID, asset2ID uint64) (*Pool, error)

Pool ...

func (*Client) PrepareAppOptInTxns

func (c *Client) PrepareAppOptInTxns(ctx context.Context, address string) ([]types.Transaction, error)

PrepareAppOptInTxns ...

type Contract

type Contract struct {
	Type  string `json:"type"`
	Name  string `json:"name"`
	Logic Logic  `json:"logic"`
}

Contract ...

type Contracts

type Contracts struct {
	PoolLogicSig Contract `json:"pool_logicsig"`
}

Contracts ...

type Logic

type Logic struct {
	Bytecode  string     `json:"bytecode"`
	Address   string     `json:"address"`
	Size      int        `json:"size"`
	Variables []Variable `json:"variables"`
}

Logic ...

type Node

type Node struct {
	ratelimit.Limiter
	// contains filtered or unexported fields
}

Node ...

func NewNode

func NewNode(ac *algod.Client, ai *indexer.Client) *Node

NewNode ...

type Pool

type Pool struct {
	Client  *Client
	Address string

	Asset1ID           uint64
	Asset2ID           uint64
	Asset1Decimals     uint64
	Asset2Decimals     uint64
	Asset1UnitName     string
	Asset2UnitName     string
	LiquidityAssetID   uint64
	LiquidityAssetName string
	Asset1Reserves     uint64
	Asset2Reserves     uint64

	IssuedLiquidity                 uint64
	UnclaimedProtocolFees           uint64
	OutstandingAsset1Amount         uint64
	OutstandingAsset2Amount         uint64
	OutstandingLiquidityAssetAmount uint64
	ValidatorAppID                  uint64
	AlgoBalance                     uint64
	Round                           uint64
}

Pool ...

func FetchPool

func FetchPool(ctx context.Context, c *Client, asset1ID, asset2ID uint64) (*Pool, error)

FetchPool ...

func GetPoolInfo

func GetPoolInfo(ctx context.Context, node *Node, validatorAppID, asset1ID, asset2ID uint64) (Pool, error)

GetPoolInfo ...

func GetPoolInfoFromAccountInfo

func GetPoolInfoFromAccountInfo(ctx context.Context, accInfo models.Account) (Pool, error)

GetPoolInfoFromAccountInfo ...

func (*Pool) BurnQuote

func (p *Pool) BurnQuote(liquidityAssetAmt uint64, slippage float64) BurnQuote

BurnQuote ...

func (*Pool) FixedInputSwapQuote

func (p *Pool) FixedInputSwapQuote(assetID, amount uint64, slippage float64) (SwapQuote, error)

FixedInputSwapQuote ...

func (*Pool) MaximumAmount

func (p *Pool) MaximumAmount(assetID uint64, targetPrice float64) uint64

MaximumAmount ...

func (*Pool) PoolPosition

func (p *Pool) PoolPosition(ctx context.Context, address string) (PoolPosition, error)

PoolPosition ...

func (*Pool) PrepareSwapTransactions

func (p *Pool) PrepareSwapTransactions(ctx context.Context, assetInID, amountIn, amountOut uint64, swapType SwapType, address string) (*TransactionGroup, error)

PrepareSwapTransactions ...

func (*Pool) PrepareSwapTransactionsFromQuote

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

PrepareSwapTransactionsFromQuote ...

func (*Pool) Prices

func (p *Pool) Prices() (asset1Price, asset2Price float64)

Prices ...

func (*Pool) Refresh

func (p *Pool) Refresh(ctx context.Context) error

Refresh ...

func (*Pool) UpdateFromAccountInfo

func (p *Pool) UpdateFromAccountInfo(ctx context.Context, accInfo models.Account) error

UpdateFromAccountInfo ...

type PoolPosition

type PoolPosition struct {
	Asset1         AssetAmount
	Asset2         AssetAmount
	LiquidityAsset AssetAmount
	Share          float64
}

PoolPosition ...

type SwapQuote

type SwapQuote struct {
	SwapType       SwapType
	AssetAmountIn  AssetAmount
	AssetAmountOut AssetAmount
	SwapFees       float64
	Slippage       float64
}

SwapQuote ...

func (*SwapQuote) AmountInWithSlippage

func (sq *SwapQuote) AmountInWithSlippage() float64

AmountInWithSlippage ...

func (*SwapQuote) AmountOutWithSlippage

func (sq *SwapQuote) AmountOutWithSlippage() float64

AmountOutWithSlippage ...

func (*SwapQuote) Price

func (sq *SwapQuote) Price() float64

Price ...

func (*SwapQuote) PriceWithSlippage

func (sq *SwapQuote) PriceWithSlippage() float64

PriceWithSlippage ...

type SwapType

type SwapType string

SwapType ...

const (
	FixedOutput SwapType = "fixed-output"
	FixedInput  SwapType = "fixed-input"
)

type TransactionGroup

type TransactionGroup struct {
	// contains filtered or unexported fields
}

TransactionGroup ...

func NewTransactionGroup

func NewTransactionGroup(txns []types.Transaction) (*TransactionGroup, error)

NewTransactionGroup ...

func PrepareSwapTransactions

func PrepareSwapTransactions(
	sp types.SuggestedParams,
	validatorAppID uint64,
	asset1ID, asset2ID, liquidityAssetID uint64,
	assetInID uint64,
	assetInAmt, assetOutAmt uint64,
	swapType SwapType,
	senderAdd string) (*TransactionGroup, error)

PrepareSwapTransactions one asset (ASA or Algo) for another with the Pool.

func (*TransactionGroup) RawSignedTransactions

func (tg *TransactionGroup) RawSignedTransactions() []byte

RawSignedTransactions ...

func (*TransactionGroup) SignWithLogicSig

func (tg *TransactionGroup) SignWithLogicSig(lsa crypto.LogicSigAccount) error

SignWithLogicSig ...

func (*TransactionGroup) SignWithPrivateKey

func (tg *TransactionGroup) SignWithPrivateKey(pk ed25519.PrivateKey) error

SignWithPrivateKey ...

func (*TransactionGroup) Transactions

func (tg *TransactionGroup) Transactions() []types.Transaction

Transactions ...

type Variable

type Variable struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Index  int    `json:"index"`
	Length int    `json:"length"`
}

Variable ...

Jump to

Keyboard shortcuts

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