github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/InitializeFeeTier.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 // InitializeFeeTier is the `initializeFeeTier` instruction. 14 type InitializeFeeTier struct { 15 TickSpacing *uint16 16 DefaultFeeRate *uint16 17 18 // [0] = [] config 19 // 20 // [1] = [WRITE] feeTier 21 // 22 // [2] = [WRITE, SIGNER] funder 23 // 24 // [3] = [SIGNER] feeAuthority 25 // 26 // [4] = [] systemProgram 27 ag_solanago.AccountMetaSlice `bin:"-"` 28 } 29 30 // NewInitializeFeeTierInstructionBuilder creates a new `InitializeFeeTier` instruction builder. 31 func NewInitializeFeeTierInstructionBuilder() *InitializeFeeTier { 32 nd := &InitializeFeeTier{ 33 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 5), 34 } 35 return nd 36 } 37 38 // SetTickSpacing sets the "tickSpacing" parameter. 39 func (inst *InitializeFeeTier) SetTickSpacing(tickSpacing uint16) *InitializeFeeTier { 40 inst.TickSpacing = &tickSpacing 41 return inst 42 } 43 44 // SetDefaultFeeRate sets the "defaultFeeRate" parameter. 45 func (inst *InitializeFeeTier) SetDefaultFeeRate(defaultFeeRate uint16) *InitializeFeeTier { 46 inst.DefaultFeeRate = &defaultFeeRate 47 return inst 48 } 49 50 // SetConfigAccount sets the "config" account. 51 func (inst *InitializeFeeTier) SetConfigAccount(config ag_solanago.PublicKey) *InitializeFeeTier { 52 inst.AccountMetaSlice[0] = ag_solanago.Meta(config) 53 return inst 54 } 55 56 // GetConfigAccount gets the "config" account. 57 func (inst *InitializeFeeTier) GetConfigAccount() *ag_solanago.AccountMeta { 58 return inst.AccountMetaSlice.Get(0) 59 } 60 61 // SetFeeTierAccount sets the "feeTier" account. 62 func (inst *InitializeFeeTier) SetFeeTierAccount(feeTier ag_solanago.PublicKey) *InitializeFeeTier { 63 inst.AccountMetaSlice[1] = ag_solanago.Meta(feeTier).WRITE() 64 return inst 65 } 66 67 // GetFeeTierAccount gets the "feeTier" account. 68 func (inst *InitializeFeeTier) GetFeeTierAccount() *ag_solanago.AccountMeta { 69 return inst.AccountMetaSlice.Get(1) 70 } 71 72 // SetFunderAccount sets the "funder" account. 73 func (inst *InitializeFeeTier) SetFunderAccount(funder ag_solanago.PublicKey) *InitializeFeeTier { 74 inst.AccountMetaSlice[2] = ag_solanago.Meta(funder).WRITE().SIGNER() 75 return inst 76 } 77 78 // GetFunderAccount gets the "funder" account. 79 func (inst *InitializeFeeTier) GetFunderAccount() *ag_solanago.AccountMeta { 80 return inst.AccountMetaSlice.Get(2) 81 } 82 83 // SetFeeAuthorityAccount sets the "feeAuthority" account. 84 func (inst *InitializeFeeTier) SetFeeAuthorityAccount(feeAuthority ag_solanago.PublicKey) *InitializeFeeTier { 85 inst.AccountMetaSlice[3] = ag_solanago.Meta(feeAuthority).SIGNER() 86 return inst 87 } 88 89 // GetFeeAuthorityAccount gets the "feeAuthority" account. 90 func (inst *InitializeFeeTier) GetFeeAuthorityAccount() *ag_solanago.AccountMeta { 91 return inst.AccountMetaSlice.Get(3) 92 } 93 94 // SetSystemProgramAccount sets the "systemProgram" account. 95 func (inst *InitializeFeeTier) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *InitializeFeeTier { 96 inst.AccountMetaSlice[4] = ag_solanago.Meta(systemProgram) 97 return inst 98 } 99 100 // GetSystemProgramAccount gets the "systemProgram" account. 101 func (inst *InitializeFeeTier) GetSystemProgramAccount() *ag_solanago.AccountMeta { 102 return inst.AccountMetaSlice.Get(4) 103 } 104 105 func (inst InitializeFeeTier) Build() *Instruction { 106 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 107 Impl: inst, 108 TypeID: Instruction_InitializeFeeTier, 109 }} 110 } 111 112 // ValidateAndBuild validates the instruction parameters and accounts; 113 // if there is a validation error, it returns the error. 114 // Otherwise, it builds and returns the instruction. 115 func (inst InitializeFeeTier) ValidateAndBuild() (*Instruction, error) { 116 if err := inst.Validate(); err != nil { 117 return nil, err 118 } 119 return inst.Build(), nil 120 } 121 122 func (inst *InitializeFeeTier) Validate() error { 123 // Check whether all (required) parameters are set: 124 { 125 if inst.TickSpacing == nil { 126 return errors.New("TickSpacing parameter is not set") 127 } 128 if inst.DefaultFeeRate == nil { 129 return errors.New("DefaultFeeRate parameter is not set") 130 } 131 } 132 133 // Check whether all (required) accounts are set: 134 { 135 if inst.AccountMetaSlice[0] == nil { 136 return errors.New("accounts.Config is not set") 137 } 138 if inst.AccountMetaSlice[1] == nil { 139 return errors.New("accounts.FeeTier is not set") 140 } 141 if inst.AccountMetaSlice[2] == nil { 142 return errors.New("accounts.Funder is not set") 143 } 144 if inst.AccountMetaSlice[3] == nil { 145 return errors.New("accounts.FeeAuthority is not set") 146 } 147 if inst.AccountMetaSlice[4] == nil { 148 return errors.New("accounts.SystemProgram is not set") 149 } 150 } 151 return nil 152 } 153 154 func (inst *InitializeFeeTier) EncodeToTree(parent ag_treeout.Branches) { 155 parent.Child(ag_format.Program(ProgramName, ProgramID)). 156 // 157 ParentFunc(func(programBranch ag_treeout.Branches) { 158 programBranch.Child(ag_format.Instruction("InitializeFeeTier")). 159 // 160 ParentFunc(func(instructionBranch ag_treeout.Branches) { 161 162 // Parameters of the instruction: 163 instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { 164 paramsBranch.Child(ag_format.Param(" TickSpacing", *inst.TickSpacing)) 165 paramsBranch.Child(ag_format.Param("DefaultFeeRate", *inst.DefaultFeeRate)) 166 }) 167 168 // Accounts of the instruction: 169 instructionBranch.Child("Accounts[len=5]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 170 accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice.Get(0))) 171 accountsBranch.Child(ag_format.Meta(" feeTier", inst.AccountMetaSlice.Get(1))) 172 accountsBranch.Child(ag_format.Meta(" funder", inst.AccountMetaSlice.Get(2))) 173 accountsBranch.Child(ag_format.Meta(" feeAuthority", inst.AccountMetaSlice.Get(3))) 174 accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice.Get(4))) 175 }) 176 }) 177 }) 178 } 179 180 func (obj InitializeFeeTier) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 181 // Serialize `TickSpacing` param: 182 err = encoder.Encode(obj.TickSpacing) 183 if err != nil { 184 return err 185 } 186 // Serialize `DefaultFeeRate` param: 187 err = encoder.Encode(obj.DefaultFeeRate) 188 if err != nil { 189 return err 190 } 191 return nil 192 } 193 func (obj *InitializeFeeTier) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 194 // Deserialize `TickSpacing`: 195 err = decoder.Decode(&obj.TickSpacing) 196 if err != nil { 197 return err 198 } 199 // Deserialize `DefaultFeeRate`: 200 err = decoder.Decode(&obj.DefaultFeeRate) 201 if err != nil { 202 return err 203 } 204 return nil 205 } 206 207 // NewInitializeFeeTierInstruction declares a new InitializeFeeTier instruction with the provided parameters and accounts. 208 func NewInitializeFeeTierInstruction( 209 // Parameters: 210 tickSpacing uint16, 211 defaultFeeRate uint16, 212 // Accounts: 213 config ag_solanago.PublicKey, 214 feeTier ag_solanago.PublicKey, 215 funder ag_solanago.PublicKey, 216 feeAuthority ag_solanago.PublicKey, 217 systemProgram ag_solanago.PublicKey) *InitializeFeeTier { 218 return NewInitializeFeeTierInstructionBuilder(). 219 SetTickSpacing(tickSpacing). 220 SetDefaultFeeRate(defaultFeeRate). 221 SetConfigAccount(config). 222 SetFeeTierAccount(feeTier). 223 SetFunderAccount(funder). 224 SetFeeAuthorityAccount(feeAuthority). 225 SetSystemProgramAccount(systemProgram) 226 }