github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/OpenPositionWithMetadata.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 // OpenPositionWithMetadata is the `openPositionWithMetadata` instruction. 14 type OpenPositionWithMetadata struct { 15 Bumps *OpenPositionWithMetadataBumps 16 TickLowerIndex *int32 17 TickUpperIndex *int32 18 19 // [0] = [WRITE, SIGNER] funder 20 // 21 // [1] = [] owner 22 // 23 // [2] = [WRITE] position 24 // 25 // [3] = [WRITE, SIGNER] positionMint 26 // 27 // [4] = [WRITE] positionMetadataAccount 28 // 29 // [5] = [WRITE] positionTokenAccount 30 // 31 // [6] = [] whirlpool 32 // 33 // [7] = [] tokenProgram 34 // 35 // [8] = [] systemProgram 36 // 37 // [9] = [] rent 38 // 39 // [10] = [] associatedTokenProgram 40 // 41 // [11] = [] metadataProgram 42 // 43 // [12] = [] metadataUpdateAuth 44 ag_solanago.AccountMetaSlice `bin:"-"` 45 } 46 47 // NewOpenPositionWithMetadataInstructionBuilder creates a new `OpenPositionWithMetadata` instruction builder. 48 func NewOpenPositionWithMetadataInstructionBuilder() *OpenPositionWithMetadata { 49 nd := &OpenPositionWithMetadata{ 50 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 13), 51 } 52 return nd 53 } 54 55 // SetBumps sets the "bumps" parameter. 56 func (inst *OpenPositionWithMetadata) SetBumps(bumps OpenPositionWithMetadataBumps) *OpenPositionWithMetadata { 57 inst.Bumps = &bumps 58 return inst 59 } 60 61 // SetTickLowerIndex sets the "tickLowerIndex" parameter. 62 func (inst *OpenPositionWithMetadata) SetTickLowerIndex(tickLowerIndex int32) *OpenPositionWithMetadata { 63 inst.TickLowerIndex = &tickLowerIndex 64 return inst 65 } 66 67 // SetTickUpperIndex sets the "tickUpperIndex" parameter. 68 func (inst *OpenPositionWithMetadata) SetTickUpperIndex(tickUpperIndex int32) *OpenPositionWithMetadata { 69 inst.TickUpperIndex = &tickUpperIndex 70 return inst 71 } 72 73 // SetFunderAccount sets the "funder" account. 74 func (inst *OpenPositionWithMetadata) SetFunderAccount(funder ag_solanago.PublicKey) *OpenPositionWithMetadata { 75 inst.AccountMetaSlice[0] = ag_solanago.Meta(funder).WRITE().SIGNER() 76 return inst 77 } 78 79 // GetFunderAccount gets the "funder" account. 80 func (inst *OpenPositionWithMetadata) GetFunderAccount() *ag_solanago.AccountMeta { 81 return inst.AccountMetaSlice.Get(0) 82 } 83 84 // SetOwnerAccount sets the "owner" account. 85 func (inst *OpenPositionWithMetadata) SetOwnerAccount(owner ag_solanago.PublicKey) *OpenPositionWithMetadata { 86 inst.AccountMetaSlice[1] = ag_solanago.Meta(owner) 87 return inst 88 } 89 90 // GetOwnerAccount gets the "owner" account. 91 func (inst *OpenPositionWithMetadata) GetOwnerAccount() *ag_solanago.AccountMeta { 92 return inst.AccountMetaSlice.Get(1) 93 } 94 95 // SetPositionAccount sets the "position" account. 96 func (inst *OpenPositionWithMetadata) SetPositionAccount(position ag_solanago.PublicKey) *OpenPositionWithMetadata { 97 inst.AccountMetaSlice[2] = ag_solanago.Meta(position).WRITE() 98 return inst 99 } 100 101 // GetPositionAccount gets the "position" account. 102 func (inst *OpenPositionWithMetadata) GetPositionAccount() *ag_solanago.AccountMeta { 103 return inst.AccountMetaSlice.Get(2) 104 } 105 106 // SetPositionMintAccount sets the "positionMint" account. 107 func (inst *OpenPositionWithMetadata) SetPositionMintAccount(positionMint ag_solanago.PublicKey) *OpenPositionWithMetadata { 108 inst.AccountMetaSlice[3] = ag_solanago.Meta(positionMint).WRITE().SIGNER() 109 return inst 110 } 111 112 // GetPositionMintAccount gets the "positionMint" account. 113 func (inst *OpenPositionWithMetadata) GetPositionMintAccount() *ag_solanago.AccountMeta { 114 return inst.AccountMetaSlice.Get(3) 115 } 116 117 // SetPositionMetadataAccountAccount sets the "positionMetadataAccount" account. 118 func (inst *OpenPositionWithMetadata) SetPositionMetadataAccountAccount(positionMetadataAccount ag_solanago.PublicKey) *OpenPositionWithMetadata { 119 inst.AccountMetaSlice[4] = ag_solanago.Meta(positionMetadataAccount).WRITE() 120 return inst 121 } 122 123 // GetPositionMetadataAccountAccount gets the "positionMetadataAccount" account. 124 func (inst *OpenPositionWithMetadata) GetPositionMetadataAccountAccount() *ag_solanago.AccountMeta { 125 return inst.AccountMetaSlice.Get(4) 126 } 127 128 // SetPositionTokenAccountAccount sets the "positionTokenAccount" account. 129 func (inst *OpenPositionWithMetadata) SetPositionTokenAccountAccount(positionTokenAccount ag_solanago.PublicKey) *OpenPositionWithMetadata { 130 inst.AccountMetaSlice[5] = ag_solanago.Meta(positionTokenAccount).WRITE() 131 return inst 132 } 133 134 // GetPositionTokenAccountAccount gets the "positionTokenAccount" account. 135 func (inst *OpenPositionWithMetadata) GetPositionTokenAccountAccount() *ag_solanago.AccountMeta { 136 return inst.AccountMetaSlice.Get(5) 137 } 138 139 // SetWhirlpoolAccount sets the "whirlpool" account. 140 func (inst *OpenPositionWithMetadata) SetWhirlpoolAccount(whirlpool ag_solanago.PublicKey) *OpenPositionWithMetadata { 141 inst.AccountMetaSlice[6] = ag_solanago.Meta(whirlpool) 142 return inst 143 } 144 145 // GetWhirlpoolAccount gets the "whirlpool" account. 146 func (inst *OpenPositionWithMetadata) GetWhirlpoolAccount() *ag_solanago.AccountMeta { 147 return inst.AccountMetaSlice.Get(6) 148 } 149 150 // SetTokenProgramAccount sets the "tokenProgram" account. 151 func (inst *OpenPositionWithMetadata) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *OpenPositionWithMetadata { 152 inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenProgram) 153 return inst 154 } 155 156 // GetTokenProgramAccount gets the "tokenProgram" account. 157 func (inst *OpenPositionWithMetadata) GetTokenProgramAccount() *ag_solanago.AccountMeta { 158 return inst.AccountMetaSlice.Get(7) 159 } 160 161 // SetSystemProgramAccount sets the "systemProgram" account. 162 func (inst *OpenPositionWithMetadata) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *OpenPositionWithMetadata { 163 inst.AccountMetaSlice[8] = ag_solanago.Meta(systemProgram) 164 return inst 165 } 166 167 // GetSystemProgramAccount gets the "systemProgram" account. 168 func (inst *OpenPositionWithMetadata) GetSystemProgramAccount() *ag_solanago.AccountMeta { 169 return inst.AccountMetaSlice.Get(8) 170 } 171 172 // SetRentAccount sets the "rent" account. 173 func (inst *OpenPositionWithMetadata) SetRentAccount(rent ag_solanago.PublicKey) *OpenPositionWithMetadata { 174 inst.AccountMetaSlice[9] = ag_solanago.Meta(rent) 175 return inst 176 } 177 178 // GetRentAccount gets the "rent" account. 179 func (inst *OpenPositionWithMetadata) GetRentAccount() *ag_solanago.AccountMeta { 180 return inst.AccountMetaSlice.Get(9) 181 } 182 183 // SetAssociatedTokenProgramAccount sets the "associatedTokenProgram" account. 184 func (inst *OpenPositionWithMetadata) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *OpenPositionWithMetadata { 185 inst.AccountMetaSlice[10] = ag_solanago.Meta(associatedTokenProgram) 186 return inst 187 } 188 189 // GetAssociatedTokenProgramAccount gets the "associatedTokenProgram" account. 190 func (inst *OpenPositionWithMetadata) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta { 191 return inst.AccountMetaSlice.Get(10) 192 } 193 194 // SetMetadataProgramAccount sets the "metadataProgram" account. 195 func (inst *OpenPositionWithMetadata) SetMetadataProgramAccount(metadataProgram ag_solanago.PublicKey) *OpenPositionWithMetadata { 196 inst.AccountMetaSlice[11] = ag_solanago.Meta(metadataProgram) 197 return inst 198 } 199 200 // GetMetadataProgramAccount gets the "metadataProgram" account. 201 func (inst *OpenPositionWithMetadata) GetMetadataProgramAccount() *ag_solanago.AccountMeta { 202 return inst.AccountMetaSlice.Get(11) 203 } 204 205 // SetMetadataUpdateAuthAccount sets the "metadataUpdateAuth" account. 206 func (inst *OpenPositionWithMetadata) SetMetadataUpdateAuthAccount(metadataUpdateAuth ag_solanago.PublicKey) *OpenPositionWithMetadata { 207 inst.AccountMetaSlice[12] = ag_solanago.Meta(metadataUpdateAuth) 208 return inst 209 } 210 211 // GetMetadataUpdateAuthAccount gets the "metadataUpdateAuth" account. 212 func (inst *OpenPositionWithMetadata) GetMetadataUpdateAuthAccount() *ag_solanago.AccountMeta { 213 return inst.AccountMetaSlice.Get(12) 214 } 215 216 func (inst OpenPositionWithMetadata) Build() *Instruction { 217 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 218 Impl: inst, 219 TypeID: Instruction_OpenPositionWithMetadata, 220 }} 221 } 222 223 // ValidateAndBuild validates the instruction parameters and accounts; 224 // if there is a validation error, it returns the error. 225 // Otherwise, it builds and returns the instruction. 226 func (inst OpenPositionWithMetadata) ValidateAndBuild() (*Instruction, error) { 227 if err := inst.Validate(); err != nil { 228 return nil, err 229 } 230 return inst.Build(), nil 231 } 232 233 func (inst *OpenPositionWithMetadata) Validate() error { 234 // Check whether all (required) parameters are set: 235 { 236 if inst.Bumps == nil { 237 return errors.New("Bumps parameter is not set") 238 } 239 if inst.TickLowerIndex == nil { 240 return errors.New("TickLowerIndex parameter is not set") 241 } 242 if inst.TickUpperIndex == nil { 243 return errors.New("TickUpperIndex parameter is not set") 244 } 245 } 246 247 // Check whether all (required) accounts are set: 248 { 249 if inst.AccountMetaSlice[0] == nil { 250 return errors.New("accounts.Funder is not set") 251 } 252 if inst.AccountMetaSlice[1] == nil { 253 return errors.New("accounts.Owner is not set") 254 } 255 if inst.AccountMetaSlice[2] == nil { 256 return errors.New("accounts.Position is not set") 257 } 258 if inst.AccountMetaSlice[3] == nil { 259 return errors.New("accounts.PositionMint is not set") 260 } 261 if inst.AccountMetaSlice[4] == nil { 262 return errors.New("accounts.PositionMetadataAccount is not set") 263 } 264 if inst.AccountMetaSlice[5] == nil { 265 return errors.New("accounts.PositionTokenAccount is not set") 266 } 267 if inst.AccountMetaSlice[6] == nil { 268 return errors.New("accounts.Whirlpool is not set") 269 } 270 if inst.AccountMetaSlice[7] == nil { 271 return errors.New("accounts.TokenProgram is not set") 272 } 273 if inst.AccountMetaSlice[8] == nil { 274 return errors.New("accounts.SystemProgram is not set") 275 } 276 if inst.AccountMetaSlice[9] == nil { 277 return errors.New("accounts.Rent is not set") 278 } 279 if inst.AccountMetaSlice[10] == nil { 280 return errors.New("accounts.AssociatedTokenProgram is not set") 281 } 282 if inst.AccountMetaSlice[11] == nil { 283 return errors.New("accounts.MetadataProgram is not set") 284 } 285 if inst.AccountMetaSlice[12] == nil { 286 return errors.New("accounts.MetadataUpdateAuth is not set") 287 } 288 } 289 return nil 290 } 291 292 func (inst *OpenPositionWithMetadata) EncodeToTree(parent ag_treeout.Branches) { 293 parent.Child(ag_format.Program(ProgramName, ProgramID)). 294 // 295 ParentFunc(func(programBranch ag_treeout.Branches) { 296 programBranch.Child(ag_format.Instruction("OpenPositionWithMetadata")). 297 // 298 ParentFunc(func(instructionBranch ag_treeout.Branches) { 299 300 // Parameters of the instruction: 301 instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { 302 paramsBranch.Child(ag_format.Param(" Bumps", *inst.Bumps)) 303 paramsBranch.Child(ag_format.Param("TickLowerIndex", *inst.TickLowerIndex)) 304 paramsBranch.Child(ag_format.Param("TickUpperIndex", *inst.TickUpperIndex)) 305 }) 306 307 // Accounts of the instruction: 308 instructionBranch.Child("Accounts[len=13]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 309 accountsBranch.Child(ag_format.Meta(" funder", inst.AccountMetaSlice.Get(0))) 310 accountsBranch.Child(ag_format.Meta(" owner", inst.AccountMetaSlice.Get(1))) 311 accountsBranch.Child(ag_format.Meta(" position", inst.AccountMetaSlice.Get(2))) 312 accountsBranch.Child(ag_format.Meta(" positionMint", inst.AccountMetaSlice.Get(3))) 313 accountsBranch.Child(ag_format.Meta(" positionMetadata", inst.AccountMetaSlice.Get(4))) 314 accountsBranch.Child(ag_format.Meta(" positionToken", inst.AccountMetaSlice.Get(5))) 315 accountsBranch.Child(ag_format.Meta(" whirlpool", inst.AccountMetaSlice.Get(6))) 316 accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(7))) 317 accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(8))) 318 accountsBranch.Child(ag_format.Meta(" rent", inst.AccountMetaSlice.Get(9))) 319 accountsBranch.Child(ag_format.Meta("associatedTokenProgram", inst.AccountMetaSlice.Get(10))) 320 accountsBranch.Child(ag_format.Meta(" metadataProgram", inst.AccountMetaSlice.Get(11))) 321 accountsBranch.Child(ag_format.Meta(" metadataUpdateAuth", inst.AccountMetaSlice.Get(12))) 322 }) 323 }) 324 }) 325 } 326 327 func (obj OpenPositionWithMetadata) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 328 // Serialize `Bumps` param: 329 err = encoder.Encode(obj.Bumps) 330 if err != nil { 331 return err 332 } 333 // Serialize `TickLowerIndex` param: 334 err = encoder.Encode(obj.TickLowerIndex) 335 if err != nil { 336 return err 337 } 338 // Serialize `TickUpperIndex` param: 339 err = encoder.Encode(obj.TickUpperIndex) 340 if err != nil { 341 return err 342 } 343 return nil 344 } 345 func (obj *OpenPositionWithMetadata) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 346 // Deserialize `Bumps`: 347 err = decoder.Decode(&obj.Bumps) 348 if err != nil { 349 return err 350 } 351 // Deserialize `TickLowerIndex`: 352 err = decoder.Decode(&obj.TickLowerIndex) 353 if err != nil { 354 return err 355 } 356 // Deserialize `TickUpperIndex`: 357 err = decoder.Decode(&obj.TickUpperIndex) 358 if err != nil { 359 return err 360 } 361 return nil 362 } 363 364 // NewOpenPositionWithMetadataInstruction declares a new OpenPositionWithMetadata instruction with the provided parameters and accounts. 365 func NewOpenPositionWithMetadataInstruction( 366 // Parameters: 367 bumps OpenPositionWithMetadataBumps, 368 tickLowerIndex int32, 369 tickUpperIndex int32, 370 // Accounts: 371 funder ag_solanago.PublicKey, 372 owner ag_solanago.PublicKey, 373 position ag_solanago.PublicKey, 374 positionMint ag_solanago.PublicKey, 375 positionMetadataAccount ag_solanago.PublicKey, 376 positionTokenAccount ag_solanago.PublicKey, 377 whirlpool ag_solanago.PublicKey, 378 tokenProgram ag_solanago.PublicKey, 379 systemProgram ag_solanago.PublicKey, 380 rent ag_solanago.PublicKey, 381 associatedTokenProgram ag_solanago.PublicKey, 382 metadataProgram ag_solanago.PublicKey, 383 metadataUpdateAuth ag_solanago.PublicKey) *OpenPositionWithMetadata { 384 return NewOpenPositionWithMetadataInstructionBuilder(). 385 SetBumps(bumps). 386 SetTickLowerIndex(tickLowerIndex). 387 SetTickUpperIndex(tickUpperIndex). 388 SetFunderAccount(funder). 389 SetOwnerAccount(owner). 390 SetPositionAccount(position). 391 SetPositionMintAccount(positionMint). 392 SetPositionMetadataAccountAccount(positionMetadataAccount). 393 SetPositionTokenAccountAccount(positionTokenAccount). 394 SetWhirlpoolAccount(whirlpool). 395 SetTokenProgramAccount(tokenProgram). 396 SetSystemProgramAccount(systemProgram). 397 SetRentAccount(rent). 398 SetAssociatedTokenProgramAccount(associatedTokenProgram). 399 SetMetadataProgramAccount(metadataProgram). 400 SetMetadataUpdateAuthAccount(metadataUpdateAuth) 401 }