github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/UpdateFeesAndRewards.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  // UpdateFeesAndRewards is the `updateFeesAndRewards` instruction.
    14  type UpdateFeesAndRewards struct {
    15  
    16  	// [0] = [WRITE] whirlpool
    17  	//
    18  	// [1] = [WRITE] position
    19  	//
    20  	// [2] = [] tickArrayLower
    21  	//
    22  	// [3] = [] tickArrayUpper
    23  	ag_solanago.AccountMetaSlice `bin:"-"`
    24  }
    25  
    26  // NewUpdateFeesAndRewardsInstructionBuilder creates a new `UpdateFeesAndRewards` instruction builder.
    27  func NewUpdateFeesAndRewardsInstructionBuilder() *UpdateFeesAndRewards {
    28  	nd := &UpdateFeesAndRewards{
    29  		AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4),
    30  	}
    31  	return nd
    32  }
    33  
    34  // SetWhirlpoolAccount sets the "whirlpool" account.
    35  func (inst *UpdateFeesAndRewards) SetWhirlpoolAccount(whirlpool ag_solanago.PublicKey) *UpdateFeesAndRewards {
    36  	inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpool).WRITE()
    37  	return inst
    38  }
    39  
    40  // GetWhirlpoolAccount gets the "whirlpool" account.
    41  func (inst *UpdateFeesAndRewards) GetWhirlpoolAccount() *ag_solanago.AccountMeta {
    42  	return inst.AccountMetaSlice.Get(0)
    43  }
    44  
    45  // SetPositionAccount sets the "position" account.
    46  func (inst *UpdateFeesAndRewards) SetPositionAccount(position ag_solanago.PublicKey) *UpdateFeesAndRewards {
    47  	inst.AccountMetaSlice[1] = ag_solanago.Meta(position).WRITE()
    48  	return inst
    49  }
    50  
    51  // GetPositionAccount gets the "position" account.
    52  func (inst *UpdateFeesAndRewards) GetPositionAccount() *ag_solanago.AccountMeta {
    53  	return inst.AccountMetaSlice.Get(1)
    54  }
    55  
    56  // SetTickArrayLowerAccount sets the "tickArrayLower" account.
    57  func (inst *UpdateFeesAndRewards) SetTickArrayLowerAccount(tickArrayLower ag_solanago.PublicKey) *UpdateFeesAndRewards {
    58  	inst.AccountMetaSlice[2] = ag_solanago.Meta(tickArrayLower)
    59  	return inst
    60  }
    61  
    62  // GetTickArrayLowerAccount gets the "tickArrayLower" account.
    63  func (inst *UpdateFeesAndRewards) GetTickArrayLowerAccount() *ag_solanago.AccountMeta {
    64  	return inst.AccountMetaSlice.Get(2)
    65  }
    66  
    67  // SetTickArrayUpperAccount sets the "tickArrayUpper" account.
    68  func (inst *UpdateFeesAndRewards) SetTickArrayUpperAccount(tickArrayUpper ag_solanago.PublicKey) *UpdateFeesAndRewards {
    69  	inst.AccountMetaSlice[3] = ag_solanago.Meta(tickArrayUpper)
    70  	return inst
    71  }
    72  
    73  // GetTickArrayUpperAccount gets the "tickArrayUpper" account.
    74  func (inst *UpdateFeesAndRewards) GetTickArrayUpperAccount() *ag_solanago.AccountMeta {
    75  	return inst.AccountMetaSlice.Get(3)
    76  }
    77  
    78  func (inst UpdateFeesAndRewards) Build() *Instruction {
    79  	return &Instruction{BaseVariant: ag_binary.BaseVariant{
    80  		Impl:   inst,
    81  		TypeID: Instruction_UpdateFeesAndRewards,
    82  	}}
    83  }
    84  
    85  // ValidateAndBuild validates the instruction parameters and accounts;
    86  // if there is a validation error, it returns the error.
    87  // Otherwise, it builds and returns the instruction.
    88  func (inst UpdateFeesAndRewards) ValidateAndBuild() (*Instruction, error) {
    89  	if err := inst.Validate(); err != nil {
    90  		return nil, err
    91  	}
    92  	return inst.Build(), nil
    93  }
    94  
    95  func (inst *UpdateFeesAndRewards) Validate() error {
    96  	// Check whether all (required) accounts are set:
    97  	{
    98  		if inst.AccountMetaSlice[0] == nil {
    99  			return errors.New("accounts.Whirlpool is not set")
   100  		}
   101  		if inst.AccountMetaSlice[1] == nil {
   102  			return errors.New("accounts.Position is not set")
   103  		}
   104  		if inst.AccountMetaSlice[2] == nil {
   105  			return errors.New("accounts.TickArrayLower is not set")
   106  		}
   107  		if inst.AccountMetaSlice[3] == nil {
   108  			return errors.New("accounts.TickArrayUpper is not set")
   109  		}
   110  	}
   111  	return nil
   112  }
   113  
   114  func (inst *UpdateFeesAndRewards) EncodeToTree(parent ag_treeout.Branches) {
   115  	parent.Child(ag_format.Program(ProgramName, ProgramID)).
   116  		//
   117  		ParentFunc(func(programBranch ag_treeout.Branches) {
   118  			programBranch.Child(ag_format.Instruction("UpdateFeesAndRewards")).
   119  				//
   120  				ParentFunc(func(instructionBranch ag_treeout.Branches) {
   121  
   122  					// Parameters of the instruction:
   123  					instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {})
   124  
   125  					// Accounts of the instruction:
   126  					instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) {
   127  						accountsBranch.Child(ag_format.Meta("     whirlpool", inst.AccountMetaSlice.Get(0)))
   128  						accountsBranch.Child(ag_format.Meta("      position", inst.AccountMetaSlice.Get(1)))
   129  						accountsBranch.Child(ag_format.Meta("tickArrayLower", inst.AccountMetaSlice.Get(2)))
   130  						accountsBranch.Child(ag_format.Meta("tickArrayUpper", inst.AccountMetaSlice.Get(3)))
   131  					})
   132  				})
   133  		})
   134  }
   135  
   136  func (obj UpdateFeesAndRewards) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
   137  	return nil
   138  }
   139  func (obj *UpdateFeesAndRewards) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
   140  	return nil
   141  }
   142  
   143  // NewUpdateFeesAndRewardsInstruction declares a new UpdateFeesAndRewards instruction with the provided parameters and accounts.
   144  func NewUpdateFeesAndRewardsInstruction(
   145  	// Accounts:
   146  	whirlpool ag_solanago.PublicKey,
   147  	position ag_solanago.PublicKey,
   148  	tickArrayLower ag_solanago.PublicKey,
   149  	tickArrayUpper ag_solanago.PublicKey) *UpdateFeesAndRewards {
   150  	return NewUpdateFeesAndRewardsInstructionBuilder().
   151  		SetWhirlpoolAccount(whirlpool).
   152  		SetPositionAccount(position).
   153  		SetTickArrayLowerAccount(tickArrayLower).
   154  		SetTickArrayUpperAccount(tickArrayUpper)
   155  }