swap_validator

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostSwapInstructionArgsSize = (1 +
		8 +
		8) // MinToReceive
)
View Source
const (
	PreSwapInstructionArgsSize = 0
)

Variables

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("sWvA66HNNvgamibZe88v3NN5nQwE8tp3KitfViFjukA")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
var (
	SYSTEM_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("11111111111111111111111111111111"))

	SYSVAR_RENT_PUBKEY = ed25519.PublicKey(mustBase58Decode("SysvarRent111111111111111111111111111111111"))
)

Functions

func GetPreSwapStateAddress

func GetPreSwapStateAddress(args *GetPreSwapStateAddressArgs) (ed25519.PublicKey, uint8, error)

Types

type AccountMeta

type AccountMeta struct {
	PublicKey  ed25519.PublicKey
	IsWritable bool
	IsSigner   bool
}

AccountMeta represents the account information required for building transactions.

type GetPreSwapStateAddressArgs

type GetPreSwapStateAddressArgs struct {
	Source      ed25519.PublicKey
	Destination ed25519.PublicKey
	Nonce       ed25519.PublicKey
}

type Instruction

type Instruction struct {
	Program  ed25519.PublicKey
	Accounts []AccountMeta
	Data     []byte
}

Instruction represents a transaction instruction.

func NewPostSwapInstruction

func NewPostSwapInstruction(
	accounts *PostSwapInstructionAccounts,
	args *PostSwapInstructionArgs,
) Instruction

func NewPreSwapInstruction

func NewPreSwapInstruction(
	accounts *PreSwapInstructionAccounts,
	args *PreSwapInstructionArgs,
) Instruction

func (Instruction) ToLegacyInstruction

func (i Instruction) ToLegacyInstruction() solana.Instruction

type PostSwapInstructionAccounts

type PostSwapInstructionAccounts struct {
	PreSwapState ed25519.PublicKey
	Source       ed25519.PublicKey
	Destination  ed25519.PublicKey
	Payer        ed25519.PublicKey
}

type PostSwapInstructionArgs

type PostSwapInstructionArgs struct {
	StateBump    uint8
	MaxToSend    uint64
	MinToReceive uint64
}

type PreSwapInstructionAccounts

type PreSwapInstructionAccounts struct {
	PreSwapState      ed25519.PublicKey
	User              ed25519.PublicKey
	Source            ed25519.PublicKey
	Destination       ed25519.PublicKey
	Nonce             ed25519.PublicKey
	Payer             ed25519.PublicKey
	RemainingAccounts []AccountMeta
}

type PreSwapInstructionArgs

type PreSwapInstructionArgs struct {
}

type SwapValidatorError

type SwapValidatorError uint32
const (
	// Invalid input token amount sent
	InvalidInputTokenAmountSent SwapValidatorError = iota + 0x1770

	// Invalid output token amount received
	InvalidOutputTokenAmountReceived

	// Unexpected writable user account
	UnexpectedWritableUserAccount

	// Unexpected update to user token account
	UnexpectedUserTokenAccountUpdate
)

Jump to

Keyboard shortcuts

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