Documentation
¶
Index ¶
- Constants
- Variables
- func EstimateBuy(args *EstimateBuyArgs) uint64
- func EstimateCurrentPrice(currentSupplyInQuarks uint64) *big.Float
- func EstimateSell(args *EstimateSellArgs) (uint64, uint64)
- func GetCurrencyAddress(args *GetCurrencyAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetMetadataAddress(args *GetMetadataAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetMintAddress(args *GetMintAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetPoolAddress(args *GetPoolAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetVaultAddress(args *GetVaultAddressArgs) (ed25519.PublicKey, uint8, error)
- func NewBurnFeesInstruction(accounts *BurnFeesInstructionAccounts, args *BurnFeesInstructionArgs) solana.Instruction
- func NewBuyAndDepositIntoVmInstruction(accounts *BuyAndDepositIntoVmInstructionAccounts, ...) solana.Instruction
- func NewBuyTokensInstruction(accounts *BuyTokensInstructionAccounts, args *BuyTokensInstructionArgs) solana.Instruction
- func NewInitializeCurrencyInstruction(accounts *InitializeCurrencyInstructionAccounts, ...) solana.Instruction
- func NewInitializeMetadataInstruction(accounts *InitializeMetadataInstructionAccounts, ...) solana.Instruction
- func NewInitializePoolInstruction(accounts *InitializePoolInstructionAccounts, ...) solana.Instruction
- func NewSellAndDepositIntoVmInstruction(accounts *SellAndDepositIntoVmInstructionAccounts, ...) solana.Instruction
- func NewSellTokensInstruction(accounts *SellTokensInstructionAccounts, args *SellTokensInstructionArgs) solana.Instruction
- func ToQuarks(amount uint64) uint64
- type AccountType
- type BurnFeesInstructionAccounts
- type BurnFeesInstructionArgs
- type BuyAndDepositIntoVmInstructionAccounts
- type BuyAndDepositIntoVmInstructionArgs
- type BuyTokensInstructionAccounts
- type BuyTokensInstructionArgs
- type CurrencyConfigAccount
- type DiscreteExponentialCurve
- type EstimateBuyArgs
- type EstimateSellArgs
- type GetCurrencyAddressArgs
- type GetMetadataAddressArgs
- type GetMintAddressArgs
- type GetPoolAddressArgs
- type GetVaultAddressArgs
- type InitializeCurrencyInstructionAccounts
- type InitializeCurrencyInstructionArgs
- type InitializeMetadataInstructionAccounts
- type InitializeMetadataInstructionArgs
- type InitializePoolInstructionAccounts
- type InitializePoolInstructionArgs
- type InstructionType
- type LiquidityPoolAccount
- type SellAndDepositIntoVmInstructionAccounts
- type SellAndDepositIntoVmInstructionArgs
- type SellTokensInstructionAccounts
- type SellTokensInstructionArgs
Constants ¶
const ( DefaultMintMaxTokenSupply = 21_000_000 // 21mm tokens DefaultMintQuarksPerUnit = 10_000_000_000 DefaultMintMaxQuarkSupply = DefaultMintMaxTokenSupply * DefaultMintQuarksPerUnit // 21mm tokens with 10 decimals DefaultMintDecimals = 10 )
const ( MaxCurrencyConfigAccountNameLength = 32 MaxCurrencyConfigAccountSymbolLength = 8 )
const ( // DefaultCurveDecimals is the number of decimal places supported by the curve DefaultCurveDecimals = 18 // DiscretePricingStepSize is the token supply interval between price steps DiscretePricingStepSize = 100 // DiscretePriceDecimals is the number of decimal places for scaled prices (18 decimals) DiscretePriceDecimals = DefaultCurveDecimals )
const (
BurnFeesInstructionArgsSize = 0
)
const ( BuyAndDepositIntoVmInstructionArgsSize = (8 + 8 + 2) // account_index )
const ( BuyTokensInstructionArgsSize = (8 + 8) // min_amount_out )
const ( CurrencyConfigAccountSize = (8 + 32 + 32 + MaxCurrencyConfigAccountNameLength + MaxCurrencyConfigAccountSymbolLength + 32 + 1 + 1 + 6) // padding )
const (
DefaultSellFeeBps = 100 // 1% fee
)
const ( InitializeCurrencyInstructionArgsSize = (MaxCurrencyConfigAccountNameLength + MaxCurrencyConfigAccountSymbolLength + 32 + 1 + 1 + 6) // padding )
const (
InitializeMetadataInstructionArgsSize = 0
)
const ( InitializePoolInstructionArgsSize = (2 + 1 + 1 + 1 + 1) // padding )
const ( LiquidityPoolAccountSize = (8 + 32 + 32 + 32 + 32 + 32 + 32 + 8 + 2 + 1 + 1 + 1 + 3) // padding )
const ( SellAndDepositIntoVmInstructionArgsSize = (8 + 8 + 2) // account_index )
const ( SellTokensInstructionArgsSize = (8 + 8) // min_amount_out )
Variables ¶
var ( MintPrefix = []byte("mint") CurrencyPrefix = []byte("currency") PoolPrefix = []byte("pool") TreasuryPrefix = []byte("treasury") MetadataPrefix = []byte("metadata") )
var ( ErrInvalidProgram = errors.New("invalid program id") ErrInvalidAccountData = errors.New("unexpected account data") ErrInvalidInstructionData = errors.New("unexpected instruction data") )
var ( PROGRAM_ADDRESS = mustBase58Decode("ccJYP5gjZqcEHaphcxAZvkxCrnTVfYMjyhSYkpQtf8Z") PROGRAM_ID = ed25519.PublicKey(PROGRAM_ADDRESS) )
var ( METADATA_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")) SPL_TOKEN_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")) SYSTEM_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("11111111111111111111111111111111")) SYSVAR_RENT_PUBKEY = ed25519.PublicKey(mustBase58Decode("SysvarRent111111111111111111111111111111111")) )
var CurrencyConfigAccountDiscriminator = []byte{byte(AccountTypeCurrencyConfig), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
var DiscreteCumulativeValueTable = initCumulativeValueTable()
DiscreteCumulativeValueTable contains pre-computed cumulative values. Values are scaled by 10^18 (18 decimal places). Each entry represents the total cost to buy tokens from supply 0 to index * 100.
var DiscretePricingTable = initPricingTable()
DiscretePricingTable contains pre-computed prices for each supply step. Prices are scaled by 10^18 (18 decimal places). Each entry represents the price at supply = index * 100.
var LiquidityPoolAccountDiscriminator = []byte{byte(AccountTypeLiquidityPool), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Functions ¶
func EstimateBuy ¶
func EstimateBuy(args *EstimateBuyArgs) uint64
func EstimateCurrentPrice ¶
func EstimateSell ¶
func EstimateSell(args *EstimateSellArgs) (uint64, uint64)
func GetCurrencyAddress ¶
func GetCurrencyAddress(args *GetCurrencyAddressArgs) (ed25519.PublicKey, uint8, error)
func GetMetadataAddress ¶
func GetMetadataAddress(args *GetMetadataAddressArgs) (ed25519.PublicKey, uint8, error)
func GetMintAddress ¶
func GetMintAddress(args *GetMintAddressArgs) (ed25519.PublicKey, uint8, error)
func GetPoolAddress ¶
func GetPoolAddress(args *GetPoolAddressArgs) (ed25519.PublicKey, uint8, error)
func GetVaultAddress ¶
func GetVaultAddress(args *GetVaultAddressArgs) (ed25519.PublicKey, uint8, error)
func NewBurnFeesInstruction ¶ added in v0.7.0
func NewBurnFeesInstruction( accounts *BurnFeesInstructionAccounts, args *BurnFeesInstructionArgs, ) solana.Instruction
func NewBuyAndDepositIntoVmInstruction ¶
func NewBuyAndDepositIntoVmInstruction( accounts *BuyAndDepositIntoVmInstructionAccounts, args *BuyAndDepositIntoVmInstructionArgs, ) solana.Instruction
func NewBuyTokensInstruction ¶
func NewBuyTokensInstruction( accounts *BuyTokensInstructionAccounts, args *BuyTokensInstructionArgs, ) solana.Instruction
func NewInitializeCurrencyInstruction ¶
func NewInitializeCurrencyInstruction( accounts *InitializeCurrencyInstructionAccounts, args *InitializeCurrencyInstructionArgs, ) solana.Instruction
func NewInitializeMetadataInstruction ¶
func NewInitializeMetadataInstruction( accounts *InitializeMetadataInstructionAccounts, args *InitializeMetadataInstructionArgs, ) solana.Instruction
func NewInitializePoolInstruction ¶
func NewInitializePoolInstruction( accounts *InitializePoolInstructionAccounts, args *InitializePoolInstructionArgs, ) solana.Instruction
func NewSellAndDepositIntoVmInstruction ¶
func NewSellAndDepositIntoVmInstruction( accounts *SellAndDepositIntoVmInstructionAccounts, args *SellAndDepositIntoVmInstructionArgs, ) solana.Instruction
func NewSellTokensInstruction ¶
func NewSellTokensInstruction( accounts *SellTokensInstructionAccounts, args *SellTokensInstructionArgs, ) solana.Instruction
Types ¶
type AccountType ¶
type AccountType uint8
const ( AccountTypeUnknown AccountType = iota AccountTypeCurrencyConfig AccountTypeLiquidityPool )
type BurnFeesInstructionAccounts ¶ added in v0.7.0
type BurnFeesInstructionArgs ¶ added in v0.7.0
type BurnFeesInstructionArgs struct {
}
type BuyAndDepositIntoVmInstructionAccounts ¶
type BuyAndDepositIntoVmInstructionAccounts struct {
Buyer ed25519.PublicKey
Pool ed25519.PublicKey
TargetMint ed25519.PublicKey
BaseMint ed25519.PublicKey
VaultTarget ed25519.PublicKey
VaultBase ed25519.PublicKey
BuyerBase ed25519.PublicKey
VmAuthority ed25519.PublicKey
Vm ed25519.PublicKey
VmMemory ed25519.PublicKey
VmOmnibus ed25519.PublicKey
VtaOwner ed25519.PublicKey
}
type CurrencyConfigAccount ¶
type CurrencyConfigAccount struct {
Authority ed25519.PublicKey
Mint ed25519.PublicKey
Name string
Symbol string
Seed ed25519.PublicKey
Bump uint8
MintBump uint8
}
func (*CurrencyConfigAccount) String ¶
func (obj *CurrencyConfigAccount) String() string
func (*CurrencyConfigAccount) Unmarshal ¶
func (obj *CurrencyConfigAccount) Unmarshal(data []byte) error
type DiscreteExponentialCurve ¶ added in v0.7.0
type DiscreteExponentialCurve struct {
// contains filtered or unexported fields
}
DiscreteExponentialCurve implements a discrete pricing curve using pre-computed tables. Prices are stored as scaled u128 values with 18 decimal precision.
func DefaultDiscreteExponentialCurve ¶ added in v0.7.0
func DefaultDiscreteExponentialCurve() *DiscreteExponentialCurve
DefaultDiscreteExponentialCurve creates a new default discrete exponential curve instance.
func (*DiscreteExponentialCurve) SpotPriceAtSupply ¶ added in v0.7.0
func (c *DiscreteExponentialCurve) SpotPriceAtSupply(currentSupply *big.Float) *big.Float
SpotPriceAtSupply returns the current price per token at the given supply level. Returns nil if the supply is beyond the table bounds.
func (*DiscreteExponentialCurve) TokensToValue ¶ added in v0.7.0
func (c *DiscreteExponentialCurve) TokensToValue(currentSupply, tokens *big.Float) *big.Float
TokensToValue calculates the total cost to buy `tokens` starting at `currentSupply`. This is equivalent to "How much does it cost to get X tokens?" Returns nil if the purchase would exceed table bounds. Supports fractional tokens - does not round up or down.
func (*DiscreteExponentialCurve) ValueToTokens ¶ added in v0.7.0
func (c *DiscreteExponentialCurve) ValueToTokens(currentSupply, value *big.Float) *big.Float
ValueToTokens calculates the number of tokens received for a given value starting at currentSupply. This is equivalent to "How many tokens can I get for Y value?" Returns nil if the supply is beyond table bounds. Supports fractional tokens - does not round up or down.
type EstimateBuyArgs ¶
type EstimateSellArgs ¶
type GetCurrencyAddressArgs ¶
type GetMetadataAddressArgs ¶
type GetMintAddressArgs ¶
type GetPoolAddressArgs ¶
type GetVaultAddressArgs ¶
type InitializeMetadataInstructionArgs ¶
type InitializeMetadataInstructionArgs struct {
}
type InstructionType ¶
type InstructionType uint8
const ( Unknown InstructionType = iota InstructionTypeInitializeCurrency InstructionTypeInitializePool InstructionTypeInitializeMetadata InstructionTypeBuyTokens InstructionTypeSellTokens InstructionTypeBuyAndDepositIntoVm InstructionTypeSellAndDepositIntoVm InstructionTypeBurnFees )
type LiquidityPoolAccount ¶
type LiquidityPoolAccount struct {
Authority ed25519.PublicKey
Currency ed25519.PublicKey
TargetMint ed25519.PublicKey
BaseMint ed25519.PublicKey
VaultTarget ed25519.PublicKey
VaultBase ed25519.PublicKey
FeesAccumulated uint64
SellFee uint16
Bump uint8
VaultTargetBump uint8
VaultBaseBump uint8
}
func (*LiquidityPoolAccount) String ¶
func (obj *LiquidityPoolAccount) String() string
func (*LiquidityPoolAccount) Unmarshal ¶
func (obj *LiquidityPoolAccount) Unmarshal(data []byte) error
type SellAndDepositIntoVmInstructionAccounts ¶
type SellAndDepositIntoVmInstructionAccounts struct {
Seller ed25519.PublicKey
Pool ed25519.PublicKey
TargetMint ed25519.PublicKey
BaseMint ed25519.PublicKey
VaultTarget ed25519.PublicKey
VaultBase ed25519.PublicKey
SellerTarget ed25519.PublicKey
VmAuthority ed25519.PublicKey
Vm ed25519.PublicKey
VmMemory ed25519.PublicKey
VmOmnibus ed25519.PublicKey
VtaOwner ed25519.PublicKey
}
Source Files
¶
- accounts_currency_config.go
- accounts_liquidity_pool.go
- address.go
- discrete_exponential_curve.go
- estimate.go
- instructions_burn_fees.go
- instructions_buy_and_deposit_into_vm.go
- instructions_buy_tokens.go
- instructions_initialize_currency.go
- instructions_initialize_metadata.go
- instructions_initialize_pool.go
- instructions_sell_and_deposit_into_vm.go
- instructions_sell_tokens.go
- program.go
- tables.go
- types_account_type.go
- types_instruction_type.go
- utils.go