github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/instructions.go (about)

     1  // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT.
     2  
     3  package whirlpool
     4  
     5  import (
     6  	"bytes"
     7  	"fmt"
     8  	ag_spew "github.com/davecgh/go-spew/spew"
     9  	ag_binary "github.com/gagliardetto/binary"
    10  	ag_solanago "github.com/gagliardetto/solana-go"
    11  	ag_text "github.com/gagliardetto/solana-go/text"
    12  	ag_treeout "github.com/gagliardetto/treeout"
    13  )
    14  
    15  var ProgramID ag_solanago.PublicKey
    16  
    17  func SetProgramID(pubkey ag_solanago.PublicKey) {
    18  	ProgramID = pubkey
    19  	ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction)
    20  }
    21  
    22  const ProgramName = "Whirlpool"
    23  
    24  func init() {
    25  	if !ProgramID.IsZero() {
    26  		ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction)
    27  	}
    28  }
    29  
    30  var (
    31  	Instruction_InitializeConfig = ag_binary.TypeID([8]byte{208, 127, 21, 1, 194, 190, 196, 70})
    32  
    33  	Instruction_InitializePool = ag_binary.TypeID([8]byte{95, 180, 10, 172, 84, 174, 232, 40})
    34  
    35  	Instruction_InitializeTickArray = ag_binary.TypeID([8]byte{11, 188, 193, 214, 141, 91, 149, 184})
    36  
    37  	Instruction_InitializeFeeTier = ag_binary.TypeID([8]byte{183, 74, 156, 160, 112, 2, 42, 30})
    38  
    39  	Instruction_InitializeReward = ag_binary.TypeID([8]byte{95, 135, 192, 196, 242, 129, 230, 68})
    40  
    41  	Instruction_SetRewardEmissions = ag_binary.TypeID([8]byte{13, 197, 86, 168, 109, 176, 27, 244})
    42  
    43  	Instruction_OpenPosition = ag_binary.TypeID([8]byte{135, 128, 47, 77, 15, 152, 240, 49})
    44  
    45  	Instruction_OpenPositionWithMetadata = ag_binary.TypeID([8]byte{242, 29, 134, 48, 58, 110, 14, 60})
    46  
    47  	Instruction_IncreaseLiquidity = ag_binary.TypeID([8]byte{46, 156, 243, 118, 13, 205, 251, 178})
    48  
    49  	Instruction_DecreaseLiquidity = ag_binary.TypeID([8]byte{160, 38, 208, 111, 104, 91, 44, 1})
    50  
    51  	Instruction_UpdateFeesAndRewards = ag_binary.TypeID([8]byte{154, 230, 250, 13, 236, 209, 75, 223})
    52  
    53  	Instruction_CollectFees = ag_binary.TypeID([8]byte{164, 152, 207, 99, 30, 186, 19, 182})
    54  
    55  	Instruction_CollectReward = ag_binary.TypeID([8]byte{70, 5, 132, 87, 86, 235, 177, 34})
    56  
    57  	Instruction_CollectProtocolFees = ag_binary.TypeID([8]byte{22, 67, 23, 98, 150, 178, 70, 220})
    58  
    59  	Instruction_Swap = ag_binary.TypeID([8]byte{248, 198, 158, 145, 225, 117, 135, 200})
    60  
    61  	Instruction_ClosePosition = ag_binary.TypeID([8]byte{123, 134, 81, 0, 49, 68, 98, 98})
    62  
    63  	Instruction_SetDefaultFeeRate = ag_binary.TypeID([8]byte{118, 215, 214, 157, 182, 229, 208, 228})
    64  
    65  	Instruction_SetDefaultProtocolFeeRate = ag_binary.TypeID([8]byte{107, 205, 249, 226, 151, 35, 86, 0})
    66  
    67  	Instruction_SetFeeRate = ag_binary.TypeID([8]byte{53, 243, 137, 65, 8, 140, 158, 6})
    68  
    69  	Instruction_SetProtocolFeeRate = ag_binary.TypeID([8]byte{95, 7, 4, 50, 154, 79, 156, 131})
    70  
    71  	Instruction_SetFeeAuthority = ag_binary.TypeID([8]byte{31, 1, 50, 87, 237, 101, 97, 132})
    72  
    73  	Instruction_SetCollectProtocolFeesAuthority = ag_binary.TypeID([8]byte{34, 150, 93, 244, 139, 225, 233, 67})
    74  
    75  	Instruction_SetRewardAuthority = ag_binary.TypeID([8]byte{34, 39, 183, 252, 83, 28, 85, 127})
    76  
    77  	Instruction_SetRewardAuthorityBySuperAuthority = ag_binary.TypeID([8]byte{240, 154, 201, 198, 148, 93, 56, 25})
    78  
    79  	Instruction_SetRewardEmissionsSuperAuthority = ag_binary.TypeID([8]byte{207, 5, 200, 209, 122, 56, 82, 183})
    80  )
    81  
    82  // InstructionIDToName returns the name of the instruction given its ID.
    83  func InstructionIDToName(id ag_binary.TypeID) string {
    84  	switch id {
    85  	case Instruction_InitializeConfig:
    86  		return "InitializeConfig"
    87  	case Instruction_InitializePool:
    88  		return "InitializePool"
    89  	case Instruction_InitializeTickArray:
    90  		return "InitializeTickArray"
    91  	case Instruction_InitializeFeeTier:
    92  		return "InitializeFeeTier"
    93  	case Instruction_InitializeReward:
    94  		return "InitializeReward"
    95  	case Instruction_SetRewardEmissions:
    96  		return "SetRewardEmissions"
    97  	case Instruction_OpenPosition:
    98  		return "OpenPosition"
    99  	case Instruction_OpenPositionWithMetadata:
   100  		return "OpenPositionWithMetadata"
   101  	case Instruction_IncreaseLiquidity:
   102  		return "IncreaseLiquidity"
   103  	case Instruction_DecreaseLiquidity:
   104  		return "DecreaseLiquidity"
   105  	case Instruction_UpdateFeesAndRewards:
   106  		return "UpdateFeesAndRewards"
   107  	case Instruction_CollectFees:
   108  		return "CollectFees"
   109  	case Instruction_CollectReward:
   110  		return "CollectReward"
   111  	case Instruction_CollectProtocolFees:
   112  		return "CollectProtocolFees"
   113  	case Instruction_Swap:
   114  		return "Swap"
   115  	case Instruction_ClosePosition:
   116  		return "ClosePosition"
   117  	case Instruction_SetDefaultFeeRate:
   118  		return "SetDefaultFeeRate"
   119  	case Instruction_SetDefaultProtocolFeeRate:
   120  		return "SetDefaultProtocolFeeRate"
   121  	case Instruction_SetFeeRate:
   122  		return "SetFeeRate"
   123  	case Instruction_SetProtocolFeeRate:
   124  		return "SetProtocolFeeRate"
   125  	case Instruction_SetFeeAuthority:
   126  		return "SetFeeAuthority"
   127  	case Instruction_SetCollectProtocolFeesAuthority:
   128  		return "SetCollectProtocolFeesAuthority"
   129  	case Instruction_SetRewardAuthority:
   130  		return "SetRewardAuthority"
   131  	case Instruction_SetRewardAuthorityBySuperAuthority:
   132  		return "SetRewardAuthorityBySuperAuthority"
   133  	case Instruction_SetRewardEmissionsSuperAuthority:
   134  		return "SetRewardEmissionsSuperAuthority"
   135  	default:
   136  		return ""
   137  	}
   138  }
   139  
   140  type Instruction struct {
   141  	ag_binary.BaseVariant
   142  }
   143  
   144  func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) {
   145  	if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok {
   146  		enToTree.EncodeToTree(parent)
   147  	} else {
   148  		parent.Child(ag_spew.Sdump(inst))
   149  	}
   150  }
   151  
   152  var InstructionImplDef = ag_binary.NewVariantDefinition(
   153  	ag_binary.AnchorTypeIDEncoding,
   154  	[]ag_binary.VariantType{
   155  		{
   156  			Name:"initialize_config", Type: (*InitializeConfig)(nil),
   157  		},
   158  		{
   159  			Name:"initialize_pool", Type:(*InitializePool)(nil),
   160  		},
   161  		{
   162  			Name:"initialize_tick_array", Type:(*InitializeTickArray)(nil),
   163  		},
   164  		{
   165  			Name:"initialize_fee_tier", Type:(*InitializeFeeTier)(nil),
   166  		},
   167  		{
   168  			Name:"initialize_reward", Type:(*InitializeReward)(nil),
   169  		},
   170  		{
   171  			Name:"set_reward_emissions", Type:(*SetRewardEmissions)(nil),
   172  		},
   173  		{
   174  			Name:"open_position", Type:(*OpenPosition)(nil),
   175  		},
   176  		{
   177  			Name:"open_position_with_metadata",Type: (*OpenPositionWithMetadata)(nil),
   178  		},
   179  		{
   180  			Name:"increase_liquidity",Type: (*IncreaseLiquidity)(nil),
   181  		},
   182  		{
   183  			Name:"decrease_liquidity", Type:(*DecreaseLiquidity)(nil),
   184  		},
   185  		{
   186  			Name:"update_fees_and_rewards", Type:(*UpdateFeesAndRewards)(nil),
   187  		},
   188  		{
   189  			Name:"collect_fees",Type: (*CollectFees)(nil),
   190  		},
   191  		{
   192  			Name:"collect_reward",Type: (*CollectReward)(nil),
   193  		},
   194  		{
   195  			Name:"collect_protocol_fees", Type:(*CollectProtocolFees)(nil),
   196  		},
   197  		{
   198  			Name:"swap", Type:(*Swap)(nil),
   199  		},
   200  		{
   201  			Name:"close_position", Type:(*ClosePosition)(nil),
   202  		},
   203  		{
   204  			Name:"set_default_fee_rate", Type:(*SetDefaultFeeRate)(nil),
   205  		},
   206  		{
   207  			Name:"set_default_protocol_fee_rate",Type: (*SetDefaultProtocolFeeRate)(nil),
   208  		},
   209  		{
   210  			Name:"set_fee_rate", Type:(*SetFeeRate)(nil),
   211  		},
   212  		{
   213  			Name:"set_protocol_fee_rate", Type:(*SetProtocolFeeRate)(nil),
   214  		},
   215  		{
   216  			Name:"set_fee_authority", Type:(*SetFeeAuthority)(nil),
   217  		},
   218  		{
   219  			Name:"set_collect_protocol_fees_authority",Type: (*SetCollectProtocolFeesAuthority)(nil),
   220  		},
   221  		{
   222  			Name:"set_reward_authority", Type:(*SetRewardAuthority)(nil),
   223  		},
   224  		{
   225  			Name:"set_reward_authority_by_super_authority", Type:(*SetRewardAuthorityBySuperAuthority)(nil),
   226  		},
   227  		{
   228  			Name:"set_reward_emissions_super_authority", Type:(*SetRewardEmissionsSuperAuthority)(nil),
   229  		},
   230  	},
   231  )
   232  
   233  func (inst *Instruction) ProgramID() ag_solanago.PublicKey {
   234  	return ProgramID
   235  }
   236  
   237  func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) {
   238  	return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts()
   239  }
   240  
   241  func (inst *Instruction) Data() ([]byte, error) {
   242  	buf := new(bytes.Buffer)
   243  	if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil {
   244  		return nil, fmt.Errorf("unable to encode instruction: %w", err)
   245  	}
   246  	return buf.Bytes(), nil
   247  }
   248  
   249  func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error {
   250  	return encoder.Encode(inst.Impl, option)
   251  }
   252  
   253  func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error {
   254  	return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef)
   255  }
   256  
   257  func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error {
   258  	err := encoder.WriteBytes(inst.TypeID.Bytes(), false)
   259  	if err != nil {
   260  		return fmt.Errorf("unable to write variant type: %w", err)
   261  	}
   262  	return encoder.Encode(inst.Impl)
   263  }
   264  
   265  func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) {
   266  	inst, err := DecodeInstruction(accounts, data)
   267  	if err != nil {
   268  		return nil, err
   269  	}
   270  	return inst, nil
   271  }
   272  
   273  func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) {
   274  	inst := new(Instruction)
   275  	if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil {
   276  		return nil, fmt.Errorf("unable to decode instruction: %w", err)
   277  	}
   278  	if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok {
   279  		err := v.SetAccounts(accounts)
   280  		if err != nil {
   281  			return nil, fmt.Errorf("unable to set accounts for instruction: %w", err)
   282  		}
   283  	}
   284  	return inst, nil
   285  }