types

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASC

type ASC struct {
	Repo      string    `json:"repo"`
	Ref       string    `json:"ref"`
	Contracts Contracts `json:"contracts"`
}

ASC represents Algorand Smart Contract

type AlgoClient

type AlgoClient interface {
	// SendRawTransaction submit a signed transaction group and wait for it to be confirmed if wait is true
	SendRawTransaction(ctx context.Context, signedGroup []byte, wait bool) (string, error)
}

AlgoClient represents the Algorand client

type ApprovalProgram

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

ApprovalProgram represents an approval program

type Asset

type Asset struct {

	// ID is an asset id
	ID uint64

	// Decimals is an asset decimals
	Decimals uint64

	// Name is an asset name
	Name string

	// UnitName is an asset unit name
	UnitName string
	// contains filtered or unexported fields
}

Asset is an Algorand token

func NewAsset

func NewAsset(id, decimals uint64, name, unitName string) *Asset

NewAsset creates an asset

func (*Asset) Equal

func (a *Asset) Equal(other *Asset) bool

Equal checks the equality of the asset with an other

func (*Asset) Fetch

func (a *Asset) Fetch(ctx context.Context, ac *algod.Client) error

Fetch fetches and updates the asset information

func (*Asset) IsFetchingRequired

func (a *Asset) IsFetchingRequired() bool

IsFetchingRequired checks whether the asset needs information fetching

func (*Asset) String

func (a *Asset) String() string

String returns a string representing the asset

type AssetAmount

type AssetAmount struct {
	// Asset is the underlying asset
	Asset *Asset

	// Amount is the amount of the asset
	Amount uint64
}

AssetAmount represents an asset amount

func NewAssetAmount

func NewAssetAmount(asset *Asset, amount uint64) (*AssetAmount, error)

NewAssetAmount creates a new asset amount

func (*AssetAmount) Add

func (a *AssetAmount) Add(other *AssetAmount, numOther *uint64) (*AssetAmount, error)

Add adds the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) Div

func (a *AssetAmount) Div(other *AssetAmount, numOther *uint64) (*AssetAmount, error)

Div divides the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) Eq

func (a *AssetAmount) Eq(other *AssetAmount, numOther *uint64) (bool, error)

Eq compares (=) the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) Gt

func (a *AssetAmount) Gt(other *AssetAmount, numOther *uint64) (bool, error)

Gt compares (>) the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) Lt

func (a *AssetAmount) Lt(other *AssetAmount, numOther *uint64) (bool, error)

Lt compares (<) the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) Mul

func (a *AssetAmount) Mul(other *AssetAmount, numOther *float64) (*AssetAmount, error)

Mul multiplies the asset with the other (if it is not nil) or otherwise numOther, and return a new one

func (*AssetAmount) String

func (a *AssetAmount) String() string

String returns a string representing an asest amount

func (*AssetAmount) Sub

func (a *AssetAmount) Sub(other *AssetAmount, numOther *uint64) (*AssetAmount, error)

Sub subtracts the asset with the other (if it is not nil) or otherwise numOther, and return a new one

type BurnQuote

type BurnQuote struct {
	// AmountsOut is an asset mapping which maps between asset ids and output asset amounts
	AmountsOut map[uint64]AssetAmount

	// LiquidityAssetAmount is a liquidity asset amount
	LiquidityAssetAmount AssetAmount

	// Slippage is a slippage
	Slippage float64
}

BurnQuote represents a burn quote

func (*BurnQuote) AmountsOutWithSlippage

func (b *BurnQuote) AmountsOutWithSlippage() (map[uint64]AssetAmount, error)

AmountsOutWithSlippage calculates asset amount out after applying the slippage

type ClearProgram

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

ClearProgram represents a clear program

type Contracts

type Contracts struct {
	PoolLogicSig PoolLogicSig `json:"pool_logicsig"`
	ValidatorApp ValidatorApp `json:"validator_app"`
}

Contracts represents contracts

type CryptoAccount

type CryptoAccount interface {
	// Address returns an address derived from the private key
	Address() string

	// PublicKey returns a public key derived from the private key
	PublicKey() []byte

	// PrivateKey returns the private key
	PrivateKey() []byte
}

CryptoAccount represents a cryptography account

type CryptoLogicSigAccount

type CryptoLogicSigAccount interface {
	// Address returns an address of the logic signature account
	Address() (string, error)

	// LogicSig returns the underlying logic signature which needs type casting
	LogicSig() interface{}
}

CryptoLogicSigAccount is a logic signature account

type GlobalStateSchema

type GlobalStateSchema struct {
	NumUints      int `json:"num_uints"`
	NumByteSlices int `json:"num_byte_slices"`
}

