github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/CollectFees.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 // CollectFees is the `collectFees` instruction. 14 type CollectFees struct { 15 16 // [0] = [] whirlpool 17 // 18 // [1] = [SIGNER] positionAuthority 19 // 20 // [2] = [WRITE] position 21 // 22 // [3] = [] positionTokenAccount 23 // 24 // [4] = [WRITE] tokenOwnerAccountA 25 // 26 // [5] = [WRITE] tokenVaultA 27 // 28 // [6] = [WRITE] tokenOwnerAccountB 29 // 30 // [7] = [WRITE] tokenVaultB 31 // 32 // [8] = [] tokenProgram 33 ag_solanago.AccountMetaSlice `bin:"-"` 34 } 35 36 // NewCollectFeesInstructionBuilder creates a new `CollectFees` instruction builder. 37 func NewCollectFeesInstructionBuilder() *CollectFees { 38 nd := &CollectFees{ 39 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 9), 40 } 41 return nd 42 } 43 44 // SetWhirlpoolAccount sets the "whirlpool" account. 45 func (inst *CollectFees) SetWhirlpoolAccount(whirlpool ag_solanago.PublicKey) *CollectFees { 46 inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpool) 47 return inst 48 } 49 50 // GetWhirlpoolAccount gets the "whirlpool" account. 51 func (inst *CollectFees) GetWhirlpoolAccount() *ag_solanago.AccountMeta { 52 return inst.AccountMetaSlice.Get(0) 53 } 54 55 // SetPositionAuthorityAccount sets the "positionAuthority" account. 56 func (inst *CollectFees) SetPositionAuthorityAccount(positionAuthority ag_solanago.PublicKey) *CollectFees { 57 inst.AccountMetaSlice[1] = ag_solanago.Meta(positionAuthority).SIGNER() 58 return inst 59 } 60 61 // GetPositionAuthorityAccount gets the "positionAuthority" account. 62 func (inst *CollectFees) GetPositionAuthorityAccount() *ag_solanago.AccountMeta { 63 return inst.AccountMetaSlice.Get(1) 64 } 65 66 // SetPositionAccount sets the "position" account. 67 func (inst *CollectFees) SetPositionAccount(position ag_solanago.PublicKey) *CollectFees { 68 inst.AccountMetaSlice[2] = ag_solanago.Meta(position).WRITE() 69 return inst 70 } 71 72 // GetPositionAccount gets the "position" account. 73 func (inst *CollectFees) GetPositionAccount() *ag_solanago.AccountMeta { 74 return inst.AccountMetaSlice.Get(2) 75 } 76 77 // SetPositionTokenAccountAccount sets the "positionTokenAccount" account. 78 func (inst *CollectFees) SetPositionTokenAccountAccount(positionTokenAccount ag_solanago.PublicKey) *CollectFees { 79 inst.AccountMetaSlice[3] = ag_solanago.Meta(positionTokenAccount) 80 return inst 81 } 82 83 // GetPositionTokenAccountAccount gets the "positionTokenAccount" account. 84 func (inst *CollectFees) GetPositionTokenAccountAccount() *ag_solanago.AccountMeta { 85 return inst.AccountMetaSlice.Get(3) 86 } 87 88 // SetTokenOwnerAccountAAccount sets the "tokenOwnerAccountA" account. 89 func (inst *CollectFees) SetTokenOwnerAccountAAccount(tokenOwnerAccountA ag_solanago.PublicKey) *CollectFees { 90 inst.AccountMetaSlice[4] = ag_solanago.Meta(tokenOwnerAccountA).WRITE() 91 return inst 92 } 93 94 // GetTokenOwnerAccountAAccount gets the "tokenOwnerAccountA" account. 95 func (inst *CollectFees) GetTokenOwnerAccountAAccount() *ag_solanago.AccountMeta { 96 return inst.AccountMetaSlice.Get(4) 97 } 98 99 // SetTokenVaultAAccount sets the "tokenVaultA" account. 100 func (inst *CollectFees) SetTokenVaultAAccount(tokenVaultA ag_solanago.PublicKey) *CollectFees { 101 inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenVaultA).WRITE() 102 return inst 103 } 104 105 // GetTokenVaultAAccount gets the "tokenVaultA" account. 106 func (inst *CollectFees) GetTokenVaultAAccount() *ag_solanago.AccountMeta { 107 return inst.AccountMetaSlice.Get(5) 108 } 109 110 // SetTokenOwnerAccountBAccount sets the "tokenOwnerAccountB" account. 111 func (inst *CollectFees) SetTokenOwnerAccountBAccount(tokenOwnerAccountB ag_solanago.PublicKey) *CollectFees { 112 inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenOwnerAccountB).WRITE() 113 return inst 114 } 115 116 // GetTokenOwnerAccountBAccount gets the "tokenOwnerAccountB" account. 117 func (inst *CollectFees) GetTokenOwnerAccountBAccount() *ag_solanago.AccountMeta { 118 return inst.AccountMetaSlice.Get(6) 119 } 120 121 // SetTokenVaultBAccount sets the "tokenVaultB" account. 122 func (inst *CollectFees) SetTokenVaultBAccount(tokenVaultB ag_solanago.PublicKey) *CollectFees { 123 inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenVaultB).WRITE() 124 return inst 125 } 126 127 // GetTokenVaultBAccount gets the "tokenVaultB" account. 128 func (inst *CollectFees) GetTokenVaultBAccount() *ag_solanago.AccountMeta { 129 return inst.AccountMetaSlice.Get(7) 130 } 131 132 // SetTokenProgramAccount sets the "tokenProgram" account. 133 func (inst *CollectFees) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CollectFees { 134 inst.AccountMetaSlice[8] = ag_solanago.Meta(tokenProgram) 135 return inst 136 } 137 138 // GetTokenProgramAccount gets the "tokenProgram" account. 139 func (inst *CollectFees) GetTokenProgramAccount() *ag_solanago.AccountMeta { 140 return inst.AccountMetaSlice.Get(8) 141 } 142 143 func (inst CollectFees) Build() *Instruction { 144 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 145 Impl: inst, 146 TypeID: Instruction_CollectFees, 147 }} 148 } 149 150 // ValidateAndBuild validates the instruction parameters and accounts; 151 // if there is a validation error, it returns the error. 152 // Otherwise, it builds and returns the instruction. 153 func (inst CollectFees) ValidateAndBuild() (*Instruction, error) { 154 if err := inst.Validate(); err != nil { 155 return nil, err 156 } 157 return inst.Build(), nil 158 } 159 160 func (inst *CollectFees) Validate() error { 161 // Check whether all (required) accounts are set: 162 { 163 if inst.AccountMetaSlice[0] == nil { 164 return errors.New("accounts.Whirlpool is not set") 165 } 166 if inst.AccountMetaSlice[1] == nil { 167 return errors.New("accounts.PositionAuthority is not set") 168 } 169 if inst.AccountMetaSlice[2] == nil { 170 return errors.New("accounts.Position is not set") 171 } 172 if inst.AccountMetaSlice[3] == nil { 173 return errors.New("accounts.PositionTokenAccount is not set") 174 } 175 if inst.AccountMetaSlice[4] == nil { 176 return errors.New("accounts.TokenOwnerAccountA is not set") 177 } 178 if inst.AccountMetaSlice[5] == nil { 179 return errors.New("accounts.TokenVaultA is not set") 180 } 181 if inst.AccountMetaSlice[6] == nil { 182 return errors.New("accounts.TokenOwnerAccountB is not set") 183 } 184 if inst.AccountMetaSlice[7] == nil { 185 return errors.New("accounts.TokenVaultB is not set") 186 } 187 if inst.AccountMetaSlice[8] == nil { 188 return errors.New("accounts.TokenProgram is not set") 189 } 190 } 191 return nil 192 } 193 194 func (inst *CollectFees) EncodeToTree(parent ag_treeout.Branches) { 195 parent.Child(ag_format.Program(ProgramName, ProgramID)). 196 // 197 ParentFunc(func(programBranch ag_treeout.Branches) { 198 programBranch.Child(ag_format.Instruction("CollectFees")). 199 // 200 ParentFunc(func(instructionBranch ag_treeout.Branches) { 201 202 // Parameters of the instruction: 203 instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) 204 205 // Accounts of the instruction: 206 instructionBranch.Child("Accounts[len=9]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 207 accountsBranch.Child(ag_format.Meta(" whirlpool", inst.AccountMetaSlice.Get(0))) 208 accountsBranch.Child(ag_format.Meta(" positionAuthority", inst.AccountMetaSlice.Get(1))) 209 accountsBranch.Child(ag_format.Meta(" position", inst.AccountMetaSlice.Get(2))) 210 accountsBranch.Child(ag_format.Meta(" positionToken", inst.AccountMetaSlice.Get(3))) 211 accountsBranch.Child(ag_format.Meta("tokenOwnerAccountA", inst.AccountMetaSlice.Get(4))) 212 accountsBranch.Child(ag_format.Meta(" tokenVaultA", inst.AccountMetaSlice.Get(5))) 213 accountsBranch.Child(ag_format.Meta("tokenOwnerAccountB", inst.AccountMetaSlice.Get(6))) 214 accountsBranch.Child(ag_format.Meta(" tokenVaultB", inst.AccountMetaSlice.Get(7))) 215 accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(8))) 216 }) 217 }) 218 }) 219 } 220 221 func (obj CollectFees) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 222 return nil 223 } 224 func (obj *CollectFees) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 225 return nil 226 } 227 228 // NewCollectFeesInstruction declares a new CollectFees instruction with the provided parameters and accounts. 229 func NewCollectFeesInstruction( 230 // Accounts: 231 whirlpool ag_solanago.PublicKey, 232 positionAuthority ag_solanago.PublicKey, 233 position ag_solanago.PublicKey, 234 positionTokenAccount ag_solanago.PublicKey, 235 tokenOwnerAccountA ag_solanago.PublicKey, 236 tokenVaultA ag_solanago.PublicKey, 237 tokenOwnerAccountB ag_solanago.PublicKey, 238 tokenVaultB ag_solanago.PublicKey, 239 tokenProgram ag_solanago.PublicKey) *CollectFees { 240 return NewCollectFeesInstructionBuilder(). 241 SetWhirlpoolAccount(whirlpool). 242 SetPositionAuthorityAccount(positionAuthority). 243 SetPositionAccount(position). 244 SetPositionTokenAccountAccount(positionTokenAccount). 245 SetTokenOwnerAccountAAccount(tokenOwnerAccountA). 246 SetTokenVaultAAccount(tokenVaultA). 247 SetTokenOwnerAccountBAccount(tokenOwnerAccountB). 248 SetTokenVaultBAccount(tokenVaultB). 249 SetTokenProgramAccount(tokenProgram) 250 }