coinbase_stable_swapper

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiquidityPoolAccountMinSize = (8 +
		32 +
		32 +
		32 +
		4 +
		8 +
		1 +
		1 +
		1) // bump
)

Minimum size without the dynamic supported_tokens vector

View Source
const (
	SwapInstructionArgsSize = (8 +
		8 +
		8) // min_amount_out
)

Variables

View Source
var (
	LiquidityPoolPrefix     = []byte("liquidity_pool")
	TokenVaultPrefix        = []byte("token_vault")
	VaultTokenAccountPrefix = []byte("vault_token_account")
	AddressWhitelistPrefix  = []byte("address_whitelist")
)
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("pqgqKahpG1y2wsgxFhzaAnkV1cL9vk8MSg9qm4q646F")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
var (
	SPL_TOKEN_PROGRAM_ID        = ed25519.PublicKey(mustBase58Decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"))
	ASSOCIATED_TOKEN_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))
	SYSTEM_PROGRAM_ID           = ed25519.PublicKey(mustBase58Decode("11111111111111111111111111111111"))
)
View Source
var (
	// LiquidityPool discriminator: [66, 38, 17, 64, 188, 80, 68, 129]
	LiquidityPoolAccountDiscriminator = []byte{66, 38, 17, 64, 188, 80, 68, 129}

	// AddressWhitelist discriminator: [10, 102, 46, 176, 154, 249, 160, 48]
	AddressWhitelistAccountDiscriminator = []byte{10, 102, 46, 176, 154, 249, 160, 48}

	// TokenVault discriminator: [121, 7, 84, 254, 151, 228, 43, 144]
	TokenVaultAccountDiscriminator = []byte{121, 7, 84, 254, 151, 228, 43, 144}
)

Account discriminators from the on-chain IDL

View Source
var (
	// swap discriminator: [248, 198, 158, 145, 225, 117, 135, 200]
	SwapInstructionDiscriminator = []byte{248, 198, 158, 145, 225, 117, 135, 200}
)

Instruction discriminators from the on-chain IDL

Functions

func GetPoolAddress

func GetPoolAddress() (ed25519.PublicKey, uint8, error)

GetPoolAddress returns the PDA for the liquidity pool

func GetTokenVaultAddress

func GetTokenVaultAddress(args *GetTokenVaultAddressArgs) (ed25519.PublicKey, uint8, error)

GetTokenVaultAddress returns the PDA for a token vault

func GetVaultTokenAccountAddress

func GetVaultTokenAccountAddress(args *GetVaultTokenAccountAddressArgs) (ed25519.PublicKey, uint8, error)

GetVaultTokenAccountAddress returns the PDA for a vault's token account

func GetWhitelistAddress

func GetWhitelistAddress() (ed25519.PublicKey, uint8, error)

GetWhitelistAddress returns the PDA for the address whitelist

func NewSwapInstruction

func NewSwapInstruction(
	accounts *SwapInstructionAccounts,
	args *SwapInstructionArgs,
) solana.Instruction

Types

type GetTokenVaultAddressArgs

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

type GetVaultTokenAccountAddressArgs

type GetVaultTokenAccountAddressArgs struct {
	Vault ed25519.PublicKey
}

type LiquidityPoolAccount

type LiquidityPoolAccount struct {
	OperationsAuthority ed25519.PublicKey
	PauseAuthority      ed25519.PublicKey
	FeeRecipient        ed25519.PublicKey
	SupportedTokens     []ed25519.PublicKey
	FeeRate             uint64
	SwapsPaused         bool
	LiquidityPaused     bool
	Bump                uint8
}

func (*LiquidityPoolAccount) String

func (obj *LiquidityPoolAccount) String() string

func (*LiquidityPoolAccount) Unmarshal

func (obj *LiquidityPoolAccount) Unmarshal(data []byte) error

type SwapInstructionAccounts

type SwapInstructionAccounts struct {
	Pool                     ed25519.PublicKey
	InVault                  ed25519.PublicKey
	OutVault                 ed25519.PublicKey
	InVaultTokenAccount      ed25519.PublicKey
	OutVaultTokenAccount     ed25519.PublicKey
	UserFromTokenAccount     ed25519.PublicKey
	ToTokenAccount           ed25519.PublicKey
	FeeRecipientTokenAccount ed25519.PublicKey
	FeeRecipient             ed25519.PublicKey
	FromMint                 ed25519.PublicKey
	ToMint                   ed25519.PublicKey
	User                     ed25519.PublicKey
	Whitelist                ed25519.PublicKey
}

type SwapInstructionArgs

type SwapInstructionArgs struct {
	AmountIn     uint64
	MinAmountOut uint64
}

Jump to

Keyboard shortcuts

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