GlobalStateSchema represents a global state schema

type LocalStateSchema

type LocalStateSchema struct {
	NumUints      int `json:"num_uints"`
	NumByteSlices int `json:"num_byte_slices"`
}

LocalStateSchema represents a local state schema

type Logic

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

Logic represents logic

type MintQuote

type MintQuote struct {
	// AmountsIn is an asset mapping which maps between asset ids and input asset amounts
	AmountsIn map[uint64]AssetAmount

	// LiquidityAssetAmount is a liquidity asset amount
	LiquidityAssetAmount AssetAmount

	// Slippage is a slippage
	Slippage float64
}

MintQuote represents a mint quote

func (*MintQuote) LiquidityAssetAmountWithSlippage

func (m *MintQuote) LiquidityAssetAmountWithSlippage() (*AssetAmount, error)

LiquidityAssetAmountWithSlippage calculates liquidity asset after applying the slippage

type PoolInfo

type PoolInfo struct {
	// Address is a pool address
	Address string

	// Asset1ID is an asset1 id
	Asset1ID uint64

	// Asset2ID is an asset2 id
	Asset2ID uint64

	// Asset1UnitName is an asset1 unit name
	Asset1UnitName string

	// Asset2UnitName is an asset2 unit name
	Asset2UnitName string

	// LiquidityAssetID is an asset id for the liquidity
	LiquidityAssetID uint64

	// LiquidityAssetID is an asset name for the liquidity
	LiquidityAssetName string

	// Asset1Reserves is an asset1's reserves value
	Asset1Reserves uint64

	// Asset2Reserves is an asset2's reserves value
	Asset2Reserves uint64

	// IssuedLiquidity is the total issued liquidity
	IssuedLiquidity uint64

	// UnclaimedProtocolFee is an unclaimed protocol fee
	UnclaimedProtocolFee uint64

	// OutstandingAsset1Amount is an outstanding asset1 amount
	OutstandingAsset1Amount uint64

	// OutstandingAsset2Amount is an outstanding asset2 amount
	OutstandingAsset2Amount uint64

	// OutstandingLiquidityAssetAmount is an outstanding liquidity asset amount
	OutstandingLiquidityAssetAmount uint64

	// ValidatorAppID is the validator app id
	ValidatorAppID uint64

	// AlgoBalance is a balance of the pool
	AlgoBalance uint64

	// Round is the latest fetch round
	Round uint64
}

PoolInfo represents pool information

type PoolLogicSig

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

PoolLogicSig represents a pool logic signature

type PoolPosition

type PoolPosition struct {
	// Asset1 is an asset1
	Asset1 AssetAmount

	// Asset2 is an asset2
	Asset2 AssetAmount

	// LiquidityAsset is a liquidity asset
	LiquidityAsset AssetAmount

	// Share is a share of user which can be calculated as a percentage by (share * 100)
	Share float64
}

PoolPosition represents a user position in the pool

type RedeemQuote

type RedeemQuote struct {
	// Amount is an asset amount that can be redeemed
	Amount AssetAmount

	// PoolAddress is a pool address
	PoolAddress string
}

RedeemQuote represents a redeem quote

type SwapQuote

type SwapQuote struct {
	// SwapType is a swap type
	SwapType string

	// AmountIn is an input asset amount
	AmountIn *AssetAmount

	// AmountOut is an output asset amount
	AmountOut *AssetAmount

	// SwapFee is a swap fee
	SwapFee *AssetAmount

	// Slippage is a slippage
	Slippage float64
}

SwapQuote represents a swap quote

func (*SwapQuote) AmountInWithSlippage

func (s *SwapQuote) AmountInWithSlippage() (*AssetAmount, error)

AmountInWithSlippage calculates the input asset amount after applying the slippage

func (*SwapQuote) AmountOutWithSlippage

func (s *SwapQuote) AmountOutWithSlippage() (*AssetAmount, error)

AmountOutWithSlippage calculates the output asset amount after applying the slippage

func (*SwapQuote) Price

func (s *SwapQuote) Price() float64

Price returns the price

func (*SwapQuote) PriceWithSlippage

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

PriceWithSlippage returns the price after applying the slippage

type ValidatorApp

type ValidatorApp struct {
	Type              string            `json:"type"`
	ApprovalProgram   ApprovalProgram   `json:"approval_program"`
	ClearProgram      ClearProgram      `json:"clear_program"`
	GlobalStateSchema GlobalStateSchema `json:"global_state_schema"`
	LocalStateSchema  LocalStateSchema  `json:"local_state_schema"`
	Name              string            `json:"name"`
}

ValidatorApp represents a validator app

type Variable

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

Variable represents a variable

Jump to

Keyboard shortcuts

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