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