usdf_swap

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPoolNameLength = 32
	MaxSwapDollars    = 1000
)
View Source
const (
	InitializeInstructionArgsSize = (MaxPoolNameLength +
		1 +
		1 +
		1) // other_vault_bump
)
View Source
const (
	PoolAccountSize = (8 +
		32 +
		MaxPoolNameLength +
		32 +
		32 +
		32 +
		32 +
		1 +
		1 +
		1 +
		1 +
		1 +
		3) // padding
)
View Source
const (
	SwapInstructionArgsSize = (8 +
		1) // usdf_to_other
)
View Source
const (
	TransferInstructionArgsSize = (8 +
		1) // is_usdf
)

Variables

View Source
var (
	PoolPrefix  = []byte("pool")
	VaultPrefix = []byte("vault")
)
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("usdfcP2V1bh1Lz7Y87pxR4zJd3wnVtssJ6GeSHFeZeu")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
var (
	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 PoolAccountDiscriminator = []byte{byte(AccountTypePool), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}

Functions

func GetPoolAddress

func GetPoolAddress(args *GetPoolAddressArgs) (ed25519.PublicKey, uint8, error)

func GetVaultAddress

func GetVaultAddress(args *GetVaultAddressArgs) (ed25519.PublicKey, uint8, error)

func NewSwapInstruction

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

func NewTransferInstruction

func NewTransferInstruction(
	accounts *TransferInstructionAccounts,
	args *TransferInstructionArgs,
) solana.Instruction

Types

type AccountType

type AccountType uint8
const (
	AccountTypeUnknown AccountType = iota
	AccountTypePool
)

type GetPoolAddressArgs

type GetPoolAddressArgs struct {
	Authority ed25519.PublicKey
	Name      string
	UsdfMint  ed25519.PublicKey
	OtherMint ed25519.PublicKey
}

type GetVaultAddressArgs

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

type InitializeInstructionAccounts

type InitializeInstructionAccounts struct {
	Authority  ed25519.PublicKey
	UsdfMint   ed25519.PublicKey
	OtherMint  ed25519.PublicKey
	Pool       ed25519.PublicKey
	UsdfVault  ed25519.PublicKey
	OtherVault ed25519.PublicKey
}

type InitializeInstructionArgs

type InitializeInstructionArgs struct {
	Name           string
	Bump           uint8
	UsdfVaultBump  uint8
	OtherVaultBump uint8
}

type InstructionType

type InstructionType uint8
const (
	InstructionTypeUnknown InstructionType = iota

	InstructionTypeInitialize
	InstructionTypeSwap
	InstructionTypeTransfer
)

type PoolAccount

type PoolAccount struct {
	Authority      ed25519.PublicKey
	Name           string
	UsdfMint       ed25519.PublicKey
	OtherMint      ed25519.PublicKey
	UsdfVault      ed25519.PublicKey
	OtherVault     ed25519.PublicKey
	Bump           uint8
	UsdfVaultBump  uint8
	OtherVaultBump uint8
	UsdfDecimals   uint8
	OtherDecimals  uint8
}

func (*PoolAccount) String

func (obj *PoolAccount) String() string

func (*PoolAccount) Unmarshal

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

type SwapInstructionAccounts

type SwapInstructionAccounts struct {
	User           ed25519.PublicKey
	Pool           ed25519.PublicKey
	UsdfVault      ed25519.PublicKey
	OtherVault     ed25519.PublicKey
	UserUsdfToken  ed25519.PublicKey
	UserOtherToken ed25519.PublicKey
}

type SwapInstructionArgs

type SwapInstructionArgs struct {
	Amount      uint64
	UsdfToOther bool
}

type TransferInstructionAccounts

type TransferInstructionAccounts struct {
	Authority   ed25519.PublicKey
	Pool        ed25519.PublicKey
	Vault       ed25519.PublicKey
	Destination ed25519.PublicKey
}

type TransferInstructionArgs

type TransferInstructionArgs struct {
	Amount uint64
	IsUsdf bool
}

Jump to

Keyboard shortcuts

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