currencycreator

package
v1.10.21-0...-6d4d443 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMintMaxTokenSupply = 21_000_000 // 21mm tokens
	DefaultMintQuarksPerUnit  = 10_000_000_000
	DefaultMintMaxQuarkSupply = DefaultMintMaxTokenSupply * DefaultMintQuarksPerUnit // 21mm tokens with 10 decimals
	DefaultMintDecimals       = 10
)
View Source
const (
	MaxCurrencyConfigAccountNameLength   = 32
	MaxCurrencyConfigAccountSymbolLength = 8
)
View Source
const (
	DefaultBuyFeeBps  = 0   // 0% fee
	DefaultSellFeeBps = 100 // 1% fee
)
View Source
const (
	DefaultCurveDecimals = 18

	DefaultCurveAString     = "11400230149967394933471" // 11400.230149967394933471
	DefaultCurveBString     = "877175273521"            // 0.000000877175273521
	DefaultCurveScaleString = "1000000000000000000"     // 10^18

)
View Source
const (
	BuyAndDepositIntoVmInstructionArgsSize = (8 +
		8 +
		2) // account_index
)
View Source
const (
	BuyTokensInstructionArgsSize = (8 +
		8) // min_amount_out
)
View Source
const (
	CurrencyConfigAccountSize = (8 +
		32 +
		32 +
		MaxCurrencyConfigAccountNameLength +
		MaxCurrencyConfigAccountSymbolLength +
		32 +
		1 +
		1 +
		6) // padding
)
View Source
const (
	InitializeCurrencyInstructionArgsSize = (MaxCurrencyConfigAccountNameLength +
		MaxCurrencyConfigAccountSymbolLength +
		32 +
		1 +
		1 +
		6) // padding
)
View Source
const (
	InitializeMetadataInstructionArgsSize = 0
)
View Source
const (
	InitializePoolInstructionArgsSize = (2 +
		2 +
		1 +
		1 +
		1 +
		1) // padding
)
View Source
const (
	LiquidityPoolAccountSize = (8 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		2 +
		2 +
		1 +
		1 +
		1 +
		1) // padding
)
View Source
const (
	SellAndDepositIntoVmInstructionArgsSize = (8 +
		8 +
		2) // account_index
)
View Source
const (
	SellTokensInstructionArgsSize = (8 +
		8) // min_amount_out
)

Variables

