github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/SetDefaultFeeRate.go (about) 1 // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. 2 3 package whirlpool 4 5 import ( 6 "errors" 7 ag_binary "github.com/gagliardetto/binary" 8 ag_solanago "github.com/gagliardetto/solana-go" 9 ag_format "github.com/gagliardetto/solana-go/text/format" 10 ag_treeout "github.com/gagliardetto/treeout" 11 ) 12 13 // SetDefaultFeeRate is the `setDefaultFeeRate` instruction. 14 type SetDefaultFeeRate struct { 15 DefaultFeeRate *uint16 16 17 // [0] = [] whirlpoolsConfig 18 // 19 // [1] = [WRITE] feeTier 20 // 21 // [2] = [SIGNER] feeAuthority 22 ag_solanago.AccountMetaSlice `bin:"-"` 23 } 24 25 // NewSetDefaultFeeRateInstructionBuilder creates a new `SetDefaultFeeRate` instruction builder. 26 func NewSetDefaultFeeRateInstructionBuilder() *SetDefaultFeeRate { 27 nd := &SetDefaultFeeRate{ 28 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), 29 } 30 return nd 31 } 32 33 // SetDefaultFeeRate sets the "defaultFeeRate" parameter. 34 func (inst *SetDefaultFeeRate) SetDefaultFeeRate(defaultFeeRate uint16) *SetDefaultFeeRate { 35 inst.DefaultFeeRate = &defaultFeeRate 36 return inst 37 } 38 39 // SetWhirlpoolsConfigAccount sets the "whirlpoolsConfig" account. 40 func (inst *SetDefaultFeeRate) SetWhirlpoolsConfigAccount(whirlpoolsConfig ag_solanago.PublicKey) *SetDefaultFeeRate { 41 inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpoolsConfig) 42 return inst 43 } 44 45 // GetWhirlpoolsConfigAccount gets the "whirlpoolsConfig" account. 46 func (inst *SetDefaultFeeRate) GetWhirlpoolsConfigAccount() *ag_solanago.AccountMeta { 47 return inst.AccountMetaSlice.Get(0) 48 } 49 50 // SetFeeTierAccount sets the "feeTier" account. 51 func (inst *SetDefaultFeeRate) SetFeeTierAccount(feeTier ag_solanago.PublicKey) *SetDefaultFeeRate { 52 inst.AccountMetaSlice[1] = ag_solanago.Meta(feeTier).WRITE() 53 return inst 54 } 55 56 // GetFeeTierAccount gets the "feeTier" account. 57 func (inst *SetDefaultFeeRate) GetFeeTierAccount() *ag_solanago.AccountMeta { 58 return inst.AccountMetaSlice.Get(1) 59 } 60 61 // SetFeeAuthorityAccount sets the "feeAuthority" account. 62 func (inst *SetDefaultFeeRate) SetFeeAuthorityAccount(feeAuthority ag_solanago.PublicKey) *SetDefaultFeeRate { 63 inst.AccountMetaSlice[2] = ag_solanago.Meta(feeAuthority).SIGNER() 64 return inst 65 } 66 67 // GetFeeAuthorityAccount gets the "feeAuthority" account. 68 func (inst *SetDefaultFeeRate) GetFeeAuthorityAccount() *ag_solanago.AccountMeta { 69 return inst.AccountMetaSlice.Get(2) 70 } 71 72 func (inst SetDefaultFeeRate) Build() *Instruction { 73 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 74 Impl: inst, 75 TypeID: Instruction_SetDefaultFeeRate, 76 }} 77 } 78 79 // ValidateAndBuild validates the instruction parameters and accounts; 80 // if there is a validation error, it returns the error. 81 // Otherwise, it builds and returns the instruction. 82 func (inst SetDefaultFeeRate) ValidateAndBuild() (*Instruction, error) { 83 if err := inst.Validate(); err != nil { 84 return nil, err 85 } 86 return inst.Build(), nil 87 } 88 89 func (inst *SetDefaultFeeRate) Validate() error { 90 // Check whether all (required) parameters are set: 91 { 92 if inst.DefaultFeeRate == nil { 93 return errors.New("DefaultFeeRate parameter is not set") 94 } 95 } 96 97 // Check whether all (required) accounts are set: 98 { 99 if inst.AccountMetaSlice[0] == nil { 100 return errors.New("accounts.WhirlpoolsConfig is not set") 101 } 102 if inst.AccountMetaSlice[1] == nil { 103 return errors.New("accounts.FeeTier is not set") 104 } 105 if inst.AccountMetaSlice[2] == nil { 106 return errors.New("accounts.FeeAuthority is not set") 107 } 108 } 109 return nil 110 } 111 112 func (inst *SetDefaultFeeRate) EncodeToTree(parent ag_treeout.Branches) { 113 parent.Child(ag_format.Program(ProgramName, ProgramID)). 114 // 115 ParentFunc(func(programBranch ag_treeout.Branches) { 116 programBranch.Child(ag_format.Instruction("SetDefaultFeeRate")). 117 // 118 ParentFunc(func(instructionBranch ag_treeout.Branches) { 119 120 // Parameters of the instruction: 121 instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { 122 paramsBranch.Child(ag_format.Param("DefaultFeeRate", *inst.DefaultFeeRate)) 123 }) 124 125 // Accounts of the instruction: 126 instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 127 accountsBranch.Child(ag_format.Meta("whirlpoolsConfig", inst.AccountMetaSlice.Get(0))) 128 accountsBranch.Child(ag_format.Meta(" feeTier", inst.AccountMetaSlice.Get(1))) 129 accountsBranch.Child(ag_format.Meta(" feeAuthority", inst.AccountMetaSlice.Get(2))) 130 }) 131 }) 132 }) 133 } 134 135 func (obj SetDefaultFeeRate) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 136 // Serialize `DefaultFeeRate` param: 137 err = encoder.Encode(obj.DefaultFeeRate) 138 if err != nil { 139 return err 140 } 141 return nil 142 } 143 func (obj *SetDefaultFeeRate) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 144 // Deserialize `DefaultFeeRate`: 145 err = decoder.Decode(&obj.DefaultFeeRate) 146 if err != nil { 147 return err 148 } 149 return nil 150 } 151 152 // NewSetDefaultFeeRateInstruction declares a new SetDefaultFeeRate instruction with the provided parameters and accounts. 153 func NewSetDefaultFeeRateInstruction( 154 // Parameters: 155 defaultFeeRate uint16, 156 // Accounts: 157 whirlpoolsConfig ag_solanago.PublicKey, 158 feeTier ag_solanago.PublicKey, 159 feeAuthority ag_solanago.PublicKey) *SetDefaultFeeRate { 160 return NewSetDefaultFeeRateInstructionBuilder(). 161 SetDefaultFeeRate(defaultFeeRate). 162 SetWhirlpoolsConfigAccount(whirlpoolsConfig). 163 SetFeeTierAccount(feeTier). 164 SetFeeAuthorityAccount(feeAuthority) 165 }