github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/SetRewardEmissions.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 // SetRewardEmissions is the `setRewardEmissions` instruction. 14 type SetRewardEmissions struct { 15 RewardIndex *uint8 16 EmissionsPerSecondX64 *ag_binary.Uint128 17 18 // [0] = [WRITE] whirlpool 19 // 20 // [1] = [SIGNER] rewardAuthority 21 // 22 // [2] = [] rewardVault 23 ag_solanago.AccountMetaSlice `bin:"-"` 24 } 25 26 // NewSetRewardEmissionsInstructionBuilder creates a new `SetRewardEmissions` instruction builder. 27 func NewSetRewardEmissionsInstructionBuilder() *SetRewardEmissions { 28 nd := &SetRewardEmissions{ 29 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), 30 } 31 return nd 32 } 33 34 // SetRewardIndex sets the "rewardIndex" parameter. 35 func (inst *SetRewardEmissions) SetRewardIndex(rewardIndex uint8) *SetRewardEmissions { 36 inst.RewardIndex = &rewardIndex 37 return inst 38 } 39 40 // SetEmissionsPerSecondX64 sets the "emissionsPerSecondX64" parameter. 41 func (inst *SetRewardEmissions) SetEmissionsPerSecondX64(emissionsPerSecondX64 ag_binary.Uint128) *SetRewardEmissions { 42 inst.EmissionsPerSecondX64 = &emissionsPerSecondX64 43 return inst 44 } 45 46 // SetWhirlpoolAccount sets the "whirlpool" account. 47 func (inst *SetRewardEmissions) SetWhirlpoolAccount(whirlpool ag_solanago.PublicKey) *SetRewardEmissions { 48 inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpool).WRITE() 49 return inst 50 } 51 52 // GetWhirlpoolAccount gets the "whirlpool" account. 53 func (inst *SetRewardEmissions) GetWhirlpoolAccount() *ag_solanago.AccountMeta { 54 return inst.AccountMetaSlice.Get(0) 55 } 56 57 // SetRewardAuthorityAccount sets the "rewardAuthority" account. 58 func (inst *SetRewardEmissions) SetRewardAuthorityAccount(rewardAuthority ag_solanago.PublicKey) *SetRewardEmissions { 59 inst.AccountMetaSlice[1] = ag_solanago.Meta(rewardAuthority).SIGNER() 60 return inst 61 } 62 63 // GetRewardAuthorityAccount gets the "rewardAuthority" account. 64 func (inst *SetRewardEmissions) GetRewardAuthorityAccount() *ag_solanago.AccountMeta { 65 return inst.AccountMetaSlice.Get(1) 66 } 67 68 // SetRewardVaultAccount sets the "rewardVault" account. 69 func (inst *SetRewardEmissions) SetRewardVaultAccount(rewardVault ag_solanago.PublicKey) *SetRewardEmissions { 70 inst.AccountMetaSlice[2] = ag_solanago.Meta(rewardVault) 71 return inst 72 } 73 74 // GetRewardVaultAccount gets the "rewardVault" account. 75 func (inst *SetRewardEmissions) GetRewardVaultAccount() *ag_solanago.AccountMeta { 76 return inst.AccountMetaSlice.Get(2) 77 } 78 79 func (inst SetRewardEmissions) Build() *Instruction { 80 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 81 Impl: inst, 82 TypeID: Instruction_SetRewardEmissions, 83 }} 84 } 85 86 // ValidateAndBuild validates the instruction parameters and accounts; 87 // if there is a validation error, it returns the error. 88 // Otherwise, it builds and returns the instruction. 89 func (inst SetRewardEmissions) ValidateAndBuild() (*Instruction, error) { 90 if err := inst.Validate(); err != nil { 91 return nil, err 92 } 93 return inst.Build(), nil 94 } 95 96 func (inst *SetRewardEmissions) Validate() error { 97 // Check whether all (required) parameters are set: 98 { 99 if inst.RewardIndex == nil { 100 return errors.New("RewardIndex parameter is not set") 101 } 102 if inst.EmissionsPerSecondX64 == nil { 103 return errors.New("EmissionsPerSecondX64 parameter is not set") 104 } 105 } 106 107 // Check whether all (required) accounts are set: 108 { 109 if inst.AccountMetaSlice[0] == nil { 110 return errors.New("accounts.Whirlpool is not set") 111 } 112 if inst.AccountMetaSlice[1] == nil { 113 return errors.New("accounts.RewardAuthority is not set") 114 } 115 if inst.AccountMetaSlice[2] == nil { 116 return errors.New("accounts.RewardVault is not set") 117 } 118 } 119 return nil 120 } 121 122 func (inst *SetRewardEmissions) EncodeToTree(parent ag_treeout.Branches) { 123 parent.Child(ag_format.Program(ProgramName, ProgramID)). 124 // 125 ParentFunc(func(programBranch ag_treeout.Branches) { 126 programBranch.Child(ag_format.Instruction("SetRewardEmissions")). 127 // 128 ParentFunc(func(instructionBranch ag_treeout.Branches) { 129 130 // Parameters of the instruction: 131 instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { 132 paramsBranch.Child(ag_format.Param(" RewardIndex", *inst.RewardIndex)) 133 paramsBranch.Child(ag_format.Param("EmissionsPerSecondX64", *inst.EmissionsPerSecondX64)) 134 }) 135 136 // Accounts of the instruction: 137 instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 138 accountsBranch.Child(ag_format.Meta(" whirlpool", inst.AccountMetaSlice.Get(0))) 139 accountsBranch.Child(ag_format.Meta("rewardAuthority", inst.AccountMetaSlice.Get(1))) 140 accountsBranch.Child(ag_format.Meta(" rewardVault", inst.AccountMetaSlice.Get(2))) 141 }) 142 }) 143 }) 144 } 145 146 func (obj SetRewardEmissions) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 147 // Serialize `RewardIndex` param: 148 err = encoder.Encode(obj.RewardIndex) 149 if err != nil { 150 return err 151 } 152 // Serialize `EmissionsPerSecondX64` param: 153 err = encoder.Encode(obj.EmissionsPerSecondX64) 154 if err != nil { 155 return err 156 } 157 return nil 158 } 159 func (obj *SetRewardEmissions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 160 // Deserialize `RewardIndex`: 161 err = decoder.Decode(&obj.RewardIndex) 162 if err != nil { 163 return err 164 } 165 // Deserialize `EmissionsPerSecondX64`: 166 err = decoder.Decode(&obj.EmissionsPerSecondX64) 167 if err != nil { 168 return err 169 } 170 return nil 171 } 172 173 // NewSetRewardEmissionsInstruction declares a new SetRewardEmissions instruction with the provided parameters and accounts. 174 func NewSetRewardEmissionsInstruction( 175 // Parameters: 176 rewardIndex uint8, 177 emissionsPerSecondX64 ag_binary.Uint128, 178 // Accounts: 179 whirlpool ag_solanago.PublicKey, 180 rewardAuthority ag_solanago.PublicKey, 181 rewardVault ag_solanago.PublicKey) *SetRewardEmissions { 182 return NewSetRewardEmissionsInstructionBuilder(). 183 SetRewardIndex(rewardIndex). 184 SetEmissionsPerSecondX64(emissionsPerSecondX64). 185 SetWhirlpoolAccount(whirlpool). 186 SetRewardAuthorityAccount(rewardAuthority). 187 SetRewardVaultAccount(rewardVault) 188 }