diff --git a/programs/lifinity_v2/DepositAllTokenTypes.go b/programs/lifinity_v2/DepositAllTokenTypes.go new file mode 100644 index 000000000..56e4f2653 --- /dev/null +++ b/programs/lifinity_v2/DepositAllTokenTypes.go @@ -0,0 +1,344 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// DepositAllTokenTypes is the `depositAllTokenTypes` instruction. +type DepositAllTokenTypes struct { + PoolTokenAmount *uint64 + MaximumTokenAAmount *uint64 + MaximumTokenBAmount *uint64 + + // [0] = [WRITE] amm + // + // [1] = [] authority + // + // [2] = [SIGNER] userTransferAuthorityInfo + // + // [3] = [WRITE] sourceAInfo + // + // [4] = [WRITE] sourceBInfo + // + // [5] = [WRITE] tokenA + // + // [6] = [WRITE] tokenB + // + // [7] = [WRITE] poolMint + // + // [8] = [WRITE] destination + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositAllTokenTypesInstructionBuilder creates a new `DepositAllTokenTypes` instruction builder. +func NewDepositAllTokenTypesInstructionBuilder() *DepositAllTokenTypes { + nd := &DepositAllTokenTypes{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetPoolTokenAmount sets the "poolTokenAmount" parameter. +func (inst *DepositAllTokenTypes) SetPoolTokenAmount(poolTokenAmount uint64) *DepositAllTokenTypes { + inst.PoolTokenAmount = &poolTokenAmount + return inst +} + +// SetMaximumTokenAAmount sets the "maximumTokenAAmount" parameter. +func (inst *DepositAllTokenTypes) SetMaximumTokenAAmount(maximumTokenAAmount uint64) *DepositAllTokenTypes { + inst.MaximumTokenAAmount = &maximumTokenAAmount + return inst +} + +// SetMaximumTokenBAmount sets the "maximumTokenBAmount" parameter. +func (inst *DepositAllTokenTypes) SetMaximumTokenBAmount(maximumTokenBAmount uint64) *DepositAllTokenTypes { + inst.MaximumTokenBAmount = &maximumTokenBAmount + return inst +} + +// SetAmmAccount sets the "amm" account. +func (inst *DepositAllTokenTypes) SetAmmAccount(amm ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[0] = ag_solanago.Meta(amm).WRITE() + return inst +} + +// GetAmmAccount gets the "amm" account. +func (inst *DepositAllTokenTypes) GetAmmAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *DepositAllTokenTypes) SetAuthorityAccount(authority ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *DepositAllTokenTypes) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetUserTransferAuthorityInfoAccount sets the "userTransferAuthorityInfo" account. +func (inst *DepositAllTokenTypes) SetUserTransferAuthorityInfoAccount(userTransferAuthorityInfo ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[2] = ag_solanago.Meta(userTransferAuthorityInfo).SIGNER() + return inst +} + +// GetUserTransferAuthorityInfoAccount gets the "userTransferAuthorityInfo" account. +func (inst *DepositAllTokenTypes) GetUserTransferAuthorityInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetSourceAInfoAccount sets the "sourceAInfo" account. +func (inst *DepositAllTokenTypes) SetSourceAInfoAccount(sourceAInfo ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[3] = ag_solanago.Meta(sourceAInfo).WRITE() + return inst +} + +// GetSourceAInfoAccount gets the "sourceAInfo" account. +func (inst *DepositAllTokenTypes) GetSourceAInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSourceBInfoAccount sets the "sourceBInfo" account. +func (inst *DepositAllTokenTypes) SetSourceBInfoAccount(sourceBInfo ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[4] = ag_solanago.Meta(sourceBInfo).WRITE() + return inst +} + +// GetSourceBInfoAccount gets the "sourceBInfo" account. +func (inst *DepositAllTokenTypes) GetSourceBInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTokenAAccount sets the "tokenA" account. +func (inst *DepositAllTokenTypes) SetTokenAAccount(tokenA ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenA).WRITE() + return inst +} + +// GetTokenAAccount gets the "tokenA" account. +func (inst *DepositAllTokenTypes) GetTokenAAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenBAccount sets the "tokenB" account. +func (inst *DepositAllTokenTypes) SetTokenBAccount(tokenB ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenB).WRITE() + return inst +} + +// GetTokenBAccount gets the "tokenB" account. +func (inst *DepositAllTokenTypes) GetTokenBAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetPoolMintAccount sets the "poolMint" account. +func (inst *DepositAllTokenTypes) SetPoolMintAccount(poolMint ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[7] = ag_solanago.Meta(poolMint).WRITE() + return inst +} + +// GetPoolMintAccount gets the "poolMint" account. +func (inst *DepositAllTokenTypes) GetPoolMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetDestinationAccount sets the "destination" account. +func (inst *DepositAllTokenTypes) SetDestinationAccount(destination ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[8] = ag_solanago.Meta(destination).WRITE() + return inst +} + +// GetDestinationAccount gets the "destination" account. +func (inst *DepositAllTokenTypes) GetDestinationAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *DepositAllTokenTypes) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *DepositAllTokenTypes { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *DepositAllTokenTypes) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst DepositAllTokenTypes) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_DepositAllTokenTypes, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst DepositAllTokenTypes) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *DepositAllTokenTypes) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.PoolTokenAmount == nil { + return errors.New("PoolTokenAmount parameter is not set") + } + if inst.MaximumTokenAAmount == nil { + return errors.New("MaximumTokenAAmount parameter is not set") + } + if inst.MaximumTokenBAmount == nil { + return errors.New("MaximumTokenBAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Amm is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.UserTransferAuthorityInfo is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SourceAInfo is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.SourceBInfo is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenA is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenB is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.PoolMint is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.Destination is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *DepositAllTokenTypes) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("DepositAllTokenTypes")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" PoolTokenAmount", *inst.PoolTokenAmount)) + paramsBranch.Child(ag_format.Param("MaximumTokenAAmount", *inst.MaximumTokenAAmount)) + paramsBranch.Child(ag_format.Param("MaximumTokenBAmount", *inst.MaximumTokenBAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("userTransferAuthorityInfo", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" sourceAInfo", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" sourceBInfo", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" tokenA", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" tokenB", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" poolMint", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" destination", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj DepositAllTokenTypes) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PoolTokenAmount` param: + err = encoder.Encode(obj.PoolTokenAmount) + if err != nil { + return err + } + // Serialize `MaximumTokenAAmount` param: + err = encoder.Encode(obj.MaximumTokenAAmount) + if err != nil { + return err + } + // Serialize `MaximumTokenBAmount` param: + err = encoder.Encode(obj.MaximumTokenBAmount) + if err != nil { + return err + } + return nil +} +func (obj *DepositAllTokenTypes) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PoolTokenAmount`: + err = decoder.Decode(&obj.PoolTokenAmount) + if err != nil { + return err + } + // Deserialize `MaximumTokenAAmount`: + err = decoder.Decode(&obj.MaximumTokenAAmount) + if err != nil { + return err + } + // Deserialize `MaximumTokenBAmount`: + err = decoder.Decode(&obj.MaximumTokenBAmount) + if err != nil { + return err + } + return nil +} + +// NewDepositAllTokenTypesInstruction declares a new DepositAllTokenTypes instruction with the provided parameters and accounts. +func NewDepositAllTokenTypesInstruction( + // Parameters: + poolTokenAmount uint64, + maximumTokenAAmount uint64, + maximumTokenBAmount uint64, + // Accounts: + amm ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + userTransferAuthorityInfo ag_solanago.PublicKey, + sourceAInfo ag_solanago.PublicKey, + sourceBInfo ag_solanago.PublicKey, + tokenA ag_solanago.PublicKey, + tokenB ag_solanago.PublicKey, + poolMint ag_solanago.PublicKey, + destination ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *DepositAllTokenTypes { + return NewDepositAllTokenTypesInstructionBuilder(). + SetPoolTokenAmount(poolTokenAmount). + SetMaximumTokenAAmount(maximumTokenAAmount). + SetMaximumTokenBAmount(maximumTokenBAmount). + SetAmmAccount(amm). + SetAuthorityAccount(authority). + SetUserTransferAuthorityInfoAccount(userTransferAuthorityInfo). + SetSourceAInfoAccount(sourceAInfo). + SetSourceBInfoAccount(sourceBInfo). + SetTokenAAccount(tokenA). + SetTokenBAccount(tokenB). + SetPoolMintAccount(poolMint). + SetDestinationAccount(destination). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/lifinity_v2/DepositAllTokenTypes_test.go b/programs/lifinity_v2/DepositAllTokenTypes_test.go new file mode 100644 index 000000000..2c06278fe --- /dev/null +++ b/programs/lifinity_v2/DepositAllTokenTypes_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_DepositAllTokenTypes(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("DepositAllTokenTypes"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(DepositAllTokenTypes) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(DepositAllTokenTypes) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/lifinity_v2/Swap.go b/programs/lifinity_v2/Swap.go new file mode 100644 index 000000000..60518204f --- /dev/null +++ b/programs/lifinity_v2/Swap.go @@ -0,0 +1,378 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Swap is the `swap` instruction. +type Swap struct { + AmountIn *uint64 + MinimumAmountOut *uint64 + + // [0] = [] authority + // + // [1] = [WRITE] amm + // + // [2] = [SIGNER] userTransferAuthority + // + // [3] = [WRITE] sourceInfo + // + // [4] = [WRITE] destinationInfo + // + // [5] = [WRITE] swapSource + // + // [6] = [WRITE] swapDestination + // + // [7] = [WRITE] poolMint + // + // [8] = [WRITE] feeAccount + // + // [9] = [] tokenProgram + // + // [10] = [] oracleMainAccount + // + // [11] = [] oracleSubAccount + // + // [12] = [] oraclePcAccount + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSwapInstructionBuilder creates a new `Swap` instruction builder. +func NewSwapInstructionBuilder() *Swap { + nd := &Swap{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13), + } + return nd +} + +// SetAmountIn sets the "amountIn" parameter. +func (inst *Swap) SetAmountIn(amountIn uint64) *Swap { + inst.AmountIn = &amountIn + return inst +} + +// SetMinimumAmountOut sets the "minimumAmountOut" parameter. +func (inst *Swap) SetMinimumAmountOut(minimumAmountOut uint64) *Swap { + inst.MinimumAmountOut = &minimumAmountOut + return inst +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Swap) SetAuthorityAccount(authority ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[0] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Swap) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAmmAccount sets the "amm" account. +func (inst *Swap) SetAmmAccount(amm ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[1] = ag_solanago.Meta(amm).WRITE() + return inst +} + +// GetAmmAccount gets the "amm" account. +func (inst *Swap) GetAmmAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetUserTransferAuthorityAccount sets the "userTransferAuthority" account. +func (inst *Swap) SetUserTransferAuthorityAccount(userTransferAuthority ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[2] = ag_solanago.Meta(userTransferAuthority).SIGNER() + return inst +} + +// GetUserTransferAuthorityAccount gets the "userTransferAuthority" account. +func (inst *Swap) GetUserTransferAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetSourceInfoAccount sets the "sourceInfo" account. +func (inst *Swap) SetSourceInfoAccount(sourceInfo ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[3] = ag_solanago.Meta(sourceInfo).WRITE() + return inst +} + +// GetSourceInfoAccount gets the "sourceInfo" account. +func (inst *Swap) GetSourceInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetDestinationInfoAccount sets the "destinationInfo" account. +func (inst *Swap) SetDestinationInfoAccount(destinationInfo ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[4] = ag_solanago.Meta(destinationInfo).WRITE() + return inst +} + +// GetDestinationInfoAccount gets the "destinationInfo" account. +func (inst *Swap) GetDestinationInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetSwapSourceAccount sets the "swapSource" account. +func (inst *Swap) SetSwapSourceAccount(swapSource ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[5] = ag_solanago.Meta(swapSource).WRITE() + return inst +} + +// GetSwapSourceAccount gets the "swapSource" account. +func (inst *Swap) GetSwapSourceAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetSwapDestinationAccount sets the "swapDestination" account. +func (inst *Swap) SetSwapDestinationAccount(swapDestination ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[6] = ag_solanago.Meta(swapDestination).WRITE() + return inst +} + +// GetSwapDestinationAccount gets the "swapDestination" account. +func (inst *Swap) GetSwapDestinationAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetPoolMintAccount sets the "poolMint" account. +func (inst *Swap) SetPoolMintAccount(poolMint ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[7] = ag_solanago.Meta(poolMint).WRITE() + return inst +} + +// GetPoolMintAccount gets the "poolMint" account. +func (inst *Swap) GetPoolMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetFeeAccountAccount sets the "feeAccount" account. +func (inst *Swap) SetFeeAccountAccount(feeAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[8] = ag_solanago.Meta(feeAccount).WRITE() + return inst +} + +// GetFeeAccountAccount gets the "feeAccount" account. +func (inst *Swap) GetFeeAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Swap) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Swap) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetOracleMainAccountAccount sets the "oracleMainAccount" account. +func (inst *Swap) SetOracleMainAccountAccount(oracleMainAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[10] = ag_solanago.Meta(oracleMainAccount) + return inst +} + +// GetOracleMainAccountAccount gets the "oracleMainAccount" account. +func (inst *Swap) GetOracleMainAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetOracleSubAccountAccount sets the "oracleSubAccount" account. +func (inst *Swap) SetOracleSubAccountAccount(oracleSubAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[11] = ag_solanago.Meta(oracleSubAccount) + return inst +} + +// GetOracleSubAccountAccount gets the "oracleSubAccount" account. +func (inst *Swap) GetOracleSubAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetOraclePcAccountAccount sets the "oraclePcAccount" account. +func (inst *Swap) SetOraclePcAccountAccount(oraclePcAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[12] = ag_solanago.Meta(oraclePcAccount) + return inst +} + +// GetOraclePcAccountAccount gets the "oraclePcAccount" account. +func (inst *Swap) GetOraclePcAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +func (inst Swap) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Swap, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Swap) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Swap) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.AmountIn == nil { + return errors.New("AmountIn parameter is not set") + } + if inst.MinimumAmountOut == nil { + return errors.New("MinimumAmountOut parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Amm is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.UserTransferAuthority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SourceInfo is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.DestinationInfo is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SwapSource is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.SwapDestination is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.PoolMint is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.FeeAccount is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.OracleMainAccount is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.OracleSubAccount is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.OraclePcAccount is not set") + } + } + return nil +} + +func (inst *Swap) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Swap")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" AmountIn", *inst.AmountIn)) + paramsBranch.Child(ag_format.Param("MinimumAmountOut", *inst.MinimumAmountOut)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("userTransferAuthority", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" sourceInfo", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" destinationInfo", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" swapSource", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" swapDestination", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" poolMint", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" fee", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" oracleMain", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" oracleSub", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" oraclePc", inst.AccountMetaSlice.Get(12))) + }) + }) + }) +} + +func (obj Swap) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `AmountIn` param: + err = encoder.Encode(obj.AmountIn) + if err != nil { + return err + } + // Serialize `MinimumAmountOut` param: + err = encoder.Encode(obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} +func (obj *Swap) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `AmountIn`: + err = decoder.Decode(&obj.AmountIn) + if err != nil { + return err + } + // Deserialize `MinimumAmountOut`: + err = decoder.Decode(&obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} + +// NewSwapInstruction declares a new Swap instruction with the provided parameters and accounts. +func NewSwapInstruction( + // Parameters: + amountIn uint64, + minimumAmountOut uint64, + // Accounts: + authority ag_solanago.PublicKey, + amm ag_solanago.PublicKey, + userTransferAuthority ag_solanago.PublicKey, + sourceInfo ag_solanago.PublicKey, + destinationInfo ag_solanago.PublicKey, + swapSource ag_solanago.PublicKey, + swapDestination ag_solanago.PublicKey, + poolMint ag_solanago.PublicKey, + feeAccount ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + oracleMainAccount ag_solanago.PublicKey, + oracleSubAccount ag_solanago.PublicKey, + oraclePcAccount ag_solanago.PublicKey) *Swap { + return NewSwapInstructionBuilder(). + SetAmountIn(amountIn). + SetMinimumAmountOut(minimumAmountOut). + SetAuthorityAccount(authority). + SetAmmAccount(amm). + SetUserTransferAuthorityAccount(userTransferAuthority). + SetSourceInfoAccount(sourceInfo). + SetDestinationInfoAccount(destinationInfo). + SetSwapSourceAccount(swapSource). + SetSwapDestinationAccount(swapDestination). + SetPoolMintAccount(poolMint). + SetFeeAccountAccount(feeAccount). + SetTokenProgramAccount(tokenProgram). + SetOracleMainAccountAccount(oracleMainAccount). + SetOracleSubAccountAccount(oracleSubAccount). + SetOraclePcAccountAccount(oraclePcAccount) +} diff --git a/programs/raydiumclmm/Swap_test.go b/programs/lifinity_v2/Swap_test.go similarity index 97% rename from programs/raydiumclmm/Swap_test.go rename to programs/lifinity_v2/Swap_test.go index 3272fdc00..318f23849 100644 --- a/programs/raydiumclmm/Swap_test.go +++ b/programs/lifinity_v2/Swap_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package lifinity_v2 import ( "bytes" diff --git a/programs/lifinity_v2/WithdrawAllTokenTypes.go b/programs/lifinity_v2/WithdrawAllTokenTypes.go new file mode 100644 index 000000000..8c66e7631 --- /dev/null +++ b/programs/lifinity_v2/WithdrawAllTokenTypes.go @@ -0,0 +1,344 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// WithdrawAllTokenTypes is the `withdrawAllTokenTypes` instruction. +type WithdrawAllTokenTypes struct { + PoolTokenAmount *uint64 + MinimumTokenAAmount *uint64 + MinimumTokenBAmount *uint64 + + // [0] = [WRITE] amm + // + // [1] = [] authority + // + // [2] = [SIGNER] userTransferAuthorityInfo + // + // [3] = [WRITE] sourceInfo + // + // [4] = [WRITE] tokenA + // + // [5] = [WRITE] tokenB + // + // [6] = [WRITE] poolMint + // + // [7] = [WRITE] destTokenAInfo + // + // [8] = [WRITE] destTokenBInfo + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawAllTokenTypesInstructionBuilder creates a new `WithdrawAllTokenTypes` instruction builder. +func NewWithdrawAllTokenTypesInstructionBuilder() *WithdrawAllTokenTypes { + nd := &WithdrawAllTokenTypes{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetPoolTokenAmount sets the "poolTokenAmount" parameter. +func (inst *WithdrawAllTokenTypes) SetPoolTokenAmount(poolTokenAmount uint64) *WithdrawAllTokenTypes { + inst.PoolTokenAmount = &poolTokenAmount + return inst +} + +// SetMinimumTokenAAmount sets the "minimumTokenAAmount" parameter. +func (inst *WithdrawAllTokenTypes) SetMinimumTokenAAmount(minimumTokenAAmount uint64) *WithdrawAllTokenTypes { + inst.MinimumTokenAAmount = &minimumTokenAAmount + return inst +} + +// SetMinimumTokenBAmount sets the "minimumTokenBAmount" parameter. +func (inst *WithdrawAllTokenTypes) SetMinimumTokenBAmount(minimumTokenBAmount uint64) *WithdrawAllTokenTypes { + inst.MinimumTokenBAmount = &minimumTokenBAmount + return inst +} + +// SetAmmAccount sets the "amm" account. +func (inst *WithdrawAllTokenTypes) SetAmmAccount(amm ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[0] = ag_solanago.Meta(amm).WRITE() + return inst +} + +// GetAmmAccount gets the "amm" account. +func (inst *WithdrawAllTokenTypes) GetAmmAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *WithdrawAllTokenTypes) SetAuthorityAccount(authority ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *WithdrawAllTokenTypes) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetUserTransferAuthorityInfoAccount sets the "userTransferAuthorityInfo" account. +func (inst *WithdrawAllTokenTypes) SetUserTransferAuthorityInfoAccount(userTransferAuthorityInfo ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[2] = ag_solanago.Meta(userTransferAuthorityInfo).SIGNER() + return inst +} + +// GetUserTransferAuthorityInfoAccount gets the "userTransferAuthorityInfo" account. +func (inst *WithdrawAllTokenTypes) GetUserTransferAuthorityInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetSourceInfoAccount sets the "sourceInfo" account. +func (inst *WithdrawAllTokenTypes) SetSourceInfoAccount(sourceInfo ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[3] = ag_solanago.Meta(sourceInfo).WRITE() + return inst +} + +// GetSourceInfoAccount gets the "sourceInfo" account. +func (inst *WithdrawAllTokenTypes) GetSourceInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetTokenAAccount sets the "tokenA" account. +func (inst *WithdrawAllTokenTypes) SetTokenAAccount(tokenA ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[4] = ag_solanago.Meta(tokenA).WRITE() + return inst +} + +// GetTokenAAccount gets the "tokenA" account. +func (inst *WithdrawAllTokenTypes) GetTokenAAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTokenBAccount sets the "tokenB" account. +func (inst *WithdrawAllTokenTypes) SetTokenBAccount(tokenB ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenB).WRITE() + return inst +} + +// GetTokenBAccount gets the "tokenB" account. +func (inst *WithdrawAllTokenTypes) GetTokenBAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetPoolMintAccount sets the "poolMint" account. +func (inst *WithdrawAllTokenTypes) SetPoolMintAccount(poolMint ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[6] = ag_solanago.Meta(poolMint).WRITE() + return inst +} + +// GetPoolMintAccount gets the "poolMint" account. +func (inst *WithdrawAllTokenTypes) GetPoolMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetDestTokenAInfoAccount sets the "destTokenAInfo" account. +func (inst *WithdrawAllTokenTypes) SetDestTokenAInfoAccount(destTokenAInfo ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[7] = ag_solanago.Meta(destTokenAInfo).WRITE() + return inst +} + +// GetDestTokenAInfoAccount gets the "destTokenAInfo" account. +func (inst *WithdrawAllTokenTypes) GetDestTokenAInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetDestTokenBInfoAccount sets the "destTokenBInfo" account. +func (inst *WithdrawAllTokenTypes) SetDestTokenBInfoAccount(destTokenBInfo ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[8] = ag_solanago.Meta(destTokenBInfo).WRITE() + return inst +} + +// GetDestTokenBInfoAccount gets the "destTokenBInfo" account. +func (inst *WithdrawAllTokenTypes) GetDestTokenBInfoAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *WithdrawAllTokenTypes) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *WithdrawAllTokenTypes { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *WithdrawAllTokenTypes) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst WithdrawAllTokenTypes) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_WithdrawAllTokenTypes, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst WithdrawAllTokenTypes) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *WithdrawAllTokenTypes) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.PoolTokenAmount == nil { + return errors.New("PoolTokenAmount parameter is not set") + } + if inst.MinimumTokenAAmount == nil { + return errors.New("MinimumTokenAAmount parameter is not set") + } + if inst.MinimumTokenBAmount == nil { + return errors.New("MinimumTokenBAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Amm is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.UserTransferAuthorityInfo is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SourceInfo is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.TokenA is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenB is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.PoolMint is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.DestTokenAInfo is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.DestTokenBInfo is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *WithdrawAllTokenTypes) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("WithdrawAllTokenTypes")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" PoolTokenAmount", *inst.PoolTokenAmount)) + paramsBranch.Child(ag_format.Param("MinimumTokenAAmount", *inst.MinimumTokenAAmount)) + paramsBranch.Child(ag_format.Param("MinimumTokenBAmount", *inst.MinimumTokenBAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("userTransferAuthorityInfo", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" sourceInfo", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" tokenA", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" tokenB", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" poolMint", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" destTokenAInfo", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" destTokenBInfo", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj WithdrawAllTokenTypes) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PoolTokenAmount` param: + err = encoder.Encode(obj.PoolTokenAmount) + if err != nil { + return err + } + // Serialize `MinimumTokenAAmount` param: + err = encoder.Encode(obj.MinimumTokenAAmount) + if err != nil { + return err + } + // Serialize `MinimumTokenBAmount` param: + err = encoder.Encode(obj.MinimumTokenBAmount) + if err != nil { + return err + } + return nil +} +func (obj *WithdrawAllTokenTypes) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PoolTokenAmount`: + err = decoder.Decode(&obj.PoolTokenAmount) + if err != nil { + return err + } + // Deserialize `MinimumTokenAAmount`: + err = decoder.Decode(&obj.MinimumTokenAAmount) + if err != nil { + return err + } + // Deserialize `MinimumTokenBAmount`: + err = decoder.Decode(&obj.MinimumTokenBAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawAllTokenTypesInstruction declares a new WithdrawAllTokenTypes instruction with the provided parameters and accounts. +func NewWithdrawAllTokenTypesInstruction( + // Parameters: + poolTokenAmount uint64, + minimumTokenAAmount uint64, + minimumTokenBAmount uint64, + // Accounts: + amm ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + userTransferAuthorityInfo ag_solanago.PublicKey, + sourceInfo ag_solanago.PublicKey, + tokenA ag_solanago.PublicKey, + tokenB ag_solanago.PublicKey, + poolMint ag_solanago.PublicKey, + destTokenAInfo ag_solanago.PublicKey, + destTokenBInfo ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *WithdrawAllTokenTypes { + return NewWithdrawAllTokenTypesInstructionBuilder(). + SetPoolTokenAmount(poolTokenAmount). + SetMinimumTokenAAmount(minimumTokenAAmount). + SetMinimumTokenBAmount(minimumTokenBAmount). + SetAmmAccount(amm). + SetAuthorityAccount(authority). + SetUserTransferAuthorityInfoAccount(userTransferAuthorityInfo). + SetSourceInfoAccount(sourceInfo). + SetTokenAAccount(tokenA). + SetTokenBAccount(tokenB). + SetPoolMintAccount(poolMint). + SetDestTokenAInfoAccount(destTokenAInfo). + SetDestTokenBInfoAccount(destTokenBInfo). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/lifinity_v2/WithdrawAllTokenTypes_test.go b/programs/lifinity_v2/WithdrawAllTokenTypes_test.go new file mode 100644 index 000000000..13a2e81a3 --- /dev/null +++ b/programs/lifinity_v2/WithdrawAllTokenTypes_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_WithdrawAllTokenTypes(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("WithdrawAllTokenTypes"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(WithdrawAllTokenTypes) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(WithdrawAllTokenTypes) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/lifinity_v2/accounts.go b/programs/lifinity_v2/accounts.go new file mode 100644 index 000000000..dde05be4b --- /dev/null +++ b/programs/lifinity_v2/accounts.go @@ -0,0 +1,407 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type Amm struct { + InitializerKey ag_solanago.PublicKey + InitializerDepositTokenAccount ag_solanago.PublicKey + InitializerReceiveTokenAccount ag_solanago.PublicKey + InitializerAmount uint64 + TakerAmount uint64 + + // Is the swap initialized, with data written to it + IsInitialized bool + + // Bump seed used to generate the program address / authority + BumpSeed uint8 + + // Freeze swap + FreezeTrade uint8 + + // Freeze deposit + FreezeDeposit uint8 + + // Freeze withdraw + FreezeWithdraw uint8 + + // Base decimals account + BaseDecimals uint8 + + // Token program ID associated with the swap + TokenProgramId ag_solanago.PublicKey + + // Address of token A liquidity account + TokenAAccount ag_solanago.PublicKey + + // Address of token B liquidity account + TokenBAccount ag_solanago.PublicKey + + // Address of pool token mint + PoolMint ag_solanago.PublicKey + + // Address of token A mint + TokenAMint ag_solanago.PublicKey + + // Address of token B mint + TokenBMint ag_solanago.PublicKey + + // Address of pool fee account + FeeAccount ag_solanago.PublicKey + + // Oracle Main account + OracleMainAccount ag_solanago.PublicKey + + // Oracle Sub account + OracleSubAccount ag_solanago.PublicKey + + // oracle Pc account + OraclePcAccount ag_solanago.PublicKey + + // Fees associated with swap + Fees AmmFees + + // Curve associated with swap + Curve AmmCurve + + // Curve associated with swap + Config AmmConfig + + // Temp area + AmmPTemp1 ag_solanago.PublicKey + + // Temp area + AmmPTemp2 ag_solanago.PublicKey + + // Temp area + AmmPTemp3 ag_solanago.PublicKey + + // Temp area + AmmPTemp4 ag_solanago.PublicKey + + // Temp area + AmmPTemp5 ag_solanago.PublicKey +} + +var AmmDiscriminator = [8]byte{143, 245, 200, 17, 74, 214, 196, 135} + +func (obj Amm) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(AmmDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `InitializerKey` param: + err = encoder.Encode(obj.InitializerKey) + if err != nil { + return err + } + // Serialize `InitializerDepositTokenAccount` param: + err = encoder.Encode(obj.InitializerDepositTokenAccount) + if err != nil { + return err + } + // Serialize `InitializerReceiveTokenAccount` param: + err = encoder.Encode(obj.InitializerReceiveTokenAccount) + if err != nil { + return err + } + // Serialize `InitializerAmount` param: + err = encoder.Encode(obj.InitializerAmount) + if err != nil { + return err + } + // Serialize `TakerAmount` param: + err = encoder.Encode(obj.TakerAmount) + if err != nil { + return err + } + // Serialize `IsInitialized` param: + err = encoder.Encode(obj.IsInitialized) + if err != nil { + return err + } + // Serialize `BumpSeed` param: + err = encoder.Encode(obj.BumpSeed) + if err != nil { + return err + } + // Serialize `FreezeTrade` param: + err = encoder.Encode(obj.FreezeTrade) + if err != nil { + return err + } + // Serialize `FreezeDeposit` param: + err = encoder.Encode(obj.FreezeDeposit) + if err != nil { + return err + } + // Serialize `FreezeWithdraw` param: + err = encoder.Encode(obj.FreezeWithdraw) + if err != nil { + return err + } + // Serialize `BaseDecimals` param: + err = encoder.Encode(obj.BaseDecimals) + if err != nil { + return err + } + // Serialize `TokenProgramId` param: + err = encoder.Encode(obj.TokenProgramId) + if err != nil { + return err + } + // Serialize `TokenAAccount` param: + err = encoder.Encode(obj.TokenAAccount) + if err != nil { + return err + } + // Serialize `TokenBAccount` param: + err = encoder.Encode(obj.TokenBAccount) + if err != nil { + return err + } + // Serialize `PoolMint` param: + err = encoder.Encode(obj.PoolMint) + if err != nil { + return err + } + // Serialize `TokenAMint` param: + err = encoder.Encode(obj.TokenAMint) + if err != nil { + return err + } + // Serialize `TokenBMint` param: + err = encoder.Encode(obj.TokenBMint) + if err != nil { + return err + } + // Serialize `FeeAccount` param: + err = encoder.Encode(obj.FeeAccount) + if err != nil { + return err + } + // Serialize `OracleMainAccount` param: + err = encoder.Encode(obj.OracleMainAccount) + if err != nil { + return err + } + // Serialize `OracleSubAccount` param: + err = encoder.Encode(obj.OracleSubAccount) + if err != nil { + return err + } + // Serialize `OraclePcAccount` param: + err = encoder.Encode(obj.OraclePcAccount) + if err != nil { + return err + } + // Serialize `Fees` param: + err = encoder.Encode(obj.Fees) + if err != nil { + return err + } + // Serialize `Curve` param: + err = encoder.Encode(obj.Curve) + if err != nil { + return err + } + // Serialize `Config` param: + err = encoder.Encode(obj.Config) + if err != nil { + return err + } + // Serialize `AmmPTemp1` param: + err = encoder.Encode(obj.AmmPTemp1) + if err != nil { + return err + } + // Serialize `AmmPTemp2` param: + err = encoder.Encode(obj.AmmPTemp2) + if err != nil { + return err + } + // Serialize `AmmPTemp3` param: + err = encoder.Encode(obj.AmmPTemp3) + if err != nil { + return err + } + // Serialize `AmmPTemp4` param: + err = encoder.Encode(obj.AmmPTemp4) + if err != nil { + return err + } + // Serialize `AmmPTemp5` param: + err = encoder.Encode(obj.AmmPTemp5) + if err != nil { + return err + } + return nil +} + +func (obj *Amm) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(AmmDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[143 245 200 17 74 214 196 135]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `InitializerKey`: + err = decoder.Decode(&obj.InitializerKey) + if err != nil { + return err + } + // Deserialize `InitializerDepositTokenAccount`: + err = decoder.Decode(&obj.InitializerDepositTokenAccount) + if err != nil { + return err + } + // Deserialize `InitializerReceiveTokenAccount`: + err = decoder.Decode(&obj.InitializerReceiveTokenAccount) + if err != nil { + return err + } + // Deserialize `InitializerAmount`: + err = decoder.Decode(&obj.InitializerAmount) + if err != nil { + return err + } + // Deserialize `TakerAmount`: + err = decoder.Decode(&obj.TakerAmount) + if err != nil { + return err + } + // Deserialize `IsInitialized`: + err = decoder.Decode(&obj.IsInitialized) + if err != nil { + return err + } + // Deserialize `BumpSeed`: + err = decoder.Decode(&obj.BumpSeed) + if err != nil { + return err + } + // Deserialize `FreezeTrade`: + err = decoder.Decode(&obj.FreezeTrade) + if err != nil { + return err + } + // Deserialize `FreezeDeposit`: + err = decoder.Decode(&obj.FreezeDeposit) + if err != nil { + return err + } + // Deserialize `FreezeWithdraw`: + err = decoder.Decode(&obj.FreezeWithdraw) + if err != nil { + return err + } + // Deserialize `BaseDecimals`: + err = decoder.Decode(&obj.BaseDecimals) + if err != nil { + return err + } + // Deserialize `TokenProgramId`: + err = decoder.Decode(&obj.TokenProgramId) + if err != nil { + return err + } + // Deserialize `TokenAAccount`: + err = decoder.Decode(&obj.TokenAAccount) + if err != nil { + return err + } + // Deserialize `TokenBAccount`: + err = decoder.Decode(&obj.TokenBAccount) + if err != nil { + return err + } + // Deserialize `PoolMint`: + err = decoder.Decode(&obj.PoolMint) + if err != nil { + return err + } + // Deserialize `TokenAMint`: + err = decoder.Decode(&obj.TokenAMint) + if err != nil { + return err + } + // Deserialize `TokenBMint`: + err = decoder.Decode(&obj.TokenBMint) + if err != nil { + return err + } + // Deserialize `FeeAccount`: + err = decoder.Decode(&obj.FeeAccount) + if err != nil { + return err + } + // Deserialize `OracleMainAccount`: + err = decoder.Decode(&obj.OracleMainAccount) + if err != nil { + return err + } + // Deserialize `OracleSubAccount`: + err = decoder.Decode(&obj.OracleSubAccount) + if err != nil { + return err + } + // Deserialize `OraclePcAccount`: + err = decoder.Decode(&obj.OraclePcAccount) + if err != nil { + return err + } + // Deserialize `Fees`: + err = decoder.Decode(&obj.Fees) + if err != nil { + return err + } + // Deserialize `Curve`: + err = decoder.Decode(&obj.Curve) + if err != nil { + return err + } + // Deserialize `Config`: + err = decoder.Decode(&obj.Config) + if err != nil { + return err + } + // Deserialize `AmmPTemp1`: + err = decoder.Decode(&obj.AmmPTemp1) + if err != nil { + return err + } + // Deserialize `AmmPTemp2`: + err = decoder.Decode(&obj.AmmPTemp2) + if err != nil { + return err + } + // Deserialize `AmmPTemp3`: + err = decoder.Decode(&obj.AmmPTemp3) + if err != nil { + return err + } + // Deserialize `AmmPTemp4`: + err = decoder.Decode(&obj.AmmPTemp4) + if err != nil { + return err + } + // Deserialize `AmmPTemp5`: + err = decoder.Decode(&obj.AmmPTemp5) + if err != nil { + return err + } + return nil +} diff --git a/programs/lifinity_v2/instructions.go b/programs/lifinity_v2/instructions.go new file mode 100644 index 000000000..0d6feca8e --- /dev/null +++ b/programs/lifinity_v2/instructions.go @@ -0,0 +1,131 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("2wT8Yq49kHgDzXuPxZSaeLaH1qbmGXtEyPy64bL7aD3c") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "LifinityV2" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + Instruction_Swap = ag_binary.TypeID([8]byte{248, 198, 158, 145, 225, 117, 135, 200}) + + Instruction_DepositAllTokenTypes = ag_binary.TypeID([8]byte{32, 95, 69, 60, 75, 79, 205, 238}) + + Instruction_WithdrawAllTokenTypes = ag_binary.TypeID([8]byte{189, 254, 156, 174, 210, 9, 164, 216}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_Swap: + return "Swap" + case Instruction_DepositAllTokenTypes: + return "DepositAllTokenTypes" + case Instruction_WithdrawAllTokenTypes: + return "WithdrawAllTokenTypes" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "swap", (*Swap)(nil), + }, + { + "deposit_all_token_types", (*DepositAllTokenTypes)(nil), + }, + { + "withdraw_all_token_types", (*WithdrawAllTokenTypes)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/lifinity_v2/testing_utils.go b/programs/lifinity_v2/testing_utils.go new file mode 100644 index 000000000..2ca9b318d --- /dev/null +++ b/programs/lifinity_v2/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/lifinity_v2/types.go b/programs/lifinity_v2/types.go new file mode 100644 index 000000000..49519cc84 --- /dev/null +++ b/programs/lifinity_v2/types.go @@ -0,0 +1,485 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package lifinity_v2 + +import ag_binary "github.com/gagliardetto/binary" + +type AmmFees struct { + TradeFeeNumerator uint64 + TradeFeeDenominator uint64 + OwnerTradeFeeNumerator uint64 + OwnerTradeFeeDenominator uint64 + OwnerWithdrawFeeNumerator uint64 + OwnerWithdrawFeeDenominator uint64 + HostFeeNumerator uint64 + HostFeeDenominator uint64 +} + +func (obj AmmFees) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `TradeFeeNumerator` param: + err = encoder.Encode(obj.TradeFeeNumerator) + if err != nil { + return err + } + // Serialize `TradeFeeDenominator` param: + err = encoder.Encode(obj.TradeFeeDenominator) + if err != nil { + return err + } + // Serialize `OwnerTradeFeeNumerator` param: + err = encoder.Encode(obj.OwnerTradeFeeNumerator) + if err != nil { + return err + } + // Serialize `OwnerTradeFeeDenominator` param: + err = encoder.Encode(obj.OwnerTradeFeeDenominator) + if err != nil { + return err + } + // Serialize `OwnerWithdrawFeeNumerator` param: + err = encoder.Encode(obj.OwnerWithdrawFeeNumerator) + if err != nil { + return err + } + // Serialize `OwnerWithdrawFeeDenominator` param: + err = encoder.Encode(obj.OwnerWithdrawFeeDenominator) + if err != nil { + return err + } + // Serialize `HostFeeNumerator` param: + err = encoder.Encode(obj.HostFeeNumerator) + if err != nil { + return err + } + // Serialize `HostFeeDenominator` param: + err = encoder.Encode(obj.HostFeeDenominator) + if err != nil { + return err + } + return nil +} + +func (obj *AmmFees) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `TradeFeeNumerator`: + err = decoder.Decode(&obj.TradeFeeNumerator) + if err != nil { + return err + } + // Deserialize `TradeFeeDenominator`: + err = decoder.Decode(&obj.TradeFeeDenominator) + if err != nil { + return err + } + // Deserialize `OwnerTradeFeeNumerator`: + err = decoder.Decode(&obj.OwnerTradeFeeNumerator) + if err != nil { + return err + } + // Deserialize `OwnerTradeFeeDenominator`: + err = decoder.Decode(&obj.OwnerTradeFeeDenominator) + if err != nil { + return err + } + // Deserialize `OwnerWithdrawFeeNumerator`: + err = decoder.Decode(&obj.OwnerWithdrawFeeNumerator) + if err != nil { + return err + } + // Deserialize `OwnerWithdrawFeeDenominator`: + err = decoder.Decode(&obj.OwnerWithdrawFeeDenominator) + if err != nil { + return err + } + // Deserialize `HostFeeNumerator`: + err = decoder.Decode(&obj.HostFeeNumerator) + if err != nil { + return err + } + // Deserialize `HostFeeDenominator`: + err = decoder.Decode(&obj.HostFeeDenominator) + if err != nil { + return err + } + return nil +} + +type AmmCurve struct { + CurveType uint8 + CurveParameters uint64 +} + +func (obj AmmCurve) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `CurveType` param: + err = encoder.Encode(obj.CurveType) + if err != nil { + return err + } + // Serialize `CurveParameters` param: + err = encoder.Encode(obj.CurveParameters) + if err != nil { + return err + } + return nil +} + +func (obj *AmmCurve) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `CurveType`: + err = decoder.Decode(&obj.CurveType) + if err != nil { + return err + } + // Deserialize `CurveParameters`: + err = decoder.Decode(&obj.CurveParameters) + if err != nil { + return err + } + return nil +} + +type AmmConfig struct { + LastPrice uint64 + LastBalancedPrice uint64 + ConfigDenominator uint64 + VolumeX uint64 + VolumeY uint64 + VolumeXInY uint64 + DepositCap uint64 + RegressionTarget uint64 + OracleType uint64 + OracleStatus uint64 + OracleMainSlotLimit uint64 + OracleSubConfidenceLimit uint64 + OracleSubSlotLimit uint64 + OraclePcConfidenceLimit uint64 + OraclePcSlotLimit uint64 + StdSpread uint64 + StdSpreadBuffer uint64 + SpreadCoefficient uint64 + PriceBufferCoin int64 + PriceBufferPc int64 + RebalanceRatio uint64 + FeeTrade uint64 + FeePlatform uint64 + OracleMainSlotBuffer uint64 + ConfigTemp4 uint64 + ConfigTemp5 uint64 + ConfigTemp6 uint64 + ConfigTemp7 uint64 + ConfigTemp8 uint64 +} + +func (obj AmmConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `LastPrice` param: + err = encoder.Encode(obj.LastPrice) + if err != nil { + return err + } + // Serialize `LastBalancedPrice` param: + err = encoder.Encode(obj.LastBalancedPrice) + if err != nil { + return err + } + // Serialize `ConfigDenominator` param: + err = encoder.Encode(obj.ConfigDenominator) + if err != nil { + return err + } + // Serialize `VolumeX` param: + err = encoder.Encode(obj.VolumeX) + if err != nil { + return err + } + // Serialize `VolumeY` param: + err = encoder.Encode(obj.VolumeY) + if err != nil { + return err + } + // Serialize `VolumeXInY` param: + err = encoder.Encode(obj.VolumeXInY) + if err != nil { + return err + } + // Serialize `DepositCap` param: + err = encoder.Encode(obj.DepositCap) + if err != nil { + return err + } + // Serialize `RegressionTarget` param: + err = encoder.Encode(obj.RegressionTarget) + if err != nil { + return err + } + // Serialize `OracleType` param: + err = encoder.Encode(obj.OracleType) + if err != nil { + return err + } + // Serialize `OracleStatus` param: + err = encoder.Encode(obj.OracleStatus) + if err != nil { + return err + } + // Serialize `OracleMainSlotLimit` param: + err = encoder.Encode(obj.OracleMainSlotLimit) + if err != nil { + return err + } + // Serialize `OracleSubConfidenceLimit` param: + err = encoder.Encode(obj.OracleSubConfidenceLimit) + if err != nil { + return err + } + // Serialize `OracleSubSlotLimit` param: + err = encoder.Encode(obj.OracleSubSlotLimit) + if err != nil { + return err + } + // Serialize `OraclePcConfidenceLimit` param: + err = encoder.Encode(obj.OraclePcConfidenceLimit) + if err != nil { + return err + } + // Serialize `OraclePcSlotLimit` param: + err = encoder.Encode(obj.OraclePcSlotLimit) + if err != nil { + return err + } + // Serialize `StdSpread` param: + err = encoder.Encode(obj.StdSpread) + if err != nil { + return err + } + // Serialize `StdSpreadBuffer` param: + err = encoder.Encode(obj.StdSpreadBuffer) + if err != nil { + return err + } + // Serialize `SpreadCoefficient` param: + err = encoder.Encode(obj.SpreadCoefficient) + if err != nil { + return err + } + // Serialize `PriceBufferCoin` param: + err = encoder.Encode(obj.PriceBufferCoin) + if err != nil { + return err + } + // Serialize `PriceBufferPc` param: + err = encoder.Encode(obj.PriceBufferPc) + if err != nil { + return err + } + // Serialize `RebalanceRatio` param: + err = encoder.Encode(obj.RebalanceRatio) + if err != nil { + return err + } + // Serialize `FeeTrade` param: + err = encoder.Encode(obj.FeeTrade) + if err != nil { + return err + } + // Serialize `FeePlatform` param: + err = encoder.Encode(obj.FeePlatform) + if err != nil { + return err + } + // Serialize `OracleMainSlotBuffer` param: + err = encoder.Encode(obj.OracleMainSlotBuffer) + if err != nil { + return err + } + // Serialize `ConfigTemp4` param: + err = encoder.Encode(obj.ConfigTemp4) + if err != nil { + return err + } + // Serialize `ConfigTemp5` param: + err = encoder.Encode(obj.ConfigTemp5) + if err != nil { + return err + } + // Serialize `ConfigTemp6` param: + err = encoder.Encode(obj.ConfigTemp6) + if err != nil { + return err + } + // Serialize `ConfigTemp7` param: + err = encoder.Encode(obj.ConfigTemp7) + if err != nil { + return err + } + // Serialize `ConfigTemp8` param: + err = encoder.Encode(obj.ConfigTemp8) + if err != nil { + return err + } + return nil +} + +func (obj *AmmConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `LastPrice`: + err = decoder.Decode(&obj.LastPrice) + if err != nil { + return err + } + // Deserialize `LastBalancedPrice`: + err = decoder.Decode(&obj.LastBalancedPrice) + if err != nil { + return err + } + // Deserialize `ConfigDenominator`: + err = decoder.Decode(&obj.ConfigDenominator) + if err != nil { + return err + } + // Deserialize `VolumeX`: + err = decoder.Decode(&obj.VolumeX) + if err != nil { + return err + } + // Deserialize `VolumeY`: + err = decoder.Decode(&obj.VolumeY) + if err != nil { + return err + } + // Deserialize `VolumeXInY`: + err = decoder.Decode(&obj.VolumeXInY) + if err != nil { + return err + } + // Deserialize `DepositCap`: + err = decoder.Decode(&obj.DepositCap) + if err != nil { + return err + } + // Deserialize `RegressionTarget`: + err = decoder.Decode(&obj.RegressionTarget) + if err != nil { + return err + } + // Deserialize `OracleType`: + err = decoder.Decode(&obj.OracleType) + if err != nil { + return err + } + // Deserialize `OracleStatus`: + err = decoder.Decode(&obj.OracleStatus) + if err != nil { + return err + } + // Deserialize `OracleMainSlotLimit`: + err = decoder.Decode(&obj.OracleMainSlotLimit) + if err != nil { + return err + } + // Deserialize `OracleSubConfidenceLimit`: + err = decoder.Decode(&obj.OracleSubConfidenceLimit) + if err != nil { + return err + } + // Deserialize `OracleSubSlotLimit`: + err = decoder.Decode(&obj.OracleSubSlotLimit) + if err != nil { + return err + } + // Deserialize `OraclePcConfidenceLimit`: + err = decoder.Decode(&obj.OraclePcConfidenceLimit) + if err != nil { + return err + } + // Deserialize `OraclePcSlotLimit`: + err = decoder.Decode(&obj.OraclePcSlotLimit) + if err != nil { + return err + } + // Deserialize `StdSpread`: + err = decoder.Decode(&obj.StdSpread) + if err != nil { + return err + } + // Deserialize `StdSpreadBuffer`: + err = decoder.Decode(&obj.StdSpreadBuffer) + if err != nil { + return err + } + // Deserialize `SpreadCoefficient`: + err = decoder.Decode(&obj.SpreadCoefficient) + if err != nil { + return err + } + // Deserialize `PriceBufferCoin`: + err = decoder.Decode(&obj.PriceBufferCoin) + if err != nil { + return err + } + // Deserialize `PriceBufferPc`: + err = decoder.Decode(&obj.PriceBufferPc) + if err != nil { + return err + } + // Deserialize `RebalanceRatio`: + err = decoder.Decode(&obj.RebalanceRatio) + if err != nil { + return err + } + // Deserialize `FeeTrade`: + err = decoder.Decode(&obj.FeeTrade) + if err != nil { + return err + } + // Deserialize `FeePlatform`: + err = decoder.Decode(&obj.FeePlatform) + if err != nil { + return err + } + // Deserialize `OracleMainSlotBuffer`: + err = decoder.Decode(&obj.OracleMainSlotBuffer) + if err != nil { + return err + } + // Deserialize `ConfigTemp4`: + err = decoder.Decode(&obj.ConfigTemp4) + if err != nil { + return err + } + // Deserialize `ConfigTemp5`: + err = decoder.Decode(&obj.ConfigTemp5) + if err != nil { + return err + } + // Deserialize `ConfigTemp6`: + err = decoder.Decode(&obj.ConfigTemp6) + if err != nil { + return err + } + // Deserialize `ConfigTemp7`: + err = decoder.Decode(&obj.ConfigTemp7) + if err != nil { + return err + } + // Deserialize `ConfigTemp8`: + err = decoder.Decode(&obj.ConfigTemp8) + if err != nil { + return err + } + return nil +} + +type CurveType ag_binary.BorshEnum + +const ( + CurveTypeStandard CurveType = iota + CurveTypeConstantProduct +) + +func (value CurveType) String() string { + switch value { + case CurveTypeStandard: + return "Standard" + case CurveTypeConstantProduct: + return "ConstantProduct" + default: + return "" + } +} diff --git a/programs/meteoradlmm/AddLiquidity.go b/programs/meteora_dlmm/AddLiquidity.go similarity index 99% rename from programs/meteoradlmm/AddLiquidity.go rename to programs/meteora_dlmm/AddLiquidity.go index 34f3a7d1f..f5fba6d29 100644 --- a/programs/meteoradlmm/AddLiquidity.go +++ b/programs/meteora_dlmm/AddLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityByStrategy.go b/programs/meteora_dlmm/AddLiquidityByStrategy.go similarity index 99% rename from programs/meteoradlmm/AddLiquidityByStrategy.go rename to programs/meteora_dlmm/AddLiquidityByStrategy.go index d612e5a6e..b78b00d23 100644 --- a/programs/meteoradlmm/AddLiquidityByStrategy.go +++ b/programs/meteora_dlmm/AddLiquidityByStrategy.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityByStrategyOneSide.go b/programs/meteora_dlmm/AddLiquidityByStrategyOneSide.go similarity index 99% rename from programs/meteoradlmm/AddLiquidityByStrategyOneSide.go rename to programs/meteora_dlmm/AddLiquidityByStrategyOneSide.go index 66d583e3e..207e59593 100644 --- a/programs/meteoradlmm/AddLiquidityByStrategyOneSide.go +++ b/programs/meteora_dlmm/AddLiquidityByStrategyOneSide.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityByStrategyOneSide_test.go b/programs/meteora_dlmm/AddLiquidityByStrategyOneSide_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidityByStrategyOneSide_test.go rename to programs/meteora_dlmm/AddLiquidityByStrategyOneSide_test.go index 659bf3be3..fe408fd36 100644 --- a/programs/meteoradlmm/AddLiquidityByStrategyOneSide_test.go +++ b/programs/meteora_dlmm/AddLiquidityByStrategyOneSide_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/AddLiquidityByStrategy_test.go b/programs/meteora_dlmm/AddLiquidityByStrategy_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidityByStrategy_test.go rename to programs/meteora_dlmm/AddLiquidityByStrategy_test.go index e85de9877..167277a34 100644 --- a/programs/meteoradlmm/AddLiquidityByStrategy_test.go +++ b/programs/meteora_dlmm/AddLiquidityByStrategy_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/AddLiquidityByWeight.go b/programs/meteora_dlmm/AddLiquidityByWeight.go similarity index 99% rename from programs/meteoradlmm/AddLiquidityByWeight.go rename to programs/meteora_dlmm/AddLiquidityByWeight.go index 8d9edce41..c9e918117 100644 --- a/programs/meteoradlmm/AddLiquidityByWeight.go +++ b/programs/meteora_dlmm/AddLiquidityByWeight.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityByWeight_test.go b/programs/meteora_dlmm/AddLiquidityByWeight_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidityByWeight_test.go rename to programs/meteora_dlmm/AddLiquidityByWeight_test.go index 51cd5ba9e..447ca6e1a 100644 --- a/programs/meteoradlmm/AddLiquidityByWeight_test.go +++ b/programs/meteora_dlmm/AddLiquidityByWeight_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/AddLiquidityOneSide.go b/programs/meteora_dlmm/AddLiquidityOneSide.go similarity index 99% rename from programs/meteoradlmm/AddLiquidityOneSide.go rename to programs/meteora_dlmm/AddLiquidityOneSide.go index 9c578e3df..74e271806 100644 --- a/programs/meteoradlmm/AddLiquidityOneSide.go +++ b/programs/meteora_dlmm/AddLiquidityOneSide.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityOneSidePrecise.go b/programs/meteora_dlmm/AddLiquidityOneSidePrecise.go similarity index 99% rename from programs/meteoradlmm/AddLiquidityOneSidePrecise.go rename to programs/meteora_dlmm/AddLiquidityOneSidePrecise.go index 0be80d97a..357d76aed 100644 --- a/programs/meteoradlmm/AddLiquidityOneSidePrecise.go +++ b/programs/meteora_dlmm/AddLiquidityOneSidePrecise.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/AddLiquidityOneSidePrecise_test.go b/programs/meteora_dlmm/AddLiquidityOneSidePrecise_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidityOneSidePrecise_test.go rename to programs/meteora_dlmm/AddLiquidityOneSidePrecise_test.go index 10bf69142..347bc9def 100644 --- a/programs/meteoradlmm/AddLiquidityOneSidePrecise_test.go +++ b/programs/meteora_dlmm/AddLiquidityOneSidePrecise_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/AddLiquidityOneSide_test.go b/programs/meteora_dlmm/AddLiquidityOneSide_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidityOneSide_test.go rename to programs/meteora_dlmm/AddLiquidityOneSide_test.go index 45658fd64..ad9ca4c53 100644 --- a/programs/meteoradlmm/AddLiquidityOneSide_test.go +++ b/programs/meteora_dlmm/AddLiquidityOneSide_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/AddLiquidity_test.go b/programs/meteora_dlmm/AddLiquidity_test.go similarity index 97% rename from programs/meteoradlmm/AddLiquidity_test.go rename to programs/meteora_dlmm/AddLiquidity_test.go index 7cf1e791e..de1785b2b 100644 --- a/programs/meteoradlmm/AddLiquidity_test.go +++ b/programs/meteora_dlmm/AddLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/ClaimFee.go b/programs/meteora_dlmm/ClaimFee.go similarity index 99% rename from programs/meteoradlmm/ClaimFee.go rename to programs/meteora_dlmm/ClaimFee.go index 91b15f6d0..831f3a280 100644 --- a/programs/meteoradlmm/ClaimFee.go +++ b/programs/meteora_dlmm/ClaimFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteorapools/ClaimFee_test.go b/programs/meteora_dlmm/ClaimFee_test.go similarity index 97% rename from programs/meteorapools/ClaimFee_test.go rename to programs/meteora_dlmm/ClaimFee_test.go index 03155b47d..ffe0c2aae 100644 --- a/programs/meteorapools/ClaimFee_test.go +++ b/programs/meteora_dlmm/ClaimFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/ClaimReward.go b/programs/meteora_dlmm/ClaimReward.go similarity index 99% rename from programs/meteoradlmm/ClaimReward.go rename to programs/meteora_dlmm/ClaimReward.go index 7c5a16ded..3862a555d 100644 --- a/programs/meteoradlmm/ClaimReward.go +++ b/programs/meteora_dlmm/ClaimReward.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/ClaimReward_test.go b/programs/meteora_dlmm/ClaimReward_test.go similarity index 97% rename from programs/meteoradlmm/ClaimReward_test.go rename to programs/meteora_dlmm/ClaimReward_test.go index e290ba4f0..077c97ead 100644 --- a/programs/meteoradlmm/ClaimReward_test.go +++ b/programs/meteora_dlmm/ClaimReward_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/ClosePosition.go b/programs/meteora_dlmm/ClosePosition.go similarity index 99% rename from programs/meteoradlmm/ClosePosition.go rename to programs/meteora_dlmm/ClosePosition.go index 657891294..e10bf1b58 100644 --- a/programs/meteoradlmm/ClosePosition.go +++ b/programs/meteora_dlmm/ClosePosition.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/raydiumclmm/ClosePosition_test.go b/programs/meteora_dlmm/ClosePosition_test.go similarity index 97% rename from programs/raydiumclmm/ClosePosition_test.go rename to programs/meteora_dlmm/ClosePosition_test.go index 02ac79623..6d42d95ea 100644 --- a/programs/raydiumclmm/ClosePosition_test.go +++ b/programs/meteora_dlmm/ClosePosition_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/ClosePresetParameter.go b/programs/meteora_dlmm/ClosePresetParameter.go similarity index 99% rename from programs/meteoradlmm/ClosePresetParameter.go rename to programs/meteora_dlmm/ClosePresetParameter.go index 55f00d744..7813786a0 100644 --- a/programs/meteoradlmm/ClosePresetParameter.go +++ b/programs/meteora_dlmm/ClosePresetParameter.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/ClosePresetParameter_test.go b/programs/meteora_dlmm/ClosePresetParameter_test.go similarity index 97% rename from programs/meteoradlmm/ClosePresetParameter_test.go rename to programs/meteora_dlmm/ClosePresetParameter_test.go index 8225ddab4..ad870ef0c 100644 --- a/programs/meteoradlmm/ClosePresetParameter_test.go +++ b/programs/meteora_dlmm/ClosePresetParameter_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/FundReward.go b/programs/meteora_dlmm/FundReward.go similarity index 99% rename from programs/meteoradlmm/FundReward.go rename to programs/meteora_dlmm/FundReward.go index 01476b11d..68481db6a 100644 --- a/programs/meteoradlmm/FundReward.go +++ b/programs/meteora_dlmm/FundReward.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/FundReward_test.go b/programs/meteora_dlmm/FundReward_test.go similarity index 97% rename from programs/meteoradlmm/FundReward_test.go rename to programs/meteora_dlmm/FundReward_test.go index 4fdecbaa9..5e91b5013 100644 --- a/programs/meteoradlmm/FundReward_test.go +++ b/programs/meteora_dlmm/FundReward_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/GoToABin.go b/programs/meteora_dlmm/GoToABin.go similarity index 99% rename from programs/meteoradlmm/GoToABin.go rename to programs/meteora_dlmm/GoToABin.go index 2d52a5e1b..913bf1a24 100644 --- a/programs/meteoradlmm/GoToABin.go +++ b/programs/meteora_dlmm/GoToABin.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/GoToABin_test.go b/programs/meteora_dlmm/GoToABin_test.go similarity index 97% rename from programs/meteoradlmm/GoToABin_test.go rename to programs/meteora_dlmm/GoToABin_test.go index b37f3943c..2830bbef5 100644 --- a/programs/meteoradlmm/GoToABin_test.go +++ b/programs/meteora_dlmm/GoToABin_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/IncreaseOracleLength.go b/programs/meteora_dlmm/IncreaseOracleLength.go similarity index 99% rename from programs/meteoradlmm/IncreaseOracleLength.go rename to programs/meteora_dlmm/IncreaseOracleLength.go index 022d59fc5..b8060fb9f 100644 --- a/programs/meteoradlmm/IncreaseOracleLength.go +++ b/programs/meteora_dlmm/IncreaseOracleLength.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/IncreaseOracleLength_test.go b/programs/meteora_dlmm/IncreaseOracleLength_test.go similarity index 97% rename from programs/meteoradlmm/IncreaseOracleLength_test.go rename to programs/meteora_dlmm/IncreaseOracleLength_test.go index 6e6c7e3f2..41eb22e49 100644 --- a/programs/meteoradlmm/IncreaseOracleLength_test.go +++ b/programs/meteora_dlmm/IncreaseOracleLength_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializeBinArray.go b/programs/meteora_dlmm/InitializeBinArray.go similarity index 99% rename from programs/meteoradlmm/InitializeBinArray.go rename to programs/meteora_dlmm/InitializeBinArray.go index 5d0bde749..191b95305 100644 --- a/programs/meteoradlmm/InitializeBinArray.go +++ b/programs/meteora_dlmm/InitializeBinArray.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializeBinArrayBitmapExtension.go b/programs/meteora_dlmm/InitializeBinArrayBitmapExtension.go similarity index 99% rename from programs/meteoradlmm/InitializeBinArrayBitmapExtension.go rename to programs/meteora_dlmm/InitializeBinArrayBitmapExtension.go index c1fb005b3..b7c1692a8 100644 --- a/programs/meteoradlmm/InitializeBinArrayBitmapExtension.go +++ b/programs/meteora_dlmm/InitializeBinArrayBitmapExtension.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializeBinArrayBitmapExtension_test.go b/programs/meteora_dlmm/InitializeBinArrayBitmapExtension_test.go similarity index 97% rename from programs/meteoradlmm/InitializeBinArrayBitmapExtension_test.go rename to programs/meteora_dlmm/InitializeBinArrayBitmapExtension_test.go index f0f4fc8c1..09307d7ac 100644 --- a/programs/meteoradlmm/InitializeBinArrayBitmapExtension_test.go +++ b/programs/meteora_dlmm/InitializeBinArrayBitmapExtension_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializeBinArray_test.go b/programs/meteora_dlmm/InitializeBinArray_test.go similarity index 97% rename from programs/meteoradlmm/InitializeBinArray_test.go rename to programs/meteora_dlmm/InitializeBinArray_test.go index 47481ae91..4c907fafa 100644 --- a/programs/meteoradlmm/InitializeBinArray_test.go +++ b/programs/meteora_dlmm/InitializeBinArray_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair.go b/programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair.go similarity index 99% rename from programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair.go rename to programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair.go index 896ccc29f..4ed1bb715 100644 --- a/programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair.go +++ b/programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair_test.go b/programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair_test.go similarity index 97% rename from programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair_test.go rename to programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair_test.go index b7acbb3e2..410acf3b9 100644 --- a/programs/meteoradlmm/InitializeCustomizablePermissionlessLbPair_test.go +++ b/programs/meteora_dlmm/InitializeCustomizablePermissionlessLbPair_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializeLbPair.go b/programs/meteora_dlmm/InitializeLbPair.go similarity index 99% rename from programs/meteoradlmm/InitializeLbPair.go rename to programs/meteora_dlmm/InitializeLbPair.go index 3d93fcc48..4693ddc3e 100644 --- a/programs/meteoradlmm/InitializeLbPair.go +++ b/programs/meteora_dlmm/InitializeLbPair.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializeLbPair_test.go b/programs/meteora_dlmm/InitializeLbPair_test.go similarity index 97% rename from programs/meteoradlmm/InitializeLbPair_test.go rename to programs/meteora_dlmm/InitializeLbPair_test.go index b39a5f0d8..7a13ae61c 100644 --- a/programs/meteoradlmm/InitializeLbPair_test.go +++ b/programs/meteora_dlmm/InitializeLbPair_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializePermissionLbPair.go b/programs/meteora_dlmm/InitializePermissionLbPair.go similarity index 99% rename from programs/meteoradlmm/InitializePermissionLbPair.go rename to programs/meteora_dlmm/InitializePermissionLbPair.go index 27595e338..06f9627e2 100644 --- a/programs/meteoradlmm/InitializePermissionLbPair.go +++ b/programs/meteora_dlmm/InitializePermissionLbPair.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializePermissionLbPair_test.go b/programs/meteora_dlmm/InitializePermissionLbPair_test.go similarity index 97% rename from programs/meteoradlmm/InitializePermissionLbPair_test.go rename to programs/meteora_dlmm/InitializePermissionLbPair_test.go index 0a0be7dc1..39449abe8 100644 --- a/programs/meteoradlmm/InitializePermissionLbPair_test.go +++ b/programs/meteora_dlmm/InitializePermissionLbPair_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializePosition.go b/programs/meteora_dlmm/InitializePosition.go similarity index 99% rename from programs/meteoradlmm/InitializePosition.go rename to programs/meteora_dlmm/InitializePosition.go index cb156cc65..394b6a818 100644 --- a/programs/meteoradlmm/InitializePosition.go +++ b/programs/meteora_dlmm/InitializePosition.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializePositionByOperator.go b/programs/meteora_dlmm/InitializePositionByOperator.go similarity index 99% rename from programs/meteoradlmm/InitializePositionByOperator.go rename to programs/meteora_dlmm/InitializePositionByOperator.go index d94a4ce05..d02c0b672 100644 --- a/programs/meteoradlmm/InitializePositionByOperator.go +++ b/programs/meteora_dlmm/InitializePositionByOperator.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializePositionByOperator_test.go b/programs/meteora_dlmm/InitializePositionByOperator_test.go similarity index 97% rename from programs/meteoradlmm/InitializePositionByOperator_test.go rename to programs/meteora_dlmm/InitializePositionByOperator_test.go index 5eb0cb338..9ef67ad24 100644 --- a/programs/meteoradlmm/InitializePositionByOperator_test.go +++ b/programs/meteora_dlmm/InitializePositionByOperator_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializePositionPda.go b/programs/meteora_dlmm/InitializePositionPda.go similarity index 99% rename from programs/meteoradlmm/InitializePositionPda.go rename to programs/meteora_dlmm/InitializePositionPda.go index 8ceb8ca7f..95b52d75d 100644 --- a/programs/meteoradlmm/InitializePositionPda.go +++ b/programs/meteora_dlmm/InitializePositionPda.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializePositionPda_test.go b/programs/meteora_dlmm/InitializePositionPda_test.go similarity index 97% rename from programs/meteoradlmm/InitializePositionPda_test.go rename to programs/meteora_dlmm/InitializePositionPda_test.go index 2ae802867..c0466e8a2 100644 --- a/programs/meteoradlmm/InitializePositionPda_test.go +++ b/programs/meteora_dlmm/InitializePositionPda_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializePosition_test.go b/programs/meteora_dlmm/InitializePosition_test.go similarity index 97% rename from programs/meteoradlmm/InitializePosition_test.go rename to programs/meteora_dlmm/InitializePosition_test.go index 27cd0de7c..878f3cc13 100644 --- a/programs/meteoradlmm/InitializePosition_test.go +++ b/programs/meteora_dlmm/InitializePosition_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializePresetParameter.go b/programs/meteora_dlmm/InitializePresetParameter.go similarity index 99% rename from programs/meteoradlmm/InitializePresetParameter.go rename to programs/meteora_dlmm/InitializePresetParameter.go index ea207c1d1..28316d7c4 100644 --- a/programs/meteoradlmm/InitializePresetParameter.go +++ b/programs/meteora_dlmm/InitializePresetParameter.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializePresetParameter_test.go b/programs/meteora_dlmm/InitializePresetParameter_test.go similarity index 97% rename from programs/meteoradlmm/InitializePresetParameter_test.go rename to programs/meteora_dlmm/InitializePresetParameter_test.go index 5dcdb6a09..296534466 100644 --- a/programs/meteoradlmm/InitializePresetParameter_test.go +++ b/programs/meteora_dlmm/InitializePresetParameter_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/InitializeReward.go b/programs/meteora_dlmm/InitializeReward.go similarity index 99% rename from programs/meteoradlmm/InitializeReward.go rename to programs/meteora_dlmm/InitializeReward.go index 0edca46f6..c1e96e00c 100644 --- a/programs/meteoradlmm/InitializeReward.go +++ b/programs/meteora_dlmm/InitializeReward.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/InitializeReward_test.go b/programs/meteora_dlmm/InitializeReward_test.go similarity index 97% rename from programs/meteoradlmm/InitializeReward_test.go rename to programs/meteora_dlmm/InitializeReward_test.go index 59c4479ab..c1937a4e3 100644 --- a/programs/meteoradlmm/InitializeReward_test.go +++ b/programs/meteora_dlmm/InitializeReward_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/MigrateBinArray.go b/programs/meteora_dlmm/MigrateBinArray.go similarity index 99% rename from programs/meteoradlmm/MigrateBinArray.go rename to programs/meteora_dlmm/MigrateBinArray.go index ca489dcb2..796b65a0d 100644 --- a/programs/meteoradlmm/MigrateBinArray.go +++ b/programs/meteora_dlmm/MigrateBinArray.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/MigrateBinArray_test.go b/programs/meteora_dlmm/MigrateBinArray_test.go similarity index 97% rename from programs/meteoradlmm/MigrateBinArray_test.go rename to programs/meteora_dlmm/MigrateBinArray_test.go index 422bd3950..fa7520553 100644 --- a/programs/meteoradlmm/MigrateBinArray_test.go +++ b/programs/meteora_dlmm/MigrateBinArray_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/MigratePosition.go b/programs/meteora_dlmm/MigratePosition.go similarity index 99% rename from programs/meteoradlmm/MigratePosition.go rename to programs/meteora_dlmm/MigratePosition.go index 6a266abb4..ea4821c20 100644 --- a/programs/meteoradlmm/MigratePosition.go +++ b/programs/meteora_dlmm/MigratePosition.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/MigratePosition_test.go b/programs/meteora_dlmm/MigratePosition_test.go similarity index 97% rename from programs/meteoradlmm/MigratePosition_test.go rename to programs/meteora_dlmm/MigratePosition_test.go index 29d047407..01d34834d 100644 --- a/programs/meteoradlmm/MigratePosition_test.go +++ b/programs/meteora_dlmm/MigratePosition_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/RemoveAllLiquidity.go b/programs/meteora_dlmm/RemoveAllLiquidity.go similarity index 99% rename from programs/meteoradlmm/RemoveAllLiquidity.go rename to programs/meteora_dlmm/RemoveAllLiquidity.go index e26a5632d..4eda22101 100644 --- a/programs/meteoradlmm/RemoveAllLiquidity.go +++ b/programs/meteora_dlmm/RemoveAllLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/RemoveAllLiquidity_test.go b/programs/meteora_dlmm/RemoveAllLiquidity_test.go similarity index 97% rename from programs/meteoradlmm/RemoveAllLiquidity_test.go rename to programs/meteora_dlmm/RemoveAllLiquidity_test.go index 95f7b9c8e..3279e6e24 100644 --- a/programs/meteoradlmm/RemoveAllLiquidity_test.go +++ b/programs/meteora_dlmm/RemoveAllLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/RemoveLiquidity.go b/programs/meteora_dlmm/RemoveLiquidity.go similarity index 99% rename from programs/meteoradlmm/RemoveLiquidity.go rename to programs/meteora_dlmm/RemoveLiquidity.go index c7153e67d..522525789 100644 --- a/programs/meteoradlmm/RemoveLiquidity.go +++ b/programs/meteora_dlmm/RemoveLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/RemoveLiquidityByRange.go b/programs/meteora_dlmm/RemoveLiquidityByRange.go similarity index 99% rename from programs/meteoradlmm/RemoveLiquidityByRange.go rename to programs/meteora_dlmm/RemoveLiquidityByRange.go index 81c8ebaf1..f512411bc 100644 --- a/programs/meteoradlmm/RemoveLiquidityByRange.go +++ b/programs/meteora_dlmm/RemoveLiquidityByRange.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/RemoveLiquidityByRange_test.go b/programs/meteora_dlmm/RemoveLiquidityByRange_test.go similarity index 97% rename from programs/meteoradlmm/RemoveLiquidityByRange_test.go rename to programs/meteora_dlmm/RemoveLiquidityByRange_test.go index 0f8cb21fa..416b285d1 100644 --- a/programs/meteoradlmm/RemoveLiquidityByRange_test.go +++ b/programs/meteora_dlmm/RemoveLiquidityByRange_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/RemoveLiquidity_test.go b/programs/meteora_dlmm/RemoveLiquidity_test.go similarity index 97% rename from programs/meteoradlmm/RemoveLiquidity_test.go rename to programs/meteora_dlmm/RemoveLiquidity_test.go index 95bf02ac0..76f312a68 100644 --- a/programs/meteoradlmm/RemoveLiquidity_test.go +++ b/programs/meteora_dlmm/RemoveLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/SetActivationPoint.go b/programs/meteora_dlmm/SetActivationPoint.go similarity index 99% rename from programs/meteoradlmm/SetActivationPoint.go rename to programs/meteora_dlmm/SetActivationPoint.go index 5e20ad5e2..8124e2191 100644 --- a/programs/meteoradlmm/SetActivationPoint.go +++ b/programs/meteora_dlmm/SetActivationPoint.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SetActivationPoint_test.go b/programs/meteora_dlmm/SetActivationPoint_test.go similarity index 97% rename from programs/meteoradlmm/SetActivationPoint_test.go rename to programs/meteora_dlmm/SetActivationPoint_test.go index b9a2a52a0..087ab2066 100644 --- a/programs/meteoradlmm/SetActivationPoint_test.go +++ b/programs/meteora_dlmm/SetActivationPoint_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/SetPreActivationDuration.go b/programs/meteora_dlmm/SetPreActivationDuration.go similarity index 99% rename from programs/meteoradlmm/SetPreActivationDuration.go rename to programs/meteora_dlmm/SetPreActivationDuration.go index 6ebc8f199..d16c40d4c 100644 --- a/programs/meteoradlmm/SetPreActivationDuration.go +++ b/programs/meteora_dlmm/SetPreActivationDuration.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SetPreActivationDuration_test.go b/programs/meteora_dlmm/SetPreActivationDuration_test.go similarity index 97% rename from programs/meteoradlmm/SetPreActivationDuration_test.go rename to programs/meteora_dlmm/SetPreActivationDuration_test.go index 14cf375b7..10bdb1d7d 100644 --- a/programs/meteoradlmm/SetPreActivationDuration_test.go +++ b/programs/meteora_dlmm/SetPreActivationDuration_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/SetPreActivationSwapAddress.go b/programs/meteora_dlmm/SetPreActivationSwapAddress.go similarity index 99% rename from programs/meteoradlmm/SetPreActivationSwapAddress.go rename to programs/meteora_dlmm/SetPreActivationSwapAddress.go index b1628a623..e4d19d071 100644 --- a/programs/meteoradlmm/SetPreActivationSwapAddress.go +++ b/programs/meteora_dlmm/SetPreActivationSwapAddress.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SetPreActivationSwapAddress_test.go b/programs/meteora_dlmm/SetPreActivationSwapAddress_test.go similarity index 97% rename from programs/meteoradlmm/SetPreActivationSwapAddress_test.go rename to programs/meteora_dlmm/SetPreActivationSwapAddress_test.go index 88a854cea..53b5205fb 100644 --- a/programs/meteoradlmm/SetPreActivationSwapAddress_test.go +++ b/programs/meteora_dlmm/SetPreActivationSwapAddress_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/Swap.go b/programs/meteora_dlmm/Swap.go similarity index 99% rename from programs/meteoradlmm/Swap.go rename to programs/meteora_dlmm/Swap.go index 60009bb59..32ebc052c 100644 --- a/programs/meteoradlmm/Swap.go +++ b/programs/meteora_dlmm/Swap.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SwapExactOut.go b/programs/meteora_dlmm/SwapExactOut.go similarity index 99% rename from programs/meteoradlmm/SwapExactOut.go rename to programs/meteora_dlmm/SwapExactOut.go index 930af3d41..b9ae515f5 100644 --- a/programs/meteoradlmm/SwapExactOut.go +++ b/programs/meteora_dlmm/SwapExactOut.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SwapExactOut_test.go b/programs/meteora_dlmm/SwapExactOut_test.go similarity index 97% rename from programs/meteoradlmm/SwapExactOut_test.go rename to programs/meteora_dlmm/SwapExactOut_test.go index 09bbe4fde..8ab5858d8 100644 --- a/programs/meteoradlmm/SwapExactOut_test.go +++ b/programs/meteora_dlmm/SwapExactOut_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/SwapWithPriceImpact.go b/programs/meteora_dlmm/SwapWithPriceImpact.go similarity index 99% rename from programs/meteoradlmm/SwapWithPriceImpact.go rename to programs/meteora_dlmm/SwapWithPriceImpact.go index 4a0c82026..5c2a4a0c7 100644 --- a/programs/meteoradlmm/SwapWithPriceImpact.go +++ b/programs/meteora_dlmm/SwapWithPriceImpact.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/SwapWithPriceImpact_test.go b/programs/meteora_dlmm/SwapWithPriceImpact_test.go similarity index 97% rename from programs/meteoradlmm/SwapWithPriceImpact_test.go rename to programs/meteora_dlmm/SwapWithPriceImpact_test.go index be0dda25c..3084c1f29 100644 --- a/programs/meteoradlmm/SwapWithPriceImpact_test.go +++ b/programs/meteora_dlmm/SwapWithPriceImpact_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/Swap_test.go b/programs/meteora_dlmm/Swap_test.go similarity index 97% rename from programs/meteoradlmm/Swap_test.go rename to programs/meteora_dlmm/Swap_test.go index 98bf67401..d0169e762 100644 --- a/programs/meteoradlmm/Swap_test.go +++ b/programs/meteora_dlmm/Swap_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/TogglePairStatus.go b/programs/meteora_dlmm/TogglePairStatus.go similarity index 99% rename from programs/meteoradlmm/TogglePairStatus.go rename to programs/meteora_dlmm/TogglePairStatus.go index a028be159..ab08fcf54 100644 --- a/programs/meteoradlmm/TogglePairStatus.go +++ b/programs/meteora_dlmm/TogglePairStatus.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/TogglePairStatus_test.go b/programs/meteora_dlmm/TogglePairStatus_test.go similarity index 97% rename from programs/meteoradlmm/TogglePairStatus_test.go rename to programs/meteora_dlmm/TogglePairStatus_test.go index df83fb104..7942f481c 100644 --- a/programs/meteoradlmm/TogglePairStatus_test.go +++ b/programs/meteora_dlmm/TogglePairStatus_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/UpdateFeeParameters.go b/programs/meteora_dlmm/UpdateFeeParameters.go similarity index 99% rename from programs/meteoradlmm/UpdateFeeParameters.go rename to programs/meteora_dlmm/UpdateFeeParameters.go index 61828f882..968282e0c 100644 --- a/programs/meteoradlmm/UpdateFeeParameters.go +++ b/programs/meteora_dlmm/UpdateFeeParameters.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/UpdateFeeParameters_test.go b/programs/meteora_dlmm/UpdateFeeParameters_test.go similarity index 97% rename from programs/meteoradlmm/UpdateFeeParameters_test.go rename to programs/meteora_dlmm/UpdateFeeParameters_test.go index 85656a43e..603b68b6d 100644 --- a/programs/meteoradlmm/UpdateFeeParameters_test.go +++ b/programs/meteora_dlmm/UpdateFeeParameters_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/UpdateFeesAndRewards.go b/programs/meteora_dlmm/UpdateFeesAndRewards.go similarity index 99% rename from programs/meteoradlmm/UpdateFeesAndRewards.go rename to programs/meteora_dlmm/UpdateFeesAndRewards.go index 651647eab..28a298118 100644 --- a/programs/meteoradlmm/UpdateFeesAndRewards.go +++ b/programs/meteora_dlmm/UpdateFeesAndRewards.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/UpdateFeesAndRewards_test.go b/programs/meteora_dlmm/UpdateFeesAndRewards_test.go similarity index 97% rename from programs/meteoradlmm/UpdateFeesAndRewards_test.go rename to programs/meteora_dlmm/UpdateFeesAndRewards_test.go index 59408c707..6c4fd843d 100644 --- a/programs/meteoradlmm/UpdateFeesAndRewards_test.go +++ b/programs/meteora_dlmm/UpdateFeesAndRewards_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/UpdatePositionOperator.go b/programs/meteora_dlmm/UpdatePositionOperator.go similarity index 99% rename from programs/meteoradlmm/UpdatePositionOperator.go rename to programs/meteora_dlmm/UpdatePositionOperator.go index 763526387..cd27940af 100644 --- a/programs/meteoradlmm/UpdatePositionOperator.go +++ b/programs/meteora_dlmm/UpdatePositionOperator.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/UpdatePositionOperator_test.go b/programs/meteora_dlmm/UpdatePositionOperator_test.go similarity index 97% rename from programs/meteoradlmm/UpdatePositionOperator_test.go rename to programs/meteora_dlmm/UpdatePositionOperator_test.go index 1bfb24f83..ff4f9d33f 100644 --- a/programs/meteoradlmm/UpdatePositionOperator_test.go +++ b/programs/meteora_dlmm/UpdatePositionOperator_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/UpdateRewardDuration.go b/programs/meteora_dlmm/UpdateRewardDuration.go similarity index 99% rename from programs/meteoradlmm/UpdateRewardDuration.go rename to programs/meteora_dlmm/UpdateRewardDuration.go index 5d5ef818a..2e627320a 100644 --- a/programs/meteoradlmm/UpdateRewardDuration.go +++ b/programs/meteora_dlmm/UpdateRewardDuration.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/UpdateRewardDuration_test.go b/programs/meteora_dlmm/UpdateRewardDuration_test.go similarity index 97% rename from programs/meteoradlmm/UpdateRewardDuration_test.go rename to programs/meteora_dlmm/UpdateRewardDuration_test.go index 6094c1ccb..26675dff2 100644 --- a/programs/meteoradlmm/UpdateRewardDuration_test.go +++ b/programs/meteora_dlmm/UpdateRewardDuration_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/UpdateRewardFunder.go b/programs/meteora_dlmm/UpdateRewardFunder.go similarity index 99% rename from programs/meteoradlmm/UpdateRewardFunder.go rename to programs/meteora_dlmm/UpdateRewardFunder.go index e9172429b..a67976806 100644 --- a/programs/meteoradlmm/UpdateRewardFunder.go +++ b/programs/meteora_dlmm/UpdateRewardFunder.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/UpdateRewardFunder_test.go b/programs/meteora_dlmm/UpdateRewardFunder_test.go similarity index 97% rename from programs/meteoradlmm/UpdateRewardFunder_test.go rename to programs/meteora_dlmm/UpdateRewardFunder_test.go index 11814bd17..a6a8ba0c5 100644 --- a/programs/meteoradlmm/UpdateRewardFunder_test.go +++ b/programs/meteora_dlmm/UpdateRewardFunder_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/WithdrawIneligibleReward.go b/programs/meteora_dlmm/WithdrawIneligibleReward.go similarity index 99% rename from programs/meteoradlmm/WithdrawIneligibleReward.go rename to programs/meteora_dlmm/WithdrawIneligibleReward.go index f46e5c119..71ade0467 100644 --- a/programs/meteoradlmm/WithdrawIneligibleReward.go +++ b/programs/meteora_dlmm/WithdrawIneligibleReward.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/WithdrawIneligibleReward_test.go b/programs/meteora_dlmm/WithdrawIneligibleReward_test.go similarity index 97% rename from programs/meteoradlmm/WithdrawIneligibleReward_test.go rename to programs/meteora_dlmm/WithdrawIneligibleReward_test.go index 4f71d41b5..278eb10cc 100644 --- a/programs/meteoradlmm/WithdrawIneligibleReward_test.go +++ b/programs/meteora_dlmm/WithdrawIneligibleReward_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/WithdrawProtocolFee.go b/programs/meteora_dlmm/WithdrawProtocolFee.go similarity index 99% rename from programs/meteoradlmm/WithdrawProtocolFee.go rename to programs/meteora_dlmm/WithdrawProtocolFee.go index 1bf7de8e5..5498d31df 100644 --- a/programs/meteoradlmm/WithdrawProtocolFee.go +++ b/programs/meteora_dlmm/WithdrawProtocolFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "errors" diff --git a/programs/meteoradlmm/WithdrawProtocolFee_test.go b/programs/meteora_dlmm/WithdrawProtocolFee_test.go similarity index 97% rename from programs/meteoradlmm/WithdrawProtocolFee_test.go rename to programs/meteora_dlmm/WithdrawProtocolFee_test.go index 88e9162ef..2430181ac 100644 --- a/programs/meteoradlmm/WithdrawProtocolFee_test.go +++ b/programs/meteora_dlmm/WithdrawProtocolFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" diff --git a/programs/meteoradlmm/accounts.go b/programs/meteora_dlmm/accounts.go similarity index 99% rename from programs/meteoradlmm/accounts.go rename to programs/meteora_dlmm/accounts.go index ec40490cc..77ef270f2 100644 --- a/programs/meteoradlmm/accounts.go +++ b/programs/meteora_dlmm/accounts.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "fmt" diff --git a/programs/meteoradlmm/instructions.go b/programs/meteora_dlmm/instructions.go similarity index 98% rename from programs/meteoradlmm/instructions.go rename to programs/meteora_dlmm/instructions.go index 17d8022c9..dc6e3e1d9 100644 --- a/programs/meteoradlmm/instructions.go +++ b/programs/meteora_dlmm/instructions.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( "bytes" @@ -12,14 +12,14 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo") func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) } -const ProgramName = "LbClmm" +const ProgramName = "MeteoraDlmm" func init() { if !ProgramID.IsZero() { diff --git a/programs/meteora_dlmm/testing_utils.go b/programs/meteora_dlmm/testing_utils.go new file mode 100644 index 000000000..fa5aa92df --- /dev/null +++ b/programs/meteora_dlmm/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_dlmm + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/meteoradlmm/types.go b/programs/meteora_dlmm/types.go similarity index 99% rename from programs/meteoradlmm/types.go rename to programs/meteora_dlmm/types.go index 402341f58..cc0e2cd58 100644 --- a/programs/meteoradlmm/types.go +++ b/programs/meteora_dlmm/types.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_dlmm import ( ag_binary "github.com/gagliardetto/binary" diff --git a/programs/meteorapools/AddBalanceLiquidity.go b/programs/meteora_pools/AddBalanceLiquidity.go similarity index 99% rename from programs/meteorapools/AddBalanceLiquidity.go rename to programs/meteora_pools/AddBalanceLiquidity.go index 27d677c7c..e346712b3 100644 --- a/programs/meteorapools/AddBalanceLiquidity.go +++ b/programs/meteora_pools/AddBalanceLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/AddBalanceLiquidity_test.go b/programs/meteora_pools/AddBalanceLiquidity_test.go similarity index 97% rename from programs/meteorapools/AddBalanceLiquidity_test.go rename to programs/meteora_pools/AddBalanceLiquidity_test.go index 341b9137a..5726de48c 100644 --- a/programs/meteorapools/AddBalanceLiquidity_test.go +++ b/programs/meteora_pools/AddBalanceLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/AddImbalanceLiquidity.go b/programs/meteora_pools/AddImbalanceLiquidity.go similarity index 99% rename from programs/meteorapools/AddImbalanceLiquidity.go rename to programs/meteora_pools/AddImbalanceLiquidity.go index de0b40b89..0de0e4096 100644 --- a/programs/meteorapools/AddImbalanceLiquidity.go +++ b/programs/meteora_pools/AddImbalanceLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/AddImbalanceLiquidity_test.go b/programs/meteora_pools/AddImbalanceLiquidity_test.go similarity index 97% rename from programs/meteorapools/AddImbalanceLiquidity_test.go rename to programs/meteora_pools/AddImbalanceLiquidity_test.go index d4290b610..6466bc08c 100644 --- a/programs/meteorapools/AddImbalanceLiquidity_test.go +++ b/programs/meteora_pools/AddImbalanceLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/BootstrapLiquidity.go b/programs/meteora_pools/BootstrapLiquidity.go similarity index 99% rename from programs/meteorapools/BootstrapLiquidity.go rename to programs/meteora_pools/BootstrapLiquidity.go index 7d761c990..145b8f62d 100644 --- a/programs/meteorapools/BootstrapLiquidity.go +++ b/programs/meteora_pools/BootstrapLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/BootstrapLiquidity_test.go b/programs/meteora_pools/BootstrapLiquidity_test.go similarity index 97% rename from programs/meteorapools/BootstrapLiquidity_test.go rename to programs/meteora_pools/BootstrapLiquidity_test.go index 931e0b39c..bfd281978 100644 --- a/programs/meteorapools/BootstrapLiquidity_test.go +++ b/programs/meteora_pools/BootstrapLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/ClaimFee.go b/programs/meteora_pools/ClaimFee.go similarity index 99% rename from programs/meteorapools/ClaimFee.go rename to programs/meteora_pools/ClaimFee.go index 19c08420a..8ffe48966 100644 --- a/programs/meteorapools/ClaimFee.go +++ b/programs/meteora_pools/ClaimFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteoradlmm/ClaimFee_test.go b/programs/meteora_pools/ClaimFee_test.go similarity index 97% rename from programs/meteoradlmm/ClaimFee_test.go rename to programs/meteora_pools/ClaimFee_test.go index 4d4b5ae40..6275f2ea1 100644 --- a/programs/meteoradlmm/ClaimFee_test.go +++ b/programs/meteora_pools/ClaimFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/CloseConfig.go b/programs/meteora_pools/CloseConfig.go similarity index 99% rename from programs/meteorapools/CloseConfig.go rename to programs/meteora_pools/CloseConfig.go index 436439de1..55ed07a42 100644 --- a/programs/meteorapools/CloseConfig.go +++ b/programs/meteora_pools/CloseConfig.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/CloseConfig_test.go b/programs/meteora_pools/CloseConfig_test.go similarity index 97% rename from programs/meteorapools/CloseConfig_test.go rename to programs/meteora_pools/CloseConfig_test.go index 3a9ba00c7..841b12e2a 100644 --- a/programs/meteorapools/CloseConfig_test.go +++ b/programs/meteora_pools/CloseConfig_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/CreateConfig.go b/programs/meteora_pools/CreateConfig.go similarity index 99% rename from programs/meteorapools/CreateConfig.go rename to programs/meteora_pools/CreateConfig.go index 3ede0d4fa..fb76881bb 100644 --- a/programs/meteorapools/CreateConfig.go +++ b/programs/meteora_pools/CreateConfig.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/CreateConfig_test.go b/programs/meteora_pools/CreateConfig_test.go similarity index 97% rename from programs/meteorapools/CreateConfig_test.go rename to programs/meteora_pools/CreateConfig_test.go index d4a1d28c7..bb224b7cb 100644 --- a/programs/meteorapools/CreateConfig_test.go +++ b/programs/meteora_pools/CreateConfig_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/CreateLockEscrow.go b/programs/meteora_pools/CreateLockEscrow.go similarity index 99% rename from programs/meteorapools/CreateLockEscrow.go rename to programs/meteora_pools/CreateLockEscrow.go index 644ac67a3..d4c88a5bb 100644 --- a/programs/meteorapools/CreateLockEscrow.go +++ b/programs/meteora_pools/CreateLockEscrow.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/CreateLockEscrow_test.go b/programs/meteora_pools/CreateLockEscrow_test.go similarity index 97% rename from programs/meteorapools/CreateLockEscrow_test.go rename to programs/meteora_pools/CreateLockEscrow_test.go index 6a9cdfa49..acd8b6f28 100644 --- a/programs/meteorapools/CreateLockEscrow_test.go +++ b/programs/meteora_pools/CreateLockEscrow_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/CreateMintMetadata.go b/programs/meteora_pools/CreateMintMetadata.go similarity index 99% rename from programs/meteorapools/CreateMintMetadata.go rename to programs/meteora_pools/CreateMintMetadata.go index f2cdd10cf..ccbd618ce 100644 --- a/programs/meteorapools/CreateMintMetadata.go +++ b/programs/meteora_pools/CreateMintMetadata.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/CreateMintMetadata_test.go b/programs/meteora_pools/CreateMintMetadata_test.go similarity index 97% rename from programs/meteorapools/CreateMintMetadata_test.go rename to programs/meteora_pools/CreateMintMetadata_test.go index 1ab65670d..294c56d96 100644 --- a/programs/meteorapools/CreateMintMetadata_test.go +++ b/programs/meteora_pools/CreateMintMetadata_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/EnableOrDisablePool.go b/programs/meteora_pools/EnableOrDisablePool.go similarity index 99% rename from programs/meteorapools/EnableOrDisablePool.go rename to programs/meteora_pools/EnableOrDisablePool.go index 99900d14b..0a895f993 100644 --- a/programs/meteorapools/EnableOrDisablePool.go +++ b/programs/meteora_pools/EnableOrDisablePool.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/EnableOrDisablePool_test.go b/programs/meteora_pools/EnableOrDisablePool_test.go similarity index 97% rename from programs/meteorapools/EnableOrDisablePool_test.go rename to programs/meteora_pools/EnableOrDisablePool_test.go index 5bebaa865..0fd924dbe 100644 --- a/programs/meteorapools/EnableOrDisablePool_test.go +++ b/programs/meteora_pools/EnableOrDisablePool_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/GetPoolInfo.go b/programs/meteora_pools/GetPoolInfo.go similarity index 99% rename from programs/meteorapools/GetPoolInfo.go rename to programs/meteora_pools/GetPoolInfo.go index e58f32b4e..8865b8aff 100644 --- a/programs/meteorapools/GetPoolInfo.go +++ b/programs/meteora_pools/GetPoolInfo.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/GetPoolInfo_test.go b/programs/meteora_pools/GetPoolInfo_test.go similarity index 97% rename from programs/meteorapools/GetPoolInfo_test.go rename to programs/meteora_pools/GetPoolInfo_test.go index 19d9c62ad..35d18b3f9 100644 --- a/programs/meteorapools/GetPoolInfo_test.go +++ b/programs/meteora_pools/GetPoolInfo_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool.go b/programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool.go similarity index 99% rename from programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool.go rename to programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool.go index 818d6ce56..7a116930b 100644 --- a/programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool.go +++ b/programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool_test.go b/programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool_test.go similarity index 97% rename from programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool_test.go rename to programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool_test.go index 4d13f755a..0b3321108 100644 --- a/programs/meteorapools/InitializeCustomizablePermissionlessConstantProductPool_test.go +++ b/programs/meteora_pools/InitializeCustomizablePermissionlessConstantProductPool_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializePermissionedPool.go b/programs/meteora_pools/InitializePermissionedPool.go similarity index 99% rename from programs/meteorapools/InitializePermissionedPool.go rename to programs/meteora_pools/InitializePermissionedPool.go index 93f032981..16db38389 100644 --- a/programs/meteorapools/InitializePermissionedPool.go +++ b/programs/meteora_pools/InitializePermissionedPool.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializePermissionedPool_test.go b/programs/meteora_pools/InitializePermissionedPool_test.go similarity index 98% rename from programs/meteorapools/InitializePermissionedPool_test.go rename to programs/meteora_pools/InitializePermissionedPool_test.go index fde71ad98..075339378 100644 --- a/programs/meteorapools/InitializePermissionedPool_test.go +++ b/programs/meteora_pools/InitializePermissionedPool_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig.go b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig.go similarity index 99% rename from programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig.go rename to programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig.go index e229b5386..6b1fc5bfc 100644 --- a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig.go +++ b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2.go b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2.go similarity index 99% rename from programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2.go rename to programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2.go index b9bb46b99..f0b3a1018 100644 --- a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2.go +++ b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2_test.go b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2_test.go similarity index 97% rename from programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2_test.go rename to programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2_test.go index 809f3114d..7c53e0607 100644 --- a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig2_test.go +++ b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig2_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig_test.go b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig_test.go similarity index 97% rename from programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig_test.go rename to programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig_test.go index 734b60674..f83012061 100644 --- a/programs/meteorapools/InitializePermissionlessConstantProductPoolWithConfig_test.go +++ b/programs/meteora_pools/InitializePermissionlessConstantProductPoolWithConfig_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializePermissionlessPool.go b/programs/meteora_pools/InitializePermissionlessPool.go similarity index 99% rename from programs/meteorapools/InitializePermissionlessPool.go rename to programs/meteora_pools/InitializePermissionlessPool.go index e67368e92..79d7def63 100644 --- a/programs/meteorapools/InitializePermissionlessPool.go +++ b/programs/meteora_pools/InitializePermissionlessPool.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializePermissionlessPoolWithFeeTier.go b/programs/meteora_pools/InitializePermissionlessPoolWithFeeTier.go similarity index 99% rename from programs/meteorapools/InitializePermissionlessPoolWithFeeTier.go rename to programs/meteora_pools/InitializePermissionlessPoolWithFeeTier.go index c85ad4937..e0a5d8b7e 100644 --- a/programs/meteorapools/InitializePermissionlessPoolWithFeeTier.go +++ b/programs/meteora_pools/InitializePermissionlessPoolWithFeeTier.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/InitializePermissionlessPoolWithFeeTier_test.go b/programs/meteora_pools/InitializePermissionlessPoolWithFeeTier_test.go similarity index 98% rename from programs/meteorapools/InitializePermissionlessPoolWithFeeTier_test.go rename to programs/meteora_pools/InitializePermissionlessPoolWithFeeTier_test.go index a3035bc0c..c4e3849b4 100644 --- a/programs/meteorapools/InitializePermissionlessPoolWithFeeTier_test.go +++ b/programs/meteora_pools/InitializePermissionlessPoolWithFeeTier_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/InitializePermissionlessPool_test.go b/programs/meteora_pools/InitializePermissionlessPool_test.go similarity index 98% rename from programs/meteorapools/InitializePermissionlessPool_test.go rename to programs/meteora_pools/InitializePermissionlessPool_test.go index 69ff75eda..6f43372e2 100644 --- a/programs/meteorapools/InitializePermissionlessPool_test.go +++ b/programs/meteora_pools/InitializePermissionlessPool_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/Lock.go b/programs/meteora_pools/Lock.go similarity index 99% rename from programs/meteorapools/Lock.go rename to programs/meteora_pools/Lock.go index 259029760..b71e952a8 100644 --- a/programs/meteorapools/Lock.go +++ b/programs/meteora_pools/Lock.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/Lock_test.go b/programs/meteora_pools/Lock_test.go similarity index 97% rename from programs/meteorapools/Lock_test.go rename to programs/meteora_pools/Lock_test.go index 7e2f91bdd..d8ee37098 100644 --- a/programs/meteorapools/Lock_test.go +++ b/programs/meteora_pools/Lock_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/OverrideCurveParam.go b/programs/meteora_pools/OverrideCurveParam.go similarity index 99% rename from programs/meteorapools/OverrideCurveParam.go rename to programs/meteora_pools/OverrideCurveParam.go index 0e4534040..09178ad1e 100644 --- a/programs/meteorapools/OverrideCurveParam.go +++ b/programs/meteora_pools/OverrideCurveParam.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/OverrideCurveParam_test.go b/programs/meteora_pools/OverrideCurveParam_test.go similarity index 98% rename from programs/meteorapools/OverrideCurveParam_test.go rename to programs/meteora_pools/OverrideCurveParam_test.go index ef499b5de..e9b13445e 100644 --- a/programs/meteorapools/OverrideCurveParam_test.go +++ b/programs/meteora_pools/OverrideCurveParam_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/PartnerClaimFee.go b/programs/meteora_pools/PartnerClaimFee.go similarity index 99% rename from programs/meteorapools/PartnerClaimFee.go rename to programs/meteora_pools/PartnerClaimFee.go index 0033eb9ca..889a8c1ca 100644 --- a/programs/meteorapools/PartnerClaimFee.go +++ b/programs/meteora_pools/PartnerClaimFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/PartnerClaimFee_test.go b/programs/meteora_pools/PartnerClaimFee_test.go similarity index 97% rename from programs/meteorapools/PartnerClaimFee_test.go rename to programs/meteora_pools/PartnerClaimFee_test.go index 3dd016638..d20d64dde 100644 --- a/programs/meteorapools/PartnerClaimFee_test.go +++ b/programs/meteora_pools/PartnerClaimFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/RemoveBalanceLiquidity.go b/programs/meteora_pools/RemoveBalanceLiquidity.go similarity index 99% rename from programs/meteorapools/RemoveBalanceLiquidity.go rename to programs/meteora_pools/RemoveBalanceLiquidity.go index 123fea930..63d27a3b0 100644 --- a/programs/meteorapools/RemoveBalanceLiquidity.go +++ b/programs/meteora_pools/RemoveBalanceLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/RemoveBalanceLiquidity_test.go b/programs/meteora_pools/RemoveBalanceLiquidity_test.go similarity index 97% rename from programs/meteorapools/RemoveBalanceLiquidity_test.go rename to programs/meteora_pools/RemoveBalanceLiquidity_test.go index ccd30c355..c63d152a0 100644 --- a/programs/meteorapools/RemoveBalanceLiquidity_test.go +++ b/programs/meteora_pools/RemoveBalanceLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/RemoveLiquiditySingleSide.go b/programs/meteora_pools/RemoveLiquiditySingleSide.go similarity index 99% rename from programs/meteorapools/RemoveLiquiditySingleSide.go rename to programs/meteora_pools/RemoveLiquiditySingleSide.go index 263b2ec99..78f93d00e 100644 --- a/programs/meteorapools/RemoveLiquiditySingleSide.go +++ b/programs/meteora_pools/RemoveLiquiditySingleSide.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/RemoveLiquiditySingleSide_test.go b/programs/meteora_pools/RemoveLiquiditySingleSide_test.go similarity index 97% rename from programs/meteorapools/RemoveLiquiditySingleSide_test.go rename to programs/meteora_pools/RemoveLiquiditySingleSide_test.go index a36c327d9..7c11b8b1a 100644 --- a/programs/meteorapools/RemoveLiquiditySingleSide_test.go +++ b/programs/meteora_pools/RemoveLiquiditySingleSide_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/SetPoolFees.go b/programs/meteora_pools/SetPoolFees.go similarity index 99% rename from programs/meteorapools/SetPoolFees.go rename to programs/meteora_pools/SetPoolFees.go index 8358ee172..3bea1c0d9 100644 --- a/programs/meteorapools/SetPoolFees.go +++ b/programs/meteora_pools/SetPoolFees.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/SetPoolFees_test.go b/programs/meteora_pools/SetPoolFees_test.go similarity index 97% rename from programs/meteorapools/SetPoolFees_test.go rename to programs/meteora_pools/SetPoolFees_test.go index 5ade18595..e733e7500 100644 --- a/programs/meteorapools/SetPoolFees_test.go +++ b/programs/meteora_pools/SetPoolFees_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/SetWhitelistedVault.go b/programs/meteora_pools/SetWhitelistedVault.go similarity index 99% rename from programs/meteorapools/SetWhitelistedVault.go rename to programs/meteora_pools/SetWhitelistedVault.go index f4b9b44d3..7070f93a5 100644 --- a/programs/meteorapools/SetWhitelistedVault.go +++ b/programs/meteora_pools/SetWhitelistedVault.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/SetWhitelistedVault_test.go b/programs/meteora_pools/SetWhitelistedVault_test.go similarity index 97% rename from programs/meteorapools/SetWhitelistedVault_test.go rename to programs/meteora_pools/SetWhitelistedVault_test.go index 461702e22..dd38e79f5 100644 --- a/programs/meteorapools/SetWhitelistedVault_test.go +++ b/programs/meteora_pools/SetWhitelistedVault_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/Swap.go b/programs/meteora_pools/Swap.go similarity index 99% rename from programs/meteorapools/Swap.go rename to programs/meteora_pools/Swap.go index 7592f973c..9f3a26a46 100644 --- a/programs/meteorapools/Swap.go +++ b/programs/meteora_pools/Swap.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteora_pools/Swap_test.go b/programs/meteora_pools/Swap_test.go new file mode 100644 index 000000000..58f387b10 --- /dev/null +++ b/programs/meteora_pools/Swap_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_pools + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Swap(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Swap"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Swap) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Swap) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteorapools/UpdateActivationPoint.go b/programs/meteora_pools/UpdateActivationPoint.go similarity index 99% rename from programs/meteorapools/UpdateActivationPoint.go rename to programs/meteora_pools/UpdateActivationPoint.go index 9a53b85b7..102e761a5 100644 --- a/programs/meteorapools/UpdateActivationPoint.go +++ b/programs/meteora_pools/UpdateActivationPoint.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/UpdateActivationPoint_test.go b/programs/meteora_pools/UpdateActivationPoint_test.go similarity index 97% rename from programs/meteorapools/UpdateActivationPoint_test.go rename to programs/meteora_pools/UpdateActivationPoint_test.go index db95dd031..bcaf21972 100644 --- a/programs/meteorapools/UpdateActivationPoint_test.go +++ b/programs/meteora_pools/UpdateActivationPoint_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/WithdrawProtocolFees.go b/programs/meteora_pools/WithdrawProtocolFees.go similarity index 99% rename from programs/meteorapools/WithdrawProtocolFees.go rename to programs/meteora_pools/WithdrawProtocolFees.go index 0e6ee7672..509044459 100644 --- a/programs/meteorapools/WithdrawProtocolFees.go +++ b/programs/meteora_pools/WithdrawProtocolFees.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "errors" diff --git a/programs/meteorapools/WithdrawProtocolFees_test.go b/programs/meteora_pools/WithdrawProtocolFees_test.go similarity index 97% rename from programs/meteorapools/WithdrawProtocolFees_test.go rename to programs/meteora_pools/WithdrawProtocolFees_test.go index ef000abcd..9e0487cdc 100644 --- a/programs/meteorapools/WithdrawProtocolFees_test.go +++ b/programs/meteora_pools/WithdrawProtocolFees_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" diff --git a/programs/meteorapools/accounts.go b/programs/meteora_pools/accounts.go similarity index 99% rename from programs/meteorapools/accounts.go rename to programs/meteora_pools/accounts.go index b1d6230af..5252bb680 100644 --- a/programs/meteorapools/accounts.go +++ b/programs/meteora_pools/accounts.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "fmt" diff --git a/programs/meteorapools/instructions.go b/programs/meteora_pools/instructions.go similarity index 98% rename from programs/meteorapools/instructions.go rename to programs/meteora_pools/instructions.go index 8292947ac..df5f11991 100644 --- a/programs/meteorapools/instructions.go +++ b/programs/meteora_pools/instructions.go @@ -1,7 +1,7 @@ // Program for AMM // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( "bytes" @@ -13,14 +13,14 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB") func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) } -const ProgramName = "Amm" +const ProgramName = "MeteoraPools" func init() { if !ProgramID.IsZero() { diff --git a/programs/meteora_pools/testing_utils.go b/programs/meteora_pools/testing_utils.go new file mode 100644 index 000000000..20238a328 --- /dev/null +++ b/programs/meteora_pools/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_pools + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/meteorapools/types.go b/programs/meteora_pools/types.go similarity index 99% rename from programs/meteorapools/types.go rename to programs/meteora_pools/types.go index 370ca0b26..e1db21ff4 100644 --- a/programs/meteorapools/types.go +++ b/programs/meteora_pools/types.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package meteora_pools import ( ag_binary "github.com/gagliardetto/binary" diff --git a/programs/meteora_vault/AddStrategy.go b/programs/meteora_vault/AddStrategy.go new file mode 100644 index 000000000..0cfbe932b --- /dev/null +++ b/programs/meteora_vault/AddStrategy.go @@ -0,0 +1,145 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// add a strategy +type AddStrategy struct { + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [] strategy + // ··········· strategy + // + // [2] = [SIGNER] admin + // ··········· admin + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewAddStrategyInstructionBuilder creates a new `AddStrategy` instruction builder. +func NewAddStrategyInstructionBuilder() *AddStrategy { + nd := &AddStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *AddStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *AddStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *AddStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// strategy +func (inst *AddStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *AddStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy) + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// strategy +func (inst *AddStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetAdminAccount sets the "admin" account. +// admin +func (inst *AddStrategy) SetAdminAccount(admin ag_solanago.PublicKey) *AddStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// admin +func (inst *AddStrategy) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst AddStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_AddStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst AddStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *AddStrategy) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Admin is not set") + } + } + return nil +} + +func (inst *AddStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("AddStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj AddStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *AddStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewAddStrategyInstruction declares a new AddStrategy instruction with the provided parameters and accounts. +func NewAddStrategyInstruction( + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + admin ag_solanago.PublicKey) *AddStrategy { + return NewAddStrategyInstructionBuilder(). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetAdminAccount(admin) +} diff --git a/programs/meteora_vault/AddStrategy_test.go b/programs/meteora_vault/AddStrategy_test.go new file mode 100644 index 000000000..905ff163d --- /dev/null +++ b/programs/meteora_vault/AddStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_AddStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("AddStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(AddStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(AddStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/CollectDust.go b/programs/meteora_vault/CollectDust.go new file mode 100644 index 000000000..9c1599ab3 --- /dev/null +++ b/programs/meteora_vault/CollectDust.go @@ -0,0 +1,190 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// collect token, that someone send wrongly +// also help in case Mango reimbursement +type CollectDust struct { + + // [0] = [] vault + // ··········· vault + // + // [1] = [WRITE] tokenVault + // ··········· Token vault, must be different from vault.token_vault + // + // [2] = [WRITE] tokenAdmin + // ··········· token admin, enforce owner is admin to avoid mistake + // + // [3] = [SIGNER] admin + // ··········· admin + // + // [4] = [] tokenProgram + // ··········· token_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCollectDustInstructionBuilder creates a new `CollectDust` instruction builder. +func NewCollectDustInstructionBuilder() *CollectDust { + nd := &CollectDust{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *CollectDust) SetVaultAccount(vault ag_solanago.PublicKey) *CollectDust { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault) + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *CollectDust) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// Token vault, must be different from vault.token_vault +func (inst *CollectDust) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *CollectDust { + inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// Token vault, must be different from vault.token_vault +func (inst *CollectDust) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetTokenAdminAccount sets the "tokenAdmin" account. +// token admin, enforce owner is admin to avoid mistake +func (inst *CollectDust) SetTokenAdminAccount(tokenAdmin ag_solanago.PublicKey) *CollectDust { + inst.AccountMetaSlice[2] = ag_solanago.Meta(tokenAdmin).WRITE() + return inst +} + +// GetTokenAdminAccount gets the "tokenAdmin" account. +// token admin, enforce owner is admin to avoid mistake +func (inst *CollectDust) GetTokenAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetAdminAccount sets the "admin" account. +// admin +func (inst *CollectDust) SetAdminAccount(admin ag_solanago.PublicKey) *CollectDust { + inst.AccountMetaSlice[3] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// admin +func (inst *CollectDust) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *CollectDust) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CollectDust { + inst.AccountMetaSlice[4] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *CollectDust) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst CollectDust) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CollectDust, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CollectDust) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CollectDust) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.TokenAdmin is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Admin is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *CollectDust) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CollectDust")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" tokenAdmin", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("tokenProgram", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj CollectDust) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *CollectDust) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewCollectDustInstruction declares a new CollectDust instruction with the provided parameters and accounts. +func NewCollectDustInstruction( + // Accounts: + vault ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + tokenAdmin ag_solanago.PublicKey, + admin ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *CollectDust { + return NewCollectDustInstructionBuilder(). + SetVaultAccount(vault). + SetTokenVaultAccount(tokenVault). + SetTokenAdminAccount(tokenAdmin). + SetAdminAccount(admin). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/CollectDust_test.go b/programs/meteora_vault/CollectDust_test.go new file mode 100644 index 000000000..660b1c83f --- /dev/null +++ b/programs/meteora_vault/CollectDust_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CollectDust(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CollectDust"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CollectDust) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CollectDust) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Deposit.go b/programs/meteora_vault/Deposit.go new file mode 100644 index 000000000..075324c5b --- /dev/null +++ b/programs/meteora_vault/Deposit.go @@ -0,0 +1,285 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// user deposit liquidity to vault +type Deposit struct { + TokenAmount *uint64 + MinimumLpTokenAmount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] tokenVault + // ··········· token_vault + // + // [2] = [WRITE] lpMint + // ··········· lp_mint + // + // [3] = [WRITE] userToken + // ··········· user_token + // + // [4] = [WRITE] userLp + // ··········· user_lp + // + // [5] = [SIGNER] user + // ··········· user + // + // [6] = [] tokenProgram + // ··········· token_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositInstructionBuilder creates a new `Deposit` instruction builder. +func NewDepositInstructionBuilder() *Deposit { + nd := &Deposit{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 7), + } + return nd +} + +// SetTokenAmount sets the "tokenAmount" parameter. +func (inst *Deposit) SetTokenAmount(tokenAmount uint64) *Deposit { + inst.TokenAmount = &tokenAmount + return inst +} + +// SetMinimumLpTokenAmount sets the "minimumLpTokenAmount" parameter. +func (inst *Deposit) SetMinimumLpTokenAmount(minimumLpTokenAmount uint64) *Deposit { + inst.MinimumLpTokenAmount = &minimumLpTokenAmount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *Deposit) SetVaultAccount(vault ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *Deposit) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *Deposit) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *Deposit) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *Deposit) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[2] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *Deposit) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetUserTokenAccount sets the "userToken" account. +// user_token +func (inst *Deposit) SetUserTokenAccount(userToken ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[3] = ag_solanago.Meta(userToken).WRITE() + return inst +} + +// GetUserTokenAccount gets the "userToken" account. +// user_token +func (inst *Deposit) GetUserTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetUserLpAccount sets the "userLp" account. +// user_lp +func (inst *Deposit) SetUserLpAccount(userLp ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[4] = ag_solanago.Meta(userLp).WRITE() + return inst +} + +// GetUserLpAccount gets the "userLp" account. +// user_lp +func (inst *Deposit) GetUserLpAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetUserAccount sets the "user" account. +// user +func (inst *Deposit) SetUserAccount(user ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[5] = ag_solanago.Meta(user).SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +// user +func (inst *Deposit) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *Deposit) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *Deposit) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +func (inst Deposit) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Deposit, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Deposit) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Deposit) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.TokenAmount == nil { + return errors.New("TokenAmount parameter is not set") + } + if inst.MinimumLpTokenAmount == nil { + return errors.New("MinimumLpTokenAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.UserToken is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.UserLp is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *Deposit) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Deposit")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" TokenAmount", *inst.TokenAmount)) + paramsBranch.Child(ag_format.Param("MinimumLpTokenAmount", *inst.MinimumLpTokenAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=7]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" userToken", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" userLp", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("tokenProgram", inst.AccountMetaSlice.Get(6))) + }) + }) + }) +} + +func (obj Deposit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `TokenAmount` param: + err = encoder.Encode(obj.TokenAmount) + if err != nil { + return err + } + // Serialize `MinimumLpTokenAmount` param: + err = encoder.Encode(obj.MinimumLpTokenAmount) + if err != nil { + return err + } + return nil +} +func (obj *Deposit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `TokenAmount`: + err = decoder.Decode(&obj.TokenAmount) + if err != nil { + return err + } + // Deserialize `MinimumLpTokenAmount`: + err = decoder.Decode(&obj.MinimumLpTokenAmount) + if err != nil { + return err + } + return nil +} + +// NewDepositInstruction declares a new Deposit instruction with the provided parameters and accounts. +func NewDepositInstruction( + // Parameters: + tokenAmount uint64, + minimumLpTokenAmount uint64, + // Accounts: + vault ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + userToken ag_solanago.PublicKey, + userLp ag_solanago.PublicKey, + user ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *Deposit { + return NewDepositInstructionBuilder(). + SetTokenAmount(tokenAmount). + SetMinimumLpTokenAmount(minimumLpTokenAmount). + SetVaultAccount(vault). + SetTokenVaultAccount(tokenVault). + SetLpMintAccount(lpMint). + SetUserTokenAccount(userToken). + SetUserLpAccount(userLp). + SetUserAccount(user). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/DepositStrategy.go b/programs/meteora_vault/DepositStrategy.go new file mode 100644 index 000000000..44ae09886 --- /dev/null +++ b/programs/meteora_vault/DepositStrategy.go @@ -0,0 +1,322 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// deposit liquidity to a strategy +type DepositStrategy struct { + Amount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] strategy + // ··········· strategy + // + // [2] = [WRITE] tokenVault + // ··········· token_vault + // + // [3] = [WRITE] feeVault + // ··········· fee_vault + // + // [4] = [WRITE] lpMint + // ··········· lp_mint + // + // [5] = [] strategyProgram + // + // [6] = [WRITE] collateralVault + // ··········· collateral_vault + // + // [7] = [WRITE] reserve + // + // [8] = [] tokenProgram + // ··········· token_program + // + // [9] = [SIGNER] operator + // ··········· operator + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositStrategyInstructionBuilder creates a new `DepositStrategy` instruction builder. +func NewDepositStrategyInstructionBuilder() *DepositStrategy { + nd := &DepositStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *DepositStrategy) SetAmount(amount uint64) *DepositStrategy { + inst.Amount = &amount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *DepositStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *DepositStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// strategy +func (inst *DepositStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// strategy +func (inst *DepositStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *DepositStrategy) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *DepositStrategy) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetFeeVaultAccount sets the "feeVault" account. +// fee_vault +func (inst *DepositStrategy) SetFeeVaultAccount(feeVault ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(feeVault).WRITE() + return inst +} + +// GetFeeVaultAccount gets the "feeVault" account. +// fee_vault +func (inst *DepositStrategy) GetFeeVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *DepositStrategy) SetLpMintAccount(lpMint ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *DepositStrategy) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *DepositStrategy) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *DepositStrategy) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// collateral_vault +func (inst *DepositStrategy) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// collateral_vault +func (inst *DepositStrategy) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *DepositStrategy) SetReserveAccount(reserve ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *DepositStrategy) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *DepositStrategy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *DepositStrategy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetOperatorAccount sets the "operator" account. +// operator +func (inst *DepositStrategy) SetOperatorAccount(operator ag_solanago.PublicKey) *DepositStrategy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(operator).SIGNER() + return inst +} + +// GetOperatorAccount gets the "operator" account. +// operator +func (inst *DepositStrategy) GetOperatorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst DepositStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_DepositStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst DepositStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *DepositStrategy) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.FeeVault is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.Operator is not set") + } + } + return nil +} + +func (inst *DepositStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("DepositStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Amount", *inst.Amount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" feeVault", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta("strategyProgram", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("collateralVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" operator", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj DepositStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + return nil +} +func (obj *DepositStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + return nil +} + +// NewDepositStrategyInstruction declares a new DepositStrategy instruction with the provided parameters and accounts. +func NewDepositStrategyInstruction( + // Parameters: + amount uint64, + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + feeVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + operator ag_solanago.PublicKey) *DepositStrategy { + return NewDepositStrategyInstructionBuilder(). + SetAmount(amount). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetTokenVaultAccount(tokenVault). + SetFeeVaultAccount(feeVault). + SetLpMintAccount(lpMint). + SetStrategyProgramAccount(strategyProgram). + SetCollateralVaultAccount(collateralVault). + SetReserveAccount(reserve). + SetTokenProgramAccount(tokenProgram). + SetOperatorAccount(operator) +} diff --git a/programs/meteora_vault/DepositStrategy_test.go b/programs/meteora_vault/DepositStrategy_test.go new file mode 100644 index 000000000..fca59c364 --- /dev/null +++ b/programs/meteora_vault/DepositStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_DepositStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("DepositStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(DepositStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(DepositStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Deposit_test.go b/programs/meteora_vault/Deposit_test.go new file mode 100644 index 000000000..ccf1155b4 --- /dev/null +++ b/programs/meteora_vault/Deposit_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Deposit(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Deposit"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Deposit) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Deposit) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/EnableVault.go b/programs/meteora_vault/EnableVault.go new file mode 100644 index 000000000..f691a793a --- /dev/null +++ b/programs/meteora_vault/EnableVault.go @@ -0,0 +1,152 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// enable vault +type EnableVault struct { + Enabled *uint8 + + // [0] = [WRITE] vault + // ··········· Vault account + // + // [1] = [SIGNER] admin + // ··········· Admin account + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewEnableVaultInstructionBuilder creates a new `EnableVault` instruction builder. +func NewEnableVaultInstructionBuilder() *EnableVault { + nd := &EnableVault{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetEnabled sets the "enabled" parameter. +func (inst *EnableVault) SetEnabled(enabled uint8) *EnableVault { + inst.Enabled = &enabled + return inst +} + +// SetVaultAccount sets the "vault" account. +// Vault account +func (inst *EnableVault) SetVaultAccount(vault ag_solanago.PublicKey) *EnableVault { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// Vault account +func (inst *EnableVault) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAdminAccount sets the "admin" account. +// Admin account +func (inst *EnableVault) SetAdminAccount(admin ag_solanago.PublicKey) *EnableVault { + inst.AccountMetaSlice[1] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// Admin account +func (inst *EnableVault) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +func (inst EnableVault) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_EnableVault, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst EnableVault) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *EnableVault) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Enabled == nil { + return errors.New("Enabled parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Admin is not set") + } + } + return nil +} + +func (inst *EnableVault) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("EnableVault")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Enabled", *inst.Enabled)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("admin", inst.AccountMetaSlice.Get(1))) + }) + }) + }) +} + +func (obj EnableVault) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Enabled` param: + err = encoder.Encode(obj.Enabled) + if err != nil { + return err + } + return nil +} +func (obj *EnableVault) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Enabled`: + err = decoder.Decode(&obj.Enabled) + if err != nil { + return err + } + return nil +} + +// NewEnableVaultInstruction declares a new EnableVault instruction with the provided parameters and accounts. +func NewEnableVaultInstruction( + // Parameters: + enabled uint8, + // Accounts: + vault ag_solanago.PublicKey, + admin ag_solanago.PublicKey) *EnableVault { + return NewEnableVaultInstructionBuilder(). + SetEnabled(enabled). + SetVaultAccount(vault). + SetAdminAccount(admin) +} diff --git a/programs/meteora_vault/EnableVault_test.go b/programs/meteora_vault/EnableVault_test.go new file mode 100644 index 000000000..795655c83 --- /dev/null +++ b/programs/meteora_vault/EnableVault_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_EnableVault(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("EnableVault"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(EnableVault) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(EnableVault) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Initialize.go b/programs/meteora_vault/Initialize.go new file mode 100644 index 000000000..92bb8fdff --- /dev/null +++ b/programs/meteora_vault/Initialize.go @@ -0,0 +1,258 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// initialize new vault +type Initialize struct { + + // [0] = [WRITE] vault + // ··········· This is base account for all vault + // ··········· No need base key now because we only allow 1 vault per token now + // ··········· Vault account + // + // [1] = [WRITE, SIGNER] payer + // ··········· Payer can be anyone + // + // [2] = [WRITE] tokenVault + // ··········· Token vault account + // + // [3] = [] tokenMint + // ··········· Token mint account + // + // [4] = [WRITE] lpMint + // + // [5] = [] rent + // ··········· rent + // + // [6] = [] tokenProgram + // ··········· token_program + // + // [7] = [] systemProgram + // ··········· system_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. +func NewInitializeInstructionBuilder() *Initialize { + nd := &Initialize{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 8), + } + return nd +} + +// SetVaultAccount sets the "vault" account. +// This is base account for all vault +// No need base key now because we only allow 1 vault per token now +// Vault account +func (inst *Initialize) SetVaultAccount(vault ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// This is base account for all vault +// No need base key now because we only allow 1 vault per token now +// Vault account +func (inst *Initialize) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetPayerAccount sets the "payer" account. +// Payer can be anyone +func (inst *Initialize) SetPayerAccount(payer ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[1] = ag_solanago.Meta(payer).WRITE().SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +// Payer can be anyone +func (inst *Initialize) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// Token vault account +func (inst *Initialize) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[2] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// Token vault account +func (inst *Initialize) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTokenMintAccount sets the "tokenMint" account. +// Token mint account +func (inst *Initialize) SetTokenMintAccount(tokenMint ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[3] = ag_solanago.Meta(tokenMint) + return inst +} + +// GetTokenMintAccount gets the "tokenMint" account. +// Token mint account +func (inst *Initialize) GetTokenMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetLpMintAccount sets the "lpMint" account. +func (inst *Initialize) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[4] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +func (inst *Initialize) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetRentAccount sets the "rent" account. +// rent +func (inst *Initialize) SetRentAccount(rent ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[5] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +// rent +func (inst *Initialize) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *Initialize) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *Initialize) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +// system_program +func (inst *Initialize) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +// system_program +func (inst *Initialize) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +func (inst Initialize) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Initialize, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Initialize) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Initialize) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.TokenMint is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Initialize")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=8]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" tokenMint", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice.Get(7))) + }) + }) + }) +} + +func (obj Initialize) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Initialize) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewInitializeInstruction declares a new Initialize instruction with the provided parameters and accounts. +func NewInitializeInstruction( + // Accounts: + vault ag_solanago.PublicKey, + payer ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + tokenMint ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *Initialize { + return NewInitializeInstructionBuilder(). + SetVaultAccount(vault). + SetPayerAccount(payer). + SetTokenVaultAccount(tokenVault). + SetTokenMintAccount(tokenMint). + SetLpMintAccount(lpMint). + SetRentAccount(rent). + SetTokenProgramAccount(tokenProgram). + SetSystemProgramAccount(systemProgram) +} diff --git a/programs/meteora_vault/InitializeStrategy.go b/programs/meteora_vault/InitializeStrategy.go new file mode 100644 index 000000000..690445441 --- /dev/null +++ b/programs/meteora_vault/InitializeStrategy.go @@ -0,0 +1,345 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Initialize a strategy and add strategy to vault.strategies index +type InitializeStrategy struct { + Bumps *StrategyBumps + StrategyType *StrategyType + + // [0] = [WRITE] vault + // ··········· Vault account + // + // [1] = [] strategyProgram + // + // [2] = [WRITE] strategy + // ··········· Strategy account + // + // [3] = [WRITE] reserve + // + // [4] = [WRITE] collateralVault + // ··········· Collateral vault account + // + // [5] = [] collateralMint + // ··········· Collateral mint account + // + // [6] = [WRITE, SIGNER] admin + // ··········· Admin account + // + // [7] = [] systemProgram + // ··········· System program account + // + // [8] = [] rent + // ··········· Rent account + // + // [9] = [] tokenProgram + // ··········· Token program account + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeStrategyInstructionBuilder creates a new `InitializeStrategy` instruction builder. +func NewInitializeStrategyInstructionBuilder() *InitializeStrategy { + nd := &InitializeStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetBumps sets the "bumps" parameter. +func (inst *InitializeStrategy) SetBumps(bumps StrategyBumps) *InitializeStrategy { + inst.Bumps = &bumps + return inst +} + +// SetStrategyType sets the "strategyType" parameter. +func (inst *InitializeStrategy) SetStrategyType(strategyType StrategyType) *InitializeStrategy { + inst.StrategyType = &strategyType + return inst +} + +// SetVaultAccount sets the "vault" account. +// Vault account +func (inst *InitializeStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// Vault account +func (inst *InitializeStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *InitializeStrategy) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *InitializeStrategy) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetStrategyAccount sets the "strategy" account. +// Strategy account +func (inst *InitializeStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// Strategy account +func (inst *InitializeStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *InitializeStrategy) SetReserveAccount(reserve ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *InitializeStrategy) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// Collateral vault account +func (inst *InitializeStrategy) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// Collateral vault account +func (inst *InitializeStrategy) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetCollateralMintAccount sets the "collateralMint" account. +// Collateral mint account +func (inst *InitializeStrategy) SetCollateralMintAccount(collateralMint ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(collateralMint) + return inst +} + +// GetCollateralMintAccount gets the "collateralMint" account. +// Collateral mint account +func (inst *InitializeStrategy) GetCollateralMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetAdminAccount sets the "admin" account. +// Admin account +func (inst *InitializeStrategy) SetAdminAccount(admin ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(admin).WRITE().SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// Admin account +func (inst *InitializeStrategy) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +// System program account +func (inst *InitializeStrategy) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +// System program account +func (inst *InitializeStrategy) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetRentAccount sets the "rent" account. +// Rent account +func (inst *InitializeStrategy) SetRentAccount(rent ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +// Rent account +func (inst *InitializeStrategy) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// Token program account +func (inst *InitializeStrategy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *InitializeStrategy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// Token program account +func (inst *InitializeStrategy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst InitializeStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_InitializeStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst InitializeStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *InitializeStrategy) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Bumps == nil { + return errors.New("Bumps parameter is not set") + } + if inst.StrategyType == nil { + return errors.New("StrategyType parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.CollateralMint is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Admin is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *InitializeStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("InitializeStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Bumps", *inst.Bumps)) + paramsBranch.Child(ag_format.Param("StrategyType", *inst.StrategyType)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("strategyProgram", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("collateralVault", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" collateralMint", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj InitializeStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Bumps` param: + err = encoder.Encode(obj.Bumps) + if err != nil { + return err + } + // Serialize `StrategyType` param: + err = encoder.Encode(obj.StrategyType) + if err != nil { + return err + } + return nil +} +func (obj *InitializeStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Bumps`: + err = decoder.Decode(&obj.Bumps) + if err != nil { + return err + } + // Deserialize `StrategyType`: + err = decoder.Decode(&obj.StrategyType) + if err != nil { + return err + } + return nil +} + +// NewInitializeStrategyInstruction declares a new InitializeStrategy instruction with the provided parameters and accounts. +func NewInitializeStrategyInstruction( + // Parameters: + bumps StrategyBumps, + strategyType StrategyType, + // Accounts: + vault ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + collateralMint ag_solanago.PublicKey, + admin ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *InitializeStrategy { + return NewInitializeStrategyInstructionBuilder(). + SetBumps(bumps). + SetStrategyType(strategyType). + SetVaultAccount(vault). + SetStrategyProgramAccount(strategyProgram). + SetStrategyAccount(strategy). + SetReserveAccount(reserve). + SetCollateralVaultAccount(collateralVault). + SetCollateralMintAccount(collateralMint). + SetAdminAccount(admin). + SetSystemProgramAccount(systemProgram). + SetRentAccount(rent). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/InitializeStrategy_test.go b/programs/meteora_vault/InitializeStrategy_test.go new file mode 100644 index 000000000..649970d17 --- /dev/null +++ b/programs/meteora_vault/InitializeStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_InitializeStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("InitializeStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(InitializeStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(InitializeStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Initialize_test.go b/programs/meteora_vault/Initialize_test.go new file mode 100644 index 000000000..3b5f4d067 --- /dev/null +++ b/programs/meteora_vault/Initialize_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initialize(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initialize"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initialize) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initialize) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/RemoveStrategy.go b/programs/meteora_vault/RemoveStrategy.go new file mode 100644 index 000000000..123f944cd --- /dev/null +++ b/programs/meteora_vault/RemoveStrategy.go @@ -0,0 +1,293 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// remove a strategy +type RemoveStrategy struct { + + // [0] = [WRITE] vault + // ··········· Vault account + // + // [1] = [WRITE] strategy + // ··········· Strategy account + // + // [2] = [] strategyProgram + // + // [3] = [WRITE] collateralVault + // ··········· Collateral vault account + // + // [4] = [WRITE] reserve + // + // [5] = [WRITE] tokenVault + // ··········· token_vault + // + // [6] = [WRITE] feeVault + // ··········· fee_vault + // + // [7] = [WRITE] lpMint + // ··········· lp_mint + // + // [8] = [] tokenProgram + // ··········· token_program + // + // [9] = [SIGNER] admin + // ··········· admin + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewRemoveStrategyInstructionBuilder creates a new `RemoveStrategy` instruction builder. +func NewRemoveStrategyInstructionBuilder() *RemoveStrategy { + nd := &RemoveStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetVaultAccount sets the "vault" account. +// Vault account +func (inst *RemoveStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// Vault account +func (inst *RemoveStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// Strategy account +func (inst *RemoveStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// Strategy account +func (inst *RemoveStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *RemoveStrategy) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *RemoveStrategy) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// Collateral vault account +func (inst *RemoveStrategy) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// Collateral vault account +func (inst *RemoveStrategy) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *RemoveStrategy) SetReserveAccount(reserve ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *RemoveStrategy) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *RemoveStrategy) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *RemoveStrategy) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetFeeVaultAccount sets the "feeVault" account. +// fee_vault +func (inst *RemoveStrategy) SetFeeVaultAccount(feeVault ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(feeVault).WRITE() + return inst +} + +// GetFeeVaultAccount gets the "feeVault" account. +// fee_vault +func (inst *RemoveStrategy) GetFeeVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *RemoveStrategy) SetLpMintAccount(lpMint ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *RemoveStrategy) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *RemoveStrategy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *RemoveStrategy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetAdminAccount sets the "admin" account. +// admin +func (inst *RemoveStrategy) SetAdminAccount(admin ag_solanago.PublicKey) *RemoveStrategy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// admin +func (inst *RemoveStrategy) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst RemoveStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RemoveStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RemoveStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RemoveStrategy) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.FeeVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.Admin is not set") + } + } + return nil +} + +func (inst *RemoveStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RemoveStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("strategyProgram", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("collateralVault", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" feeVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj RemoveStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *RemoveStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewRemoveStrategyInstruction declares a new RemoveStrategy instruction with the provided parameters and accounts. +func NewRemoveStrategyInstruction( + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + feeVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + admin ag_solanago.PublicKey) *RemoveStrategy { + return NewRemoveStrategyInstructionBuilder(). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetStrategyProgramAccount(strategyProgram). + SetCollateralVaultAccount(collateralVault). + SetReserveAccount(reserve). + SetTokenVaultAccount(tokenVault). + SetFeeVaultAccount(feeVault). + SetLpMintAccount(lpMint). + SetTokenProgramAccount(tokenProgram). + SetAdminAccount(admin) +} diff --git a/programs/meteora_vault/RemoveStrategy2.go b/programs/meteora_vault/RemoveStrategy2.go new file mode 100644 index 000000000..cefd411bb --- /dev/null +++ b/programs/meteora_vault/RemoveStrategy2.go @@ -0,0 +1,375 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// remove a strategy by advance payment +type RemoveStrategy2 struct { + MaxAdminPayAmount *uint64 + + // [0] = [WRITE] vault + // ··········· Vault account + // + // [1] = [WRITE] strategy + // ··········· Strategy account + // + // [2] = [] strategyProgram + // + // [3] = [WRITE] collateralVault + // ··········· Collateral vault account + // + // [4] = [WRITE] reserve + // + // [5] = [WRITE] tokenVault + // ··········· token_vault + // + // [6] = [WRITE] tokenAdminAdvancePayment + // ··········· token_advance_payemnt + // ··········· the owner of token_advance_payment must be admin + // + // [7] = [WRITE] tokenVaultAdvancePayment + // ··········· token_vault_advance_payment + // ··········· the account must be different from token_vault + // ··········· the owner of token_advance_payment must be vault + // + // [8] = [WRITE] feeVault + // ··········· fee_vault + // + // [9] = [WRITE] lpMint + // ··········· lp_mint + // + // [10] = [] tokenProgram + // ··········· token_program + // + // [11] = [SIGNER] admin + // ··········· admin + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewRemoveStrategy2InstructionBuilder creates a new `RemoveStrategy2` instruction builder. +func NewRemoveStrategy2InstructionBuilder() *RemoveStrategy2 { + nd := &RemoveStrategy2{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetMaxAdminPayAmount sets the "maxAdminPayAmount" parameter. +func (inst *RemoveStrategy2) SetMaxAdminPayAmount(maxAdminPayAmount uint64) *RemoveStrategy2 { + inst.MaxAdminPayAmount = &maxAdminPayAmount + return inst +} + +// SetVaultAccount sets the "vault" account. +// Vault account +func (inst *RemoveStrategy2) SetVaultAccount(vault ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// Vault account +func (inst *RemoveStrategy2) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// Strategy account +func (inst *RemoveStrategy2) SetStrategyAccount(strategy ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// Strategy account +func (inst *RemoveStrategy2) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *RemoveStrategy2) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[2] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *RemoveStrategy2) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// Collateral vault account +func (inst *RemoveStrategy2) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[3] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// Collateral vault account +func (inst *RemoveStrategy2) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *RemoveStrategy2) SetReserveAccount(reserve ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[4] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *RemoveStrategy2) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *RemoveStrategy2) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *RemoveStrategy2) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenAdminAdvancePaymentAccount sets the "tokenAdminAdvancePayment" account. +// token_advance_payemnt +// the owner of token_advance_payment must be admin +func (inst *RemoveStrategy2) SetTokenAdminAdvancePaymentAccount(tokenAdminAdvancePayment ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenAdminAdvancePayment).WRITE() + return inst +} + +// GetTokenAdminAdvancePaymentAccount gets the "tokenAdminAdvancePayment" account. +// token_advance_payemnt +// the owner of token_advance_payment must be admin +func (inst *RemoveStrategy2) GetTokenAdminAdvancePaymentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetTokenVaultAdvancePaymentAccount sets the "tokenVaultAdvancePayment" account. +// token_vault_advance_payment +// the account must be different from token_vault +// the owner of token_advance_payment must be vault +func (inst *RemoveStrategy2) SetTokenVaultAdvancePaymentAccount(tokenVaultAdvancePayment ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenVaultAdvancePayment).WRITE() + return inst +} + +// GetTokenVaultAdvancePaymentAccount gets the "tokenVaultAdvancePayment" account. +// token_vault_advance_payment +// the account must be different from token_vault +// the owner of token_advance_payment must be vault +func (inst *RemoveStrategy2) GetTokenVaultAdvancePaymentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetFeeVaultAccount sets the "feeVault" account. +// fee_vault +func (inst *RemoveStrategy2) SetFeeVaultAccount(feeVault ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[8] = ag_solanago.Meta(feeVault).WRITE() + return inst +} + +// GetFeeVaultAccount gets the "feeVault" account. +// fee_vault +func (inst *RemoveStrategy2) GetFeeVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *RemoveStrategy2) SetLpMintAccount(lpMint ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[9] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *RemoveStrategy2) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *RemoveStrategy2) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *RemoveStrategy2) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetAdminAccount sets the "admin" account. +// admin +func (inst *RemoveStrategy2) SetAdminAccount(admin ag_solanago.PublicKey) *RemoveStrategy2 { + inst.AccountMetaSlice[11] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// admin +func (inst *RemoveStrategy2) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst RemoveStrategy2) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RemoveStrategy2, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RemoveStrategy2) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RemoveStrategy2) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.MaxAdminPayAmount == nil { + return errors.New("MaxAdminPayAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenAdminAdvancePayment is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.TokenVaultAdvancePayment is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.FeeVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Admin is not set") + } + } + return nil +} + +func (inst *RemoveStrategy2) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RemoveStrategy2")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("MaxAdminPayAmount", *inst.MaxAdminPayAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" strategyProgram", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" collateralVault", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("tokenAdminAdvancePayment", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta("tokenVaultAdvancePayment", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" feeVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj RemoveStrategy2) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MaxAdminPayAmount` param: + err = encoder.Encode(obj.MaxAdminPayAmount) + if err != nil { + return err + } + return nil +} +func (obj *RemoveStrategy2) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MaxAdminPayAmount`: + err = decoder.Decode(&obj.MaxAdminPayAmount) + if err != nil { + return err + } + return nil +} + +// NewRemoveStrategy2Instruction declares a new RemoveStrategy2 instruction with the provided parameters and accounts. +func NewRemoveStrategy2Instruction( + // Parameters: + maxAdminPayAmount uint64, + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + tokenAdminAdvancePayment ag_solanago.PublicKey, + tokenVaultAdvancePayment ag_solanago.PublicKey, + feeVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + admin ag_solanago.PublicKey) *RemoveStrategy2 { + return NewRemoveStrategy2InstructionBuilder(). + SetMaxAdminPayAmount(maxAdminPayAmount). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetStrategyProgramAccount(strategyProgram). + SetCollateralVaultAccount(collateralVault). + SetReserveAccount(reserve). + SetTokenVaultAccount(tokenVault). + SetTokenAdminAdvancePaymentAccount(tokenAdminAdvancePayment). + SetTokenVaultAdvancePaymentAccount(tokenVaultAdvancePayment). + SetFeeVaultAccount(feeVault). + SetLpMintAccount(lpMint). + SetTokenProgramAccount(tokenProgram). + SetAdminAccount(admin) +} diff --git a/programs/meteora_vault/RemoveStrategy2_test.go b/programs/meteora_vault/RemoveStrategy2_test.go new file mode 100644 index 000000000..e36730299 --- /dev/null +++ b/programs/meteora_vault/RemoveStrategy2_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RemoveStrategy2(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RemoveStrategy2"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RemoveStrategy2) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RemoveStrategy2) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/RemoveStrategy_test.go b/programs/meteora_vault/RemoveStrategy_test.go new file mode 100644 index 000000000..647c08466 --- /dev/null +++ b/programs/meteora_vault/RemoveStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RemoveStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RemoveStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RemoveStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RemoveStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/SetOperator.go b/programs/meteora_vault/SetOperator.go new file mode 100644 index 000000000..f99e2b401 --- /dev/null +++ b/programs/meteora_vault/SetOperator.go @@ -0,0 +1,142 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// set new operator +type SetOperator struct { + + // [0] = [WRITE] vault + // ··········· Vault account + // + // [1] = [] operator + // + // [2] = [SIGNER] admin + // ··········· admin + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSetOperatorInstructionBuilder creates a new `SetOperator` instruction builder. +func NewSetOperatorInstructionBuilder() *SetOperator { + nd := &SetOperator{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetVaultAccount sets the "vault" account. +// Vault account +func (inst *SetOperator) SetVaultAccount(vault ag_solanago.PublicKey) *SetOperator { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// Vault account +func (inst *SetOperator) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetOperatorAccount sets the "operator" account. +func (inst *SetOperator) SetOperatorAccount(operator ag_solanago.PublicKey) *SetOperator { + inst.AccountMetaSlice[1] = ag_solanago.Meta(operator) + return inst +} + +// GetOperatorAccount gets the "operator" account. +func (inst *SetOperator) GetOperatorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetAdminAccount sets the "admin" account. +// admin +func (inst *SetOperator) SetAdminAccount(admin ag_solanago.PublicKey) *SetOperator { + inst.AccountMetaSlice[2] = ag_solanago.Meta(admin).SIGNER() + return inst +} + +// GetAdminAccount gets the "admin" account. +// admin +func (inst *SetOperator) GetAdminAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst SetOperator) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SetOperator, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SetOperator) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SetOperator) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Operator is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Admin is not set") + } + } + return nil +} + +func (inst *SetOperator) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SetOperator")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("operator", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" admin", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj SetOperator) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *SetOperator) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewSetOperatorInstruction declares a new SetOperator instruction with the provided parameters and accounts. +func NewSetOperatorInstruction( + // Accounts: + vault ag_solanago.PublicKey, + operator ag_solanago.PublicKey, + admin ag_solanago.PublicKey) *SetOperator { + return NewSetOperatorInstructionBuilder(). + SetVaultAccount(vault). + SetOperatorAccount(operator). + SetAdminAccount(admin) +} diff --git a/programs/meteora_vault/SetOperator_test.go b/programs/meteora_vault/SetOperator_test.go new file mode 100644 index 000000000..690702042 --- /dev/null +++ b/programs/meteora_vault/SetOperator_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SetOperator(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SetOperator"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SetOperator) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SetOperator) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Withdraw.go b/programs/meteora_vault/Withdraw.go new file mode 100644 index 000000000..16bd91041 --- /dev/null +++ b/programs/meteora_vault/Withdraw.go @@ -0,0 +1,285 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// user withdraw liquidity from vault +type Withdraw struct { + UnmintAmount *uint64 + MinOutAmount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] tokenVault + // ··········· token_vault + // + // [2] = [WRITE] lpMint + // ··········· lp_mint + // + // [3] = [WRITE] userToken + // ··········· user_token + // + // [4] = [WRITE] userLp + // ··········· user_lp + // + // [5] = [SIGNER] user + // ··········· user + // + // [6] = [] tokenProgram + // ··········· token_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. +func NewWithdrawInstructionBuilder() *Withdraw { + nd := &Withdraw{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 7), + } + return nd +} + +// SetUnmintAmount sets the "unmintAmount" parameter. +func (inst *Withdraw) SetUnmintAmount(unmintAmount uint64) *Withdraw { + inst.UnmintAmount = &unmintAmount + return inst +} + +// SetMinOutAmount sets the "minOutAmount" parameter. +func (inst *Withdraw) SetMinOutAmount(minOutAmount uint64) *Withdraw { + inst.MinOutAmount = &minOutAmount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *Withdraw) SetVaultAccount(vault ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *Withdraw) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *Withdraw) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *Withdraw) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *Withdraw) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[2] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *Withdraw) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetUserTokenAccount sets the "userToken" account. +// user_token +func (inst *Withdraw) SetUserTokenAccount(userToken ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[3] = ag_solanago.Meta(userToken).WRITE() + return inst +} + +// GetUserTokenAccount gets the "userToken" account. +// user_token +func (inst *Withdraw) GetUserTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetUserLpAccount sets the "userLp" account. +// user_lp +func (inst *Withdraw) SetUserLpAccount(userLp ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[4] = ag_solanago.Meta(userLp).WRITE() + return inst +} + +// GetUserLpAccount gets the "userLp" account. +// user_lp +func (inst *Withdraw) GetUserLpAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetUserAccount sets the "user" account. +// user +func (inst *Withdraw) SetUserAccount(user ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[5] = ag_solanago.Meta(user).SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +// user +func (inst *Withdraw) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *Withdraw) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *Withdraw) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +func (inst Withdraw) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.UnmintAmount == nil { + return errors.New("UnmintAmount parameter is not set") + } + if inst.MinOutAmount == nil { + return errors.New("MinOutAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.UserToken is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.UserLp is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("UnmintAmount", *inst.UnmintAmount)) + paramsBranch.Child(ag_format.Param("MinOutAmount", *inst.MinOutAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=7]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" userToken", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" userLp", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("tokenProgram", inst.AccountMetaSlice.Get(6))) + }) + }) + }) +} + +func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `UnmintAmount` param: + err = encoder.Encode(obj.UnmintAmount) + if err != nil { + return err + } + // Serialize `MinOutAmount` param: + err = encoder.Encode(obj.MinOutAmount) + if err != nil { + return err + } + return nil +} +func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `UnmintAmount`: + err = decoder.Decode(&obj.UnmintAmount) + if err != nil { + return err + } + // Deserialize `MinOutAmount`: + err = decoder.Decode(&obj.MinOutAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. +func NewWithdrawInstruction( + // Parameters: + unmintAmount uint64, + minOutAmount uint64, + // Accounts: + vault ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + userToken ag_solanago.PublicKey, + userLp ag_solanago.PublicKey, + user ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *Withdraw { + return NewWithdrawInstructionBuilder(). + SetUnmintAmount(unmintAmount). + SetMinOutAmount(minOutAmount). + SetVaultAccount(vault). + SetTokenVaultAccount(tokenVault). + SetLpMintAccount(lpMint). + SetUserTokenAccount(userToken). + SetUserLpAccount(userLp). + SetUserAccount(user). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/Withdraw2.go b/programs/meteora_vault/Withdraw2.go new file mode 100644 index 000000000..992db15ea --- /dev/null +++ b/programs/meteora_vault/Withdraw2.go @@ -0,0 +1,285 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Withdraw v2. Withdraw from token vault if no remaining accounts are available. Else, it will attempt to withdraw from strategy and token vault. This method just proxy between 2 methods. Protocol integration should be using withdraw instead of this function. +type Withdraw2 struct { + UnmintAmount *uint64 + MinOutAmount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] tokenVault + // ··········· token_vault + // + // [2] = [WRITE] lpMint + // ··········· lp_mint + // + // [3] = [WRITE] userToken + // ··········· user_token + // + // [4] = [WRITE] userLp + // ··········· user_lp + // + // [5] = [SIGNER] user + // ··········· user + // + // [6] = [] tokenProgram + // ··········· token_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdraw2InstructionBuilder creates a new `Withdraw2` instruction builder. +func NewWithdraw2InstructionBuilder() *Withdraw2 { + nd := &Withdraw2{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 7), + } + return nd +} + +// SetUnmintAmount sets the "unmintAmount" parameter. +func (inst *Withdraw2) SetUnmintAmount(unmintAmount uint64) *Withdraw2 { + inst.UnmintAmount = &unmintAmount + return inst +} + +// SetMinOutAmount sets the "minOutAmount" parameter. +func (inst *Withdraw2) SetMinOutAmount(minOutAmount uint64) *Withdraw2 { + inst.MinOutAmount = &minOutAmount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *Withdraw2) SetVaultAccount(vault ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *Withdraw2) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *Withdraw2) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *Withdraw2) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *Withdraw2) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[2] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *Withdraw2) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetUserTokenAccount sets the "userToken" account. +// user_token +func (inst *Withdraw2) SetUserTokenAccount(userToken ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[3] = ag_solanago.Meta(userToken).WRITE() + return inst +} + +// GetUserTokenAccount gets the "userToken" account. +// user_token +func (inst *Withdraw2) GetUserTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetUserLpAccount sets the "userLp" account. +// user_lp +func (inst *Withdraw2) SetUserLpAccount(userLp ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[4] = ag_solanago.Meta(userLp).WRITE() + return inst +} + +// GetUserLpAccount gets the "userLp" account. +// user_lp +func (inst *Withdraw2) GetUserLpAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetUserAccount sets the "user" account. +// user +func (inst *Withdraw2) SetUserAccount(user ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[5] = ag_solanago.Meta(user).SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +// user +func (inst *Withdraw2) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *Withdraw2) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Withdraw2 { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *Withdraw2) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +func (inst Withdraw2) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw2, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw2) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw2) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.UnmintAmount == nil { + return errors.New("UnmintAmount parameter is not set") + } + if inst.MinOutAmount == nil { + return errors.New("MinOutAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.UserToken is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.UserLp is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *Withdraw2) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw2")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("UnmintAmount", *inst.UnmintAmount)) + paramsBranch.Child(ag_format.Param("MinOutAmount", *inst.MinOutAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=7]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" userToken", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" userLp", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("tokenProgram", inst.AccountMetaSlice.Get(6))) + }) + }) + }) +} + +func (obj Withdraw2) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `UnmintAmount` param: + err = encoder.Encode(obj.UnmintAmount) + if err != nil { + return err + } + // Serialize `MinOutAmount` param: + err = encoder.Encode(obj.MinOutAmount) + if err != nil { + return err + } + return nil +} +func (obj *Withdraw2) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `UnmintAmount`: + err = decoder.Decode(&obj.UnmintAmount) + if err != nil { + return err + } + // Deserialize `MinOutAmount`: + err = decoder.Decode(&obj.MinOutAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdraw2Instruction declares a new Withdraw2 instruction with the provided parameters and accounts. +func NewWithdraw2Instruction( + // Parameters: + unmintAmount uint64, + minOutAmount uint64, + // Accounts: + vault ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + userToken ag_solanago.PublicKey, + userLp ag_solanago.PublicKey, + user ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *Withdraw2 { + return NewWithdraw2InstructionBuilder(). + SetUnmintAmount(unmintAmount). + SetMinOutAmount(minOutAmount). + SetVaultAccount(vault). + SetTokenVaultAccount(tokenVault). + SetLpMintAccount(lpMint). + SetUserTokenAccount(userToken). + SetUserLpAccount(userLp). + SetUserAccount(user). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/Withdraw2_test.go b/programs/meteora_vault/Withdraw2_test.go new file mode 100644 index 000000000..7eb3ed1a5 --- /dev/null +++ b/programs/meteora_vault/Withdraw2_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Withdraw2(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Withdraw2"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Withdraw2) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Withdraw2) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/WithdrawDirectlyFromStrategy.go b/programs/meteora_vault/WithdrawDirectlyFromStrategy.go new file mode 100644 index 000000000..41826c4d5 --- /dev/null +++ b/programs/meteora_vault/WithdrawDirectlyFromStrategy.go @@ -0,0 +1,389 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly +type WithdrawDirectlyFromStrategy struct { + UnmintAmount *uint64 + MinOutAmount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] strategy + // ··········· strategy + // + // [2] = [WRITE] reserve + // + // [3] = [] strategyProgram + // + // [4] = [WRITE] collateralVault + // ··········· collateral_vault + // + // [5] = [WRITE] tokenVault + // ··········· token_vault + // + // [6] = [WRITE] lpMint + // ··········· lp_mint + // + // [7] = [WRITE] feeVault + // ··········· fee_vault + // + // [8] = [WRITE] userToken + // ··········· user_token + // + // [9] = [WRITE] userLp + // ··········· user_lp + // + // [10] = [SIGNER] user + // ··········· user + // + // [11] = [] tokenProgram + // ··········· token_program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawDirectlyFromStrategyInstructionBuilder creates a new `WithdrawDirectlyFromStrategy` instruction builder. +func NewWithdrawDirectlyFromStrategyInstructionBuilder() *WithdrawDirectlyFromStrategy { + nd := &WithdrawDirectlyFromStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetUnmintAmount sets the "unmintAmount" parameter. +func (inst *WithdrawDirectlyFromStrategy) SetUnmintAmount(unmintAmount uint64) *WithdrawDirectlyFromStrategy { + inst.UnmintAmount = &unmintAmount + return inst +} + +// SetMinOutAmount sets the "minOutAmount" parameter. +func (inst *WithdrawDirectlyFromStrategy) SetMinOutAmount(minOutAmount uint64) *WithdrawDirectlyFromStrategy { + inst.MinOutAmount = &minOutAmount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *WithdrawDirectlyFromStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *WithdrawDirectlyFromStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// strategy +func (inst *WithdrawDirectlyFromStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// strategy +func (inst *WithdrawDirectlyFromStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *WithdrawDirectlyFromStrategy) SetReserveAccount(reserve ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *WithdrawDirectlyFromStrategy) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *WithdrawDirectlyFromStrategy) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *WithdrawDirectlyFromStrategy) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// collateral_vault +func (inst *WithdrawDirectlyFromStrategy) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// collateral_vault +func (inst *WithdrawDirectlyFromStrategy) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *WithdrawDirectlyFromStrategy) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *WithdrawDirectlyFromStrategy) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *WithdrawDirectlyFromStrategy) SetLpMintAccount(lpMint ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *WithdrawDirectlyFromStrategy) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetFeeVaultAccount sets the "feeVault" account. +// fee_vault +func (inst *WithdrawDirectlyFromStrategy) SetFeeVaultAccount(feeVault ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(feeVault).WRITE() + return inst +} + +// GetFeeVaultAccount gets the "feeVault" account. +// fee_vault +func (inst *WithdrawDirectlyFromStrategy) GetFeeVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetUserTokenAccount sets the "userToken" account. +// user_token +func (inst *WithdrawDirectlyFromStrategy) SetUserTokenAccount(userToken ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(userToken).WRITE() + return inst +} + +// GetUserTokenAccount gets the "userToken" account. +// user_token +func (inst *WithdrawDirectlyFromStrategy) GetUserTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetUserLpAccount sets the "userLp" account. +// user_lp +func (inst *WithdrawDirectlyFromStrategy) SetUserLpAccount(userLp ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(userLp).WRITE() + return inst +} + +// GetUserLpAccount gets the "userLp" account. +// user_lp +func (inst *WithdrawDirectlyFromStrategy) GetUserLpAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetUserAccount sets the "user" account. +// user +func (inst *WithdrawDirectlyFromStrategy) SetUserAccount(user ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[10] = ag_solanago.Meta(user).SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +// user +func (inst *WithdrawDirectlyFromStrategy) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *WithdrawDirectlyFromStrategy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *WithdrawDirectlyFromStrategy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst WithdrawDirectlyFromStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_WithdrawDirectlyFromStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst WithdrawDirectlyFromStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *WithdrawDirectlyFromStrategy) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.UnmintAmount == nil { + return errors.New("UnmintAmount parameter is not set") + } + if inst.MinOutAmount == nil { + return errors.New("MinOutAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.FeeVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.UserToken is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.UserLp is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *WithdrawDirectlyFromStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("WithdrawDirectlyFromStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("UnmintAmount", *inst.UnmintAmount)) + paramsBranch.Child(ag_format.Param("MinOutAmount", *inst.MinOutAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("strategyProgram", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("collateralVault", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" feeVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" userToken", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" userLp", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj WithdrawDirectlyFromStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `UnmintAmount` param: + err = encoder.Encode(obj.UnmintAmount) + if err != nil { + return err + } + // Serialize `MinOutAmount` param: + err = encoder.Encode(obj.MinOutAmount) + if err != nil { + return err + } + return nil +} +func (obj *WithdrawDirectlyFromStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `UnmintAmount`: + err = decoder.Decode(&obj.UnmintAmount) + if err != nil { + return err + } + // Deserialize `MinOutAmount`: + err = decoder.Decode(&obj.MinOutAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawDirectlyFromStrategyInstruction declares a new WithdrawDirectlyFromStrategy instruction with the provided parameters and accounts. +func NewWithdrawDirectlyFromStrategyInstruction( + // Parameters: + unmintAmount uint64, + minOutAmount uint64, + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + feeVault ag_solanago.PublicKey, + userToken ag_solanago.PublicKey, + userLp ag_solanago.PublicKey, + user ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *WithdrawDirectlyFromStrategy { + return NewWithdrawDirectlyFromStrategyInstructionBuilder(). + SetUnmintAmount(unmintAmount). + SetMinOutAmount(minOutAmount). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetReserveAccount(reserve). + SetStrategyProgramAccount(strategyProgram). + SetCollateralVaultAccount(collateralVault). + SetTokenVaultAccount(tokenVault). + SetLpMintAccount(lpMint). + SetFeeVaultAccount(feeVault). + SetUserTokenAccount(userToken). + SetUserLpAccount(userLp). + SetUserAccount(user). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/meteora_vault/WithdrawDirectlyFromStrategy_test.go b/programs/meteora_vault/WithdrawDirectlyFromStrategy_test.go new file mode 100644 index 000000000..3b20d149f --- /dev/null +++ b/programs/meteora_vault/WithdrawDirectlyFromStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_WithdrawDirectlyFromStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("WithdrawDirectlyFromStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(WithdrawDirectlyFromStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(WithdrawDirectlyFromStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/WithdrawStrategy.go b/programs/meteora_vault/WithdrawStrategy.go new file mode 100644 index 000000000..89c979667 --- /dev/null +++ b/programs/meteora_vault/WithdrawStrategy.go @@ -0,0 +1,322 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// withdraw liquidity from a strategy +type WithdrawStrategy struct { + Amount *uint64 + + // [0] = [WRITE] vault + // ··········· vault + // + // [1] = [WRITE] strategy + // ··········· strategy + // + // [2] = [WRITE] tokenVault + // ··········· token_vault + // + // [3] = [WRITE] feeVault + // ··········· fee_vault + // + // [4] = [WRITE] lpMint + // ··········· lp_mint + // + // [5] = [] strategyProgram + // + // [6] = [WRITE] collateralVault + // ··········· collateral_vault + // + // [7] = [WRITE] reserve + // + // [8] = [] tokenProgram + // ··········· token_program + // + // [9] = [SIGNER] operator + // ··········· operator + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawStrategyInstructionBuilder creates a new `WithdrawStrategy` instruction builder. +func NewWithdrawStrategyInstructionBuilder() *WithdrawStrategy { + nd := &WithdrawStrategy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *WithdrawStrategy) SetAmount(amount uint64) *WithdrawStrategy { + inst.Amount = &amount + return inst +} + +// SetVaultAccount sets the "vault" account. +// vault +func (inst *WithdrawStrategy) SetVaultAccount(vault ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(vault).WRITE() + return inst +} + +// GetVaultAccount gets the "vault" account. +// vault +func (inst *WithdrawStrategy) GetVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetStrategyAccount sets the "strategy" account. +// strategy +func (inst *WithdrawStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() + return inst +} + +// GetStrategyAccount gets the "strategy" account. +// strategy +func (inst *WithdrawStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetTokenVaultAccount sets the "tokenVault" account. +// token_vault +func (inst *WithdrawStrategy) SetTokenVaultAccount(tokenVault ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(tokenVault).WRITE() + return inst +} + +// GetTokenVaultAccount gets the "tokenVault" account. +// token_vault +func (inst *WithdrawStrategy) GetTokenVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetFeeVaultAccount sets the "feeVault" account. +// fee_vault +func (inst *WithdrawStrategy) SetFeeVaultAccount(feeVault ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(feeVault).WRITE() + return inst +} + +// GetFeeVaultAccount gets the "feeVault" account. +// fee_vault +func (inst *WithdrawStrategy) GetFeeVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetLpMintAccount sets the "lpMint" account. +// lp_mint +func (inst *WithdrawStrategy) SetLpMintAccount(lpMint ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// lp_mint +func (inst *WithdrawStrategy) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetStrategyProgramAccount sets the "strategyProgram" account. +func (inst *WithdrawStrategy) SetStrategyProgramAccount(strategyProgram ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(strategyProgram) + return inst +} + +// GetStrategyProgramAccount gets the "strategyProgram" account. +func (inst *WithdrawStrategy) GetStrategyProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetCollateralVaultAccount sets the "collateralVault" account. +// collateral_vault +func (inst *WithdrawStrategy) SetCollateralVaultAccount(collateralVault ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(collateralVault).WRITE() + return inst +} + +// GetCollateralVaultAccount gets the "collateralVault" account. +// collateral_vault +func (inst *WithdrawStrategy) GetCollateralVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetReserveAccount sets the "reserve" account. +func (inst *WithdrawStrategy) SetReserveAccount(reserve ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(reserve).WRITE() + return inst +} + +// GetReserveAccount gets the "reserve" account. +func (inst *WithdrawStrategy) GetReserveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token_program +func (inst *WithdrawStrategy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token_program +func (inst *WithdrawStrategy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetOperatorAccount sets the "operator" account. +// operator +func (inst *WithdrawStrategy) SetOperatorAccount(operator ag_solanago.PublicKey) *WithdrawStrategy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(operator).SIGNER() + return inst +} + +// GetOperatorAccount gets the "operator" account. +// operator +func (inst *WithdrawStrategy) GetOperatorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst WithdrawStrategy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_WithdrawStrategy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst WithdrawStrategy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *WithdrawStrategy) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Vault is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Strategy is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.TokenVault is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.FeeVault is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.StrategyProgram is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.CollateralVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Reserve is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.Operator is not set") + } + } + return nil +} + +func (inst *WithdrawStrategy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("WithdrawStrategy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Amount", *inst.Amount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" tokenVault", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" feeVault", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta("strategyProgram", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta("collateralVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" reserve", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" operator", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj WithdrawStrategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + return nil +} +func (obj *WithdrawStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawStrategyInstruction declares a new WithdrawStrategy instruction with the provided parameters and accounts. +func NewWithdrawStrategyInstruction( + // Parameters: + amount uint64, + // Accounts: + vault ag_solanago.PublicKey, + strategy ag_solanago.PublicKey, + tokenVault ag_solanago.PublicKey, + feeVault ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + strategyProgram ag_solanago.PublicKey, + collateralVault ag_solanago.PublicKey, + reserve ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + operator ag_solanago.PublicKey) *WithdrawStrategy { + return NewWithdrawStrategyInstructionBuilder(). + SetAmount(amount). + SetVaultAccount(vault). + SetStrategyAccount(strategy). + SetTokenVaultAccount(tokenVault). + SetFeeVaultAccount(feeVault). + SetLpMintAccount(lpMint). + SetStrategyProgramAccount(strategyProgram). + SetCollateralVaultAccount(collateralVault). + SetReserveAccount(reserve). + SetTokenProgramAccount(tokenProgram). + SetOperatorAccount(operator) +} diff --git a/programs/meteora_vault/WithdrawStrategy_test.go b/programs/meteora_vault/WithdrawStrategy_test.go new file mode 100644 index 000000000..f4d486c26 --- /dev/null +++ b/programs/meteora_vault/WithdrawStrategy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_WithdrawStrategy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("WithdrawStrategy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(WithdrawStrategy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(WithdrawStrategy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/Withdraw_test.go b/programs/meteora_vault/Withdraw_test.go new file mode 100644 index 000000000..75b1ce59f --- /dev/null +++ b/programs/meteora_vault/Withdraw_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Withdraw(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Withdraw"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Withdraw) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Withdraw) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/meteora_vault/accounts.go b/programs/meteora_vault/accounts.go new file mode 100644 index 000000000..013f533bb --- /dev/null +++ b/programs/meteora_vault/accounts.go @@ -0,0 +1,316 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type Vault struct { + // The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault. + Enabled uint8 + + // Vault nonce, to create vault seeds + Bumps VaultBumps + + // The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies. + TotalAmount uint64 + + // Token account, hold liquidity in vault reserve + TokenVault ag_solanago.PublicKey + + // Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address + FeeVault ag_solanago.PublicKey + + // Token mint that vault supports + TokenMint ag_solanago.PublicKey + + // Lp mint of vault + LpMint ag_solanago.PublicKey + + // The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time. + Strategies [30]ag_solanago.PublicKey + + // The base address to create vault seeds + Base ag_solanago.PublicKey + + // Admin of vault + Admin ag_solanago.PublicKey + + // Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address + Operator ag_solanago.PublicKey + + // Stores information for locked profit. + LockedProfitTracker LockedProfitTracker +} + +var VaultDiscriminator = [8]byte{211, 8, 232, 43, 2, 152, 117, 119} + +func (obj Vault) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(VaultDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Enabled` param: + err = encoder.Encode(obj.Enabled) + if err != nil { + return err + } + // Serialize `Bumps` param: + err = encoder.Encode(obj.Bumps) + if err != nil { + return err + } + // Serialize `TotalAmount` param: + err = encoder.Encode(obj.TotalAmount) + if err != nil { + return err + } + // Serialize `TokenVault` param: + err = encoder.Encode(obj.TokenVault) + if err != nil { + return err + } + // Serialize `FeeVault` param: + err = encoder.Encode(obj.FeeVault) + if err != nil { + return err + } + // Serialize `TokenMint` param: + err = encoder.Encode(obj.TokenMint) + if err != nil { + return err + } + // Serialize `LpMint` param: + err = encoder.Encode(obj.LpMint) + if err != nil { + return err + } + // Serialize `Strategies` param: + err = encoder.Encode(obj.Strategies) + if err != nil { + return err + } + // Serialize `Base` param: + err = encoder.Encode(obj.Base) + if err != nil { + return err + } + // Serialize `Admin` param: + err = encoder.Encode(obj.Admin) + if err != nil { + return err + } + // Serialize `Operator` param: + err = encoder.Encode(obj.Operator) + if err != nil { + return err + } + // Serialize `LockedProfitTracker` param: + err = encoder.Encode(obj.LockedProfitTracker) + if err != nil { + return err + } + return nil +} + +func (obj *Vault) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(VaultDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[211 8 232 43 2 152 117 119]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Enabled`: + err = decoder.Decode(&obj.Enabled) + if err != nil { + return err + } + // Deserialize `Bumps`: + err = decoder.Decode(&obj.Bumps) + if err != nil { + return err + } + // Deserialize `TotalAmount`: + err = decoder.Decode(&obj.TotalAmount) + if err != nil { + return err + } + // Deserialize `TokenVault`: + err = decoder.Decode(&obj.TokenVault) + if err != nil { + return err + } + // Deserialize `FeeVault`: + err = decoder.Decode(&obj.FeeVault) + if err != nil { + return err + } + // Deserialize `TokenMint`: + err = decoder.Decode(&obj.TokenMint) + if err != nil { + return err + } + // Deserialize `LpMint`: + err = decoder.Decode(&obj.LpMint) + if err != nil { + return err + } + // Deserialize `Strategies`: + err = decoder.Decode(&obj.Strategies) + if err != nil { + return err + } + // Deserialize `Base`: + err = decoder.Decode(&obj.Base) + if err != nil { + return err + } + // Deserialize `Admin`: + err = decoder.Decode(&obj.Admin) + if err != nil { + return err + } + // Deserialize `Operator`: + err = decoder.Decode(&obj.Operator) + if err != nil { + return err + } + // Deserialize `LockedProfitTracker`: + err = decoder.Decode(&obj.LockedProfitTracker) + if err != nil { + return err + } + return nil +} + +type Strategy struct { + // Lending pool address, that the strategy will deposit/withdraw balance + Reserve ag_solanago.PublicKey + + // The token account, that holds the collateral token + CollateralVault ag_solanago.PublicKey + + // Specify type of strategy + StrategyType StrategyType + + // The liquidity in strategy at the time vault deposit/withdraw from a lending protocol + CurrentLiquidity uint64 + + // Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call. + Bumps [10]uint8 + + // Vault address, that the strategy belongs + Vault ag_solanago.PublicKey + + // If we remove strategy by remove_strategy2 endpoint, this account will be never added again + IsDisable uint8 +} + +var StrategyDiscriminator = [8]byte{174, 110, 39, 119, 82, 106, 169, 102} + +func (obj Strategy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(StrategyDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Reserve` param: + err = encoder.Encode(obj.Reserve) + if err != nil { + return err + } + // Serialize `CollateralVault` param: + err = encoder.Encode(obj.CollateralVault) + if err != nil { + return err + } + // Serialize `StrategyType` param: + err = encoder.Encode(obj.StrategyType) + if err != nil { + return err + } + // Serialize `CurrentLiquidity` param: + err = encoder.Encode(obj.CurrentLiquidity) + if err != nil { + return err + } + // Serialize `Bumps` param: + err = encoder.Encode(obj.Bumps) + if err != nil { + return err + } + // Serialize `Vault` param: + err = encoder.Encode(obj.Vault) + if err != nil { + return err + } + // Serialize `IsDisable` param: + err = encoder.Encode(obj.IsDisable) + if err != nil { + return err + } + return nil +} + +func (obj *Strategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(StrategyDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[174 110 39 119 82 106 169 102]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Reserve`: + err = decoder.Decode(&obj.Reserve) + if err != nil { + return err + } + // Deserialize `CollateralVault`: + err = decoder.Decode(&obj.CollateralVault) + if err != nil { + return err + } + // Deserialize `StrategyType`: + err = decoder.Decode(&obj.StrategyType) + if err != nil { + return err + } + // Deserialize `CurrentLiquidity`: + err = decoder.Decode(&obj.CurrentLiquidity) + if err != nil { + return err + } + // Deserialize `Bumps`: + err = decoder.Decode(&obj.Bumps) + if err != nil { + return err + } + // Deserialize `Vault`: + err = decoder.Decode(&obj.Vault) + if err != nil { + return err + } + // Deserialize `IsDisable`: + err = decoder.Decode(&obj.IsDisable) + if err != nil { + return err + } + return nil +} diff --git a/programs/meteora_vault/instructions.go b/programs/meteora_vault/instructions.go new file mode 100644 index 000000000..24c5dc618 --- /dev/null +++ b/programs/meteora_vault/instructions.go @@ -0,0 +1,224 @@ +// Program for vault +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "MeteoraVault" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + // initialize new vault + Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) + + // enable vault + Instruction_EnableVault = ag_binary.TypeID([8]byte{145, 82, 241, 156, 26, 154, 233, 211}) + + // set new operator + Instruction_SetOperator = ag_binary.TypeID([8]byte{238, 153, 101, 169, 243, 131, 36, 1}) + + // Initialize a strategy and add strategy to vault.strategies index + Instruction_InitializeStrategy = ag_binary.TypeID([8]byte{208, 119, 144, 145, 178, 57, 105, 252}) + + // remove a strategy + Instruction_RemoveStrategy = ag_binary.TypeID([8]byte{185, 238, 33, 91, 134, 210, 97, 26}) + + // remove a strategy by advance payment + Instruction_RemoveStrategy2 = ag_binary.TypeID([8]byte{138, 104, 208, 148, 126, 35, 195, 14}) + + // collect token, that someone send wrongly + // also help in case Mango reimbursement + Instruction_CollectDust = ag_binary.TypeID([8]byte{246, 149, 21, 82, 160, 74, 254, 240}) + + // add a strategy + Instruction_AddStrategy = ag_binary.TypeID([8]byte{64, 123, 127, 227, 192, 234, 198, 20}) + + // deposit liquidity to a strategy + Instruction_DepositStrategy = ag_binary.TypeID([8]byte{246, 82, 57, 226, 131, 222, 253, 249}) + + // withdraw liquidity from a strategy + Instruction_WithdrawStrategy = ag_binary.TypeID([8]byte{31, 45, 162, 5, 193, 217, 134, 188}) + + // Withdraw v2. Withdraw from token vault if no remaining accounts are available. Else, it will attempt to withdraw from strategy and token vault. This method just proxy between 2 methods. Protocol integration should be using withdraw instead of this function. + Instruction_Withdraw2 = ag_binary.TypeID([8]byte{80, 6, 111, 73, 174, 211, 66, 132}) + + // user deposit liquidity to vault + Instruction_Deposit = ag_binary.TypeID([8]byte{242, 35, 198, 137, 82, 225, 242, 182}) + + // user withdraw liquidity from vault + Instruction_Withdraw = ag_binary.TypeID([8]byte{183, 18, 70, 156, 148, 109, 161, 34}) + + // user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly + Instruction_WithdrawDirectlyFromStrategy = ag_binary.TypeID([8]byte{201, 141, 146, 46, 173, 116, 198, 22}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_Initialize: + return "Initialize" + case Instruction_EnableVault: + return "EnableVault" + case Instruction_SetOperator: + return "SetOperator" + case Instruction_InitializeStrategy: + return "InitializeStrategy" + case Instruction_RemoveStrategy: + return "RemoveStrategy" + case Instruction_RemoveStrategy2: + return "RemoveStrategy2" + case Instruction_CollectDust: + return "CollectDust" + case Instruction_AddStrategy: + return "AddStrategy" + case Instruction_DepositStrategy: + return "DepositStrategy" + case Instruction_WithdrawStrategy: + return "WithdrawStrategy" + case Instruction_Withdraw2: + return "Withdraw2" + case Instruction_Deposit: + return "Deposit" + case Instruction_Withdraw: + return "Withdraw" + case Instruction_WithdrawDirectlyFromStrategy: + return "WithdrawDirectlyFromStrategy" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "initialize", (*Initialize)(nil), + }, + { + "enable_vault", (*EnableVault)(nil), + }, + { + "set_operator", (*SetOperator)(nil), + }, + { + "initialize_strategy", (*InitializeStrategy)(nil), + }, + { + "remove_strategy", (*RemoveStrategy)(nil), + }, + { + "remove_strategy2", (*RemoveStrategy2)(nil), + }, + { + "collect_dust", (*CollectDust)(nil), + }, + { + "add_strategy", (*AddStrategy)(nil), + }, + { + "deposit_strategy", (*DepositStrategy)(nil), + }, + { + "withdraw_strategy", (*WithdrawStrategy)(nil), + }, + { + "withdraw2", (*Withdraw2)(nil), + }, + { + "deposit", (*Deposit)(nil), + }, + { + "withdraw", (*Withdraw)(nil), + }, + { + "withdraw_directly_from_strategy", (*WithdrawDirectlyFromStrategy)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/meteora_vault/testing_utils.go b/programs/meteora_vault/testing_utils.go new file mode 100644 index 000000000..1eec77ba3 --- /dev/null +++ b/programs/meteora_vault/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/meteora_vault/types.go b/programs/meteora_vault/types.go new file mode 100644 index 000000000..46c559930 --- /dev/null +++ b/programs/meteora_vault/types.go @@ -0,0 +1,174 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package meteora_vault + +import ag_binary "github.com/gagliardetto/binary" + +type VaultBumps struct { + // vault_bump + VaultBump uint8 + + // token_vault_bump + TokenVaultBump uint8 +} + +func (obj VaultBumps) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `VaultBump` param: + err = encoder.Encode(obj.VaultBump) + if err != nil { + return err + } + // Serialize `TokenVaultBump` param: + err = encoder.Encode(obj.TokenVaultBump) + if err != nil { + return err + } + return nil +} + +func (obj *VaultBumps) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `VaultBump`: + err = decoder.Decode(&obj.VaultBump) + if err != nil { + return err + } + // Deserialize `TokenVaultBump`: + err = decoder.Decode(&obj.TokenVaultBump) + if err != nil { + return err + } + return nil +} + +type StrategyBumps struct { + // strategy_index + StrategyIndex uint8 + + // Bumps of PDAs for the integrated protocol. + OtherBumps [10]uint8 +} + +func (obj StrategyBumps) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `StrategyIndex` param: + err = encoder.Encode(obj.StrategyIndex) + if err != nil { + return err + } + // Serialize `OtherBumps` param: + err = encoder.Encode(obj.OtherBumps) + if err != nil { + return err + } + return nil +} + +func (obj *StrategyBumps) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `StrategyIndex`: + err = decoder.Decode(&obj.StrategyIndex) + if err != nil { + return err + } + // Deserialize `OtherBumps`: + err = decoder.Decode(&obj.OtherBumps) + if err != nil { + return err + } + return nil +} + +type LockedProfitTracker struct { + // The total locked profit from the last report + LastUpdatedLockedProfit uint64 + + // The last timestamp (in seconds) rebalancing + LastReport uint64 + + // Rate per second of degradation + LockedProfitDegradation uint64 +} + +func (obj LockedProfitTracker) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `LastUpdatedLockedProfit` param: + err = encoder.Encode(obj.LastUpdatedLockedProfit) + if err != nil { + return err + } + // Serialize `LastReport` param: + err = encoder.Encode(obj.LastReport) + if err != nil { + return err + } + // Serialize `LockedProfitDegradation` param: + err = encoder.Encode(obj.LockedProfitDegradation) + if err != nil { + return err + } + return nil +} + +func (obj *LockedProfitTracker) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `LastUpdatedLockedProfit`: + err = decoder.Decode(&obj.LastUpdatedLockedProfit) + if err != nil { + return err + } + // Deserialize `LastReport`: + err = decoder.Decode(&obj.LastReport) + if err != nil { + return err + } + // Deserialize `LockedProfitDegradation`: + err = decoder.Decode(&obj.LockedProfitDegradation) + if err != nil { + return err + } + return nil +} + +type StrategyType ag_binary.BorshEnum + +const ( + StrategyTypePortFinanceWithoutLM StrategyType = iota + StrategyTypePortFinanceWithLM + StrategyTypeSolendWithoutLM + StrategyTypeMango + StrategyTypeSolendWithLM + StrategyTypeApricotWithoutLM + StrategyTypeFrancium + StrategyTypeTulip + StrategyTypeVault + StrategyTypeDrift + StrategyTypeFrakt + StrategyTypeMarginfi +) + +func (value StrategyType) String() string { + switch value { + case StrategyTypePortFinanceWithoutLM: + return "PortFinanceWithoutLM" + case StrategyTypePortFinanceWithLM: + return "PortFinanceWithLM" + case StrategyTypeSolendWithoutLM: + return "SolendWithoutLM" + case StrategyTypeMango: + return "Mango" + case StrategyTypeSolendWithLM: + return "SolendWithLM" + case StrategyTypeApricotWithoutLM: + return "ApricotWithoutLM" + case StrategyTypeFrancium: + return "Francium" + case StrategyTypeTulip: + return "Tulip" + case StrategyTypeVault: + return "Vault" + case StrategyTypeDrift: + return "Drift" + case StrategyTypeFrakt: + return "Frakt" + case StrategyTypeMarginfi: + return "Marginfi" + default: + return "" + } +} diff --git a/programs/phoenix_v1/CancelAllOrders.go b/programs/phoenix_v1/CancelAllOrders.go new file mode 100644 index 000000000..3558d7230 --- /dev/null +++ b/programs/phoenix_v1/CancelAllOrders.go @@ -0,0 +1,250 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelAllOrders is the `CancelAllOrders` instruction. +type CancelAllOrders struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelAllOrdersInstructionBuilder creates a new `CancelAllOrders` instruction builder. +func NewCancelAllOrdersInstructionBuilder() *CancelAllOrders { + nd := &CancelAllOrders{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelAllOrders) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelAllOrders) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelAllOrders) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelAllOrders) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelAllOrders) SetMarketAccount(market ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelAllOrders) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelAllOrders) SetTraderAccount(trader ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelAllOrders) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *CancelAllOrders) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *CancelAllOrders) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *CancelAllOrders) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *CancelAllOrders) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *CancelAllOrders) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *CancelAllOrders) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *CancelAllOrders) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *CancelAllOrders) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *CancelAllOrders) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CancelAllOrders { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *CancelAllOrders) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst CancelAllOrders) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelAllOrders, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelAllOrders) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelAllOrders) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *CancelAllOrders) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelAllOrders")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj CancelAllOrders) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *CancelAllOrders) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewCancelAllOrdersInstruction declares a new CancelAllOrders instruction with the provided parameters and accounts. +func NewCancelAllOrdersInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *CancelAllOrders { + return NewCancelAllOrdersInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/CancelAllOrdersWithFreeFunds.go b/programs/phoenix_v1/CancelAllOrdersWithFreeFunds.go new file mode 100644 index 000000000..90ca3d7ea --- /dev/null +++ b/programs/phoenix_v1/CancelAllOrdersWithFreeFunds.go @@ -0,0 +1,155 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelAllOrdersWithFreeFunds is the `CancelAllOrdersWithFreeFunds` instruction. +type CancelAllOrdersWithFreeFunds struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelAllOrdersWithFreeFundsInstructionBuilder creates a new `CancelAllOrdersWithFreeFunds` instruction builder. +func NewCancelAllOrdersWithFreeFundsInstructionBuilder() *CancelAllOrdersWithFreeFunds { + nd := &CancelAllOrdersWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelAllOrdersWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelAllOrdersWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelAllOrdersWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelAllOrdersWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelAllOrdersWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelAllOrdersWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelAllOrdersWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *CancelAllOrdersWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelAllOrdersWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelAllOrdersWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *CancelAllOrdersWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelAllOrdersWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst CancelAllOrdersWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelAllOrdersWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelAllOrdersWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelAllOrdersWithFreeFunds) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + } + return nil +} + +func (inst *CancelAllOrdersWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelAllOrdersWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj CancelAllOrdersWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *CancelAllOrdersWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewCancelAllOrdersWithFreeFundsInstruction declares a new CancelAllOrdersWithFreeFunds instruction with the provided parameters and accounts. +func NewCancelAllOrdersWithFreeFundsInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey) *CancelAllOrdersWithFreeFunds { + return NewCancelAllOrdersWithFreeFundsInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader) +} diff --git a/programs/phoenix_v1/CancelAllOrdersWithFreeFunds_test.go b/programs/phoenix_v1/CancelAllOrdersWithFreeFunds_test.go new file mode 100644 index 000000000..6e379476e --- /dev/null +++ b/programs/phoenix_v1/CancelAllOrdersWithFreeFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelAllOrdersWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelAllOrdersWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelAllOrdersWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelAllOrdersWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CancelAllOrders_test.go b/programs/phoenix_v1/CancelAllOrders_test.go new file mode 100644 index 000000000..72080a38c --- /dev/null +++ b/programs/phoenix_v1/CancelAllOrders_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelAllOrders(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelAllOrders"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelAllOrders) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelAllOrders) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CancelMultipleOrdersById.go b/programs/phoenix_v1/CancelMultipleOrdersById.go new file mode 100644 index 000000000..81e2dd07d --- /dev/null +++ b/programs/phoenix_v1/CancelMultipleOrdersById.go @@ -0,0 +1,279 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelMultipleOrdersById is the `CancelMultipleOrdersById` instruction. +type CancelMultipleOrdersById struct { + Params *CancelMultipleOrdersByIdParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelMultipleOrdersByIdInstructionBuilder creates a new `CancelMultipleOrdersById` instruction builder. +func NewCancelMultipleOrdersByIdInstructionBuilder() *CancelMultipleOrdersById { + nd := &CancelMultipleOrdersById{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *CancelMultipleOrdersById) SetParams(params CancelMultipleOrdersByIdParams) *CancelMultipleOrdersById { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelMultipleOrdersById) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelMultipleOrdersById) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelMultipleOrdersById) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelMultipleOrdersById) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelMultipleOrdersById) SetMarketAccount(market ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelMultipleOrdersById) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelMultipleOrdersById) SetTraderAccount(trader ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelMultipleOrdersById) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *CancelMultipleOrdersById) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *CancelMultipleOrdersById) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *CancelMultipleOrdersById) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *CancelMultipleOrdersById) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *CancelMultipleOrdersById) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *CancelMultipleOrdersById) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *CancelMultipleOrdersById) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *CancelMultipleOrdersById) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *CancelMultipleOrdersById) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CancelMultipleOrdersById { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *CancelMultipleOrdersById) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst CancelMultipleOrdersById) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelMultipleOrdersById, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelMultipleOrdersById) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelMultipleOrdersById) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *CancelMultipleOrdersById) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelMultipleOrdersById")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj CancelMultipleOrdersById) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *CancelMultipleOrdersById) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewCancelMultipleOrdersByIdInstruction declares a new CancelMultipleOrdersById instruction with the provided parameters and accounts. +func NewCancelMultipleOrdersByIdInstruction( + // Parameters: + params CancelMultipleOrdersByIdParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *CancelMultipleOrdersById { + return NewCancelMultipleOrdersByIdInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds.go b/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds.go new file mode 100644 index 000000000..3871f1c4f --- /dev/null +++ b/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelMultipleOrdersByIdWithFreeFunds is the `CancelMultipleOrdersByIdWithFreeFunds` instruction. +type CancelMultipleOrdersByIdWithFreeFunds struct { + Params *CancelMultipleOrdersByIdParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelMultipleOrdersByIdWithFreeFundsInstructionBuilder creates a new `CancelMultipleOrdersByIdWithFreeFunds` instruction builder. +func NewCancelMultipleOrdersByIdWithFreeFundsInstructionBuilder() *CancelMultipleOrdersByIdWithFreeFunds { + nd := &CancelMultipleOrdersByIdWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) SetParams(params CancelMultipleOrdersByIdParams) *CancelMultipleOrdersByIdWithFreeFunds { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelMultipleOrdersByIdWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelMultipleOrdersByIdWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *CancelMultipleOrdersByIdWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *CancelMultipleOrdersByIdWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelMultipleOrdersByIdWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst CancelMultipleOrdersByIdWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelMultipleOrdersByIdWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelMultipleOrdersByIdWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelMultipleOrdersByIdWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + } + return nil +} + +func (inst *CancelMultipleOrdersByIdWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelMultipleOrdersByIdWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj CancelMultipleOrdersByIdWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *CancelMultipleOrdersByIdWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewCancelMultipleOrdersByIdWithFreeFundsInstruction declares a new CancelMultipleOrdersByIdWithFreeFunds instruction with the provided parameters and accounts. +func NewCancelMultipleOrdersByIdWithFreeFundsInstruction( + // Parameters: + params CancelMultipleOrdersByIdParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey) *CancelMultipleOrdersByIdWithFreeFunds { + return NewCancelMultipleOrdersByIdWithFreeFundsInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader) +} diff --git a/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds_test.go b/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds_test.go new file mode 100644 index 000000000..3a2d8c952 --- /dev/null +++ b/programs/phoenix_v1/CancelMultipleOrdersByIdWithFreeFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelMultipleOrdersByIdWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelMultipleOrdersByIdWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelMultipleOrdersByIdWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelMultipleOrdersByIdWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CancelMultipleOrdersById_test.go b/programs/phoenix_v1/CancelMultipleOrdersById_test.go new file mode 100644 index 000000000..2e4a7a088 --- /dev/null +++ b/programs/phoenix_v1/CancelMultipleOrdersById_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelMultipleOrdersById(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelMultipleOrdersById"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelMultipleOrdersById) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelMultipleOrdersById) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CancelUpTo.go b/programs/phoenix_v1/CancelUpTo.go new file mode 100644 index 000000000..2adff5db1 --- /dev/null +++ b/programs/phoenix_v1/CancelUpTo.go @@ -0,0 +1,279 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelUpTo is the `CancelUpTo` instruction. +type CancelUpTo struct { + Params *CancelUpToParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelUpToInstructionBuilder creates a new `CancelUpTo` instruction builder. +func NewCancelUpToInstructionBuilder() *CancelUpTo { + nd := &CancelUpTo{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *CancelUpTo) SetParams(params CancelUpToParams) *CancelUpTo { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelUpTo) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelUpTo) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelUpTo) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelUpTo) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelUpTo) SetMarketAccount(market ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelUpTo) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelUpTo) SetTraderAccount(trader ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelUpTo) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *CancelUpTo) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *CancelUpTo) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *CancelUpTo) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *CancelUpTo) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *CancelUpTo) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *CancelUpTo) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *CancelUpTo) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *CancelUpTo) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *CancelUpTo) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CancelUpTo { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *CancelUpTo) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst CancelUpTo) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelUpTo, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelUpTo) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelUpTo) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *CancelUpTo) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelUpTo")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj CancelUpTo) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *CancelUpTo) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewCancelUpToInstruction declares a new CancelUpTo instruction with the provided parameters and accounts. +func NewCancelUpToInstruction( + // Parameters: + params CancelUpToParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *CancelUpTo { + return NewCancelUpToInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/CancelUpToWithFreeFunds.go b/programs/phoenix_v1/CancelUpToWithFreeFunds.go new file mode 100644 index 000000000..402152b30 --- /dev/null +++ b/programs/phoenix_v1/CancelUpToWithFreeFunds.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CancelUpToWithFreeFunds is the `CancelUpToWithFreeFunds` instruction. +type CancelUpToWithFreeFunds struct { + Params *CancelUpToParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCancelUpToWithFreeFundsInstructionBuilder creates a new `CancelUpToWithFreeFunds` instruction builder. +func NewCancelUpToWithFreeFundsInstructionBuilder() *CancelUpToWithFreeFunds { + nd := &CancelUpToWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *CancelUpToWithFreeFunds) SetParams(params CancelUpToParams) *CancelUpToWithFreeFunds { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CancelUpToWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CancelUpToWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CancelUpToWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CancelUpToWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CancelUpToWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CancelUpToWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CancelUpToWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *CancelUpToWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CancelUpToWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *CancelUpToWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *CancelUpToWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *CancelUpToWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst CancelUpToWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CancelUpToWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CancelUpToWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CancelUpToWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + } + return nil +} + +func (inst *CancelUpToWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CancelUpToWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj CancelUpToWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *CancelUpToWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewCancelUpToWithFreeFundsInstruction declares a new CancelUpToWithFreeFunds instruction with the provided parameters and accounts. +func NewCancelUpToWithFreeFundsInstruction( + // Parameters: + params CancelUpToParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey) *CancelUpToWithFreeFunds { + return NewCancelUpToWithFreeFundsInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader) +} diff --git a/programs/phoenix_v1/CancelUpToWithFreeFunds_test.go b/programs/phoenix_v1/CancelUpToWithFreeFunds_test.go new file mode 100644 index 000000000..cf8c1abb1 --- /dev/null +++ b/programs/phoenix_v1/CancelUpToWithFreeFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelUpToWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelUpToWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelUpToWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelUpToWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CancelUpTo_test.go b/programs/phoenix_v1/CancelUpTo_test.go new file mode 100644 index 000000000..b4860c684 --- /dev/null +++ b/programs/phoenix_v1/CancelUpTo_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CancelUpTo(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CancelUpTo"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CancelUpTo) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CancelUpTo) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ChangeFeeRecipient.go b/programs/phoenix_v1/ChangeFeeRecipient.go new file mode 100644 index 000000000..99fd95a34 --- /dev/null +++ b/programs/phoenix_v1/ChangeFeeRecipient.go @@ -0,0 +1,174 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ChangeFeeRecipient is the `ChangeFeeRecipient` instruction. +type ChangeFeeRecipient struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + // + // [4] = [] newFeeRecipient + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewChangeFeeRecipientInstructionBuilder creates a new `ChangeFeeRecipient` instruction builder. +func NewChangeFeeRecipientInstructionBuilder() *ChangeFeeRecipient { + nd := &ChangeFeeRecipient{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ChangeFeeRecipient) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ChangeFeeRecipient { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ChangeFeeRecipient) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ChangeFeeRecipient) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ChangeFeeRecipient { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ChangeFeeRecipient) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ChangeFeeRecipient) SetMarketAccount(market ag_solanago.PublicKey) *ChangeFeeRecipient { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ChangeFeeRecipient) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *ChangeFeeRecipient) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *ChangeFeeRecipient { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *ChangeFeeRecipient) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetNewFeeRecipientAccount sets the "newFeeRecipient" account. +func (inst *ChangeFeeRecipient) SetNewFeeRecipientAccount(newFeeRecipient ag_solanago.PublicKey) *ChangeFeeRecipient { + inst.AccountMetaSlice[4] = ag_solanago.Meta(newFeeRecipient) + return inst +} + +// GetNewFeeRecipientAccount gets the "newFeeRecipient" account. +func (inst *ChangeFeeRecipient) GetNewFeeRecipientAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst ChangeFeeRecipient) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ChangeFeeRecipient, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ChangeFeeRecipient) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ChangeFeeRecipient) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.NewFeeRecipient is not set") + } + } + return nil +} + +func (inst *ChangeFeeRecipient) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ChangeFeeRecipient")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("newFeeRecipient", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj ChangeFeeRecipient) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *ChangeFeeRecipient) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewChangeFeeRecipientInstruction declares a new ChangeFeeRecipient instruction with the provided parameters and accounts. +func NewChangeFeeRecipientInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey, + newFeeRecipient ag_solanago.PublicKey) *ChangeFeeRecipient { + return NewChangeFeeRecipientInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority). + SetNewFeeRecipientAccount(newFeeRecipient) +} diff --git a/programs/phoenix_v1/ChangeFeeRecipient_test.go b/programs/phoenix_v1/ChangeFeeRecipient_test.go new file mode 100644 index 000000000..0a23fcecd --- /dev/null +++ b/programs/phoenix_v1/ChangeFeeRecipient_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ChangeFeeRecipient(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ChangeFeeRecipient"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ChangeFeeRecipient) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ChangeFeeRecipient) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ChangeMarketStatus.go b/programs/phoenix_v1/ChangeMarketStatus.go new file mode 100644 index 000000000..b41912d88 --- /dev/null +++ b/programs/phoenix_v1/ChangeMarketStatus.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ChangeMarketStatus is the `ChangeMarketStatus` instruction. +type ChangeMarketStatus struct { + MarketStatus *MarketStatus + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewChangeMarketStatusInstructionBuilder creates a new `ChangeMarketStatus` instruction builder. +func NewChangeMarketStatusInstructionBuilder() *ChangeMarketStatus { + nd := &ChangeMarketStatus{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetMarketStatus sets the "marketStatus" parameter. +func (inst *ChangeMarketStatus) SetMarketStatus(marketStatus MarketStatus) *ChangeMarketStatus { + inst.MarketStatus = &marketStatus + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ChangeMarketStatus) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ChangeMarketStatus { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ChangeMarketStatus) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ChangeMarketStatus) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ChangeMarketStatus { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ChangeMarketStatus) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ChangeMarketStatus) SetMarketAccount(market ag_solanago.PublicKey) *ChangeMarketStatus { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ChangeMarketStatus) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *ChangeMarketStatus) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *ChangeMarketStatus { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *ChangeMarketStatus) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst ChangeMarketStatus) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ChangeMarketStatus, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ChangeMarketStatus) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ChangeMarketStatus) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.MarketStatus == nil { + return errors.New("MarketStatus parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + } + return nil +} + +func (inst *ChangeMarketStatus) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ChangeMarketStatus")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("MarketStatus", *inst.MarketStatus)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj ChangeMarketStatus) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MarketStatus` param: + err = encoder.Encode(obj.MarketStatus) + if err != nil { + return err + } + return nil +} +func (obj *ChangeMarketStatus) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MarketStatus`: + err = decoder.Decode(&obj.MarketStatus) + if err != nil { + return err + } + return nil +} + +// NewChangeMarketStatusInstruction declares a new ChangeMarketStatus instruction with the provided parameters and accounts. +func NewChangeMarketStatusInstruction( + // Parameters: + marketStatus MarketStatus, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey) *ChangeMarketStatus { + return NewChangeMarketStatusInstructionBuilder(). + SetMarketStatus(marketStatus). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority) +} diff --git a/programs/phoenix_v1/ChangeMarketStatus_test.go b/programs/phoenix_v1/ChangeMarketStatus_test.go new file mode 100644 index 000000000..d2fcc14b1 --- /dev/null +++ b/programs/phoenix_v1/ChangeMarketStatus_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ChangeMarketStatus(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ChangeMarketStatus"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ChangeMarketStatus) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ChangeMarketStatus) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ChangeSeatStatus.go b/programs/phoenix_v1/ChangeSeatStatus.go new file mode 100644 index 000000000..22dfcdef2 --- /dev/null +++ b/programs/phoenix_v1/ChangeSeatStatus.go @@ -0,0 +1,203 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ChangeSeatStatus is the `ChangeSeatStatus` instruction. +type ChangeSeatStatus struct { + ApprovalStatus *SeatApprovalStatus + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + // + // [4] = [WRITE] seat + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewChangeSeatStatusInstructionBuilder creates a new `ChangeSeatStatus` instruction builder. +func NewChangeSeatStatusInstructionBuilder() *ChangeSeatStatus { + nd := &ChangeSeatStatus{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetApprovalStatus sets the "approvalStatus" parameter. +func (inst *ChangeSeatStatus) SetApprovalStatus(approvalStatus SeatApprovalStatus) *ChangeSeatStatus { + inst.ApprovalStatus = &approvalStatus + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ChangeSeatStatus) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ChangeSeatStatus { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ChangeSeatStatus) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ChangeSeatStatus) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ChangeSeatStatus { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ChangeSeatStatus) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ChangeSeatStatus) SetMarketAccount(market ag_solanago.PublicKey) *ChangeSeatStatus { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ChangeSeatStatus) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *ChangeSeatStatus) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *ChangeSeatStatus { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *ChangeSeatStatus) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *ChangeSeatStatus) SetSeatAccount(seat ag_solanago.PublicKey) *ChangeSeatStatus { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat).WRITE() + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *ChangeSeatStatus) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst ChangeSeatStatus) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ChangeSeatStatus, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ChangeSeatStatus) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ChangeSeatStatus) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ApprovalStatus == nil { + return errors.New("ApprovalStatus parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + } + return nil +} + +func (inst *ChangeSeatStatus) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ChangeSeatStatus")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ApprovalStatus", *inst.ApprovalStatus)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj ChangeSeatStatus) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ApprovalStatus` param: + err = encoder.Encode(obj.ApprovalStatus) + if err != nil { + return err + } + return nil +} +func (obj *ChangeSeatStatus) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ApprovalStatus`: + err = decoder.Decode(&obj.ApprovalStatus) + if err != nil { + return err + } + return nil +} + +// NewChangeSeatStatusInstruction declares a new ChangeSeatStatus instruction with the provided parameters and accounts. +func NewChangeSeatStatusInstruction( + // Parameters: + approvalStatus SeatApprovalStatus, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey, + seat ag_solanago.PublicKey) *ChangeSeatStatus { + return NewChangeSeatStatusInstructionBuilder(). + SetApprovalStatus(approvalStatus). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority). + SetSeatAccount(seat) +} diff --git a/programs/phoenix_v1/ChangeSeatStatus_test.go b/programs/phoenix_v1/ChangeSeatStatus_test.go new file mode 100644 index 000000000..ce29a60a3 --- /dev/null +++ b/programs/phoenix_v1/ChangeSeatStatus_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ChangeSeatStatus(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ChangeSeatStatus"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ChangeSeatStatus) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ChangeSeatStatus) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ClaimAuthority.go b/programs/phoenix_v1/ClaimAuthority.go new file mode 100644 index 000000000..229b52c7a --- /dev/null +++ b/programs/phoenix_v1/ClaimAuthority.go @@ -0,0 +1,155 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ClaimAuthority is the `ClaimAuthority` instruction. +type ClaimAuthority struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] successor + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewClaimAuthorityInstructionBuilder creates a new `ClaimAuthority` instruction builder. +func NewClaimAuthorityInstructionBuilder() *ClaimAuthority { + nd := &ClaimAuthority{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ClaimAuthority) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ClaimAuthority { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ClaimAuthority) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ClaimAuthority) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ClaimAuthority { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ClaimAuthority) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ClaimAuthority) SetMarketAccount(market ag_solanago.PublicKey) *ClaimAuthority { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ClaimAuthority) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetSuccessorAccount sets the "successor" account. +func (inst *ClaimAuthority) SetSuccessorAccount(successor ag_solanago.PublicKey) *ClaimAuthority { + inst.AccountMetaSlice[3] = ag_solanago.Meta(successor).SIGNER() + return inst +} + +// GetSuccessorAccount gets the "successor" account. +func (inst *ClaimAuthority) GetSuccessorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst ClaimAuthority) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ClaimAuthority, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ClaimAuthority) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ClaimAuthority) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Successor is not set") + } + } + return nil +} + +func (inst *ClaimAuthority) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ClaimAuthority")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" successor", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj ClaimAuthority) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *ClaimAuthority) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewClaimAuthorityInstruction declares a new ClaimAuthority instruction with the provided parameters and accounts. +func NewClaimAuthorityInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + successor ag_solanago.PublicKey) *ClaimAuthority { + return NewClaimAuthorityInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetSuccessorAccount(successor) +} diff --git a/programs/phoenix_v1/ClaimAuthority_test.go b/programs/phoenix_v1/ClaimAuthority_test.go new file mode 100644 index 000000000..d75738764 --- /dev/null +++ b/programs/phoenix_v1/ClaimAuthority_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ClaimAuthority(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ClaimAuthority"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ClaimAuthority) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ClaimAuthority) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/CollectFees.go b/programs/phoenix_v1/CollectFees.go new file mode 100644 index 000000000..8c1a8be53 --- /dev/null +++ b/programs/phoenix_v1/CollectFees.go @@ -0,0 +1,212 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// CollectFees is the `CollectFees` instruction. +type CollectFees struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] sweeper + // + // [4] = [WRITE] feeRecipient + // + // [5] = [WRITE] quoteVault + // + // [6] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCollectFeesInstructionBuilder creates a new `CollectFees` instruction builder. +func NewCollectFeesInstructionBuilder() *CollectFees { + nd := &CollectFees{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 7), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *CollectFees) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *CollectFees) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *CollectFees) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *CollectFees) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *CollectFees) SetMarketAccount(market ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *CollectFees) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetSweeperAccount sets the "sweeper" account. +func (inst *CollectFees) SetSweeperAccount(sweeper ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[3] = ag_solanago.Meta(sweeper).SIGNER() + return inst +} + +// GetSweeperAccount gets the "sweeper" account. +func (inst *CollectFees) GetSweeperAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetFeeRecipientAccount sets the "feeRecipient" account. +func (inst *CollectFees) SetFeeRecipientAccount(feeRecipient ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[4] = ag_solanago.Meta(feeRecipient).WRITE() + return inst +} + +// GetFeeRecipientAccount gets the "feeRecipient" account. +func (inst *CollectFees) GetFeeRecipientAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *CollectFees) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *CollectFees) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *CollectFees) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CollectFees { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *CollectFees) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +func (inst CollectFees) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CollectFees, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CollectFees) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CollectFees) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Sweeper is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.FeeRecipient is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *CollectFees) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CollectFees")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=7]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" sweeper", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" feeRecipient", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(6))) + }) + }) + }) +} + +func (obj CollectFees) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *CollectFees) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewCollectFeesInstruction declares a new CollectFees instruction with the provided parameters and accounts. +func NewCollectFeesInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + sweeper ag_solanago.PublicKey, + feeRecipient ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *CollectFees { + return NewCollectFeesInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetSweeperAccount(sweeper). + SetFeeRecipientAccount(feeRecipient). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/CollectFees_test.go b/programs/phoenix_v1/CollectFees_test.go new file mode 100644 index 000000000..2522d586a --- /dev/null +++ b/programs/phoenix_v1/CollectFees_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CollectFees(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CollectFees"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CollectFees) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CollectFees) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/DepositFunds.go b/programs/phoenix_v1/DepositFunds.go new file mode 100644 index 000000000..1b62da8cb --- /dev/null +++ b/programs/phoenix_v1/DepositFunds.go @@ -0,0 +1,298 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// DepositFunds is the `DepositFunds` instruction. +type DepositFunds struct { + DepositFundsParams *DepositParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + // + // [5] = [WRITE] baseAccount + // + // [6] = [WRITE] quoteAccount + // + // [7] = [WRITE] baseVault + // + // [8] = [WRITE] quoteVault + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositFundsInstructionBuilder creates a new `DepositFunds` instruction builder. +func NewDepositFundsInstructionBuilder() *DepositFunds { + nd := &DepositFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetDepositFundsParams sets the "depositFundsParams" parameter. +func (inst *DepositFunds) SetDepositFundsParams(depositFundsParams DepositParams) *DepositFunds { + inst.DepositFundsParams = &depositFundsParams + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *DepositFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *DepositFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *DepositFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *DepositFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *DepositFunds) SetMarketAccount(market ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *DepositFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *DepositFunds) SetTraderAccount(trader ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *DepositFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *DepositFunds) SetSeatAccount(seat ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *DepositFunds) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *DepositFunds) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[5] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *DepositFunds) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *DepositFunds) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[6] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *DepositFunds) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *DepositFunds) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[7] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *DepositFunds) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *DepositFunds) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[8] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *DepositFunds) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *DepositFunds) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *DepositFunds { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *DepositFunds) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst DepositFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_DepositFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst DepositFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *DepositFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.DepositFundsParams == nil { + return errors.New("DepositFundsParams parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *DepositFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("DepositFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("DepositFundsParams", *inst.DepositFundsParams)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj DepositFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `DepositFundsParams` param: + err = encoder.Encode(obj.DepositFundsParams) + if err != nil { + return err + } + return nil +} +func (obj *DepositFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `DepositFundsParams`: + err = decoder.Decode(&obj.DepositFundsParams) + if err != nil { + return err + } + return nil +} + +// NewDepositFundsInstruction declares a new DepositFunds instruction with the provided parameters and accounts. +func NewDepositFundsInstruction( + // Parameters: + depositFundsParams DepositParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *DepositFunds { + return NewDepositFundsInstructionBuilder(). + SetDepositFundsParams(depositFundsParams). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/DepositFunds_test.go b/programs/phoenix_v1/DepositFunds_test.go new file mode 100644 index 000000000..bbb0fd20c --- /dev/null +++ b/programs/phoenix_v1/DepositFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_DepositFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("DepositFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(DepositFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(DepositFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/EvictSeat.go b/programs/phoenix_v1/EvictSeat.go new file mode 100644 index 000000000..6fc37bf18 --- /dev/null +++ b/programs/phoenix_v1/EvictSeat.go @@ -0,0 +1,288 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// EvictSeat is the `EvictSeat` instruction. +type EvictSeat struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + // + // [4] = [] trader + // + // [5] = [] seat + // + // [6] = [WRITE] baseAccount + // + // [7] = [WRITE] quoteAccount + // + // [8] = [WRITE] baseVault + // + // [9] = [WRITE] quoteVault + // + // [10] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewEvictSeatInstructionBuilder creates a new `EvictSeat` instruction builder. +func NewEvictSeatInstructionBuilder() *EvictSeat { + nd := &EvictSeat{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 11), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *EvictSeat) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *EvictSeat) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *EvictSeat) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *EvictSeat) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *EvictSeat) SetMarketAccount(market ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *EvictSeat) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *EvictSeat) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *EvictSeat) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetTraderAccount sets the "trader" account. +func (inst *EvictSeat) SetTraderAccount(trader ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[4] = ag_solanago.Meta(trader) + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *EvictSeat) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetSeatAccount sets the "seat" account. +func (inst *EvictSeat) SetSeatAccount(seat ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[5] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *EvictSeat) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *EvictSeat) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *EvictSeat) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *EvictSeat) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *EvictSeat) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *EvictSeat) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[8] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *EvictSeat) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *EvictSeat) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[9] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *EvictSeat) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *EvictSeat) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *EvictSeat { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *EvictSeat) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +func (inst EvictSeat) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_EvictSeat, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst EvictSeat) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *EvictSeat) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *EvictSeat) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("EvictSeat")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=11]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(10))) + }) + }) + }) +} + +func (obj EvictSeat) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *EvictSeat) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewEvictSeatInstruction declares a new EvictSeat instruction with the provided parameters and accounts. +func NewEvictSeatInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *EvictSeat { + return NewEvictSeatInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/EvictSeat_test.go b/programs/phoenix_v1/EvictSeat_test.go new file mode 100644 index 000000000..9396a0e75 --- /dev/null +++ b/programs/phoenix_v1/EvictSeat_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_EvictSeat(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("EvictSeat"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(EvictSeat) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(EvictSeat) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ForceCancelOrders.go b/programs/phoenix_v1/ForceCancelOrders.go new file mode 100644 index 000000000..d7e006020 --- /dev/null +++ b/programs/phoenix_v1/ForceCancelOrders.go @@ -0,0 +1,317 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ForceCancelOrders is the `ForceCancelOrders` instruction. +type ForceCancelOrders struct { + Params *CancelUpToParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + // + // [4] = [] trader + // + // [5] = [] seat + // + // [6] = [WRITE] baseAccount + // + // [7] = [WRITE] quoteAccount + // + // [8] = [WRITE] baseVault + // + // [9] = [WRITE] quoteVault + // + // [10] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewForceCancelOrdersInstructionBuilder creates a new `ForceCancelOrders` instruction builder. +func NewForceCancelOrdersInstructionBuilder() *ForceCancelOrders { + nd := &ForceCancelOrders{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 11), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *ForceCancelOrders) SetParams(params CancelUpToParams) *ForceCancelOrders { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ForceCancelOrders) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ForceCancelOrders) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ForceCancelOrders) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ForceCancelOrders) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ForceCancelOrders) SetMarketAccount(market ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ForceCancelOrders) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *ForceCancelOrders) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *ForceCancelOrders) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetTraderAccount sets the "trader" account. +func (inst *ForceCancelOrders) SetTraderAccount(trader ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[4] = ag_solanago.Meta(trader) + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *ForceCancelOrders) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetSeatAccount sets the "seat" account. +func (inst *ForceCancelOrders) SetSeatAccount(seat ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[5] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *ForceCancelOrders) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *ForceCancelOrders) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *ForceCancelOrders) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *ForceCancelOrders) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *ForceCancelOrders) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *ForceCancelOrders) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[8] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *ForceCancelOrders) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *ForceCancelOrders) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[9] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *ForceCancelOrders) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *ForceCancelOrders) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *ForceCancelOrders { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *ForceCancelOrders) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +func (inst ForceCancelOrders) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ForceCancelOrders, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ForceCancelOrders) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ForceCancelOrders) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *ForceCancelOrders) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ForceCancelOrders")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=11]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(10))) + }) + }) + }) +} + +func (obj ForceCancelOrders) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *ForceCancelOrders) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewForceCancelOrdersInstruction declares a new ForceCancelOrders instruction with the provided parameters and accounts. +func NewForceCancelOrdersInstruction( + // Parameters: + params CancelUpToParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *ForceCancelOrders { + return NewForceCancelOrdersInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/ForceCancelOrders_test.go b/programs/phoenix_v1/ForceCancelOrders_test.go new file mode 100644 index 000000000..ff37e1fbb --- /dev/null +++ b/programs/phoenix_v1/ForceCancelOrders_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ForceCancelOrders(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ForceCancelOrders"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ForceCancelOrders) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ForceCancelOrders) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/InitializeMarket.go b/programs/phoenix_v1/InitializeMarket.go new file mode 100644 index 000000000..1253a4670 --- /dev/null +++ b/programs/phoenix_v1/InitializeMarket.go @@ -0,0 +1,298 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// InitializeMarket is the `InitializeMarket` instruction. +type InitializeMarket struct { + InitializeParams *InitializeParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [WRITE, SIGNER] marketCreator + // + // [4] = [] baseMint + // + // [5] = [] quoteMint + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] systemProgram + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeMarketInstructionBuilder creates a new `InitializeMarket` instruction builder. +func NewInitializeMarketInstructionBuilder() *InitializeMarket { + nd := &InitializeMarket{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetInitializeParams sets the "initializeParams" parameter. +func (inst *InitializeMarket) SetInitializeParams(initializeParams InitializeParams) *InitializeMarket { + inst.InitializeParams = &initializeParams + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *InitializeMarket) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *InitializeMarket) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *InitializeMarket) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *InitializeMarket) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *InitializeMarket) SetMarketAccount(market ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *InitializeMarket) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketCreatorAccount sets the "marketCreator" account. +func (inst *InitializeMarket) SetMarketCreatorAccount(marketCreator ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketCreator).WRITE().SIGNER() + return inst +} + +// GetMarketCreatorAccount gets the "marketCreator" account. +func (inst *InitializeMarket) GetMarketCreatorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseMintAccount sets the "baseMint" account. +func (inst *InitializeMarket) SetBaseMintAccount(baseMint ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseMint) + return inst +} + +// GetBaseMintAccount gets the "baseMint" account. +func (inst *InitializeMarket) GetBaseMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteMintAccount sets the "quoteMint" account. +func (inst *InitializeMarket) SetQuoteMintAccount(quoteMint ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteMint) + return inst +} + +// GetQuoteMintAccount gets the "quoteMint" account. +func (inst *InitializeMarket) GetQuoteMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *InitializeMarket) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *InitializeMarket) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *InitializeMarket) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *InitializeMarket) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *InitializeMarket) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[8] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *InitializeMarket) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *InitializeMarket) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *InitializeMarket { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *InitializeMarket) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst InitializeMarket) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_InitializeMarket, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst InitializeMarket) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *InitializeMarket) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.InitializeParams == nil { + return errors.New("InitializeParams parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketCreator is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseMint is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteMint is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *InitializeMarket) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("InitializeMarket")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("InitializeParams", *inst.InitializeParams)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" marketCreator", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" baseMint", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quoteMint", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj InitializeMarket) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `InitializeParams` param: + err = encoder.Encode(obj.InitializeParams) + if err != nil { + return err + } + return nil +} +func (obj *InitializeMarket) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `InitializeParams`: + err = decoder.Decode(&obj.InitializeParams) + if err != nil { + return err + } + return nil +} + +// NewInitializeMarketInstruction declares a new InitializeMarket instruction with the provided parameters and accounts. +func NewInitializeMarketInstruction( + // Parameters: + initializeParams InitializeParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketCreator ag_solanago.PublicKey, + baseMint ag_solanago.PublicKey, + quoteMint ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *InitializeMarket { + return NewInitializeMarketInstructionBuilder(). + SetInitializeParams(initializeParams). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketCreatorAccount(marketCreator). + SetBaseMintAccount(baseMint). + SetQuoteMintAccount(quoteMint). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetSystemProgramAccount(systemProgram). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/InitializeMarket_test.go b/programs/phoenix_v1/InitializeMarket_test.go new file mode 100644 index 000000000..70e1ee672 --- /dev/null +++ b/programs/phoenix_v1/InitializeMarket_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_InitializeMarket(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("InitializeMarket"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(InitializeMarket) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(InitializeMarket) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/Log.go b/programs/phoenix_v1/Log.go new file mode 100644 index 000000000..4d3c3abc6 --- /dev/null +++ b/programs/phoenix_v1/Log.go @@ -0,0 +1,98 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Log is the `Log` instruction. +type Log struct { + + // [0] = [SIGNER] logAuthority + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewLogInstructionBuilder creates a new `Log` instruction builder. +func NewLogInstructionBuilder() *Log { + nd := &Log{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), + } + return nd +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *Log) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *Log { + inst.AccountMetaSlice[0] = ag_solanago.Meta(logAuthority).SIGNER() + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *Log) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +func (inst Log) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Log, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Log) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Log) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.LogAuthority is not set") + } + } + return nil +} + +func (inst *Log) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Log")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("logAuthority", inst.AccountMetaSlice.Get(0))) + }) + }) + }) +} + +func (obj Log) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Log) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewLogInstruction declares a new Log instruction with the provided parameters and accounts. +func NewLogInstruction( + // Accounts: + logAuthority ag_solanago.PublicKey) *Log { + return NewLogInstructionBuilder(). + SetLogAuthorityAccount(logAuthority) +} diff --git a/programs/phoenix_v1/Log_test.go b/programs/phoenix_v1/Log_test.go new file mode 100644 index 000000000..01da962cc --- /dev/null +++ b/programs/phoenix_v1/Log_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Log(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Log"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Log) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Log) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/NameSuccessor.go b/programs/phoenix_v1/NameSuccessor.go new file mode 100644 index 000000000..860c80934 --- /dev/null +++ b/programs/phoenix_v1/NameSuccessor.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// NameSuccessor is the `NameSuccessor` instruction. +type NameSuccessor struct { + Successor *ag_solanago.PublicKey + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewNameSuccessorInstructionBuilder creates a new `NameSuccessor` instruction builder. +func NewNameSuccessorInstructionBuilder() *NameSuccessor { + nd := &NameSuccessor{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetSuccessor sets the "successor" parameter. +func (inst *NameSuccessor) SetSuccessor(successor ag_solanago.PublicKey) *NameSuccessor { + inst.Successor = &successor + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *NameSuccessor) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *NameSuccessor { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *NameSuccessor) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *NameSuccessor) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *NameSuccessor { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *NameSuccessor) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *NameSuccessor) SetMarketAccount(market ag_solanago.PublicKey) *NameSuccessor { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *NameSuccessor) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *NameSuccessor) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *NameSuccessor { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *NameSuccessor) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst NameSuccessor) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_NameSuccessor, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst NameSuccessor) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *NameSuccessor) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Successor == nil { + return errors.New("Successor parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + } + return nil +} + +func (inst *NameSuccessor) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("NameSuccessor")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Successor", *inst.Successor)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj NameSuccessor) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Successor` param: + err = encoder.Encode(obj.Successor) + if err != nil { + return err + } + return nil +} +func (obj *NameSuccessor) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Successor`: + err = decoder.Decode(&obj.Successor) + if err != nil { + return err + } + return nil +} + +// NewNameSuccessorInstruction declares a new NameSuccessor instruction with the provided parameters and accounts. +func NewNameSuccessorInstruction( + // Parameters: + successor ag_solanago.PublicKey, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey) *NameSuccessor { + return NewNameSuccessorInstructionBuilder(). + SetSuccessor(successor). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority) +} diff --git a/programs/phoenix_v1/NameSuccessor_test.go b/programs/phoenix_v1/NameSuccessor_test.go new file mode 100644 index 000000000..3ceabbcec --- /dev/null +++ b/programs/phoenix_v1/NameSuccessor_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_NameSuccessor(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("NameSuccessor"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(NameSuccessor) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(NameSuccessor) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/PlaceLimitOrder.go b/programs/phoenix_v1/PlaceLimitOrder.go new file mode 100644 index 000000000..8064f2baf --- /dev/null +++ b/programs/phoenix_v1/PlaceLimitOrder.go @@ -0,0 +1,326 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// PlaceLimitOrder is the `PlaceLimitOrder` instruction. +type PlaceLimitOrder struct { + OrderPacket OrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + // + // [5] = [WRITE] baseAccount + // + // [6] = [WRITE] quoteAccount + // + // [7] = [WRITE] baseVault + // + // [8] = [WRITE] quoteVault + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewPlaceLimitOrderInstructionBuilder creates a new `PlaceLimitOrder` instruction builder. +func NewPlaceLimitOrderInstructionBuilder() *PlaceLimitOrder { + nd := &PlaceLimitOrder{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetOrderPacket sets the "orderPacket" parameter. +func (inst *PlaceLimitOrder) SetOrderPacket(orderPacket OrderPacket) *PlaceLimitOrder { + inst.OrderPacket = orderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *PlaceLimitOrder) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *PlaceLimitOrder) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *PlaceLimitOrder) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *PlaceLimitOrder) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *PlaceLimitOrder) SetMarketAccount(market ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *PlaceLimitOrder) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *PlaceLimitOrder) SetTraderAccount(trader ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *PlaceLimitOrder) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *PlaceLimitOrder) SetSeatAccount(seat ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *PlaceLimitOrder) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *PlaceLimitOrder) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[5] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *PlaceLimitOrder) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *PlaceLimitOrder) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[6] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *PlaceLimitOrder) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *PlaceLimitOrder) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[7] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *PlaceLimitOrder) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *PlaceLimitOrder) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[8] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *PlaceLimitOrder) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *PlaceLimitOrder) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *PlaceLimitOrder { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *PlaceLimitOrder) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst PlaceLimitOrder) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_PlaceLimitOrder, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst PlaceLimitOrder) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *PlaceLimitOrder) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.OrderPacket == nil { + return errors.New("OrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *PlaceLimitOrder) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("PlaceLimitOrder")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("OrderPacket", inst.OrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj PlaceLimitOrder) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `OrderPacket` param: + { + tmp := orderPacketContainer{} + switch realvalue := obj.OrderPacket.(type) { + case *OrderPacketPostOnly: + tmp.Enum = 0 + tmp.PostOnly = *realvalue + case *OrderPacketLimit: + tmp.Enum = 1 + tmp.Limit = *realvalue + case *OrderPacketImmediateOrCancel: + tmp.Enum = 2 + tmp.ImmediateOrCancel = *realvalue + } + err := encoder.Encode(tmp) + if err != nil { + return err + } + } + return nil +} +func (obj *PlaceLimitOrder) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `OrderPacket`: + { + tmp := new(orderPacketContainer) + err := decoder.Decode(tmp) + if err != nil { + return err + } + switch tmp.Enum { + case 0: + obj.OrderPacket = &tmp.PostOnly + case 1: + obj.OrderPacket = &tmp.Limit + case 2: + obj.OrderPacket = &tmp.ImmediateOrCancel + default: + return fmt.Errorf("unknown enum index: %v", tmp.Enum) + } + } + return nil +} + +// NewPlaceLimitOrderInstruction declares a new PlaceLimitOrder instruction with the provided parameters and accounts. +func NewPlaceLimitOrderInstruction( + // Parameters: + orderPacket OrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *PlaceLimitOrder { + return NewPlaceLimitOrderInstructionBuilder(). + SetOrderPacket(orderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds.go b/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds.go new file mode 100644 index 000000000..00408e283 --- /dev/null +++ b/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds.go @@ -0,0 +1,231 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// PlaceLimitOrderWithFreeFunds is the `PlaceLimitOrderWithFreeFunds` instruction. +type PlaceLimitOrderWithFreeFunds struct { + OrderPacket OrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewPlaceLimitOrderWithFreeFundsInstructionBuilder creates a new `PlaceLimitOrderWithFreeFunds` instruction builder. +func NewPlaceLimitOrderWithFreeFundsInstructionBuilder() *PlaceLimitOrderWithFreeFunds { + nd := &PlaceLimitOrderWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetOrderPacket sets the "orderPacket" parameter. +func (inst *PlaceLimitOrderWithFreeFunds) SetOrderPacket(orderPacket OrderPacket) *PlaceLimitOrderWithFreeFunds { + inst.OrderPacket = orderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *PlaceLimitOrderWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *PlaceLimitOrderWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *PlaceLimitOrderWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *PlaceLimitOrderWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *PlaceLimitOrderWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *PlaceLimitOrderWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *PlaceLimitOrderWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *PlaceLimitOrderWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *PlaceLimitOrderWithFreeFunds) SetSeatAccount(seat ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *PlaceLimitOrderWithFreeFunds) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst PlaceLimitOrderWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_PlaceLimitOrderWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst PlaceLimitOrderWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *PlaceLimitOrderWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.OrderPacket == nil { + return errors.New("OrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + } + return nil +} + +func (inst *PlaceLimitOrderWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("PlaceLimitOrderWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("OrderPacket", inst.OrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj PlaceLimitOrderWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `OrderPacket` param: + { + tmp := orderPacketContainer{} + switch realvalue := obj.OrderPacket.(type) { + case *OrderPacketPostOnly: + tmp.Enum = 0 + tmp.PostOnly = *realvalue + case *OrderPacketLimit: + tmp.Enum = 1 + tmp.Limit = *realvalue + case *OrderPacketImmediateOrCancel: + tmp.Enum = 2 + tmp.ImmediateOrCancel = *realvalue + } + err := encoder.Encode(tmp) + if err != nil { + return err + } + } + return nil +} +func (obj *PlaceLimitOrderWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `OrderPacket`: + { + tmp := new(orderPacketContainer) + err := decoder.Decode(tmp) + if err != nil { + return err + } + switch tmp.Enum { + case 0: + obj.OrderPacket = &tmp.PostOnly + case 1: + obj.OrderPacket = &tmp.Limit + case 2: + obj.OrderPacket = &tmp.ImmediateOrCancel + default: + return fmt.Errorf("unknown enum index: %v", tmp.Enum) + } + } + return nil +} + +// NewPlaceLimitOrderWithFreeFundsInstruction declares a new PlaceLimitOrderWithFreeFunds instruction with the provided parameters and accounts. +func NewPlaceLimitOrderWithFreeFundsInstruction( + // Parameters: + orderPacket OrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey) *PlaceLimitOrderWithFreeFunds { + return NewPlaceLimitOrderWithFreeFundsInstructionBuilder(). + SetOrderPacket(orderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat) +} diff --git a/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds_test.go b/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds_test.go new file mode 100644 index 000000000..53c7c7417 --- /dev/null +++ b/programs/phoenix_v1/PlaceLimitOrderWithFreeFunds_test.go @@ -0,0 +1,71 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_PlaceLimitOrderWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("PlaceLimitOrderWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + { + { + params := new(PlaceLimitOrderWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(PostOnly) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrderWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(PlaceLimitOrderWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(Limit) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrderWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(PlaceLimitOrderWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(ImmediateOrCancel) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrderWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + } + } + }) + } +} diff --git a/programs/phoenix_v1/PlaceLimitOrder_test.go b/programs/phoenix_v1/PlaceLimitOrder_test.go new file mode 100644 index 000000000..ea587d7d7 --- /dev/null +++ b/programs/phoenix_v1/PlaceLimitOrder_test.go @@ -0,0 +1,71 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_PlaceLimitOrder(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("PlaceLimitOrder"+strconv.Itoa(i), func(t *testing.T) { + { + { + { + params := new(PlaceLimitOrder) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(PostOnly) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrder) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(PlaceLimitOrder) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(Limit) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrder) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(PlaceLimitOrder) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(ImmediateOrCancel) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceLimitOrder) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + } + } + }) + } +} diff --git a/programs/phoenix_v1/PlaceMultiplePostOnlyOrders.go b/programs/phoenix_v1/PlaceMultiplePostOnlyOrders.go new file mode 100644 index 000000000..60cdd5138 --- /dev/null +++ b/programs/phoenix_v1/PlaceMultiplePostOnlyOrders.go @@ -0,0 +1,298 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// PlaceMultiplePostOnlyOrders is the `PlaceMultiplePostOnlyOrders` instruction. +type PlaceMultiplePostOnlyOrders struct { + MultipleOrderPacket *MultipleOrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + // + // [5] = [WRITE] baseAccount + // + // [6] = [WRITE] quoteAccount + // + // [7] = [WRITE] baseVault + // + // [8] = [WRITE] quoteVault + // + // [9] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewPlaceMultiplePostOnlyOrdersInstructionBuilder creates a new `PlaceMultiplePostOnlyOrders` instruction builder. +func NewPlaceMultiplePostOnlyOrdersInstructionBuilder() *PlaceMultiplePostOnlyOrders { + nd := &PlaceMultiplePostOnlyOrders{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), + } + return nd +} + +// SetMultipleOrderPacket sets the "multipleOrderPacket" parameter. +func (inst *PlaceMultiplePostOnlyOrders) SetMultipleOrderPacket(multipleOrderPacket MultipleOrderPacket) *PlaceMultiplePostOnlyOrders { + inst.MultipleOrderPacket = &multipleOrderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *PlaceMultiplePostOnlyOrders) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *PlaceMultiplePostOnlyOrders) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *PlaceMultiplePostOnlyOrders) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *PlaceMultiplePostOnlyOrders) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *PlaceMultiplePostOnlyOrders) SetMarketAccount(market ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *PlaceMultiplePostOnlyOrders) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *PlaceMultiplePostOnlyOrders) SetTraderAccount(trader ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *PlaceMultiplePostOnlyOrders) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *PlaceMultiplePostOnlyOrders) SetSeatAccount(seat ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *PlaceMultiplePostOnlyOrders) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *PlaceMultiplePostOnlyOrders) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[5] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *PlaceMultiplePostOnlyOrders) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *PlaceMultiplePostOnlyOrders) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[6] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *PlaceMultiplePostOnlyOrders) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *PlaceMultiplePostOnlyOrders) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[7] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *PlaceMultiplePostOnlyOrders) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *PlaceMultiplePostOnlyOrders) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[8] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *PlaceMultiplePostOnlyOrders) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *PlaceMultiplePostOnlyOrders) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *PlaceMultiplePostOnlyOrders) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +func (inst PlaceMultiplePostOnlyOrders) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_PlaceMultiplePostOnlyOrders, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst PlaceMultiplePostOnlyOrders) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *PlaceMultiplePostOnlyOrders) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.MultipleOrderPacket == nil { + return errors.New("MultipleOrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *PlaceMultiplePostOnlyOrders) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("PlaceMultiplePostOnlyOrders")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("MultipleOrderPacket", *inst.MultipleOrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + }) + }) + }) +} + +func (obj PlaceMultiplePostOnlyOrders) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MultipleOrderPacket` param: + err = encoder.Encode(obj.MultipleOrderPacket) + if err != nil { + return err + } + return nil +} +func (obj *PlaceMultiplePostOnlyOrders) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MultipleOrderPacket`: + err = decoder.Decode(&obj.MultipleOrderPacket) + if err != nil { + return err + } + return nil +} + +// NewPlaceMultiplePostOnlyOrdersInstruction declares a new PlaceMultiplePostOnlyOrders instruction with the provided parameters and accounts. +func NewPlaceMultiplePostOnlyOrdersInstruction( + // Parameters: + multipleOrderPacket MultipleOrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrders { + return NewPlaceMultiplePostOnlyOrdersInstructionBuilder(). + SetMultipleOrderPacket(multipleOrderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds.go b/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds.go new file mode 100644 index 000000000..c424ac423 --- /dev/null +++ b/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds.go @@ -0,0 +1,203 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// PlaceMultiplePostOnlyOrdersWithFreeFunds is the `PlaceMultiplePostOnlyOrdersWithFreeFunds` instruction. +type PlaceMultiplePostOnlyOrdersWithFreeFunds struct { + MultipleOrderPacket *MultipleOrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewPlaceMultiplePostOnlyOrdersWithFreeFundsInstructionBuilder creates a new `PlaceMultiplePostOnlyOrdersWithFreeFunds` instruction builder. +func NewPlaceMultiplePostOnlyOrdersWithFreeFundsInstructionBuilder() *PlaceMultiplePostOnlyOrdersWithFreeFunds { + nd := &PlaceMultiplePostOnlyOrdersWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetMultipleOrderPacket sets the "multipleOrderPacket" parameter. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetMultipleOrderPacket(multipleOrderPacket MultipleOrderPacket) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.MultipleOrderPacket = &multipleOrderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) SetSeatAccount(seat ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst PlaceMultiplePostOnlyOrdersWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_PlaceMultiplePostOnlyOrdersWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst PlaceMultiplePostOnlyOrdersWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.MultipleOrderPacket == nil { + return errors.New("MultipleOrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + } + return nil +} + +func (inst *PlaceMultiplePostOnlyOrdersWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("PlaceMultiplePostOnlyOrdersWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("MultipleOrderPacket", *inst.MultipleOrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj PlaceMultiplePostOnlyOrdersWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MultipleOrderPacket` param: + err = encoder.Encode(obj.MultipleOrderPacket) + if err != nil { + return err + } + return nil +} +func (obj *PlaceMultiplePostOnlyOrdersWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MultipleOrderPacket`: + err = decoder.Decode(&obj.MultipleOrderPacket) + if err != nil { + return err + } + return nil +} + +// NewPlaceMultiplePostOnlyOrdersWithFreeFundsInstruction declares a new PlaceMultiplePostOnlyOrdersWithFreeFunds instruction with the provided parameters and accounts. +func NewPlaceMultiplePostOnlyOrdersWithFreeFundsInstruction( + // Parameters: + multipleOrderPacket MultipleOrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey) *PlaceMultiplePostOnlyOrdersWithFreeFunds { + return NewPlaceMultiplePostOnlyOrdersWithFreeFundsInstructionBuilder(). + SetMultipleOrderPacket(multipleOrderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat) +} diff --git a/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds_test.go b/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds_test.go new file mode 100644 index 000000000..995b793f1 --- /dev/null +++ b/programs/phoenix_v1/PlaceMultiplePostOnlyOrdersWithFreeFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_PlaceMultiplePostOnlyOrdersWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("PlaceMultiplePostOnlyOrdersWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(PlaceMultiplePostOnlyOrdersWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceMultiplePostOnlyOrdersWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/PlaceMultiplePostOnlyOrders_test.go b/programs/phoenix_v1/PlaceMultiplePostOnlyOrders_test.go new file mode 100644 index 000000000..6e1a43889 --- /dev/null +++ b/programs/phoenix_v1/PlaceMultiplePostOnlyOrders_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_PlaceMultiplePostOnlyOrders(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("PlaceMultiplePostOnlyOrders"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(PlaceMultiplePostOnlyOrders) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(PlaceMultiplePostOnlyOrders) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ReduceOrder.go b/programs/phoenix_v1/ReduceOrder.go new file mode 100644 index 000000000..5ee553a87 --- /dev/null +++ b/programs/phoenix_v1/ReduceOrder.go @@ -0,0 +1,279 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ReduceOrder is the `ReduceOrder` instruction. +type ReduceOrder struct { + Params *ReduceOrderParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewReduceOrderInstructionBuilder creates a new `ReduceOrder` instruction builder. +func NewReduceOrderInstructionBuilder() *ReduceOrder { + nd := &ReduceOrder{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *ReduceOrder) SetParams(params ReduceOrderParams) *ReduceOrder { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ReduceOrder) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ReduceOrder) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ReduceOrder) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ReduceOrder) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ReduceOrder) SetMarketAccount(market ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ReduceOrder) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *ReduceOrder) SetTraderAccount(trader ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *ReduceOrder) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *ReduceOrder) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *ReduceOrder) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *ReduceOrder) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *ReduceOrder) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *ReduceOrder) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *ReduceOrder) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *ReduceOrder) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *ReduceOrder) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *ReduceOrder) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *ReduceOrder { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *ReduceOrder) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst ReduceOrder) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ReduceOrder, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ReduceOrder) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ReduceOrder) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *ReduceOrder) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ReduceOrder")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj ReduceOrder) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *ReduceOrder) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewReduceOrderInstruction declares a new ReduceOrder instruction with the provided parameters and accounts. +func NewReduceOrderInstruction( + // Parameters: + params ReduceOrderParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *ReduceOrder { + return NewReduceOrderInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/ReduceOrderWithFreeFunds.go b/programs/phoenix_v1/ReduceOrderWithFreeFunds.go new file mode 100644 index 000000000..5b4218220 --- /dev/null +++ b/programs/phoenix_v1/ReduceOrderWithFreeFunds.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ReduceOrderWithFreeFunds is the `ReduceOrderWithFreeFunds` instruction. +type ReduceOrderWithFreeFunds struct { + Params *ReduceOrderParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [WRITE, SIGNER] trader + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewReduceOrderWithFreeFundsInstructionBuilder creates a new `ReduceOrderWithFreeFunds` instruction builder. +func NewReduceOrderWithFreeFundsInstructionBuilder() *ReduceOrderWithFreeFunds { + nd := &ReduceOrderWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetParams sets the "params" parameter. +func (inst *ReduceOrderWithFreeFunds) SetParams(params ReduceOrderParams) *ReduceOrderWithFreeFunds { + inst.Params = ¶ms + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *ReduceOrderWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *ReduceOrderWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *ReduceOrderWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *ReduceOrderWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *ReduceOrderWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *ReduceOrderWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *ReduceOrderWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *ReduceOrderWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *ReduceOrderWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *ReduceOrderWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *ReduceOrderWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).WRITE().SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *ReduceOrderWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +func (inst ReduceOrderWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ReduceOrderWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ReduceOrderWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ReduceOrderWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Params == nil { + return errors.New("Params parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + } + return nil +} + +func (inst *ReduceOrderWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ReduceOrderWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Params", *inst.Params)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + }) + }) + }) +} + +func (obj ReduceOrderWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Params` param: + err = encoder.Encode(obj.Params) + if err != nil { + return err + } + return nil +} +func (obj *ReduceOrderWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Params`: + err = decoder.Decode(&obj.Params) + if err != nil { + return err + } + return nil +} + +// NewReduceOrderWithFreeFundsInstruction declares a new ReduceOrderWithFreeFunds instruction with the provided parameters and accounts. +func NewReduceOrderWithFreeFundsInstruction( + // Parameters: + params ReduceOrderParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey) *ReduceOrderWithFreeFunds { + return NewReduceOrderWithFreeFundsInstructionBuilder(). + SetParams(params). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader) +} diff --git a/programs/phoenix_v1/ReduceOrderWithFreeFunds_test.go b/programs/phoenix_v1/ReduceOrderWithFreeFunds_test.go new file mode 100644 index 000000000..b659a2ad3 --- /dev/null +++ b/programs/phoenix_v1/ReduceOrderWithFreeFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ReduceOrderWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ReduceOrderWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ReduceOrderWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ReduceOrderWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/ReduceOrder_test.go b/programs/phoenix_v1/ReduceOrder_test.go new file mode 100644 index 000000000..3a0e1e2cc --- /dev/null +++ b/programs/phoenix_v1/ReduceOrder_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ReduceOrder(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ReduceOrder"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ReduceOrder) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ReduceOrder) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/RequestSeat.go b/programs/phoenix_v1/RequestSeat.go new file mode 100644 index 000000000..ddd1cc4e5 --- /dev/null +++ b/programs/phoenix_v1/RequestSeat.go @@ -0,0 +1,193 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// RequestSeat is the `RequestSeat` instruction. +type RequestSeat struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [WRITE, SIGNER] payer + // + // [4] = [WRITE] seat + // + // [5] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewRequestSeatInstructionBuilder creates a new `RequestSeat` instruction builder. +func NewRequestSeatInstructionBuilder() *RequestSeat { + nd := &RequestSeat{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *RequestSeat) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *RequestSeat) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *RequestSeat) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *RequestSeat) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *RequestSeat) SetMarketAccount(market ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *RequestSeat) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetPayerAccount sets the "payer" account. +func (inst *RequestSeat) SetPayerAccount(payer ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[3] = ag_solanago.Meta(payer).WRITE().SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +func (inst *RequestSeat) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *RequestSeat) SetSeatAccount(seat ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat).WRITE() + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *RequestSeat) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *RequestSeat) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *RequestSeat { + inst.AccountMetaSlice[5] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *RequestSeat) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +func (inst RequestSeat) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RequestSeat, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RequestSeat) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RequestSeat) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *RequestSeat) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RequestSeat")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(5))) + }) + }) + }) +} + +func (obj RequestSeat) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *RequestSeat) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewRequestSeatInstruction declares a new RequestSeat instruction with the provided parameters and accounts. +func NewRequestSeatInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + payer ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *RequestSeat { + return NewRequestSeatInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetPayerAccount(payer). + SetSeatAccount(seat). + SetSystemProgramAccount(systemProgram) +} diff --git a/programs/phoenix_v1/RequestSeatAuthorized.go b/programs/phoenix_v1/RequestSeatAuthorized.go new file mode 100644 index 000000000..24346786b --- /dev/null +++ b/programs/phoenix_v1/RequestSeatAuthorized.go @@ -0,0 +1,231 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// RequestSeatAuthorized is the `RequestSeatAuthorized` instruction. +type RequestSeatAuthorized struct { + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] marketAuthority + // + // [4] = [WRITE, SIGNER] payer + // + // [5] = [] trader + // + // [6] = [WRITE] seat + // + // [7] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewRequestSeatAuthorizedInstructionBuilder creates a new `RequestSeatAuthorized` instruction builder. +func NewRequestSeatAuthorizedInstructionBuilder() *RequestSeatAuthorized { + nd := &RequestSeatAuthorized{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 8), + } + return nd +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *RequestSeatAuthorized) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *RequestSeatAuthorized) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *RequestSeatAuthorized) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *RequestSeatAuthorized) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *RequestSeatAuthorized) SetMarketAccount(market ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *RequestSeatAuthorized) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetMarketAuthorityAccount sets the "marketAuthority" account. +func (inst *RequestSeatAuthorized) SetMarketAuthorityAccount(marketAuthority ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[3] = ag_solanago.Meta(marketAuthority).SIGNER() + return inst +} + +// GetMarketAuthorityAccount gets the "marketAuthority" account. +func (inst *RequestSeatAuthorized) GetMarketAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetPayerAccount sets the "payer" account. +func (inst *RequestSeatAuthorized) SetPayerAccount(payer ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[4] = ag_solanago.Meta(payer).WRITE().SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +func (inst *RequestSeatAuthorized) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetTraderAccount sets the "trader" account. +func (inst *RequestSeatAuthorized) SetTraderAccount(trader ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[5] = ag_solanago.Meta(trader) + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *RequestSeatAuthorized) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetSeatAccount sets the "seat" account. +func (inst *RequestSeatAuthorized) SetSeatAccount(seat ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[6] = ag_solanago.Meta(seat).WRITE() + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *RequestSeatAuthorized) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *RequestSeatAuthorized) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *RequestSeatAuthorized { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *RequestSeatAuthorized) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +func (inst RequestSeatAuthorized) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RequestSeatAuthorized, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RequestSeatAuthorized) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RequestSeatAuthorized) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.MarketAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Seat is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *RequestSeatAuthorized) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RequestSeatAuthorized")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=8]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("marketAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(7))) + }) + }) + }) +} + +func (obj RequestSeatAuthorized) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *RequestSeatAuthorized) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewRequestSeatAuthorizedInstruction declares a new RequestSeatAuthorized instruction with the provided parameters and accounts. +func NewRequestSeatAuthorizedInstruction( + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + marketAuthority ag_solanago.PublicKey, + payer ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *RequestSeatAuthorized { + return NewRequestSeatAuthorizedInstructionBuilder(). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetMarketAuthorityAccount(marketAuthority). + SetPayerAccount(payer). + SetTraderAccount(trader). + SetSeatAccount(seat). + SetSystemProgramAccount(systemProgram) +} diff --git a/programs/phoenix_v1/RequestSeatAuthorized_test.go b/programs/phoenix_v1/RequestSeatAuthorized_test.go new file mode 100644 index 000000000..f8b51b997 --- /dev/null +++ b/programs/phoenix_v1/RequestSeatAuthorized_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RequestSeatAuthorized(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RequestSeatAuthorized"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RequestSeatAuthorized) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RequestSeatAuthorized) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/RequestSeat_test.go b/programs/phoenix_v1/RequestSeat_test.go new file mode 100644 index 000000000..80812ff00 --- /dev/null +++ b/programs/phoenix_v1/RequestSeat_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RequestSeat(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RequestSeat"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RequestSeat) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RequestSeat) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/phoenix_v1/Swap.go b/programs/phoenix_v1/Swap.go new file mode 100644 index 000000000..53639b284 --- /dev/null +++ b/programs/phoenix_v1/Swap.go @@ -0,0 +1,307 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Swap is the `Swap` instruction. +type Swap struct { + OrderPacket OrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSwapInstructionBuilder creates a new `Swap` instruction builder. +func NewSwapInstructionBuilder() *Swap { + nd := &Swap{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetOrderPacket sets the "orderPacket" parameter. +func (inst *Swap) SetOrderPacket(orderPacket OrderPacket) *Swap { + inst.OrderPacket = orderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *Swap) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *Swap) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *Swap) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *Swap) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *Swap) SetMarketAccount(market ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *Swap) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *Swap) SetTraderAccount(trader ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *Swap) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *Swap) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *Swap) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *Swap) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *Swap) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *Swap) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *Swap) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *Swap) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *Swap) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Swap) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Swap { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Swap) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst Swap) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Swap, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Swap) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Swap) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.OrderPacket == nil { + return errors.New("OrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *Swap) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Swap")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("OrderPacket", inst.OrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj Swap) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `OrderPacket` param: + { + tmp := orderPacketContainer{} + switch realvalue := obj.OrderPacket.(type) { + case *OrderPacketPostOnly: + tmp.Enum = 0 + tmp.PostOnly = *realvalue + case *OrderPacketLimit: + tmp.Enum = 1 + tmp.Limit = *realvalue + case *OrderPacketImmediateOrCancel: + tmp.Enum = 2 + tmp.ImmediateOrCancel = *realvalue + } + err := encoder.Encode(tmp) + if err != nil { + return err + } + } + return nil +} +func (obj *Swap) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `OrderPacket`: + { + tmp := new(orderPacketContainer) + err := decoder.Decode(tmp) + if err != nil { + return err + } + switch tmp.Enum { + case 0: + obj.OrderPacket = &tmp.PostOnly + case 1: + obj.OrderPacket = &tmp.Limit + case 2: + obj.OrderPacket = &tmp.ImmediateOrCancel + default: + return fmt.Errorf("unknown enum index: %v", tmp.Enum) + } + } + return nil +} + +// NewSwapInstruction declares a new Swap instruction with the provided parameters and accounts. +func NewSwapInstruction( + // Parameters: + orderPacket OrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *Swap { + return NewSwapInstructionBuilder(). + SetOrderPacket(orderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/SwapWithFreeFunds.go b/programs/phoenix_v1/SwapWithFreeFunds.go new file mode 100644 index 000000000..c9e0ccb0f --- /dev/null +++ b/programs/phoenix_v1/SwapWithFreeFunds.go @@ -0,0 +1,231 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// SwapWithFreeFunds is the `SwapWithFreeFunds` instruction. +type SwapWithFreeFunds struct { + OrderPacket OrderPacket + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [] seat + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSwapWithFreeFundsInstructionBuilder creates a new `SwapWithFreeFunds` instruction builder. +func NewSwapWithFreeFundsInstructionBuilder() *SwapWithFreeFunds { + nd := &SwapWithFreeFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetOrderPacket sets the "orderPacket" parameter. +func (inst *SwapWithFreeFunds) SetOrderPacket(orderPacket OrderPacket) *SwapWithFreeFunds { + inst.OrderPacket = orderPacket + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *SwapWithFreeFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *SwapWithFreeFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *SwapWithFreeFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *SwapWithFreeFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *SwapWithFreeFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *SwapWithFreeFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *SwapWithFreeFunds) SetMarketAccount(market ag_solanago.PublicKey) *SwapWithFreeFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *SwapWithFreeFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *SwapWithFreeFunds) SetTraderAccount(trader ag_solanago.PublicKey) *SwapWithFreeFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *SwapWithFreeFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetSeatAccount sets the "seat" account. +func (inst *SwapWithFreeFunds) SetSeatAccount(seat ag_solanago.PublicKey) *SwapWithFreeFunds { + inst.AccountMetaSlice[4] = ag_solanago.Meta(seat) + return inst +} + +// GetSeatAccount gets the "seat" account. +func (inst *SwapWithFreeFunds) GetSeatAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst SwapWithFreeFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SwapWithFreeFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SwapWithFreeFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SwapWithFreeFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.OrderPacket == nil { + return errors.New("OrderPacket parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Seat is not set") + } + } + return nil +} + +func (inst *SwapWithFreeFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SwapWithFreeFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("OrderPacket", inst.OrderPacket)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" seat", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj SwapWithFreeFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `OrderPacket` param: + { + tmp := orderPacketContainer{} + switch realvalue := obj.OrderPacket.(type) { + case *OrderPacketPostOnly: + tmp.Enum = 0 + tmp.PostOnly = *realvalue + case *OrderPacketLimit: + tmp.Enum = 1 + tmp.Limit = *realvalue + case *OrderPacketImmediateOrCancel: + tmp.Enum = 2 + tmp.ImmediateOrCancel = *realvalue + } + err := encoder.Encode(tmp) + if err != nil { + return err + } + } + return nil +} +func (obj *SwapWithFreeFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `OrderPacket`: + { + tmp := new(orderPacketContainer) + err := decoder.Decode(tmp) + if err != nil { + return err + } + switch tmp.Enum { + case 0: + obj.OrderPacket = &tmp.PostOnly + case 1: + obj.OrderPacket = &tmp.Limit + case 2: + obj.OrderPacket = &tmp.ImmediateOrCancel + default: + return fmt.Errorf("unknown enum index: %v", tmp.Enum) + } + } + return nil +} + +// NewSwapWithFreeFundsInstruction declares a new SwapWithFreeFunds instruction with the provided parameters and accounts. +func NewSwapWithFreeFundsInstruction( + // Parameters: + orderPacket OrderPacket, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + seat ag_solanago.PublicKey) *SwapWithFreeFunds { + return NewSwapWithFreeFundsInstructionBuilder(). + SetOrderPacket(orderPacket). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetSeatAccount(seat) +} diff --git a/programs/phoenix_v1/SwapWithFreeFunds_test.go b/programs/phoenix_v1/SwapWithFreeFunds_test.go new file mode 100644 index 000000000..b57ac880d --- /dev/null +++ b/programs/phoenix_v1/SwapWithFreeFunds_test.go @@ -0,0 +1,71 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SwapWithFreeFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SwapWithFreeFunds"+strconv.Itoa(i), func(t *testing.T) { + { + { + { + params := new(SwapWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(PostOnly) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SwapWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(SwapWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(Limit) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SwapWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(SwapWithFreeFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(ImmediateOrCancel) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SwapWithFreeFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + } + } + }) + } +} diff --git a/programs/phoenix_v1/Swap_test.go b/programs/phoenix_v1/Swap_test.go new file mode 100644 index 000000000..6bc25c344 --- /dev/null +++ b/programs/phoenix_v1/Swap_test.go @@ -0,0 +1,71 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Swap(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Swap"+strconv.Itoa(i), func(t *testing.T) { + { + { + { + params := new(Swap) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(PostOnly) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Swap) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(Swap) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(Limit) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Swap) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + { + params := new(Swap) + fu.Fuzz(params) + params.AccountMetaSlice = nil + tmp := new(ImmediateOrCancel) + fu.Fuzz(tmp) + params.SetOrderPacket(tmp) + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Swap) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + } + } + }) + } +} diff --git a/programs/phoenix_v1/WithdrawFunds.go b/programs/phoenix_v1/WithdrawFunds.go new file mode 100644 index 000000000..78ca08720 --- /dev/null +++ b/programs/phoenix_v1/WithdrawFunds.go @@ -0,0 +1,279 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// WithdrawFunds is the `WithdrawFunds` instruction. +type WithdrawFunds struct { + WithdrawFundsParams *WithdrawParams + + // [0] = [] phoenixProgram + // + // [1] = [] logAuthority + // + // [2] = [WRITE] market + // + // [3] = [SIGNER] trader + // + // [4] = [WRITE] baseAccount + // + // [5] = [WRITE] quoteAccount + // + // [6] = [WRITE] baseVault + // + // [7] = [WRITE] quoteVault + // + // [8] = [] tokenProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawFundsInstructionBuilder creates a new `WithdrawFunds` instruction builder. +func NewWithdrawFundsInstructionBuilder() *WithdrawFunds { + nd := &WithdrawFunds{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), + } + return nd +} + +// SetWithdrawFundsParams sets the "withdrawFundsParams" parameter. +func (inst *WithdrawFunds) SetWithdrawFundsParams(withdrawFundsParams WithdrawParams) *WithdrawFunds { + inst.WithdrawFundsParams = &withdrawFundsParams + return inst +} + +// SetPhoenixProgramAccount sets the "phoenixProgram" account. +func (inst *WithdrawFunds) SetPhoenixProgramAccount(phoenixProgram ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[0] = ag_solanago.Meta(phoenixProgram) + return inst +} + +// GetPhoenixProgramAccount gets the "phoenixProgram" account. +func (inst *WithdrawFunds) GetPhoenixProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLogAuthorityAccount sets the "logAuthority" account. +func (inst *WithdrawFunds) SetLogAuthorityAccount(logAuthority ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[1] = ag_solanago.Meta(logAuthority) + return inst +} + +// GetLogAuthorityAccount gets the "logAuthority" account. +func (inst *WithdrawFunds) GetLogAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMarketAccount sets the "market" account. +func (inst *WithdrawFunds) SetMarketAccount(market ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[2] = ag_solanago.Meta(market).WRITE() + return inst +} + +// GetMarketAccount gets the "market" account. +func (inst *WithdrawFunds) GetMarketAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetTraderAccount sets the "trader" account. +func (inst *WithdrawFunds) SetTraderAccount(trader ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[3] = ag_solanago.Meta(trader).SIGNER() + return inst +} + +// GetTraderAccount gets the "trader" account. +func (inst *WithdrawFunds) GetTraderAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetBaseAccountAccount sets the "baseAccount" account. +func (inst *WithdrawFunds) SetBaseAccountAccount(baseAccount ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[4] = ag_solanago.Meta(baseAccount).WRITE() + return inst +} + +// GetBaseAccountAccount gets the "baseAccount" account. +func (inst *WithdrawFunds) GetBaseAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetQuoteAccountAccount sets the "quoteAccount" account. +func (inst *WithdrawFunds) SetQuoteAccountAccount(quoteAccount ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[5] = ag_solanago.Meta(quoteAccount).WRITE() + return inst +} + +// GetQuoteAccountAccount gets the "quoteAccount" account. +func (inst *WithdrawFunds) GetQuoteAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetBaseVaultAccount sets the "baseVault" account. +func (inst *WithdrawFunds) SetBaseVaultAccount(baseVault ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[6] = ag_solanago.Meta(baseVault).WRITE() + return inst +} + +// GetBaseVaultAccount gets the "baseVault" account. +func (inst *WithdrawFunds) GetBaseVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetQuoteVaultAccount sets the "quoteVault" account. +func (inst *WithdrawFunds) SetQuoteVaultAccount(quoteVault ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[7] = ag_solanago.Meta(quoteVault).WRITE() + return inst +} + +// GetQuoteVaultAccount gets the "quoteVault" account. +func (inst *WithdrawFunds) GetQuoteVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *WithdrawFunds) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *WithdrawFunds { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *WithdrawFunds) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +func (inst WithdrawFunds) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_WithdrawFunds, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst WithdrawFunds) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *WithdrawFunds) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.WithdrawFundsParams == nil { + return errors.New("WithdrawFundsParams parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.PhoenixProgram is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LogAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Market is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Trader is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.BaseAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.QuoteAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.BaseVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.QuoteVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + } + return nil +} + +func (inst *WithdrawFunds) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("WithdrawFunds")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("WithdrawFundsParams", *inst.WithdrawFundsParams)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("phoenixProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" logAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" market", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" trader", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" base", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" quote", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" baseVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" quoteVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + }) + }) + }) +} + +func (obj WithdrawFunds) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `WithdrawFundsParams` param: + err = encoder.Encode(obj.WithdrawFundsParams) + if err != nil { + return err + } + return nil +} +func (obj *WithdrawFunds) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `WithdrawFundsParams`: + err = decoder.Decode(&obj.WithdrawFundsParams) + if err != nil { + return err + } + return nil +} + +// NewWithdrawFundsInstruction declares a new WithdrawFunds instruction with the provided parameters and accounts. +func NewWithdrawFundsInstruction( + // Parameters: + withdrawFundsParams WithdrawParams, + // Accounts: + phoenixProgram ag_solanago.PublicKey, + logAuthority ag_solanago.PublicKey, + market ag_solanago.PublicKey, + trader ag_solanago.PublicKey, + baseAccount ag_solanago.PublicKey, + quoteAccount ag_solanago.PublicKey, + baseVault ag_solanago.PublicKey, + quoteVault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey) *WithdrawFunds { + return NewWithdrawFundsInstructionBuilder(). + SetWithdrawFundsParams(withdrawFundsParams). + SetPhoenixProgramAccount(phoenixProgram). + SetLogAuthorityAccount(logAuthority). + SetMarketAccount(market). + SetTraderAccount(trader). + SetBaseAccountAccount(baseAccount). + SetQuoteAccountAccount(quoteAccount). + SetBaseVaultAccount(baseVault). + SetQuoteVaultAccount(quoteVault). + SetTokenProgramAccount(tokenProgram) +} diff --git a/programs/phoenix_v1/WithdrawFunds_test.go b/programs/phoenix_v1/WithdrawFunds_test.go new file mode 100644 index 000000000..3507a3253 --- /dev/null +++ b/programs/phoenix_v1/WithdrawFunds_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_WithdrawFunds(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("WithdrawFunds"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(WithdrawFunds) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(WithdrawFunds) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stabblestableswap/constants.go b/programs/phoenix_v1/accounts.go similarity index 79% rename from programs/stabblestableswap/constants.go rename to programs/phoenix_v1/accounts.go index b17f15db2..98b4a9c74 100644 --- a/programs/stabblestableswap/constants.go +++ b/programs/phoenix_v1/accounts.go @@ -1,3 +1,3 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package stable_swap +package phoenix_v1 diff --git a/programs/phoenix_v1/instructions.go b/programs/phoenix_v1/instructions.go new file mode 100644 index 000000000..732e37489 --- /dev/null +++ b/programs/phoenix_v1/instructions.go @@ -0,0 +1,306 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "PhoenixV1" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + Instruction_Swap = ag_binary.TypeID([8]byte{248, 198, 158, 145, 225, 117, 135, 200}) + + Instruction_SwapWithFreeFunds = ag_binary.TypeID([8]byte{85, 145, 253, 195, 175, 103, 32, 30}) + + Instruction_PlaceLimitOrder = ag_binary.TypeID([8]byte{108, 176, 33, 186, 146, 229, 1, 197}) + + Instruction_PlaceLimitOrderWithFreeFunds = ag_binary.TypeID([8]byte{201, 97, 183, 58, 224, 51, 193, 217}) + + Instruction_ReduceOrder = ag_binary.TypeID([8]byte{138, 143, 24, 74, 37, 73, 195, 236}) + + Instruction_ReduceOrderWithFreeFunds = ag_binary.TypeID([8]byte{153, 234, 42, 168, 238, 72, 171, 102}) + + Instruction_CancelAllOrders = ag_binary.TypeID([8]byte{196, 83, 243, 171, 17, 100, 160, 143}) + + Instruction_CancelAllOrdersWithFreeFunds = ag_binary.TypeID([8]byte{26, 160, 6, 99, 49, 168, 177, 236}) + + Instruction_CancelUpTo = ag_binary.TypeID([8]byte{26, 209, 244, 253, 59, 175, 227, 54}) + + Instruction_CancelUpToWithFreeFunds = ag_binary.TypeID([8]byte{224, 111, 103, 64, 53, 162, 174, 119}) + + Instruction_CancelMultipleOrdersById = ag_binary.TypeID([8]byte{240, 145, 18, 248, 67, 112, 10, 149}) + + Instruction_CancelMultipleOrdersByIdWithFreeFunds = ag_binary.TypeID([8]byte{70, 205, 161, 158, 178, 223, 151, 140}) + + Instruction_WithdrawFunds = ag_binary.TypeID([8]byte{241, 36, 29, 111, 208, 31, 104, 217}) + + Instruction_DepositFunds = ag_binary.TypeID([8]byte{202, 39, 52, 211, 53, 20, 250, 88}) + + Instruction_RequestSeat = ag_binary.TypeID([8]byte{45, 147, 28, 81, 244, 235, 148, 143}) + + Instruction_Log = ag_binary.TypeID([8]byte{141, 230, 214, 242, 9, 209, 207, 170}) + + Instruction_PlaceMultiplePostOnlyOrders = ag_binary.TypeID([8]byte{43, 115, 45, 80, 85, 20, 71, 229}) + + Instruction_PlaceMultiplePostOnlyOrdersWithFreeFunds = ag_binary.TypeID([8]byte{219, 66, 162, 10, 147, 94, 156, 68}) + + Instruction_InitializeMarket = ag_binary.TypeID([8]byte{35, 35, 189, 193, 155, 48, 170, 203}) + + Instruction_ClaimAuthority = ag_binary.TypeID([8]byte{222, 132, 185, 123, 127, 107, 6, 31}) + + Instruction_NameSuccessor = ag_binary.TypeID([8]byte{160, 203, 37, 229, 225, 119, 129, 236}) + + Instruction_ChangeMarketStatus = ag_binary.TypeID([8]byte{221, 127, 224, 41, 177, 145, 126, 8}) + + Instruction_ChangeSeatStatus = ag_binary.TypeID([8]byte{197, 197, 78, 110, 99, 229, 168, 22}) + + Instruction_RequestSeatAuthorized = ag_binary.TypeID([8]byte{250, 119, 182, 161, 113, 25, 150, 156}) + + Instruction_EvictSeat = ag_binary.TypeID([8]byte{232, 165, 194, 88, 233, 155, 82, 197}) + + Instruction_ForceCancelOrders = ag_binary.TypeID([8]byte{64, 181, 196, 63, 222, 72, 64, 232}) + + Instruction_CollectFees = ag_binary.TypeID([8]byte{164, 152, 207, 99, 30, 186, 19, 182}) + + Instruction_ChangeFeeRecipient = ag_binary.TypeID([8]byte{253, 7, 246, 194, 88, 253, 47, 118}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_Swap: + return "Swap" + case Instruction_SwapWithFreeFunds: + return "SwapWithFreeFunds" + case Instruction_PlaceLimitOrder: + return "PlaceLimitOrder" + case Instruction_PlaceLimitOrderWithFreeFunds: + return "PlaceLimitOrderWithFreeFunds" + case Instruction_ReduceOrder: + return "ReduceOrder" + case Instruction_ReduceOrderWithFreeFunds: + return "ReduceOrderWithFreeFunds" + case Instruction_CancelAllOrders: + return "CancelAllOrders" + case Instruction_CancelAllOrdersWithFreeFunds: + return "CancelAllOrdersWithFreeFunds" + case Instruction_CancelUpTo: + return "CancelUpTo" + case Instruction_CancelUpToWithFreeFunds: + return "CancelUpToWithFreeFunds" + case Instruction_CancelMultipleOrdersById: + return "CancelMultipleOrdersById" + case Instruction_CancelMultipleOrdersByIdWithFreeFunds: + return "CancelMultipleOrdersByIdWithFreeFunds" + case Instruction_WithdrawFunds: + return "WithdrawFunds" + case Instruction_DepositFunds: + return "DepositFunds" + case Instruction_RequestSeat: + return "RequestSeat" + case Instruction_Log: + return "Log" + case Instruction_PlaceMultiplePostOnlyOrders: + return "PlaceMultiplePostOnlyOrders" + case Instruction_PlaceMultiplePostOnlyOrdersWithFreeFunds: + return "PlaceMultiplePostOnlyOrdersWithFreeFunds" + case Instruction_InitializeMarket: + return "InitializeMarket" + case Instruction_ClaimAuthority: + return "ClaimAuthority" + case Instruction_NameSuccessor: + return "NameSuccessor" + case Instruction_ChangeMarketStatus: + return "ChangeMarketStatus" + case Instruction_ChangeSeatStatus: + return "ChangeSeatStatus" + case Instruction_RequestSeatAuthorized: + return "RequestSeatAuthorized" + case Instruction_EvictSeat: + return "EvictSeat" + case Instruction_ForceCancelOrders: + return "ForceCancelOrders" + case Instruction_CollectFees: + return "CollectFees" + case Instruction_ChangeFeeRecipient: + return "ChangeFeeRecipient" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "swap", (*Swap)(nil), + }, + { + "swap_with_free_funds", (*SwapWithFreeFunds)(nil), + }, + { + "place_limit_order", (*PlaceLimitOrder)(nil), + }, + { + "place_limit_order_with_free_funds", (*PlaceLimitOrderWithFreeFunds)(nil), + }, + { + "reduce_order", (*ReduceOrder)(nil), + }, + { + "reduce_order_with_free_funds", (*ReduceOrderWithFreeFunds)(nil), + }, + { + "cancel_all_orders", (*CancelAllOrders)(nil), + }, + { + "cancel_all_orders_with_free_funds", (*CancelAllOrdersWithFreeFunds)(nil), + }, + { + "cancel_up_to", (*CancelUpTo)(nil), + }, + { + "cancel_up_to_with_free_funds", (*CancelUpToWithFreeFunds)(nil), + }, + { + "cancel_multiple_orders_by_id", (*CancelMultipleOrdersById)(nil), + }, + { + "cancel_multiple_orders_by_id_with_free_funds", (*CancelMultipleOrdersByIdWithFreeFunds)(nil), + }, + { + "withdraw_funds", (*WithdrawFunds)(nil), + }, + { + "deposit_funds", (*DepositFunds)(nil), + }, + { + "request_seat", (*RequestSeat)(nil), + }, + { + "log", (*Log)(nil), + }, + { + "place_multiple_post_only_orders", (*PlaceMultiplePostOnlyOrders)(nil), + }, + { + "place_multiple_post_only_orders_with_free_funds", (*PlaceMultiplePostOnlyOrdersWithFreeFunds)(nil), + }, + { + "initialize_market", (*InitializeMarket)(nil), + }, + { + "claim_authority", (*ClaimAuthority)(nil), + }, + { + "name_successor", (*NameSuccessor)(nil), + }, + { + "change_market_status", (*ChangeMarketStatus)(nil), + }, + { + "change_seat_status", (*ChangeSeatStatus)(nil), + }, + { + "request_seat_authorized", (*RequestSeatAuthorized)(nil), + }, + { + "evict_seat", (*EvictSeat)(nil), + }, + { + "force_cancel_orders", (*ForceCancelOrders)(nil), + }, + { + "collect_fees", (*CollectFees)(nil), + }, + { + "change_fee_recipient", (*ChangeFeeRecipient)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/raydiumclmm/testing_utils.go b/programs/phoenix_v1/testing_utils.go similarity index 96% rename from programs/raydiumclmm/testing_utils.go rename to programs/phoenix_v1/testing_utils.go index cb09721d7..bccd4cea8 100644 --- a/programs/raydiumclmm/testing_utils.go +++ b/programs/phoenix_v1/testing_utils.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package phoenix_v1 import ( "bytes" diff --git a/programs/phoenix_v1/types.go b/programs/phoenix_v1/types.go new file mode 100644 index 000000000..8f5da2d13 --- /dev/null +++ b/programs/phoenix_v1/types.go @@ -0,0 +1,2317 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package phoenix_v1 + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type MarketSizeParams struct { + BidsSize uint64 + AsksSize uint64 + NumSeats uint64 +} + +func (obj MarketSizeParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `BidsSize` param: + err = encoder.Encode(obj.BidsSize) + if err != nil { + return err + } + // Serialize `AsksSize` param: + err = encoder.Encode(obj.AsksSize) + if err != nil { + return err + } + // Serialize `NumSeats` param: + err = encoder.Encode(obj.NumSeats) + if err != nil { + return err + } + return nil +} + +func (obj *MarketSizeParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `BidsSize`: + err = decoder.Decode(&obj.BidsSize) + if err != nil { + return err + } + // Deserialize `AsksSize`: + err = decoder.Decode(&obj.AsksSize) + if err != nil { + return err + } + // Deserialize `NumSeats`: + err = decoder.Decode(&obj.NumSeats) + if err != nil { + return err + } + return nil +} + +type TokenParams struct { + Decimals uint32 + VaultBump uint32 + MintKey ag_solanago.PublicKey + VaultKey ag_solanago.PublicKey +} + +func (obj TokenParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Decimals` param: + err = encoder.Encode(obj.Decimals) + if err != nil { + return err + } + // Serialize `VaultBump` param: + err = encoder.Encode(obj.VaultBump) + if err != nil { + return err + } + // Serialize `MintKey` param: + err = encoder.Encode(obj.MintKey) + if err != nil { + return err + } + // Serialize `VaultKey` param: + err = encoder.Encode(obj.VaultKey) + if err != nil { + return err + } + return nil +} + +func (obj *TokenParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Decimals`: + err = decoder.Decode(&obj.Decimals) + if err != nil { + return err + } + // Deserialize `VaultBump`: + err = decoder.Decode(&obj.VaultBump) + if err != nil { + return err + } + // Deserialize `MintKey`: + err = decoder.Decode(&obj.MintKey) + if err != nil { + return err + } + // Deserialize `VaultKey`: + err = decoder.Decode(&obj.VaultKey) + if err != nil { + return err + } + return nil +} + +type Seat struct { + Discriminant uint64 + Market ag_solanago.PublicKey + Trader ag_solanago.PublicKey + ApprovalStatus uint64 + Padding [6]uint64 +} + +func (obj Seat) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Discriminant` param: + err = encoder.Encode(obj.Discriminant) + if err != nil { + return err + } + // Serialize `Market` param: + err = encoder.Encode(obj.Market) + if err != nil { + return err + } + // Serialize `Trader` param: + err = encoder.Encode(obj.Trader) + if err != nil { + return err + } + // Serialize `ApprovalStatus` param: + err = encoder.Encode(obj.ApprovalStatus) + if err != nil { + return err + } + // Serialize `Padding` param: + err = encoder.Encode(obj.Padding) + if err != nil { + return err + } + return nil +} + +func (obj *Seat) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Discriminant`: + err = decoder.Decode(&obj.Discriminant) + if err != nil { + return err + } + // Deserialize `Market`: + err = decoder.Decode(&obj.Market) + if err != nil { + return err + } + // Deserialize `Trader`: + err = decoder.Decode(&obj.Trader) + if err != nil { + return err + } + // Deserialize `ApprovalStatus`: + err = decoder.Decode(&obj.ApprovalStatus) + if err != nil { + return err + } + // Deserialize `Padding`: + err = decoder.Decode(&obj.Padding) + if err != nil { + return err + } + return nil +} + +type AuditLogHeader struct { + Instruction uint8 + SequenceNumber uint64 + Timestamp int64 + Slot uint64 + Market ag_solanago.PublicKey + Signer ag_solanago.PublicKey + TotalEvents uint16 +} + +func (obj AuditLogHeader) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Instruction` param: + err = encoder.Encode(obj.Instruction) + if err != nil { + return err + } + // Serialize `SequenceNumber` param: + err = encoder.Encode(obj.SequenceNumber) + if err != nil { + return err + } + // Serialize `Timestamp` param: + err = encoder.Encode(obj.Timestamp) + if err != nil { + return err + } + // Serialize `Slot` param: + err = encoder.Encode(obj.Slot) + if err != nil { + return err + } + // Serialize `Market` param: + err = encoder.Encode(obj.Market) + if err != nil { + return err + } + // Serialize `Signer` param: + err = encoder.Encode(obj.Signer) + if err != nil { + return err + } + // Serialize `TotalEvents` param: + err = encoder.Encode(obj.TotalEvents) + if err != nil { + return err + } + return nil +} + +func (obj *AuditLogHeader) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Instruction`: + err = decoder.Decode(&obj.Instruction) + if err != nil { + return err + } + // Deserialize `SequenceNumber`: + err = decoder.Decode(&obj.SequenceNumber) + if err != nil { + return err + } + // Deserialize `Timestamp`: + err = decoder.Decode(&obj.Timestamp) + if err != nil { + return err + } + // Deserialize `Slot`: + err = decoder.Decode(&obj.Slot) + if err != nil { + return err + } + // Deserialize `Market`: + err = decoder.Decode(&obj.Market) + if err != nil { + return err + } + // Deserialize `Signer`: + err = decoder.Decode(&obj.Signer) + if err != nil { + return err + } + // Deserialize `TotalEvents`: + err = decoder.Decode(&obj.TotalEvents) + if err != nil { + return err + } + return nil +} + +type FillEvent struct { + Index uint16 + MakerId ag_solanago.PublicKey + OrderSequenceNumber uint64 + PriceInTicks uint64 + BaseLotsFilled uint64 + BaseLotsRemaining uint64 +} + +func (obj FillEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `MakerId` param: + err = encoder.Encode(obj.MakerId) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `BaseLotsFilled` param: + err = encoder.Encode(obj.BaseLotsFilled) + if err != nil { + return err + } + // Serialize `BaseLotsRemaining` param: + err = encoder.Encode(obj.BaseLotsRemaining) + if err != nil { + return err + } + return nil +} + +func (obj *FillEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `MakerId`: + err = decoder.Decode(&obj.MakerId) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `BaseLotsFilled`: + err = decoder.Decode(&obj.BaseLotsFilled) + if err != nil { + return err + } + // Deserialize `BaseLotsRemaining`: + err = decoder.Decode(&obj.BaseLotsRemaining) + if err != nil { + return err + } + return nil +} + +type ReduceEvent struct { + Index uint16 + OrderSequenceNumber uint64 + PriceInTicks uint64 + BaseLotsRemoved uint64 + BaseLotsRemaining uint64 +} + +func (obj ReduceEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `BaseLotsRemoved` param: + err = encoder.Encode(obj.BaseLotsRemoved) + if err != nil { + return err + } + // Serialize `BaseLotsRemaining` param: + err = encoder.Encode(obj.BaseLotsRemaining) + if err != nil { + return err + } + return nil +} + +func (obj *ReduceEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `BaseLotsRemoved`: + err = decoder.Decode(&obj.BaseLotsRemoved) + if err != nil { + return err + } + // Deserialize `BaseLotsRemaining`: + err = decoder.Decode(&obj.BaseLotsRemaining) + if err != nil { + return err + } + return nil +} + +type PlaceEvent struct { + Index uint16 + OrderSequenceNumber uint64 + ClientOrderId ag_binary.Uint128 + PriceInTicks uint64 + BaseLotsPlaced uint64 +} + +func (obj PlaceEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `ClientOrderId` param: + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `BaseLotsPlaced` param: + err = encoder.Encode(obj.BaseLotsPlaced) + if err != nil { + return err + } + return nil +} + +func (obj *PlaceEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `ClientOrderId`: + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `BaseLotsPlaced`: + err = decoder.Decode(&obj.BaseLotsPlaced) + if err != nil { + return err + } + return nil +} + +type EvictEvent struct { + Index uint16 + MakerId ag_solanago.PublicKey + OrderSequenceNumber uint64 + PriceInTicks uint64 + BaseLotsEvicted uint64 +} + +func (obj EvictEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `MakerId` param: + err = encoder.Encode(obj.MakerId) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `BaseLotsEvicted` param: + err = encoder.Encode(obj.BaseLotsEvicted) + if err != nil { + return err + } + return nil +} + +func (obj *EvictEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `MakerId`: + err = decoder.Decode(&obj.MakerId) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `BaseLotsEvicted`: + err = decoder.Decode(&obj.BaseLotsEvicted) + if err != nil { + return err + } + return nil +} + +type FillSummaryEvent struct { + Index uint16 + ClientOrderId ag_binary.Uint128 + TotalBaseLotsFilled uint64 + TotalQuoteLotsFilled uint64 + TotalFeeInQuoteLots uint64 +} + +func (obj FillSummaryEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `ClientOrderId` param: + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + // Serialize `TotalBaseLotsFilled` param: + err = encoder.Encode(obj.TotalBaseLotsFilled) + if err != nil { + return err + } + // Serialize `TotalQuoteLotsFilled` param: + err = encoder.Encode(obj.TotalQuoteLotsFilled) + if err != nil { + return err + } + // Serialize `TotalFeeInQuoteLots` param: + err = encoder.Encode(obj.TotalFeeInQuoteLots) + if err != nil { + return err + } + return nil +} + +func (obj *FillSummaryEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `ClientOrderId`: + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + // Deserialize `TotalBaseLotsFilled`: + err = decoder.Decode(&obj.TotalBaseLotsFilled) + if err != nil { + return err + } + // Deserialize `TotalQuoteLotsFilled`: + err = decoder.Decode(&obj.TotalQuoteLotsFilled) + if err != nil { + return err + } + // Deserialize `TotalFeeInQuoteLots`: + err = decoder.Decode(&obj.TotalFeeInQuoteLots) + if err != nil { + return err + } + return nil +} + +type FeeEvent struct { + Index uint16 + FeesCollectedInQuoteLots uint64 +} + +func (obj FeeEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `FeesCollectedInQuoteLots` param: + err = encoder.Encode(obj.FeesCollectedInQuoteLots) + if err != nil { + return err + } + return nil +} + +func (obj *FeeEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `FeesCollectedInQuoteLots`: + err = decoder.Decode(&obj.FeesCollectedInQuoteLots) + if err != nil { + return err + } + return nil +} + +type TimeInForceEvent struct { + Index uint16 + OrderSequenceNumber uint64 + LastValidSlot uint64 + LastValidUnixTimestampInSeconds uint64 +} + +func (obj TimeInForceEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `LastValidSlot` param: + err = encoder.Encode(obj.LastValidSlot) + if err != nil { + return err + } + // Serialize `LastValidUnixTimestampInSeconds` param: + err = encoder.Encode(obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + return nil +} + +func (obj *TimeInForceEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `LastValidSlot`: + err = decoder.Decode(&obj.LastValidSlot) + if err != nil { + return err + } + // Deserialize `LastValidUnixTimestampInSeconds`: + err = decoder.Decode(&obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + return nil +} + +type ExpiredOrderEvent struct { + Index uint16 + MakerId ag_solanago.PublicKey + OrderSequenceNumber uint64 + PriceInTicks uint64 + BaseLotsRemoved uint64 +} + +func (obj ExpiredOrderEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `MakerId` param: + err = encoder.Encode(obj.MakerId) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `BaseLotsRemoved` param: + err = encoder.Encode(obj.BaseLotsRemoved) + if err != nil { + return err + } + return nil +} + +func (obj *ExpiredOrderEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `MakerId`: + err = decoder.Decode(&obj.MakerId) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `BaseLotsRemoved`: + err = decoder.Decode(&obj.BaseLotsRemoved) + if err != nil { + return err + } + return nil +} + +type CancelUpToParams struct { + Side Side + TickLimit *uint64 `bin:"optional"` + NumOrdersToSearch *uint32 `bin:"optional"` + NumOrdersToCancel *uint32 `bin:"optional"` +} + +func (obj CancelUpToParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Side` param: + err = encoder.Encode(obj.Side) + if err != nil { + return err + } + // Serialize `TickLimit` param (optional): + { + if obj.TickLimit == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.TickLimit) + if err != nil { + return err + } + } + } + // Serialize `NumOrdersToSearch` param (optional): + { + if obj.NumOrdersToSearch == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.NumOrdersToSearch) + if err != nil { + return err + } + } + } + // Serialize `NumOrdersToCancel` param (optional): + { + if obj.NumOrdersToCancel == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.NumOrdersToCancel) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *CancelUpToParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Side`: + err = decoder.Decode(&obj.Side) + if err != nil { + return err + } + // Deserialize `TickLimit` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.TickLimit) + if err != nil { + return err + } + } + } + // Deserialize `NumOrdersToSearch` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.NumOrdersToSearch) + if err != nil { + return err + } + } + } + // Deserialize `NumOrdersToCancel` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.NumOrdersToCancel) + if err != nil { + return err + } + } + } + return nil +} + +type CancelMultipleOrdersByIdParams struct { + Orders []CancelOrderParams +} + +func (obj CancelMultipleOrdersByIdParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Orders` param: + err = encoder.Encode(obj.Orders) + if err != nil { + return err + } + return nil +} + +func (obj *CancelMultipleOrdersByIdParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Orders`: + err = decoder.Decode(&obj.Orders) + if err != nil { + return err + } + return nil +} + +type DepositParams struct { + QuoteLotsToDeposit uint64 + BaseLotsToDeposit uint64 +} + +func (obj DepositParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `QuoteLotsToDeposit` param: + err = encoder.Encode(obj.QuoteLotsToDeposit) + if err != nil { + return err + } + // Serialize `BaseLotsToDeposit` param: + err = encoder.Encode(obj.BaseLotsToDeposit) + if err != nil { + return err + } + return nil +} + +func (obj *DepositParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `QuoteLotsToDeposit`: + err = decoder.Decode(&obj.QuoteLotsToDeposit) + if err != nil { + return err + } + // Deserialize `BaseLotsToDeposit`: + err = decoder.Decode(&obj.BaseLotsToDeposit) + if err != nil { + return err + } + return nil +} + +type InitializeParams struct { + MarketSizeParams MarketSizeParams + NumQuoteLotsPerQuoteUnit uint64 + TickSizeInQuoteLotsPerBaseUnit uint64 + NumBaseLotsPerBaseUnit uint64 + TakerFeeBps uint16 + FeeCollector ag_solanago.PublicKey + RawBaseUnitsPerBaseUnit *uint32 `bin:"optional"` +} + +func (obj InitializeParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MarketSizeParams` param: + err = encoder.Encode(obj.MarketSizeParams) + if err != nil { + return err + } + // Serialize `NumQuoteLotsPerQuoteUnit` param: + err = encoder.Encode(obj.NumQuoteLotsPerQuoteUnit) + if err != nil { + return err + } + // Serialize `TickSizeInQuoteLotsPerBaseUnit` param: + err = encoder.Encode(obj.TickSizeInQuoteLotsPerBaseUnit) + if err != nil { + return err + } + // Serialize `NumBaseLotsPerBaseUnit` param: + err = encoder.Encode(obj.NumBaseLotsPerBaseUnit) + if err != nil { + return err + } + // Serialize `TakerFeeBps` param: + err = encoder.Encode(obj.TakerFeeBps) + if err != nil { + return err + } + // Serialize `FeeCollector` param: + err = encoder.Encode(obj.FeeCollector) + if err != nil { + return err + } + // Serialize `RawBaseUnitsPerBaseUnit` param (optional): + { + if obj.RawBaseUnitsPerBaseUnit == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.RawBaseUnitsPerBaseUnit) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *InitializeParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MarketSizeParams`: + err = decoder.Decode(&obj.MarketSizeParams) + if err != nil { + return err + } + // Deserialize `NumQuoteLotsPerQuoteUnit`: + err = decoder.Decode(&obj.NumQuoteLotsPerQuoteUnit) + if err != nil { + return err + } + // Deserialize `TickSizeInQuoteLotsPerBaseUnit`: + err = decoder.Decode(&obj.TickSizeInQuoteLotsPerBaseUnit) + if err != nil { + return err + } + // Deserialize `NumBaseLotsPerBaseUnit`: + err = decoder.Decode(&obj.NumBaseLotsPerBaseUnit) + if err != nil { + return err + } + // Deserialize `TakerFeeBps`: + err = decoder.Decode(&obj.TakerFeeBps) + if err != nil { + return err + } + // Deserialize `FeeCollector`: + err = decoder.Decode(&obj.FeeCollector) + if err != nil { + return err + } + // Deserialize `RawBaseUnitsPerBaseUnit` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.RawBaseUnitsPerBaseUnit) + if err != nil { + return err + } + } + } + return nil +} + +type MultipleOrderPacket struct { + Bids []CondensedOrder + Asks []CondensedOrder + ClientOrderId *ag_binary.Uint128 `bin:"optional"` + FailedMultipleLimitOrderBehavior FailedMultipleLimitOrderBehavior +} + +func (obj MultipleOrderPacket) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Bids` param: + err = encoder.Encode(obj.Bids) + if err != nil { + return err + } + // Serialize `Asks` param: + err = encoder.Encode(obj.Asks) + if err != nil { + return err + } + // Serialize `ClientOrderId` param (optional): + { + if obj.ClientOrderId == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + } + } + // Serialize `FailedMultipleLimitOrderBehavior` param: + err = encoder.Encode(obj.FailedMultipleLimitOrderBehavior) + if err != nil { + return err + } + return nil +} + +func (obj *MultipleOrderPacket) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Bids`: + err = decoder.Decode(&obj.Bids) + if err != nil { + return err + } + // Deserialize `Asks`: + err = decoder.Decode(&obj.Asks) + if err != nil { + return err + } + // Deserialize `ClientOrderId` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + } + } + // Deserialize `FailedMultipleLimitOrderBehavior`: + err = decoder.Decode(&obj.FailedMultipleLimitOrderBehavior) + if err != nil { + return err + } + return nil +} + +type CondensedOrder struct { + PriceInTicks uint64 + SizeInBaseLots uint64 + LastValidSlot *uint64 `bin:"optional"` + LastValidUnixTimestampInSeconds *uint64 `bin:"optional"` +} + +func (obj CondensedOrder) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `SizeInBaseLots` param: + err = encoder.Encode(obj.SizeInBaseLots) + if err != nil { + return err + } + // Serialize `LastValidSlot` param (optional): + { + if obj.LastValidSlot == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Serialize `LastValidUnixTimestampInSeconds` param (optional): + { + if obj.LastValidUnixTimestampInSeconds == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *CondensedOrder) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `SizeInBaseLots`: + err = decoder.Decode(&obj.SizeInBaseLots) + if err != nil { + return err + } + // Deserialize `LastValidSlot` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Deserialize `LastValidUnixTimestampInSeconds` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + return nil +} + +type CancelOrderParams struct { + Side Side + PriceInTicks uint64 + OrderSequenceNumber uint64 +} + +func (obj CancelOrderParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Side` param: + err = encoder.Encode(obj.Side) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `OrderSequenceNumber` param: + err = encoder.Encode(obj.OrderSequenceNumber) + if err != nil { + return err + } + return nil +} + +func (obj *CancelOrderParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Side`: + err = decoder.Decode(&obj.Side) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `OrderSequenceNumber`: + err = decoder.Decode(&obj.OrderSequenceNumber) + if err != nil { + return err + } + return nil +} + +type ReduceOrderParams struct { + BaseParams CancelOrderParams + Size uint64 +} + +func (obj ReduceOrderParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `BaseParams` param: + err = encoder.Encode(obj.BaseParams) + if err != nil { + return err + } + // Serialize `Size` param: + err = encoder.Encode(obj.Size) + if err != nil { + return err + } + return nil +} + +func (obj *ReduceOrderParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `BaseParams`: + err = decoder.Decode(&obj.BaseParams) + if err != nil { + return err + } + // Deserialize `Size`: + err = decoder.Decode(&obj.Size) + if err != nil { + return err + } + return nil +} + +type WithdrawParams struct { + QuoteLotsToWithdraw *uint64 `bin:"optional"` + BaseLotsToWithdraw *uint64 `bin:"optional"` +} + +func (obj WithdrawParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `QuoteLotsToWithdraw` param (optional): + { + if obj.QuoteLotsToWithdraw == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.QuoteLotsToWithdraw) + if err != nil { + return err + } + } + } + // Serialize `BaseLotsToWithdraw` param (optional): + { + if obj.BaseLotsToWithdraw == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.BaseLotsToWithdraw) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *WithdrawParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `QuoteLotsToWithdraw` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.QuoteLotsToWithdraw) + if err != nil { + return err + } + } + } + // Deserialize `BaseLotsToWithdraw` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.BaseLotsToWithdraw) + if err != nil { + return err + } + } + } + return nil +} + +type MarketHeader struct { + Discriminant uint64 + Status uint64 + MarketSizeParams MarketSizeParams + BaseParams TokenParams + BaseLotSize uint64 + QuoteParams TokenParams + QuoteLotSize uint64 + TickSizeInQuoteAtomsPerBaseUnit uint64 + Authority ag_solanago.PublicKey + FeeRecipient ag_solanago.PublicKey + MarketSequenceNumber uint64 + Successor ag_solanago.PublicKey + RawBaseUnitsPerBaseUnit uint32 + Padding1 uint32 + Padding2 [32]uint64 +} + +func (obj MarketHeader) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Discriminant` param: + err = encoder.Encode(obj.Discriminant) + if err != nil { + return err + } + // Serialize `Status` param: + err = encoder.Encode(obj.Status) + if err != nil { + return err + } + // Serialize `MarketSizeParams` param: + err = encoder.Encode(obj.MarketSizeParams) + if err != nil { + return err + } + // Serialize `BaseParams` param: + err = encoder.Encode(obj.BaseParams) + if err != nil { + return err + } + // Serialize `BaseLotSize` param: + err = encoder.Encode(obj.BaseLotSize) + if err != nil { + return err + } + // Serialize `QuoteParams` param: + err = encoder.Encode(obj.QuoteParams) + if err != nil { + return err + } + // Serialize `QuoteLotSize` param: + err = encoder.Encode(obj.QuoteLotSize) + if err != nil { + return err + } + // Serialize `TickSizeInQuoteAtomsPerBaseUnit` param: + err = encoder.Encode(obj.TickSizeInQuoteAtomsPerBaseUnit) + if err != nil { + return err + } + // Serialize `Authority` param: + err = encoder.Encode(obj.Authority) + if err != nil { + return err + } + // Serialize `FeeRecipient` param: + err = encoder.Encode(obj.FeeRecipient) + if err != nil { + return err + } + // Serialize `MarketSequenceNumber` param: + err = encoder.Encode(obj.MarketSequenceNumber) + if err != nil { + return err + } + // Serialize `Successor` param: + err = encoder.Encode(obj.Successor) + if err != nil { + return err + } + // Serialize `RawBaseUnitsPerBaseUnit` param: + err = encoder.Encode(obj.RawBaseUnitsPerBaseUnit) + if err != nil { + return err + } + // Serialize `Padding1` param: + err = encoder.Encode(obj.Padding1) + if err != nil { + return err + } + // Serialize `Padding2` param: + err = encoder.Encode(obj.Padding2) + if err != nil { + return err + } + return nil +} + +func (obj *MarketHeader) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Discriminant`: + err = decoder.Decode(&obj.Discriminant) + if err != nil { + return err + } + // Deserialize `Status`: + err = decoder.Decode(&obj.Status) + if err != nil { + return err + } + // Deserialize `MarketSizeParams`: + err = decoder.Decode(&obj.MarketSizeParams) + if err != nil { + return err + } + // Deserialize `BaseParams`: + err = decoder.Decode(&obj.BaseParams) + if err != nil { + return err + } + // Deserialize `BaseLotSize`: + err = decoder.Decode(&obj.BaseLotSize) + if err != nil { + return err + } + // Deserialize `QuoteParams`: + err = decoder.Decode(&obj.QuoteParams) + if err != nil { + return err + } + // Deserialize `QuoteLotSize`: + err = decoder.Decode(&obj.QuoteLotSize) + if err != nil { + return err + } + // Deserialize `TickSizeInQuoteAtomsPerBaseUnit`: + err = decoder.Decode(&obj.TickSizeInQuoteAtomsPerBaseUnit) + if err != nil { + return err + } + // Deserialize `Authority`: + err = decoder.Decode(&obj.Authority) + if err != nil { + return err + } + // Deserialize `FeeRecipient`: + err = decoder.Decode(&obj.FeeRecipient) + if err != nil { + return err + } + // Deserialize `MarketSequenceNumber`: + err = decoder.Decode(&obj.MarketSequenceNumber) + if err != nil { + return err + } + // Deserialize `Successor`: + err = decoder.Decode(&obj.Successor) + if err != nil { + return err + } + // Deserialize `RawBaseUnitsPerBaseUnit`: + err = decoder.Decode(&obj.RawBaseUnitsPerBaseUnit) + if err != nil { + return err + } + // Deserialize `Padding1`: + err = decoder.Decode(&obj.Padding1) + if err != nil { + return err + } + // Deserialize `Padding2`: + err = decoder.Decode(&obj.Padding2) + if err != nil { + return err + } + return nil +} + +type PhoenixMarketEvent interface { + isPhoenixMarketEvent() +} + +type phoenixMarketEventContainer struct { + Enum ag_binary.BorshEnum `borsh_enum:"true"` + Uninitialized PhoenixMarketEventUninitialized + Header PhoenixMarketEventHeader + Fill PhoenixMarketEventFill + Place PhoenixMarketEventPlace + Reduce PhoenixMarketEventReduce + Evict PhoenixMarketEventEvict + FillSummary PhoenixMarketEventFillSummary + Fee PhoenixMarketEventFee + TimeInForce PhoenixMarketEventTimeInForce + ExpiredOrder PhoenixMarketEventExpiredOrder +} + +type PhoenixMarketEventUninitialized uint8 + +func (obj PhoenixMarketEventUninitialized) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} + +func (obj *PhoenixMarketEventUninitialized) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +func (_ *PhoenixMarketEventUninitialized) isPhoenixMarketEvent() {} + +type PhoenixMarketEventHeader struct { + Elem0 AuditLogHeader +} + +func (_ *PhoenixMarketEventHeader) isPhoenixMarketEvent() {} + +type PhoenixMarketEventFill struct { + Elem0 FillEvent +} + +func (_ *PhoenixMarketEventFill) isPhoenixMarketEvent() {} + +type PhoenixMarketEventPlace struct { + Elem0 PlaceEvent +} + +func (_ *PhoenixMarketEventPlace) isPhoenixMarketEvent() {} + +type PhoenixMarketEventReduce struct { + Elem0 ReduceEvent +} + +func (_ *PhoenixMarketEventReduce) isPhoenixMarketEvent() {} + +type PhoenixMarketEventEvict struct { + Elem0 EvictEvent +} + +func (_ *PhoenixMarketEventEvict) isPhoenixMarketEvent() {} + +type PhoenixMarketEventFillSummary struct { + Elem0 FillSummaryEvent +} + +func (_ *PhoenixMarketEventFillSummary) isPhoenixMarketEvent() {} + +type PhoenixMarketEventFee struct { + Elem0 FeeEvent +} + +func (_ *PhoenixMarketEventFee) isPhoenixMarketEvent() {} + +type PhoenixMarketEventTimeInForce struct { + Elem0 TimeInForceEvent +} + +func (_ *PhoenixMarketEventTimeInForce) isPhoenixMarketEvent() {} + +type PhoenixMarketEventExpiredOrder struct { + Elem0 ExpiredOrderEvent +} + +func (_ *PhoenixMarketEventExpiredOrder) isPhoenixMarketEvent() {} + +type FailedMultipleLimitOrderBehavior ag_binary.BorshEnum + +const ( + FailedMultipleLimitOrderBehaviorFailOnInsufficientFundsAndAmendOnCross FailedMultipleLimitOrderBehavior = iota + FailedMultipleLimitOrderBehaviorFailOnInsufficientFundsAndFailOnCross + FailedMultipleLimitOrderBehaviorSkipOnInsufficientFundsAndAmendOnCross + FailedMultipleLimitOrderBehaviorSkipOnInsufficientFundsAndFailOnCross +) + +func (value FailedMultipleLimitOrderBehavior) String() string { + switch value { + case FailedMultipleLimitOrderBehaviorFailOnInsufficientFundsAndAmendOnCross: + return "FailOnInsufficientFundsAndAmendOnCross" + case FailedMultipleLimitOrderBehaviorFailOnInsufficientFundsAndFailOnCross: + return "FailOnInsufficientFundsAndFailOnCross" + case FailedMultipleLimitOrderBehaviorSkipOnInsufficientFundsAndAmendOnCross: + return "SkipOnInsufficientFundsAndAmendOnCross" + case FailedMultipleLimitOrderBehaviorSkipOnInsufficientFundsAndFailOnCross: + return "SkipOnInsufficientFundsAndFailOnCross" + default: + return "" + } +} + +type MarketStatus ag_binary.BorshEnum + +const ( + MarketStatusUninitialized MarketStatus = iota + MarketStatusActive + MarketStatusPostOnly + MarketStatusPaused + MarketStatusClosed + MarketStatusTombstoned +) + +func (value MarketStatus) String() string { + switch value { + case MarketStatusUninitialized: + return "Uninitialized" + case MarketStatusActive: + return "Active" + case MarketStatusPostOnly: + return "PostOnly" + case MarketStatusPaused: + return "Paused" + case MarketStatusClosed: + return "Closed" + case MarketStatusTombstoned: + return "Tombstoned" + default: + return "" + } +} + +type SeatApprovalStatus ag_binary.BorshEnum + +const ( + SeatApprovalStatusNotApproved SeatApprovalStatus = iota + SeatApprovalStatusApproved + SeatApprovalStatusRetired +) + +func (value SeatApprovalStatus) String() string { + switch value { + case SeatApprovalStatusNotApproved: + return "NotApproved" + case SeatApprovalStatusApproved: + return "Approved" + case SeatApprovalStatusRetired: + return "Retired" + default: + return "" + } +} + +type OrderPacket interface { + isOrderPacket() +} + +type orderPacketContainer struct { + Enum ag_binary.BorshEnum `borsh_enum:"true"` + PostOnly OrderPacketPostOnly + Limit OrderPacketLimit + ImmediateOrCancel OrderPacketImmediateOrCancel +} + +type OrderPacketPostOnly struct { + Side Side + PriceInTicks uint64 + NumBaseLots uint64 + ClientOrderId ag_binary.Uint128 + RejectPostOnly bool + UseOnlyDepositedFunds bool + LastValidSlot *uint64 `bin:"optional"` + LastValidUnixTimestampInSeconds *uint64 `bin:"optional"` + FailSilentlyOnInsufficientFunds bool +} + +func (obj OrderPacketPostOnly) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Side` param: + err = encoder.Encode(obj.Side) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `NumBaseLots` param: + err = encoder.Encode(obj.NumBaseLots) + if err != nil { + return err + } + // Serialize `ClientOrderId` param: + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + // Serialize `RejectPostOnly` param: + err = encoder.Encode(obj.RejectPostOnly) + if err != nil { + return err + } + // Serialize `UseOnlyDepositedFunds` param: + err = encoder.Encode(obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Serialize `LastValidSlot` param (optional): + { + if obj.LastValidSlot == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Serialize `LastValidUnixTimestampInSeconds` param (optional): + { + if obj.LastValidUnixTimestampInSeconds == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + // Serialize `FailSilentlyOnInsufficientFunds` param: + err = encoder.Encode(obj.FailSilentlyOnInsufficientFunds) + if err != nil { + return err + } + return nil +} + +func (obj *OrderPacketPostOnly) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Side`: + err = decoder.Decode(&obj.Side) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `NumBaseLots`: + err = decoder.Decode(&obj.NumBaseLots) + if err != nil { + return err + } + // Deserialize `ClientOrderId`: + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + // Deserialize `RejectPostOnly`: + err = decoder.Decode(&obj.RejectPostOnly) + if err != nil { + return err + } + // Deserialize `UseOnlyDepositedFunds`: + err = decoder.Decode(&obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Deserialize `LastValidSlot` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Deserialize `LastValidUnixTimestampInSeconds` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + // Deserialize `FailSilentlyOnInsufficientFunds`: + err = decoder.Decode(&obj.FailSilentlyOnInsufficientFunds) + if err != nil { + return err + } + return nil +} + +func (_ *OrderPacketPostOnly) isOrderPacket() {} + +type OrderPacketLimit struct { + Side Side + PriceInTicks uint64 + NumBaseLots uint64 + SelfTradeBehavior SelfTradeBehavior + MatchLimit *uint64 `bin:"optional"` + ClientOrderId ag_binary.Uint128 + UseOnlyDepositedFunds bool + LastValidSlot *uint64 `bin:"optional"` + LastValidUnixTimestampInSeconds *uint64 `bin:"optional"` + FailSilentlyOnInsufficientFunds bool +} + +func (obj OrderPacketLimit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Side` param: + err = encoder.Encode(obj.Side) + if err != nil { + return err + } + // Serialize `PriceInTicks` param: + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + // Serialize `NumBaseLots` param: + err = encoder.Encode(obj.NumBaseLots) + if err != nil { + return err + } + // Serialize `SelfTradeBehavior` param: + err = encoder.Encode(obj.SelfTradeBehavior) + if err != nil { + return err + } + // Serialize `MatchLimit` param (optional): + { + if obj.MatchLimit == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.MatchLimit) + if err != nil { + return err + } + } + } + // Serialize `ClientOrderId` param: + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + // Serialize `UseOnlyDepositedFunds` param: + err = encoder.Encode(obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Serialize `LastValidSlot` param (optional): + { + if obj.LastValidSlot == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Serialize `LastValidUnixTimestampInSeconds` param (optional): + { + if obj.LastValidUnixTimestampInSeconds == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + // Serialize `FailSilentlyOnInsufficientFunds` param: + err = encoder.Encode(obj.FailSilentlyOnInsufficientFunds) + if err != nil { + return err + } + return nil +} + +func (obj *OrderPacketLimit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Side`: + err = decoder.Decode(&obj.Side) + if err != nil { + return err + } + // Deserialize `PriceInTicks`: + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + // Deserialize `NumBaseLots`: + err = decoder.Decode(&obj.NumBaseLots) + if err != nil { + return err + } + // Deserialize `SelfTradeBehavior`: + err = decoder.Decode(&obj.SelfTradeBehavior) + if err != nil { + return err + } + // Deserialize `MatchLimit` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.MatchLimit) + if err != nil { + return err + } + } + } + // Deserialize `ClientOrderId`: + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + // Deserialize `UseOnlyDepositedFunds`: + err = decoder.Decode(&obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Deserialize `LastValidSlot` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Deserialize `LastValidUnixTimestampInSeconds` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + // Deserialize `FailSilentlyOnInsufficientFunds`: + err = decoder.Decode(&obj.FailSilentlyOnInsufficientFunds) + if err != nil { + return err + } + return nil +} + +func (_ *OrderPacketLimit) isOrderPacket() {} + +type OrderPacketImmediateOrCancel struct { + Side Side + PriceInTicks *uint64 `bin:"optional"` + NumBaseLots uint64 + NumQuoteLots uint64 + MinBaseLotsToFill uint64 + MinQuoteLotsToFill uint64 + SelfTradeBehavior SelfTradeBehavior + MatchLimit *uint64 `bin:"optional"` + ClientOrderId ag_binary.Uint128 + UseOnlyDepositedFunds bool + LastValidSlot *uint64 `bin:"optional"` + LastValidUnixTimestampInSeconds *uint64 `bin:"optional"` +} + +func (obj OrderPacketImmediateOrCancel) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Side` param: + err = encoder.Encode(obj.Side) + if err != nil { + return err + } + // Serialize `PriceInTicks` param (optional): + { + if obj.PriceInTicks == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.PriceInTicks) + if err != nil { + return err + } + } + } + // Serialize `NumBaseLots` param: + err = encoder.Encode(obj.NumBaseLots) + if err != nil { + return err + } + // Serialize `NumQuoteLots` param: + err = encoder.Encode(obj.NumQuoteLots) + if err != nil { + return err + } + // Serialize `MinBaseLotsToFill` param: + err = encoder.Encode(obj.MinBaseLotsToFill) + if err != nil { + return err + } + // Serialize `MinQuoteLotsToFill` param: + err = encoder.Encode(obj.MinQuoteLotsToFill) + if err != nil { + return err + } + // Serialize `SelfTradeBehavior` param: + err = encoder.Encode(obj.SelfTradeBehavior) + if err != nil { + return err + } + // Serialize `MatchLimit` param (optional): + { + if obj.MatchLimit == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.MatchLimit) + if err != nil { + return err + } + } + } + // Serialize `ClientOrderId` param: + err = encoder.Encode(obj.ClientOrderId) + if err != nil { + return err + } + // Serialize `UseOnlyDepositedFunds` param: + err = encoder.Encode(obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Serialize `LastValidSlot` param (optional): + { + if obj.LastValidSlot == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Serialize `LastValidUnixTimestampInSeconds` param (optional): + { + if obj.LastValidUnixTimestampInSeconds == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *OrderPacketImmediateOrCancel) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Side`: + err = decoder.Decode(&obj.Side) + if err != nil { + return err + } + // Deserialize `PriceInTicks` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.PriceInTicks) + if err != nil { + return err + } + } + } + // Deserialize `NumBaseLots`: + err = decoder.Decode(&obj.NumBaseLots) + if err != nil { + return err + } + // Deserialize `NumQuoteLots`: + err = decoder.Decode(&obj.NumQuoteLots) + if err != nil { + return err + } + // Deserialize `MinBaseLotsToFill`: + err = decoder.Decode(&obj.MinBaseLotsToFill) + if err != nil { + return err + } + // Deserialize `MinQuoteLotsToFill`: + err = decoder.Decode(&obj.MinQuoteLotsToFill) + if err != nil { + return err + } + // Deserialize `SelfTradeBehavior`: + err = decoder.Decode(&obj.SelfTradeBehavior) + if err != nil { + return err + } + // Deserialize `MatchLimit` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.MatchLimit) + if err != nil { + return err + } + } + } + // Deserialize `ClientOrderId`: + err = decoder.Decode(&obj.ClientOrderId) + if err != nil { + return err + } + // Deserialize `UseOnlyDepositedFunds`: + err = decoder.Decode(&obj.UseOnlyDepositedFunds) + if err != nil { + return err + } + // Deserialize `LastValidSlot` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidSlot) + if err != nil { + return err + } + } + } + // Deserialize `LastValidUnixTimestampInSeconds` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.LastValidUnixTimestampInSeconds) + if err != nil { + return err + } + } + } + return nil +} + +func (_ *OrderPacketImmediateOrCancel) isOrderPacket() {} + +type Side ag_binary.BorshEnum + +const ( + SideBid Side = iota + SideAsk +) + +func (value Side) String() string { + switch value { + case SideBid: + return "Bid" + case SideAsk: + return "Ask" + default: + return "" + } +} + +type SelfTradeBehavior ag_binary.BorshEnum + +const ( + SelfTradeBehaviorAbort SelfTradeBehavior = iota + SelfTradeBehaviorCancelProvide + SelfTradeBehaviorDecrementTake +) + +func (value SelfTradeBehavior) String() string { + switch value { + case SelfTradeBehaviorAbort: + return "Abort" + case SelfTradeBehaviorCancelProvide: + return "CancelProvide" + case SelfTradeBehaviorDecrementTake: + return "DecrementTake" + default: + return "" + } +} diff --git a/programs/pumpfun/Buy.go b/programs/pumpfun/Buy.go new file mode 100644 index 000000000..b6b2849fb --- /dev/null +++ b/programs/pumpfun/Buy.go @@ -0,0 +1,359 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Buys tokens from a bonding curve. +type Buy struct { + Amount *uint64 + MaxSolCost *uint64 + + // [0] = [] global + // + // [1] = [WRITE] feeRecipient + // + // [2] = [] mint + // + // [3] = [WRITE] bondingCurve + // + // [4] = [WRITE] associatedBondingCurve + // + // [5] = [WRITE] associatedUser + // + // [6] = [WRITE, SIGNER] user + // + // [7] = [] systemProgram + // + // [8] = [] tokenProgram + // + // [9] = [] rent + // + // [10] = [] eventAuthority + // + // [11] = [] program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewBuyInstructionBuilder creates a new `Buy` instruction builder. +func NewBuyInstructionBuilder() *Buy { + nd := &Buy{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *Buy) SetAmount(amount uint64) *Buy { + inst.Amount = &amount + return inst +} + +// SetMaxSolCost sets the "maxSolCost" parameter. +func (inst *Buy) SetMaxSolCost(maxSolCost uint64) *Buy { + inst.MaxSolCost = &maxSolCost + return inst +} + +// SetGlobalAccount sets the "global" account. +func (inst *Buy) SetGlobalAccount(global ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[0] = ag_solanago.Meta(global) + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *Buy) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetFeeRecipientAccount sets the "feeRecipient" account. +func (inst *Buy) SetFeeRecipientAccount(feeRecipient ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[1] = ag_solanago.Meta(feeRecipient).WRITE() + return inst +} + +// GetFeeRecipientAccount gets the "feeRecipient" account. +func (inst *Buy) GetFeeRecipientAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMintAccount sets the "mint" account. +func (inst *Buy) SetMintAccount(mint ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[2] = ag_solanago.Meta(mint) + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Buy) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetBondingCurveAccount sets the "bondingCurve" account. +func (inst *Buy) SetBondingCurveAccount(bondingCurve ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[3] = ag_solanago.Meta(bondingCurve).WRITE() + return inst +} + +// GetBondingCurveAccount gets the "bondingCurve" account. +func (inst *Buy) GetBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetAssociatedBondingCurveAccount sets the "associatedBondingCurve" account. +func (inst *Buy) SetAssociatedBondingCurveAccount(associatedBondingCurve ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[4] = ag_solanago.Meta(associatedBondingCurve).WRITE() + return inst +} + +// GetAssociatedBondingCurveAccount gets the "associatedBondingCurve" account. +func (inst *Buy) GetAssociatedBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetAssociatedUserAccount sets the "associatedUser" account. +func (inst *Buy) SetAssociatedUserAccount(associatedUser ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[5] = ag_solanago.Meta(associatedUser).WRITE() + return inst +} + +// GetAssociatedUserAccount gets the "associatedUser" account. +func (inst *Buy) GetAssociatedUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetUserAccount sets the "user" account. +func (inst *Buy) SetUserAccount(user ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[6] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *Buy) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Buy) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Buy) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Buy) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Buy) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetRentAccount sets the "rent" account. +func (inst *Buy) SetRentAccount(rent ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[9] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +func (inst *Buy) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetEventAuthorityAccount sets the "eventAuthority" account. +func (inst *Buy) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[10] = ag_solanago.Meta(eventAuthority) + return inst +} + +// GetEventAuthorityAccount gets the "eventAuthority" account. +func (inst *Buy) GetEventAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetProgramAccount sets the "program" account. +func (inst *Buy) SetProgramAccount(program ag_solanago.PublicKey) *Buy { + inst.AccountMetaSlice[11] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *Buy) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst Buy) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Buy, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Buy) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Buy) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + if inst.MaxSolCost == nil { + return errors.New("MaxSolCost parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.FeeRecipient is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.BondingCurve is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.AssociatedBondingCurve is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.AssociatedUser is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.EventAuthority is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Program is not set") + } + } + return nil +} + +func (inst *Buy) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Buy")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) + paramsBranch.Child(ag_format.Param("MaxSolCost", *inst.MaxSolCost)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" feeRecipient", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" bondingCurve", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("associatedBondingCurve", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" associatedUser", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" eventAuthority", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj Buy) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `MaxSolCost` param: + err = encoder.Encode(obj.MaxSolCost) + if err != nil { + return err + } + return nil +} +func (obj *Buy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `MaxSolCost`: + err = decoder.Decode(&obj.MaxSolCost) + if err != nil { + return err + } + return nil +} + +// NewBuyInstruction declares a new Buy instruction with the provided parameters and accounts. +func NewBuyInstruction( + // Parameters: + amount uint64, + maxSolCost uint64, + // Accounts: + global ag_solanago.PublicKey, + feeRecipient ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + bondingCurve ag_solanago.PublicKey, + associatedBondingCurve ag_solanago.PublicKey, + associatedUser ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + eventAuthority ag_solanago.PublicKey, + program ag_solanago.PublicKey) *Buy { + return NewBuyInstructionBuilder(). + SetAmount(amount). + SetMaxSolCost(maxSolCost). + SetGlobalAccount(global). + SetFeeRecipientAccount(feeRecipient). + SetMintAccount(mint). + SetBondingCurveAccount(bondingCurve). + SetAssociatedBondingCurveAccount(associatedBondingCurve). + SetAssociatedUserAccount(associatedUser). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram). + SetTokenProgramAccount(tokenProgram). + SetRentAccount(rent). + SetEventAuthorityAccount(eventAuthority). + SetProgramAccount(program) +} diff --git a/programs/pumpfun/Buy_test.go b/programs/pumpfun/Buy_test.go new file mode 100644 index 000000000..7f5992f4e --- /dev/null +++ b/programs/pumpfun/Buy_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Buy(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Buy"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Buy) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Buy) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/Create.go b/programs/pumpfun/Create.go new file mode 100644 index 000000000..31b583c36 --- /dev/null +++ b/programs/pumpfun/Create.go @@ -0,0 +1,420 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Creates a new coin and bonding curve. +type Create struct { + Name *string + Symbol *string + Uri *string + + // [0] = [WRITE, SIGNER] mint + // + // [1] = [] mintAuthority + // + // [2] = [WRITE] bondingCurve + // + // [3] = [WRITE] associatedBondingCurve + // + // [4] = [] global + // + // [5] = [] mplTokenMetadata + // + // [6] = [WRITE] metadata + // + // [7] = [WRITE, SIGNER] user + // + // [8] = [] systemProgram + // + // [9] = [] tokenProgram + // + // [10] = [] associatedTokenProgram + // + // [11] = [] rent + // + // [12] = [] eventAuthority + // + // [13] = [] program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCreateInstructionBuilder creates a new `Create` instruction builder. +func NewCreateInstructionBuilder() *Create { + nd := &Create{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 14), + } + return nd +} + +// SetName sets the "name" parameter. +func (inst *Create) SetName(name string) *Create { + inst.Name = &name + return inst +} + +// SetSymbol sets the "symbol" parameter. +func (inst *Create) SetSymbol(symbol string) *Create { + inst.Symbol = &symbol + return inst +} + +// SetUri sets the "uri" parameter. +func (inst *Create) SetUri(uri string) *Create { + inst.Uri = &uri + return inst +} + +// SetMintAccount sets the "mint" account. +func (inst *Create) SetMintAccount(mint ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[0] = ag_solanago.Meta(mint).WRITE().SIGNER() + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Create) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetMintAuthorityAccount sets the "mintAuthority" account. +func (inst *Create) SetMintAuthorityAccount(mintAuthority ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[1] = ag_solanago.Meta(mintAuthority) + return inst +} + +// GetMintAuthorityAccount gets the "mintAuthority" account. +func (inst *Create) GetMintAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetBondingCurveAccount sets the "bondingCurve" account. +func (inst *Create) SetBondingCurveAccount(bondingCurve ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[2] = ag_solanago.Meta(bondingCurve).WRITE() + return inst +} + +// GetBondingCurveAccount gets the "bondingCurve" account. +func (inst *Create) GetBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetAssociatedBondingCurveAccount sets the "associatedBondingCurve" account. +func (inst *Create) SetAssociatedBondingCurveAccount(associatedBondingCurve ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[3] = ag_solanago.Meta(associatedBondingCurve).WRITE() + return inst +} + +// GetAssociatedBondingCurveAccount gets the "associatedBondingCurve" account. +func (inst *Create) GetAssociatedBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetGlobalAccount sets the "global" account. +func (inst *Create) SetGlobalAccount(global ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[4] = ag_solanago.Meta(global) + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *Create) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetMplTokenMetadataAccount sets the "mplTokenMetadata" account. +func (inst *Create) SetMplTokenMetadataAccount(mplTokenMetadata ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[5] = ag_solanago.Meta(mplTokenMetadata) + return inst +} + +// GetMplTokenMetadataAccount gets the "mplTokenMetadata" account. +func (inst *Create) GetMplTokenMetadataAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetMetadataAccount sets the "metadata" account. +func (inst *Create) SetMetadataAccount(metadata ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[6] = ag_solanago.Meta(metadata).WRITE() + return inst +} + +// GetMetadataAccount gets the "metadata" account. +func (inst *Create) GetMetadataAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetUserAccount sets the "user" account. +func (inst *Create) SetUserAccount(user ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[7] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *Create) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Create) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[8] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Create) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Create) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Create) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetAssociatedTokenProgramAccount sets the "associatedTokenProgram" account. +func (inst *Create) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[10] = ag_solanago.Meta(associatedTokenProgram) + return inst +} + +// GetAssociatedTokenProgramAccount gets the "associatedTokenProgram" account. +func (inst *Create) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetRentAccount sets the "rent" account. +func (inst *Create) SetRentAccount(rent ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[11] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +func (inst *Create) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetEventAuthorityAccount sets the "eventAuthority" account. +func (inst *Create) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[12] = ag_solanago.Meta(eventAuthority) + return inst +} + +// GetEventAuthorityAccount gets the "eventAuthority" account. +func (inst *Create) GetEventAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +// SetProgramAccount sets the "program" account. +func (inst *Create) SetProgramAccount(program ag_solanago.PublicKey) *Create { + inst.AccountMetaSlice[13] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *Create) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(13) +} + +func (inst Create) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Create, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Create) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Create) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Name == nil { + return errors.New("Name parameter is not set") + } + if inst.Symbol == nil { + return errors.New("Symbol parameter is not set") + } + if inst.Uri == nil { + return errors.New("Uri parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.MintAuthority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.BondingCurve is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.AssociatedBondingCurve is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.MplTokenMetadata is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Metadata is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.AssociatedTokenProgram is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.EventAuthority is not set") + } + if inst.AccountMetaSlice[13] == nil { + return errors.New("accounts.Program is not set") + } + } + return nil +} + +func (inst *Create) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Create")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Name", *inst.Name)) + paramsBranch.Child(ag_format.Param("Symbol", *inst.Symbol)) + paramsBranch.Child(ag_format.Param(" Uri", *inst.Uri)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=14]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" mintAuthority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" bondingCurve", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("associatedBondingCurve", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" mplTokenMetadata", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" metadata", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta("associatedTokenProgram", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" eventAuthority", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice.Get(13))) + }) + }) + }) +} + +func (obj Create) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Name` param: + err = encoder.Encode(obj.Name) + if err != nil { + return err + } + // Serialize `Symbol` param: + err = encoder.Encode(obj.Symbol) + if err != nil { + return err + } + // Serialize `Uri` param: + err = encoder.Encode(obj.Uri) + if err != nil { + return err + } + return nil +} +func (obj *Create) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Name`: + err = decoder.Decode(&obj.Name) + if err != nil { + return err + } + // Deserialize `Symbol`: + err = decoder.Decode(&obj.Symbol) + if err != nil { + return err + } + // Deserialize `Uri`: + err = decoder.Decode(&obj.Uri) + if err != nil { + return err + } + return nil +} + +// NewCreateInstruction declares a new Create instruction with the provided parameters and accounts. +func NewCreateInstruction( + // Parameters: + name string, + symbol string, + uri string, + // Accounts: + mint ag_solanago.PublicKey, + mintAuthority ag_solanago.PublicKey, + bondingCurve ag_solanago.PublicKey, + associatedBondingCurve ag_solanago.PublicKey, + global ag_solanago.PublicKey, + mplTokenMetadata ag_solanago.PublicKey, + metadata ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + associatedTokenProgram ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + eventAuthority ag_solanago.PublicKey, + program ag_solanago.PublicKey) *Create { + return NewCreateInstructionBuilder(). + SetName(name). + SetSymbol(symbol). + SetUri(uri). + SetMintAccount(mint). + SetMintAuthorityAccount(mintAuthority). + SetBondingCurveAccount(bondingCurve). + SetAssociatedBondingCurveAccount(associatedBondingCurve). + SetGlobalAccount(global). + SetMplTokenMetadataAccount(mplTokenMetadata). + SetMetadataAccount(metadata). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram). + SetTokenProgramAccount(tokenProgram). + SetAssociatedTokenProgramAccount(associatedTokenProgram). + SetRentAccount(rent). + SetEventAuthorityAccount(eventAuthority). + SetProgramAccount(program) +} diff --git a/programs/pumpfun/Create_test.go b/programs/pumpfun/Create_test.go new file mode 100644 index 000000000..9e8876ef8 --- /dev/null +++ b/programs/pumpfun/Create_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Create(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Create"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Create) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Create) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/Initialize.go b/programs/pumpfun/Initialize.go new file mode 100644 index 000000000..41c2b7303 --- /dev/null +++ b/programs/pumpfun/Initialize.go @@ -0,0 +1,136 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Creates the global state. +type Initialize struct { + + // [0] = [WRITE] global + // + // [1] = [WRITE, SIGNER] user + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. +func NewInitializeInstructionBuilder() *Initialize { + nd := &Initialize{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetGlobalAccount sets the "global" account. +func (inst *Initialize) SetGlobalAccount(global ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[0] = ag_solanago.Meta(global).WRITE() + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *Initialize) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetUserAccount sets the "user" account. +func (inst *Initialize) SetUserAccount(user ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[1] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *Initialize) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Initialize) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Initialize) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst Initialize) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Initialize, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Initialize) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Initialize) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Initialize")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj Initialize) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Initialize) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewInitializeInstruction declares a new Initialize instruction with the provided parameters and accounts. +func NewInitializeInstruction( + // Accounts: + global ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *Initialize { + return NewInitializeInstructionBuilder(). + SetGlobalAccount(global). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram) +} diff --git a/programs/pumpfun/Initialize_test.go b/programs/pumpfun/Initialize_test.go new file mode 100644 index 000000000..756e40e0a --- /dev/null +++ b/programs/pumpfun/Initialize_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initialize(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initialize"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initialize) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initialize) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/Sell.go b/programs/pumpfun/Sell.go new file mode 100644 index 000000000..1db19cc62 --- /dev/null +++ b/programs/pumpfun/Sell.go @@ -0,0 +1,359 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Sells tokens into a bonding curve. +type Sell struct { + Amount *uint64 + MinSolOutput *uint64 + + // [0] = [] global + // + // [1] = [WRITE] feeRecipient + // + // [2] = [] mint + // + // [3] = [WRITE] bondingCurve + // + // [4] = [WRITE] associatedBondingCurve + // + // [5] = [WRITE] associatedUser + // + // [6] = [WRITE, SIGNER] user + // + // [7] = [] systemProgram + // + // [8] = [] associatedTokenProgram + // + // [9] = [] tokenProgram + // + // [10] = [] eventAuthority + // + // [11] = [] program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSellInstructionBuilder creates a new `Sell` instruction builder. +func NewSellInstructionBuilder() *Sell { + nd := &Sell{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *Sell) SetAmount(amount uint64) *Sell { + inst.Amount = &amount + return inst +} + +// SetMinSolOutput sets the "minSolOutput" parameter. +func (inst *Sell) SetMinSolOutput(minSolOutput uint64) *Sell { + inst.MinSolOutput = &minSolOutput + return inst +} + +// SetGlobalAccount sets the "global" account. +func (inst *Sell) SetGlobalAccount(global ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[0] = ag_solanago.Meta(global) + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *Sell) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetFeeRecipientAccount sets the "feeRecipient" account. +func (inst *Sell) SetFeeRecipientAccount(feeRecipient ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[1] = ag_solanago.Meta(feeRecipient).WRITE() + return inst +} + +// GetFeeRecipientAccount gets the "feeRecipient" account. +func (inst *Sell) GetFeeRecipientAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMintAccount sets the "mint" account. +func (inst *Sell) SetMintAccount(mint ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[2] = ag_solanago.Meta(mint) + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Sell) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetBondingCurveAccount sets the "bondingCurve" account. +func (inst *Sell) SetBondingCurveAccount(bondingCurve ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[3] = ag_solanago.Meta(bondingCurve).WRITE() + return inst +} + +// GetBondingCurveAccount gets the "bondingCurve" account. +func (inst *Sell) GetBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetAssociatedBondingCurveAccount sets the "associatedBondingCurve" account. +func (inst *Sell) SetAssociatedBondingCurveAccount(associatedBondingCurve ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[4] = ag_solanago.Meta(associatedBondingCurve).WRITE() + return inst +} + +// GetAssociatedBondingCurveAccount gets the "associatedBondingCurve" account. +func (inst *Sell) GetAssociatedBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetAssociatedUserAccount sets the "associatedUser" account. +func (inst *Sell) SetAssociatedUserAccount(associatedUser ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[5] = ag_solanago.Meta(associatedUser).WRITE() + return inst +} + +// GetAssociatedUserAccount gets the "associatedUser" account. +func (inst *Sell) GetAssociatedUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetUserAccount sets the "user" account. +func (inst *Sell) SetUserAccount(user ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[6] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *Sell) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Sell) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Sell) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetAssociatedTokenProgramAccount sets the "associatedTokenProgram" account. +func (inst *Sell) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[8] = ag_solanago.Meta(associatedTokenProgram) + return inst +} + +// GetAssociatedTokenProgramAccount gets the "associatedTokenProgram" account. +func (inst *Sell) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Sell) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Sell) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetEventAuthorityAccount sets the "eventAuthority" account. +func (inst *Sell) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[10] = ag_solanago.Meta(eventAuthority) + return inst +} + +// GetEventAuthorityAccount gets the "eventAuthority" account. +func (inst *Sell) GetEventAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetProgramAccount sets the "program" account. +func (inst *Sell) SetProgramAccount(program ag_solanago.PublicKey) *Sell { + inst.AccountMetaSlice[11] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *Sell) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst Sell) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Sell, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Sell) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Sell) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + if inst.MinSolOutput == nil { + return errors.New("MinSolOutput parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.FeeRecipient is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.BondingCurve is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.AssociatedBondingCurve is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.AssociatedUser is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.AssociatedTokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.EventAuthority is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Program is not set") + } + } + return nil +} + +func (inst *Sell) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Sell")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) + paramsBranch.Child(ag_format.Param("MinSolOutput", *inst.MinSolOutput)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" feeRecipient", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" bondingCurve", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("associatedBondingCurve", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" associatedUser", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta("associatedTokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" eventAuthority", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj Sell) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `MinSolOutput` param: + err = encoder.Encode(obj.MinSolOutput) + if err != nil { + return err + } + return nil +} +func (obj *Sell) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `MinSolOutput`: + err = decoder.Decode(&obj.MinSolOutput) + if err != nil { + return err + } + return nil +} + +// NewSellInstruction declares a new Sell instruction with the provided parameters and accounts. +func NewSellInstruction( + // Parameters: + amount uint64, + minSolOutput uint64, + // Accounts: + global ag_solanago.PublicKey, + feeRecipient ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + bondingCurve ag_solanago.PublicKey, + associatedBondingCurve ag_solanago.PublicKey, + associatedUser ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + associatedTokenProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + eventAuthority ag_solanago.PublicKey, + program ag_solanago.PublicKey) *Sell { + return NewSellInstructionBuilder(). + SetAmount(amount). + SetMinSolOutput(minSolOutput). + SetGlobalAccount(global). + SetFeeRecipientAccount(feeRecipient). + SetMintAccount(mint). + SetBondingCurveAccount(bondingCurve). + SetAssociatedBondingCurveAccount(associatedBondingCurve). + SetAssociatedUserAccount(associatedUser). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram). + SetAssociatedTokenProgramAccount(associatedTokenProgram). + SetTokenProgramAccount(tokenProgram). + SetEventAuthorityAccount(eventAuthority). + SetProgramAccount(program) +} diff --git a/programs/pumpfun/Sell_test.go b/programs/pumpfun/Sell_test.go new file mode 100644 index 000000000..2c2f95be4 --- /dev/null +++ b/programs/pumpfun/Sell_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Sell(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Sell"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Sell) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Sell) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/SetParams.go b/programs/pumpfun/SetParams.go new file mode 100644 index 000000000..c948da602 --- /dev/null +++ b/programs/pumpfun/SetParams.go @@ -0,0 +1,318 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Sets the global state parameters. +type SetParams struct { + FeeRecipient *ag_solanago.PublicKey + InitialVirtualTokenReserves *uint64 + InitialVirtualSolReserves *uint64 + InitialRealTokenReserves *uint64 + TokenTotalSupply *uint64 + FeeBasisPoints *uint64 + + // [0] = [WRITE] global + // + // [1] = [WRITE, SIGNER] user + // + // [2] = [] systemProgram + // + // [3] = [] eventAuthority + // + // [4] = [] program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSetParamsInstructionBuilder creates a new `SetParams` instruction builder. +func NewSetParamsInstructionBuilder() *SetParams { + nd := &SetParams{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + } + return nd +} + +// SetFeeRecipient sets the "feeRecipient" parameter. +func (inst *SetParams) SetFeeRecipient(feeRecipient ag_solanago.PublicKey) *SetParams { + inst.FeeRecipient = &feeRecipient + return inst +} + +// SetInitialVirtualTokenReserves sets the "initialVirtualTokenReserves" parameter. +func (inst *SetParams) SetInitialVirtualTokenReserves(initialVirtualTokenReserves uint64) *SetParams { + inst.InitialVirtualTokenReserves = &initialVirtualTokenReserves + return inst +} + +// SetInitialVirtualSolReserves sets the "initialVirtualSolReserves" parameter. +func (inst *SetParams) SetInitialVirtualSolReserves(initialVirtualSolReserves uint64) *SetParams { + inst.InitialVirtualSolReserves = &initialVirtualSolReserves + return inst +} + +// SetInitialRealTokenReserves sets the "initialRealTokenReserves" parameter. +func (inst *SetParams) SetInitialRealTokenReserves(initialRealTokenReserves uint64) *SetParams { + inst.InitialRealTokenReserves = &initialRealTokenReserves + return inst +} + +// SetTokenTotalSupply sets the "tokenTotalSupply" parameter. +func (inst *SetParams) SetTokenTotalSupply(tokenTotalSupply uint64) *SetParams { + inst.TokenTotalSupply = &tokenTotalSupply + return inst +} + +// SetFeeBasisPoints sets the "feeBasisPoints" parameter. +func (inst *SetParams) SetFeeBasisPoints(feeBasisPoints uint64) *SetParams { + inst.FeeBasisPoints = &feeBasisPoints + return inst +} + +// SetGlobalAccount sets the "global" account. +func (inst *SetParams) SetGlobalAccount(global ag_solanago.PublicKey) *SetParams { + inst.AccountMetaSlice[0] = ag_solanago.Meta(global).WRITE() + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *SetParams) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetUserAccount sets the "user" account. +func (inst *SetParams) SetUserAccount(user ag_solanago.PublicKey) *SetParams { + inst.AccountMetaSlice[1] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *SetParams) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *SetParams) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *SetParams { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *SetParams) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetEventAuthorityAccount sets the "eventAuthority" account. +func (inst *SetParams) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *SetParams { + inst.AccountMetaSlice[3] = ag_solanago.Meta(eventAuthority) + return inst +} + +// GetEventAuthorityAccount gets the "eventAuthority" account. +func (inst *SetParams) GetEventAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetProgramAccount sets the "program" account. +func (inst *SetParams) SetProgramAccount(program ag_solanago.PublicKey) *SetParams { + inst.AccountMetaSlice[4] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *SetParams) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +func (inst SetParams) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SetParams, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SetParams) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SetParams) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.FeeRecipient == nil { + return errors.New("FeeRecipient parameter is not set") + } + if inst.InitialVirtualTokenReserves == nil { + return errors.New("InitialVirtualTokenReserves parameter is not set") + } + if inst.InitialVirtualSolReserves == nil { + return errors.New("InitialVirtualSolReserves parameter is not set") + } + if inst.InitialRealTokenReserves == nil { + return errors.New("InitialRealTokenReserves parameter is not set") + } + if inst.TokenTotalSupply == nil { + return errors.New("TokenTotalSupply parameter is not set") + } + if inst.FeeBasisPoints == nil { + return errors.New("FeeBasisPoints parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.EventAuthority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Program is not set") + } + } + return nil +} + +func (inst *SetParams) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SetParams")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=6]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" FeeRecipient", *inst.FeeRecipient)) + paramsBranch.Child(ag_format.Param("InitialVirtualTokenReserves", *inst.InitialVirtualTokenReserves)) + paramsBranch.Child(ag_format.Param(" InitialVirtualSolReserves", *inst.InitialVirtualSolReserves)) + paramsBranch.Child(ag_format.Param(" InitialRealTokenReserves", *inst.InitialRealTokenReserves)) + paramsBranch.Child(ag_format.Param(" TokenTotalSupply", *inst.TokenTotalSupply)) + paramsBranch.Child(ag_format.Param(" FeeBasisPoints", *inst.FeeBasisPoints)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("eventAuthority", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice.Get(4))) + }) + }) + }) +} + +func (obj SetParams) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `FeeRecipient` param: + err = encoder.Encode(obj.FeeRecipient) + if err != nil { + return err + } + // Serialize `InitialVirtualTokenReserves` param: + err = encoder.Encode(obj.InitialVirtualTokenReserves) + if err != nil { + return err + } + // Serialize `InitialVirtualSolReserves` param: + err = encoder.Encode(obj.InitialVirtualSolReserves) + if err != nil { + return err + } + // Serialize `InitialRealTokenReserves` param: + err = encoder.Encode(obj.InitialRealTokenReserves) + if err != nil { + return err + } + // Serialize `TokenTotalSupply` param: + err = encoder.Encode(obj.TokenTotalSupply) + if err != nil { + return err + } + // Serialize `FeeBasisPoints` param: + err = encoder.Encode(obj.FeeBasisPoints) + if err != nil { + return err + } + return nil +} +func (obj *SetParams) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `FeeRecipient`: + err = decoder.Decode(&obj.FeeRecipient) + if err != nil { + return err + } + // Deserialize `InitialVirtualTokenReserves`: + err = decoder.Decode(&obj.InitialVirtualTokenReserves) + if err != nil { + return err + } + // Deserialize `InitialVirtualSolReserves`: + err = decoder.Decode(&obj.InitialVirtualSolReserves) + if err != nil { + return err + } + // Deserialize `InitialRealTokenReserves`: + err = decoder.Decode(&obj.InitialRealTokenReserves) + if err != nil { + return err + } + // Deserialize `TokenTotalSupply`: + err = decoder.Decode(&obj.TokenTotalSupply) + if err != nil { + return err + } + // Deserialize `FeeBasisPoints`: + err = decoder.Decode(&obj.FeeBasisPoints) + if err != nil { + return err + } + return nil +} + +// NewSetParamsInstruction declares a new SetParams instruction with the provided parameters and accounts. +func NewSetParamsInstruction( + // Parameters: + feeRecipient ag_solanago.PublicKey, + initialVirtualTokenReserves uint64, + initialVirtualSolReserves uint64, + initialRealTokenReserves uint64, + tokenTotalSupply uint64, + feeBasisPoints uint64, + // Accounts: + global ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + eventAuthority ag_solanago.PublicKey, + program ag_solanago.PublicKey) *SetParams { + return NewSetParamsInstructionBuilder(). + SetFeeRecipient(feeRecipient). + SetInitialVirtualTokenReserves(initialVirtualTokenReserves). + SetInitialVirtualSolReserves(initialVirtualSolReserves). + SetInitialRealTokenReserves(initialRealTokenReserves). + SetTokenTotalSupply(tokenTotalSupply). + SetFeeBasisPoints(feeBasisPoints). + SetGlobalAccount(global). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram). + SetEventAuthorityAccount(eventAuthority). + SetProgramAccount(program) +} diff --git a/programs/pumpfun/SetParams_test.go b/programs/pumpfun/SetParams_test.go new file mode 100644 index 000000000..e12296edf --- /dev/null +++ b/programs/pumpfun/SetParams_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SetParams(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SetParams"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SetParams) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SetParams) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/Withdraw.go b/programs/pumpfun/Withdraw.go new file mode 100644 index 000000000..76a3aef58 --- /dev/null +++ b/programs/pumpfun/Withdraw.go @@ -0,0 +1,307 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Allows the admin to withdraw liquidity for a migration once the bonding curve completes +type Withdraw struct { + + // [0] = [] global + // + // [1] = [WRITE] lastWithdraw + // + // [2] = [] mint + // + // [3] = [WRITE] bondingCurve + // + // [4] = [WRITE] associatedBondingCurve + // + // [5] = [WRITE] associatedUser + // + // [6] = [WRITE, SIGNER] user + // + // [7] = [] systemProgram + // + // [8] = [] tokenProgram + // + // [9] = [] rent + // + // [10] = [] eventAuthority + // + // [11] = [] program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. +func NewWithdrawInstructionBuilder() *Withdraw { + nd := &Withdraw{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetGlobalAccount sets the "global" account. +func (inst *Withdraw) SetGlobalAccount(global ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[0] = ag_solanago.Meta(global) + return inst +} + +// GetGlobalAccount gets the "global" account. +func (inst *Withdraw) GetGlobalAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetLastWithdrawAccount sets the "lastWithdraw" account. +func (inst *Withdraw) SetLastWithdrawAccount(lastWithdraw ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[1] = ag_solanago.Meta(lastWithdraw).WRITE() + return inst +} + +// GetLastWithdrawAccount gets the "lastWithdraw" account. +func (inst *Withdraw) GetLastWithdrawAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMintAccount sets the "mint" account. +func (inst *Withdraw) SetMintAccount(mint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[2] = ag_solanago.Meta(mint) + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Withdraw) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetBondingCurveAccount sets the "bondingCurve" account. +func (inst *Withdraw) SetBondingCurveAccount(bondingCurve ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[3] = ag_solanago.Meta(bondingCurve).WRITE() + return inst +} + +// GetBondingCurveAccount gets the "bondingCurve" account. +func (inst *Withdraw) GetBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetAssociatedBondingCurveAccount sets the "associatedBondingCurve" account. +func (inst *Withdraw) SetAssociatedBondingCurveAccount(associatedBondingCurve ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[4] = ag_solanago.Meta(associatedBondingCurve).WRITE() + return inst +} + +// GetAssociatedBondingCurveAccount gets the "associatedBondingCurve" account. +func (inst *Withdraw) GetAssociatedBondingCurveAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetAssociatedUserAccount sets the "associatedUser" account. +func (inst *Withdraw) SetAssociatedUserAccount(associatedUser ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[5] = ag_solanago.Meta(associatedUser).WRITE() + return inst +} + +// GetAssociatedUserAccount gets the "associatedUser" account. +func (inst *Withdraw) GetAssociatedUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetUserAccount sets the "user" account. +func (inst *Withdraw) SetUserAccount(user ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[6] = ag_solanago.Meta(user).WRITE().SIGNER() + return inst +} + +// GetUserAccount gets the "user" account. +func (inst *Withdraw) GetUserAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Withdraw) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[7] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Withdraw) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +func (inst *Withdraw) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +func (inst *Withdraw) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetRentAccount sets the "rent" account. +func (inst *Withdraw) SetRentAccount(rent ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[9] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +func (inst *Withdraw) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetEventAuthorityAccount sets the "eventAuthority" account. +func (inst *Withdraw) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[10] = ag_solanago.Meta(eventAuthority) + return inst +} + +// GetEventAuthorityAccount gets the "eventAuthority" account. +func (inst *Withdraw) GetEventAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetProgramAccount sets the "program" account. +func (inst *Withdraw) SetProgramAccount(program ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[11] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *Withdraw) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst Withdraw) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Global is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.LastWithdraw is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.BondingCurve is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.AssociatedBondingCurve is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.AssociatedUser is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.User is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.EventAuthority is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Program is not set") + } + } + return nil +} + +func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" global", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" lastWithdraw", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" bondingCurve", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("associatedBondingCurve", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" associatedUser", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" eventAuthority", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. +func NewWithdrawInstruction( + // Accounts: + global ag_solanago.PublicKey, + lastWithdraw ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + bondingCurve ag_solanago.PublicKey, + associatedBondingCurve ag_solanago.PublicKey, + associatedUser ag_solanago.PublicKey, + user ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + eventAuthority ag_solanago.PublicKey, + program ag_solanago.PublicKey) *Withdraw { + return NewWithdrawInstructionBuilder(). + SetGlobalAccount(global). + SetLastWithdrawAccount(lastWithdraw). + SetMintAccount(mint). + SetBondingCurveAccount(bondingCurve). + SetAssociatedBondingCurveAccount(associatedBondingCurve). + SetAssociatedUserAccount(associatedUser). + SetUserAccount(user). + SetSystemProgramAccount(systemProgram). + SetTokenProgramAccount(tokenProgram). + SetRentAccount(rent). + SetEventAuthorityAccount(eventAuthority). + SetProgramAccount(program) +} diff --git a/programs/pumpfun/Withdraw_test.go b/programs/pumpfun/Withdraw_test.go new file mode 100644 index 000000000..126b5385c --- /dev/null +++ b/programs/pumpfun/Withdraw_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Withdraw(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Withdraw"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Withdraw) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Withdraw) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/pumpfun/accounts.go b/programs/pumpfun/accounts.go new file mode 100644 index 000000000..7c8f3b108 --- /dev/null +++ b/programs/pumpfun/accounts.go @@ -0,0 +1,267 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type Global struct { + Initialized bool + Authority ag_solanago.PublicKey + FeeRecipient ag_solanago.PublicKey + InitialVirtualTokenReserves uint64 + InitialVirtualSolReserves uint64 + InitialRealTokenReserves uint64 + TokenTotalSupply uint64 + FeeBasisPoints uint64 +} + +var GlobalDiscriminator = [8]byte{167, 232, 232, 177, 200, 108, 114, 127} + +func (obj Global) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(GlobalDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Initialized` param: + err = encoder.Encode(obj.Initialized) + if err != nil { + return err + } + // Serialize `Authority` param: + err = encoder.Encode(obj.Authority) + if err != nil { + return err + } + // Serialize `FeeRecipient` param: + err = encoder.Encode(obj.FeeRecipient) + if err != nil { + return err + } + // Serialize `InitialVirtualTokenReserves` param: + err = encoder.Encode(obj.InitialVirtualTokenReserves) + if err != nil { + return err + } + // Serialize `InitialVirtualSolReserves` param: + err = encoder.Encode(obj.InitialVirtualSolReserves) + if err != nil { + return err + } + // Serialize `InitialRealTokenReserves` param: + err = encoder.Encode(obj.InitialRealTokenReserves) + if err != nil { + return err + } + // Serialize `TokenTotalSupply` param: + err = encoder.Encode(obj.TokenTotalSupply) + if err != nil { + return err + } + // Serialize `FeeBasisPoints` param: + err = encoder.Encode(obj.FeeBasisPoints) + if err != nil { + return err + } + return nil +} + +func (obj *Global) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(GlobalDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[167 232 232 177 200 108 114 127]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Initialized`: + err = decoder.Decode(&obj.Initialized) + if err != nil { + return err + } + // Deserialize `Authority`: + err = decoder.Decode(&obj.Authority) + if err != nil { + return err + } + // Deserialize `FeeRecipient`: + err = decoder.Decode(&obj.FeeRecipient) + if err != nil { + return err + } + // Deserialize `InitialVirtualTokenReserves`: + err = decoder.Decode(&obj.InitialVirtualTokenReserves) + if err != nil { + return err + } + // Deserialize `InitialVirtualSolReserves`: + err = decoder.Decode(&obj.InitialVirtualSolReserves) + if err != nil { + return err + } + // Deserialize `InitialRealTokenReserves`: + err = decoder.Decode(&obj.InitialRealTokenReserves) + if err != nil { + return err + } + // Deserialize `TokenTotalSupply`: + err = decoder.Decode(&obj.TokenTotalSupply) + if err != nil { + return err + } + // Deserialize `FeeBasisPoints`: + err = decoder.Decode(&obj.FeeBasisPoints) + if err != nil { + return err + } + return nil +} + +type BondingCurve struct { + VirtualTokenReserves uint64 + VirtualSolReserves uint64 + RealTokenReserves uint64 + RealSolReserves uint64 + TokenTotalSupply uint64 + Complete bool +} + +var BondingCurveDiscriminator = [8]byte{23, 183, 248, 55, 96, 216, 172, 96} + +func (obj BondingCurve) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(BondingCurveDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `VirtualTokenReserves` param: + err = encoder.Encode(obj.VirtualTokenReserves) + if err != nil { + return err + } + // Serialize `VirtualSolReserves` param: + err = encoder.Encode(obj.VirtualSolReserves) + if err != nil { + return err + } + // Serialize `RealTokenReserves` param: + err = encoder.Encode(obj.RealTokenReserves) + if err != nil { + return err + } + // Serialize `RealSolReserves` param: + err = encoder.Encode(obj.RealSolReserves) + if err != nil { + return err + } + // Serialize `TokenTotalSupply` param: + err = encoder.Encode(obj.TokenTotalSupply) + if err != nil { + return err + } + // Serialize `Complete` param: + err = encoder.Encode(obj.Complete) + if err != nil { + return err + } + return nil +} + +func (obj *BondingCurve) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(BondingCurveDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[23 183 248 55 96 216 172 96]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `VirtualTokenReserves`: + err = decoder.Decode(&obj.VirtualTokenReserves) + if err != nil { + return err + } + // Deserialize `VirtualSolReserves`: + err = decoder.Decode(&obj.VirtualSolReserves) + if err != nil { + return err + } + // Deserialize `RealTokenReserves`: + err = decoder.Decode(&obj.RealTokenReserves) + if err != nil { + return err + } + // Deserialize `RealSolReserves`: + err = decoder.Decode(&obj.RealSolReserves) + if err != nil { + return err + } + // Deserialize `TokenTotalSupply`: + err = decoder.Decode(&obj.TokenTotalSupply) + if err != nil { + return err + } + // Deserialize `Complete`: + err = decoder.Decode(&obj.Complete) + if err != nil { + return err + } + return nil +} + +type LastWithdraw struct { + LastWithdrawTimestamp int64 +} + +var LastWithdrawDiscriminator = [8]byte{203, 18, 220, 103, 120, 145, 187, 2} + +func (obj LastWithdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(LastWithdrawDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `LastWithdrawTimestamp` param: + err = encoder.Encode(obj.LastWithdrawTimestamp) + if err != nil { + return err + } + return nil +} + +func (obj *LastWithdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(LastWithdrawDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[203 18 220 103 120 145 187 2]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `LastWithdrawTimestamp`: + err = decoder.Decode(&obj.LastWithdrawTimestamp) + if err != nil { + return err + } + return nil +} diff --git a/programs/pumpfun/instructions.go b/programs/pumpfun/instructions.go new file mode 100644 index 000000000..192ab434d --- /dev/null +++ b/programs/pumpfun/instructions.go @@ -0,0 +1,158 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "Pumpfun" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + // Creates the global state. + Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) + + // Sets the global state parameters. + Instruction_SetParams = ag_binary.TypeID([8]byte{27, 234, 178, 52, 147, 2, 187, 141}) + + // Creates a new coin and bonding curve. + Instruction_Create = ag_binary.TypeID([8]byte{24, 30, 200, 40, 5, 28, 7, 119}) + + // Buys tokens from a bonding curve. + Instruction_Buy = ag_binary.TypeID([8]byte{102, 6, 61, 18, 1, 218, 235, 234}) + + // Sells tokens into a bonding curve. + Instruction_Sell = ag_binary.TypeID([8]byte{51, 230, 133, 164, 1, 127, 131, 173}) + + // Allows the admin to withdraw liquidity for a migration once the bonding curve completes + Instruction_Withdraw = ag_binary.TypeID([8]byte{183, 18, 70, 156, 148, 109, 161, 34}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_Initialize: + return "Initialize" + case Instruction_SetParams: + return "SetParams" + case Instruction_Create: + return "Create" + case Instruction_Buy: + return "Buy" + case Instruction_Sell: + return "Sell" + case Instruction_Withdraw: + return "Withdraw" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "initialize", (*Initialize)(nil), + }, + { + "set_params", (*SetParams)(nil), + }, + { + "create", (*Create)(nil), + }, + { + "buy", (*Buy)(nil), + }, + { + "sell", (*Sell)(nil), + }, + { + "withdraw", (*Withdraw)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/meteoradlmm/testing_utils.go b/programs/pumpfun/testing_utils.go similarity index 96% rename from programs/meteoradlmm/testing_utils.go rename to programs/pumpfun/testing_utils.go index 90687a190..09bcb037c 100644 --- a/programs/meteoradlmm/testing_utils.go +++ b/programs/pumpfun/testing_utils.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package pumpfun import ( "bytes" diff --git a/programs/pumpfun/types.go b/programs/pumpfun/types.go new file mode 100644 index 000000000..50d11977b --- /dev/null +++ b/programs/pumpfun/types.go @@ -0,0 +1,3 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package pumpfun diff --git a/programs/raydiumamm/AdminCancelOrders.go b/programs/raydium_amm/AdminCancelOrders.go similarity index 100% rename from programs/raydiumamm/AdminCancelOrders.go rename to programs/raydium_amm/AdminCancelOrders.go diff --git a/programs/raydiumamm/AdminCancelOrders_test.go b/programs/raydium_amm/AdminCancelOrders_test.go similarity index 100% rename from programs/raydiumamm/AdminCancelOrders_test.go rename to programs/raydium_amm/AdminCancelOrders_test.go diff --git a/programs/raydiumamm/CreateConfigAccount.go b/programs/raydium_amm/CreateConfigAccount.go similarity index 100% rename from programs/raydiumamm/CreateConfigAccount.go rename to programs/raydium_amm/CreateConfigAccount.go diff --git a/programs/raydiumamm/CreateConfigAccount_test.go b/programs/raydium_amm/CreateConfigAccount_test.go similarity index 100% rename from programs/raydiumamm/CreateConfigAccount_test.go rename to programs/raydium_amm/CreateConfigAccount_test.go diff --git a/programs/raydiumamm/Deposit.go b/programs/raydium_amm/Deposit.go similarity index 100% rename from programs/raydiumamm/Deposit.go rename to programs/raydium_amm/Deposit.go diff --git a/programs/raydiumamm/Deposit_test.go b/programs/raydium_amm/Deposit_test.go similarity index 100% rename from programs/raydiumamm/Deposit_test.go rename to programs/raydium_amm/Deposit_test.go diff --git a/programs/raydiumamm/Initialize.go b/programs/raydium_amm/Initialize.go similarity index 100% rename from programs/raydiumamm/Initialize.go rename to programs/raydium_amm/Initialize.go diff --git a/programs/raydiumamm/Initialize2.go b/programs/raydium_amm/Initialize2.go similarity index 100% rename from programs/raydiumamm/Initialize2.go rename to programs/raydium_amm/Initialize2.go diff --git a/programs/raydiumamm/Initialize2_test.go b/programs/raydium_amm/Initialize2_test.go similarity index 100% rename from programs/raydiumamm/Initialize2_test.go rename to programs/raydium_amm/Initialize2_test.go diff --git a/programs/raydiumamm/Initialize_test.go b/programs/raydium_amm/Initialize_test.go similarity index 100% rename from programs/raydiumamm/Initialize_test.go rename to programs/raydium_amm/Initialize_test.go diff --git a/programs/raydiumamm/MigrateToOpenBook.go b/programs/raydium_amm/MigrateToOpenBook.go similarity index 100% rename from programs/raydiumamm/MigrateToOpenBook.go rename to programs/raydium_amm/MigrateToOpenBook.go diff --git a/programs/raydiumamm/MigrateToOpenBook_test.go b/programs/raydium_amm/MigrateToOpenBook_test.go similarity index 100% rename from programs/raydiumamm/MigrateToOpenBook_test.go rename to programs/raydium_amm/MigrateToOpenBook_test.go diff --git a/programs/raydiumamm/MonitorStep.go b/programs/raydium_amm/MonitorStep.go similarity index 100% rename from programs/raydiumamm/MonitorStep.go rename to programs/raydium_amm/MonitorStep.go diff --git a/programs/raydiumamm/MonitorStep_test.go b/programs/raydium_amm/MonitorStep_test.go similarity index 100% rename from programs/raydiumamm/MonitorStep_test.go rename to programs/raydium_amm/MonitorStep_test.go diff --git a/programs/raydiumamm/PreInitialize.go b/programs/raydium_amm/PreInitialize.go similarity index 100% rename from programs/raydiumamm/PreInitialize.go rename to programs/raydium_amm/PreInitialize.go diff --git a/programs/raydiumamm/PreInitialize_test.go b/programs/raydium_amm/PreInitialize_test.go similarity index 100% rename from programs/raydiumamm/PreInitialize_test.go rename to programs/raydium_amm/PreInitialize_test.go diff --git a/programs/raydiumamm/SetParams.go b/programs/raydium_amm/SetParams.go similarity index 100% rename from programs/raydiumamm/SetParams.go rename to programs/raydium_amm/SetParams.go diff --git a/programs/raydiumamm/SetParams_test.go b/programs/raydium_amm/SetParams_test.go similarity index 100% rename from programs/raydiumamm/SetParams_test.go rename to programs/raydium_amm/SetParams_test.go diff --git a/programs/raydiumamm/SimulateInfo.go b/programs/raydium_amm/SimulateInfo.go similarity index 100% rename from programs/raydiumamm/SimulateInfo.go rename to programs/raydium_amm/SimulateInfo.go diff --git a/programs/raydiumamm/SimulateInfo_test.go b/programs/raydium_amm/SimulateInfo_test.go similarity index 100% rename from programs/raydiumamm/SimulateInfo_test.go rename to programs/raydium_amm/SimulateInfo_test.go diff --git a/programs/raydiumamm/SwapBaseIn.go b/programs/raydium_amm/SwapBaseIn.go similarity index 82% rename from programs/raydiumamm/SwapBaseIn.go rename to programs/raydium_amm/SwapBaseIn.go index 1548baee8..f940c2263 100644 --- a/programs/raydiumamm/SwapBaseIn.go +++ b/programs/raydium_amm/SwapBaseIn.go @@ -45,9 +45,9 @@ type SwapBaseIn struct { // // [14] = [] serumVaultSigner // - // [15] = [WRITE] uerSourceTokenAccount + // [15] = [WRITE] userSourceTokenAccount // - // [16] = [WRITE] uerDestinationTokenAccount + // [16] = [WRITE] userDestinationTokenAccount // // [17] = [SIGNER] userSourceOwner ag_solanago.AccountMetaSlice `bin:"-"` @@ -238,25 +238,25 @@ func (inst *SwapBaseIn) GetSerumVaultSignerAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(14) } -// SetUerSourceTokenAccountAccount sets the "uerSourceTokenAccount" account. -func (inst *SwapBaseIn) SetUerSourceTokenAccountAccount(uerSourceTokenAccount ag_solanago.PublicKey) *SwapBaseIn { - inst.AccountMetaSlice[15] = ag_solanago.Meta(uerSourceTokenAccount).WRITE() +// SetUserSourceTokenAccountAccount sets the "userSourceTokenAccount" account. +func (inst *SwapBaseIn) SetUserSourceTokenAccountAccount(userSourceTokenAccount ag_solanago.PublicKey) *SwapBaseIn { + inst.AccountMetaSlice[15] = ag_solanago.Meta(userSourceTokenAccount).WRITE() return inst } -// GetUerSourceTokenAccountAccount gets the "uerSourceTokenAccount" account. -func (inst *SwapBaseIn) GetUerSourceTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserSourceTokenAccountAccount gets the "userSourceTokenAccount" account. +func (inst *SwapBaseIn) GetUserSourceTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(15) } -// SetUerDestinationTokenAccountAccount sets the "uerDestinationTokenAccount" account. -func (inst *SwapBaseIn) SetUerDestinationTokenAccountAccount(uerDestinationTokenAccount ag_solanago.PublicKey) *SwapBaseIn { - inst.AccountMetaSlice[16] = ag_solanago.Meta(uerDestinationTokenAccount).WRITE() +// SetUserDestinationTokenAccountAccount sets the "userDestinationTokenAccount" account. +func (inst *SwapBaseIn) SetUserDestinationTokenAccountAccount(userDestinationTokenAccount ag_solanago.PublicKey) *SwapBaseIn { + inst.AccountMetaSlice[16] = ag_solanago.Meta(userDestinationTokenAccount).WRITE() return inst } -// GetUerDestinationTokenAccountAccount gets the "uerDestinationTokenAccount" account. -func (inst *SwapBaseIn) GetUerDestinationTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserDestinationTokenAccountAccount gets the "userDestinationTokenAccount" account. +func (inst *SwapBaseIn) GetUserDestinationTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(16) } @@ -347,10 +347,10 @@ func (inst *SwapBaseIn) Validate() error { return errors.New("accounts.SerumVaultSigner is not set") } if inst.AccountMetaSlice[15] == nil { - return errors.New("accounts.UerSourceTokenAccount is not set") + return errors.New("accounts.UserSourceTokenAccount is not set") } if inst.AccountMetaSlice[16] == nil { - return errors.New("accounts.UerDestinationTokenAccount is not set") + return errors.New("accounts.UserDestinationTokenAccount is not set") } if inst.AccountMetaSlice[17] == nil { return errors.New("accounts.UserSourceOwner is not set") @@ -375,24 +375,24 @@ func (inst *SwapBaseIn) EncodeToTree(parent ag_treeout.Branches) { // Accounts of the instruction: instructionBranch.Child("Accounts[len=18]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" ammAuthority", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" ammOpenOrders", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" ammTargetOrders", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" poolCoinToken", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" poolPcToken", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta(" serumProgram", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta(" serumMarket", inst.AccountMetaSlice.Get(8))) - accountsBranch.Child(ag_format.Meta(" serumBids", inst.AccountMetaSlice.Get(9))) - accountsBranch.Child(ag_format.Meta(" serumAsks", inst.AccountMetaSlice.Get(10))) - accountsBranch.Child(ag_format.Meta(" serumEventQueue", inst.AccountMetaSlice.Get(11))) - accountsBranch.Child(ag_format.Meta(" serumCoinVault", inst.AccountMetaSlice.Get(12))) - accountsBranch.Child(ag_format.Meta(" serumPcVault", inst.AccountMetaSlice.Get(13))) - accountsBranch.Child(ag_format.Meta(" serumVaultSigner", inst.AccountMetaSlice.Get(14))) - accountsBranch.Child(ag_format.Meta(" uerSourceToken", inst.AccountMetaSlice.Get(15))) - accountsBranch.Child(ag_format.Meta("uerDestinationToken", inst.AccountMetaSlice.Get(16))) - accountsBranch.Child(ag_format.Meta(" userSourceOwner", inst.AccountMetaSlice.Get(17))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" ammAuthority", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ammOpenOrders", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" ammTargetOrders", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" poolCoinToken", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" poolPcToken", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" serumProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" serumMarket", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" serumBids", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" serumAsks", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" serumEventQueue", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" serumCoinVault", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" serumPcVault", inst.AccountMetaSlice.Get(13))) + accountsBranch.Child(ag_format.Meta(" serumVaultSigner", inst.AccountMetaSlice.Get(14))) + accountsBranch.Child(ag_format.Meta(" userSourceToken", inst.AccountMetaSlice.Get(15))) + accountsBranch.Child(ag_format.Meta("userDestinationToken", inst.AccountMetaSlice.Get(16))) + accountsBranch.Child(ag_format.Meta(" userSourceOwner", inst.AccountMetaSlice.Get(17))) }) }) }) @@ -446,8 +446,8 @@ func NewSwapBaseInInstruction( serumCoinVaultAccount ag_solanago.PublicKey, serumPcVaultAccount ag_solanago.PublicKey, serumVaultSigner ag_solanago.PublicKey, - uerSourceTokenAccount ag_solanago.PublicKey, - uerDestinationTokenAccount ag_solanago.PublicKey, + userSourceTokenAccount ag_solanago.PublicKey, + userDestinationTokenAccount ag_solanago.PublicKey, userSourceOwner ag_solanago.PublicKey) *SwapBaseIn { return NewSwapBaseInInstructionBuilder(). SetAmountIn(amountIn). @@ -467,7 +467,7 @@ func NewSwapBaseInInstruction( SetSerumCoinVaultAccountAccount(serumCoinVaultAccount). SetSerumPcVaultAccountAccount(serumPcVaultAccount). SetSerumVaultSignerAccount(serumVaultSigner). - SetUerSourceTokenAccountAccount(uerSourceTokenAccount). - SetUerDestinationTokenAccountAccount(uerDestinationTokenAccount). + SetUserSourceTokenAccountAccount(userSourceTokenAccount). + SetUserDestinationTokenAccountAccount(userDestinationTokenAccount). SetUserSourceOwnerAccount(userSourceOwner) } diff --git a/programs/raydiumamm/SwapBaseIn_test.go b/programs/raydium_amm/SwapBaseIn_test.go similarity index 100% rename from programs/raydiumamm/SwapBaseIn_test.go rename to programs/raydium_amm/SwapBaseIn_test.go diff --git a/programs/raydiumamm/SwapBaseOut.go b/programs/raydium_amm/SwapBaseOut.go similarity index 81% rename from programs/raydiumamm/SwapBaseOut.go rename to programs/raydium_amm/SwapBaseOut.go index 4f0d83290..18bd6d8f1 100644 --- a/programs/raydiumamm/SwapBaseOut.go +++ b/programs/raydium_amm/SwapBaseOut.go @@ -45,9 +45,9 @@ type SwapBaseOut struct { // // [14] = [] serumVaultSigner // - // [15] = [WRITE] uerSourceTokenAccount + // [15] = [WRITE] userSourceTokenAccount // - // [16] = [WRITE] uerDestinationTokenAccount + // [16] = [WRITE] userDestinationTokenAccount // // [17] = [SIGNER] userSourceOwner ag_solanago.AccountMetaSlice `bin:"-"` @@ -238,25 +238,25 @@ func (inst *SwapBaseOut) GetSerumVaultSignerAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(14) } -// SetUerSourceTokenAccountAccount sets the "uerSourceTokenAccount" account. -func (inst *SwapBaseOut) SetUerSourceTokenAccountAccount(uerSourceTokenAccount ag_solanago.PublicKey) *SwapBaseOut { - inst.AccountMetaSlice[15] = ag_solanago.Meta(uerSourceTokenAccount).WRITE() +// SetUserSourceTokenAccountAccount sets the "userSourceTokenAccount" account. +func (inst *SwapBaseOut) SetUserSourceTokenAccountAccount(userSourceTokenAccount ag_solanago.PublicKey) *SwapBaseOut { + inst.AccountMetaSlice[15] = ag_solanago.Meta(userSourceTokenAccount).WRITE() return inst } -// GetUerSourceTokenAccountAccount gets the "uerSourceTokenAccount" account. -func (inst *SwapBaseOut) GetUerSourceTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserSourceTokenAccountAccount gets the "userSourceTokenAccount" account. +func (inst *SwapBaseOut) GetUserSourceTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(15) } -// SetUerDestinationTokenAccountAccount sets the "uerDestinationTokenAccount" account. -func (inst *SwapBaseOut) SetUerDestinationTokenAccountAccount(uerDestinationTokenAccount ag_solanago.PublicKey) *SwapBaseOut { - inst.AccountMetaSlice[16] = ag_solanago.Meta(uerDestinationTokenAccount).WRITE() +// SetUserDestinationTokenAccountAccount sets the "userDestinationTokenAccount" account. +func (inst *SwapBaseOut) SetUserDestinationTokenAccountAccount(userDestinationTokenAccount ag_solanago.PublicKey) *SwapBaseOut { + inst.AccountMetaSlice[16] = ag_solanago.Meta(userDestinationTokenAccount).WRITE() return inst } -// GetUerDestinationTokenAccountAccount gets the "uerDestinationTokenAccount" account. -func (inst *SwapBaseOut) GetUerDestinationTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserDestinationTokenAccountAccount gets the "userDestinationTokenAccount" account. +func (inst *SwapBaseOut) GetUserDestinationTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(16) } @@ -347,10 +347,10 @@ func (inst *SwapBaseOut) Validate() error { return errors.New("accounts.SerumVaultSigner is not set") } if inst.AccountMetaSlice[15] == nil { - return errors.New("accounts.UerSourceTokenAccount is not set") + return errors.New("accounts.UserSourceTokenAccount is not set") } if inst.AccountMetaSlice[16] == nil { - return errors.New("accounts.UerDestinationTokenAccount is not set") + return errors.New("accounts.UserDestinationTokenAccount is not set") } if inst.AccountMetaSlice[17] == nil { return errors.New("accounts.UserSourceOwner is not set") @@ -375,24 +375,24 @@ func (inst *SwapBaseOut) EncodeToTree(parent ag_treeout.Branches) { // Accounts of the instruction: instructionBranch.Child("Accounts[len=18]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" ammAuthority", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" ammOpenOrders", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" ammTargetOrders", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" poolCoinToken", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" poolPcToken", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta(" serumProgram", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta(" serumMarket", inst.AccountMetaSlice.Get(8))) - accountsBranch.Child(ag_format.Meta(" serumBids", inst.AccountMetaSlice.Get(9))) - accountsBranch.Child(ag_format.Meta(" serumAsks", inst.AccountMetaSlice.Get(10))) - accountsBranch.Child(ag_format.Meta(" serumEventQueue", inst.AccountMetaSlice.Get(11))) - accountsBranch.Child(ag_format.Meta(" serumCoinVault", inst.AccountMetaSlice.Get(12))) - accountsBranch.Child(ag_format.Meta(" serumPcVault", inst.AccountMetaSlice.Get(13))) - accountsBranch.Child(ag_format.Meta(" serumVaultSigner", inst.AccountMetaSlice.Get(14))) - accountsBranch.Child(ag_format.Meta(" uerSourceToken", inst.AccountMetaSlice.Get(15))) - accountsBranch.Child(ag_format.Meta("uerDestinationToken", inst.AccountMetaSlice.Get(16))) - accountsBranch.Child(ag_format.Meta(" userSourceOwner", inst.AccountMetaSlice.Get(17))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" amm", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" ammAuthority", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ammOpenOrders", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" ammTargetOrders", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" poolCoinToken", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" poolPcToken", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" serumProgram", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" serumMarket", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" serumBids", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" serumAsks", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" serumEventQueue", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" serumCoinVault", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" serumPcVault", inst.AccountMetaSlice.Get(13))) + accountsBranch.Child(ag_format.Meta(" serumVaultSigner", inst.AccountMetaSlice.Get(14))) + accountsBranch.Child(ag_format.Meta(" userSourceToken", inst.AccountMetaSlice.Get(15))) + accountsBranch.Child(ag_format.Meta("userDestinationToken", inst.AccountMetaSlice.Get(16))) + accountsBranch.Child(ag_format.Meta(" userSourceOwner", inst.AccountMetaSlice.Get(17))) }) }) }) @@ -446,8 +446,8 @@ func NewSwapBaseOutInstruction( serumCoinVaultAccount ag_solanago.PublicKey, serumPcVaultAccount ag_solanago.PublicKey, serumVaultSigner ag_solanago.PublicKey, - uerSourceTokenAccount ag_solanago.PublicKey, - uerDestinationTokenAccount ag_solanago.PublicKey, + userSourceTokenAccount ag_solanago.PublicKey, + userDestinationTokenAccount ag_solanago.PublicKey, userSourceOwner ag_solanago.PublicKey) *SwapBaseOut { return NewSwapBaseOutInstructionBuilder(). SetMaxAmountIn(maxAmountIn). @@ -467,7 +467,7 @@ func NewSwapBaseOutInstruction( SetSerumCoinVaultAccountAccount(serumCoinVaultAccount). SetSerumPcVaultAccountAccount(serumPcVaultAccount). SetSerumVaultSignerAccount(serumVaultSigner). - SetUerSourceTokenAccountAccount(uerSourceTokenAccount). - SetUerDestinationTokenAccountAccount(uerDestinationTokenAccount). + SetUserSourceTokenAccountAccount(userSourceTokenAccount). + SetUserDestinationTokenAccountAccount(userDestinationTokenAccount). SetUserSourceOwnerAccount(userSourceOwner) } diff --git a/programs/raydiumamm/SwapBaseOut_test.go b/programs/raydium_amm/SwapBaseOut_test.go similarity index 100% rename from programs/raydiumamm/SwapBaseOut_test.go rename to programs/raydium_amm/SwapBaseOut_test.go diff --git a/programs/raydiumamm/UpdateConfigAccount.go b/programs/raydium_amm/UpdateConfigAccount.go similarity index 100% rename from programs/raydiumamm/UpdateConfigAccount.go rename to programs/raydium_amm/UpdateConfigAccount.go diff --git a/programs/raydiumamm/UpdateConfigAccount_test.go b/programs/raydium_amm/UpdateConfigAccount_test.go similarity index 100% rename from programs/raydiumamm/UpdateConfigAccount_test.go rename to programs/raydium_amm/UpdateConfigAccount_test.go diff --git a/programs/raydiumamm/Withdraw.go b/programs/raydium_amm/Withdraw.go similarity index 93% rename from programs/raydiumamm/Withdraw.go rename to programs/raydium_amm/Withdraw.go index 6213d72a5..98d0fe223 100644 --- a/programs/raydiumamm/Withdraw.go +++ b/programs/raydium_amm/Withdraw.go @@ -46,9 +46,9 @@ type Withdraw struct { // // [15] = [WRITE] userLpTokenAccount // - // [16] = [WRITE] uerCoinTokenAccount + // [16] = [WRITE] userCoinTokenAccount // - // [17] = [WRITE] uerPcTokenAccount + // [17] = [WRITE] userPcTokenAccount // // [18] = [SIGNER] userOwner // @@ -250,25 +250,25 @@ func (inst *Withdraw) GetUserLpTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(15) } -// SetUerCoinTokenAccountAccount sets the "uerCoinTokenAccount" account. -func (inst *Withdraw) SetUerCoinTokenAccountAccount(uerCoinTokenAccount ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[16] = ag_solanago.Meta(uerCoinTokenAccount).WRITE() +// SetUserCoinTokenAccountAccount sets the "userCoinTokenAccount" account. +func (inst *Withdraw) SetUserCoinTokenAccountAccount(userCoinTokenAccount ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[16] = ag_solanago.Meta(userCoinTokenAccount).WRITE() return inst } -// GetUerCoinTokenAccountAccount gets the "uerCoinTokenAccount" account. -func (inst *Withdraw) GetUerCoinTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserCoinTokenAccountAccount gets the "userCoinTokenAccount" account. +func (inst *Withdraw) GetUserCoinTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(16) } -// SetUerPcTokenAccountAccount sets the "uerPcTokenAccount" account. -func (inst *Withdraw) SetUerPcTokenAccountAccount(uerPcTokenAccount ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[17] = ag_solanago.Meta(uerPcTokenAccount).WRITE() +// SetUserPcTokenAccountAccount sets the "userPcTokenAccount" account. +func (inst *Withdraw) SetUserPcTokenAccountAccount(userPcTokenAccount ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[17] = ag_solanago.Meta(userPcTokenAccount).WRITE() return inst } -// GetUerPcTokenAccountAccount gets the "uerPcTokenAccount" account. -func (inst *Withdraw) GetUerPcTokenAccountAccount() *ag_solanago.AccountMeta { +// GetUserPcTokenAccountAccount gets the "userPcTokenAccount" account. +func (inst *Withdraw) GetUserPcTokenAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(17) } @@ -392,10 +392,10 @@ func (inst *Withdraw) Validate() error { return errors.New("accounts.UserLpTokenAccount is not set") } if inst.AccountMetaSlice[16] == nil { - return errors.New("accounts.UerCoinTokenAccount is not set") + return errors.New("accounts.UserCoinTokenAccount is not set") } if inst.AccountMetaSlice[17] == nil { - return errors.New("accounts.UerPcTokenAccount is not set") + return errors.New("accounts.UserPcTokenAccount is not set") } if inst.AccountMetaSlice[18] == nil { return errors.New("accounts.UserOwner is not set") @@ -444,8 +444,8 @@ func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { accountsBranch.Child(ag_format.Meta(" serumPcVault", inst.AccountMetaSlice.Get(13))) accountsBranch.Child(ag_format.Meta(" serumVaultSigner", inst.AccountMetaSlice.Get(14))) accountsBranch.Child(ag_format.Meta(" userLpToken", inst.AccountMetaSlice.Get(15))) - accountsBranch.Child(ag_format.Meta(" uerCoinToken", inst.AccountMetaSlice.Get(16))) - accountsBranch.Child(ag_format.Meta(" uerPcToken", inst.AccountMetaSlice.Get(17))) + accountsBranch.Child(ag_format.Meta(" userCoinToken", inst.AccountMetaSlice.Get(16))) + accountsBranch.Child(ag_format.Meta(" userPcToken", inst.AccountMetaSlice.Get(17))) accountsBranch.Child(ag_format.Meta(" userOwner", inst.AccountMetaSlice.Get(18))) accountsBranch.Child(ag_format.Meta(" serumEventQ", inst.AccountMetaSlice.Get(19))) accountsBranch.Child(ag_format.Meta(" serumBids", inst.AccountMetaSlice.Get(20))) @@ -493,8 +493,8 @@ func NewWithdrawInstruction( serumPcVaultAccount ag_solanago.PublicKey, serumVaultSigner ag_solanago.PublicKey, userLpTokenAccount ag_solanago.PublicKey, - uerCoinTokenAccount ag_solanago.PublicKey, - uerPcTokenAccount ag_solanago.PublicKey, + userCoinTokenAccount ag_solanago.PublicKey, + userPcTokenAccount ag_solanago.PublicKey, userOwner ag_solanago.PublicKey, serumEventQ ag_solanago.PublicKey, serumBids ag_solanago.PublicKey, @@ -517,8 +517,8 @@ func NewWithdrawInstruction( SetSerumPcVaultAccountAccount(serumPcVaultAccount). SetSerumVaultSignerAccount(serumVaultSigner). SetUserLpTokenAccountAccount(userLpTokenAccount). - SetUerCoinTokenAccountAccount(uerCoinTokenAccount). - SetUerPcTokenAccountAccount(uerPcTokenAccount). + SetUserCoinTokenAccountAccount(userCoinTokenAccount). + SetUserPcTokenAccountAccount(userPcTokenAccount). SetUserOwnerAccount(userOwner). SetSerumEventQAccount(serumEventQ). SetSerumBidsAccount(serumBids). diff --git a/programs/raydiumamm/WithdrawPnl.go b/programs/raydium_amm/WithdrawPnl.go similarity index 100% rename from programs/raydiumamm/WithdrawPnl.go rename to programs/raydium_amm/WithdrawPnl.go diff --git a/programs/raydiumamm/WithdrawPnl_test.go b/programs/raydium_amm/WithdrawPnl_test.go similarity index 100% rename from programs/raydiumamm/WithdrawPnl_test.go rename to programs/raydium_amm/WithdrawPnl_test.go diff --git a/programs/raydiumamm/WithdrawSrm.go b/programs/raydium_amm/WithdrawSrm.go similarity index 100% rename from programs/raydiumamm/WithdrawSrm.go rename to programs/raydium_amm/WithdrawSrm.go diff --git a/programs/raydiumamm/WithdrawSrm_test.go b/programs/raydium_amm/WithdrawSrm_test.go similarity index 100% rename from programs/raydiumamm/WithdrawSrm_test.go rename to programs/raydium_amm/WithdrawSrm_test.go diff --git a/programs/raydiumamm/Withdraw_test.go b/programs/raydium_amm/Withdraw_test.go similarity index 100% rename from programs/raydiumamm/Withdraw_test.go rename to programs/raydium_amm/Withdraw_test.go diff --git a/programs/raydiumamm/accounts.go b/programs/raydium_amm/accounts.go similarity index 98% rename from programs/raydiumamm/accounts.go rename to programs/raydium_amm/accounts.go index 720c388a8..9d2a217a8 100644 --- a/programs/raydiumamm/accounts.go +++ b/programs/raydium_amm/accounts.go @@ -408,10 +408,10 @@ type AmmInfo struct { PcLotSize uint64 MinPriceMultiplier uint64 MaxPriceMultiplier uint64 - SysDecimalValue uint64 - Fees Fees - OutPut OutPutData - TokenCoin ag_solanago.PublicKey + SysDecimalValue uint64 + Fees Fees + OutPut OutPutData + TokenCoin ag_solanago.PublicKey TokenPc ag_solanago.PublicKey CoinMint ag_solanago.PublicKey PcMint ag_solanago.PublicKey @@ -549,7 +549,7 @@ func (obj AmmInfo) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { if err != nil { return err } - // Serialize `Pool` param: + // Serialize `Market` param: err = encoder.Encode(obj.Market) if err != nil { return err @@ -718,7 +718,7 @@ func (obj *AmmInfo) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) if err != nil { return err } - // Deserialize `Pool`: + // Deserialize `Market`: err = decoder.Decode(&obj.Market) if err != nil { return err diff --git a/programs/raydiumamm/instructions.go b/programs/raydium_amm/instructions.go similarity index 97% rename from programs/raydiumamm/instructions.go rename to programs/raydium_amm/instructions.go index 1a3fa0074..d4bde4490 100644 --- a/programs/raydiumamm/instructions.go +++ b/programs/raydium_amm/instructions.go @@ -12,7 +12,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8") func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey diff --git a/programs/raydiumamm/testing_utils.go b/programs/raydium_amm/testing_utils.go similarity index 100% rename from programs/raydiumamm/testing_utils.go rename to programs/raydium_amm/testing_utils.go diff --git a/programs/raydiumamm/types.go b/programs/raydium_amm/types.go similarity index 100% rename from programs/raydiumamm/types.go rename to programs/raydium_amm/types.go diff --git a/programs/raydiumclmm/ClosePosition.go b/programs/raydium_clmm/ClosePosition.go similarity index 87% rename from programs/raydiumclmm/ClosePosition.go rename to programs/raydium_clmm/ClosePosition.go index 13c18f5b1..743b5241b 100644 --- a/programs/raydiumclmm/ClosePosition.go +++ b/programs/raydium_clmm/ClosePosition.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,7 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -// Close a position, the nft mint and nft account +// Close the user's position and NFT account. If the NFT mint belongs to token2022, it will also be closed and the funds returned to the NFT owner. // // # Arguments // @@ -22,20 +22,18 @@ type ClosePosition struct { // ··········· The position nft owner // // [1] = [WRITE] positionNftMint - // ··········· Unique token mint address + // ··········· Mint address bound to the personal position. // // [2] = [WRITE] positionNftAccount - // ··········· Token account where position NFT will be minted + // ··········· User token account where position NFT be minted to // // [3] = [WRITE] personalPosition - // ··········· To store metaplex metadata - // ··········· Metadata for the tokenized position // // [4] = [] systemProgram - // ··········· Program to create the position manager state account + // ··········· System program to close the position state account // // [5] = [] tokenProgram - // ··········· Program to create mint account and mint tokens + // ··········· Token/Token2022 program to close token/mint account ag_solanago.AccountMetaSlice `bin:"-"` } @@ -61,68 +59,64 @@ func (inst *ClosePosition) GetNftOwnerAccount() *ag_solanago.AccountMeta { } // SetPositionNftMintAccount sets the "positionNftMint" account. -// Unique token mint address +// Mint address bound to the personal position. func (inst *ClosePosition) SetPositionNftMintAccount(positionNftMint ag_solanago.PublicKey) *ClosePosition { inst.AccountMetaSlice[1] = ag_solanago.Meta(positionNftMint).WRITE() return inst } // GetPositionNftMintAccount gets the "positionNftMint" account. -// Unique token mint address +// Mint address bound to the personal position. func (inst *ClosePosition) GetPositionNftMintAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(1) } // SetPositionNftAccountAccount sets the "positionNftAccount" account. -// Token account where position NFT will be minted +// User token account where position NFT be minted to func (inst *ClosePosition) SetPositionNftAccountAccount(positionNftAccount ag_solanago.PublicKey) *ClosePosition { inst.AccountMetaSlice[2] = ag_solanago.Meta(positionNftAccount).WRITE() return inst } // GetPositionNftAccountAccount gets the "positionNftAccount" account. -// Token account where position NFT will be minted +// User token account where position NFT be minted to func (inst *ClosePosition) GetPositionNftAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(2) } // SetPersonalPositionAccount sets the "personalPosition" account. -// To store metaplex metadata -// Metadata for the tokenized position func (inst *ClosePosition) SetPersonalPositionAccount(personalPosition ag_solanago.PublicKey) *ClosePosition { inst.AccountMetaSlice[3] = ag_solanago.Meta(personalPosition).WRITE() return inst } // GetPersonalPositionAccount gets the "personalPosition" account. -// To store metaplex metadata -// Metadata for the tokenized position func (inst *ClosePosition) GetPersonalPositionAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(3) } // SetSystemProgramAccount sets the "systemProgram" account. -// Program to create the position manager state account +// System program to close the position state account func (inst *ClosePosition) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *ClosePosition { inst.AccountMetaSlice[4] = ag_solanago.Meta(systemProgram) return inst } // GetSystemProgramAccount gets the "systemProgram" account. -// Program to create the position manager state account +// System program to close the position state account func (inst *ClosePosition) GetSystemProgramAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(4) } // SetTokenProgramAccount sets the "tokenProgram" account. -// Program to create mint account and mint tokens +// Token/Token2022 program to close token/mint account func (inst *ClosePosition) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *ClosePosition { inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenProgram) return inst } // GetTokenProgramAccount gets the "tokenProgram" account. -// Program to create mint account and mint tokens +// Token/Token2022 program to close token/mint account func (inst *ClosePosition) GetTokenProgramAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(5) } diff --git a/programs/meteoradlmm/ClosePosition_test.go b/programs/raydium_clmm/ClosePosition_test.go similarity index 97% rename from programs/meteoradlmm/ClosePosition_test.go rename to programs/raydium_clmm/ClosePosition_test.go index b4e49ee0e..3803a7111 100644 --- a/programs/meteoradlmm/ClosePosition_test.go +++ b/programs/raydium_clmm/ClosePosition_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package lb_clmm +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/CollectFundFee.go b/programs/raydium_clmm/CollectFundFee.go similarity index 99% rename from programs/raydiumclmm/CollectFundFee.go rename to programs/raydium_clmm/CollectFundFee.go index 9c62963ae..038128399 100644 --- a/programs/raydiumclmm/CollectFundFee.go +++ b/programs/raydium_clmm/CollectFundFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydium_clmm/CollectFundFee_test.go b/programs/raydium_clmm/CollectFundFee_test.go new file mode 100644 index 000000000..988a640eb --- /dev/null +++ b/programs/raydium_clmm/CollectFundFee_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CollectFundFee(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CollectFundFee"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CollectFundFee) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CollectFundFee) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/CollectProtocolFee.go b/programs/raydium_clmm/CollectProtocolFee.go similarity index 99% rename from programs/raydiumclmm/CollectProtocolFee.go rename to programs/raydium_clmm/CollectProtocolFee.go index 2a6e29ef4..f58e9f2b8 100644 --- a/programs/raydiumclmm/CollectProtocolFee.go +++ b/programs/raydium_clmm/CollectProtocolFee.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydium_clmm/CollectProtocolFee_test.go b/programs/raydium_clmm/CollectProtocolFee_test.go new file mode 100644 index 000000000..4a326dbd7 --- /dev/null +++ b/programs/raydium_clmm/CollectProtocolFee_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CollectProtocolFee(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CollectProtocolFee"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CollectProtocolFee) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CollectProtocolFee) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/CollectRemainingRewards.go b/programs/raydium_clmm/CollectRemainingRewards.go similarity index 99% rename from programs/raydiumclmm/CollectRemainingRewards.go rename to programs/raydium_clmm/CollectRemainingRewards.go index 5efc81f3d..9308521ed 100644 --- a/programs/raydiumclmm/CollectRemainingRewards.go +++ b/programs/raydium_clmm/CollectRemainingRewards.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/CollectRemainingRewards_test.go b/programs/raydium_clmm/CollectRemainingRewards_test.go similarity index 97% rename from programs/raydiumclmm/CollectRemainingRewards_test.go rename to programs/raydium_clmm/CollectRemainingRewards_test.go index 090e70979..ee151167f 100644 --- a/programs/raydiumclmm/CollectRemainingRewards_test.go +++ b/programs/raydium_clmm/CollectRemainingRewards_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/CreateAmmConfig.go b/programs/raydium_clmm/CreateAmmConfig.go similarity index 99% rename from programs/raydiumclmm/CreateAmmConfig.go rename to programs/raydium_clmm/CreateAmmConfig.go index cd174be9b..c0ff4ba87 100644 --- a/programs/raydiumclmm/CreateAmmConfig.go +++ b/programs/raydium_clmm/CreateAmmConfig.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydium_clmm/CreateAmmConfig_test.go b/programs/raydium_clmm/CreateAmmConfig_test.go new file mode 100644 index 000000000..61ce51afc --- /dev/null +++ b/programs/raydium_clmm/CreateAmmConfig_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CreateAmmConfig(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CreateAmmConfig"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CreateAmmConfig) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CreateAmmConfig) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/CreateOperationAccount.go b/programs/raydium_clmm/CreateOperationAccount.go similarity index 99% rename from programs/raydiumclmm/CreateOperationAccount.go rename to programs/raydium_clmm/CreateOperationAccount.go index 5d4f46fb6..528f92a41 100644 --- a/programs/raydiumclmm/CreateOperationAccount.go +++ b/programs/raydium_clmm/CreateOperationAccount.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/CreateOperationAccount_test.go b/programs/raydium_clmm/CreateOperationAccount_test.go similarity index 97% rename from programs/raydiumclmm/CreateOperationAccount_test.go rename to programs/raydium_clmm/CreateOperationAccount_test.go index 78f642de2..d93897d39 100644 --- a/programs/raydiumclmm/CreateOperationAccount_test.go +++ b/programs/raydium_clmm/CreateOperationAccount_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/CreatePool.go b/programs/raydium_clmm/CreatePool.go similarity index 96% rename from programs/raydiumclmm/CreatePool.go rename to programs/raydium_clmm/CreatePool.go index cee0b8c59..2c271b9ef 100644 --- a/programs/raydiumclmm/CreatePool.go +++ b/programs/raydium_clmm/CreatePool.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -31,7 +31,7 @@ type CreatePool struct { // ··········· Initialize an account to store the pool state // // [3] = [] tokenMint0 - // ··········· Token_0 mint, the key must grater then token_1 mint. + // ··········· Token_0 mint, the key must be smaller then token_1 mint. // // [4] = [] tokenMint1 // ··········· Token_1 mint @@ -42,7 +42,8 @@ type CreatePool struct { // [6] = [WRITE] tokenVault1 // ··········· Token_1 vault for the pool // - // [7] = [] observationState + // [7] = [WRITE] observationState + // ··········· Initialize an account to store oracle observations // // [8] = [WRITE] tickArrayBitmap // ··········· Initialize an account to store if a tick array is initialized. @@ -121,14 +122,14 @@ func (inst *CreatePool) GetPoolStateAccount() *ag_solanago.AccountMeta { } // SetTokenMint0Account sets the "tokenMint0" account. -// Token_0 mint, the key must grater then token_1 mint. +// Token_0 mint, the key must be smaller then token_1 mint. func (inst *CreatePool) SetTokenMint0Account(tokenMint0 ag_solanago.PublicKey) *CreatePool { inst.AccountMetaSlice[3] = ag_solanago.Meta(tokenMint0) return inst } // GetTokenMint0Account gets the "tokenMint0" account. -// Token_0 mint, the key must grater then token_1 mint. +// Token_0 mint, the key must be smaller then token_1 mint. func (inst *CreatePool) GetTokenMint0Account() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(3) } @@ -173,12 +174,14 @@ func (inst *CreatePool) GetTokenVault1Account() *ag_solanago.AccountMeta { } // SetObservationStateAccount sets the "observationState" account. +// Initialize an account to store oracle observations func (inst *CreatePool) SetObservationStateAccount(observationState ag_solanago.PublicKey) *CreatePool { - inst.AccountMetaSlice[7] = ag_solanago.Meta(observationState) + inst.AccountMetaSlice[7] = ag_solanago.Meta(observationState).WRITE() return inst } // GetObservationStateAccount gets the "observationState" account. +// Initialize an account to store oracle observations func (inst *CreatePool) GetObservationStateAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(7) } diff --git a/programs/raydiumclmm/CreatePool_test.go b/programs/raydium_clmm/CreatePool_test.go similarity index 97% rename from programs/raydiumclmm/CreatePool_test.go rename to programs/raydium_clmm/CreatePool_test.go index 4c29e6ef3..d5625f97c 100644 --- a/programs/raydiumclmm/CreatePool_test.go +++ b/programs/raydium_clmm/CreatePool_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/DecreaseLiquidity.go b/programs/raydium_clmm/DecreaseLiquidity.go similarity index 99% rename from programs/raydiumclmm/DecreaseLiquidity.go rename to programs/raydium_clmm/DecreaseLiquidity.go index c789310b3..f37cebd32 100644 --- a/programs/raydiumclmm/DecreaseLiquidity.go +++ b/programs/raydium_clmm/DecreaseLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,6 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) +// #[deprecated(note = "Use `decrease_liquidity_v2` instead.")] // Decreases liquidity with a exist position // // # Arguments diff --git a/programs/raydiumclmm/DecreaseLiquidityV2.go b/programs/raydium_clmm/DecreaseLiquidityV2.go similarity index 99% rename from programs/raydiumclmm/DecreaseLiquidityV2.go rename to programs/raydium_clmm/DecreaseLiquidityV2.go index 814a1d8f9..d46fd387e 100644 --- a/programs/raydiumclmm/DecreaseLiquidityV2.go +++ b/programs/raydium_clmm/DecreaseLiquidityV2.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/DecreaseLiquidityV2_test.go b/programs/raydium_clmm/DecreaseLiquidityV2_test.go similarity index 97% rename from programs/raydiumclmm/DecreaseLiquidityV2_test.go rename to programs/raydium_clmm/DecreaseLiquidityV2_test.go index 8588c44b3..dd9a57721 100644 --- a/programs/raydiumclmm/DecreaseLiquidityV2_test.go +++ b/programs/raydium_clmm/DecreaseLiquidityV2_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/DecreaseLiquidity_test.go b/programs/raydium_clmm/DecreaseLiquidity_test.go similarity index 97% rename from programs/raydiumclmm/DecreaseLiquidity_test.go rename to programs/raydium_clmm/DecreaseLiquidity_test.go index 299b7c0b3..b803721ce 100644 --- a/programs/raydiumclmm/DecreaseLiquidity_test.go +++ b/programs/raydium_clmm/DecreaseLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/IncreaseLiquidity.go b/programs/raydium_clmm/IncreaseLiquidity.go similarity index 99% rename from programs/raydiumclmm/IncreaseLiquidity.go rename to programs/raydium_clmm/IncreaseLiquidity.go index 7408c541a..0869c84a2 100644 --- a/programs/raydiumclmm/IncreaseLiquidity.go +++ b/programs/raydium_clmm/IncreaseLiquidity.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,6 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) +// #[deprecated(note = "Use `increase_liquidity_v2` instead.")] // Increases liquidity with a exist position, with amount paid by `payer` // // # Arguments diff --git a/programs/raydiumclmm/IncreaseLiquidityV2.go b/programs/raydium_clmm/IncreaseLiquidityV2.go similarity index 99% rename from programs/raydiumclmm/IncreaseLiquidityV2.go rename to programs/raydium_clmm/IncreaseLiquidityV2.go index 1ffd0f993..0e6966c39 100644 --- a/programs/raydiumclmm/IncreaseLiquidityV2.go +++ b/programs/raydium_clmm/IncreaseLiquidityV2.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -18,7 +18,7 @@ import ( // * `liquidity` - The desired liquidity to be added, if zero, calculate liquidity base amount_0 or amount_1 according base_flag // * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check // * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check -// * `base_flag` - active if liquidity is zero, 0: calculate liquidity base amount_0_max otherwise base amount_1_max +// * `base_flag` - must be specified if liquidity is zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max // type IncreaseLiquidityV2 struct { Liquidity *ag_binary.Uint128 diff --git a/programs/raydiumclmm/IncreaseLiquidityV2_test.go b/programs/raydium_clmm/IncreaseLiquidityV2_test.go similarity index 97% rename from programs/raydiumclmm/IncreaseLiquidityV2_test.go rename to programs/raydium_clmm/IncreaseLiquidityV2_test.go index ebfa8cdad..6d32ed690 100644 --- a/programs/raydiumclmm/IncreaseLiquidityV2_test.go +++ b/programs/raydium_clmm/IncreaseLiquidityV2_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/IncreaseLiquidity_test.go b/programs/raydium_clmm/IncreaseLiquidity_test.go similarity index 97% rename from programs/raydiumclmm/IncreaseLiquidity_test.go rename to programs/raydium_clmm/IncreaseLiquidity_test.go index 117bcb9ee..f12d159d1 100644 --- a/programs/raydiumclmm/IncreaseLiquidity_test.go +++ b/programs/raydium_clmm/IncreaseLiquidity_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/InitializeReward.go b/programs/raydium_clmm/InitializeReward.go similarity index 99% rename from programs/raydiumclmm/InitializeReward.go rename to programs/raydium_clmm/InitializeReward.go index bf563c51b..e9f75cc88 100644 --- a/programs/raydiumclmm/InitializeReward.go +++ b/programs/raydium_clmm/InitializeReward.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/InitializeReward_test.go b/programs/raydium_clmm/InitializeReward_test.go similarity index 97% rename from programs/raydiumclmm/InitializeReward_test.go rename to programs/raydium_clmm/InitializeReward_test.go index 5bbb9ca9e..75493d178 100644 --- a/programs/raydiumclmm/InitializeReward_test.go +++ b/programs/raydium_clmm/InitializeReward_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/OpenPosition.go b/programs/raydium_clmm/OpenPosition.go similarity index 98% rename from programs/raydiumclmm/OpenPosition.go rename to programs/raydium_clmm/OpenPosition.go index 542e34c78..fb9370479 100644 --- a/programs/raydiumclmm/OpenPosition.go +++ b/programs/raydium_clmm/OpenPosition.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,6 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) +// #[deprecated(note = "Use `open_position_with_token22_nft` instead.")] // Creates a new position wrapped in a NFT // // # Arguments @@ -42,6 +43,7 @@ type OpenPosition struct { // // [3] = [WRITE] positionNftAccount // ··········· Token account where position NFT will be minted + // ··········· This account created in the contract by cpi to avoid large stack variables // // [4] = [WRITE] metadataAccount // ··········· To store metaplex metadata @@ -177,6 +179,7 @@ func (inst *OpenPosition) GetPositionNftMintAccount() *ag_solanago.AccountMeta { // SetPositionNftAccountAccount sets the "positionNftAccount" account. // Token account where position NFT will be minted +// This account created in the contract by cpi to avoid large stack variables func (inst *OpenPosition) SetPositionNftAccountAccount(positionNftAccount ag_solanago.PublicKey) *OpenPosition { inst.AccountMetaSlice[3] = ag_solanago.Meta(positionNftAccount).WRITE() return inst @@ -184,6 +187,7 @@ func (inst *OpenPosition) SetPositionNftAccountAccount(positionNftAccount ag_sol // GetPositionNftAccountAccount gets the "positionNftAccount" account. // Token account where position NFT will be minted +// This account created in the contract by cpi to avoid large stack variables func (inst *OpenPosition) GetPositionNftAccountAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(3) } diff --git a/programs/raydiumclmm/OpenPositionV2.go b/programs/raydium_clmm/OpenPositionV2.go similarity index 96% rename from programs/raydiumclmm/OpenPositionV2.go rename to programs/raydium_clmm/OpenPositionV2.go index d8d92904f..ebed2f80e 100644 --- a/programs/raydiumclmm/OpenPositionV2.go +++ b/programs/raydium_clmm/OpenPositionV2.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,6 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) +// #[deprecated(note = "Use `open_position_with_token22_nft` instead.")] // Creates a new position wrapped in a NFT, support Token2022 // // # Arguments @@ -19,10 +20,11 @@ import ( // * `tick_upper_index` - The upper boundary of market // * `tick_array_lower_start_index` - The start index of tick array which include tick low // * `tick_array_upper_start_index` - The start index of tick array which include tick upper -// * `liquidity` - The liquidity to be added, if zero, calculate liquidity base amount_0_max or amount_1_max according base_flag +// * `liquidity` - The liquidity to be added, if zero, and the base_flage is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidity // * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check // * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check -// * `base_flag` - must be special if liquidity is zero, false: calculate liquidity base amount_0_max otherwise base amount_1_max +// * `with_metadata` - The flag indicating whether to create NFT mint metadata +// * `base_flag` - if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max // type OpenPositionV2 struct { TickLowerIndex *int32 @@ -32,7 +34,7 @@ type OpenPositionV2 struct { Liquidity *ag_binary.Uint128 Amount0Max *uint64 Amount1Max *uint64 - WithMatedata *bool + WithMetadata *bool BaseFlag *bool `bin:"optional"` // [0] = [WRITE, SIGNER] payer @@ -150,9 +152,9 @@ func (inst *OpenPositionV2) SetAmount1Max(amount1Max uint64) *OpenPositionV2 { return inst } -// SetWithMatedata sets the "withMatedata" parameter. -func (inst *OpenPositionV2) SetWithMatedata(withMatedata bool) *OpenPositionV2 { - inst.WithMatedata = &withMatedata +// SetWithMetadata sets the "withMetadata" parameter. +func (inst *OpenPositionV2) SetWithMetadata(withMetadata bool) *OpenPositionV2 { + inst.WithMetadata = &withMetadata return inst } @@ -483,8 +485,8 @@ func (inst *OpenPositionV2) Validate() error { if inst.Amount1Max == nil { return errors.New("Amount1Max parameter is not set") } - if inst.WithMatedata == nil { - return errors.New("WithMatedata parameter is not set") + if inst.WithMetadata == nil { + return errors.New("WithMetadata parameter is not set") } } @@ -577,7 +579,7 @@ func (inst *OpenPositionV2) EncodeToTree(parent ag_treeout.Branches) { paramsBranch.Child(ag_format.Param(" Liquidity", *inst.Liquidity)) paramsBranch.Child(ag_format.Param(" Amount0Max", *inst.Amount0Max)) paramsBranch.Child(ag_format.Param(" Amount1Max", *inst.Amount1Max)) - paramsBranch.Child(ag_format.Param(" WithMatedata", *inst.WithMatedata)) + paramsBranch.Child(ag_format.Param(" WithMetadata", *inst.WithMetadata)) paramsBranch.Child(ag_format.Param(" BaseFlag (OPT)", inst.BaseFlag)) }) @@ -646,8 +648,8 @@ func (obj OpenPositionV2) MarshalWithEncoder(encoder *ag_binary.Encoder) (err er if err != nil { return err } - // Serialize `WithMatedata` param: - err = encoder.Encode(obj.WithMatedata) + // Serialize `WithMetadata` param: + err = encoder.Encode(obj.WithMetadata) if err != nil { return err } @@ -707,8 +709,8 @@ func (obj *OpenPositionV2) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err if err != nil { return err } - // Deserialize `WithMatedata`: - err = decoder.Decode(&obj.WithMatedata) + // Deserialize `WithMetadata`: + err = decoder.Decode(&obj.WithMetadata) if err != nil { return err } @@ -738,7 +740,7 @@ func NewOpenPositionV2Instruction( liquidity ag_binary.Uint128, amount0Max uint64, amount1Max uint64, - withMatedata bool, + withMetadata bool, baseFlag bool, // Accounts: payer ag_solanago.PublicKey, @@ -771,7 +773,7 @@ func NewOpenPositionV2Instruction( SetLiquidity(liquidity). SetAmount0Max(amount0Max). SetAmount1Max(amount1Max). - SetWithMatedata(withMatedata). + SetWithMetadata(withMetadata). SetBaseFlag(baseFlag). SetPayerAccount(payer). SetPositionNftOwnerAccount(positionNftOwner). diff --git a/programs/raydiumclmm/OpenPositionV2_test.go b/programs/raydium_clmm/OpenPositionV2_test.go similarity index 97% rename from programs/raydiumclmm/OpenPositionV2_test.go rename to programs/raydium_clmm/OpenPositionV2_test.go index 71514de21..9b6c925a7 100644 --- a/programs/raydiumclmm/OpenPositionV2_test.go +++ b/programs/raydium_clmm/OpenPositionV2_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydium_clmm/OpenPositionWithToken22Nft.go b/programs/raydium_clmm/OpenPositionWithToken22Nft.go new file mode 100644 index 000000000..c8eaa7adc --- /dev/null +++ b/programs/raydium_clmm/OpenPositionWithToken22Nft.go @@ -0,0 +1,752 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Creates a new position wrapped in a Token2022 NFT without relying on metadata_program and metadata_account, reduce the cost for user to create a personal position. +// +// # Arguments +// +// * `ctx` - The context of accounts +// * `tick_lower_index` - The low boundary of market +// * `tick_upper_index` - The upper boundary of market +// * `tick_array_lower_start_index` - The start index of tick array which include tick low +// * `tick_array_upper_start_index` - The start index of tick array which include tick upper +// * `liquidity` - The liquidity to be added, if zero, and the base_flage is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidity +// * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check +// * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check +// * `with_metadata` - The flag indicating whether to create NFT mint metadata +// * `base_flag` - if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max +// +type OpenPositionWithToken22Nft struct { + TickLowerIndex *int32 + TickUpperIndex *int32 + TickArrayLowerStartIndex *int32 + TickArrayUpperStartIndex *int32 + Liquidity *ag_binary.Uint128 + Amount0Max *uint64 + Amount1Max *uint64 + WithMetadata *bool + BaseFlag *bool `bin:"optional"` + + // [0] = [WRITE, SIGNER] payer + // ··········· Pays to mint the position + // + // [1] = [] positionNftOwner + // + // [2] = [WRITE, SIGNER] positionNftMint + // ··········· Unique token mint address, initialize in constract + // + // [3] = [WRITE] positionNftAccount + // + // [4] = [WRITE] poolState + // ··········· Add liquidity for this pool + // + // [5] = [WRITE] protocolPosition + // ··········· Store the information of market marking in range + // + // [6] = [WRITE] tickArrayLower + // + // [7] = [WRITE] tickArrayUpper + // + // [8] = [WRITE] personalPosition + // ··········· personal position state + // + // [9] = [WRITE] tokenAccount0 + // ··········· The token_0 account deposit token to the pool + // + // [10] = [WRITE] tokenAccount1 + // ··········· The token_1 account deposit token to the pool + // + // [11] = [WRITE] tokenVault0 + // ··········· The address that holds pool tokens for token_0 + // + // [12] = [WRITE] tokenVault1 + // ··········· The address that holds pool tokens for token_1 + // + // [13] = [] rent + // ··········· Sysvar for token mint and ATA creation + // + // [14] = [] systemProgram + // ··········· Program to create the position manager state account + // + // [15] = [] tokenProgram + // ··········· Program to transfer for token account + // + // [16] = [] associatedTokenProgram + // ··········· Program to create an ATA for receiving position NFT + // + // [17] = [] tokenProgram2022 + // ··········· Program to create NFT mint/token account and transfer for token22 account + // + // [18] = [] vault0Mint + // ··········· The mint of token vault 0 + // + // [19] = [] vault1Mint + // ··········· The mint of token vault 1 + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewOpenPositionWithToken22NftInstructionBuilder creates a new `OpenPositionWithToken22Nft` instruction builder. +func NewOpenPositionWithToken22NftInstructionBuilder() *OpenPositionWithToken22Nft { + nd := &OpenPositionWithToken22Nft{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 20), + } + return nd +} + +// SetTickLowerIndex sets the "tickLowerIndex" parameter. +func (inst *OpenPositionWithToken22Nft) SetTickLowerIndex(tickLowerIndex int32) *OpenPositionWithToken22Nft { + inst.TickLowerIndex = &tickLowerIndex + return inst +} + +// SetTickUpperIndex sets the "tickUpperIndex" parameter. +func (inst *OpenPositionWithToken22Nft) SetTickUpperIndex(tickUpperIndex int32) *OpenPositionWithToken22Nft { + inst.TickUpperIndex = &tickUpperIndex + return inst +} + +// SetTickArrayLowerStartIndex sets the "tickArrayLowerStartIndex" parameter. +func (inst *OpenPositionWithToken22Nft) SetTickArrayLowerStartIndex(tickArrayLowerStartIndex int32) *OpenPositionWithToken22Nft { + inst.TickArrayLowerStartIndex = &tickArrayLowerStartIndex + return inst +} + +// SetTickArrayUpperStartIndex sets the "tickArrayUpperStartIndex" parameter. +func (inst *OpenPositionWithToken22Nft) SetTickArrayUpperStartIndex(tickArrayUpperStartIndex int32) *OpenPositionWithToken22Nft { + inst.TickArrayUpperStartIndex = &tickArrayUpperStartIndex + return inst +} + +// SetLiquidity sets the "liquidity" parameter. +func (inst *OpenPositionWithToken22Nft) SetLiquidity(liquidity ag_binary.Uint128) *OpenPositionWithToken22Nft { + inst.Liquidity = &liquidity + return inst +} + +// SetAmount0Max sets the "amount0Max" parameter. +func (inst *OpenPositionWithToken22Nft) SetAmount0Max(amount0Max uint64) *OpenPositionWithToken22Nft { + inst.Amount0Max = &amount0Max + return inst +} + +// SetAmount1Max sets the "amount1Max" parameter. +func (inst *OpenPositionWithToken22Nft) SetAmount1Max(amount1Max uint64) *OpenPositionWithToken22Nft { + inst.Amount1Max = &amount1Max + return inst +} + +// SetWithMetadata sets the "withMetadata" parameter. +func (inst *OpenPositionWithToken22Nft) SetWithMetadata(withMetadata bool) *OpenPositionWithToken22Nft { + inst.WithMetadata = &withMetadata + return inst +} + +// SetBaseFlag sets the "baseFlag" parameter. +func (inst *OpenPositionWithToken22Nft) SetBaseFlag(baseFlag bool) *OpenPositionWithToken22Nft { + inst.BaseFlag = &baseFlag + return inst +} + +// SetPayerAccount sets the "payer" account. +// Pays to mint the position +func (inst *OpenPositionWithToken22Nft) SetPayerAccount(payer ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[0] = ag_solanago.Meta(payer).WRITE().SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +// Pays to mint the position +func (inst *OpenPositionWithToken22Nft) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetPositionNftOwnerAccount sets the "positionNftOwner" account. +func (inst *OpenPositionWithToken22Nft) SetPositionNftOwnerAccount(positionNftOwner ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[1] = ag_solanago.Meta(positionNftOwner) + return inst +} + +// GetPositionNftOwnerAccount gets the "positionNftOwner" account. +func (inst *OpenPositionWithToken22Nft) GetPositionNftOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPositionNftMintAccount sets the "positionNftMint" account. +// Unique token mint address, initialize in constract +func (inst *OpenPositionWithToken22Nft) SetPositionNftMintAccount(positionNftMint ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[2] = ag_solanago.Meta(positionNftMint).WRITE().SIGNER() + return inst +} + +// GetPositionNftMintAccount gets the "positionNftMint" account. +// Unique token mint address, initialize in constract +func (inst *OpenPositionWithToken22Nft) GetPositionNftMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetPositionNftAccountAccount sets the "positionNftAccount" account. +func (inst *OpenPositionWithToken22Nft) SetPositionNftAccountAccount(positionNftAccount ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[3] = ag_solanago.Meta(positionNftAccount).WRITE() + return inst +} + +// GetPositionNftAccountAccount gets the "positionNftAccount" account. +func (inst *OpenPositionWithToken22Nft) GetPositionNftAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetPoolStateAccount sets the "poolState" account. +// Add liquidity for this pool +func (inst *OpenPositionWithToken22Nft) SetPoolStateAccount(poolState ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[4] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// Add liquidity for this pool +func (inst *OpenPositionWithToken22Nft) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetProtocolPositionAccount sets the "protocolPosition" account. +// Store the information of market marking in range +func (inst *OpenPositionWithToken22Nft) SetProtocolPositionAccount(protocolPosition ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[5] = ag_solanago.Meta(protocolPosition).WRITE() + return inst +} + +// GetProtocolPositionAccount gets the "protocolPosition" account. +// Store the information of market marking in range +func (inst *OpenPositionWithToken22Nft) GetProtocolPositionAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetTickArrayLowerAccount sets the "tickArrayLower" account. +func (inst *OpenPositionWithToken22Nft) SetTickArrayLowerAccount(tickArrayLower ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tickArrayLower).WRITE() + return inst +} + +// GetTickArrayLowerAccount gets the "tickArrayLower" account. +func (inst *OpenPositionWithToken22Nft) GetTickArrayLowerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetTickArrayUpperAccount sets the "tickArrayUpper" account. +func (inst *OpenPositionWithToken22Nft) SetTickArrayUpperAccount(tickArrayUpper ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[7] = ag_solanago.Meta(tickArrayUpper).WRITE() + return inst +} + +// GetTickArrayUpperAccount gets the "tickArrayUpper" account. +func (inst *OpenPositionWithToken22Nft) GetTickArrayUpperAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetPersonalPositionAccount sets the "personalPosition" account. +// personal position state +func (inst *OpenPositionWithToken22Nft) SetPersonalPositionAccount(personalPosition ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[8] = ag_solanago.Meta(personalPosition).WRITE() + return inst +} + +// GetPersonalPositionAccount gets the "personalPosition" account. +// personal position state +func (inst *OpenPositionWithToken22Nft) GetPersonalPositionAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenAccount0Account sets the "tokenAccount0" account. +// The token_0 account deposit token to the pool +func (inst *OpenPositionWithToken22Nft) SetTokenAccount0Account(tokenAccount0 ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenAccount0).WRITE() + return inst +} + +// GetTokenAccount0Account gets the "tokenAccount0" account. +// The token_0 account deposit token to the pool +func (inst *OpenPositionWithToken22Nft) GetTokenAccount0Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenAccount1Account sets the "tokenAccount1" account. +// The token_1 account deposit token to the pool +func (inst *OpenPositionWithToken22Nft) SetTokenAccount1Account(tokenAccount1 ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenAccount1).WRITE() + return inst +} + +// GetTokenAccount1Account gets the "tokenAccount1" account. +// The token_1 account deposit token to the pool +func (inst *OpenPositionWithToken22Nft) GetTokenAccount1Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetTokenVault0Account sets the "tokenVault0" account. +// The address that holds pool tokens for token_0 +func (inst *OpenPositionWithToken22Nft) SetTokenVault0Account(tokenVault0 ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenVault0).WRITE() + return inst +} + +// GetTokenVault0Account gets the "tokenVault0" account. +// The address that holds pool tokens for token_0 +func (inst *OpenPositionWithToken22Nft) GetTokenVault0Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetTokenVault1Account sets the "tokenVault1" account. +// The address that holds pool tokens for token_1 +func (inst *OpenPositionWithToken22Nft) SetTokenVault1Account(tokenVault1 ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[12] = ag_solanago.Meta(tokenVault1).WRITE() + return inst +} + +// GetTokenVault1Account gets the "tokenVault1" account. +// The address that holds pool tokens for token_1 +func (inst *OpenPositionWithToken22Nft) GetTokenVault1Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +// SetRentAccount sets the "rent" account. +// Sysvar for token mint and ATA creation +func (inst *OpenPositionWithToken22Nft) SetRentAccount(rent ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[13] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +// Sysvar for token mint and ATA creation +func (inst *OpenPositionWithToken22Nft) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(13) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +// Program to create the position manager state account +func (inst *OpenPositionWithToken22Nft) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[14] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +// Program to create the position manager state account +func (inst *OpenPositionWithToken22Nft) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(14) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// Program to transfer for token account +func (inst *OpenPositionWithToken22Nft) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[15] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// Program to transfer for token account +func (inst *OpenPositionWithToken22Nft) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(15) +} + +// SetAssociatedTokenProgramAccount sets the "associatedTokenProgram" account. +// Program to create an ATA for receiving position NFT +func (inst *OpenPositionWithToken22Nft) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[16] = ag_solanago.Meta(associatedTokenProgram) + return inst +} + +// GetAssociatedTokenProgramAccount gets the "associatedTokenProgram" account. +// Program to create an ATA for receiving position NFT +func (inst *OpenPositionWithToken22Nft) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(16) +} + +// SetTokenProgram2022Account sets the "tokenProgram2022" account. +// Program to create NFT mint/token account and transfer for token22 account +func (inst *OpenPositionWithToken22Nft) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[17] = ag_solanago.Meta(tokenProgram2022) + return inst +} + +// GetTokenProgram2022Account gets the "tokenProgram2022" account. +// Program to create NFT mint/token account and transfer for token22 account +func (inst *OpenPositionWithToken22Nft) GetTokenProgram2022Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(17) +} + +// SetVault0MintAccount sets the "vault0Mint" account. +// The mint of token vault 0 +func (inst *OpenPositionWithToken22Nft) SetVault0MintAccount(vault0Mint ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[18] = ag_solanago.Meta(vault0Mint) + return inst +} + +// GetVault0MintAccount gets the "vault0Mint" account. +// The mint of token vault 0 +func (inst *OpenPositionWithToken22Nft) GetVault0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(18) +} + +// SetVault1MintAccount sets the "vault1Mint" account. +// The mint of token vault 1 +func (inst *OpenPositionWithToken22Nft) SetVault1MintAccount(vault1Mint ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + inst.AccountMetaSlice[19] = ag_solanago.Meta(vault1Mint) + return inst +} + +// GetVault1MintAccount gets the "vault1Mint" account. +// The mint of token vault 1 +func (inst *OpenPositionWithToken22Nft) GetVault1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(19) +} + +func (inst OpenPositionWithToken22Nft) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_OpenPositionWithToken22Nft, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst OpenPositionWithToken22Nft) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *OpenPositionWithToken22Nft) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.TickLowerIndex == nil { + return errors.New("TickLowerIndex parameter is not set") + } + if inst.TickUpperIndex == nil { + return errors.New("TickUpperIndex parameter is not set") + } + if inst.TickArrayLowerStartIndex == nil { + return errors.New("TickArrayLowerStartIndex parameter is not set") + } + if inst.TickArrayUpperStartIndex == nil { + return errors.New("TickArrayUpperStartIndex parameter is not set") + } + if inst.Liquidity == nil { + return errors.New("Liquidity parameter is not set") + } + if inst.Amount0Max == nil { + return errors.New("Amount0Max parameter is not set") + } + if inst.Amount1Max == nil { + return errors.New("Amount1Max parameter is not set") + } + if inst.WithMetadata == nil { + return errors.New("WithMetadata parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.PositionNftOwner is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.PositionNftMint is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.PositionNftAccount is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.ProtocolPosition is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TickArrayLower is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.TickArrayUpper is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.PersonalPosition is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenAccount0 is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenAccount1 is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.TokenVault0 is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.TokenVault1 is not set") + } + if inst.AccountMetaSlice[13] == nil { + return errors.New("accounts.Rent is not set") + } + if inst.AccountMetaSlice[14] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[15] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[16] == nil { + return errors.New("accounts.AssociatedTokenProgram is not set") + } + if inst.AccountMetaSlice[17] == nil { + return errors.New("accounts.TokenProgram2022 is not set") + } + if inst.AccountMetaSlice[18] == nil { + return errors.New("accounts.Vault0Mint is not set") + } + if inst.AccountMetaSlice[19] == nil { + return errors.New("accounts.Vault1Mint is not set") + } + } + return nil +} + +func (inst *OpenPositionWithToken22Nft) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("OpenPositionWithToken22Nft")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=9]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" TickLowerIndex", *inst.TickLowerIndex)) + paramsBranch.Child(ag_format.Param(" TickUpperIndex", *inst.TickUpperIndex)) + paramsBranch.Child(ag_format.Param("TickArrayLowerStartIndex", *inst.TickArrayLowerStartIndex)) + paramsBranch.Child(ag_format.Param("TickArrayUpperStartIndex", *inst.TickArrayUpperStartIndex)) + paramsBranch.Child(ag_format.Param(" Liquidity", *inst.Liquidity)) + paramsBranch.Child(ag_format.Param(" Amount0Max", *inst.Amount0Max)) + paramsBranch.Child(ag_format.Param(" Amount1Max", *inst.Amount1Max)) + paramsBranch.Child(ag_format.Param(" WithMetadata", *inst.WithMetadata)) + paramsBranch.Child(ag_format.Param(" BaseFlag (OPT)", inst.BaseFlag)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=20]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" positionNftOwner", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" positionNftMint", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" positionNft", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" protocolPosition", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" tickArrayLower", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" tickArrayUpper", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" personalPosition", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" tokenAccount0", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenAccount1", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" tokenVault0", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" tokenVault1", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(13))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(14))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(15))) + accountsBranch.Child(ag_format.Meta("associatedTokenProgram", inst.AccountMetaSlice.Get(16))) + accountsBranch.Child(ag_format.Meta(" tokenProgram2022", inst.AccountMetaSlice.Get(17))) + accountsBranch.Child(ag_format.Meta(" vault0Mint", inst.AccountMetaSlice.Get(18))) + accountsBranch.Child(ag_format.Meta(" vault1Mint", inst.AccountMetaSlice.Get(19))) + }) + }) + }) +} + +func (obj OpenPositionWithToken22Nft) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `TickLowerIndex` param: + err = encoder.Encode(obj.TickLowerIndex) + if err != nil { + return err + } + // Serialize `TickUpperIndex` param: + err = encoder.Encode(obj.TickUpperIndex) + if err != nil { + return err + } + // Serialize `TickArrayLowerStartIndex` param: + err = encoder.Encode(obj.TickArrayLowerStartIndex) + if err != nil { + return err + } + // Serialize `TickArrayUpperStartIndex` param: + err = encoder.Encode(obj.TickArrayUpperStartIndex) + if err != nil { + return err + } + // Serialize `Liquidity` param: + err = encoder.Encode(obj.Liquidity) + if err != nil { + return err + } + // Serialize `Amount0Max` param: + err = encoder.Encode(obj.Amount0Max) + if err != nil { + return err + } + // Serialize `Amount1Max` param: + err = encoder.Encode(obj.Amount1Max) + if err != nil { + return err + } + // Serialize `WithMetadata` param: + err = encoder.Encode(obj.WithMetadata) + if err != nil { + return err + } + // Serialize `BaseFlag` param (optional): + { + if obj.BaseFlag == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.BaseFlag) + if err != nil { + return err + } + } + } + return nil +} +func (obj *OpenPositionWithToken22Nft) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `TickLowerIndex`: + err = decoder.Decode(&obj.TickLowerIndex) + if err != nil { + return err + } + // Deserialize `TickUpperIndex`: + err = decoder.Decode(&obj.TickUpperIndex) + if err != nil { + return err + } + // Deserialize `TickArrayLowerStartIndex`: + err = decoder.Decode(&obj.TickArrayLowerStartIndex) + if err != nil { + return err + } + // Deserialize `TickArrayUpperStartIndex`: + err = decoder.Decode(&obj.TickArrayUpperStartIndex) + if err != nil { + return err + } + // Deserialize `Liquidity`: + err = decoder.Decode(&obj.Liquidity) + if err != nil { + return err + } + // Deserialize `Amount0Max`: + err = decoder.Decode(&obj.Amount0Max) + if err != nil { + return err + } + // Deserialize `Amount1Max`: + err = decoder.Decode(&obj.Amount1Max) + if err != nil { + return err + } + // Deserialize `WithMetadata`: + err = decoder.Decode(&obj.WithMetadata) + if err != nil { + return err + } + // Deserialize `BaseFlag` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.BaseFlag) + if err != nil { + return err + } + } + } + return nil +} + +// NewOpenPositionWithToken22NftInstruction declares a new OpenPositionWithToken22Nft instruction with the provided parameters and accounts. +func NewOpenPositionWithToken22NftInstruction( + // Parameters: + tickLowerIndex int32, + tickUpperIndex int32, + tickArrayLowerStartIndex int32, + tickArrayUpperStartIndex int32, + liquidity ag_binary.Uint128, + amount0Max uint64, + amount1Max uint64, + withMetadata bool, + baseFlag bool, + // Accounts: + payer ag_solanago.PublicKey, + positionNftOwner ag_solanago.PublicKey, + positionNftMint ag_solanago.PublicKey, + positionNftAccount ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + protocolPosition ag_solanago.PublicKey, + tickArrayLower ag_solanago.PublicKey, + tickArrayUpper ag_solanago.PublicKey, + personalPosition ag_solanago.PublicKey, + tokenAccount0 ag_solanago.PublicKey, + tokenAccount1 ag_solanago.PublicKey, + tokenVault0 ag_solanago.PublicKey, + tokenVault1 ag_solanago.PublicKey, + rent ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + associatedTokenProgram ag_solanago.PublicKey, + tokenProgram2022 ag_solanago.PublicKey, + vault0Mint ag_solanago.PublicKey, + vault1Mint ag_solanago.PublicKey) *OpenPositionWithToken22Nft { + return NewOpenPositionWithToken22NftInstructionBuilder(). + SetTickLowerIndex(tickLowerIndex). + SetTickUpperIndex(tickUpperIndex). + SetTickArrayLowerStartIndex(tickArrayLowerStartIndex). + SetTickArrayUpperStartIndex(tickArrayUpperStartIndex). + SetLiquidity(liquidity). + SetAmount0Max(amount0Max). + SetAmount1Max(amount1Max). + SetWithMetadata(withMetadata). + SetBaseFlag(baseFlag). + SetPayerAccount(payer). + SetPositionNftOwnerAccount(positionNftOwner). + SetPositionNftMintAccount(positionNftMint). + SetPositionNftAccountAccount(positionNftAccount). + SetPoolStateAccount(poolState). + SetProtocolPositionAccount(protocolPosition). + SetTickArrayLowerAccount(tickArrayLower). + SetTickArrayUpperAccount(tickArrayUpper). + SetPersonalPositionAccount(personalPosition). + SetTokenAccount0Account(tokenAccount0). + SetTokenAccount1Account(tokenAccount1). + SetTokenVault0Account(tokenVault0). + SetTokenVault1Account(tokenVault1). + SetRentAccount(rent). + SetSystemProgramAccount(systemProgram). + SetTokenProgramAccount(tokenProgram). + SetAssociatedTokenProgramAccount(associatedTokenProgram). + SetTokenProgram2022Account(tokenProgram2022). + SetVault0MintAccount(vault0Mint). + SetVault1MintAccount(vault1Mint) +} diff --git a/programs/raydium_clmm/OpenPositionWithToken22Nft_test.go b/programs/raydium_clmm/OpenPositionWithToken22Nft_test.go new file mode 100644 index 000000000..6c7c98f73 --- /dev/null +++ b/programs/raydium_clmm/OpenPositionWithToken22Nft_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_OpenPositionWithToken22Nft(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("OpenPositionWithToken22Nft"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(OpenPositionWithToken22Nft) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(OpenPositionWithToken22Nft) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/OpenPosition_test.go b/programs/raydium_clmm/OpenPosition_test.go similarity index 97% rename from programs/raydiumclmm/OpenPosition_test.go rename to programs/raydium_clmm/OpenPosition_test.go index 8f6eecbb9..565267930 100644 --- a/programs/raydiumclmm/OpenPosition_test.go +++ b/programs/raydium_clmm/OpenPosition_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/SetRewardParams.go b/programs/raydium_clmm/SetRewardParams.go similarity index 99% rename from programs/raydiumclmm/SetRewardParams.go rename to programs/raydium_clmm/SetRewardParams.go index cffcbc6fb..8d13fefe1 100644 --- a/programs/raydiumclmm/SetRewardParams.go +++ b/programs/raydium_clmm/SetRewardParams.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/SetRewardParams_test.go b/programs/raydium_clmm/SetRewardParams_test.go similarity index 97% rename from programs/raydiumclmm/SetRewardParams_test.go rename to programs/raydium_clmm/SetRewardParams_test.go index f64caaa9b..747a471aa 100644 --- a/programs/raydiumclmm/SetRewardParams_test.go +++ b/programs/raydium_clmm/SetRewardParams_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/Swap.go b/programs/raydium_clmm/Swap.go similarity index 99% rename from programs/raydiumclmm/Swap.go rename to programs/raydium_clmm/Swap.go index 604526d98..ef45aff04 100644 --- a/programs/raydiumclmm/Swap.go +++ b/programs/raydium_clmm/Swap.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" @@ -10,6 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) +// #[deprecated(note = "Use `swap_v2` instead.")] // Swaps one token for as much as possible of another token across a single pool // // # Arguments diff --git a/programs/raydiumclmm/SwapRouterBaseIn.go b/programs/raydium_clmm/SwapRouterBaseIn.go similarity index 99% rename from programs/raydiumclmm/SwapRouterBaseIn.go rename to programs/raydium_clmm/SwapRouterBaseIn.go index 15adcff36..478b51e16 100644 --- a/programs/raydiumclmm/SwapRouterBaseIn.go +++ b/programs/raydium_clmm/SwapRouterBaseIn.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/SwapRouterBaseIn_test.go b/programs/raydium_clmm/SwapRouterBaseIn_test.go similarity index 97% rename from programs/raydiumclmm/SwapRouterBaseIn_test.go rename to programs/raydium_clmm/SwapRouterBaseIn_test.go index 7571baafe..d97731b43 100644 --- a/programs/raydiumclmm/SwapRouterBaseIn_test.go +++ b/programs/raydium_clmm/SwapRouterBaseIn_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/SwapV2.go b/programs/raydium_clmm/SwapV2.go similarity index 99% rename from programs/raydiumclmm/SwapV2.go rename to programs/raydium_clmm/SwapV2.go index aa6d7aab4..3a45f6194 100644 --- a/programs/raydiumclmm/SwapV2.go +++ b/programs/raydium_clmm/SwapV2.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/SwapV2_test.go b/programs/raydium_clmm/SwapV2_test.go similarity index 97% rename from programs/raydiumclmm/SwapV2_test.go rename to programs/raydium_clmm/SwapV2_test.go index 6f8de634a..2d8727148 100644 --- a/programs/raydiumclmm/SwapV2_test.go +++ b/programs/raydium_clmm/SwapV2_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/meteorapools/Swap_test.go b/programs/raydium_clmm/Swap_test.go similarity index 97% rename from programs/meteorapools/Swap_test.go rename to programs/raydium_clmm/Swap_test.go index 51b79b60f..df5f6683a 100644 --- a/programs/meteorapools/Swap_test.go +++ b/programs/raydium_clmm/Swap_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/TransferRewardOwner.go b/programs/raydium_clmm/TransferRewardOwner.go similarity index 99% rename from programs/raydiumclmm/TransferRewardOwner.go rename to programs/raydium_clmm/TransferRewardOwner.go index 768364ee4..7a208a7b4 100644 --- a/programs/raydiumclmm/TransferRewardOwner.go +++ b/programs/raydium_clmm/TransferRewardOwner.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/TransferRewardOwner_test.go b/programs/raydium_clmm/TransferRewardOwner_test.go similarity index 97% rename from programs/raydiumclmm/TransferRewardOwner_test.go rename to programs/raydium_clmm/TransferRewardOwner_test.go index a972f483c..767c26a65 100644 --- a/programs/raydiumclmm/TransferRewardOwner_test.go +++ b/programs/raydium_clmm/TransferRewardOwner_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/UpdateAmmConfig.go b/programs/raydium_clmm/UpdateAmmConfig.go similarity index 99% rename from programs/raydiumclmm/UpdateAmmConfig.go rename to programs/raydium_clmm/UpdateAmmConfig.go index 89b91a3b4..7eacdf9c0 100644 --- a/programs/raydiumclmm/UpdateAmmConfig.go +++ b/programs/raydium_clmm/UpdateAmmConfig.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydium_clmm/UpdateAmmConfig_test.go b/programs/raydium_clmm/UpdateAmmConfig_test.go new file mode 100644 index 000000000..da2aafab3 --- /dev/null +++ b/programs/raydium_clmm/UpdateAmmConfig_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdateAmmConfig(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdateAmmConfig"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdateAmmConfig) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdateAmmConfig) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/UpdateOperationAccount.go b/programs/raydium_clmm/UpdateOperationAccount.go similarity index 99% rename from programs/raydiumclmm/UpdateOperationAccount.go rename to programs/raydium_clmm/UpdateOperationAccount.go index cc641e358..089b67a79 100644 --- a/programs/raydiumclmm/UpdateOperationAccount.go +++ b/programs/raydium_clmm/UpdateOperationAccount.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/UpdateOperationAccount_test.go b/programs/raydium_clmm/UpdateOperationAccount_test.go similarity index 97% rename from programs/raydiumclmm/UpdateOperationAccount_test.go rename to programs/raydium_clmm/UpdateOperationAccount_test.go index bd286c126..64d7bdfb5 100644 --- a/programs/raydiumclmm/UpdateOperationAccount_test.go +++ b/programs/raydium_clmm/UpdateOperationAccount_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydium_clmm/UpdatePoolStatus.go b/programs/raydium_clmm/UpdatePoolStatus.go new file mode 100644 index 000000000..094696446 --- /dev/null +++ b/programs/raydium_clmm/UpdatePoolStatus.go @@ -0,0 +1,152 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Update pool status for given vaule +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `status` - The vaule of status +// +type UpdatePoolStatus struct { + Status *uint8 + + // [0] = [SIGNER] authority + // + // [1] = [WRITE] poolState + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewUpdatePoolStatusInstructionBuilder creates a new `UpdatePoolStatus` instruction builder. +func NewUpdatePoolStatusInstructionBuilder() *UpdatePoolStatus { + nd := &UpdatePoolStatus{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetStatus sets the "status" parameter. +func (inst *UpdatePoolStatus) SetStatus(status uint8) *UpdatePoolStatus { + inst.Status = &status + return inst +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *UpdatePoolStatus) SetAuthorityAccount(authority ag_solanago.PublicKey) *UpdatePoolStatus { + inst.AccountMetaSlice[0] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *UpdatePoolStatus) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetPoolStateAccount sets the "poolState" account. +func (inst *UpdatePoolStatus) SetPoolStateAccount(poolState ag_solanago.PublicKey) *UpdatePoolStatus { + inst.AccountMetaSlice[1] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +func (inst *UpdatePoolStatus) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +func (inst UpdatePoolStatus) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdatePoolStatus, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdatePoolStatus) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdatePoolStatus) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Status == nil { + return errors.New("Status parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.PoolState is not set") + } + } + return nil +} + +func (inst *UpdatePoolStatus) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdatePoolStatus")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Status", *inst.Status)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("authority", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("poolState", inst.AccountMetaSlice.Get(1))) + }) + }) + }) +} + +func (obj UpdatePoolStatus) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Status` param: + err = encoder.Encode(obj.Status) + if err != nil { + return err + } + return nil +} +func (obj *UpdatePoolStatus) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Status`: + err = decoder.Decode(&obj.Status) + if err != nil { + return err + } + return nil +} + +// NewUpdatePoolStatusInstruction declares a new UpdatePoolStatus instruction with the provided parameters and accounts. +func NewUpdatePoolStatusInstruction( + // Parameters: + status uint8, + // Accounts: + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey) *UpdatePoolStatus { + return NewUpdatePoolStatusInstructionBuilder(). + SetStatus(status). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState) +} diff --git a/programs/raydium_clmm/UpdatePoolStatus_test.go b/programs/raydium_clmm/UpdatePoolStatus_test.go new file mode 100644 index 000000000..2641067d0 --- /dev/null +++ b/programs/raydium_clmm/UpdatePoolStatus_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdatePoolStatus(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdatePoolStatus"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdatePoolStatus) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdatePoolStatus) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydiumclmm/UpdateRewardInfos.go b/programs/raydium_clmm/UpdateRewardInfos.go similarity index 99% rename from programs/raydiumclmm/UpdateRewardInfos.go rename to programs/raydium_clmm/UpdateRewardInfos.go index 91fec3baa..46df8c6c2 100644 --- a/programs/raydiumclmm/UpdateRewardInfos.go +++ b/programs/raydium_clmm/UpdateRewardInfos.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "errors" diff --git a/programs/raydiumclmm/UpdateRewardInfos_test.go b/programs/raydium_clmm/UpdateRewardInfos_test.go similarity index 97% rename from programs/raydiumclmm/UpdateRewardInfos_test.go rename to programs/raydium_clmm/UpdateRewardInfos_test.go index c3f978dae..cd4e13a78 100644 --- a/programs/raydiumclmm/UpdateRewardInfos_test.go +++ b/programs/raydium_clmm/UpdateRewardInfos_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" diff --git a/programs/raydiumclmm/accounts.go b/programs/raydium_clmm/accounts.go similarity index 94% rename from programs/raydiumclmm/accounts.go rename to programs/raydium_clmm/accounts.go index fe3c62a0c..b88520117 100644 --- a/programs/raydiumclmm/accounts.go +++ b/programs/raydium_clmm/accounts.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "fmt" @@ -232,13 +232,21 @@ func (obj *OperationState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err type ObservationState struct { // Whether the ObservationState is initialized Initialized bool - PoolId ag_solanago.PublicKey + + // recent update epoch + RecentEpoch uint64 + + // the most-recently updated index of the observations array + ObservationIndex uint16 + + // belongs to which pool + PoolId ag_solanago.PublicKey // observation array - Observations [1000]Observation + Observations [100]Observation // padding for feature update - Padding [5]ag_binary.Uint128 + Padding [4]uint64 } var ObservationStateDiscriminator = [8]byte{122, 174, 197, 53, 129, 9, 165, 132} @@ -254,6 +262,16 @@ func (obj ObservationState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err if err != nil { return err } + // Serialize `RecentEpoch` param: + err = encoder.Encode(obj.RecentEpoch) + if err != nil { + return err + } + // Serialize `ObservationIndex` param: + err = encoder.Encode(obj.ObservationIndex) + if err != nil { + return err + } // Serialize `PoolId` param: err = encoder.Encode(obj.PoolId) if err != nil { @@ -291,6 +309,16 @@ func (obj *ObservationState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (e if err != nil { return err } + // Deserialize `RecentEpoch`: + err = decoder.Decode(&obj.RecentEpoch) + if err != nil { + return err + } + // Deserialize `ObservationIndex`: + err = decoder.Decode(&obj.ObservationIndex) + if err != nil { + return err + } // Deserialize `PoolId`: err = decoder.Decode(&obj.PoolId) if err != nil { @@ -311,7 +339,7 @@ func (obj *ObservationState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (e type PersonalPositionState struct { // Bump to identify PDA - Bump uint8 + Bump [1]uint8 // Mint address of the tokenized position NftMint ag_solanago.PublicKey @@ -340,7 +368,8 @@ type PersonalPositionState struct { // The fees owed to the position owner in token_1, as of the last computation TokenFeesOwed1 uint64 RewardInfos [3]PositionRewardInfo - Padding [8]uint64 + RecentEpoch uint64 + Padding [7]uint64 } var PersonalPositionStateDiscriminator = [8]byte{70, 111, 150, 126, 230, 15, 25, 117} @@ -406,6 +435,11 @@ func (obj PersonalPositionState) MarshalWithEncoder(encoder *ag_binary.Encoder) if err != nil { return err } + // Serialize `RecentEpoch` param: + err = encoder.Encode(obj.RecentEpoch) + if err != nil { + return err + } // Serialize `Padding` param: err = encoder.Encode(obj.Padding) if err != nil { @@ -483,6 +517,11 @@ func (obj *PersonalPositionState) UnmarshalWithDecoder(decoder *ag_binary.Decode if err != nil { return err } + // Deserialize `RecentEpoch`: + err = decoder.Decode(&obj.RecentEpoch) + if err != nil { + return err + } // Deserialize `Padding`: err = decoder.Decode(&obj.Padding) if err != nil { @@ -523,10 +562,8 @@ type PoolState struct { // The current tick of the pool, i.e. according to the last tick transition that was run. TickCurrent int32 - - // the most-recently updated index of the observations array - ObservationIndex uint16 - ObservationUpdateDuration uint16 + Padding3 uint16 + Padding4 uint16 // The fee growth as a Q64.64 number, i.e. fees of token_0 and token_1 collected per // unit of liquidity for the entire life of the pool. @@ -568,7 +605,8 @@ type PoolState struct { FundFeesToken0 uint64 FundFeesToken1 uint64 OpenTime uint64 - Padding1 [25]uint64 + RecentEpoch uint64 + Padding1 [24]uint64 Padding2 [32]uint64 } @@ -650,13 +688,13 @@ func (obj PoolState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) if err != nil { return err } - // Serialize `ObservationIndex` param: - err = encoder.Encode(obj.ObservationIndex) + // Serialize `Padding3` param: + err = encoder.Encode(obj.Padding3) if err != nil { return err } - // Serialize `ObservationUpdateDuration` param: - err = encoder.Encode(obj.ObservationUpdateDuration) + // Serialize `Padding4` param: + err = encoder.Encode(obj.Padding4) if err != nil { return err } @@ -755,6 +793,11 @@ func (obj PoolState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) if err != nil { return err } + // Serialize `RecentEpoch` param: + err = encoder.Encode(obj.RecentEpoch) + if err != nil { + return err + } // Serialize `Padding1` param: err = encoder.Encode(obj.Padding1) if err != nil { @@ -852,13 +895,13 @@ func (obj *PoolState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err erro if err != nil { return err } - // Deserialize `ObservationIndex`: - err = decoder.Decode(&obj.ObservationIndex) + // Deserialize `Padding3`: + err = decoder.Decode(&obj.Padding3) if err != nil { return err } - // Deserialize `ObservationUpdateDuration`: - err = decoder.Decode(&obj.ObservationUpdateDuration) + // Deserialize `Padding4`: + err = decoder.Decode(&obj.Padding4) if err != nil { return err } @@ -957,6 +1000,11 @@ func (obj *PoolState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err erro if err != nil { return err } + // Deserialize `RecentEpoch`: + err = decoder.Decode(&obj.RecentEpoch) + if err != nil { + return err + } // Deserialize `Padding1`: err = decoder.Decode(&obj.Padding1) if err != nil { @@ -1000,7 +1048,8 @@ type ProtocolPositionState struct { // The reward growth per unit of liquidity as of the last update to liquidity RewardGrowthInside [3]ag_binary.Uint128 - Padding [8]uint64 + RecentEpoch uint64 + Padding [7]uint64 } var ProtocolPositionStateDiscriminator = [8]byte{100, 226, 145, 99, 146, 218, 160, 106} @@ -1061,6 +1110,11 @@ func (obj ProtocolPositionState) MarshalWithEncoder(encoder *ag_binary.Encoder) if err != nil { return err } + // Serialize `RecentEpoch` param: + err = encoder.Encode(obj.RecentEpoch) + if err != nil { + return err + } // Serialize `Padding` param: err = encoder.Encode(obj.Padding) if err != nil { @@ -1133,6 +1187,11 @@ func (obj *ProtocolPositionState) UnmarshalWithDecoder(decoder *ag_binary.Decode if err != nil { return err } + // Deserialize `RecentEpoch`: + err = decoder.Decode(&obj.RecentEpoch) + if err != nil { + return err + } // Deserialize `Padding`: err = decoder.Decode(&obj.Padding) if err != nil { @@ -1146,7 +1205,8 @@ type TickArrayState struct { StartTickIndex int32 Ticks [60]TickState InitializedTickCount uint8 - Padding [115]uint8 + RecentEpoch uint64 + Padding [107]uint8 } var TickArrayStateDiscriminator = [8]byte{192, 155, 85, 205, 49, 249, 129, 42} @@ -1177,6 +1237,11 @@ func (obj TickArrayState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err er if err != nil { return err } + // Serialize `RecentEpoch` param: + err = encoder.Encode(obj.RecentEpoch) + if err != nil { + return err + } // Serialize `Padding` param: err = encoder.Encode(obj.Padding) if err != nil { @@ -1219,6 +1284,11 @@ func (obj *TickArrayState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err if err != nil { return err } + // Deserialize `RecentEpoch`: + err = decoder.Decode(&obj.RecentEpoch) + if err != nil { + return err + } // Deserialize `Padding`: err = decoder.Decode(&obj.Padding) if err != nil { diff --git a/programs/raydiumclmm/instructions.go b/programs/raydium_clmm/instructions.go similarity index 85% rename from programs/raydiumclmm/instructions.go rename to programs/raydium_clmm/instructions.go index 5caea28c3..47264ddcb 100644 --- a/programs/raydiumclmm/instructions.go +++ b/programs/raydium_clmm/instructions.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( "bytes" @@ -12,14 +12,14 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK") func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) } -const ProgramName = "AmmV3" +const ProgramName = "RaydiumClmm" func init() { if !ProgramID.IsZero() { @@ -164,6 +164,7 @@ var ( // Instruction_CollectFundFee = ag_binary.TypeID([8]byte{167, 138, 78, 149, 223, 194, 6, 126}) + // #[deprecated(note = "Use `open_position_with_token22_nft` instead.")] // Creates a new position wrapped in a NFT // // # Arguments @@ -179,6 +180,7 @@ var ( // Instruction_OpenPosition = ag_binary.TypeID([8]byte{135, 128, 47, 77, 15, 152, 240, 49}) + // #[deprecated(note = "Use `open_position_with_token22_nft` instead.")] // Creates a new position wrapped in a NFT, support Token2022 // // # Arguments @@ -188,14 +190,32 @@ var ( // * `tick_upper_index` - The upper boundary of market // * `tick_array_lower_start_index` - The start index of tick array which include tick low // * `tick_array_upper_start_index` - The start index of tick array which include tick upper - // * `liquidity` - The liquidity to be added, if zero, calculate liquidity base amount_0_max or amount_1_max according base_flag + // * `liquidity` - The liquidity to be added, if zero, and the base_flage is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidity // * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check // * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check - // * `base_flag` - must be special if liquidity is zero, false: calculate liquidity base amount_0_max otherwise base amount_1_max + // * `with_metadata` - The flag indicating whether to create NFT mint metadata + // * `base_flag` - if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max // Instruction_OpenPositionV2 = ag_binary.TypeID([8]byte{77, 184, 74, 214, 112, 86, 241, 199}) - // Close a position, the nft mint and nft account + // Creates a new position wrapped in a Token2022 NFT without relying on metadata_program and metadata_account, reduce the cost for user to create a personal position. + // + // # Arguments + // + // * `ctx` - The context of accounts + // * `tick_lower_index` - The low boundary of market + // * `tick_upper_index` - The upper boundary of market + // * `tick_array_lower_start_index` - The start index of tick array which include tick low + // * `tick_array_upper_start_index` - The start index of tick array which include tick upper + // * `liquidity` - The liquidity to be added, if zero, and the base_flage is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidity + // * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check + // * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check + // * `with_metadata` - The flag indicating whether to create NFT mint metadata + // * `base_flag` - if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max + // + Instruction_OpenPositionWithToken22Nft = ag_binary.TypeID([8]byte{77, 255, 174, 82, 125, 29, 201, 46}) + + // Close the user's position and NFT account. If the NFT mint belongs to token2022, it will also be closed and the funds returned to the NFT owner. // // # Arguments // @@ -203,6 +223,7 @@ var ( // Instruction_ClosePosition = ag_binary.TypeID([8]byte{123, 134, 81, 0, 49, 68, 98, 98}) + // #[deprecated(note = "Use `increase_liquidity_v2` instead.")] // Increases liquidity with a exist position, with amount paid by `payer` // // # Arguments @@ -222,10 +243,11 @@ var ( // * `liquidity` - The desired liquidity to be added, if zero, calculate liquidity base amount_0 or amount_1 according base_flag // * `amount_0_max` - The max amount of token_0 to spend, which serves as a slippage check // * `amount_1_max` - The max amount of token_1 to spend, which serves as a slippage check - // * `base_flag` - active if liquidity is zero, 0: calculate liquidity base amount_0_max otherwise base amount_1_max + // * `base_flag` - must be specified if liquidity is zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max // Instruction_IncreaseLiquidityV2 = ag_binary.TypeID([8]byte{133, 29, 89, 223, 69, 238, 176, 10}) + // #[deprecated(note = "Use `decrease_liquidity_v2` instead.")] // Decreases liquidity with a exist position // // # Arguments @@ -248,6 +270,7 @@ var ( // Instruction_DecreaseLiquidityV2 = ag_binary.TypeID([8]byte{58, 127, 188, 62, 79, 82, 196, 96}) + // #[deprecated(note = "Use `swap_v2` instead.")] // Swaps one token for as much as possible of another token across a single pool // // # Arguments @@ -316,6 +339,8 @@ func InstructionIDToName(id ag_binary.TypeID) string { return "OpenPosition" case Instruction_OpenPositionV2: return "OpenPositionV2" + case Instruction_OpenPositionWithToken22Nft: + return "OpenPositionWithToken22Nft" case Instruction_ClosePosition: return "ClosePosition" case Instruction_IncreaseLiquidity: @@ -397,6 +422,9 @@ var InstructionImplDef = ag_binary.NewVariantDefinition( { "open_position_v2", (*OpenPositionV2)(nil), }, + { + "open_position_with_token22_nft", (*OpenPositionWithToken22Nft)(nil), + }, { "close_position", (*ClosePosition)(nil), }, diff --git a/programs/raydium_clmm/testing_utils.go b/programs/raydium_clmm/testing_utils.go new file mode 100644 index 000000000..20d8f2e98 --- /dev/null +++ b/programs/raydium_clmm/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_clmm + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/raydiumclmm/types.go b/programs/raydium_clmm/types.go similarity index 94% rename from programs/raydiumclmm/types.go rename to programs/raydium_clmm/types.go index 01938cbf6..de571a329 100644 --- a/programs/raydiumclmm/types.go +++ b/programs/raydium_clmm/types.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_clmm import ( ag_binary "github.com/gagliardetto/binary" @@ -60,14 +60,11 @@ type Observation struct { // The block timestamp of the observation BlockTimestamp uint32 - // the price of the observation timestamp, Q64.64 - SqrtPriceX64 ag_binary.Uint128 - - // the cumulative of price during the duration time, Q64.64 - CumulativeTimePriceX64 ag_binary.Uint128 + // the cumulative of tick during the duration time + TickCumulative int64 // padding for feature update - Padding ag_binary.Uint128 + Padding [4]uint64 } func (obj Observation) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { @@ -76,13 +73,8 @@ func (obj Observation) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error if err != nil { return err } - // Serialize `SqrtPriceX64` param: - err = encoder.Encode(obj.SqrtPriceX64) - if err != nil { - return err - } - // Serialize `CumulativeTimePriceX64` param: - err = encoder.Encode(obj.CumulativeTimePriceX64) + // Serialize `TickCumulative` param: + err = encoder.Encode(obj.TickCumulative) if err != nil { return err } @@ -100,13 +92,8 @@ func (obj *Observation) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err er if err != nil { return err } - // Deserialize `SqrtPriceX64`: - err = decoder.Decode(&obj.SqrtPriceX64) - if err != nil { - return err - } - // Deserialize `CumulativeTimePriceX64`: - err = decoder.Decode(&obj.CumulativeTimePriceX64) + // Deserialize `TickCumulative`: + err = decoder.Decode(&obj.TickCumulative) if err != nil { return err } diff --git a/programs/raydium_cp/CollectFundFee.go b/programs/raydium_cp/CollectFundFee.go new file mode 100644 index 000000000..21dd1cbff --- /dev/null +++ b/programs/raydium_cp/CollectFundFee.go @@ -0,0 +1,399 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Collect the fund fee accrued to the pool +// +// # Arguments +// +// * `ctx` - The context of accounts +// * `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1 +// * `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0 +// +type CollectFundFee struct { + Amount0Requested *uint64 + Amount1Requested *uint64 + + // [0] = [SIGNER] owner + // ··········· Only admin or fund_owner can collect fee now + // + // [1] = [] authority + // + // [2] = [WRITE] poolState + // ··········· Pool state stores accumulated protocol fee amount + // + // [3] = [] ammConfig + // ··········· Amm config account stores fund_owner + // + // [4] = [WRITE] token0Vault + // ··········· The address that holds pool tokens for token_0 + // + // [5] = [WRITE] token1Vault + // ··········· The address that holds pool tokens for token_1 + // + // [6] = [] vault0Mint + // ··········· The mint of token_0 vault + // + // [7] = [] vault1Mint + // ··········· The mint of token_1 vault + // + // [8] = [WRITE] recipientToken0Account + // ··········· The address that receives the collected token_0 fund fees + // + // [9] = [WRITE] recipientToken1Account + // ··········· The address that receives the collected token_1 fund fees + // + // [10] = [] tokenProgram + // ··········· The SPL program to perform token transfers + // + // [11] = [] tokenProgram2022 + // ··········· The SPL program 2022 to perform token transfers + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCollectFundFeeInstructionBuilder creates a new `CollectFundFee` instruction builder. +func NewCollectFundFeeInstructionBuilder() *CollectFundFee { + nd := &CollectFundFee{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetAmount0Requested sets the "amount0Requested" parameter. +func (inst *CollectFundFee) SetAmount0Requested(amount0Requested uint64) *CollectFundFee { + inst.Amount0Requested = &amount0Requested + return inst +} + +// SetAmount1Requested sets the "amount1Requested" parameter. +func (inst *CollectFundFee) SetAmount1Requested(amount1Requested uint64) *CollectFundFee { + inst.Amount1Requested = &amount1Requested + return inst +} + +// SetOwnerAccount sets the "owner" account. +// Only admin or fund_owner can collect fee now +func (inst *CollectFundFee) SetOwnerAccount(owner ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// Only admin or fund_owner can collect fee now +func (inst *CollectFundFee) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *CollectFundFee) SetAuthorityAccount(authority ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *CollectFundFee) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolStateAccount sets the "poolState" account. +// Pool state stores accumulated protocol fee amount +func (inst *CollectFundFee) SetPoolStateAccount(poolState ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[2] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// Pool state stores accumulated protocol fee amount +func (inst *CollectFundFee) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// Amm config account stores fund_owner +func (inst *CollectFundFee) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[3] = ag_solanago.Meta(ammConfig) + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// Amm config account stores fund_owner +func (inst *CollectFundFee) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetToken0VaultAccount sets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *CollectFundFee) SetToken0VaultAccount(token0Vault ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[4] = ag_solanago.Meta(token0Vault).WRITE() + return inst +} + +// GetToken0VaultAccount gets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *CollectFundFee) GetToken0VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetToken1VaultAccount sets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *CollectFundFee) SetToken1VaultAccount(token1Vault ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[5] = ag_solanago.Meta(token1Vault).WRITE() + return inst +} + +// GetToken1VaultAccount gets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *CollectFundFee) GetToken1VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetVault0MintAccount sets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *CollectFundFee) SetVault0MintAccount(vault0Mint ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[6] = ag_solanago.Meta(vault0Mint) + return inst +} + +// GetVault0MintAccount gets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *CollectFundFee) GetVault0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetVault1MintAccount sets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *CollectFundFee) SetVault1MintAccount(vault1Mint ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[7] = ag_solanago.Meta(vault1Mint) + return inst +} + +// GetVault1MintAccount gets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *CollectFundFee) GetVault1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetRecipientToken0AccountAccount sets the "recipientToken0Account" account. +// The address that receives the collected token_0 fund fees +func (inst *CollectFundFee) SetRecipientToken0AccountAccount(recipientToken0Account ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[8] = ag_solanago.Meta(recipientToken0Account).WRITE() + return inst +} + +// GetRecipientToken0AccountAccount gets the "recipientToken0Account" account. +// The address that receives the collected token_0 fund fees +func (inst *CollectFundFee) GetRecipientToken0AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetRecipientToken1AccountAccount sets the "recipientToken1Account" account. +// The address that receives the collected token_1 fund fees +func (inst *CollectFundFee) SetRecipientToken1AccountAccount(recipientToken1Account ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[9] = ag_solanago.Meta(recipientToken1Account).WRITE() + return inst +} + +// GetRecipientToken1AccountAccount gets the "recipientToken1Account" account. +// The address that receives the collected token_1 fund fees +func (inst *CollectFundFee) GetRecipientToken1AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// The SPL program to perform token transfers +func (inst *CollectFundFee) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// The SPL program to perform token transfers +func (inst *CollectFundFee) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetTokenProgram2022Account sets the "tokenProgram2022" account. +// The SPL program 2022 to perform token transfers +func (inst *CollectFundFee) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *CollectFundFee { + inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram2022) + return inst +} + +// GetTokenProgram2022Account gets the "tokenProgram2022" account. +// The SPL program 2022 to perform token transfers +func (inst *CollectFundFee) GetTokenProgram2022Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst CollectFundFee) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CollectFundFee, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CollectFundFee) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CollectFundFee) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount0Requested == nil { + return errors.New("Amount0Requested parameter is not set") + } + if inst.Amount1Requested == nil { + return errors.New("Amount1Requested parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Token0Vault is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Token1Vault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Vault0Mint is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Vault1Mint is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.RecipientToken0Account is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.RecipientToken1Account is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.TokenProgram2022 is not set") + } + } + return nil +} + +func (inst *CollectFundFee) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CollectFundFee")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Amount0Requested", *inst.Amount0Requested)) + paramsBranch.Child(ag_format.Param("Amount1Requested", *inst.Amount1Requested)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" token0Vault", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" token1Vault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" vault0Mint", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" vault1Mint", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" recipientToken0", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" recipientToken1", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta("tokenProgram2022", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj CollectFundFee) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount0Requested` param: + err = encoder.Encode(obj.Amount0Requested) + if err != nil { + return err + } + // Serialize `Amount1Requested` param: + err = encoder.Encode(obj.Amount1Requested) + if err != nil { + return err + } + return nil +} +func (obj *CollectFundFee) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount0Requested`: + err = decoder.Decode(&obj.Amount0Requested) + if err != nil { + return err + } + // Deserialize `Amount1Requested`: + err = decoder.Decode(&obj.Amount1Requested) + if err != nil { + return err + } + return nil +} + +// NewCollectFundFeeInstruction declares a new CollectFundFee instruction with the provided parameters and accounts. +func NewCollectFundFeeInstruction( + // Parameters: + amount0Requested uint64, + amount1Requested uint64, + // Accounts: + owner ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + token0Vault ag_solanago.PublicKey, + token1Vault ag_solanago.PublicKey, + vault0Mint ag_solanago.PublicKey, + vault1Mint ag_solanago.PublicKey, + recipientToken0Account ag_solanago.PublicKey, + recipientToken1Account ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + tokenProgram2022 ag_solanago.PublicKey) *CollectFundFee { + return NewCollectFundFeeInstructionBuilder(). + SetAmount0Requested(amount0Requested). + SetAmount1Requested(amount1Requested). + SetOwnerAccount(owner). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState). + SetAmmConfigAccount(ammConfig). + SetToken0VaultAccount(token0Vault). + SetToken1VaultAccount(token1Vault). + SetVault0MintAccount(vault0Mint). + SetVault1MintAccount(vault1Mint). + SetRecipientToken0AccountAccount(recipientToken0Account). + SetRecipientToken1AccountAccount(recipientToken1Account). + SetTokenProgramAccount(tokenProgram). + SetTokenProgram2022Account(tokenProgram2022) +} diff --git a/programs/raydiumclmm/CollectFundFee_test.go b/programs/raydium_cp/CollectFundFee_test.go similarity index 97% rename from programs/raydiumclmm/CollectFundFee_test.go rename to programs/raydium_cp/CollectFundFee_test.go index 2cd055456..97d6025b0 100644 --- a/programs/raydiumclmm/CollectFundFee_test.go +++ b/programs/raydium_cp/CollectFundFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "bytes" diff --git a/programs/raydium_cp/CollectProtocolFee.go b/programs/raydium_cp/CollectProtocolFee.go new file mode 100644 index 000000000..8784567d5 --- /dev/null +++ b/programs/raydium_cp/CollectProtocolFee.go @@ -0,0 +1,399 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Collect the protocol fee accrued to the pool +// +// # Arguments +// +// * `ctx` - The context of accounts +// * `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1 +// * `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0 +// +type CollectProtocolFee struct { + Amount0Requested *uint64 + Amount1Requested *uint64 + + // [0] = [SIGNER] owner + // ··········· Only admin or owner can collect fee now + // + // [1] = [] authority + // + // [2] = [WRITE] poolState + // ··········· Pool state stores accumulated protocol fee amount + // + // [3] = [] ammConfig + // ··········· Amm config account stores owner + // + // [4] = [WRITE] token0Vault + // ··········· The address that holds pool tokens for token_0 + // + // [5] = [WRITE] token1Vault + // ··········· The address that holds pool tokens for token_1 + // + // [6] = [] vault0Mint + // ··········· The mint of token_0 vault + // + // [7] = [] vault1Mint + // ··········· The mint of token_1 vault + // + // [8] = [WRITE] recipientToken0Account + // ··········· The address that receives the collected token_0 protocol fees + // + // [9] = [WRITE] recipientToken1Account + // ··········· The address that receives the collected token_1 protocol fees + // + // [10] = [] tokenProgram + // ··········· The SPL program to perform token transfers + // + // [11] = [] tokenProgram2022 + // ··········· The SPL program 2022 to perform token transfers + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCollectProtocolFeeInstructionBuilder creates a new `CollectProtocolFee` instruction builder. +func NewCollectProtocolFeeInstructionBuilder() *CollectProtocolFee { + nd := &CollectProtocolFee{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + } + return nd +} + +// SetAmount0Requested sets the "amount0Requested" parameter. +func (inst *CollectProtocolFee) SetAmount0Requested(amount0Requested uint64) *CollectProtocolFee { + inst.Amount0Requested = &amount0Requested + return inst +} + +// SetAmount1Requested sets the "amount1Requested" parameter. +func (inst *CollectProtocolFee) SetAmount1Requested(amount1Requested uint64) *CollectProtocolFee { + inst.Amount1Requested = &amount1Requested + return inst +} + +// SetOwnerAccount sets the "owner" account. +// Only admin or owner can collect fee now +func (inst *CollectProtocolFee) SetOwnerAccount(owner ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// Only admin or owner can collect fee now +func (inst *CollectProtocolFee) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *CollectProtocolFee) SetAuthorityAccount(authority ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *CollectProtocolFee) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolStateAccount sets the "poolState" account. +// Pool state stores accumulated protocol fee amount +func (inst *CollectProtocolFee) SetPoolStateAccount(poolState ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[2] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// Pool state stores accumulated protocol fee amount +func (inst *CollectProtocolFee) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// Amm config account stores owner +func (inst *CollectProtocolFee) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[3] = ag_solanago.Meta(ammConfig) + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// Amm config account stores owner +func (inst *CollectProtocolFee) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetToken0VaultAccount sets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *CollectProtocolFee) SetToken0VaultAccount(token0Vault ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[4] = ag_solanago.Meta(token0Vault).WRITE() + return inst +} + +// GetToken0VaultAccount gets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *CollectProtocolFee) GetToken0VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetToken1VaultAccount sets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *CollectProtocolFee) SetToken1VaultAccount(token1Vault ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[5] = ag_solanago.Meta(token1Vault).WRITE() + return inst +} + +// GetToken1VaultAccount gets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *CollectProtocolFee) GetToken1VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetVault0MintAccount sets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *CollectProtocolFee) SetVault0MintAccount(vault0Mint ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[6] = ag_solanago.Meta(vault0Mint) + return inst +} + +// GetVault0MintAccount gets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *CollectProtocolFee) GetVault0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetVault1MintAccount sets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *CollectProtocolFee) SetVault1MintAccount(vault1Mint ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[7] = ag_solanago.Meta(vault1Mint) + return inst +} + +// GetVault1MintAccount gets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *CollectProtocolFee) GetVault1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetRecipientToken0AccountAccount sets the "recipientToken0Account" account. +// The address that receives the collected token_0 protocol fees +func (inst *CollectProtocolFee) SetRecipientToken0AccountAccount(recipientToken0Account ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[8] = ag_solanago.Meta(recipientToken0Account).WRITE() + return inst +} + +// GetRecipientToken0AccountAccount gets the "recipientToken0Account" account. +// The address that receives the collected token_0 protocol fees +func (inst *CollectProtocolFee) GetRecipientToken0AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetRecipientToken1AccountAccount sets the "recipientToken1Account" account. +// The address that receives the collected token_1 protocol fees +func (inst *CollectProtocolFee) SetRecipientToken1AccountAccount(recipientToken1Account ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[9] = ag_solanago.Meta(recipientToken1Account).WRITE() + return inst +} + +// GetRecipientToken1AccountAccount gets the "recipientToken1Account" account. +// The address that receives the collected token_1 protocol fees +func (inst *CollectProtocolFee) GetRecipientToken1AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// The SPL program to perform token transfers +func (inst *CollectProtocolFee) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[10] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// The SPL program to perform token transfers +func (inst *CollectProtocolFee) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetTokenProgram2022Account sets the "tokenProgram2022" account. +// The SPL program 2022 to perform token transfers +func (inst *CollectProtocolFee) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *CollectProtocolFee { + inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram2022) + return inst +} + +// GetTokenProgram2022Account gets the "tokenProgram2022" account. +// The SPL program 2022 to perform token transfers +func (inst *CollectProtocolFee) GetTokenProgram2022Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +func (inst CollectProtocolFee) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CollectProtocolFee, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CollectProtocolFee) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CollectProtocolFee) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount0Requested == nil { + return errors.New("Amount0Requested parameter is not set") + } + if inst.Amount1Requested == nil { + return errors.New("Amount1Requested parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Token0Vault is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Token1Vault is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Vault0Mint is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Vault1Mint is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.RecipientToken0Account is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.RecipientToken1Account is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.TokenProgram2022 is not set") + } + } + return nil +} + +func (inst *CollectProtocolFee) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CollectProtocolFee")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Amount0Requested", *inst.Amount0Requested)) + paramsBranch.Child(ag_format.Param("Amount1Requested", *inst.Amount1Requested)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" token0Vault", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" token1Vault", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" vault0Mint", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" vault1Mint", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" recipientToken0", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" recipientToken1", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta("tokenProgram2022", inst.AccountMetaSlice.Get(11))) + }) + }) + }) +} + +func (obj CollectProtocolFee) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount0Requested` param: + err = encoder.Encode(obj.Amount0Requested) + if err != nil { + return err + } + // Serialize `Amount1Requested` param: + err = encoder.Encode(obj.Amount1Requested) + if err != nil { + return err + } + return nil +} +func (obj *CollectProtocolFee) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount0Requested`: + err = decoder.Decode(&obj.Amount0Requested) + if err != nil { + return err + } + // Deserialize `Amount1Requested`: + err = decoder.Decode(&obj.Amount1Requested) + if err != nil { + return err + } + return nil +} + +// NewCollectProtocolFeeInstruction declares a new CollectProtocolFee instruction with the provided parameters and accounts. +func NewCollectProtocolFeeInstruction( + // Parameters: + amount0Requested uint64, + amount1Requested uint64, + // Accounts: + owner ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + token0Vault ag_solanago.PublicKey, + token1Vault ag_solanago.PublicKey, + vault0Mint ag_solanago.PublicKey, + vault1Mint ag_solanago.PublicKey, + recipientToken0Account ag_solanago.PublicKey, + recipientToken1Account ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + tokenProgram2022 ag_solanago.PublicKey) *CollectProtocolFee { + return NewCollectProtocolFeeInstructionBuilder(). + SetAmount0Requested(amount0Requested). + SetAmount1Requested(amount1Requested). + SetOwnerAccount(owner). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState). + SetAmmConfigAccount(ammConfig). + SetToken0VaultAccount(token0Vault). + SetToken1VaultAccount(token1Vault). + SetVault0MintAccount(vault0Mint). + SetVault1MintAccount(vault1Mint). + SetRecipientToken0AccountAccount(recipientToken0Account). + SetRecipientToken1AccountAccount(recipientToken1Account). + SetTokenProgramAccount(tokenProgram). + SetTokenProgram2022Account(tokenProgram2022) +} diff --git a/programs/raydiumclmm/CollectProtocolFee_test.go b/programs/raydium_cp/CollectProtocolFee_test.go similarity index 97% rename from programs/raydiumclmm/CollectProtocolFee_test.go rename to programs/raydium_cp/CollectProtocolFee_test.go index d6f81231c..695a5547e 100644 --- a/programs/raydiumclmm/CollectProtocolFee_test.go +++ b/programs/raydium_cp/CollectProtocolFee_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "bytes" diff --git a/programs/raydium_cp/CreateAmmConfig.go b/programs/raydium_cp/CreateAmmConfig.go new file mode 100644 index 000000000..ee17bc13c --- /dev/null +++ b/programs/raydium_cp/CreateAmmConfig.go @@ -0,0 +1,270 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// # Arguments +// +// * `ctx`- The accounts needed by instruction. +// * `index` - The index of amm config, there may be multiple config. +// * `trade_fee_rate` - Trade fee rate, can be changed. +// * `protocol_fee_rate` - The rate of protocol fee within tarde fee. +// * `fund_fee_rate` - The rate of fund fee within tarde fee. +// +type CreateAmmConfig struct { + Index *uint16 + TradeFeeRate *uint64 + ProtocolFeeRate *uint64 + FundFeeRate *uint64 + CreatePoolFee *uint64 + + // [0] = [WRITE, SIGNER] owner + // ··········· Address to be set as protocol owner. + // + // [1] = [WRITE] ammConfig + // ··········· Initialize config state account to store protocol owner address and fee rates. + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCreateAmmConfigInstructionBuilder creates a new `CreateAmmConfig` instruction builder. +func NewCreateAmmConfigInstructionBuilder() *CreateAmmConfig { + nd := &CreateAmmConfig{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetIndex sets the "index" parameter. +func (inst *CreateAmmConfig) SetIndex(index uint16) *CreateAmmConfig { + inst.Index = &index + return inst +} + +// SetTradeFeeRate sets the "tradeFeeRate" parameter. +func (inst *CreateAmmConfig) SetTradeFeeRate(tradeFeeRate uint64) *CreateAmmConfig { + inst.TradeFeeRate = &tradeFeeRate + return inst +} + +// SetProtocolFeeRate sets the "protocolFeeRate" parameter. +func (inst *CreateAmmConfig) SetProtocolFeeRate(protocolFeeRate uint64) *CreateAmmConfig { + inst.ProtocolFeeRate = &protocolFeeRate + return inst +} + +// SetFundFeeRate sets the "fundFeeRate" parameter. +func (inst *CreateAmmConfig) SetFundFeeRate(fundFeeRate uint64) *CreateAmmConfig { + inst.FundFeeRate = &fundFeeRate + return inst +} + +// SetCreatePoolFee sets the "createPoolFee" parameter. +func (inst *CreateAmmConfig) SetCreatePoolFee(createPoolFee uint64) *CreateAmmConfig { + inst.CreatePoolFee = &createPoolFee + return inst +} + +// SetOwnerAccount sets the "owner" account. +// Address to be set as protocol owner. +func (inst *CreateAmmConfig) SetOwnerAccount(owner ag_solanago.PublicKey) *CreateAmmConfig { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).WRITE().SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// Address to be set as protocol owner. +func (inst *CreateAmmConfig) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// Initialize config state account to store protocol owner address and fee rates. +func (inst *CreateAmmConfig) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *CreateAmmConfig { + inst.AccountMetaSlice[1] = ag_solanago.Meta(ammConfig).WRITE() + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// Initialize config state account to store protocol owner address and fee rates. +func (inst *CreateAmmConfig) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *CreateAmmConfig) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *CreateAmmConfig { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *CreateAmmConfig) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst CreateAmmConfig) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CreateAmmConfig, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CreateAmmConfig) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CreateAmmConfig) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Index == nil { + return errors.New("Index parameter is not set") + } + if inst.TradeFeeRate == nil { + return errors.New("TradeFeeRate parameter is not set") + } + if inst.ProtocolFeeRate == nil { + return errors.New("ProtocolFeeRate parameter is not set") + } + if inst.FundFeeRate == nil { + return errors.New("FundFeeRate parameter is not set") + } + if inst.CreatePoolFee == nil { + return errors.New("CreatePoolFee parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *CreateAmmConfig) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CreateAmmConfig")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=5]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Index", *inst.Index)) + paramsBranch.Child(ag_format.Param(" TradeFeeRate", *inst.TradeFeeRate)) + paramsBranch.Child(ag_format.Param("ProtocolFeeRate", *inst.ProtocolFeeRate)) + paramsBranch.Child(ag_format.Param(" FundFeeRate", *inst.FundFeeRate)) + paramsBranch.Child(ag_format.Param(" CreatePoolFee", *inst.CreatePoolFee)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj CreateAmmConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `TradeFeeRate` param: + err = encoder.Encode(obj.TradeFeeRate) + if err != nil { + return err + } + // Serialize `ProtocolFeeRate` param: + err = encoder.Encode(obj.ProtocolFeeRate) + if err != nil { + return err + } + // Serialize `FundFeeRate` param: + err = encoder.Encode(obj.FundFeeRate) + if err != nil { + return err + } + // Serialize `CreatePoolFee` param: + err = encoder.Encode(obj.CreatePoolFee) + if err != nil { + return err + } + return nil +} +func (obj *CreateAmmConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `TradeFeeRate`: + err = decoder.Decode(&obj.TradeFeeRate) + if err != nil { + return err + } + // Deserialize `ProtocolFeeRate`: + err = decoder.Decode(&obj.ProtocolFeeRate) + if err != nil { + return err + } + // Deserialize `FundFeeRate`: + err = decoder.Decode(&obj.FundFeeRate) + if err != nil { + return err + } + // Deserialize `CreatePoolFee`: + err = decoder.Decode(&obj.CreatePoolFee) + if err != nil { + return err + } + return nil +} + +// NewCreateAmmConfigInstruction declares a new CreateAmmConfig instruction with the provided parameters and accounts. +func NewCreateAmmConfigInstruction( + // Parameters: + index uint16, + tradeFeeRate uint64, + protocolFeeRate uint64, + fundFeeRate uint64, + createPoolFee uint64, + // Accounts: + owner ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *CreateAmmConfig { + return NewCreateAmmConfigInstructionBuilder(). + SetIndex(index). + SetTradeFeeRate(tradeFeeRate). + SetProtocolFeeRate(protocolFeeRate). + SetFundFeeRate(fundFeeRate). + SetCreatePoolFee(createPoolFee). + SetOwnerAccount(owner). + SetAmmConfigAccount(ammConfig). + SetSystemProgramAccount(systemProgram) +} diff --git a/programs/raydiumclmm/CreateAmmConfig_test.go b/programs/raydium_cp/CreateAmmConfig_test.go similarity index 97% rename from programs/raydiumclmm/CreateAmmConfig_test.go rename to programs/raydium_cp/CreateAmmConfig_test.go index 4d42f02a1..c6b18ce2b 100644 --- a/programs/raydiumclmm/CreateAmmConfig_test.go +++ b/programs/raydium_cp/CreateAmmConfig_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "bytes" diff --git a/programs/raydium_cp/Deposit.go b/programs/raydium_cp/Deposit.go new file mode 100644 index 000000000..c72c42b4b --- /dev/null +++ b/programs/raydium_cp/Deposit.go @@ -0,0 +1,442 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Creates a pool for the given token pair and the initial price +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `lp_token_amount` - Pool token amount to transfer. token_a and token_b amount are set by the current exchange rate and size of the pool +// * `maximum_token_0_amount` - Maximum token 0 amount to deposit, prevents excessive slippage +// * `maximum_token_1_amount` - Maximum token 1 amount to deposit, prevents excessive slippage +// +type Deposit struct { + LpTokenAmount *uint64 + MaximumToken0Amount *uint64 + MaximumToken1Amount *uint64 + + // [0] = [SIGNER] owner + // ··········· Pays to mint the position + // + // [1] = [] authority + // + // [2] = [WRITE] poolState + // + // [3] = [WRITE] ownerLpToken + // ··········· Owner lp tokan account + // + // [4] = [WRITE] token0Account + // ··········· The payer's token account for token_0 + // + // [5] = [WRITE] token1Account + // ··········· The payer's token account for token_1 + // + // [6] = [WRITE] token0Vault + // ··········· The address that holds pool tokens for token_0 + // + // [7] = [WRITE] token1Vault + // ··········· The address that holds pool tokens for token_1 + // + // [8] = [] tokenProgram + // ··········· token Program + // + // [9] = [] tokenProgram2022 + // ··········· Token program 2022 + // + // [10] = [] vault0Mint + // ··········· The mint of token_0 vault + // + // [11] = [] vault1Mint + // ··········· The mint of token_1 vault + // + // [12] = [WRITE] lpMint + // ··········· Lp token mint + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositInstructionBuilder creates a new `Deposit` instruction builder. +func NewDepositInstructionBuilder() *Deposit { + nd := &Deposit{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13), + } + return nd +} + +// SetLpTokenAmount sets the "lpTokenAmount" parameter. +func (inst *Deposit) SetLpTokenAmount(lpTokenAmount uint64) *Deposit { + inst.LpTokenAmount = &lpTokenAmount + return inst +} + +// SetMaximumToken0Amount sets the "maximumToken0Amount" parameter. +func (inst *Deposit) SetMaximumToken0Amount(maximumToken0Amount uint64) *Deposit { + inst.MaximumToken0Amount = &maximumToken0Amount + return inst +} + +// SetMaximumToken1Amount sets the "maximumToken1Amount" parameter. +func (inst *Deposit) SetMaximumToken1Amount(maximumToken1Amount uint64) *Deposit { + inst.MaximumToken1Amount = &maximumToken1Amount + return inst +} + +// SetOwnerAccount sets the "owner" account. +// Pays to mint the position +func (inst *Deposit) SetOwnerAccount(owner ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// Pays to mint the position +func (inst *Deposit) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Deposit) SetAuthorityAccount(authority ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Deposit) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolStateAccount sets the "poolState" account. +func (inst *Deposit) SetPoolStateAccount(poolState ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[2] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +func (inst *Deposit) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetOwnerLpTokenAccount sets the "ownerLpToken" account. +// Owner lp tokan account +func (inst *Deposit) SetOwnerLpTokenAccount(ownerLpToken ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[3] = ag_solanago.Meta(ownerLpToken).WRITE() + return inst +} + +// GetOwnerLpTokenAccount gets the "ownerLpToken" account. +// Owner lp tokan account +func (inst *Deposit) GetOwnerLpTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetToken0AccountAccount sets the "token0Account" account. +// The payer's token account for token_0 +func (inst *Deposit) SetToken0AccountAccount(token0Account ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[4] = ag_solanago.Meta(token0Account).WRITE() + return inst +} + +// GetToken0AccountAccount gets the "token0Account" account. +// The payer's token account for token_0 +func (inst *Deposit) GetToken0AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetToken1AccountAccount sets the "token1Account" account. +// The payer's token account for token_1 +func (inst *Deposit) SetToken1AccountAccount(token1Account ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[5] = ag_solanago.Meta(token1Account).WRITE() + return inst +} + +// GetToken1AccountAccount gets the "token1Account" account. +// The payer's token account for token_1 +func (inst *Deposit) GetToken1AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetToken0VaultAccount sets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *Deposit) SetToken0VaultAccount(token0Vault ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[6] = ag_solanago.Meta(token0Vault).WRITE() + return inst +} + +// GetToken0VaultAccount gets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *Deposit) GetToken0VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetToken1VaultAccount sets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *Deposit) SetToken1VaultAccount(token1Vault ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[7] = ag_solanago.Meta(token1Vault).WRITE() + return inst +} + +// GetToken1VaultAccount gets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *Deposit) GetToken1VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token Program +func (inst *Deposit) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token Program +func (inst *Deposit) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgram2022Account sets the "tokenProgram2022" account. +// Token program 2022 +func (inst *Deposit) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram2022) + return inst +} + +// GetTokenProgram2022Account gets the "tokenProgram2022" account. +// Token program 2022 +func (inst *Deposit) GetTokenProgram2022Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetVault0MintAccount sets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *Deposit) SetVault0MintAccount(vault0Mint ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[10] = ag_solanago.Meta(vault0Mint) + return inst +} + +// GetVault0MintAccount gets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *Deposit) GetVault0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetVault1MintAccount sets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *Deposit) SetVault1MintAccount(vault1Mint ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[11] = ag_solanago.Meta(vault1Mint) + return inst +} + +// GetVault1MintAccount gets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *Deposit) GetVault1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetLpMintAccount sets the "lpMint" account. +// Lp token mint +func (inst *Deposit) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[12] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// Lp token mint +func (inst *Deposit) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +func (inst Deposit) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Deposit, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Deposit) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Deposit) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.LpTokenAmount == nil { + return errors.New("LpTokenAmount parameter is not set") + } + if inst.MaximumToken0Amount == nil { + return errors.New("MaximumToken0Amount parameter is not set") + } + if inst.MaximumToken1Amount == nil { + return errors.New("MaximumToken1Amount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.OwnerLpToken is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Token0Account is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Token1Account is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Token0Vault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Token1Vault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram2022 is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.Vault0Mint is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Vault1Mint is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.LpMint is not set") + } + } + return nil +} + +func (inst *Deposit) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Deposit")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" LpTokenAmount", *inst.LpTokenAmount)) + paramsBranch.Child(ag_format.Param("MaximumToken0Amount", *inst.MaximumToken0Amount)) + paramsBranch.Child(ag_format.Param("MaximumToken1Amount", *inst.MaximumToken1Amount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ownerLpToken", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" token0", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" token1", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" token0Vault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" token1Vault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta("tokenProgram2022", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" vault0Mint", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" vault1Mint", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(12))) + }) + }) + }) +} + +func (obj Deposit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `LpTokenAmount` param: + err = encoder.Encode(obj.LpTokenAmount) + if err != nil { + return err + } + // Serialize `MaximumToken0Amount` param: + err = encoder.Encode(obj.MaximumToken0Amount) + if err != nil { + return err + } + // Serialize `MaximumToken1Amount` param: + err = encoder.Encode(obj.MaximumToken1Amount) + if err != nil { + return err + } + return nil +} +func (obj *Deposit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `LpTokenAmount`: + err = decoder.Decode(&obj.LpTokenAmount) + if err != nil { + return err + } + // Deserialize `MaximumToken0Amount`: + err = decoder.Decode(&obj.MaximumToken0Amount) + if err != nil { + return err + } + // Deserialize `MaximumToken1Amount`: + err = decoder.Decode(&obj.MaximumToken1Amount) + if err != nil { + return err + } + return nil +} + +// NewDepositInstruction declares a new Deposit instruction with the provided parameters and accounts. +func NewDepositInstruction( + // Parameters: + lpTokenAmount uint64, + maximumToken0Amount uint64, + maximumToken1Amount uint64, + // Accounts: + owner ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + ownerLpToken ag_solanago.PublicKey, + token0Account ag_solanago.PublicKey, + token1Account ag_solanago.PublicKey, + token0Vault ag_solanago.PublicKey, + token1Vault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + tokenProgram2022 ag_solanago.PublicKey, + vault0Mint ag_solanago.PublicKey, + vault1Mint ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey) *Deposit { + return NewDepositInstructionBuilder(). + SetLpTokenAmount(lpTokenAmount). + SetMaximumToken0Amount(maximumToken0Amount). + SetMaximumToken1Amount(maximumToken1Amount). + SetOwnerAccount(owner). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState). + SetOwnerLpTokenAccount(ownerLpToken). + SetToken0AccountAccount(token0Account). + SetToken1AccountAccount(token1Account). + SetToken0VaultAccount(token0Vault). + SetToken1VaultAccount(token1Vault). + SetTokenProgramAccount(tokenProgram). + SetTokenProgram2022Account(tokenProgram2022). + SetVault0MintAccount(vault0Mint). + SetVault1MintAccount(vault1Mint). + SetLpMintAccount(lpMint) +} diff --git a/programs/raydium_cp/Deposit_test.go b/programs/raydium_cp/Deposit_test.go new file mode 100644 index 000000000..bd3da1bfc --- /dev/null +++ b/programs/raydium_cp/Deposit_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Deposit(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Deposit"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Deposit) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Deposit) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydium_cp/Initialize.go b/programs/raydium_cp/Initialize.go new file mode 100644 index 000000000..de9fa04dd --- /dev/null +++ b/programs/raydium_cp/Initialize.go @@ -0,0 +1,593 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Creates a pool for the given token pair and the initial price +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `init_amount_0` - the initial amount_0 to deposit +// * `init_amount_1` - the initial amount_1 to deposit +// * `open_time` - the timestamp allowed for swap +// +type Initialize struct { + InitAmount0 *uint64 + InitAmount1 *uint64 + OpenTime *uint64 + + // [0] = [WRITE, SIGNER] creator + // ··········· Address paying to create the pool. Can be anyone + // + // [1] = [] ammConfig + // ··········· Which config the pool belongs to. + // + // [2] = [] authority + // + // [3] = [WRITE] poolState + // ··········· Initialize an account to store the pool state + // + // [4] = [] token0Mint + // ··········· Token_0 mint, the key must smaller then token_1 mint. + // + // [5] = [] token1Mint + // ··········· Token_1 mint, the key must grater then token_0 mint. + // + // [6] = [WRITE] lpMint + // ··········· pool lp mint + // + // [7] = [WRITE] creatorToken0 + // ··········· payer token0 account + // + // [8] = [WRITE] creatorToken1 + // ··········· creator token1 account + // + // [9] = [WRITE] creatorLpToken + // ··········· creator lp token account + // + // [10] = [WRITE] token0Vault + // + // [11] = [WRITE] token1Vault + // + // [12] = [WRITE] createPoolFee + // ··········· create pool fee account + // + // [13] = [WRITE] observationState + // ··········· an account to store oracle observations + // + // [14] = [] tokenProgram + // ··········· Program to create mint account and mint tokens + // + // [15] = [] token0Program + // ··········· Spl token program or token program 2022 + // + // [16] = [] token1Program + // ··········· Spl token program or token program 2022 + // + // [17] = [] associatedTokenProgram + // ··········· Program to create an ATA for receiving position NFT + // + // [18] = [] systemProgram + // ··········· To create a new program account + // + // [19] = [] rent + // ··········· Sysvar for program account + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. +func NewInitializeInstructionBuilder() *Initialize { + nd := &Initialize{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 20), + } + return nd +} + +// SetInitAmount0 sets the "initAmount0" parameter. +func (inst *Initialize) SetInitAmount0(initAmount0 uint64) *Initialize { + inst.InitAmount0 = &initAmount0 + return inst +} + +// SetInitAmount1 sets the "initAmount1" parameter. +func (inst *Initialize) SetInitAmount1(initAmount1 uint64) *Initialize { + inst.InitAmount1 = &initAmount1 + return inst +} + +// SetOpenTime sets the "openTime" parameter. +func (inst *Initialize) SetOpenTime(openTime uint64) *Initialize { + inst.OpenTime = &openTime + return inst +} + +// SetCreatorAccount sets the "creator" account. +// Address paying to create the pool. Can be anyone +func (inst *Initialize) SetCreatorAccount(creator ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[0] = ag_solanago.Meta(creator).WRITE().SIGNER() + return inst +} + +// GetCreatorAccount gets the "creator" account. +// Address paying to create the pool. Can be anyone +func (inst *Initialize) GetCreatorAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// Which config the pool belongs to. +func (inst *Initialize) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[1] = ag_solanago.Meta(ammConfig) + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// Which config the pool belongs to. +func (inst *Initialize) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Initialize) SetAuthorityAccount(authority ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Initialize) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetPoolStateAccount sets the "poolState" account. +// Initialize an account to store the pool state +func (inst *Initialize) SetPoolStateAccount(poolState ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[3] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// Initialize an account to store the pool state +func (inst *Initialize) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetToken0MintAccount sets the "token0Mint" account. +// Token_0 mint, the key must smaller then token_1 mint. +func (inst *Initialize) SetToken0MintAccount(token0Mint ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[4] = ag_solanago.Meta(token0Mint) + return inst +} + +// GetToken0MintAccount gets the "token0Mint" account. +// Token_0 mint, the key must smaller then token_1 mint. +func (inst *Initialize) GetToken0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetToken1MintAccount sets the "token1Mint" account. +// Token_1 mint, the key must grater then token_0 mint. +func (inst *Initialize) SetToken1MintAccount(token1Mint ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[5] = ag_solanago.Meta(token1Mint) + return inst +} + +// GetToken1MintAccount gets the "token1Mint" account. +// Token_1 mint, the key must grater then token_0 mint. +func (inst *Initialize) GetToken1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetLpMintAccount sets the "lpMint" account. +// pool lp mint +func (inst *Initialize) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[6] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// pool lp mint +func (inst *Initialize) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetCreatorToken0Account sets the "creatorToken0" account. +// payer token0 account +func (inst *Initialize) SetCreatorToken0Account(creatorToken0 ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[7] = ag_solanago.Meta(creatorToken0).WRITE() + return inst +} + +// GetCreatorToken0Account gets the "creatorToken0" account. +// payer token0 account +func (inst *Initialize) GetCreatorToken0Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetCreatorToken1Account sets the "creatorToken1" account. +// creator token1 account +func (inst *Initialize) SetCreatorToken1Account(creatorToken1 ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[8] = ag_solanago.Meta(creatorToken1).WRITE() + return inst +} + +// GetCreatorToken1Account gets the "creatorToken1" account. +// creator token1 account +func (inst *Initialize) GetCreatorToken1Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetCreatorLpTokenAccount sets the "creatorLpToken" account. +// creator lp token account +func (inst *Initialize) SetCreatorLpTokenAccount(creatorLpToken ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[9] = ag_solanago.Meta(creatorLpToken).WRITE() + return inst +} + +// GetCreatorLpTokenAccount gets the "creatorLpToken" account. +// creator lp token account +func (inst *Initialize) GetCreatorLpTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetToken0VaultAccount sets the "token0Vault" account. +func (inst *Initialize) SetToken0VaultAccount(token0Vault ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[10] = ag_solanago.Meta(token0Vault).WRITE() + return inst +} + +// GetToken0VaultAccount gets the "token0Vault" account. +func (inst *Initialize) GetToken0VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetToken1VaultAccount sets the "token1Vault" account. +func (inst *Initialize) SetToken1VaultAccount(token1Vault ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[11] = ag_solanago.Meta(token1Vault).WRITE() + return inst +} + +// GetToken1VaultAccount gets the "token1Vault" account. +func (inst *Initialize) GetToken1VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetCreatePoolFeeAccount sets the "createPoolFee" account. +// create pool fee account +func (inst *Initialize) SetCreatePoolFeeAccount(createPoolFee ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[12] = ag_solanago.Meta(createPoolFee).WRITE() + return inst +} + +// GetCreatePoolFeeAccount gets the "createPoolFee" account. +// create pool fee account +func (inst *Initialize) GetCreatePoolFeeAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +// SetObservationStateAccount sets the "observationState" account. +// an account to store oracle observations +func (inst *Initialize) SetObservationStateAccount(observationState ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[13] = ag_solanago.Meta(observationState).WRITE() + return inst +} + +// GetObservationStateAccount gets the "observationState" account. +// an account to store oracle observations +func (inst *Initialize) GetObservationStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(13) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// Program to create mint account and mint tokens +func (inst *Initialize) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[14] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// Program to create mint account and mint tokens +func (inst *Initialize) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(14) +} + +// SetToken0ProgramAccount sets the "token0Program" account. +// Spl token program or token program 2022 +func (inst *Initialize) SetToken0ProgramAccount(token0Program ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[15] = ag_solanago.Meta(token0Program) + return inst +} + +// GetToken0ProgramAccount gets the "token0Program" account. +// Spl token program or token program 2022 +func (inst *Initialize) GetToken0ProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(15) +} + +// SetToken1ProgramAccount sets the "token1Program" account. +// Spl token program or token program 2022 +func (inst *Initialize) SetToken1ProgramAccount(token1Program ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[16] = ag_solanago.Meta(token1Program) + return inst +} + +// GetToken1ProgramAccount gets the "token1Program" account. +// Spl token program or token program 2022 +func (inst *Initialize) GetToken1ProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(16) +} + +// SetAssociatedTokenProgramAccount sets the "associatedTokenProgram" account. +// Program to create an ATA for receiving position NFT +func (inst *Initialize) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[17] = ag_solanago.Meta(associatedTokenProgram) + return inst +} + +// GetAssociatedTokenProgramAccount gets the "associatedTokenProgram" account. +// Program to create an ATA for receiving position NFT +func (inst *Initialize) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(17) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +// To create a new program account +func (inst *Initialize) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[18] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +// To create a new program account +func (inst *Initialize) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(18) +} + +// SetRentAccount sets the "rent" account. +// Sysvar for program account +func (inst *Initialize) SetRentAccount(rent ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[19] = ag_solanago.Meta(rent) + return inst +} + +// GetRentAccount gets the "rent" account. +// Sysvar for program account +func (inst *Initialize) GetRentAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(19) +} + +func (inst Initialize) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Initialize, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Initialize) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Initialize) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.InitAmount0 == nil { + return errors.New("InitAmount0 parameter is not set") + } + if inst.InitAmount1 == nil { + return errors.New("InitAmount1 parameter is not set") + } + if inst.OpenTime == nil { + return errors.New("OpenTime parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Creator is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Token0Mint is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Token1Mint is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.CreatorToken0 is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.CreatorToken1 is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.CreatorLpToken is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.Token0Vault is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Token1Vault is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.CreatePoolFee is not set") + } + if inst.AccountMetaSlice[13] == nil { + return errors.New("accounts.ObservationState is not set") + } + if inst.AccountMetaSlice[14] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[15] == nil { + return errors.New("accounts.Token0Program is not set") + } + if inst.AccountMetaSlice[16] == nil { + return errors.New("accounts.Token1Program is not set") + } + if inst.AccountMetaSlice[17] == nil { + return errors.New("accounts.AssociatedTokenProgram is not set") + } + if inst.AccountMetaSlice[18] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[19] == nil { + return errors.New("accounts.Rent is not set") + } + } + return nil +} + +func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Initialize")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("InitAmount0", *inst.InitAmount0)) + paramsBranch.Child(ag_format.Param("InitAmount1", *inst.InitAmount1)) + paramsBranch.Child(ag_format.Param(" OpenTime", *inst.OpenTime)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=20]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" creator", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" token0Mint", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" token1Mint", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" creatorToken0", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" creatorToken1", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta(" creatorLpToken", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" token0Vault", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" token1Vault", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" createPoolFee", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" observationState", inst.AccountMetaSlice.Get(13))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(14))) + accountsBranch.Child(ag_format.Meta(" token0Program", inst.AccountMetaSlice.Get(15))) + accountsBranch.Child(ag_format.Meta(" token1Program", inst.AccountMetaSlice.Get(16))) + accountsBranch.Child(ag_format.Meta("associatedTokenProgram", inst.AccountMetaSlice.Get(17))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(18))) + accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(19))) + }) + }) + }) +} + +func (obj Initialize) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `InitAmount0` param: + err = encoder.Encode(obj.InitAmount0) + if err != nil { + return err + } + // Serialize `InitAmount1` param: + err = encoder.Encode(obj.InitAmount1) + if err != nil { + return err + } + // Serialize `OpenTime` param: + err = encoder.Encode(obj.OpenTime) + if err != nil { + return err + } + return nil +} +func (obj *Initialize) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `InitAmount0`: + err = decoder.Decode(&obj.InitAmount0) + if err != nil { + return err + } + // Deserialize `InitAmount1`: + err = decoder.Decode(&obj.InitAmount1) + if err != nil { + return err + } + // Deserialize `OpenTime`: + err = decoder.Decode(&obj.OpenTime) + if err != nil { + return err + } + return nil +} + +// NewInitializeInstruction declares a new Initialize instruction with the provided parameters and accounts. +func NewInitializeInstruction( + // Parameters: + initAmount0 uint64, + initAmount1 uint64, + openTime uint64, + // Accounts: + creator ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + token0Mint ag_solanago.PublicKey, + token1Mint ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + creatorToken0 ag_solanago.PublicKey, + creatorToken1 ag_solanago.PublicKey, + creatorLpToken ag_solanago.PublicKey, + token0Vault ag_solanago.PublicKey, + token1Vault ag_solanago.PublicKey, + createPoolFee ag_solanago.PublicKey, + observationState ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + token0Program ag_solanago.PublicKey, + token1Program ag_solanago.PublicKey, + associatedTokenProgram ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + rent ag_solanago.PublicKey) *Initialize { + return NewInitializeInstructionBuilder(). + SetInitAmount0(initAmount0). + SetInitAmount1(initAmount1). + SetOpenTime(openTime). + SetCreatorAccount(creator). + SetAmmConfigAccount(ammConfig). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState). + SetToken0MintAccount(token0Mint). + SetToken1MintAccount(token1Mint). + SetLpMintAccount(lpMint). + SetCreatorToken0Account(creatorToken0). + SetCreatorToken1Account(creatorToken1). + SetCreatorLpTokenAccount(creatorLpToken). + SetToken0VaultAccount(token0Vault). + SetToken1VaultAccount(token1Vault). + SetCreatePoolFeeAccount(createPoolFee). + SetObservationStateAccount(observationState). + SetTokenProgramAccount(tokenProgram). + SetToken0ProgramAccount(token0Program). + SetToken1ProgramAccount(token1Program). + SetAssociatedTokenProgramAccount(associatedTokenProgram). + SetSystemProgramAccount(systemProgram). + SetRentAccount(rent) +} diff --git a/programs/raydium_cp/Initialize_test.go b/programs/raydium_cp/Initialize_test.go new file mode 100644 index 000000000..5e216199d --- /dev/null +++ b/programs/raydium_cp/Initialize_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initialize(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initialize"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initialize) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initialize) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydium_cp/SwapBaseInput.go b/programs/raydium_cp/SwapBaseInput.go new file mode 100644 index 000000000..20ead79f3 --- /dev/null +++ b/programs/raydium_cp/SwapBaseInput.go @@ -0,0 +1,421 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Swap the tokens in the pool base input amount +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `amount_in` - input amount to transfer, output to DESTINATION is based on the exchange rate +// * `minimum_amount_out` - Minimum amount of output token, prevents excessive slippage +// +type SwapBaseInput struct { + AmountIn *uint64 + MinimumAmountOut *uint64 + + // [0] = [SIGNER] payer + // ··········· The user performing the swap + // + // [1] = [] authority + // + // [2] = [] ammConfig + // ··········· The factory state to read protocol fees + // + // [3] = [WRITE] poolState + // ··········· The program account of the pool in which the swap will be performed + // + // [4] = [WRITE] inputTokenAccount + // ··········· The user token account for input token + // + // [5] = [WRITE] outputTokenAccount + // ··········· The user token account for output token + // + // [6] = [WRITE] inputVault + // ··········· The vault token account for input token + // + // [7] = [WRITE] outputVault + // ··········· The vault token account for output token + // + // [8] = [] inputTokenProgram + // ··········· SPL program for input token transfers + // + // [9] = [] outputTokenProgram + // ··········· SPL program for output token transfers + // + // [10] = [] inputTokenMint + // ··········· The mint of input token + // + // [11] = [] outputTokenMint + // ··········· The mint of output token + // + // [12] = [WRITE] observationState + // ··········· The program account for the most recent oracle observation + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSwapBaseInputInstructionBuilder creates a new `SwapBaseInput` instruction builder. +func NewSwapBaseInputInstructionBuilder() *SwapBaseInput { + nd := &SwapBaseInput{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13), + } + return nd +} + +// SetAmountIn sets the "amountIn" parameter. +func (inst *SwapBaseInput) SetAmountIn(amountIn uint64) *SwapBaseInput { + inst.AmountIn = &amountIn + return inst +} + +// SetMinimumAmountOut sets the "minimumAmountOut" parameter. +func (inst *SwapBaseInput) SetMinimumAmountOut(minimumAmountOut uint64) *SwapBaseInput { + inst.MinimumAmountOut = &minimumAmountOut + return inst +} + +// SetPayerAccount sets the "payer" account. +// The user performing the swap +func (inst *SwapBaseInput) SetPayerAccount(payer ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[0] = ag_solanago.Meta(payer).SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +// The user performing the swap +func (inst *SwapBaseInput) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *SwapBaseInput) SetAuthorityAccount(authority ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *SwapBaseInput) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// The factory state to read protocol fees +func (inst *SwapBaseInput) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[2] = ag_solanago.Meta(ammConfig) + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// The factory state to read protocol fees +func (inst *SwapBaseInput) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetPoolStateAccount sets the "poolState" account. +// The program account of the pool in which the swap will be performed +func (inst *SwapBaseInput) SetPoolStateAccount(poolState ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[3] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// The program account of the pool in which the swap will be performed +func (inst *SwapBaseInput) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetInputTokenAccountAccount sets the "inputTokenAccount" account. +// The user token account for input token +func (inst *SwapBaseInput) SetInputTokenAccountAccount(inputTokenAccount ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[4] = ag_solanago.Meta(inputTokenAccount).WRITE() + return inst +} + +// GetInputTokenAccountAccount gets the "inputTokenAccount" account. +// The user token account for input token +func (inst *SwapBaseInput) GetInputTokenAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetOutputTokenAccountAccount sets the "outputTokenAccount" account. +// The user token account for output token +func (inst *SwapBaseInput) SetOutputTokenAccountAccount(outputTokenAccount ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[5] = ag_solanago.Meta(outputTokenAccount).WRITE() + return inst +} + +// GetOutputTokenAccountAccount gets the "outputTokenAccount" account. +// The user token account for output token +func (inst *SwapBaseInput) GetOutputTokenAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetInputVaultAccount sets the "inputVault" account. +// The vault token account for input token +func (inst *SwapBaseInput) SetInputVaultAccount(inputVault ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[6] = ag_solanago.Meta(inputVault).WRITE() + return inst +} + +// GetInputVaultAccount gets the "inputVault" account. +// The vault token account for input token +func (inst *SwapBaseInput) GetInputVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetOutputVaultAccount sets the "outputVault" account. +// The vault token account for output token +func (inst *SwapBaseInput) SetOutputVaultAccount(outputVault ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[7] = ag_solanago.Meta(outputVault).WRITE() + return inst +} + +// GetOutputVaultAccount gets the "outputVault" account. +// The vault token account for output token +func (inst *SwapBaseInput) GetOutputVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetInputTokenProgramAccount sets the "inputTokenProgram" account. +// SPL program for input token transfers +func (inst *SwapBaseInput) SetInputTokenProgramAccount(inputTokenProgram ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[8] = ag_solanago.Meta(inputTokenProgram) + return inst +} + +// GetInputTokenProgramAccount gets the "inputTokenProgram" account. +// SPL program for input token transfers +func (inst *SwapBaseInput) GetInputTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetOutputTokenProgramAccount sets the "outputTokenProgram" account. +// SPL program for output token transfers +func (inst *SwapBaseInput) SetOutputTokenProgramAccount(outputTokenProgram ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[9] = ag_solanago.Meta(outputTokenProgram) + return inst +} + +// GetOutputTokenProgramAccount gets the "outputTokenProgram" account. +// SPL program for output token transfers +func (inst *SwapBaseInput) GetOutputTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetInputTokenMintAccount sets the "inputTokenMint" account. +// The mint of input token +func (inst *SwapBaseInput) SetInputTokenMintAccount(inputTokenMint ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[10] = ag_solanago.Meta(inputTokenMint) + return inst +} + +// GetInputTokenMintAccount gets the "inputTokenMint" account. +// The mint of input token +func (inst *SwapBaseInput) GetInputTokenMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetOutputTokenMintAccount sets the "outputTokenMint" account. +// The mint of output token +func (inst *SwapBaseInput) SetOutputTokenMintAccount(outputTokenMint ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[11] = ag_solanago.Meta(outputTokenMint) + return inst +} + +// GetOutputTokenMintAccount gets the "outputTokenMint" account. +// The mint of output token +func (inst *SwapBaseInput) GetOutputTokenMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetObservationStateAccount sets the "observationState" account. +// The program account for the most recent oracle observation +func (inst *SwapBaseInput) SetObservationStateAccount(observationState ag_solanago.PublicKey) *SwapBaseInput { + inst.AccountMetaSlice[12] = ag_solanago.Meta(observationState).WRITE() + return inst +} + +// GetObservationStateAccount gets the "observationState" account. +// The program account for the most recent oracle observation +func (inst *SwapBaseInput) GetObservationStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +func (inst SwapBaseInput) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SwapBaseInput, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SwapBaseInput) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SwapBaseInput) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.AmountIn == nil { + return errors.New("AmountIn parameter is not set") + } + if inst.MinimumAmountOut == nil { + return errors.New("MinimumAmountOut parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.InputTokenAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.OutputTokenAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.InputVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.OutputVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.InputTokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.OutputTokenProgram is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.InputTokenMint is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.OutputTokenMint is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.ObservationState is not set") + } + } + return nil +} + +func (inst *SwapBaseInput) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SwapBaseInput")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" AmountIn", *inst.AmountIn)) + paramsBranch.Child(ag_format.Param("MinimumAmountOut", *inst.MinimumAmountOut)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" inputToken", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" outputToken", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" inputVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" outputVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" inputTokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta("outputTokenProgram", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" inputTokenMint", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" outputTokenMint", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" observationState", inst.AccountMetaSlice.Get(12))) + }) + }) + }) +} + +func (obj SwapBaseInput) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `AmountIn` param: + err = encoder.Encode(obj.AmountIn) + if err != nil { + return err + } + // Serialize `MinimumAmountOut` param: + err = encoder.Encode(obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} +func (obj *SwapBaseInput) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `AmountIn`: + err = decoder.Decode(&obj.AmountIn) + if err != nil { + return err + } + // Deserialize `MinimumAmountOut`: + err = decoder.Decode(&obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} + +// NewSwapBaseInputInstruction declares a new SwapBaseInput instruction with the provided parameters and accounts. +func NewSwapBaseInputInstruction( + // Parameters: + amountIn uint64, + minimumAmountOut uint64, + // Accounts: + payer ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + inputTokenAccount ag_solanago.PublicKey, + outputTokenAccount ag_solanago.PublicKey, + inputVault ag_solanago.PublicKey, + outputVault ag_solanago.PublicKey, + inputTokenProgram ag_solanago.PublicKey, + outputTokenProgram ag_solanago.PublicKey, + inputTokenMint ag_solanago.PublicKey, + outputTokenMint ag_solanago.PublicKey, + observationState ag_solanago.PublicKey) *SwapBaseInput { + return NewSwapBaseInputInstructionBuilder(). + SetAmountIn(amountIn). + SetMinimumAmountOut(minimumAmountOut). + SetPayerAccount(payer). + SetAuthorityAccount(authority). + SetAmmConfigAccount(ammConfig). + SetPoolStateAccount(poolState). + SetInputTokenAccountAccount(inputTokenAccount). + SetOutputTokenAccountAccount(outputTokenAccount). + SetInputVaultAccount(inputVault). + SetOutputVaultAccount(outputVault). + SetInputTokenProgramAccount(inputTokenProgram). + SetOutputTokenProgramAccount(outputTokenProgram). + SetInputTokenMintAccount(inputTokenMint). + SetOutputTokenMintAccount(outputTokenMint). + SetObservationStateAccount(observationState) +} diff --git a/programs/raydium_cp/SwapBaseInput_test.go b/programs/raydium_cp/SwapBaseInput_test.go new file mode 100644 index 000000000..092fee861 --- /dev/null +++ b/programs/raydium_cp/SwapBaseInput_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SwapBaseInput(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SwapBaseInput"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SwapBaseInput) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SwapBaseInput) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydium_cp/SwapBaseOutput.go b/programs/raydium_cp/SwapBaseOutput.go new file mode 100644 index 000000000..874291290 --- /dev/null +++ b/programs/raydium_cp/SwapBaseOutput.go @@ -0,0 +1,421 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Swap the tokens in the pool base output amount +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `max_amount_in` - input amount prevents excessive slippage +// * `amount_out` - amount of output token +// +type SwapBaseOutput struct { + MaxAmountIn *uint64 + AmountOut *uint64 + + // [0] = [SIGNER] payer + // ··········· The user performing the swap + // + // [1] = [] authority + // + // [2] = [] ammConfig + // ··········· The factory state to read protocol fees + // + // [3] = [WRITE] poolState + // ··········· The program account of the pool in which the swap will be performed + // + // [4] = [WRITE] inputTokenAccount + // ··········· The user token account for input token + // + // [5] = [WRITE] outputTokenAccount + // ··········· The user token account for output token + // + // [6] = [WRITE] inputVault + // ··········· The vault token account for input token + // + // [7] = [WRITE] outputVault + // ··········· The vault token account for output token + // + // [8] = [] inputTokenProgram + // ··········· SPL program for input token transfers + // + // [9] = [] outputTokenProgram + // ··········· SPL program for output token transfers + // + // [10] = [] inputTokenMint + // ··········· The mint of input token + // + // [11] = [] outputTokenMint + // ··········· The mint of output token + // + // [12] = [WRITE] observationState + // ··········· The program account for the most recent oracle observation + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewSwapBaseOutputInstructionBuilder creates a new `SwapBaseOutput` instruction builder. +func NewSwapBaseOutputInstructionBuilder() *SwapBaseOutput { + nd := &SwapBaseOutput{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13), + } + return nd +} + +// SetMaxAmountIn sets the "maxAmountIn" parameter. +func (inst *SwapBaseOutput) SetMaxAmountIn(maxAmountIn uint64) *SwapBaseOutput { + inst.MaxAmountIn = &maxAmountIn + return inst +} + +// SetAmountOut sets the "amountOut" parameter. +func (inst *SwapBaseOutput) SetAmountOut(amountOut uint64) *SwapBaseOutput { + inst.AmountOut = &amountOut + return inst +} + +// SetPayerAccount sets the "payer" account. +// The user performing the swap +func (inst *SwapBaseOutput) SetPayerAccount(payer ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[0] = ag_solanago.Meta(payer).SIGNER() + return inst +} + +// GetPayerAccount gets the "payer" account. +// The user performing the swap +func (inst *SwapBaseOutput) GetPayerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *SwapBaseOutput) SetAuthorityAccount(authority ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *SwapBaseOutput) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// The factory state to read protocol fees +func (inst *SwapBaseOutput) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[2] = ag_solanago.Meta(ammConfig) + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// The factory state to read protocol fees +func (inst *SwapBaseOutput) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetPoolStateAccount sets the "poolState" account. +// The program account of the pool in which the swap will be performed +func (inst *SwapBaseOutput) SetPoolStateAccount(poolState ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[3] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// The program account of the pool in which the swap will be performed +func (inst *SwapBaseOutput) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetInputTokenAccountAccount sets the "inputTokenAccount" account. +// The user token account for input token +func (inst *SwapBaseOutput) SetInputTokenAccountAccount(inputTokenAccount ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[4] = ag_solanago.Meta(inputTokenAccount).WRITE() + return inst +} + +// GetInputTokenAccountAccount gets the "inputTokenAccount" account. +// The user token account for input token +func (inst *SwapBaseOutput) GetInputTokenAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetOutputTokenAccountAccount sets the "outputTokenAccount" account. +// The user token account for output token +func (inst *SwapBaseOutput) SetOutputTokenAccountAccount(outputTokenAccount ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[5] = ag_solanago.Meta(outputTokenAccount).WRITE() + return inst +} + +// GetOutputTokenAccountAccount gets the "outputTokenAccount" account. +// The user token account for output token +func (inst *SwapBaseOutput) GetOutputTokenAccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetInputVaultAccount sets the "inputVault" account. +// The vault token account for input token +func (inst *SwapBaseOutput) SetInputVaultAccount(inputVault ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[6] = ag_solanago.Meta(inputVault).WRITE() + return inst +} + +// GetInputVaultAccount gets the "inputVault" account. +// The vault token account for input token +func (inst *SwapBaseOutput) GetInputVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetOutputVaultAccount sets the "outputVault" account. +// The vault token account for output token +func (inst *SwapBaseOutput) SetOutputVaultAccount(outputVault ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[7] = ag_solanago.Meta(outputVault).WRITE() + return inst +} + +// GetOutputVaultAccount gets the "outputVault" account. +// The vault token account for output token +func (inst *SwapBaseOutput) GetOutputVaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetInputTokenProgramAccount sets the "inputTokenProgram" account. +// SPL program for input token transfers +func (inst *SwapBaseOutput) SetInputTokenProgramAccount(inputTokenProgram ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[8] = ag_solanago.Meta(inputTokenProgram) + return inst +} + +// GetInputTokenProgramAccount gets the "inputTokenProgram" account. +// SPL program for input token transfers +func (inst *SwapBaseOutput) GetInputTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetOutputTokenProgramAccount sets the "outputTokenProgram" account. +// SPL program for output token transfers +func (inst *SwapBaseOutput) SetOutputTokenProgramAccount(outputTokenProgram ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[9] = ag_solanago.Meta(outputTokenProgram) + return inst +} + +// GetOutputTokenProgramAccount gets the "outputTokenProgram" account. +// SPL program for output token transfers +func (inst *SwapBaseOutput) GetOutputTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetInputTokenMintAccount sets the "inputTokenMint" account. +// The mint of input token +func (inst *SwapBaseOutput) SetInputTokenMintAccount(inputTokenMint ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[10] = ag_solanago.Meta(inputTokenMint) + return inst +} + +// GetInputTokenMintAccount gets the "inputTokenMint" account. +// The mint of input token +func (inst *SwapBaseOutput) GetInputTokenMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetOutputTokenMintAccount sets the "outputTokenMint" account. +// The mint of output token +func (inst *SwapBaseOutput) SetOutputTokenMintAccount(outputTokenMint ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[11] = ag_solanago.Meta(outputTokenMint) + return inst +} + +// GetOutputTokenMintAccount gets the "outputTokenMint" account. +// The mint of output token +func (inst *SwapBaseOutput) GetOutputTokenMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetObservationStateAccount sets the "observationState" account. +// The program account for the most recent oracle observation +func (inst *SwapBaseOutput) SetObservationStateAccount(observationState ag_solanago.PublicKey) *SwapBaseOutput { + inst.AccountMetaSlice[12] = ag_solanago.Meta(observationState).WRITE() + return inst +} + +// GetObservationStateAccount gets the "observationState" account. +// The program account for the most recent oracle observation +func (inst *SwapBaseOutput) GetObservationStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +func (inst SwapBaseOutput) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SwapBaseOutput, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SwapBaseOutput) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SwapBaseOutput) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.MaxAmountIn == nil { + return errors.New("MaxAmountIn parameter is not set") + } + if inst.AmountOut == nil { + return errors.New("AmountOut parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Payer is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.AmmConfig is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.InputTokenAccount is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.OutputTokenAccount is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.InputVault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.OutputVault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.InputTokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.OutputTokenProgram is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.InputTokenMint is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.OutputTokenMint is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.ObservationState is not set") + } + } + return nil +} + +func (inst *SwapBaseOutput) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SwapBaseOutput")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("MaxAmountIn", *inst.MaxAmountIn)) + paramsBranch.Child(ag_format.Param(" AmountOut", *inst.AmountOut)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" payer", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" ammConfig", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" inputToken", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" outputToken", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" inputVault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" outputVault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" inputTokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta("outputTokenProgram", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" inputTokenMint", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" outputTokenMint", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" observationState", inst.AccountMetaSlice.Get(12))) + }) + }) + }) +} + +func (obj SwapBaseOutput) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MaxAmountIn` param: + err = encoder.Encode(obj.MaxAmountIn) + if err != nil { + return err + } + // Serialize `AmountOut` param: + err = encoder.Encode(obj.AmountOut) + if err != nil { + return err + } + return nil +} +func (obj *SwapBaseOutput) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MaxAmountIn`: + err = decoder.Decode(&obj.MaxAmountIn) + if err != nil { + return err + } + // Deserialize `AmountOut`: + err = decoder.Decode(&obj.AmountOut) + if err != nil { + return err + } + return nil +} + +// NewSwapBaseOutputInstruction declares a new SwapBaseOutput instruction with the provided parameters and accounts. +func NewSwapBaseOutputInstruction( + // Parameters: + maxAmountIn uint64, + amountOut uint64, + // Accounts: + payer ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + inputTokenAccount ag_solanago.PublicKey, + outputTokenAccount ag_solanago.PublicKey, + inputVault ag_solanago.PublicKey, + outputVault ag_solanago.PublicKey, + inputTokenProgram ag_solanago.PublicKey, + outputTokenProgram ag_solanago.PublicKey, + inputTokenMint ag_solanago.PublicKey, + outputTokenMint ag_solanago.PublicKey, + observationState ag_solanago.PublicKey) *SwapBaseOutput { + return NewSwapBaseOutputInstructionBuilder(). + SetMaxAmountIn(maxAmountIn). + SetAmountOut(amountOut). + SetPayerAccount(payer). + SetAuthorityAccount(authority). + SetAmmConfigAccount(ammConfig). + SetPoolStateAccount(poolState). + SetInputTokenAccountAccount(inputTokenAccount). + SetOutputTokenAccountAccount(outputTokenAccount). + SetInputVaultAccount(inputVault). + SetOutputVaultAccount(outputVault). + SetInputTokenProgramAccount(inputTokenProgram). + SetOutputTokenProgramAccount(outputTokenProgram). + SetInputTokenMintAccount(inputTokenMint). + SetOutputTokenMintAccount(outputTokenMint). + SetObservationStateAccount(observationState) +} diff --git a/programs/raydium_cp/SwapBaseOutput_test.go b/programs/raydium_cp/SwapBaseOutput_test.go new file mode 100644 index 000000000..86b219e2c --- /dev/null +++ b/programs/raydium_cp/SwapBaseOutput_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SwapBaseOutput(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SwapBaseOutput"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SwapBaseOutput) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SwapBaseOutput) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydium_cp/UpdateAmmConfig.go b/programs/raydium_cp/UpdateAmmConfig.go new file mode 100644 index 000000000..7dbbeff51 --- /dev/null +++ b/programs/raydium_cp/UpdateAmmConfig.go @@ -0,0 +1,187 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Updates the owner of the amm config +// Must be called by the current owner or admin +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `trade_fee_rate`- The new trade fee rate of amm config, be set when `param` is 0 +// * `protocol_fee_rate`- The new protocol fee rate of amm config, be set when `param` is 1 +// * `fund_fee_rate`- The new fund fee rate of amm config, be set when `param` is 2 +// * `new_owner`- The config's new owner, be set when `param` is 3 +// * `new_fund_owner`- The config's new fund owner, be set when `param` is 4 +// * `param`- The vaule can be 0 | 1 | 2 | 3 | 4, otherwise will report a error +// +type UpdateAmmConfig struct { + Param *uint8 + Value *uint64 + + // [0] = [SIGNER] owner + // ··········· The amm config owner or admin + // + // [1] = [WRITE] ammConfig + // ··········· Amm config account to be changed + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewUpdateAmmConfigInstructionBuilder creates a new `UpdateAmmConfig` instruction builder. +func NewUpdateAmmConfigInstructionBuilder() *UpdateAmmConfig { + nd := &UpdateAmmConfig{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetParam sets the "param" parameter. +func (inst *UpdateAmmConfig) SetParam(param uint8) *UpdateAmmConfig { + inst.Param = ¶m + return inst +} + +// SetValue sets the "value" parameter. +func (inst *UpdateAmmConfig) SetValue(value uint64) *UpdateAmmConfig { + inst.Value = &value + return inst +} + +// SetOwnerAccount sets the "owner" account. +// The amm config owner or admin +func (inst *UpdateAmmConfig) SetOwnerAccount(owner ag_solanago.PublicKey) *UpdateAmmConfig { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// The amm config owner or admin +func (inst *UpdateAmmConfig) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAmmConfigAccount sets the "ammConfig" account. +// Amm config account to be changed +func (inst *UpdateAmmConfig) SetAmmConfigAccount(ammConfig ag_solanago.PublicKey) *UpdateAmmConfig { + inst.AccountMetaSlice[1] = ag_solanago.Meta(ammConfig).WRITE() + return inst +} + +// GetAmmConfigAccount gets the "ammConfig" account. +// Amm config account to be changed +func (inst *UpdateAmmConfig) GetAmmConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +func (inst UpdateAmmConfig) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdateAmmConfig, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdateAmmConfig) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdateAmmConfig) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Param == nil { + return errors.New("Param parameter is not set") + } + if inst.Value == nil { + return errors.New("Value parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.AmmConfig is not set") + } + } + return nil +} + +func (inst *UpdateAmmConfig) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdateAmmConfig")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Param", *inst.Param)) + paramsBranch.Child(ag_format.Param("Value", *inst.Value)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("ammConfig", inst.AccountMetaSlice.Get(1))) + }) + }) + }) +} + +func (obj UpdateAmmConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Param` param: + err = encoder.Encode(obj.Param) + if err != nil { + return err + } + // Serialize `Value` param: + err = encoder.Encode(obj.Value) + if err != nil { + return err + } + return nil +} +func (obj *UpdateAmmConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Param`: + err = decoder.Decode(&obj.Param) + if err != nil { + return err + } + // Deserialize `Value`: + err = decoder.Decode(&obj.Value) + if err != nil { + return err + } + return nil +} + +// NewUpdateAmmConfigInstruction declares a new UpdateAmmConfig instruction with the provided parameters and accounts. +func NewUpdateAmmConfigInstruction( + // Parameters: + param uint8, + value uint64, + // Accounts: + owner ag_solanago.PublicKey, + ammConfig ag_solanago.PublicKey) *UpdateAmmConfig { + return NewUpdateAmmConfigInstructionBuilder(). + SetParam(param). + SetValue(value). + SetOwnerAccount(owner). + SetAmmConfigAccount(ammConfig) +} diff --git a/programs/raydiumclmm/UpdateAmmConfig_test.go b/programs/raydium_cp/UpdateAmmConfig_test.go similarity index 97% rename from programs/raydiumclmm/UpdateAmmConfig_test.go rename to programs/raydium_cp/UpdateAmmConfig_test.go index b0fbbc0e3..17d0e45b1 100644 --- a/programs/raydiumclmm/UpdateAmmConfig_test.go +++ b/programs/raydium_cp/UpdateAmmConfig_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "bytes" diff --git a/programs/raydiumclmm/UpdatePoolStatus.go b/programs/raydium_cp/UpdatePoolStatus.go similarity index 99% rename from programs/raydiumclmm/UpdatePoolStatus.go rename to programs/raydium_cp/UpdatePoolStatus.go index 4bdd7cc2c..069dad206 100644 --- a/programs/raydiumclmm/UpdatePoolStatus.go +++ b/programs/raydium_cp/UpdatePoolStatus.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "errors" diff --git a/programs/raydiumclmm/UpdatePoolStatus_test.go b/programs/raydium_cp/UpdatePoolStatus_test.go similarity index 97% rename from programs/raydiumclmm/UpdatePoolStatus_test.go rename to programs/raydium_cp/UpdatePoolStatus_test.go index 94f10d198..ee721fbb9 100644 --- a/programs/raydiumclmm/UpdatePoolStatus_test.go +++ b/programs/raydium_cp/UpdatePoolStatus_test.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm_v3 +package raydium_cp import ( "bytes" diff --git a/programs/raydium_cp/Withdraw.go b/programs/raydium_cp/Withdraw.go new file mode 100644 index 000000000..acac0d835 --- /dev/null +++ b/programs/raydium_cp/Withdraw.go @@ -0,0 +1,467 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Withdraw lp for token0 ande token1 +// +// # Arguments +// +// * `ctx`- The context of accounts +// * `lp_token_amount` - Amount of pool tokens to burn. User receives an output of token a and b based on the percentage of the pool tokens that are returned. +// * `minimum_token_0_amount` - Minimum amount of token 0 to receive, prevents excessive slippage +// * `minimum_token_1_amount` - Minimum amount of token 1 to receive, prevents excessive slippage +// +type Withdraw struct { + LpTokenAmount *uint64 + MinimumToken0Amount *uint64 + MinimumToken1Amount *uint64 + + // [0] = [SIGNER] owner + // ··········· Pays to mint the position + // + // [1] = [] authority + // + // [2] = [WRITE] poolState + // ··········· Pool state account + // + // [3] = [WRITE] ownerLpToken + // ··········· Owner lp token account + // + // [4] = [WRITE] token0Account + // ··········· The owner's token account for receive token_0 + // + // [5] = [WRITE] token1Account + // ··········· The owner's token account for receive token_1 + // + // [6] = [WRITE] token0Vault + // ··········· The address that holds pool tokens for token_0 + // + // [7] = [WRITE] token1Vault + // ··········· The address that holds pool tokens for token_1 + // + // [8] = [] tokenProgram + // ··········· token Program + // + // [9] = [] tokenProgram2022 + // ··········· Token program 2022 + // + // [10] = [] vault0Mint + // ··········· The mint of token_0 vault + // + // [11] = [] vault1Mint + // ··········· The mint of token_1 vault + // + // [12] = [WRITE] lpMint + // ··········· Pool lp token mint + // + // [13] = [] memoProgram + // ··········· memo program + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. +func NewWithdrawInstructionBuilder() *Withdraw { + nd := &Withdraw{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 14), + } + return nd +} + +// SetLpTokenAmount sets the "lpTokenAmount" parameter. +func (inst *Withdraw) SetLpTokenAmount(lpTokenAmount uint64) *Withdraw { + inst.LpTokenAmount = &lpTokenAmount + return inst +} + +// SetMinimumToken0Amount sets the "minimumToken0Amount" parameter. +func (inst *Withdraw) SetMinimumToken0Amount(minimumToken0Amount uint64) *Withdraw { + inst.MinimumToken0Amount = &minimumToken0Amount + return inst +} + +// SetMinimumToken1Amount sets the "minimumToken1Amount" parameter. +func (inst *Withdraw) SetMinimumToken1Amount(minimumToken1Amount uint64) *Withdraw { + inst.MinimumToken1Amount = &minimumToken1Amount + return inst +} + +// SetOwnerAccount sets the "owner" account. +// Pays to mint the position +func (inst *Withdraw) SetOwnerAccount(owner ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() + return inst +} + +// GetOwnerAccount gets the "owner" account. +// Pays to mint the position +func (inst *Withdraw) GetOwnerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Withdraw) SetAuthorityAccount(authority ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority) + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Withdraw) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolStateAccount sets the "poolState" account. +// Pool state account +func (inst *Withdraw) SetPoolStateAccount(poolState ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[2] = ag_solanago.Meta(poolState).WRITE() + return inst +} + +// GetPoolStateAccount gets the "poolState" account. +// Pool state account +func (inst *Withdraw) GetPoolStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetOwnerLpTokenAccount sets the "ownerLpToken" account. +// Owner lp token account +func (inst *Withdraw) SetOwnerLpTokenAccount(ownerLpToken ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[3] = ag_solanago.Meta(ownerLpToken).WRITE() + return inst +} + +// GetOwnerLpTokenAccount gets the "ownerLpToken" account. +// Owner lp token account +func (inst *Withdraw) GetOwnerLpTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetToken0AccountAccount sets the "token0Account" account. +// The owner's token account for receive token_0 +func (inst *Withdraw) SetToken0AccountAccount(token0Account ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[4] = ag_solanago.Meta(token0Account).WRITE() + return inst +} + +// GetToken0AccountAccount gets the "token0Account" account. +// The owner's token account for receive token_0 +func (inst *Withdraw) GetToken0AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetToken1AccountAccount sets the "token1Account" account. +// The owner's token account for receive token_1 +func (inst *Withdraw) SetToken1AccountAccount(token1Account ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[5] = ag_solanago.Meta(token1Account).WRITE() + return inst +} + +// GetToken1AccountAccount gets the "token1Account" account. +// The owner's token account for receive token_1 +func (inst *Withdraw) GetToken1AccountAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +// SetToken0VaultAccount sets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *Withdraw) SetToken0VaultAccount(token0Vault ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[6] = ag_solanago.Meta(token0Vault).WRITE() + return inst +} + +// GetToken0VaultAccount gets the "token0Vault" account. +// The address that holds pool tokens for token_0 +func (inst *Withdraw) GetToken0VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(6) +} + +// SetToken1VaultAccount sets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *Withdraw) SetToken1VaultAccount(token1Vault ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[7] = ag_solanago.Meta(token1Vault).WRITE() + return inst +} + +// GetToken1VaultAccount gets the "token1Vault" account. +// The address that holds pool tokens for token_1 +func (inst *Withdraw) GetToken1VaultAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(7) +} + +// SetTokenProgramAccount sets the "tokenProgram" account. +// token Program +func (inst *Withdraw) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) + return inst +} + +// GetTokenProgramAccount gets the "tokenProgram" account. +// token Program +func (inst *Withdraw) GetTokenProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(8) +} + +// SetTokenProgram2022Account sets the "tokenProgram2022" account. +// Token program 2022 +func (inst *Withdraw) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram2022) + return inst +} + +// GetTokenProgram2022Account gets the "tokenProgram2022" account. +// Token program 2022 +func (inst *Withdraw) GetTokenProgram2022Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(9) +} + +// SetVault0MintAccount sets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *Withdraw) SetVault0MintAccount(vault0Mint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[10] = ag_solanago.Meta(vault0Mint) + return inst +} + +// GetVault0MintAccount gets the "vault0Mint" account. +// The mint of token_0 vault +func (inst *Withdraw) GetVault0MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(10) +} + +// SetVault1MintAccount sets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *Withdraw) SetVault1MintAccount(vault1Mint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[11] = ag_solanago.Meta(vault1Mint) + return inst +} + +// GetVault1MintAccount gets the "vault1Mint" account. +// The mint of token_1 vault +func (inst *Withdraw) GetVault1MintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(11) +} + +// SetLpMintAccount sets the "lpMint" account. +// Pool lp token mint +func (inst *Withdraw) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[12] = ag_solanago.Meta(lpMint).WRITE() + return inst +} + +// GetLpMintAccount gets the "lpMint" account. +// Pool lp token mint +func (inst *Withdraw) GetLpMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(12) +} + +// SetMemoProgramAccount sets the "memoProgram" account. +// memo program +func (inst *Withdraw) SetMemoProgramAccount(memoProgram ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[13] = ag_solanago.Meta(memoProgram) + return inst +} + +// GetMemoProgramAccount gets the "memoProgram" account. +// memo program +func (inst *Withdraw) GetMemoProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(13) +} + +func (inst Withdraw) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.LpTokenAmount == nil { + return errors.New("LpTokenAmount parameter is not set") + } + if inst.MinimumToken0Amount == nil { + return errors.New("MinimumToken0Amount parameter is not set") + } + if inst.MinimumToken1Amount == nil { + return errors.New("MinimumToken1Amount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Owner is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.PoolState is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.OwnerLpToken is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Token0Account is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.Token1Account is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.Token0Vault is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.Token1Vault is not set") + } + if inst.AccountMetaSlice[8] == nil { + return errors.New("accounts.TokenProgram is not set") + } + if inst.AccountMetaSlice[9] == nil { + return errors.New("accounts.TokenProgram2022 is not set") + } + if inst.AccountMetaSlice[10] == nil { + return errors.New("accounts.Vault0Mint is not set") + } + if inst.AccountMetaSlice[11] == nil { + return errors.New("accounts.Vault1Mint is not set") + } + if inst.AccountMetaSlice[12] == nil { + return errors.New("accounts.LpMint is not set") + } + if inst.AccountMetaSlice[13] == nil { + return errors.New("accounts.MemoProgram is not set") + } + } + return nil +} + +func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" LpTokenAmount", *inst.LpTokenAmount)) + paramsBranch.Child(ag_format.Param("MinimumToken0Amount", *inst.MinimumToken0Amount)) + paramsBranch.Child(ag_format.Param("MinimumToken1Amount", *inst.MinimumToken1Amount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=14]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" poolState", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" ownerLpToken", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta(" token0", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" token1", inst.AccountMetaSlice.Get(5))) + accountsBranch.Child(ag_format.Meta(" token0Vault", inst.AccountMetaSlice.Get(6))) + accountsBranch.Child(ag_format.Meta(" token1Vault", inst.AccountMetaSlice.Get(7))) + accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) + accountsBranch.Child(ag_format.Meta("tokenProgram2022", inst.AccountMetaSlice.Get(9))) + accountsBranch.Child(ag_format.Meta(" vault0Mint", inst.AccountMetaSlice.Get(10))) + accountsBranch.Child(ag_format.Meta(" vault1Mint", inst.AccountMetaSlice.Get(11))) + accountsBranch.Child(ag_format.Meta(" lpMint", inst.AccountMetaSlice.Get(12))) + accountsBranch.Child(ag_format.Meta(" memoProgram", inst.AccountMetaSlice.Get(13))) + }) + }) + }) +} + +func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `LpTokenAmount` param: + err = encoder.Encode(obj.LpTokenAmount) + if err != nil { + return err + } + // Serialize `MinimumToken0Amount` param: + err = encoder.Encode(obj.MinimumToken0Amount) + if err != nil { + return err + } + // Serialize `MinimumToken1Amount` param: + err = encoder.Encode(obj.MinimumToken1Amount) + if err != nil { + return err + } + return nil +} +func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `LpTokenAmount`: + err = decoder.Decode(&obj.LpTokenAmount) + if err != nil { + return err + } + // Deserialize `MinimumToken0Amount`: + err = decoder.Decode(&obj.MinimumToken0Amount) + if err != nil { + return err + } + // Deserialize `MinimumToken1Amount`: + err = decoder.Decode(&obj.MinimumToken1Amount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. +func NewWithdrawInstruction( + // Parameters: + lpTokenAmount uint64, + minimumToken0Amount uint64, + minimumToken1Amount uint64, + // Accounts: + owner ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + poolState ag_solanago.PublicKey, + ownerLpToken ag_solanago.PublicKey, + token0Account ag_solanago.PublicKey, + token1Account ag_solanago.PublicKey, + token0Vault ag_solanago.PublicKey, + token1Vault ag_solanago.PublicKey, + tokenProgram ag_solanago.PublicKey, + tokenProgram2022 ag_solanago.PublicKey, + vault0Mint ag_solanago.PublicKey, + vault1Mint ag_solanago.PublicKey, + lpMint ag_solanago.PublicKey, + memoProgram ag_solanago.PublicKey) *Withdraw { + return NewWithdrawInstructionBuilder(). + SetLpTokenAmount(lpTokenAmount). + SetMinimumToken0Amount(minimumToken0Amount). + SetMinimumToken1Amount(minimumToken1Amount). + SetOwnerAccount(owner). + SetAuthorityAccount(authority). + SetPoolStateAccount(poolState). + SetOwnerLpTokenAccount(ownerLpToken). + SetToken0AccountAccount(token0Account). + SetToken1AccountAccount(token1Account). + SetToken0VaultAccount(token0Vault). + SetToken1VaultAccount(token1Vault). + SetTokenProgramAccount(tokenProgram). + SetTokenProgram2022Account(tokenProgram2022). + SetVault0MintAccount(vault0Mint). + SetVault1MintAccount(vault1Mint). + SetLpMintAccount(lpMint). + SetMemoProgramAccount(memoProgram) +} diff --git a/programs/raydium_cp/Withdraw_test.go b/programs/raydium_cp/Withdraw_test.go new file mode 100644 index 000000000..fcf500be1 --- /dev/null +++ b/programs/raydium_cp/Withdraw_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Withdraw(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Withdraw"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Withdraw) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Withdraw) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/raydium_cp/accounts.go b/programs/raydium_cp/accounts.go new file mode 100644 index 000000000..25f09f31d --- /dev/null +++ b/programs/raydium_cp/accounts.go @@ -0,0 +1,570 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type AmmConfig struct { + // Bump to identify PDA + Bump uint8 + + // Status to control if new pool can be create + DisableCreatePool bool + + // Config index + Index uint16 + + // The trade fee, denominated in hundredths of a bip (10^-6) + TradeFeeRate uint64 + + // The protocol fee + ProtocolFeeRate uint64 + + // The fund fee, denominated in hundredths of a bip (10^-6) + FundFeeRate uint64 + + // Fee for create a new pool + CreatePoolFee uint64 + + // Address of the protocol fee owner + ProtocolOwner ag_solanago.PublicKey + + // Address of the fund fee owner + FundOwner ag_solanago.PublicKey + + // padding + Padding [16]uint64 +} + +var AmmConfigDiscriminator = [8]byte{218, 244, 33, 104, 203, 203, 43, 111} + +func (obj AmmConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(AmmConfigDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Bump` param: + err = encoder.Encode(obj.Bump) + if err != nil { + return err + } + // Serialize `DisableCreatePool` param: + err = encoder.Encode(obj.DisableCreatePool) + if err != nil { + return err + } + // Serialize `Index` param: + err = encoder.Encode(obj.Index) + if err != nil { + return err + } + // Serialize `TradeFeeRate` param: + err = encoder.Encode(obj.TradeFeeRate) + if err != nil { + return err + } + // Serialize `ProtocolFeeRate` param: + err = encoder.Encode(obj.ProtocolFeeRate) + if err != nil { + return err + } + // Serialize `FundFeeRate` param: + err = encoder.Encode(obj.FundFeeRate) + if err != nil { + return err + } + // Serialize `CreatePoolFee` param: + err = encoder.Encode(obj.CreatePoolFee) + if err != nil { + return err + } + // Serialize `ProtocolOwner` param: + err = encoder.Encode(obj.ProtocolOwner) + if err != nil { + return err + } + // Serialize `FundOwner` param: + err = encoder.Encode(obj.FundOwner) + if err != nil { + return err + } + // Serialize `Padding` param: + err = encoder.Encode(obj.Padding) + if err != nil { + return err + } + return nil +} + +func (obj *AmmConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(AmmConfigDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[218 244 33 104 203 203 43 111]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Bump`: + err = decoder.Decode(&obj.Bump) + if err != nil { + return err + } + // Deserialize `DisableCreatePool`: + err = decoder.Decode(&obj.DisableCreatePool) + if err != nil { + return err + } + // Deserialize `Index`: + err = decoder.Decode(&obj.Index) + if err != nil { + return err + } + // Deserialize `TradeFeeRate`: + err = decoder.Decode(&obj.TradeFeeRate) + if err != nil { + return err + } + // Deserialize `ProtocolFeeRate`: + err = decoder.Decode(&obj.ProtocolFeeRate) + if err != nil { + return err + } + // Deserialize `FundFeeRate`: + err = decoder.Decode(&obj.FundFeeRate) + if err != nil { + return err + } + // Deserialize `CreatePoolFee`: + err = decoder.Decode(&obj.CreatePoolFee) + if err != nil { + return err + } + // Deserialize `ProtocolOwner`: + err = decoder.Decode(&obj.ProtocolOwner) + if err != nil { + return err + } + // Deserialize `FundOwner`: + err = decoder.Decode(&obj.FundOwner) + if err != nil { + return err + } + // Deserialize `Padding`: + err = decoder.Decode(&obj.Padding) + if err != nil { + return err + } + return nil +} + +type ObservationState struct { + // Whether the ObservationState is initialized + Initialized bool + + // the most-recently updated index of the observations array + ObservationIndex uint16 + PoolId ag_solanago.PublicKey + + // observation array + Observations [100]Observation + + // padding for feature update + Padding [4]uint64 +} + +var ObservationStateDiscriminator = [8]byte{122, 174, 197, 53, 129, 9, 165, 132} + +func (obj ObservationState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(ObservationStateDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Initialized` param: + err = encoder.Encode(obj.Initialized) + if err != nil { + return err + } + // Serialize `ObservationIndex` param: + err = encoder.Encode(obj.ObservationIndex) + if err != nil { + return err + } + // Serialize `PoolId` param: + err = encoder.Encode(obj.PoolId) + if err != nil { + return err + } + // Serialize `Observations` param: + err = encoder.Encode(obj.Observations) + if err != nil { + return err + } + // Serialize `Padding` param: + err = encoder.Encode(obj.Padding) + if err != nil { + return err + } + return nil +} + +func (obj *ObservationState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(ObservationStateDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[122 174 197 53 129 9 165 132]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Initialized`: + err = decoder.Decode(&obj.Initialized) + if err != nil { + return err + } + // Deserialize `ObservationIndex`: + err = decoder.Decode(&obj.ObservationIndex) + if err != nil { + return err + } + // Deserialize `PoolId`: + err = decoder.Decode(&obj.PoolId) + if err != nil { + return err + } + // Deserialize `Observations`: + err = decoder.Decode(&obj.Observations) + if err != nil { + return err + } + // Deserialize `Padding`: + err = decoder.Decode(&obj.Padding) + if err != nil { + return err + } + return nil +} + +type PoolState struct { + // Which config the pool belongs + AmmConfig ag_solanago.PublicKey + + // pool creator + PoolCreator ag_solanago.PublicKey + + // Token A + Token0Vault ag_solanago.PublicKey + + // Token B + Token1Vault ag_solanago.PublicKey + + // Pool tokens are issued when A or B tokens are deposited. + // Pool tokens can be withdrawn back to the original A or B token. + LpMint ag_solanago.PublicKey + + // Mint information for token A + Token0Mint ag_solanago.PublicKey + + // Mint information for token B + Token1Mint ag_solanago.PublicKey + + // token_0 program + Token0Program ag_solanago.PublicKey + + // token_1 program + Token1Program ag_solanago.PublicKey + + // observation account to store oracle data + ObservationKey ag_solanago.PublicKey + AuthBump uint8 + + // Bitwise representation of the state of the pool + // bit0, 1: disable deposit(vaule is 1), 0: normal + // bit1, 1: disable withdraw(vaule is 2), 0: normal + // bit2, 1: disable swap(vaule is 4), 0: normal + Status uint8 + LpMintDecimals uint8 + + // mint0 and mint1 decimals + Mint0Decimals uint8 + Mint1Decimals uint8 + + // lp mint supply + LpSupply uint64 + + // The amounts of token_0 and token_1 that are owed to the liquidity provider. + ProtocolFeesToken0 uint64 + ProtocolFeesToken1 uint64 + FundFeesToken0 uint64 + FundFeesToken1 uint64 + + // The timestamp allowed for swap in the pool. + OpenTime uint64 + + // padding for future updates + Padding [32]uint64 +} + +var PoolStateDiscriminator = [8]byte{247, 237, 227, 245, 215, 195, 222, 70} + +func (obj PoolState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(PoolStateDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `AmmConfig` param: + err = encoder.Encode(obj.AmmConfig) + if err != nil { + return err + } + // Serialize `PoolCreator` param: + err = encoder.Encode(obj.PoolCreator) + if err != nil { + return err + } + // Serialize `Token0Vault` param: + err = encoder.Encode(obj.Token0Vault) + if err != nil { + return err + } + // Serialize `Token1Vault` param: + err = encoder.Encode(obj.Token1Vault) + if err != nil { + return err + } + // Serialize `LpMint` param: + err = encoder.Encode(obj.LpMint) + if err != nil { + return err + } + // Serialize `Token0Mint` param: + err = encoder.Encode(obj.Token0Mint) + if err != nil { + return err + } + // Serialize `Token1Mint` param: + err = encoder.Encode(obj.Token1Mint) + if err != nil { + return err + } + // Serialize `Token0Program` param: + err = encoder.Encode(obj.Token0Program) + if err != nil { + return err + } + // Serialize `Token1Program` param: + err = encoder.Encode(obj.Token1Program) + if err != nil { + return err + } + // Serialize `ObservationKey` param: + err = encoder.Encode(obj.ObservationKey) + if err != nil { + return err + } + // Serialize `AuthBump` param: + err = encoder.Encode(obj.AuthBump) + if err != nil { + return err + } + // Serialize `Status` param: + err = encoder.Encode(obj.Status) + if err != nil { + return err + } + // Serialize `LpMintDecimals` param: + err = encoder.Encode(obj.LpMintDecimals) + if err != nil { + return err + } + // Serialize `Mint0Decimals` param: + err = encoder.Encode(obj.Mint0Decimals) + if err != nil { + return err + } + // Serialize `Mint1Decimals` param: + err = encoder.Encode(obj.Mint1Decimals) + if err != nil { + return err + } + // Serialize `LpSupply` param: + err = encoder.Encode(obj.LpSupply) + if err != nil { + return err + } + // Serialize `ProtocolFeesToken0` param: + err = encoder.Encode(obj.ProtocolFeesToken0) + if err != nil { + return err + } + // Serialize `ProtocolFeesToken1` param: + err = encoder.Encode(obj.ProtocolFeesToken1) + if err != nil { + return err + } + // Serialize `FundFeesToken0` param: + err = encoder.Encode(obj.FundFeesToken0) + if err != nil { + return err + } + // Serialize `FundFeesToken1` param: + err = encoder.Encode(obj.FundFeesToken1) + if err != nil { + return err + } + // Serialize `OpenTime` param: + err = encoder.Encode(obj.OpenTime) + if err != nil { + return err + } + // Serialize `Padding` param: + err = encoder.Encode(obj.Padding) + if err != nil { + return err + } + return nil +} + +func (obj *PoolState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(PoolStateDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[247 237 227 245 215 195 222 70]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `AmmConfig`: + err = decoder.Decode(&obj.AmmConfig) + if err != nil { + return err + } + // Deserialize `PoolCreator`: + err = decoder.Decode(&obj.PoolCreator) + if err != nil { + return err + } + // Deserialize `Token0Vault`: + err = decoder.Decode(&obj.Token0Vault) + if err != nil { + return err + } + // Deserialize `Token1Vault`: + err = decoder.Decode(&obj.Token1Vault) + if err != nil { + return err + } + // Deserialize `LpMint`: + err = decoder.Decode(&obj.LpMint) + if err != nil { + return err + } + // Deserialize `Token0Mint`: + err = decoder.Decode(&obj.Token0Mint) + if err != nil { + return err + } + // Deserialize `Token1Mint`: + err = decoder.Decode(&obj.Token1Mint) + if err != nil { + return err + } + // Deserialize `Token0Program`: + err = decoder.Decode(&obj.Token0Program) + if err != nil { + return err + } + // Deserialize `Token1Program`: + err = decoder.Decode(&obj.Token1Program) + if err != nil { + return err + } + // Deserialize `ObservationKey`: + err = decoder.Decode(&obj.ObservationKey) + if err != nil { + return err + } + // Deserialize `AuthBump`: + err = decoder.Decode(&obj.AuthBump) + if err != nil { + return err + } + // Deserialize `Status`: + err = decoder.Decode(&obj.Status) + if err != nil { + return err + } + // Deserialize `LpMintDecimals`: + err = decoder.Decode(&obj.LpMintDecimals) + if err != nil { + return err + } + // Deserialize `Mint0Decimals`: + err = decoder.Decode(&obj.Mint0Decimals) + if err != nil { + return err + } + // Deserialize `Mint1Decimals`: + err = decoder.Decode(&obj.Mint1Decimals) + if err != nil { + return err + } + // Deserialize `LpSupply`: + err = decoder.Decode(&obj.LpSupply) + if err != nil { + return err + } + // Deserialize `ProtocolFeesToken0`: + err = decoder.Decode(&obj.ProtocolFeesToken0) + if err != nil { + return err + } + // Deserialize `ProtocolFeesToken1`: + err = decoder.Decode(&obj.ProtocolFeesToken1) + if err != nil { + return err + } + // Deserialize `FundFeesToken0`: + err = decoder.Decode(&obj.FundFeesToken0) + if err != nil { + return err + } + // Deserialize `FundFeesToken1`: + err = decoder.Decode(&obj.FundFeesToken1) + if err != nil { + return err + } + // Deserialize `OpenTime`: + err = decoder.Decode(&obj.OpenTime) + if err != nil { + return err + } + // Deserialize `Padding`: + err = decoder.Decode(&obj.Padding) + if err != nil { + return err + } + return nil +} diff --git a/programs/raydium_cp/instructions.go b/programs/raydium_cp/instructions.go new file mode 100644 index 000000000..e189a52b1 --- /dev/null +++ b/programs/raydium_cp/instructions.go @@ -0,0 +1,267 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "RaydiumCp" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + // # Arguments + // + // * `ctx`- The accounts needed by instruction. + // * `index` - The index of amm config, there may be multiple config. + // * `trade_fee_rate` - Trade fee rate, can be changed. + // * `protocol_fee_rate` - The rate of protocol fee within tarde fee. + // * `fund_fee_rate` - The rate of fund fee within tarde fee. + // + Instruction_CreateAmmConfig = ag_binary.TypeID([8]byte{137, 52, 237, 212, 215, 117, 108, 104}) + + // Updates the owner of the amm config + // Must be called by the current owner or admin + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `trade_fee_rate`- The new trade fee rate of amm config, be set when `param` is 0 + // * `protocol_fee_rate`- The new protocol fee rate of amm config, be set when `param` is 1 + // * `fund_fee_rate`- The new fund fee rate of amm config, be set when `param` is 2 + // * `new_owner`- The config's new owner, be set when `param` is 3 + // * `new_fund_owner`- The config's new fund owner, be set when `param` is 4 + // * `param`- The vaule can be 0 | 1 | 2 | 3 | 4, otherwise will report a error + // + Instruction_UpdateAmmConfig = ag_binary.TypeID([8]byte{49, 60, 174, 136, 154, 28, 116, 200}) + + // Update pool status for given vaule + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `status` - The vaule of status + // + Instruction_UpdatePoolStatus = ag_binary.TypeID([8]byte{130, 87, 108, 6, 46, 224, 117, 123}) + + // Collect the protocol fee accrued to the pool + // + // # Arguments + // + // * `ctx` - The context of accounts + // * `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1 + // * `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0 + // + Instruction_CollectProtocolFee = ag_binary.TypeID([8]byte{136, 136, 252, 221, 194, 66, 126, 89}) + + // Collect the fund fee accrued to the pool + // + // # Arguments + // + // * `ctx` - The context of accounts + // * `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1 + // * `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0 + // + Instruction_CollectFundFee = ag_binary.TypeID([8]byte{167, 138, 78, 149, 223, 194, 6, 126}) + + // Creates a pool for the given token pair and the initial price + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `init_amount_0` - the initial amount_0 to deposit + // * `init_amount_1` - the initial amount_1 to deposit + // * `open_time` - the timestamp allowed for swap + // + Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) + + // Creates a pool for the given token pair and the initial price + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `lp_token_amount` - Pool token amount to transfer. token_a and token_b amount are set by the current exchange rate and size of the pool + // * `maximum_token_0_amount` - Maximum token 0 amount to deposit, prevents excessive slippage + // * `maximum_token_1_amount` - Maximum token 1 amount to deposit, prevents excessive slippage + // + Instruction_Deposit = ag_binary.TypeID([8]byte{242, 35, 198, 137, 82, 225, 242, 182}) + + // Withdraw lp for token0 ande token1 + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `lp_token_amount` - Amount of pool tokens to burn. User receives an output of token a and b based on the percentage of the pool tokens that are returned. + // * `minimum_token_0_amount` - Minimum amount of token 0 to receive, prevents excessive slippage + // * `minimum_token_1_amount` - Minimum amount of token 1 to receive, prevents excessive slippage + // + Instruction_Withdraw = ag_binary.TypeID([8]byte{183, 18, 70, 156, 148, 109, 161, 34}) + + // Swap the tokens in the pool base input amount + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `amount_in` - input amount to transfer, output to DESTINATION is based on the exchange rate + // * `minimum_amount_out` - Minimum amount of output token, prevents excessive slippage + // + Instruction_SwapBaseInput = ag_binary.TypeID([8]byte{143, 190, 90, 218, 196, 30, 51, 222}) + + // Swap the tokens in the pool base output amount + // + // # Arguments + // + // * `ctx`- The context of accounts + // * `max_amount_in` - input amount prevents excessive slippage + // * `amount_out` - amount of output token + // + Instruction_SwapBaseOutput = ag_binary.TypeID([8]byte{55, 217, 98, 86, 163, 74, 180, 173}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_CreateAmmConfig: + return "CreateAmmConfig" + case Instruction_UpdateAmmConfig: + return "UpdateAmmConfig" + case Instruction_UpdatePoolStatus: + return "UpdatePoolStatus" + case Instruction_CollectProtocolFee: + return "CollectProtocolFee" + case Instruction_CollectFundFee: + return "CollectFundFee" + case Instruction_Initialize: + return "Initialize" + case Instruction_Deposit: + return "Deposit" + case Instruction_Withdraw: + return "Withdraw" + case Instruction_SwapBaseInput: + return "SwapBaseInput" + case Instruction_SwapBaseOutput: + return "SwapBaseOutput" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "create_amm_config", (*CreateAmmConfig)(nil), + }, + { + "update_amm_config", (*UpdateAmmConfig)(nil), + }, + { + "update_pool_status", (*UpdatePoolStatus)(nil), + }, + { + "collect_protocol_fee", (*CollectProtocolFee)(nil), + }, + { + "collect_fund_fee", (*CollectFundFee)(nil), + }, + { + "initialize", (*Initialize)(nil), + }, + { + "deposit", (*Deposit)(nil), + }, + { + "withdraw", (*Withdraw)(nil), + }, + { + "swap_base_input", (*SwapBaseInput)(nil), + }, + { + "swap_base_output", (*SwapBaseOutput)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/meteorapools/testing_utils.go b/programs/raydium_cp/testing_utils.go similarity index 96% rename from programs/meteorapools/testing_utils.go rename to programs/raydium_cp/testing_utils.go index df9b52c79..c3596e29f 100644 --- a/programs/meteorapools/testing_utils.go +++ b/programs/raydium_cp/testing_utils.go @@ -1,6 +1,6 @@ // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. -package amm +package raydium_cp import ( "bytes" diff --git a/programs/raydium_cp/types.go b/programs/raydium_cp/types.go new file mode 100644 index 000000000..6bb2e9cf0 --- /dev/null +++ b/programs/raydium_cp/types.go @@ -0,0 +1,129 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package raydium_cp + +import ag_binary "github.com/gagliardetto/binary" + +type Observation struct { + // The block timestamp of the observation + BlockTimestamp uint64 + + // the cumulative of token0 price during the duration time, Q32.32, the remaining 64 bit for overflow + CumulativeToken0PriceX32 ag_binary.Uint128 + + // the cumulative of token1 price during the duration time, Q32.32, the remaining 64 bit for overflow + CumulativeToken1PriceX32 ag_binary.Uint128 +} + +func (obj Observation) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `BlockTimestamp` param: + err = encoder.Encode(obj.BlockTimestamp) + if err != nil { + return err + } + // Serialize `CumulativeToken0PriceX32` param: + err = encoder.Encode(obj.CumulativeToken0PriceX32) + if err != nil { + return err + } + // Serialize `CumulativeToken1PriceX32` param: + err = encoder.Encode(obj.CumulativeToken1PriceX32) + if err != nil { + return err + } + return nil +} + +func (obj *Observation) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `BlockTimestamp`: + err = decoder.Decode(&obj.BlockTimestamp) + if err != nil { + return err + } + // Deserialize `CumulativeToken0PriceX32`: + err = decoder.Decode(&obj.CumulativeToken0PriceX32) + if err != nil { + return err + } + // Deserialize `CumulativeToken1PriceX32`: + err = decoder.Decode(&obj.CumulativeToken1PriceX32) + if err != nil { + return err + } + return nil +} + +type TradeDirection ag_binary.BorshEnum + +const ( + TradeDirectionZeroForOne TradeDirection = iota + TradeDirectionOneForZero +) + +func (value TradeDirection) String() string { + switch value { + case TradeDirectionZeroForOne: + return "ZeroForOne" + case TradeDirectionOneForZero: + return "OneForZero" + default: + return "" + } +} + +type RoundDirection ag_binary.BorshEnum + +const ( + RoundDirectionFloor RoundDirection = iota + RoundDirectionCeiling +) + +func (value RoundDirection) String() string { + switch value { + case RoundDirectionFloor: + return "Floor" + case RoundDirectionCeiling: + return "Ceiling" + default: + return "" + } +} + +type PoolStatusBitIndex ag_binary.BorshEnum + +const ( + PoolStatusBitIndexDeposit PoolStatusBitIndex = iota + PoolStatusBitIndexWithdraw + PoolStatusBitIndexSwap +) + +func (value PoolStatusBitIndex) String() string { + switch value { + case PoolStatusBitIndexDeposit: + return "Deposit" + case PoolStatusBitIndexWithdraw: + return "Withdraw" + case PoolStatusBitIndexSwap: + return "Swap" + default: + return "" + } +} + +type PoolStatusBitFlag ag_binary.BorshEnum + +const ( + PoolStatusBitFlagEnable PoolStatusBitFlag = iota + PoolStatusBitFlagDisable +) + +func (value PoolStatusBitFlag) String() string { + switch value { + case PoolStatusBitFlagEnable: + return "Enable" + case PoolStatusBitFlagDisable: + return "Disable" + default: + return "" + } +} diff --git a/programs/stabblestableswap/addresses.go b/programs/stabblestableswap/addresses.go deleted file mode 100644 index 4ae0a4630..000000000 --- a/programs/stabblestableswap/addresses.go +++ /dev/null @@ -1,7 +0,0 @@ -// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. - -package stable_swap - -import ag_solanago "github.com/gagliardetto/solana-go" - -var Addresses = map[string]ag_solanago.PublicKey{} diff --git a/programs/stabblestableswap/deposit.go b/programs/stabblestableswap/deposit.go deleted file mode 100644 index a5115306c..000000000 --- a/programs/stabblestableswap/deposit.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. - -package stable_swap - -import ( - "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" - ag_treeout "github.com/gagliardetto/treeout" -) - -// add liquidity -type Deposit struct { - Amounts *[]uint64 - MinimumAmountOut *uint64 - - // [0] = [SIGNER] user - // - // [1] = [WRITE] user_pool_token - // - // [2] = [WRITE] mint - // - // [3] = [WRITE] pool - // - // [4] = [] pool_authority - // - // [5] = [] vault - // - // [6] = [] vault_authority - // - // [7] = [] token_program - // - // [8] = [] token_program_2022 - ag_solanago.AccountMetaSlice `bin:"-"` -} - -// NewDepositInstructionBuilder creates a new `Deposit` instruction builder. -func NewDepositInstructionBuilder() *Deposit { - nd := &Deposit{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), - } - return nd -} - -// SetAmounts sets the "amounts" parameter. -func (inst *Deposit) SetAmounts(amounts []uint64) *Deposit { - inst.Amounts = &amounts - return inst -} - -// SetMinimumAmountOut sets the "minimum_amount_out" parameter. -func (inst *Deposit) SetMinimumAmountOut(minimum_amount_out uint64) *Deposit { - inst.MinimumAmountOut = &minimum_amount_out - return inst -} - -// SetUserAccount sets the "user" account. -func (inst *Deposit) SetUserAccount(user ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[0] = ag_solanago.Meta(user).SIGNER() - return inst -} - -// GetUserAccount gets the "user" account. -func (inst *Deposit) GetUserAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - -// SetUserPoolTokenAccount sets the "user_pool_token" account. -func (inst *Deposit) SetUserPoolTokenAccount(userPoolToken ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[1] = ag_solanago.Meta(userPoolToken).WRITE() - return inst -} - -// GetUserPoolTokenAccount gets the "user_pool_token" account. -func (inst *Deposit) GetUserPoolTokenAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - -// SetMintAccount sets the "mint" account. -func (inst *Deposit) SetMintAccount(mint ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[2] = ag_solanago.Meta(mint).WRITE() - return inst -} - -// GetMintAccount gets the "mint" account. -func (inst *Deposit) GetMintAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - -// SetPoolAccount sets the "pool" account. -func (inst *Deposit) SetPoolAccount(pool ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[3] = ag_solanago.Meta(pool).WRITE() - return inst -} - -// GetPoolAccount gets the "pool" account. -func (inst *Deposit) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) -} - -// SetPoolAuthorityAccount sets the "pool_authority" account. -func (inst *Deposit) SetPoolAuthorityAccount(poolAuthority ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[4] = ag_solanago.Meta(poolAuthority) - return inst -} - -// GetPoolAuthorityAccount gets the "pool_authority" account. -func (inst *Deposit) GetPoolAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) -} - -// SetVaultAccount sets the "vault" account. -func (inst *Deposit) SetVaultAccount(vault ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[5] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *Deposit) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(5) -} - -// SetVaultAuthorityAccount sets the "vault_authority" account. -func (inst *Deposit) SetVaultAuthorityAccount(vaultAuthority ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[6] = ag_solanago.Meta(vaultAuthority) - return inst -} - -// GetVaultAuthorityAccount gets the "vault_authority" account. -func (inst *Deposit) GetVaultAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(6) -} - -// SetTokenProgramAccount sets the "token_program" account. -func (inst *Deposit) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenProgram) - return inst -} - -// GetTokenProgramAccount gets the "token_program" account. -func (inst *Deposit) GetTokenProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(7) -} - -// SetTokenProgram2022Account sets the "token_program_2022" account. -func (inst *Deposit) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *Deposit { - inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram2022) - return inst -} - -// GetTokenProgram2022Account gets the "token_program_2022" account. -func (inst *Deposit) GetTokenProgram2022Account() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(8) -} - -func (inst Deposit) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ - Impl: inst, - TypeID: Instruction_Deposit, - }} -} - -// ValidateAndBuild validates the instruction parameters and accounts; -// if there is a validation error, it returns the error. -// Otherwise, it builds and returns the instruction. -func (inst Deposit) ValidateAndBuild() (*Instruction, error) { - if err := inst.Validate(); err != nil { - return nil, err - } - return inst.Build(), nil -} - -func (inst *Deposit) Validate() error { - // Check whether all (required) parameters are set: - { - if inst.Amounts == nil { - return errors.New("Amounts parameter is not set") - } - if inst.MinimumAmountOut == nil { - return errors.New("MinimumAmountOut parameter is not set") - } - } - - // Check whether all (required) accounts are set: - { - if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.User is not set") - } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.UserPoolToken is not set") - } - if inst.AccountMetaSlice[2] == nil { - return errors.New("accounts.Mint is not set") - } - if inst.AccountMetaSlice[3] == nil { - return errors.New("accounts.Pool is not set") - } - if inst.AccountMetaSlice[4] == nil { - return errors.New("accounts.PoolAuthority is not set") - } - if inst.AccountMetaSlice[5] == nil { - return errors.New("accounts.Vault is not set") - } - if inst.AccountMetaSlice[6] == nil { - return errors.New("accounts.VaultAuthority is not set") - } - if inst.AccountMetaSlice[7] == nil { - return errors.New("accounts.TokenProgram is not set") - } - if inst.AccountMetaSlice[8] == nil { - return errors.New("accounts.TokenProgram2022 is not set") - } - } - return nil -} - -func (inst *Deposit) EncodeToTree(parent ag_treeout.Branches) { - parent.Child(ag_format.Program(ProgramName, ProgramID)). - // - ParentFunc(func(programBranch ag_treeout.Branches) { - programBranch.Child(ag_format.Instruction("Deposit")). - // - ParentFunc(func(instructionBranch ag_treeout.Branches) { - - // Parameters of the instruction: - instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { - paramsBranch.Child(ag_format.Param(" Amounts", *inst.Amounts)) - paramsBranch.Child(ag_format.Param(" MinimumAmountOut", *inst.MinimumAmountOut)) - }) - - // Accounts of the instruction: - instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" user_pool_token", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" pool_authority", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" vault_authority", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta(" token_program", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta("token_program_2022", inst.AccountMetaSlice.Get(8))) - }) - }) - }) -} - -func (obj Deposit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `Amounts` param: - err = encoder.Encode(obj.Amounts) - if err != nil { - return err - } - // Serialize `MinimumAmountOut` param: - err = encoder.Encode(obj.MinimumAmountOut) - if err != nil { - return err - } - return nil -} -func (obj *Deposit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `Amounts`: - err = decoder.Decode(&obj.Amounts) - if err != nil { - return err - } - // Deserialize `MinimumAmountOut`: - err = decoder.Decode(&obj.MinimumAmountOut) - if err != nil { - return err - } - return nil -} - -// NewDepositInstruction declares a new Deposit instruction with the provided parameters and accounts. -func NewDepositInstruction( - // Parameters: - amounts []uint64, - minimum_amount_out uint64, - // Accounts: - user ag_solanago.PublicKey, - userPoolToken ag_solanago.PublicKey, - mint ag_solanago.PublicKey, - pool ag_solanago.PublicKey, - poolAuthority ag_solanago.PublicKey, - vault ag_solanago.PublicKey, - vaultAuthority ag_solanago.PublicKey, - tokenProgram ag_solanago.PublicKey, - tokenProgram2022 ag_solanago.PublicKey) *Deposit { - return NewDepositInstructionBuilder(). - SetAmounts(amounts). - SetMinimumAmountOut(minimum_amount_out). - SetUserAccount(user). - SetUserPoolTokenAccount(userPoolToken). - SetMintAccount(mint). - SetPoolAccount(pool). - SetPoolAuthorityAccount(poolAuthority). - SetVaultAccount(vault). - SetVaultAuthorityAccount(vaultAuthority). - SetTokenProgramAccount(tokenProgram). - SetTokenProgram2022Account(tokenProgram2022) -} diff --git a/programs/stabblestableswap/errors.go b/programs/stabblestableswap/errors.go deleted file mode 100644 index 3182e4214..000000000 --- a/programs/stabblestableswap/errors.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. - -package stable_swap - -import ( - "encoding/json" - "errors" - "fmt" - ag_jsonrpc "github.com/gagliardetto/solana-go/rpc/jsonrpc" -) - -var ( - _ *json.Encoder = nil - _ *ag_jsonrpc.RPCError = nil - _ fmt.Formatter = nil - _ = errors.ErrUnsupported -) -var ( - Errors = map[int]CustomError{} -) - -type CustomError interface { - Code() int - Name() string - Error() string -} - -type customErrorDef struct { - code int - name string - msg string -} - -func (e *customErrorDef) Code() int { - return e.code -} - -func (e *customErrorDef) Name() string { - return e.name -} - -func (e *customErrorDef) Error() string { - return fmt.Sprintf("%s(%d): %s", e.name, e.code, e.msg) -} - -func DecodeCustomError(rpcErr error) (err error, ok bool) { - if errCode, o := decodeErrorCode(rpcErr); o { - if customErr, o := Errors[errCode]; o { - err = customErr - ok = true - return - } - } - return -} - -func decodeErrorCode(rpcErr error) (errorCode int, ok bool) { - var jErr *ag_jsonrpc.RPCError - if errors.As(rpcErr, &jErr) && jErr.Data != nil { - if root, o := jErr.Data.(map[string]interface{}); o { - if rootErr, o := root["err"].(map[string]interface{}); o { - if rootErrInstructionError, o := rootErr["InstructionError"]; o { - if rootErrInstructionErrorItems, o := rootErrInstructionError.([]interface{}); o { - if len(rootErrInstructionErrorItems) == 2 { - if v, o := rootErrInstructionErrorItems[1].(map[string]interface{}); o { - if v2, o := v["Custom"].(json.Number); o { - if code, err := v2.Int64(); err == nil { - ok = true - errorCode = int(code) - } - } else if v2, o := v["Custom"].(float64); o { - ok = true - errorCode = int(v2) - } - } - } - } - } - } - } - } - return -} diff --git a/programs/stabblestableswap/withdraw.go b/programs/stabblestableswap/withdraw.go deleted file mode 100644 index e9d15d8c9..000000000 --- a/programs/stabblestableswap/withdraw.go +++ /dev/null @@ -1,321 +0,0 @@ -// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. - -package stable_swap - -import ( - "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" - ag_treeout "github.com/gagliardetto/treeout" -) - -// remove liquidity -type Withdraw struct { - Amount *uint64 - MinimumAmountsOut *[]uint64 - - // [0] = [SIGNER] user - // - // [1] = [WRITE] user_pool_token - // - // [2] = [WRITE] mint - // - // [3] = [WRITE] pool - // - // [4] = [] withdraw_authority - // - // [5] = [] vault - // - // [6] = [] vault_authority - // - // [7] = [] vault_program - // - // [8] = [] token_program - // - // [9] = [] token_program_2022 - ag_solanago.AccountMetaSlice `bin:"-"` -} - -// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. -func NewWithdrawInstructionBuilder() *Withdraw { - nd := &Withdraw{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 10), - } - return nd -} - -// SetAmount sets the "amount" parameter. -func (inst *Withdraw) SetAmount(amount uint64) *Withdraw { - inst.Amount = &amount - return inst -} - -// SetMinimumAmountsOut sets the "minimum_amounts_out" parameter. -func (inst *Withdraw) SetMinimumAmountsOut(minimum_amounts_out []uint64) *Withdraw { - inst.MinimumAmountsOut = &minimum_amounts_out - return inst -} - -// SetUserAccount sets the "user" account. -func (inst *Withdraw) SetUserAccount(user ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[0] = ag_solanago.Meta(user).SIGNER() - return inst -} - -// GetUserAccount gets the "user" account. -func (inst *Withdraw) GetUserAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - -// SetUserPoolTokenAccount sets the "user_pool_token" account. -func (inst *Withdraw) SetUserPoolTokenAccount(userPoolToken ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[1] = ag_solanago.Meta(userPoolToken).WRITE() - return inst -} - -// GetUserPoolTokenAccount gets the "user_pool_token" account. -func (inst *Withdraw) GetUserPoolTokenAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - -// SetMintAccount sets the "mint" account. -func (inst *Withdraw) SetMintAccount(mint ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[2] = ag_solanago.Meta(mint).WRITE() - return inst -} - -// GetMintAccount gets the "mint" account. -func (inst *Withdraw) GetMintAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - -// SetPoolAccount sets the "pool" account. -func (inst *Withdraw) SetPoolAccount(pool ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[3] = ag_solanago.Meta(pool).WRITE() - return inst -} - -// GetPoolAccount gets the "pool" account. -func (inst *Withdraw) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) -} - -// SetWithdrawAuthorityAccount sets the "withdraw_authority" account. -func (inst *Withdraw) SetWithdrawAuthorityAccount(withdrawAuthority ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[4] = ag_solanago.Meta(withdrawAuthority) - return inst -} - -// GetWithdrawAuthorityAccount gets the "withdraw_authority" account. -func (inst *Withdraw) GetWithdrawAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) -} - -// SetVaultAccount sets the "vault" account. -func (inst *Withdraw) SetVaultAccount(vault ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[5] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *Withdraw) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(5) -} - -// SetVaultAuthorityAccount sets the "vault_authority" account. -func (inst *Withdraw) SetVaultAuthorityAccount(vaultAuthority ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[6] = ag_solanago.Meta(vaultAuthority) - return inst -} - -// GetVaultAuthorityAccount gets the "vault_authority" account. -func (inst *Withdraw) GetVaultAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(6) -} - -// SetVaultProgramAccount sets the "vault_program" account. -func (inst *Withdraw) SetVaultProgramAccount(vaultProgram ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[7] = ag_solanago.Meta(vaultProgram) - return inst -} - -// GetVaultProgramAccount gets the "vault_program" account. -func (inst *Withdraw) GetVaultProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(7) -} - -// SetTokenProgramAccount sets the "token_program" account. -func (inst *Withdraw) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) - return inst -} - -// GetTokenProgramAccount gets the "token_program" account. -func (inst *Withdraw) GetTokenProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(8) -} - -// SetTokenProgram2022Account sets the "token_program_2022" account. -func (inst *Withdraw) SetTokenProgram2022Account(tokenProgram2022 ag_solanago.PublicKey) *Withdraw { - inst.AccountMetaSlice[9] = ag_solanago.Meta(tokenProgram2022) - return inst -} - -// GetTokenProgram2022Account gets the "token_program_2022" account. -func (inst *Withdraw) GetTokenProgram2022Account() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(9) -} - -func (inst Withdraw) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ - Impl: inst, - TypeID: Instruction_Withdraw, - }} -} - -// ValidateAndBuild validates the instruction parameters and accounts; -// if there is a validation error, it returns the error. -// Otherwise, it builds and returns the instruction. -func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { - if err := inst.Validate(); err != nil { - return nil, err - } - return inst.Build(), nil -} - -func (inst *Withdraw) Validate() error { - // Check whether all (required) parameters are set: - { - if inst.Amount == nil { - return errors.New("Amount parameter is not set") - } - if inst.MinimumAmountsOut == nil { - return errors.New("MinimumAmountsOut parameter is not set") - } - } - - // Check whether all (required) accounts are set: - { - if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.User is not set") - } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.UserPoolToken is not set") - } - if inst.AccountMetaSlice[2] == nil { - return errors.New("accounts.Mint is not set") - } - if inst.AccountMetaSlice[3] == nil { - return errors.New("accounts.Pool is not set") - } - if inst.AccountMetaSlice[4] == nil { - return errors.New("accounts.WithdrawAuthority is not set") - } - if inst.AccountMetaSlice[5] == nil { - return errors.New("accounts.Vault is not set") - } - if inst.AccountMetaSlice[6] == nil { - return errors.New("accounts.VaultAuthority is not set") - } - if inst.AccountMetaSlice[7] == nil { - return errors.New("accounts.VaultProgram is not set") - } - if inst.AccountMetaSlice[8] == nil { - return errors.New("accounts.TokenProgram is not set") - } - if inst.AccountMetaSlice[9] == nil { - return errors.New("accounts.TokenProgram2022 is not set") - } - } - return nil -} - -func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { - parent.Child(ag_format.Program(ProgramName, ProgramID)). - // - ParentFunc(func(programBranch ag_treeout.Branches) { - programBranch.Child(ag_format.Instruction("Withdraw")). - // - ParentFunc(func(instructionBranch ag_treeout.Branches) { - - // Parameters of the instruction: - instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { - paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) - paramsBranch.Child(ag_format.Param(" MinimumAmountsOut", *inst.MinimumAmountsOut)) - }) - - // Accounts of the instruction: - instructionBranch.Child("Accounts[len=10]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" user_pool_token", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta("withdraw_authority", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" vault_authority", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta(" vault_program", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta(" token_program", inst.AccountMetaSlice.Get(8))) - accountsBranch.Child(ag_format.Meta("token_program_2022", inst.AccountMetaSlice.Get(9))) - }) - }) - }) -} - -func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `Amount` param: - err = encoder.Encode(obj.Amount) - if err != nil { - return err - } - // Serialize `MinimumAmountsOut` param: - err = encoder.Encode(obj.MinimumAmountsOut) - if err != nil { - return err - } - return nil -} -func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `Amount`: - err = decoder.Decode(&obj.Amount) - if err != nil { - return err - } - // Deserialize `MinimumAmountsOut`: - err = decoder.Decode(&obj.MinimumAmountsOut) - if err != nil { - return err - } - return nil -} - -// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. -func NewWithdrawInstruction( - // Parameters: - amount uint64, - minimum_amounts_out []uint64, - // Accounts: - user ag_solanago.PublicKey, - userPoolToken ag_solanago.PublicKey, - mint ag_solanago.PublicKey, - pool ag_solanago.PublicKey, - withdrawAuthority ag_solanago.PublicKey, - vault ag_solanago.PublicKey, - vaultAuthority ag_solanago.PublicKey, - vaultProgram ag_solanago.PublicKey, - tokenProgram ag_solanago.PublicKey, - tokenProgram2022 ag_solanago.PublicKey) *Withdraw { - return NewWithdrawInstructionBuilder(). - SetAmount(amount). - SetMinimumAmountsOut(minimum_amounts_out). - SetUserAccount(user). - SetUserPoolTokenAccount(userPoolToken). - SetMintAccount(mint). - SetPoolAccount(pool). - SetWithdrawAuthorityAccount(withdrawAuthority). - SetVaultAccount(vault). - SetVaultAuthorityAccount(vaultAuthority). - SetVaultProgramAccount(vaultProgram). - SetTokenProgramAccount(tokenProgram). - SetTokenProgram2022Account(tokenProgram2022) -} diff --git a/programs/stabblestableswap/acceptowner.go b/programs/stable_swap/AcceptOwner.go similarity index 72% rename from programs/stabblestableswap/acceptowner.go rename to programs/stable_swap/AcceptOwner.go index 2314bb2c1..943ba9d33 100644 --- a/programs/stabblestableswap/acceptowner.go +++ b/programs/stable_swap/AcceptOwner.go @@ -13,40 +13,27 @@ import ( // AcceptOwner is the `accept_owner` instruction. type AcceptOwner struct { - // [0] = [SIGNER] pending_owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewAcceptOwnerInstructionBuilder creates a new `AcceptOwner` instruction builder. func NewAcceptOwnerInstructionBuilder() *AcceptOwner { nd := &AcceptOwner{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } -// SetPendingOwnerAccount sets the "pending_owner" account. -func (inst *AcceptOwner) SetPendingOwnerAccount(pendingOwner ag_solanago.PublicKey) *AcceptOwner { - inst.AccountMetaSlice[0] = ag_solanago.Meta(pendingOwner).SIGNER() - return inst -} - -// GetPendingOwnerAccount gets the "pending_owner" account. -func (inst *AcceptOwner) GetPendingOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *AcceptOwner) SetPoolAccount(pool ag_solanago.PublicKey) *AcceptOwner { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *AcceptOwner) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst AcceptOwner) Build() *Instruction { @@ -70,9 +57,6 @@ func (inst *AcceptOwner) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.PendingOwner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -91,9 +75,8 @@ func (inst *AcceptOwner) EncodeToTree(parent ag_treeout.Branches) { instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("pending_owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -109,9 +92,7 @@ func (obj *AcceptOwner) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err er // NewAcceptOwnerInstruction declares a new AcceptOwner instruction with the provided parameters and accounts. func NewAcceptOwnerInstruction( // Accounts: - pendingOwner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *AcceptOwner { return NewAcceptOwnerInstructionBuilder(). - SetPendingOwnerAccount(pendingOwner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/acceptowner_test.go b/programs/stable_swap/AcceptOwner_test.go similarity index 100% rename from programs/stabblestableswap/acceptowner_test.go rename to programs/stable_swap/AcceptOwner_test.go diff --git a/programs/stabblestableswap/approvestrategy.go b/programs/stable_swap/ApproveStrategy.go similarity index 56% rename from programs/stabblestableswap/approvestrategy.go rename to programs/stable_swap/ApproveStrategy.go index 14d6e6334..78ab0b273 100644 --- a/programs/stabblestableswap/approvestrategy.go +++ b/programs/stable_swap/ApproveStrategy.go @@ -13,51 +13,32 @@ import ( // ApproveStrategy is the `approve_strategy` instruction. type ApproveStrategy struct { - // [0] = [] admin_only + // ····· admin_only: [0] = [WRITE] pool // - // ····· admin_only: [1] = [WRITE] pool - // - // ················· [2] = [] vault - // - // ················· [3] = [SIGNER] admin - // - // [4] = [WRITE] strategy + // [1] = [WRITE] strategy ag_solanago.AccountMetaSlice `bin:"-"` } // NewApproveStrategyInstructionBuilder creates a new `ApproveStrategy` instruction builder. func NewApproveStrategyInstructionBuilder() *ApproveStrategy { nd := &ApproveStrategy{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), } return nd } -// SetAdminOnlyAccount sets the "admin_only" account. -func (inst *ApproveStrategy) SetAdminOnlyAccount(adminOnly ag_solanago.PublicKey) *ApproveStrategy { - inst.AccountMetaSlice[0] = ag_solanago.Meta(adminOnly) - return inst -} - -// GetAdminOnlyAccount gets the "admin_only" account. -func (inst *ApproveStrategy) GetAdminOnlyAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - type ApproveStrategyAdminOnlyAccountsBuilder struct { ag_solanago.AccountMetaSlice `bin:"-"` } func NewApproveStrategyAdminOnlyAccountsBuilder() *ApproveStrategyAdminOnlyAccountsBuilder { return &ApproveStrategyAdminOnlyAccountsBuilder{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } } func (inst *ApproveStrategy) SetAdminOnlyAccountsFromBuilder(approveStrategyAdminOnlyAccountsBuilder *ApproveStrategyAdminOnlyAccountsBuilder) *ApproveStrategy { - inst.AccountMetaSlice[1] = approveStrategyAdminOnlyAccountsBuilder.GetPoolAccount() - inst.AccountMetaSlice[2] = approveStrategyAdminOnlyAccountsBuilder.GetVaultAccount() - inst.AccountMetaSlice[3] = approveStrategyAdminOnlyAccountsBuilder.GetAdminAccount() + inst.AccountMetaSlice[0] = approveStrategyAdminOnlyAccountsBuilder.GetPoolAccount() return inst } @@ -72,37 +53,15 @@ func (inst *ApproveStrategyAdminOnlyAccountsBuilder) GetPoolAccount() *ag_solana return inst.AccountMetaSlice.Get(0) } -// SetVaultAccount sets the "vault" account. -func (inst *ApproveStrategyAdminOnlyAccountsBuilder) SetVaultAccount(vault ag_solanago.PublicKey) *ApproveStrategyAdminOnlyAccountsBuilder { - inst.AccountMetaSlice[1] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *ApproveStrategyAdminOnlyAccountsBuilder) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - -// SetAdminAccount sets the "admin" account. -func (inst *ApproveStrategyAdminOnlyAccountsBuilder) SetAdminAccount(admin ag_solanago.PublicKey) *ApproveStrategyAdminOnlyAccountsBuilder { - inst.AccountMetaSlice[2] = ag_solanago.Meta(admin).SIGNER() - return inst -} - -// GetAdminAccount gets the "admin" account. -func (inst *ApproveStrategyAdminOnlyAccountsBuilder) GetAdminAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - // SetStrategyAccount sets the "strategy" account. func (inst *ApproveStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *ApproveStrategy { - inst.AccountMetaSlice[4] = ag_solanago.Meta(strategy).WRITE() + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() return inst } // GetStrategyAccount gets the "strategy" account. func (inst *ApproveStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) + return inst.AccountMetaSlice.Get(1) } func (inst ApproveStrategy) Build() *Instruction { @@ -126,18 +85,9 @@ func (inst *ApproveStrategy) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.AdminOnly is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.AdminOnlyPool is not set") } - if inst.AccountMetaSlice[2] == nil { - return errors.New("accounts.AdminOnlyVault is not set") - } - if inst.AccountMetaSlice[3] == nil { - return errors.New("accounts.AdminOnlyAdmin is not set") - } - if inst.AccountMetaSlice[4] == nil { + if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Strategy is not set") } } @@ -156,12 +106,9 @@ func (inst *ApproveStrategy) EncodeToTree(parent ag_treeout.Branches) { instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" admin_only", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" admin_only/pool", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta("admin_only/vault", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta("admin_only/admin", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(4))) + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("admin_only/pool", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) }) }) }) @@ -177,18 +124,11 @@ func (obj *ApproveStrategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (er // NewApproveStrategyInstruction declares a new ApproveStrategy instruction with the provided parameters and accounts. func NewApproveStrategyInstruction( // Accounts: - adminOnly ag_solanago.PublicKey, adminOnlyPool ag_solanago.PublicKey, - adminOnlyVault ag_solanago.PublicKey, - adminOnlyAdmin ag_solanago.PublicKey, strategy ag_solanago.PublicKey) *ApproveStrategy { return NewApproveStrategyInstructionBuilder(). - SetAdminOnlyAccount(adminOnly). SetAdminOnlyAccountsFromBuilder( NewApproveStrategyAdminOnlyAccountsBuilder(). - SetPoolAccount(adminOnlyPool). - SetVaultAccount(adminOnlyVault). - SetAdminAccount(adminOnlyAdmin), - ). + SetPoolAccount(adminOnlyPool)). SetStrategyAccount(strategy) } diff --git a/programs/stabblestableswap/approvestrategy_test.go b/programs/stable_swap/ApproveStrategy_test.go similarity index 100% rename from programs/stabblestableswap/approvestrategy_test.go rename to programs/stable_swap/ApproveStrategy_test.go diff --git a/programs/stabblestableswap/changeampfactor.go b/programs/stable_swap/ChangeAmpFactor.go similarity index 73% rename from programs/stabblestableswap/changeampfactor.go rename to programs/stable_swap/ChangeAmpFactor.go index 65018d653..041eb99c8 100644 --- a/programs/stabblestableswap/changeampfactor.go +++ b/programs/stable_swap/ChangeAmpFactor.go @@ -16,17 +16,13 @@ type ChangeAmpFactor struct { RampDuration *uint32 // [0] = [WRITE] pool - // - // [1] = [] vault - // - // [2] = [SIGNER] admin ag_solanago.AccountMetaSlice `bin:"-"` } // NewChangeAmpFactorInstructionBuilder creates a new `ChangeAmpFactor` instruction builder. func NewChangeAmpFactorInstructionBuilder() *ChangeAmpFactor { nd := &ChangeAmpFactor{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } @@ -54,28 +50,6 @@ func (inst *ChangeAmpFactor) GetPoolAccount() *ag_solanago.AccountMeta { return inst.AccountMetaSlice.Get(0) } -// SetVaultAccount sets the "vault" account. -func (inst *ChangeAmpFactor) SetVaultAccount(vault ag_solanago.PublicKey) *ChangeAmpFactor { - inst.AccountMetaSlice[1] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *ChangeAmpFactor) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - -// SetAdminAccount sets the "admin" account. -func (inst *ChangeAmpFactor) SetAdminAccount(admin ag_solanago.PublicKey) *ChangeAmpFactor { - inst.AccountMetaSlice[2] = ag_solanago.Meta(admin).SIGNER() - return inst -} - -// GetAdminAccount gets the "admin" account. -func (inst *ChangeAmpFactor) GetAdminAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - func (inst ChangeAmpFactor) Build() *Instruction { return &Instruction{BaseVariant: ag_binary.BaseVariant{ Impl: inst, @@ -109,12 +83,6 @@ func (inst *ChangeAmpFactor) Validate() error { if inst.AccountMetaSlice[0] == nil { return errors.New("accounts.Pool is not set") } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.Vault is not set") - } - if inst.AccountMetaSlice[2] == nil { - return errors.New("accounts.Admin is not set") - } } return nil } @@ -134,10 +102,8 @@ func (inst *ChangeAmpFactor) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta("vault", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta("admin", inst.AccountMetaSlice.Get(2))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -176,13 +142,9 @@ func NewChangeAmpFactorInstruction( new_amp_factor uint16, ramp_duration uint32, // Accounts: - pool ag_solanago.PublicKey, - vault ag_solanago.PublicKey, - admin ag_solanago.PublicKey) *ChangeAmpFactor { + pool ag_solanago.PublicKey) *ChangeAmpFactor { return NewChangeAmpFactorInstructionBuilder(). SetNewAmpFactor(new_amp_factor). SetRampDuration(ramp_duration). - SetPoolAccount(pool). - SetVaultAccount(vault). - SetAdminAccount(admin) + SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/changeampfactor_test.go b/programs/stable_swap/ChangeAmpFactor_test.go similarity index 100% rename from programs/stabblestableswap/changeampfactor_test.go rename to programs/stable_swap/ChangeAmpFactor_test.go diff --git a/programs/stabblestableswap/changeswapfee.go b/programs/stable_swap/ChangeSwapFee.go similarity index 78% rename from programs/stabblestableswap/changeswapfee.go rename to programs/stable_swap/ChangeSwapFee.go index 1c324979a..03761153b 100644 --- a/programs/stabblestableswap/changeswapfee.go +++ b/programs/stable_swap/ChangeSwapFee.go @@ -14,16 +14,14 @@ import ( type ChangeSwapFee struct { NewSwapFee *uint64 - // [0] = [SIGNER] owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewChangeSwapFeeInstructionBuilder creates a new `ChangeSwapFee` instruction builder. func NewChangeSwapFeeInstructionBuilder() *ChangeSwapFee { nd := &ChangeSwapFee{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } @@ -34,26 +32,15 @@ func (inst *ChangeSwapFee) SetNewSwapFee(new_swap_fee uint64) *ChangeSwapFee { return inst } -// SetOwnerAccount sets the "owner" account. -func (inst *ChangeSwapFee) SetOwnerAccount(owner ag_solanago.PublicKey) *ChangeSwapFee { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *ChangeSwapFee) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *ChangeSwapFee) SetPoolAccount(pool ag_solanago.PublicKey) *ChangeSwapFee { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *ChangeSwapFee) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst ChangeSwapFee) Build() *Instruction { @@ -84,9 +71,6 @@ func (inst *ChangeSwapFee) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Owner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -107,9 +91,8 @@ func (inst *ChangeSwapFee) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -137,10 +120,8 @@ func NewChangeSwapFeeInstruction( // Parameters: new_swap_fee uint64, // Accounts: - owner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *ChangeSwapFee { return NewChangeSwapFeeInstructionBuilder(). SetNewSwapFee(new_swap_fee). - SetOwnerAccount(owner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/changeswapfee_test.go b/programs/stable_swap/ChangeSwapFee_test.go similarity index 100% rename from programs/stabblestableswap/changeswapfee_test.go rename to programs/stable_swap/ChangeSwapFee_test.go diff --git a/programs/stabblestableswap/createstrategy.go b/programs/stable_swap/CreateStrategy.go similarity index 79% rename from programs/stabblestableswap/createstrategy.go rename to programs/stable_swap/CreateStrategy.go index b19b688e0..32ef64322 100644 --- a/programs/stabblestableswap/createstrategy.go +++ b/programs/stable_swap/CreateStrategy.go @@ -19,20 +19,16 @@ type CreateStrategy struct { RampMinDuration *uint32 RampMaxDuration *uint32 - // [0] = [] owner_only + // ····· owner_only: [0] = [WRITE] pool // - // ····· owner_only: [1] = [SIGNER] owner - // - // ················· [2] = [WRITE] pool - // - // [3] = [WRITE] strategy + // [1] = [WRITE] strategy ag_solanago.AccountMetaSlice `bin:"-"` } // NewCreateStrategyInstructionBuilder creates a new `CreateStrategy` instruction builder. func NewCreateStrategyInstructionBuilder() *CreateStrategy { nd := &CreateStrategy{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), } return nd } @@ -73,64 +69,41 @@ func (inst *CreateStrategy) SetRampMaxDuration(ramp_max_duration uint32) *Create return inst } -// SetOwnerOnlyAccount sets the "owner_only" account. -func (inst *CreateStrategy) SetOwnerOnlyAccount(ownerOnly ag_solanago.PublicKey) *CreateStrategy { - inst.AccountMetaSlice[0] = ag_solanago.Meta(ownerOnly) - return inst -} - -// GetOwnerOnlyAccount gets the "owner_only" account. -func (inst *CreateStrategy) GetOwnerOnlyAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - type CreateStrategyOwnerOnlyAccountsBuilder struct { ag_solanago.AccountMetaSlice `bin:"-"` } func NewCreateStrategyOwnerOnlyAccountsBuilder() *CreateStrategyOwnerOnlyAccountsBuilder { return &CreateStrategyOwnerOnlyAccountsBuilder{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } } func (inst *CreateStrategy) SetOwnerOnlyAccountsFromBuilder(createStrategyOwnerOnlyAccountsBuilder *CreateStrategyOwnerOnlyAccountsBuilder) *CreateStrategy { - inst.AccountMetaSlice[1] = createStrategyOwnerOnlyAccountsBuilder.GetOwnerAccount() - inst.AccountMetaSlice[2] = createStrategyOwnerOnlyAccountsBuilder.GetPoolAccount() + inst.AccountMetaSlice[1] = createStrategyOwnerOnlyAccountsBuilder.GetPoolAccount() return inst } -// SetOwnerAccount sets the "owner" account. -func (inst *CreateStrategyOwnerOnlyAccountsBuilder) SetOwnerAccount(owner ag_solanago.PublicKey) *CreateStrategyOwnerOnlyAccountsBuilder { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *CreateStrategyOwnerOnlyAccountsBuilder) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *CreateStrategyOwnerOnlyAccountsBuilder) SetPoolAccount(pool ag_solanago.PublicKey) *CreateStrategyOwnerOnlyAccountsBuilder { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *CreateStrategyOwnerOnlyAccountsBuilder) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } // SetStrategyAccount sets the "strategy" account. func (inst *CreateStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *CreateStrategy { - inst.AccountMetaSlice[3] = ag_solanago.Meta(strategy).WRITE() + inst.AccountMetaSlice[1] = ag_solanago.Meta(strategy).WRITE() return inst } // GetStrategyAccount gets the "strategy" account. func (inst *CreateStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) + return inst.AccountMetaSlice.Get(1) } func (inst CreateStrategy) Build() *Instruction { @@ -176,15 +149,9 @@ func (inst *CreateStrategy) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.OwnerOnly is not set") - } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.OwnerOnlyOwner is not set") - } - if inst.AccountMetaSlice[2] == nil { return errors.New("accounts.OwnerOnlyPool is not set") } - if inst.AccountMetaSlice[3] == nil { + if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Strategy is not set") } } @@ -210,11 +177,9 @@ func (inst *CreateStrategy) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" owner_only", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta("owner_only/owner", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" owner_only/pool", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(3))) + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("owner_only/pool", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" strategy", inst.AccountMetaSlice.Get(1))) }) }) }) @@ -297,8 +262,6 @@ func NewCreateStrategyInstruction( ramp_min_duration uint32, ramp_max_duration uint32, // Accounts: - ownerOnly ag_solanago.PublicKey, - ownerOnlyOwner ag_solanago.PublicKey, ownerOnlyPool ag_solanago.PublicKey, strategy ag_solanago.PublicKey) *CreateStrategy { return NewCreateStrategyInstructionBuilder(). @@ -308,10 +271,8 @@ func NewCreateStrategyInstruction( SetRampMaxStep(ramp_max_step). SetRampMinDuration(ramp_min_duration). SetRampMaxDuration(ramp_max_duration). - SetOwnerOnlyAccount(ownerOnly). SetOwnerOnlyAccountsFromBuilder( NewCreateStrategyOwnerOnlyAccountsBuilder(). - SetOwnerAccount(ownerOnlyOwner). SetPoolAccount(ownerOnlyPool), ). SetStrategyAccount(strategy) diff --git a/programs/stabblestableswap/createstrategy_test.go b/programs/stable_swap/CreateStrategy_test.go similarity index 100% rename from programs/stabblestableswap/createstrategy_test.go rename to programs/stable_swap/CreateStrategy_test.go diff --git a/programs/stable_swap/Deposit.go b/programs/stable_swap/Deposit.go new file mode 100644 index 000000000..e632c98d6 --- /dev/null +++ b/programs/stable_swap/Deposit.go @@ -0,0 +1,188 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_swap + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// addliquidity +type Deposit struct { + Amounts *[]uint64 + MinimumAmountOut *uint64 + + // [0] = [WRITE] user_pool_token + // + // [1] = [WRITE] mint + // + // [2] = [WRITE] pool + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewDepositInstructionBuilder creates a new `Deposit` instruction builder. +func NewDepositInstructionBuilder() *Deposit { + nd := &Deposit{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetAmounts sets the "amounts" parameter. +func (inst *Deposit) SetAmounts(amounts []uint64) *Deposit { + inst.Amounts = &amounts + return inst +} + +// SetMinimumAmountOut sets the "minimum_amount_out" parameter. +func (inst *Deposit) SetMinimumAmountOut(minimum_amount_out uint64) *Deposit { + inst.MinimumAmountOut = &minimum_amount_out + return inst +} + +// SetUserPoolTokenAccount sets the "user_pool_token" account. +func (inst *Deposit) SetUserPoolTokenAccount(userPoolToken ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[0] = ag_solanago.Meta(userPoolToken).WRITE() + return inst +} + +// GetUserPoolTokenAccount gets the "user_pool_token" account. +func (inst *Deposit) GetUserPoolTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetMintAccount sets the "mint" account. +func (inst *Deposit) SetMintAccount(mint ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[1] = ag_solanago.Meta(mint).WRITE() + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Deposit) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolAccount sets the "pool" account. +func (inst *Deposit) SetPoolAccount(pool ag_solanago.PublicKey) *Deposit { + inst.AccountMetaSlice[2] = ag_solanago.Meta(pool).WRITE() + return inst +} + +// GetPoolAccount gets the "pool" account. +func (inst *Deposit) GetPoolAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst Deposit) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Deposit, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Deposit) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Deposit) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amounts == nil { + return errors.New("Amounts parameter is not set") + } + if inst.MinimumAmountOut == nil { + return errors.New("MinimumAmountOut parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.UserPoolToken is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Pool is not set") + } + } + return nil +} + +func (inst *Deposit) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Deposit")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amounts", *inst.Amounts)) + paramsBranch.Child(ag_format.Param(" MinimumAmountOut", *inst.MinimumAmountOut)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("user_pool_token", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj Deposit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amounts` param: + err = encoder.Encode(obj.Amounts) + if err != nil { + return err + } + // Serialize `MinimumAmountOut` param: + err = encoder.Encode(obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} +func (obj *Deposit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amounts`: + err = decoder.Decode(&obj.Amounts) + if err != nil { + return err + } + // Deserialize `MinimumAmountOut`: + err = decoder.Decode(&obj.MinimumAmountOut) + if err != nil { + return err + } + return nil +} + +// NewDepositInstruction declares a new Deposit instruction with the provided parameters and accounts. +func NewDepositInstruction( + // Parameters: + amounts []uint64, + minimum_amount_out uint64, + // Accounts: + userPoolToken ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + pool ag_solanago.PublicKey) *Deposit { + return NewDepositInstructionBuilder(). + SetAmounts(amounts). + SetMinimumAmountOut(minimum_amount_out). + SetUserPoolTokenAccount(userPoolToken). + SetMintAccount(mint). + SetPoolAccount(pool) +} diff --git a/programs/stabblestableswap/deposit_test.go b/programs/stable_swap/Deposit_test.go similarity index 100% rename from programs/stabblestableswap/deposit_test.go rename to programs/stable_swap/Deposit_test.go diff --git a/programs/stabblestableswap/execstrategy.go b/programs/stable_swap/ExecStrategy.go similarity index 80% rename from programs/stabblestableswap/execstrategy.go rename to programs/stable_swap/ExecStrategy.go index 58a9fa9f5..51cec87a2 100644 --- a/programs/stabblestableswap/execstrategy.go +++ b/programs/stable_swap/ExecStrategy.go @@ -15,16 +15,14 @@ type ExecStrategy struct { RampStep *uint16 RampDuration *uint32 - // [0] = [] strategy - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewExecStrategyInstructionBuilder creates a new `ExecStrategy` instruction builder. func NewExecStrategyInstructionBuilder() *ExecStrategy { nd := &ExecStrategy{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } @@ -41,26 +39,15 @@ func (inst *ExecStrategy) SetRampDuration(ramp_duration uint32) *ExecStrategy { return inst } -// SetStrategyAccount sets the "strategy" account. -func (inst *ExecStrategy) SetStrategyAccount(strategy ag_solanago.PublicKey) *ExecStrategy { - inst.AccountMetaSlice[0] = ag_solanago.Meta(strategy) - return inst -} - -// GetStrategyAccount gets the "strategy" account. -func (inst *ExecStrategy) GetStrategyAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *ExecStrategy) SetPoolAccount(pool ag_solanago.PublicKey) *ExecStrategy { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *ExecStrategy) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst ExecStrategy) Build() *Instruction { @@ -94,9 +81,6 @@ func (inst *ExecStrategy) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Strategy is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -118,9 +102,8 @@ func (inst *ExecStrategy) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("strategy", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -159,11 +142,9 @@ func NewExecStrategyInstruction( ramp_step uint16, ramp_duration uint32, // Accounts: - strategy ag_solanago.PublicKey, pool ag_solanago.PublicKey) *ExecStrategy { return NewExecStrategyInstructionBuilder(). SetRampStep(ramp_step). SetRampDuration(ramp_duration). - SetStrategyAccount(strategy). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/execstrategy_test.go b/programs/stable_swap/ExecStrategy_test.go similarity index 100% rename from programs/stabblestableswap/execstrategy_test.go rename to programs/stable_swap/ExecStrategy_test.go diff --git a/programs/stabblestableswap/initialize.go b/programs/stable_swap/Initialize.go similarity index 53% rename from programs/stabblestableswap/initialize.go rename to programs/stable_swap/Initialize.go index 7b500f6d9..0d3794536 100644 --- a/programs/stabblestableswap/initialize.go +++ b/programs/stable_swap/Initialize.go @@ -10,30 +10,20 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -// initialize a pool +// initializeapool type Initialize struct { AmpFactor *uint16 SwapFee *uint64 MaxCaps *[]uint64 - // [0] = [SIGNER] owner - // - // [1] = [] mint - // - // [2] = [WRITE] pool - // - // [3] = [] pool_authority - // - // [4] = [] withdraw_authority - // - // [5] = [] vault + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. func NewInitializeInstructionBuilder() *Initialize { nd := &Initialize{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } @@ -56,70 +46,15 @@ func (inst *Initialize) SetMaxCaps(max_caps []uint64) *Initialize { return inst } -// SetOwnerAccount sets the "owner" account. -func (inst *Initialize) SetOwnerAccount(owner ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *Initialize) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - -// SetMintAccount sets the "mint" account. -func (inst *Initialize) SetMintAccount(mint ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[1] = ag_solanago.Meta(mint) - return inst -} - -// GetMintAccount gets the "mint" account. -func (inst *Initialize) GetMintAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - // SetPoolAccount sets the "pool" account. func (inst *Initialize) SetPoolAccount(pool ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[2] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *Initialize) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - -// SetPoolAuthorityAccount sets the "pool_authority" account. -func (inst *Initialize) SetPoolAuthorityAccount(poolAuthority ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[3] = ag_solanago.Meta(poolAuthority) - return inst -} - -// GetPoolAuthorityAccount gets the "pool_authority" account. -func (inst *Initialize) GetPoolAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) -} - -// SetWithdrawAuthorityAccount sets the "withdraw_authority" account. -func (inst *Initialize) SetWithdrawAuthorityAccount(withdrawAuthority ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[4] = ag_solanago.Meta(withdrawAuthority) - return inst -} - -// GetWithdrawAuthorityAccount gets the "withdraw_authority" account. -func (inst *Initialize) GetWithdrawAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) -} - -// SetVaultAccount sets the "vault" account. -func (inst *Initialize) SetVaultAccount(vault ag_solanago.PublicKey) *Initialize { - inst.AccountMetaSlice[5] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *Initialize) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(5) + return inst.AccountMetaSlice.Get(0) } func (inst Initialize) Build() *Instruction { @@ -156,23 +91,8 @@ func (inst *Initialize) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Owner is not set") - } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.Mint is not set") - } - if inst.AccountMetaSlice[2] == nil { return errors.New("accounts.Pool is not set") } - if inst.AccountMetaSlice[3] == nil { - return errors.New("accounts.PoolAuthority is not set") - } - if inst.AccountMetaSlice[4] == nil { - return errors.New("accounts.WithdrawAuthority is not set") - } - if inst.AccountMetaSlice[5] == nil { - return errors.New("accounts.Vault is not set") - } } return nil } @@ -193,13 +113,8 @@ func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" pool_authority", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta("withdraw_authority", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(5))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -249,20 +164,10 @@ func NewInitializeInstruction( swap_fee uint64, max_caps []uint64, // Accounts: - owner ag_solanago.PublicKey, - mint ag_solanago.PublicKey, - pool ag_solanago.PublicKey, - poolAuthority ag_solanago.PublicKey, - withdrawAuthority ag_solanago.PublicKey, - vault ag_solanago.PublicKey) *Initialize { + pool ag_solanago.PublicKey) *Initialize { return NewInitializeInstructionBuilder(). SetAmpFactor(amp_factor). SetSwapFee(swap_fee). SetMaxCaps(max_caps). - SetOwnerAccount(owner). - SetMintAccount(mint). - SetPoolAccount(pool). - SetPoolAuthorityAccount(poolAuthority). - SetWithdrawAuthorityAccount(withdrawAuthority). - SetVaultAccount(vault) + SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/initialize_test.go b/programs/stable_swap/Initialize_test.go similarity index 100% rename from programs/stabblestableswap/initialize_test.go rename to programs/stable_swap/Initialize_test.go diff --git a/programs/stabblestableswap/pause.go b/programs/stable_swap/Pause.go similarity index 73% rename from programs/stabblestableswap/pause.go rename to programs/stable_swap/Pause.go index 678416b15..8cc244285 100644 --- a/programs/stabblestableswap/pause.go +++ b/programs/stable_swap/Pause.go @@ -13,40 +13,27 @@ import ( // Pause is the `pause` instruction. type Pause struct { - // [0] = [SIGNER] owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewPauseInstructionBuilder creates a new `Pause` instruction builder. func NewPauseInstructionBuilder() *Pause { nd := &Pause{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } -// SetOwnerAccount sets the "owner" account. -func (inst *Pause) SetOwnerAccount(owner ag_solanago.PublicKey) *Pause { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *Pause) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *Pause) SetPoolAccount(pool ag_solanago.PublicKey) *Pause { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *Pause) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst Pause) Build() *Instruction { @@ -70,9 +57,6 @@ func (inst *Pause) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Owner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -91,9 +75,8 @@ func (inst *Pause) EncodeToTree(parent ag_treeout.Branches) { instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -109,9 +92,7 @@ func (obj *Pause) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { // NewPauseInstruction declares a new Pause instruction with the provided parameters and accounts. func NewPauseInstruction( // Accounts: - owner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *Pause { return NewPauseInstructionBuilder(). - SetOwnerAccount(owner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/pause_test.go b/programs/stable_swap/Pause_test.go similarity index 100% rename from programs/stabblestableswap/pause_test.go rename to programs/stable_swap/Pause_test.go diff --git a/programs/stabblestableswap/rejectowner.go b/programs/stable_swap/RejectOwner.go similarity index 72% rename from programs/stabblestableswap/rejectowner.go rename to programs/stable_swap/RejectOwner.go index 72a7aeee9..447da1486 100644 --- a/programs/stabblestableswap/rejectowner.go +++ b/programs/stable_swap/RejectOwner.go @@ -13,40 +13,27 @@ import ( // RejectOwner is the `reject_owner` instruction. type RejectOwner struct { - // [0] = [SIGNER] pending_owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewRejectOwnerInstructionBuilder creates a new `RejectOwner` instruction builder. func NewRejectOwnerInstructionBuilder() *RejectOwner { nd := &RejectOwner{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } -// SetPendingOwnerAccount sets the "pending_owner" account. -func (inst *RejectOwner) SetPendingOwnerAccount(pendingOwner ag_solanago.PublicKey) *RejectOwner { - inst.AccountMetaSlice[0] = ag_solanago.Meta(pendingOwner).SIGNER() - return inst -} - -// GetPendingOwnerAccount gets the "pending_owner" account. -func (inst *RejectOwner) GetPendingOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *RejectOwner) SetPoolAccount(pool ag_solanago.PublicKey) *RejectOwner { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *RejectOwner) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst RejectOwner) Build() *Instruction { @@ -70,9 +57,6 @@ func (inst *RejectOwner) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.PendingOwner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -91,9 +75,8 @@ func (inst *RejectOwner) EncodeToTree(parent ag_treeout.Branches) { instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("pending_owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -109,9 +92,7 @@ func (obj *RejectOwner) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err er // NewRejectOwnerInstruction declares a new RejectOwner instruction with the provided parameters and accounts. func NewRejectOwnerInstruction( // Accounts: - pendingOwner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *RejectOwner { return NewRejectOwnerInstructionBuilder(). - SetPendingOwnerAccount(pendingOwner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/rejectowner_test.go b/programs/stable_swap/RejectOwner_test.go similarity index 100% rename from programs/stabblestableswap/rejectowner_test.go rename to programs/stable_swap/RejectOwner_test.go diff --git a/programs/stabblestableswap/shutdown.go b/programs/stable_swap/Shutdown.go similarity index 98% rename from programs/stabblestableswap/shutdown.go rename to programs/stable_swap/Shutdown.go index f8238dd69..e726c8bc7 100644 --- a/programs/stabblestableswap/shutdown.go +++ b/programs/stable_swap/Shutdown.go @@ -10,7 +10,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -// shutdown the zero-liquidity pool +// shutdownthezero-liquiditypool type Shutdown struct { // [0] = [WRITE] owner diff --git a/programs/stabblestableswap/shutdown_test.go b/programs/stable_swap/Shutdown_test.go similarity index 100% rename from programs/stabblestableswap/shutdown_test.go rename to programs/stable_swap/Shutdown_test.go diff --git a/programs/stabblestableswap/swap.go b/programs/stable_swap/Swap.go similarity index 59% rename from programs/stabblestableswap/swap.go rename to programs/stable_swap/Swap.go index 99b24c1cd..cc9e49ab8 100644 --- a/programs/stabblestableswap/swap.go +++ b/programs/stable_swap/Swap.go @@ -15,36 +15,24 @@ type Swap struct { AmountIn *uint64 `bin:"optional"` MinimumAmountOut *uint64 - // [0] = [SIGNER] user + // [0] = [WRITE] user_token_in // - // [1] = [WRITE] user_token_in + // [1] = [WRITE] user_token_out // - // [2] = [WRITE] user_token_out + // [2] = [WRITE] vault_token_in // - // [3] = [WRITE] vault_token_in + // [3] = [WRITE] vault_token_out // - // [4] = [WRITE] vault_token_out + // [4] = [WRITE] beneficiary_token_out // - // [5] = [WRITE] beneficiary_token_out - // - // [6] = [WRITE] pool - // - // [7] = [] withdraw_authority - // - // [8] = [] vault - // - // [9] = [] vault_authority - // - // [10] = [] vault_program - // - // [11] = [] token_program + // [5] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewSwapInstructionBuilder creates a new `Swap` instruction builder. func NewSwapInstructionBuilder() *Swap { nd := &Swap{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), } return nd } @@ -61,136 +49,70 @@ func (inst *Swap) SetMinimumAmountOut(minimum_amount_out uint64) *Swap { return inst } -// SetUserAccount sets the "user" account. -func (inst *Swap) SetUserAccount(user ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[0] = ag_solanago.Meta(user).SIGNER() - return inst -} - -// GetUserAccount gets the "user" account. -func (inst *Swap) GetUserAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetUserTokenInAccount sets the "user_token_in" account. func (inst *Swap) SetUserTokenInAccount(userTokenIn ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[1] = ag_solanago.Meta(userTokenIn).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(userTokenIn).WRITE() return inst } // GetUserTokenInAccount gets the "user_token_in" account. func (inst *Swap) GetUserTokenInAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } // SetUserTokenOutAccount sets the "user_token_out" account. func (inst *Swap) SetUserTokenOutAccount(userTokenOut ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[2] = ag_solanago.Meta(userTokenOut).WRITE() + inst.AccountMetaSlice[1] = ag_solanago.Meta(userTokenOut).WRITE() return inst } // GetUserTokenOutAccount gets the "user_token_out" account. func (inst *Swap) GetUserTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) + return inst.AccountMetaSlice.Get(1) } // SetVaultTokenInAccount sets the "vault_token_in" account. func (inst *Swap) SetVaultTokenInAccount(vaultTokenIn ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[3] = ag_solanago.Meta(vaultTokenIn).WRITE() + inst.AccountMetaSlice[2] = ag_solanago.Meta(vaultTokenIn).WRITE() return inst } // GetVaultTokenInAccount gets the "vault_token_in" account. func (inst *Swap) GetVaultTokenInAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) + return inst.AccountMetaSlice.Get(2) } // SetVaultTokenOutAccount sets the "vault_token_out" account. func (inst *Swap) SetVaultTokenOutAccount(vaultTokenOut ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[4] = ag_solanago.Meta(vaultTokenOut).WRITE() + inst.AccountMetaSlice[3] = ag_solanago.Meta(vaultTokenOut).WRITE() return inst } // GetVaultTokenOutAccount gets the "vault_token_out" account. func (inst *Swap) GetVaultTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) + return inst.AccountMetaSlice.Get(3) } // SetBeneficiaryTokenOutAccount sets the "beneficiary_token_out" account. func (inst *Swap) SetBeneficiaryTokenOutAccount(beneficiaryTokenOut ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[5] = ag_solanago.Meta(beneficiaryTokenOut).WRITE() + inst.AccountMetaSlice[4] = ag_solanago.Meta(beneficiaryTokenOut).WRITE() return inst } // GetBeneficiaryTokenOutAccount gets the "beneficiary_token_out" account. func (inst *Swap) GetBeneficiaryTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(5) + return inst.AccountMetaSlice.Get(4) } // SetPoolAccount sets the "pool" account. func (inst *Swap) SetPoolAccount(pool ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[6] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[5] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *Swap) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(6) -} - -// SetWithdrawAuthorityAccount sets the "withdraw_authority" account. -func (inst *Swap) SetWithdrawAuthorityAccount(withdrawAuthority ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[7] = ag_solanago.Meta(withdrawAuthority) - return inst -} - -// GetWithdrawAuthorityAccount gets the "withdraw_authority" account. -func (inst *Swap) GetWithdrawAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(7) -} - -// SetVaultAccount sets the "vault" account. -func (inst *Swap) SetVaultAccount(vault ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[8] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *Swap) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(8) -} - -// SetVaultAuthorityAccount sets the "vault_authority" account. -func (inst *Swap) SetVaultAuthorityAccount(vaultAuthority ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[9] = ag_solanago.Meta(vaultAuthority) - return inst -} - -// GetVaultAuthorityAccount gets the "vault_authority" account. -func (inst *Swap) GetVaultAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(9) -} - -// SetVaultProgramAccount sets the "vault_program" account. -func (inst *Swap) SetVaultProgramAccount(vaultProgram ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[10] = ag_solanago.Meta(vaultProgram) - return inst -} - -// GetVaultProgramAccount gets the "vault_program" account. -func (inst *Swap) GetVaultProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(10) -} - -// SetTokenProgramAccount sets the "token_program" account. -func (inst *Swap) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Swap { - inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram) - return inst -} - -// GetTokenProgramAccount gets the "token_program" account. -func (inst *Swap) GetTokenProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(11) + return inst.AccountMetaSlice.Get(5) } func (inst Swap) Build() *Instruction { @@ -221,41 +143,23 @@ func (inst *Swap) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.User is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.UserTokenIn is not set") } - if inst.AccountMetaSlice[2] == nil { + if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.UserTokenOut is not set") } - if inst.AccountMetaSlice[3] == nil { + if inst.AccountMetaSlice[2] == nil { return errors.New("accounts.VaultTokenIn is not set") } - if inst.AccountMetaSlice[4] == nil { + if inst.AccountMetaSlice[3] == nil { return errors.New("accounts.VaultTokenOut is not set") } - if inst.AccountMetaSlice[5] == nil { + if inst.AccountMetaSlice[4] == nil { return errors.New("accounts.BeneficiaryTokenOut is not set") } - if inst.AccountMetaSlice[6] == nil { + if inst.AccountMetaSlice[5] == nil { return errors.New("accounts.Pool is not set") } - if inst.AccountMetaSlice[7] == nil { - return errors.New("accounts.WithdrawAuthority is not set") - } - if inst.AccountMetaSlice[8] == nil { - return errors.New("accounts.Vault is not set") - } - if inst.AccountMetaSlice[9] == nil { - return errors.New("accounts.VaultAuthority is not set") - } - if inst.AccountMetaSlice[10] == nil { - return errors.New("accounts.VaultProgram is not set") - } - if inst.AccountMetaSlice[11] == nil { - return errors.New("accounts.TokenProgram is not set") - } } return nil } @@ -275,19 +179,13 @@ func (inst *Swap) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" user_token_in", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" user_token_out", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" vault_token_in", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" vault_token_out", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta("beneficiary_token_out", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta(" withdraw_authority", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(8))) - accountsBranch.Child(ag_format.Meta(" vault_authority", inst.AccountMetaSlice.Get(9))) - accountsBranch.Child(ag_format.Meta(" vault_program", inst.AccountMetaSlice.Get(10))) - accountsBranch.Child(ag_format.Meta(" token_program", inst.AccountMetaSlice.Get(11))) + instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" user_token_in", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" user_token_out", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" vault_token_in", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" vault_token_out", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("beneficiary_token_out", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(5))) }) }) }) @@ -347,31 +245,19 @@ func NewSwapInstruction( amount_in uint64, minimum_amount_out uint64, // Accounts: - user ag_solanago.PublicKey, userTokenIn ag_solanago.PublicKey, userTokenOut ag_solanago.PublicKey, vaultTokenIn ag_solanago.PublicKey, vaultTokenOut ag_solanago.PublicKey, beneficiaryTokenOut ag_solanago.PublicKey, - pool ag_solanago.PublicKey, - withdrawAuthority ag_solanago.PublicKey, - vault ag_solanago.PublicKey, - vaultAuthority ag_solanago.PublicKey, - vaultProgram ag_solanago.PublicKey, - tokenProgram ag_solanago.PublicKey) *Swap { + pool ag_solanago.PublicKey) *Swap { return NewSwapInstructionBuilder(). SetAmountIn(amount_in). SetMinimumAmountOut(minimum_amount_out). - SetUserAccount(user). SetUserTokenInAccount(userTokenIn). SetUserTokenOutAccount(userTokenOut). SetVaultTokenInAccount(vaultTokenIn). SetVaultTokenOutAccount(vaultTokenOut). SetBeneficiaryTokenOutAccount(beneficiaryTokenOut). - SetPoolAccount(pool). - SetWithdrawAuthorityAccount(withdrawAuthority). - SetVaultAccount(vault). - SetVaultAuthorityAccount(vaultAuthority). - SetVaultProgramAccount(vaultProgram). - SetTokenProgramAccount(tokenProgram) + SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/swapv2.go b/programs/stable_swap/SwapV2.go similarity index 51% rename from programs/stabblestableswap/swapv2.go rename to programs/stable_swap/SwapV2.go index 7d1d8bc6c..3f24a7881 100644 --- a/programs/stabblestableswap/swapv2.go +++ b/programs/stable_swap/SwapV2.go @@ -15,42 +15,24 @@ type SwapV2 struct { AmountIn *uint64 `bin:"optional"` MinimumAmountOut *uint64 - // [0] = [SIGNER] user + // [0] = [WRITE] user_token_in // - // [1] = [] mint_in + // [1] = [WRITE] user_token_out // - // [2] = [] mint_out + // [2] = [WRITE] vault_token_in // - // [3] = [WRITE] user_token_in + // [3] = [WRITE] vault_token_out // - // [4] = [WRITE] user_token_out + // [4] = [WRITE] beneficiary_token_out // - // [5] = [WRITE] vault_token_in - // - // [6] = [WRITE] vault_token_out - // - // [7] = [WRITE] beneficiary_token_out - // - // [8] = [WRITE] pool - // - // [9] = [] withdraw_authority - // - // [10] = [] vault - // - // [11] = [] vault_authority - // - // [12] = [] vault_program - // - // [13] = [] token_program - // - // [14] = [] token_2022_program + // [5] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewSwapV2InstructionBuilder creates a new `SwapV2` instruction builder. func NewSwapV2InstructionBuilder() *SwapV2 { nd := &SwapV2{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 15), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), } return nd } @@ -67,169 +49,70 @@ func (inst *SwapV2) SetMinimumAmountOut(minimum_amount_out uint64) *SwapV2 { return inst } -// SetUserAccount sets the "user" account. -func (inst *SwapV2) SetUserAccount(user ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[0] = ag_solanago.Meta(user).SIGNER() - return inst -} - -// GetUserAccount gets the "user" account. -func (inst *SwapV2) GetUserAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - -// SetMintInAccount sets the "mint_in" account. -func (inst *SwapV2) SetMintInAccount(mintIn ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[1] = ag_solanago.Meta(mintIn) - return inst -} - -// GetMintInAccount gets the "mint_in" account. -func (inst *SwapV2) GetMintInAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) -} - -// SetMintOutAccount sets the "mint_out" account. -func (inst *SwapV2) SetMintOutAccount(mintOut ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[2] = ag_solanago.Meta(mintOut) - return inst -} - -// GetMintOutAccount gets the "mint_out" account. -func (inst *SwapV2) GetMintOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(2) -} - // SetUserTokenInAccount sets the "user_token_in" account. func (inst *SwapV2) SetUserTokenInAccount(userTokenIn ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[3] = ag_solanago.Meta(userTokenIn).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(userTokenIn).WRITE() return inst } // GetUserTokenInAccount gets the "user_token_in" account. func (inst *SwapV2) GetUserTokenInAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(3) + return inst.AccountMetaSlice.Get(0) } // SetUserTokenOutAccount sets the "user_token_out" account. func (inst *SwapV2) SetUserTokenOutAccount(userTokenOut ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[4] = ag_solanago.Meta(userTokenOut).WRITE() + inst.AccountMetaSlice[1] = ag_solanago.Meta(userTokenOut).WRITE() return inst } // GetUserTokenOutAccount gets the "user_token_out" account. func (inst *SwapV2) GetUserTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(4) + return inst.AccountMetaSlice.Get(1) } // SetVaultTokenInAccount sets the "vault_token_in" account. func (inst *SwapV2) SetVaultTokenInAccount(vaultTokenIn ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[5] = ag_solanago.Meta(vaultTokenIn).WRITE() + inst.AccountMetaSlice[2] = ag_solanago.Meta(vaultTokenIn).WRITE() return inst } // GetVaultTokenInAccount gets the "vault_token_in" account. func (inst *SwapV2) GetVaultTokenInAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(5) + return inst.AccountMetaSlice.Get(2) } // SetVaultTokenOutAccount sets the "vault_token_out" account. func (inst *SwapV2) SetVaultTokenOutAccount(vaultTokenOut ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[6] = ag_solanago.Meta(vaultTokenOut).WRITE() + inst.AccountMetaSlice[3] = ag_solanago.Meta(vaultTokenOut).WRITE() return inst } // GetVaultTokenOutAccount gets the "vault_token_out" account. func (inst *SwapV2) GetVaultTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(6) + return inst.AccountMetaSlice.Get(3) } // SetBeneficiaryTokenOutAccount sets the "beneficiary_token_out" account. func (inst *SwapV2) SetBeneficiaryTokenOutAccount(beneficiaryTokenOut ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[7] = ag_solanago.Meta(beneficiaryTokenOut).WRITE() + inst.AccountMetaSlice[4] = ag_solanago.Meta(beneficiaryTokenOut).WRITE() return inst } // GetBeneficiaryTokenOutAccount gets the "beneficiary_token_out" account. func (inst *SwapV2) GetBeneficiaryTokenOutAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(7) + return inst.AccountMetaSlice.Get(4) } // SetPoolAccount sets the "pool" account. func (inst *SwapV2) SetPoolAccount(pool ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[8] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[5] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *SwapV2) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(8) -} - -// SetWithdrawAuthorityAccount sets the "withdraw_authority" account. -func (inst *SwapV2) SetWithdrawAuthorityAccount(withdrawAuthority ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[9] = ag_solanago.Meta(withdrawAuthority) - return inst -} - -// GetWithdrawAuthorityAccount gets the "withdraw_authority" account. -func (inst *SwapV2) GetWithdrawAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(9) -} - -// SetVaultAccount sets the "vault" account. -func (inst *SwapV2) SetVaultAccount(vault ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[10] = ag_solanago.Meta(vault) - return inst -} - -// GetVaultAccount gets the "vault" account. -func (inst *SwapV2) GetVaultAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(10) -} - -// SetVaultAuthorityAccount sets the "vault_authority" account. -func (inst *SwapV2) SetVaultAuthorityAccount(vaultAuthority ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[11] = ag_solanago.Meta(vaultAuthority) - return inst -} - -// GetVaultAuthorityAccount gets the "vault_authority" account. -func (inst *SwapV2) GetVaultAuthorityAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(11) -} - -// SetVaultProgramAccount sets the "vault_program" account. -func (inst *SwapV2) SetVaultProgramAccount(vaultProgram ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[12] = ag_solanago.Meta(vaultProgram) - return inst -} - -// GetVaultProgramAccount gets the "vault_program" account. -func (inst *SwapV2) GetVaultProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(12) -} - -// SetTokenProgramAccount sets the "token_program" account. -func (inst *SwapV2) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[13] = ag_solanago.Meta(tokenProgram) - return inst -} - -// GetTokenProgramAccount gets the "token_program" account. -func (inst *SwapV2) GetTokenProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(13) -} - -// SetToken2022ProgramAccount sets the "token_2022_program" account. -func (inst *SwapV2) SetToken2022ProgramAccount(token2022Program ag_solanago.PublicKey) *SwapV2 { - inst.AccountMetaSlice[14] = ag_solanago.Meta(token2022Program) - return inst -} - -// GetToken2022ProgramAccount gets the "token_2022_program" account. -func (inst *SwapV2) GetToken2022ProgramAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(14) + return inst.AccountMetaSlice.Get(5) } func (inst SwapV2) Build() *Instruction { @@ -260,50 +143,23 @@ func (inst *SwapV2) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.User is not set") - } - if inst.AccountMetaSlice[1] == nil { - return errors.New("accounts.MintIn is not set") - } - if inst.AccountMetaSlice[2] == nil { - return errors.New("accounts.MintOut is not set") - } - if inst.AccountMetaSlice[3] == nil { return errors.New("accounts.UserTokenIn is not set") } - if inst.AccountMetaSlice[4] == nil { + if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.UserTokenOut is not set") } - if inst.AccountMetaSlice[5] == nil { + if inst.AccountMetaSlice[2] == nil { return errors.New("accounts.VaultTokenIn is not set") } - if inst.AccountMetaSlice[6] == nil { + if inst.AccountMetaSlice[3] == nil { return errors.New("accounts.VaultTokenOut is not set") } - if inst.AccountMetaSlice[7] == nil { + if inst.AccountMetaSlice[4] == nil { return errors.New("accounts.BeneficiaryTokenOut is not set") } - if inst.AccountMetaSlice[8] == nil { + if inst.AccountMetaSlice[5] == nil { return errors.New("accounts.Pool is not set") } - if inst.AccountMetaSlice[9] == nil { - return errors.New("accounts.WithdrawAuthority is not set") - } - if inst.AccountMetaSlice[10] == nil { - return errors.New("accounts.Vault is not set") - } - if inst.AccountMetaSlice[11] == nil { - return errors.New("accounts.VaultAuthority is not set") - } - if inst.AccountMetaSlice[12] == nil { - return errors.New("accounts.VaultProgram is not set") - } - if inst.AccountMetaSlice[13] == nil { - return errors.New("accounts.TokenProgram is not set") - } - if inst.AccountMetaSlice[14] == nil { - return errors.New("accounts.Token2022Program is not set") - } } return nil } @@ -323,22 +179,13 @@ func (inst *SwapV2) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=15]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta(" user", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" mint_in", inst.AccountMetaSlice.Get(1))) - accountsBranch.Child(ag_format.Meta(" mint_out", inst.AccountMetaSlice.Get(2))) - accountsBranch.Child(ag_format.Meta(" user_token_in", inst.AccountMetaSlice.Get(3))) - accountsBranch.Child(ag_format.Meta(" user_token_out", inst.AccountMetaSlice.Get(4))) - accountsBranch.Child(ag_format.Meta(" vault_token_in", inst.AccountMetaSlice.Get(5))) - accountsBranch.Child(ag_format.Meta(" vault_token_out", inst.AccountMetaSlice.Get(6))) - accountsBranch.Child(ag_format.Meta("beneficiary_token_out", inst.AccountMetaSlice.Get(7))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(8))) - accountsBranch.Child(ag_format.Meta(" withdraw_authority", inst.AccountMetaSlice.Get(9))) - accountsBranch.Child(ag_format.Meta(" vault", inst.AccountMetaSlice.Get(10))) - accountsBranch.Child(ag_format.Meta(" vault_authority", inst.AccountMetaSlice.Get(11))) - accountsBranch.Child(ag_format.Meta(" vault_program", inst.AccountMetaSlice.Get(12))) - accountsBranch.Child(ag_format.Meta(" token_program", inst.AccountMetaSlice.Get(13))) - accountsBranch.Child(ag_format.Meta(" token_2022_program", inst.AccountMetaSlice.Get(14))) + instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" user_token_in", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" user_token_out", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" vault_token_in", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta(" vault_token_out", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("beneficiary_token_out", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(5))) }) }) }) @@ -398,37 +245,19 @@ func NewSwapV2Instruction( amount_in uint64, minimum_amount_out uint64, // Accounts: - user ag_solanago.PublicKey, - mintIn ag_solanago.PublicKey, - mintOut ag_solanago.PublicKey, userTokenIn ag_solanago.PublicKey, userTokenOut ag_solanago.PublicKey, vaultTokenIn ag_solanago.PublicKey, vaultTokenOut ag_solanago.PublicKey, beneficiaryTokenOut ag_solanago.PublicKey, - pool ag_solanago.PublicKey, - withdrawAuthority ag_solanago.PublicKey, - vault ag_solanago.PublicKey, - vaultAuthority ag_solanago.PublicKey, - vaultProgram ag_solanago.PublicKey, - tokenProgram ag_solanago.PublicKey, - token2022Program ag_solanago.PublicKey) *SwapV2 { + pool ag_solanago.PublicKey) *SwapV2 { return NewSwapV2InstructionBuilder(). SetAmountIn(amount_in). SetMinimumAmountOut(minimum_amount_out). - SetUserAccount(user). - SetMintInAccount(mintIn). - SetMintOutAccount(mintOut). SetUserTokenInAccount(userTokenIn). SetUserTokenOutAccount(userTokenOut). SetVaultTokenInAccount(vaultTokenIn). SetVaultTokenOutAccount(vaultTokenOut). SetBeneficiaryTokenOutAccount(beneficiaryTokenOut). - SetPoolAccount(pool). - SetWithdrawAuthorityAccount(withdrawAuthority). - SetVaultAccount(vault). - SetVaultAuthorityAccount(vaultAuthority). - SetVaultProgramAccount(vaultProgram). - SetTokenProgramAccount(tokenProgram). - SetToken2022ProgramAccount(token2022Program) + SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/swapv2_test.go b/programs/stable_swap/SwapV2_test.go similarity index 100% rename from programs/stabblestableswap/swapv2_test.go rename to programs/stable_swap/SwapV2_test.go diff --git a/programs/stabblestableswap/swap_test.go b/programs/stable_swap/Swap_test.go similarity index 100% rename from programs/stabblestableswap/swap_test.go rename to programs/stable_swap/Swap_test.go diff --git a/programs/stabblestableswap/transferowner.go b/programs/stable_swap/TransferOwner.go similarity index 78% rename from programs/stabblestableswap/transferowner.go rename to programs/stable_swap/TransferOwner.go index 432617abb..6d538d7d0 100644 --- a/programs/stabblestableswap/transferowner.go +++ b/programs/stable_swap/TransferOwner.go @@ -14,16 +14,14 @@ import ( type TransferOwner struct { NewOwner *ag_solanago.PublicKey - // [0] = [SIGNER] owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewTransferOwnerInstructionBuilder creates a new `TransferOwner` instruction builder. func NewTransferOwnerInstructionBuilder() *TransferOwner { nd := &TransferOwner{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } @@ -34,26 +32,15 @@ func (inst *TransferOwner) SetNewOwner(new_owner ag_solanago.PublicKey) *Transfe return inst } -// SetOwnerAccount sets the "owner" account. -func (inst *TransferOwner) SetOwnerAccount(owner ag_solanago.PublicKey) *TransferOwner { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *TransferOwner) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *TransferOwner) SetPoolAccount(pool ag_solanago.PublicKey) *TransferOwner { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *TransferOwner) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst TransferOwner) Build() *Instruction { @@ -84,9 +71,6 @@ func (inst *TransferOwner) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Owner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -107,9 +91,8 @@ func (inst *TransferOwner) EncodeToTree(parent ag_treeout.Branches) { }) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -137,10 +120,8 @@ func NewTransferOwnerInstruction( // Parameters: new_owner ag_solanago.PublicKey, // Accounts: - owner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *TransferOwner { return NewTransferOwnerInstructionBuilder(). SetNewOwner(new_owner). - SetOwnerAccount(owner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/transferowner_test.go b/programs/stable_swap/TransferOwner_test.go similarity index 100% rename from programs/stabblestableswap/transferowner_test.go rename to programs/stable_swap/TransferOwner_test.go diff --git a/programs/stabblestableswap/unpause.go b/programs/stable_swap/Unpause.go similarity index 73% rename from programs/stabblestableswap/unpause.go rename to programs/stable_swap/Unpause.go index 3b32da52e..6c596f3db 100644 --- a/programs/stabblestableswap/unpause.go +++ b/programs/stable_swap/Unpause.go @@ -13,40 +13,27 @@ import ( // Unpause is the `unpause` instruction. type Unpause struct { - // [0] = [SIGNER] owner - // - // [1] = [WRITE] pool + // [0] = [WRITE] pool ag_solanago.AccountMetaSlice `bin:"-"` } // NewUnpauseInstructionBuilder creates a new `Unpause` instruction builder. func NewUnpauseInstructionBuilder() *Unpause { nd := &Unpause{ - AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 1), } return nd } -// SetOwnerAccount sets the "owner" account. -func (inst *Unpause) SetOwnerAccount(owner ag_solanago.PublicKey) *Unpause { - inst.AccountMetaSlice[0] = ag_solanago.Meta(owner).SIGNER() - return inst -} - -// GetOwnerAccount gets the "owner" account. -func (inst *Unpause) GetOwnerAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(0) -} - // SetPoolAccount sets the "pool" account. func (inst *Unpause) SetPoolAccount(pool ag_solanago.PublicKey) *Unpause { - inst.AccountMetaSlice[1] = ag_solanago.Meta(pool).WRITE() + inst.AccountMetaSlice[0] = ag_solanago.Meta(pool).WRITE() return inst } // GetPoolAccount gets the "pool" account. func (inst *Unpause) GetPoolAccount() *ag_solanago.AccountMeta { - return inst.AccountMetaSlice.Get(1) + return inst.AccountMetaSlice.Get(0) } func (inst Unpause) Build() *Instruction { @@ -70,9 +57,6 @@ func (inst *Unpause) Validate() error { // Check whether all (required) accounts are set: { if inst.AccountMetaSlice[0] == nil { - return errors.New("accounts.Owner is not set") - } - if inst.AccountMetaSlice[1] == nil { return errors.New("accounts.Pool is not set") } } @@ -91,9 +75,8 @@ func (inst *Unpause) EncodeToTree(parent ag_treeout.Branches) { instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) // Accounts of the instruction: - instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { - accountsBranch.Child(ag_format.Meta("owner", inst.AccountMetaSlice.Get(0))) - accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(1))) + instructionBranch.Child("Accounts[len=1]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("pool", inst.AccountMetaSlice.Get(0))) }) }) }) @@ -109,9 +92,7 @@ func (obj *Unpause) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) // NewUnpauseInstruction declares a new Unpause instruction with the provided parameters and accounts. func NewUnpauseInstruction( // Accounts: - owner ag_solanago.PublicKey, pool ag_solanago.PublicKey) *Unpause { return NewUnpauseInstructionBuilder(). - SetOwnerAccount(owner). SetPoolAccount(pool) } diff --git a/programs/stabblestableswap/unpause_test.go b/programs/stable_swap/Unpause_test.go similarity index 100% rename from programs/stabblestableswap/unpause_test.go rename to programs/stable_swap/Unpause_test.go diff --git a/programs/stable_swap/Withdraw.go b/programs/stable_swap/Withdraw.go new file mode 100644 index 000000000..a2add9c64 --- /dev/null +++ b/programs/stable_swap/Withdraw.go @@ -0,0 +1,188 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_swap + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// removeliquidity +type Withdraw struct { + Amount *uint64 + MinimumAmountsOut *[]uint64 + + // [0] = [WRITE] user_pool_token + // + // [1] = [WRITE] mint + // + // [2] = [WRITE] pool + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. +func NewWithdrawInstructionBuilder() *Withdraw { + nd := &Withdraw{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *Withdraw) SetAmount(amount uint64) *Withdraw { + inst.Amount = &amount + return inst +} + +// SetMinimumAmountsOut sets the "minimum_amounts_out" parameter. +func (inst *Withdraw) SetMinimumAmountsOut(minimum_amounts_out []uint64) *Withdraw { + inst.MinimumAmountsOut = &minimum_amounts_out + return inst +} + +// SetUserPoolTokenAccount sets the "user_pool_token" account. +func (inst *Withdraw) SetUserPoolTokenAccount(userPoolToken ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[0] = ag_solanago.Meta(userPoolToken).WRITE() + return inst +} + +// GetUserPoolTokenAccount gets the "user_pool_token" account. +func (inst *Withdraw) GetUserPoolTokenAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetMintAccount sets the "mint" account. +func (inst *Withdraw) SetMintAccount(mint ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[1] = ag_solanago.Meta(mint).WRITE() + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *Withdraw) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetPoolAccount sets the "pool" account. +func (inst *Withdraw) SetPoolAccount(pool ag_solanago.PublicKey) *Withdraw { + inst.AccountMetaSlice[2] = ag_solanago.Meta(pool).WRITE() + return inst +} + +// GetPoolAccount gets the "pool" account. +func (inst *Withdraw) GetPoolAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +func (inst Withdraw) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + if inst.MinimumAmountsOut == nil { + return errors.New("MinimumAmountsOut parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.UserPoolToken is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Pool is not set") + } + } + return nil +} + +func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) + paramsBranch.Child(ag_format.Param(" MinimumAmountsOut", *inst.MinimumAmountsOut)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("user_pool_token", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" pool", inst.AccountMetaSlice.Get(2))) + }) + }) + }) +} + +func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `MinimumAmountsOut` param: + err = encoder.Encode(obj.MinimumAmountsOut) + if err != nil { + return err + } + return nil +} +func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `MinimumAmountsOut`: + err = decoder.Decode(&obj.MinimumAmountsOut) + if err != nil { + return err + } + return nil +} + +// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. +func NewWithdrawInstruction( + // Parameters: + amount uint64, + minimum_amounts_out []uint64, + // Accounts: + userPoolToken ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + pool ag_solanago.PublicKey) *Withdraw { + return NewWithdrawInstructionBuilder(). + SetAmount(amount). + SetMinimumAmountsOut(minimum_amounts_out). + SetUserPoolTokenAccount(userPoolToken). + SetMintAccount(mint). + SetPoolAccount(pool) +} diff --git a/programs/stabblestableswap/withdraw_test.go b/programs/stable_swap/Withdraw_test.go similarity index 100% rename from programs/stabblestableswap/withdraw_test.go rename to programs/stable_swap/Withdraw_test.go diff --git a/programs/stabblestableswap/accounts.go b/programs/stable_swap/accounts.go similarity index 95% rename from programs/stabblestableswap/accounts.go rename to programs/stable_swap/accounts.go index 0194db5a4..ad7440e87 100644 --- a/programs/stabblestableswap/accounts.go +++ b/programs/stable_swap/accounts.go @@ -23,7 +23,7 @@ type PoolAccount struct { PendingOwner *ag_solanago.PublicKey `bin:"optional"` } -var PoolAccountDiscriminator = [8]byte{241, 154, 109, 4, 17, 177, 109, 188} +var PoolAccountDiscriminator = [8]byte{116, 210, 187, 119, 196, 196, 52, 137} func (obj PoolAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { // Write account discriminator: @@ -117,7 +117,7 @@ func (obj *PoolAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err er if !discriminator.Equal(PoolAccountDiscriminator[:]) { return fmt.Errorf( "wrong discriminator: wanted %s, got %s", - "[241 154 109 4 17 177 109 188]", + "[116 210 187 119 196 196 52 137]", fmt.Sprint(discriminator[:])) } } @@ -203,7 +203,7 @@ type StrategyAccount struct { RampMaxDuration uint32 } -var StrategyAccountDiscriminator = [8]byte{174, 110, 39, 119, 82, 106, 169, 102} +var StrategyAccountDiscriminator = [8]byte{97, 218, 254, 239, 248, 146, 59, 42} func (obj StrategyAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { // Write account discriminator: @@ -264,7 +264,7 @@ func (obj *StrategyAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (er if !discriminator.Equal(StrategyAccountDiscriminator[:]) { return fmt.Errorf( "wrong discriminator: wanted %s, got %s", - "[174 110 39 119 82 106 169 102]", + "[97 218 254 239 248 146 59 42]", fmt.Sprint(discriminator[:])) } } @@ -314,13 +314,13 @@ func (obj *StrategyAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (er type VaultAccount struct { Admin ag_solanago.PublicKey - // PDA of pool programs seeded by vault address + // PDAofpoolprogramsseededbyvaultaddress WithdrawAuthority ag_solanago.PublicKey - // bump seed of withdraw_authority PDA + // bumpseedofwithdraw_authorityPDA WithdrawAuthorityBump uint8 - // bump seed of vault_authority PDA + // bumpseedofvault_authorityPDA AuthorityBump uint8 IsActive bool Beneficiary ag_solanago.PublicKey @@ -328,7 +328,7 @@ type VaultAccount struct { PendingAdmin *ag_solanago.PublicKey `bin:"optional"` } -var VaultAccountDiscriminator = [8]byte{211, 8, 232, 43, 2, 152, 117, 119} +var VaultAccountDiscriminator = [8]byte{230, 251, 241, 83, 139, 202, 93, 28} func (obj VaultAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { // Write account discriminator: @@ -402,7 +402,7 @@ func (obj *VaultAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err e if !discriminator.Equal(VaultAccountDiscriminator[:]) { return fmt.Errorf( "wrong discriminator: wanted %s, got %s", - "[211 8 232 43 2 152 117 119]", + "[230 251 241 83 139 202 93 28]", fmt.Sprint(discriminator[:])) } } diff --git a/programs/stabblestableswap/instructions.go b/programs/stable_swap/instructions.go similarity index 74% rename from programs/stabblestableswap/instructions.go rename to programs/stable_swap/instructions.go index 439ec9ca4..f55efdd7c 100644 --- a/programs/stabblestableswap/instructions.go +++ b/programs/stable_swap/instructions.go @@ -12,10 +12,10 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("swapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ") -func SetProgramID(PublicKey ag_solanago.PublicKey) { - ProgramID = PublicKey +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) } @@ -38,19 +38,19 @@ var ( Instruction_CreateStrategy = ag_binary.TypeID([8]byte{152, 160, 107, 148, 245, 190, 127, 224}) - // add liquidity + // addliquidity Instruction_Deposit = ag_binary.TypeID([8]byte{242, 35, 198, 137, 82, 225, 242, 182}) Instruction_ExecStrategy = ag_binary.TypeID([8]byte{249, 46, 55, 57, 31, 38, 61, 27}) - // initialize a pool + // initializeapool Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) Instruction_Pause = ag_binary.TypeID([8]byte{211, 22, 221, 251, 74, 121, 193, 47}) Instruction_RejectOwner = ag_binary.TypeID([8]byte{238, 206, 198, 215, 51, 178, 133, 228}) - // shutdown the zero-liquidity pool + // shutdownthezero-liquiditypool Instruction_Shutdown = ag_binary.TypeID([8]byte{146, 204, 241, 213, 86, 21, 253, 211}) // swap @@ -62,7 +62,7 @@ var ( Instruction_Unpause = ag_binary.TypeID([8]byte{169, 144, 4, 38, 10, 141, 188, 255}) - // remove liquidity + // removeliquidity Instruction_Withdraw = ag_binary.TypeID([8]byte{183, 18, 70, 156, 148, 109, 161, 34}) ) @@ -122,52 +122,52 @@ var InstructionImplDef = ag_binary.NewVariantDefinition( ag_binary.AnchorTypeIDEncoding, []ag_binary.VariantType{ { - Name: "accept_owner", Type: (*AcceptOwner)(nil), + "accept_owner", (*AcceptOwner)(nil), }, { - Name: "approve_strategy", Type: (*ApproveStrategy)(nil), + "approve_strategy", (*ApproveStrategy)(nil), }, { - Name: "change_amp_factor", Type: (*ChangeAmpFactor)(nil), + "change_amp_factor", (*ChangeAmpFactor)(nil), }, { - Name: "change_swap_fee", Type: (*ChangeSwapFee)(nil), + "change_swap_fee", (*ChangeSwapFee)(nil), }, { - Name: "create_strategy", Type: (*CreateStrategy)(nil), + "create_strategy", (*CreateStrategy)(nil), }, { - Name: "deposit", Type: (*Deposit)(nil), + "deposit", (*Deposit)(nil), }, { - Name: "exec_strategy", Type: (*ExecStrategy)(nil), + "exec_strategy", (*ExecStrategy)(nil), }, { - Name: "initialize", Type: (*Initialize)(nil), + "initialize", (*Initialize)(nil), }, { - Name: "pause", Type: (*Pause)(nil), + "pause", (*Pause)(nil), }, { - Name: "reject_owner", Type: (*RejectOwner)(nil), + "reject_owner", (*RejectOwner)(nil), }, { - Name: "shutdown", Type: (*Shutdown)(nil), + "shutdown", (*Shutdown)(nil), }, { - Name: "swap", Type: (*Swap)(nil), + "swap", (*Swap)(nil), }, { - Name: "swap_v2", Type: (*SwapV2)(nil), + "swap_v2", (*SwapV2)(nil), }, { - Name: "transfer_owner", Type: (*TransferOwner)(nil), + "transfer_owner", (*TransferOwner)(nil), }, { - Name: "unpause", Type: (*Unpause)(nil), + "unpause", (*Unpause)(nil), }, { - Name: "withdraw", Type: (*Withdraw)(nil), + "withdraw", (*Withdraw)(nil), }, }, ) @@ -205,14 +205,14 @@ func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { } func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { - inst, err := decodeInstruction(accounts, data) + inst, err := DecodeInstruction(accounts, data) if err != nil { return nil, err } return inst, nil } -func decodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { inst := new(Instruction) if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { return nil, fmt.Errorf("unable to decode instruction: %w", err) @@ -225,25 +225,3 @@ func decodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instr } return inst, nil } - -func DecodeInstructions(message *ag_solanago.Message) (instructions []*Instruction, err error) { - for _, ins := range message.Instructions { - var programID ag_solanago.PublicKey - if programID, err = message.Program(ins.ProgramIDIndex); err != nil { - return - } - if !programID.Equals(ProgramID) { - continue - } - var accounts []*ag_solanago.AccountMeta - if accounts, err = ins.ResolveInstructionAccounts(message); err != nil { - return - } - var insDecoded *Instruction - if insDecoded, err = decodeInstruction(accounts, ins.Data); err != nil { - return - } - instructions = append(instructions, insDecoded) - } - return -} diff --git a/programs/stabblestableswap/testing_utils.go b/programs/stable_swap/testing_utils.go similarity index 100% rename from programs/stabblestableswap/testing_utils.go rename to programs/stable_swap/testing_utils.go diff --git a/programs/stabblestableswap/types.go b/programs/stable_swap/types.go similarity index 96% rename from programs/stabblestableswap/types.go rename to programs/stable_swap/types.go index f4a366657..da4973a34 100644 --- a/programs/stabblestableswap/types.go +++ b/programs/stable_swap/types.go @@ -194,13 +194,13 @@ func (obj *PoolBalanceUpdatedData) UnmarshalWithDecoder(decoder *ag_binary.Decod } type PoolBalanceUpdatedEvent struct { - Pubkey ag_solanago.PublicKey - Data PoolBalanceUpdatedData + PublicKey ag_solanago.PublicKey + Data PoolBalanceUpdatedData } func (obj PoolBalanceUpdatedEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `Pubkey` param: - err = encoder.Encode(obj.Pubkey) + // Serialize `PublicKey` param: + err = encoder.Encode(obj.PublicKey) if err != nil { return err } @@ -213,8 +213,8 @@ func (obj PoolBalanceUpdatedEvent) MarshalWithEncoder(encoder *ag_binary.Encoder } func (obj *PoolBalanceUpdatedEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `Pubkey`: - err = decoder.Decode(&obj.Pubkey) + // Deserialize `PublicKey`: + err = decoder.Decode(&obj.PublicKey) if err != nil { return err } @@ -370,13 +370,13 @@ func (obj *PoolUpdatedData) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (er } type PoolUpdatedEvent struct { - Pubkey ag_solanago.PublicKey - Data PoolUpdatedData + PublicKey ag_solanago.PublicKey + Data PoolUpdatedData } func (obj PoolUpdatedEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `Pubkey` param: - err = encoder.Encode(obj.Pubkey) + // Serialize `PublicKey` param: + err = encoder.Encode(obj.PublicKey) if err != nil { return err } @@ -389,8 +389,8 @@ func (obj PoolUpdatedEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err } func (obj *PoolUpdatedEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `Pubkey`: - err = decoder.Decode(&obj.Pubkey) + // Deserialize `PublicKey`: + err = decoder.Decode(&obj.PublicKey) if err != nil { return err } @@ -504,13 +504,13 @@ func (obj *Strategy) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error type Vault struct { Admin ag_solanago.PublicKey - // PDA of pool programs seeded by vault address + // PDAofpoolprogramsseededbyvaultaddress WithdrawAuthority ag_solanago.PublicKey - // bump seed of withdraw_authority PDA + // bumpseedofwithdraw_authorityPDA WithdrawAuthorityBump uint8 - // bump seed of vault_authority PDA + // bumpseedofvault_authorityPDA AuthorityBump uint8 IsActive bool Beneficiary ag_solanago.PublicKey diff --git a/programs/stable_vault/AcceptAdmin.go b/programs/stable_vault/AcceptAdmin.go new file mode 100644 index 000000000..48a7b4dc0 --- /dev/null +++ b/programs/stable_vault/AcceptAdmin.go @@ -0,0 +1,76 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// AcceptAdmin is the `accept_admin` instruction. +type AcceptAdmin struct { + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewAcceptAdminInstructionBuilder creates a new `AcceptAdmin` instruction builder. +func NewAcceptAdminInstructionBuilder() *AcceptAdmin { + nd := &AcceptAdmin{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +func (inst AcceptAdmin) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_AcceptAdmin, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst AcceptAdmin) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *AcceptAdmin) Validate() error { + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *AcceptAdmin) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("AcceptAdmin")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj AcceptAdmin) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *AcceptAdmin) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewAcceptAdminInstruction declares a new AcceptAdmin instruction with the provided parameters and accounts. +func NewAcceptAdminInstruction() *AcceptAdmin { + return NewAcceptAdminInstructionBuilder() +} diff --git a/programs/stable_vault/AcceptAdmin_test.go b/programs/stable_vault/AcceptAdmin_test.go new file mode 100644 index 000000000..0570f2316 --- /dev/null +++ b/programs/stable_vault/AcceptAdmin_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_AcceptAdmin(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("AcceptAdmin"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(AcceptAdmin) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(AcceptAdmin) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/ChangeBeneficiary.go b/programs/stable_vault/ChangeBeneficiary.go new file mode 100644 index 000000000..a8f967cdc --- /dev/null +++ b/programs/stable_vault/ChangeBeneficiary.go @@ -0,0 +1,107 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ChangeBeneficiary is the `change_beneficiary` instruction. +type ChangeBeneficiary struct { + NewBeneficiary *ag_solanago.PublicKey + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewChangeBeneficiaryInstructionBuilder creates a new `ChangeBeneficiary` instruction builder. +func NewChangeBeneficiaryInstructionBuilder() *ChangeBeneficiary { + nd := &ChangeBeneficiary{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetNewBeneficiary sets the "new_beneficiary" parameter. +func (inst *ChangeBeneficiary) SetNewBeneficiary(new_beneficiary ag_solanago.PublicKey) *ChangeBeneficiary { + inst.NewBeneficiary = &new_beneficiary + return inst +} + +func (inst ChangeBeneficiary) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ChangeBeneficiary, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ChangeBeneficiary) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ChangeBeneficiary) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewBeneficiary == nil { + return errors.New("NewBeneficiary parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *ChangeBeneficiary) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ChangeBeneficiary")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" NewBeneficiary", *inst.NewBeneficiary)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj ChangeBeneficiary) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewBeneficiary` param: + err = encoder.Encode(obj.NewBeneficiary) + if err != nil { + return err + } + return nil +} +func (obj *ChangeBeneficiary) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewBeneficiary`: + err = decoder.Decode(&obj.NewBeneficiary) + if err != nil { + return err + } + return nil +} + +// NewChangeBeneficiaryInstruction declares a new ChangeBeneficiary instruction with the provided parameters and accounts. +func NewChangeBeneficiaryInstruction( + // Parameters: + new_beneficiary ag_solanago.PublicKey) *ChangeBeneficiary { + return NewChangeBeneficiaryInstructionBuilder(). + SetNewBeneficiary(new_beneficiary) +} diff --git a/programs/stable_vault/ChangeBeneficiaryFee.go b/programs/stable_vault/ChangeBeneficiaryFee.go new file mode 100644 index 000000000..86e55b951 --- /dev/null +++ b/programs/stable_vault/ChangeBeneficiaryFee.go @@ -0,0 +1,107 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ChangeBeneficiaryFee is the `change_beneficiary_fee` instruction. +type ChangeBeneficiaryFee struct { + NewBeneficiaryFee *uint64 + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewChangeBeneficiaryFeeInstructionBuilder creates a new `ChangeBeneficiaryFee` instruction builder. +func NewChangeBeneficiaryFeeInstructionBuilder() *ChangeBeneficiaryFee { + nd := &ChangeBeneficiaryFee{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetNewBeneficiaryFee sets the "new_beneficiary_fee" parameter. +func (inst *ChangeBeneficiaryFee) SetNewBeneficiaryFee(new_beneficiary_fee uint64) *ChangeBeneficiaryFee { + inst.NewBeneficiaryFee = &new_beneficiary_fee + return inst +} + +func (inst ChangeBeneficiaryFee) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ChangeBeneficiaryFee, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ChangeBeneficiaryFee) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ChangeBeneficiaryFee) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewBeneficiaryFee == nil { + return errors.New("NewBeneficiaryFee parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *ChangeBeneficiaryFee) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ChangeBeneficiaryFee")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" NewBeneficiaryFee", *inst.NewBeneficiaryFee)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj ChangeBeneficiaryFee) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewBeneficiaryFee` param: + err = encoder.Encode(obj.NewBeneficiaryFee) + if err != nil { + return err + } + return nil +} +func (obj *ChangeBeneficiaryFee) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewBeneficiaryFee`: + err = decoder.Decode(&obj.NewBeneficiaryFee) + if err != nil { + return err + } + return nil +} + +// NewChangeBeneficiaryFeeInstruction declares a new ChangeBeneficiaryFee instruction with the provided parameters and accounts. +func NewChangeBeneficiaryFeeInstruction( + // Parameters: + new_beneficiary_fee uint64) *ChangeBeneficiaryFee { + return NewChangeBeneficiaryFeeInstructionBuilder(). + SetNewBeneficiaryFee(new_beneficiary_fee) +} diff --git a/programs/stable_vault/ChangeBeneficiaryFee_test.go b/programs/stable_vault/ChangeBeneficiaryFee_test.go new file mode 100644 index 000000000..2555c8c99 --- /dev/null +++ b/programs/stable_vault/ChangeBeneficiaryFee_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ChangeBeneficiaryFee(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ChangeBeneficiaryFee"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ChangeBeneficiaryFee) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ChangeBeneficiaryFee) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/ChangeBeneficiary_test.go b/programs/stable_vault/ChangeBeneficiary_test.go new file mode 100644 index 000000000..460a1caf5 --- /dev/null +++ b/programs/stable_vault/ChangeBeneficiary_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ChangeBeneficiary(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ChangeBeneficiary"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ChangeBeneficiary) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ChangeBeneficiary) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/Initialize.go b/programs/stable_vault/Initialize.go new file mode 100644 index 000000000..0e1984185 --- /dev/null +++ b/programs/stable_vault/Initialize.go @@ -0,0 +1,176 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Initialize is the `initialize` instruction. +type Initialize struct { + WithdrawAuthority *ag_solanago.PublicKey + WithdrawAuthorityBump *uint8 + Beneficiary *ag_solanago.PublicKey + BeneficiaryFee *uint64 + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. +func NewInitializeInstructionBuilder() *Initialize { + nd := &Initialize{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetWithdrawAuthority sets the "withdraw_authority" parameter. +func (inst *Initialize) SetWithdrawAuthority(withdraw_authority ag_solanago.PublicKey) *Initialize { + inst.WithdrawAuthority = &withdraw_authority + return inst +} + +// SetWithdrawAuthorityBump sets the "withdraw_authority_bump" parameter. +func (inst *Initialize) SetWithdrawAuthorityBump(withdraw_authority_bump uint8) *Initialize { + inst.WithdrawAuthorityBump = &withdraw_authority_bump + return inst +} + +// SetBeneficiary sets the "beneficiary" parameter. +func (inst *Initialize) SetBeneficiary(beneficiary ag_solanago.PublicKey) *Initialize { + inst.Beneficiary = &beneficiary + return inst +} + +// SetBeneficiaryFee sets the "beneficiary_fee" parameter. +func (inst *Initialize) SetBeneficiaryFee(beneficiary_fee uint64) *Initialize { + inst.BeneficiaryFee = &beneficiary_fee + return inst +} + +func (inst Initialize) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Initialize, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Initialize) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Initialize) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.WithdrawAuthority == nil { + return errors.New("WithdrawAuthority parameter is not set") + } + if inst.WithdrawAuthorityBump == nil { + return errors.New("WithdrawAuthorityBump parameter is not set") + } + if inst.Beneficiary == nil { + return errors.New("Beneficiary parameter is not set") + } + if inst.BeneficiaryFee == nil { + return errors.New("BeneficiaryFee parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Initialize")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=4]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" WithdrawAuthority", *inst.WithdrawAuthority)) + paramsBranch.Child(ag_format.Param(" WithdrawAuthorityBump", *inst.WithdrawAuthorityBump)) + paramsBranch.Child(ag_format.Param(" Beneficiary", *inst.Beneficiary)) + paramsBranch.Child(ag_format.Param(" BeneficiaryFee", *inst.BeneficiaryFee)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj Initialize) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `WithdrawAuthority` param: + err = encoder.Encode(obj.WithdrawAuthority) + if err != nil { + return err + } + // Serialize `WithdrawAuthorityBump` param: + err = encoder.Encode(obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Serialize `Beneficiary` param: + err = encoder.Encode(obj.Beneficiary) + if err != nil { + return err + } + // Serialize `BeneficiaryFee` param: + err = encoder.Encode(obj.BeneficiaryFee) + if err != nil { + return err + } + return nil +} +func (obj *Initialize) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `WithdrawAuthority`: + err = decoder.Decode(&obj.WithdrawAuthority) + if err != nil { + return err + } + // Deserialize `WithdrawAuthorityBump`: + err = decoder.Decode(&obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Deserialize `Beneficiary`: + err = decoder.Decode(&obj.Beneficiary) + if err != nil { + return err + } + // Deserialize `BeneficiaryFee`: + err = decoder.Decode(&obj.BeneficiaryFee) + if err != nil { + return err + } + return nil +} + +// NewInitializeInstruction declares a new Initialize instruction with the provided parameters and accounts. +func NewInitializeInstruction( + // Parameters: + withdraw_authority ag_solanago.PublicKey, + withdraw_authority_bump uint8, + beneficiary ag_solanago.PublicKey, + beneficiary_fee uint64) *Initialize { + return NewInitializeInstructionBuilder(). + SetWithdrawAuthority(withdraw_authority). + SetWithdrawAuthorityBump(withdraw_authority_bump). + SetBeneficiary(beneficiary). + SetBeneficiaryFee(beneficiary_fee) +} diff --git a/programs/stable_vault/Initialize_test.go b/programs/stable_vault/Initialize_test.go new file mode 100644 index 000000000..0b645cfe7 --- /dev/null +++ b/programs/stable_vault/Initialize_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initialize(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initialize"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initialize) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initialize) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/Pause.go b/programs/stable_vault/Pause.go new file mode 100644 index 000000000..49c3e253b --- /dev/null +++ b/programs/stable_vault/Pause.go @@ -0,0 +1,76 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Pause is the `pause` instruction. +type Pause struct { + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewPauseInstructionBuilder creates a new `Pause` instruction builder. +func NewPauseInstructionBuilder() *Pause { + nd := &Pause{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +func (inst Pause) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Pause, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Pause) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Pause) Validate() error { + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *Pause) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Pause")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj Pause) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Pause) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewPauseInstruction declares a new Pause instruction with the provided parameters and accounts. +func NewPauseInstruction() *Pause { + return NewPauseInstructionBuilder() +} diff --git a/programs/stable_vault/Pause_test.go b/programs/stable_vault/Pause_test.go new file mode 100644 index 000000000..545feb598 --- /dev/null +++ b/programs/stable_vault/Pause_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Pause(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Pause"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Pause) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Pause) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/RejectAdmin.go b/programs/stable_vault/RejectAdmin.go new file mode 100644 index 000000000..e42e680d5 --- /dev/null +++ b/programs/stable_vault/RejectAdmin.go @@ -0,0 +1,76 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// RejectAdmin is the `reject_admin` instruction. +type RejectAdmin struct { + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewRejectAdminInstructionBuilder creates a new `RejectAdmin` instruction builder. +func NewRejectAdminInstructionBuilder() *RejectAdmin { + nd := &RejectAdmin{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +func (inst RejectAdmin) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RejectAdmin, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RejectAdmin) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RejectAdmin) Validate() error { + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *RejectAdmin) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RejectAdmin")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj RejectAdmin) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *RejectAdmin) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewRejectAdminInstruction declares a new RejectAdmin instruction with the provided parameters and accounts. +func NewRejectAdminInstruction() *RejectAdmin { + return NewRejectAdminInstructionBuilder() +} diff --git a/programs/stable_vault/RejectAdmin_test.go b/programs/stable_vault/RejectAdmin_test.go new file mode 100644 index 000000000..5286a90b3 --- /dev/null +++ b/programs/stable_vault/RejectAdmin_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RejectAdmin(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RejectAdmin"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RejectAdmin) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RejectAdmin) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/TransferAdmin.go b/programs/stable_vault/TransferAdmin.go new file mode 100644 index 000000000..7a92db3dd --- /dev/null +++ b/programs/stable_vault/TransferAdmin.go @@ -0,0 +1,107 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// TransferAdmin is the `transfer_admin` instruction. +type TransferAdmin struct { + NewAdmin *ag_solanago.PublicKey + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewTransferAdminInstructionBuilder creates a new `TransferAdmin` instruction builder. +func NewTransferAdminInstructionBuilder() *TransferAdmin { + nd := &TransferAdmin{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetNewAdmin sets the "new_admin" parameter. +func (inst *TransferAdmin) SetNewAdmin(new_admin ag_solanago.PublicKey) *TransferAdmin { + inst.NewAdmin = &new_admin + return inst +} + +func (inst TransferAdmin) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_TransferAdmin, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst TransferAdmin) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *TransferAdmin) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewAdmin == nil { + return errors.New("NewAdmin parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *TransferAdmin) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("TransferAdmin")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" NewAdmin", *inst.NewAdmin)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj TransferAdmin) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewAdmin` param: + err = encoder.Encode(obj.NewAdmin) + if err != nil { + return err + } + return nil +} +func (obj *TransferAdmin) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewAdmin`: + err = decoder.Decode(&obj.NewAdmin) + if err != nil { + return err + } + return nil +} + +// NewTransferAdminInstruction declares a new TransferAdmin instruction with the provided parameters and accounts. +func NewTransferAdminInstruction( + // Parameters: + new_admin ag_solanago.PublicKey) *TransferAdmin { + return NewTransferAdminInstructionBuilder(). + SetNewAdmin(new_admin) +} diff --git a/programs/stable_vault/TransferAdmin_test.go b/programs/stable_vault/TransferAdmin_test.go new file mode 100644 index 000000000..e96f1826a --- /dev/null +++ b/programs/stable_vault/TransferAdmin_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_TransferAdmin(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("TransferAdmin"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(TransferAdmin) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(TransferAdmin) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/Unpause.go b/programs/stable_vault/Unpause.go new file mode 100644 index 000000000..83429fdf7 --- /dev/null +++ b/programs/stable_vault/Unpause.go @@ -0,0 +1,76 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Unpause is the `unpause` instruction. +type Unpause struct { + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewUnpauseInstructionBuilder creates a new `Unpause` instruction builder. +func NewUnpauseInstructionBuilder() *Unpause { + nd := &Unpause{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +func (inst Unpause) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Unpause, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Unpause) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Unpause) Validate() error { + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *Unpause) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Unpause")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj Unpause) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *Unpause) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewUnpauseInstruction declares a new Unpause instruction with the provided parameters and accounts. +func NewUnpauseInstruction() *Unpause { + return NewUnpauseInstructionBuilder() +} diff --git a/programs/stable_vault/Unpause_test.go b/programs/stable_vault/Unpause_test.go new file mode 100644 index 000000000..dd7eb2cc4 --- /dev/null +++ b/programs/stable_vault/Unpause_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Unpause(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Unpause"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Unpause) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Unpause) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/Withdraw.go b/programs/stable_vault/Withdraw.go new file mode 100644 index 000000000..5452dc316 --- /dev/null +++ b/programs/stable_vault/Withdraw.go @@ -0,0 +1,130 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// Withdraw is the `withdraw` instruction. +type Withdraw struct { + Amount *uint64 + BeneficiaryAmount *uint64 + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawInstructionBuilder creates a new `Withdraw` instruction builder. +func NewWithdrawInstructionBuilder() *Withdraw { + nd := &Withdraw{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *Withdraw) SetAmount(amount uint64) *Withdraw { + inst.Amount = &amount + return inst +} + +// SetBeneficiaryAmount sets the "beneficiary_amount" parameter. +func (inst *Withdraw) SetBeneficiaryAmount(beneficiary_amount uint64) *Withdraw { + inst.BeneficiaryAmount = &beneficiary_amount + return inst +} + +func (inst Withdraw) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Withdraw, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Withdraw) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Withdraw) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + if inst.BeneficiaryAmount == nil { + return errors.New("BeneficiaryAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *Withdraw) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Withdraw")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) + paramsBranch.Child(ag_format.Param(" BeneficiaryAmount", *inst.BeneficiaryAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj Withdraw) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `BeneficiaryAmount` param: + err = encoder.Encode(obj.BeneficiaryAmount) + if err != nil { + return err + } + return nil +} +func (obj *Withdraw) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `BeneficiaryAmount`: + err = decoder.Decode(&obj.BeneficiaryAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawInstruction declares a new Withdraw instruction with the provided parameters and accounts. +func NewWithdrawInstruction( + // Parameters: + amount uint64, + beneficiary_amount uint64) *Withdraw { + return NewWithdrawInstructionBuilder(). + SetAmount(amount). + SetBeneficiaryAmount(beneficiary_amount) +} diff --git a/programs/stable_vault/WithdrawV2.go b/programs/stable_vault/WithdrawV2.go new file mode 100644 index 000000000..16af12e93 --- /dev/null +++ b/programs/stable_vault/WithdrawV2.go @@ -0,0 +1,130 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// WithdrawV2 is the `withdraw_v2` instruction. +type WithdrawV2 struct { + Amount *uint64 + BeneficiaryAmount *uint64 + + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewWithdrawV2InstructionBuilder creates a new `WithdrawV2` instruction builder. +func NewWithdrawV2InstructionBuilder() *WithdrawV2 { + nd := &WithdrawV2{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 0), + } + return nd +} + +// SetAmount sets the "amount" parameter. +func (inst *WithdrawV2) SetAmount(amount uint64) *WithdrawV2 { + inst.Amount = &amount + return inst +} + +// SetBeneficiaryAmount sets the "beneficiary_amount" parameter. +func (inst *WithdrawV2) SetBeneficiaryAmount(beneficiary_amount uint64) *WithdrawV2 { + inst.BeneficiaryAmount = &beneficiary_amount + return inst +} + +func (inst WithdrawV2) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_WithdrawV2, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst WithdrawV2) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *WithdrawV2) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Amount == nil { + return errors.New("Amount parameter is not set") + } + if inst.BeneficiaryAmount == nil { + return errors.New("BeneficiaryAmount parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + } + return nil +} + +func (inst *WithdrawV2) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("WithdrawV2")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Amount", *inst.Amount)) + paramsBranch.Child(ag_format.Param(" BeneficiaryAmount", *inst.BeneficiaryAmount)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=0]").ParentFunc(func(accountsBranch ag_treeout.Branches) {}) + }) + }) +} + +func (obj WithdrawV2) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `BeneficiaryAmount` param: + err = encoder.Encode(obj.BeneficiaryAmount) + if err != nil { + return err + } + return nil +} +func (obj *WithdrawV2) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `BeneficiaryAmount`: + err = decoder.Decode(&obj.BeneficiaryAmount) + if err != nil { + return err + } + return nil +} + +// NewWithdrawV2Instruction declares a new WithdrawV2 instruction with the provided parameters and accounts. +func NewWithdrawV2Instruction( + // Parameters: + amount uint64, + beneficiary_amount uint64) *WithdrawV2 { + return NewWithdrawV2InstructionBuilder(). + SetAmount(amount). + SetBeneficiaryAmount(beneficiary_amount) +} diff --git a/programs/stable_vault/WithdrawV2_test.go b/programs/stable_vault/WithdrawV2_test.go new file mode 100644 index 000000000..ff300fc9e --- /dev/null +++ b/programs/stable_vault/WithdrawV2_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_WithdrawV2(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("WithdrawV2"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(WithdrawV2) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(WithdrawV2) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/Withdraw_test.go b/programs/stable_vault/Withdraw_test.go new file mode 100644 index 000000000..7dec4192a --- /dev/null +++ b/programs/stable_vault/Withdraw_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Withdraw(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Withdraw"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Withdraw) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Withdraw) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/programs/stable_vault/accounts.go b/programs/stable_vault/accounts.go new file mode 100644 index 000000000..e71724d16 --- /dev/null +++ b/programs/stable_vault/accounts.go @@ -0,0 +1,155 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type VaultAccount struct { + Admin ag_solanago.PublicKey + + // PDAofpoolprogramsseededbyvaultaddress + WithdrawAuthority ag_solanago.PublicKey + + // bumpseedofwithdraw_authorityPDA + WithdrawAuthorityBump uint8 + + // bumpseedofvault_authorityPDA + AuthorityBump uint8 + IsActive bool + Beneficiary ag_solanago.PublicKey + BeneficiaryFee uint64 + PendingAdmin *ag_solanago.PublicKey `bin:"optional"` +} + +var VaultAccountDiscriminator = [8]byte{230, 251, 241, 83, 139, 202, 93, 28} + +func (obj VaultAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(VaultAccountDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Admin` param: + err = encoder.Encode(obj.Admin) + if err != nil { + return err + } + // Serialize `WithdrawAuthority` param: + err = encoder.Encode(obj.WithdrawAuthority) + if err != nil { + return err + } + // Serialize `WithdrawAuthorityBump` param: + err = encoder.Encode(obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Serialize `AuthorityBump` param: + err = encoder.Encode(obj.AuthorityBump) + if err != nil { + return err + } + // Serialize `IsActive` param: + err = encoder.Encode(obj.IsActive) + if err != nil { + return err + } + // Serialize `Beneficiary` param: + err = encoder.Encode(obj.Beneficiary) + if err != nil { + return err + } + // Serialize `BeneficiaryFee` param: + err = encoder.Encode(obj.BeneficiaryFee) + if err != nil { + return err + } + // Serialize `PendingAdmin` param (optional): + { + if obj.PendingAdmin == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.PendingAdmin) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *VaultAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(VaultAccountDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[230 251 241 83 139 202 93 28]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Admin`: + err = decoder.Decode(&obj.Admin) + if err != nil { + return err + } + // Deserialize `WithdrawAuthority`: + err = decoder.Decode(&obj.WithdrawAuthority) + if err != nil { + return err + } + // Deserialize `WithdrawAuthorityBump`: + err = decoder.Decode(&obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Deserialize `AuthorityBump`: + err = decoder.Decode(&obj.AuthorityBump) + if err != nil { + return err + } + // Deserialize `IsActive`: + err = decoder.Decode(&obj.IsActive) + if err != nil { + return err + } + // Deserialize `Beneficiary`: + err = decoder.Decode(&obj.Beneficiary) + if err != nil { + return err + } + // Deserialize `BeneficiaryFee`: + err = decoder.Decode(&obj.BeneficiaryFee) + if err != nil { + return err + } + // Deserialize `PendingAdmin` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.PendingAdmin) + if err != nil { + return err + } + } + } + return nil +} diff --git a/programs/stable_vault/instructions.go b/programs/stable_vault/instructions.go new file mode 100644 index 000000000..67d119a94 --- /dev/null +++ b/programs/stable_vault/instructions.go @@ -0,0 +1,180 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("vo1tWgqZMjG61Z2T9qUaMYKqZ75CYzMuaZ2LZP1n7HV") + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "StableVault" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + Instruction_AcceptAdmin = ag_binary.TypeID([8]byte{112, 42, 45, 90, 116, 181, 13, 170}) + + Instruction_ChangeBeneficiary = ag_binary.TypeID([8]byte{110, 79, 77, 10, 30, 181, 18, 1}) + + Instruction_ChangeBeneficiaryFee = ag_binary.TypeID([8]byte{47, 164, 28, 91, 72, 42, 199, 21}) + + Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) + + Instruction_Pause = ag_binary.TypeID([8]byte{211, 22, 221, 251, 74, 121, 193, 47}) + + Instruction_RejectAdmin = ag_binary.TypeID([8]byte{253, 12, 169, 115, 88, 117, 177, 252}) + + Instruction_TransferAdmin = ag_binary.TypeID([8]byte{42, 242, 66, 106, 228, 10, 111, 156}) + + Instruction_Unpause = ag_binary.TypeID([8]byte{169, 144, 4, 38, 10, 141, 188, 255}) + + Instruction_Withdraw = ag_binary.TypeID([8]byte{183, 18, 70, 156, 148, 109, 161, 34}) + + Instruction_WithdrawV2 = ag_binary.TypeID([8]byte{242, 80, 163, 0, 196, 221, 194, 194}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_AcceptAdmin: + return "AcceptAdmin" + case Instruction_ChangeBeneficiary: + return "ChangeBeneficiary" + case Instruction_ChangeBeneficiaryFee: + return "ChangeBeneficiaryFee" + case Instruction_Initialize: + return "Initialize" + case Instruction_Pause: + return "Pause" + case Instruction_RejectAdmin: + return "RejectAdmin" + case Instruction_TransferAdmin: + return "TransferAdmin" + case Instruction_Unpause: + return "Unpause" + case Instruction_Withdraw: + return "Withdraw" + case Instruction_WithdrawV2: + return "WithdrawV2" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "accept_admin", (*AcceptAdmin)(nil), + }, + { + "change_beneficiary", (*ChangeBeneficiary)(nil), + }, + { + "change_beneficiary_fee", (*ChangeBeneficiaryFee)(nil), + }, + { + "initialize", (*Initialize)(nil), + }, + { + "pause", (*Pause)(nil), + }, + { + "reject_admin", (*RejectAdmin)(nil), + }, + { + "transfer_admin", (*TransferAdmin)(nil), + }, + { + "unpause", (*Unpause)(nil), + }, + { + "withdraw", (*Withdraw)(nil), + }, + { + "withdraw_v2", (*WithdrawV2)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/programs/stable_vault/testing_utils.go b/programs/stable_vault/testing_utils.go new file mode 100644 index 000000000..2f6dea2af --- /dev/null +++ b/programs/stable_vault/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/programs/stable_vault/types.go b/programs/stable_vault/types.go new file mode 100644 index 000000000..e4ff81a56 --- /dev/null +++ b/programs/stable_vault/types.go @@ -0,0 +1,200 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package stable_vault + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type Vault struct { + Admin ag_solanago.PublicKey + + // PDAofpoolprogramsseededbyvaultaddress + WithdrawAuthority ag_solanago.PublicKey + + // bumpseedofwithdraw_authorityPDA + WithdrawAuthorityBump uint8 + + // bumpseedofvault_authorityPDA + AuthorityBump uint8 + IsActive bool + Beneficiary ag_solanago.PublicKey + BeneficiaryFee uint64 + PendingAdmin *ag_solanago.PublicKey `bin:"optional"` +} + +func (obj Vault) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Admin` param: + err = encoder.Encode(obj.Admin) + if err != nil { + return err + } + // Serialize `WithdrawAuthority` param: + err = encoder.Encode(obj.WithdrawAuthority) + if err != nil { + return err + } + // Serialize `WithdrawAuthorityBump` param: + err = encoder.Encode(obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Serialize `AuthorityBump` param: + err = encoder.Encode(obj.AuthorityBump) + if err != nil { + return err + } + // Serialize `IsActive` param: + err = encoder.Encode(obj.IsActive) + if err != nil { + return err + } + // Serialize `Beneficiary` param: + err = encoder.Encode(obj.Beneficiary) + if err != nil { + return err + } + // Serialize `BeneficiaryFee` param: + err = encoder.Encode(obj.BeneficiaryFee) + if err != nil { + return err + } + // Serialize `PendingAdmin` param (optional): + { + if obj.PendingAdmin == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.PendingAdmin) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *Vault) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Admin`: + err = decoder.Decode(&obj.Admin) + if err != nil { + return err + } + // Deserialize `WithdrawAuthority`: + err = decoder.Decode(&obj.WithdrawAuthority) + if err != nil { + return err + } + // Deserialize `WithdrawAuthorityBump`: + err = decoder.Decode(&obj.WithdrawAuthorityBump) + if err != nil { + return err + } + // Deserialize `AuthorityBump`: + err = decoder.Decode(&obj.AuthorityBump) + if err != nil { + return err + } + // Deserialize `IsActive`: + err = decoder.Decode(&obj.IsActive) + if err != nil { + return err + } + // Deserialize `Beneficiary`: + err = decoder.Decode(&obj.Beneficiary) + if err != nil { + return err + } + // Deserialize `BeneficiaryFee`: + err = decoder.Decode(&obj.BeneficiaryFee) + if err != nil { + return err + } + // Deserialize `PendingAdmin` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.PendingAdmin) + if err != nil { + return err + } + } + } + return nil +} + +type VaultUpdatedData struct { + IsActive bool + BeneficiaryFee uint64 +} + +func (obj VaultUpdatedData) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `IsActive` param: + err = encoder.Encode(obj.IsActive) + if err != nil { + return err + } + // Serialize `BeneficiaryFee` param: + err = encoder.Encode(obj.BeneficiaryFee) + if err != nil { + return err + } + return nil +} + +func (obj *VaultUpdatedData) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `IsActive`: + err = decoder.Decode(&obj.IsActive) + if err != nil { + return err + } + // Deserialize `BeneficiaryFee`: + err = decoder.Decode(&obj.BeneficiaryFee) + if err != nil { + return err + } + return nil +} + +type VaultUpdatedEvent struct { + PublicKey ag_solanago.PublicKey + Data VaultUpdatedData +} + +func (obj VaultUpdatedEvent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PublicKey` param: + err = encoder.Encode(obj.PublicKey) + if err != nil { + return err + } + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + return nil +} + +func (obj *VaultUpdatedEvent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PublicKey`: + err = decoder.Decode(&obj.PublicKey) + if err != nil { + return err + } + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + return nil +} diff --git a/programs/whirlpool/instructions.go b/programs/whirlpool/instructions.go index abcde9731..a66098d3f 100644 --- a/programs/whirlpool/instructions.go +++ b/programs/whirlpool/instructions.go @@ -12,7 +12,7 @@ import ( ag_treeout "github.com/gagliardetto/treeout" ) -var ProgramID ag_solanago.PublicKey +var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc") func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey diff --git a/programs/whirlpool/utils.go b/programs/whirlpool/utils.go deleted file mode 100644 index 4d17441ef..000000000 --- a/programs/whirlpool/utils.go +++ /dev/null @@ -1 +0,0 @@ -package whirlpool