View Source
var (
	MintPrefix     = []byte("mint")
	CurrencyPrefix = []byte("currency")
	PoolPrefix     = []byte("pool")
	TreasuryPrefix = []byte("treasury")
	MetadataPrefix = []byte("metadata")
)
View Source
var (
	ErrInvalidProgram         = errors.New("invalid program id")
	ErrInvalidAccountData     = errors.New("unexpected account data")
	ErrInvalidInstructionData = errors.New("unexpected instruction data")
)
View Source
var (
	PROGRAM_ADDRESS = mustBase58Decode("ccZLx5N31asHhCa7hFmvdC9EGYVam13L8WXPTjPEiJY")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
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"))
)
View Source
var CurrencyConfigAccountDiscriminator = []byte{byte(AccountTypeCurrencyConfig), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
View Source
var LiquidityPoolAccountDiscriminator = []byte{byte(AccountTypeLiquidityPool), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}

Functions

func EstimateBuy

func EstimateBuy(args *EstimateBuyArgs) (uint64, uint64)

func EstimateCurrentPrice

func EstimateCurrentPrice(currentSupplyInQuarks uint64) *big.Float

func EstimateSell

func EstimateSell(args *EstimateSellArgs) (uint64, uint64)

func EstimateValueExchange

func EstimateValueExchange(args *EstimateValueExchangeArgs) 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 ToQuarks

func ToQuarks(amount uint64) uint64

Types

type AccountType

type AccountType uint8
const (
	AccountTypeUnknown AccountType = iota
	AccountTypeCurrencyConfig
	AccountTypeLiquidityPool
)

type BuyAndDepositIntoVmInstructionAccounts

type BuyAndDepositIntoVmInstructionAccounts struct {
	Buyer       ed25519.PublicKey
	Pool        ed25519.PublicKey
	Currency    ed25519.PublicKey
	TargetMint  ed25519.PublicKey
	BaseMint    ed25519.PublicKey
	VaultTarget ed25519.PublicKey
	VaultBase   ed25519.PublicKey
	BuyerBase   ed25519.PublicKey
	FeeTarget   ed25519.PublicKey
	FeeBase     ed25519.PublicKey

	VmAuthority ed25519.PublicKey
	Vm          ed25519.PublicKey
	VmMemory    ed25519.PublicKey
	VmOmnibus   ed25519.PublicKey
	VtaOwner    ed25519.PublicKey
}

type BuyAndDepositIntoVmInstructionArgs

type BuyAndDepositIntoVmInstructionArgs struct {
	InAmount      uint64
	MinOutAmount  uint64
	VmMemoryIndex uint16
}

type BuyTokensInstructionAccounts

type BuyTokensInstructionAccounts struct {
	Buyer       ed25519.PublicKey
	Pool        ed25519.PublicKey
	Currency    ed25519.PublicKey
	TargetMint  ed25519.PublicKey
	BaseMint    ed25519.PublicKey
	VaultTarget ed25519.PublicKey
	VaultBase   ed25519.PublicKey
	BuyerTarget ed25519.PublicKey
	BuyerBase   ed25519.PublicKey
	FeeTarget   ed25519.PublicKey
	FeeBase     ed25519.PublicKey
}

type BuyTokensInstructionArgs

type BuyTokensInstructionArgs struct {
	InAmount     uint64
	MinAmountOut uint64
}

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 EstimateBuyArgs

type EstimateBuyArgs struct {
	BuyAmountInQuarks     uint64
	CurrentSupplyInQuarks uint64
	ValueMintDecimals     uint8
	BuyFeeBps             uint16
}

type EstimateSellArgs

type EstimateSellArgs struct {
	SellAmountInQuarks   uint64
	CurrentValueInQuarks uint64
	ValueMintDecimals    uint8
	SellFeeBps           uint16
}

type EstimateValueExchangeArgs

type EstimateValueExchangeArgs struct {
	ValueInQuarks        uint64
	CurrentValueInQuarks uint64
	ValueMintDecimals    uint8
}

type ExponentialCurve

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

func DefaultExponentialCurve

func DefaultExponentialCurve() *ExponentialCurve

func (*ExponentialCurve) CostToBuyTokens

func (curve *ExponentialCurve) CostToBuyTokens(currentSupply, tokensToBuy *big.Float) *big.Float

What is the cost to buy tokensToBuy given the currentSupply?

func (*ExponentialCurve) SpotPriceAtSupply

func (curve *ExponentialCurve) SpotPriceAtSupply(currentSupply *big.Float) *big.Float

func (*ExponentialCurve) TokensBoughtForValue

func (curve *ExponentialCurve) TokensBoughtForValue(currentSupply, value *big.Float) *big.Float

How many tokens will be bought for a value given the currentSupply?

func (*ExponentialCurve) TokensForValueExchange

func (curve *ExponentialCurve) TokensForValueExchange(currentValue, value *big.Float) *big.Float

How many tokens should be exchanged for a value given the currentValue?

func (*ExponentialCurve) ValueFromSellingTokens

func (curve *ExponentialCurve) ValueFromSellingTokens(currentValue, tokensToSell *big.Float) *big.Float

How much value is received when selling tokensToSell with currentValueLocked in the reserves?

type GetCurrencyAddressArgs

type GetCurrencyAddressArgs struct {
	Mint ed25519.PublicKey
}

type GetMetadataAddressArgs

type GetMetadataAddressArgs struct {
	Mint ed25519.PublicKey
}

type GetMintAddressArgs

type GetMintAddressArgs struct {
	Authority ed25519.PublicKey
	Name      string
	Seed      ed25519.PublicKey
}

type GetPoolAddressArgs

type GetPoolAddressArgs struct {
	Currency ed25519.PublicKey
}

type GetVaultAddressArgs

type GetVaultAddressArgs struct {
	Pool ed25519.PublicKey
	Mint ed25519.PublicKey
}

type InitializeCurrencyInstructionAccounts

type InitializeCurrencyInstructionAccounts struct {
	Authority ed25519.PublicKey
	Mint      ed25519.PublicKey
	Currency  ed25519.PublicKey
}

type InitializeCurrencyInstructionArgs

type InitializeCurrencyInstructionArgs struct {
	Name     string
	Symbol   string
	Seed     ed25519.PublicKey
	Bump     uint8
	MintBump uint8
}

type InitializeMetadataInstructionAccounts

type InitializeMetadataInstructionAccounts struct {
	Authority ed25519.PublicKey
	Mint      ed25519.PublicKey
	Currency  ed25519.PublicKey
	Metadata  ed25519.PublicKey
}

type InitializeMetadataInstructionArgs

type InitializeMetadataInstructionArgs struct {
}

type InitializePoolInstructionAccounts

type InitializePoolInstructionAccounts struct {
	Authority   ed25519.PublicKey
	Currency    ed25519.PublicKey
	TargetMint  ed25519.PublicKey
	BaseMint    ed25519.PublicKey
	Pool        ed25519.PublicKey
	VaultTarget ed25519.PublicKey
	VaultBase   ed25519.PublicKey
	FeeTarget   ed25519.PublicKey
	FeeBase     ed25519.PublicKey
}

type InitializePoolInstructionArgs

type InitializePoolInstructionArgs struct {
	BuyFee          uint16
	SellFee         uint16
	Bump            uint8
	VaultTargetBump uint8
	VaultBaseBump   uint8
}

type InstructionType

type InstructionType uint8
const (
	Unknown InstructionType = iota

	InstructionTypeInitializeCurrency
	InstructionTypeInitializePool
	InstructionTypeInitializeMetadata

	InstructionTypeBuyTokens
	InstructionTypeSellTokens
	InstructionTypeBuyAndDepositIntoVm
	InstructionTypeSellAndDepositIntoVm
)

type LiquidityPoolAccount

type LiquidityPoolAccount struct {
	Authority       ed25519.PublicKey
	Currency        ed25519.PublicKey
	TargetMint      ed25519.PublicKey
	BaseMint        ed25519.PublicKey
	VaultTarget     ed25519.PublicKey
	VaultBase       ed25519.PublicKey
	FeeTarget       ed25519.PublicKey
	FeeBase         ed25519.PublicKey
	BuyFee          uint16
	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
	Currency     ed25519.PublicKey
	TargetMint   ed25519.PublicKey
	BaseMint     ed25519.PublicKey
	VaultTarget  ed25519.PublicKey
	VaultBase    ed25519.PublicKey
	SellerTarget ed25519.PublicKey
	FeeTarget    ed25519.PublicKey
	FeeBase      ed25519.PublicKey

	VmAuthority ed25519.PublicKey
	Vm          ed25519.PublicKey
	VmMemory    ed25519.PublicKey
	VmOmnibus   ed25519.PublicKey
	VtaOwner    ed25519.PublicKey
}

type SellAndDepositIntoVmInstructionArgs

type SellAndDepositIntoVmInstructionArgs struct {
	InAmount      uint64
	MinOutAmount  uint64
	VmMemoryIndex uint16
}

type SellTokensInstructionAccounts

type SellTokensInstructionAccounts struct {
	Seller       ed25519.PublicKey
	Pool         ed25519.PublicKey
	Currency     ed25519.PublicKey
	TargetMint   ed25519.PublicKey
	BaseMint     ed25519.PublicKey
	VaultTarget  ed25519.PublicKey
	VaultBase    ed25519.PublicKey
	SellerTarget ed25519.PublicKey
	SellerBase   ed25519.PublicKey
	FeeTarget    ed25519.PublicKey
	FeeBase      ed25519.PublicKey
}

type SellTokensInstructionArgs

type SellTokensInstructionArgs struct {
	InAmount     uint64
	MinAmountOut uint64
}

Jump to

Keyboard shortcuts

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