// Code generated by https://github.com/daog1/solana-anchor-go. DO NOT EDIT.

package pump

import (
	"errors"
	ag_binary "github.com/gagliardetto/binary"
	ag_solanago "github.com/gagliardetto/solana-go"
	ag_format "github.com/gagliardetto/solana-go/text/format"
	ag_treeout "github.com/gagliardetto/treeout"
)

// Migrates liquidity to pump_amm if the bonding curve is complete
type Migrate struct {

	// [0] = [] global
	//
	// [1] = [WRITE] withdraw_authority
	//
	// [2] = [] mint
	//
	// [3] = [WRITE] bonding_curve
	//
	// [4] = [WRITE] associated_bonding_curve
	//
	// [5] = [SIGNER] user
	//
	// [6] = [] system_program
	//
	// [7] = [] token_program
	//
	// [8] = [] pump_amm
	//
	// [9] = [WRITE] pool
	//
	// [10] = [WRITE] pool_authority
	//
	// [11] = [WRITE] pool_authority_mint_account
	//
	// [12] = [WRITE] pool_authority_wsol_account
	//
	// [13] = [] amm_global_config
	//
	// [14] = [] wsol_mint
	//
	// [15] = [WRITE] lp_mint
	//
	// [16] = [WRITE] user_pool_token_account
	//
	// [17] = [WRITE] pool_base_token_account
	//
	// [18] = [WRITE] pool_quote_token_account
	//
	// [19] = [] token_2022_program
	//
	// [20] = [] associated_token_program
	//
	// [21] = [] pump_amm_event_authority
	//
	// [22] = [] event_authority
	//
	// [23] = [] program
	ag_solanago.AccountMetaSlice `bin:"-"`
}

// NewMigrateInstructionBuilder creates a new `Migrate` instruction builder.
func NewMigrateInstructionBuilder() *Migrate {
	nd := &Migrate{
		AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 24),
	}
	nd.AccountMetaSlice[6] = ag_solanago.Meta(Addresses["11111111111111111111111111111111"])
	nd.AccountMetaSlice[7] = ag_solanago.Meta(Addresses["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"])
	nd.AccountMetaSlice[8] = ag_solanago.Meta(Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"])
	nd.AccountMetaSlice[14] = ag_solanago.Meta(Addresses["So11111111111111111111111111111111111111112"])
	nd.AccountMetaSlice[19] = ag_solanago.Meta(Addresses["TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"])
	nd.AccountMetaSlice[20] = ag_solanago.Meta(Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"])
	return nd
}

// NewMigrateInstructionBuilderExt creates a new `Migrate` instruction builder.
func NewMigrateInstructionBuilderExt(remainingAccounts int) *Migrate {
	nd := &Migrate{
		AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 24+remainingAccounts),
	}
	nd.AccountMetaSlice[6] = ag_solanago.Meta(Addresses["11111111111111111111111111111111"])
	nd.AccountMetaSlice[7] = ag_solanago.Meta(Addresses["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"])
	nd.AccountMetaSlice[8] = ag_solanago.Meta(Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"])
	nd.AccountMetaSlice[14] = ag_solanago.Meta(Addresses["So11111111111111111111111111111111111111112"])
	nd.AccountMetaSlice[19] = ag_solanago.Meta(Addresses["TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"])
	nd.AccountMetaSlice[20] = ag_solanago.Meta(Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"])
	return nd
}

// SetGlobalAccount sets the "global" account.
func (inst *Migrate) SetGlobalAccount(global ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[0] = ag_solanago.Meta(global)
	return inst
}

func (inst *Migrate) findFindGlobalAddress(knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x676c6f62616c
	seeds = append(seeds, []byte{byte(0x67), byte(0x6c), byte(0x6f), byte(0x62), byte(0x61), byte(0x6c)})

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, ProgramID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, ProgramID)
	}
	return
}

// FindGlobalAddressWithBumpSeed calculates Global account address with given seeds and a known bump seed.
func (inst *Migrate) FindGlobalAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindGlobalAddress(bumpSeed)
	return
}

func (inst *Migrate) MustFindGlobalAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindGlobalAddress(bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindGlobalAddress finds Global account address with given seeds.
func (inst *Migrate) FindGlobalAddress() (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindGlobalAddress(0)
	return
}

func (inst *Migrate) MustFindGlobalAddress() (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindGlobalAddress(0)
	if err != nil {
		panic(err)
	}
	return
}

// GetGlobalAccount gets the "global" account.
func (inst *Migrate) GetGlobalAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(0)
}

// SetWithdrawAuthorityAccount sets the "withdraw_authority" account.
func (inst *Migrate) SetWithdrawAuthorityAccount(withdrawAuthority ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[1] = ag_solanago.Meta(withdrawAuthority).WRITE()
	return inst
}

// GetWithdrawAuthorityAccount gets the "withdraw_authority" account.
func (inst *Migrate) GetWithdrawAuthorityAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(1)
}

// SetMintAccount sets the "mint" account.
func (inst *Migrate) SetMintAccount(mint ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[2] = ag_solanago.Meta(mint)
	return inst
}

// GetMintAccount gets the "mint" account.
func (inst *Migrate) GetMintAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(2)
}

// SetBondingCurveAccount sets the "bonding_curve" account.
func (inst *Migrate) SetBondingCurveAccount(bondingCurve ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[3] = ag_solanago.Meta(bondingCurve).WRITE()
	return inst
}

func (inst *Migrate) findFindBondingCurveAddress(mint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x626f6e64696e672d6375727665
	seeds = append(seeds, []byte{byte(0x62), byte(0x6f), byte(0x6e), byte(0x64), byte(0x69), byte(0x6e), byte(0x67), byte(0x2d), byte(0x63), byte(0x75), byte(0x72), byte(0x76), byte(0x65)})
	// path: mint
	seeds = append(seeds, mint.Bytes())

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, ProgramID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, ProgramID)
	}
	return
}

// FindBondingCurveAddressWithBumpSeed calculates BondingCurve account address with given seeds and a known bump seed.
func (inst *Migrate) FindBondingCurveAddressWithBumpSeed(mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindBondingCurveAddress(mint, bumpSeed)
	return
}

func (inst *Migrate) MustFindBondingCurveAddressWithBumpSeed(mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindBondingCurveAddress(mint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindBondingCurveAddress finds BondingCurve account address with given seeds.
func (inst *Migrate) FindBondingCurveAddress(mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindBondingCurveAddress(mint, 0)
	return
}

func (inst *Migrate) MustFindBondingCurveAddress(mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindBondingCurveAddress(mint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetBondingCurveAccount gets the "bonding_curve" account.
func (inst *Migrate) GetBondingCurveAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(3)
}

// SetAssociatedBondingCurveAccount sets the "associated_bonding_curve" account.
func (inst *Migrate) SetAssociatedBondingCurveAccount(associatedBondingCurve ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[4] = ag_solanago.Meta(associatedBondingCurve).WRITE()
	return inst
}

func (inst *Migrate) findFindAssociatedBondingCurveAddress(bondingCurve ag_solanago.PublicKey, mint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: bondingCurve
	seeds = append(seeds, bondingCurve.Bytes())
	// const: 0x06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9
	seeds = append(seeds, []byte{byte(0x6), byte(0xdd), byte(0xf6), byte(0xe1), byte(0xd7), byte(0x65), byte(0xa1), byte(0x93), byte(0xd9), byte(0xcb), byte(0xe1), byte(0x46), byte(0xce), byte(0xeb), byte(0x79), byte(0xac), byte(0x1c), byte(0xb4), byte(0x85), byte(0xed), byte(0x5f), byte(0x5b), byte(0x37), byte(0x91), byte(0x3a), byte(0x8c), byte(0xf5), byte(0x85), byte(0x7e), byte(0xff), byte(0x0), byte(0xa9)})
	// path: mint
	seeds = append(seeds, mint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindAssociatedBondingCurveAddressWithBumpSeed calculates AssociatedBondingCurve account address with given seeds and a known bump seed.
func (inst *Migrate) FindAssociatedBondingCurveAddressWithBumpSeed(bondingCurve ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindAssociatedBondingCurveAddress(bondingCurve, mint, bumpSeed)
	return
}

func (inst *Migrate) MustFindAssociatedBondingCurveAddressWithBumpSeed(bondingCurve ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindAssociatedBondingCurveAddress(bondingCurve, mint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindAssociatedBondingCurveAddress finds AssociatedBondingCurve account address with given seeds.
func (inst *Migrate) FindAssociatedBondingCurveAddress(bondingCurve ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindAssociatedBondingCurveAddress(bondingCurve, mint, 0)
	return
}

func (inst *Migrate) MustFindAssociatedBondingCurveAddress(bondingCurve ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindAssociatedBondingCurveAddress(bondingCurve, mint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetAssociatedBondingCurveAccount gets the "associated_bonding_curve" account.
func (inst *Migrate) GetAssociatedBondingCurveAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(4)
}

// SetUserAccount sets the "user" account.
func (inst *Migrate) SetUserAccount(user ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[5] = ag_solanago.Meta(user).SIGNER()
	return inst
}

// GetUserAccount gets the "user" account.
func (inst *Migrate) GetUserAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(5)
}

// SetSystemProgramAccount sets the "system_program" account.
func (inst *Migrate) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[6] = ag_solanago.Meta(systemProgram)
	return inst
}

// GetSystemProgramAccount gets the "system_program" account.
func (inst *Migrate) GetSystemProgramAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(6)
}

// SetTokenProgramAccount sets the "token_program" account.
func (inst *Migrate) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenProgram)
	return inst
}

// GetTokenProgramAccount gets the "token_program" account.
func (inst *Migrate) GetTokenProgramAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(7)
}

// SetPumpAmmAccount sets the "pump_amm" account.
func (inst *Migrate) SetPumpAmmAccount(pumpAmm ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[8] = ag_solanago.Meta(pumpAmm)
	return inst
}

// GetPumpAmmAccount gets the "pump_amm" account.
func (inst *Migrate) GetPumpAmmAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(8)
}

// SetPoolAccount sets the "pool" account.
func (inst *Migrate) SetPoolAccount(pool ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[9] = ag_solanago.Meta(pool).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolAddress(poolAuthority ag_solanago.PublicKey, mint ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x706f6f6c
	seeds = append(seeds, []byte{byte(0x70), byte(0x6f), byte(0x6f), byte(0x6c)})
	// const: 0x0000
	seeds = append(seeds, []byte{byte(0x0), byte(0x0)})
	// path: poolAuthority
	seeds = append(seeds, poolAuthority.Bytes())
	// path: mint
	seeds = append(seeds, mint.Bytes())
	// path: wsolMint
	seeds = append(seeds, wsolMint.Bytes())

	programID := Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPoolAddressWithBumpSeed calculates Pool account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, mint ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolAddress(poolAuthority, mint, wsolMint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, mint ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAddress(poolAuthority, mint, wsolMint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolAddress finds Pool account address with given seeds.
func (inst *Migrate) FindPoolAddress(poolAuthority ag_solanago.PublicKey, mint ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolAddress(poolAuthority, mint, wsolMint, 0)
	return
}

func (inst *Migrate) MustFindPoolAddress(poolAuthority ag_solanago.PublicKey, mint ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAddress(poolAuthority, mint, wsolMint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolAccount gets the "pool" account.
func (inst *Migrate) GetPoolAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(9)
}

// SetPoolAuthorityAccount sets the "pool_authority" account.
func (inst *Migrate) SetPoolAuthorityAccount(poolAuthority ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[10] = ag_solanago.Meta(poolAuthority).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolAuthorityAddress(mint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x706f6f6c2d617574686f72697479
	seeds = append(seeds, []byte{byte(0x70), byte(0x6f), byte(0x6f), byte(0x6c), byte(0x2d), byte(0x61), byte(0x75), byte(0x74), byte(0x68), byte(0x6f), byte(0x72), byte(0x69), byte(0x74), byte(0x79)})
	// path: mint
	seeds = append(seeds, mint.Bytes())

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, ProgramID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, ProgramID)
	}
	return
}

// FindPoolAuthorityAddressWithBumpSeed calculates PoolAuthority account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolAuthorityAddressWithBumpSeed(mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolAuthorityAddress(mint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolAuthorityAddressWithBumpSeed(mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityAddress(mint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolAuthorityAddress finds PoolAuthority account address with given seeds.
func (inst *Migrate) FindPoolAuthorityAddress(mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolAuthorityAddress(mint, 0)
	return
}

func (inst *Migrate) MustFindPoolAuthorityAddress(mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityAddress(mint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolAuthorityAccount gets the "pool_authority" account.
func (inst *Migrate) GetPoolAuthorityAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(10)
}

// SetPoolAuthorityMintAccountAccount sets the "pool_authority_mint_account" account.
func (inst *Migrate) SetPoolAuthorityMintAccountAccount(poolAuthorityMintAccount ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[11] = ag_solanago.Meta(poolAuthorityMintAccount).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolAuthorityMintAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: poolAuthority
	seeds = append(seeds, poolAuthority.Bytes())
	// path: tokenProgram
	seeds = append(seeds, tokenProgram.Bytes())
	// path: mint
	seeds = append(seeds, mint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPoolAuthorityMintAccountAddressWithBumpSeed calculates PoolAuthorityMintAccount account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolAuthorityMintAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolAuthorityMintAccountAddress(poolAuthority, tokenProgram, mint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolAuthorityMintAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityMintAccountAddress(poolAuthority, tokenProgram, mint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolAuthorityMintAccountAddress finds PoolAuthorityMintAccount account address with given seeds.
func (inst *Migrate) FindPoolAuthorityMintAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolAuthorityMintAccountAddress(poolAuthority, tokenProgram, mint, 0)
	return
}

func (inst *Migrate) MustFindPoolAuthorityMintAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityMintAccountAddress(poolAuthority, tokenProgram, mint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolAuthorityMintAccountAccount gets the "pool_authority_mint_account" account.
func (inst *Migrate) GetPoolAuthorityMintAccountAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(11)
}

// SetPoolAuthorityWsolAccountAccount sets the "pool_authority_wsol_account" account.
func (inst *Migrate) SetPoolAuthorityWsolAccountAccount(poolAuthorityWsolAccount ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[12] = ag_solanago.Meta(poolAuthorityWsolAccount).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolAuthorityWsolAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: poolAuthority
	seeds = append(seeds, poolAuthority.Bytes())
	// path: tokenProgram
	seeds = append(seeds, tokenProgram.Bytes())
	// path: wsolMint
	seeds = append(seeds, wsolMint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPoolAuthorityWsolAccountAddressWithBumpSeed calculates PoolAuthorityWsolAccount account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolAuthorityWsolAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolAuthorityWsolAccountAddress(poolAuthority, tokenProgram, wsolMint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolAuthorityWsolAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityWsolAccountAddress(poolAuthority, tokenProgram, wsolMint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolAuthorityWsolAccountAddress finds PoolAuthorityWsolAccount account address with given seeds.
func (inst *Migrate) FindPoolAuthorityWsolAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolAuthorityWsolAccountAddress(poolAuthority, tokenProgram, wsolMint, 0)
	return
}

func (inst *Migrate) MustFindPoolAuthorityWsolAccountAddress(poolAuthority ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolAuthorityWsolAccountAddress(poolAuthority, tokenProgram, wsolMint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolAuthorityWsolAccountAccount gets the "pool_authority_wsol_account" account.
func (inst *Migrate) GetPoolAuthorityWsolAccountAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(12)
}

// SetAmmGlobalConfigAccount sets the "amm_global_config" account.
func (inst *Migrate) SetAmmGlobalConfigAccount(ammGlobalConfig ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[13] = ag_solanago.Meta(ammGlobalConfig)
	return inst
}

func (inst *Migrate) findFindAmmGlobalConfigAddress(knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x676c6f62616c5f636f6e666967
	seeds = append(seeds, []byte{byte(0x67), byte(0x6c), byte(0x6f), byte(0x62), byte(0x61), byte(0x6c), byte(0x5f), byte(0x63), byte(0x6f), byte(0x6e), byte(0x66), byte(0x69), byte(0x67)})

	programID := Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindAmmGlobalConfigAddressWithBumpSeed calculates AmmGlobalConfig account address with given seeds and a known bump seed.
func (inst *Migrate) FindAmmGlobalConfigAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindAmmGlobalConfigAddress(bumpSeed)
	return
}

func (inst *Migrate) MustFindAmmGlobalConfigAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindAmmGlobalConfigAddress(bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindAmmGlobalConfigAddress finds AmmGlobalConfig account address with given seeds.
func (inst *Migrate) FindAmmGlobalConfigAddress() (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindAmmGlobalConfigAddress(0)
	return
}

func (inst *Migrate) MustFindAmmGlobalConfigAddress() (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindAmmGlobalConfigAddress(0)
	if err != nil {
		panic(err)
	}
	return
}

// GetAmmGlobalConfigAccount gets the "amm_global_config" account.
func (inst *Migrate) GetAmmGlobalConfigAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(13)
}

// SetWsolMintAccount sets the "wsol_mint" account.
func (inst *Migrate) SetWsolMintAccount(wsolMint ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[14] = ag_solanago.Meta(wsolMint)
	return inst
}

// GetWsolMintAccount gets the "wsol_mint" account.
func (inst *Migrate) GetWsolMintAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(14)
}

// SetLpMintAccount sets the "lp_mint" account.
func (inst *Migrate) SetLpMintAccount(lpMint ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[15] = ag_solanago.Meta(lpMint).WRITE()
	return inst
}

func (inst *Migrate) findFindLpMintAddress(pool ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x706f6f6c5f6c705f6d696e74
	seeds = append(seeds, []byte{byte(0x70), byte(0x6f), byte(0x6f), byte(0x6c), byte(0x5f), byte(0x6c), byte(0x70), byte(0x5f), byte(0x6d), byte(0x69), byte(0x6e), byte(0x74)})
	// path: pool
	seeds = append(seeds, pool.Bytes())

	programID := Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindLpMintAddressWithBumpSeed calculates LpMint account address with given seeds and a known bump seed.
func (inst *Migrate) FindLpMintAddressWithBumpSeed(pool ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindLpMintAddress(pool, bumpSeed)
	return
}

func (inst *Migrate) MustFindLpMintAddressWithBumpSeed(pool ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindLpMintAddress(pool, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindLpMintAddress finds LpMint account address with given seeds.
func (inst *Migrate) FindLpMintAddress(pool ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindLpMintAddress(pool, 0)
	return
}

func (inst *Migrate) MustFindLpMintAddress(pool ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindLpMintAddress(pool, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetLpMintAccount gets the "lp_mint" account.
func (inst *Migrate) GetLpMintAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(15)
}

// SetUserPoolTokenAccountAccount sets the "user_pool_token_account" account.
func (inst *Migrate) SetUserPoolTokenAccountAccount(userPoolTokenAccount ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[16] = ag_solanago.Meta(userPoolTokenAccount).WRITE()
	return inst
}

func (inst *Migrate) findFindUserPoolTokenAccountAddress(poolAuthority ag_solanago.PublicKey, token2022Program ag_solanago.PublicKey, lpMint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: poolAuthority
	seeds = append(seeds, poolAuthority.Bytes())
	// path: token2022Program
	seeds = append(seeds, token2022Program.Bytes())
	// path: lpMint
	seeds = append(seeds, lpMint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindUserPoolTokenAccountAddressWithBumpSeed calculates UserPoolTokenAccount account address with given seeds and a known bump seed.
func (inst *Migrate) FindUserPoolTokenAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, token2022Program ag_solanago.PublicKey, lpMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindUserPoolTokenAccountAddress(poolAuthority, token2022Program, lpMint, bumpSeed)
	return
}

func (inst *Migrate) MustFindUserPoolTokenAccountAddressWithBumpSeed(poolAuthority ag_solanago.PublicKey, token2022Program ag_solanago.PublicKey, lpMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindUserPoolTokenAccountAddress(poolAuthority, token2022Program, lpMint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindUserPoolTokenAccountAddress finds UserPoolTokenAccount account address with given seeds.
func (inst *Migrate) FindUserPoolTokenAccountAddress(poolAuthority ag_solanago.PublicKey, token2022Program ag_solanago.PublicKey, lpMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindUserPoolTokenAccountAddress(poolAuthority, token2022Program, lpMint, 0)
	return
}

func (inst *Migrate) MustFindUserPoolTokenAccountAddress(poolAuthority ag_solanago.PublicKey, token2022Program ag_solanago.PublicKey, lpMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindUserPoolTokenAccountAddress(poolAuthority, token2022Program, lpMint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetUserPoolTokenAccountAccount gets the "user_pool_token_account" account.
func (inst *Migrate) GetUserPoolTokenAccountAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(16)
}

// SetPoolBaseTokenAccountAccount sets the "pool_base_token_account" account.
func (inst *Migrate) SetPoolBaseTokenAccountAccount(poolBaseTokenAccount ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[17] = ag_solanago.Meta(poolBaseTokenAccount).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolBaseTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: pool
	seeds = append(seeds, pool.Bytes())
	// path: tokenProgram
	seeds = append(seeds, tokenProgram.Bytes())
	// path: mint
	seeds = append(seeds, mint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPoolBaseTokenAccountAddressWithBumpSeed calculates PoolBaseTokenAccount account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolBaseTokenAccountAddressWithBumpSeed(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolBaseTokenAccountAddress(pool, tokenProgram, mint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolBaseTokenAccountAddressWithBumpSeed(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolBaseTokenAccountAddress(pool, tokenProgram, mint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolBaseTokenAccountAddress finds PoolBaseTokenAccount account address with given seeds.
func (inst *Migrate) FindPoolBaseTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolBaseTokenAccountAddress(pool, tokenProgram, mint, 0)
	return
}

func (inst *Migrate) MustFindPoolBaseTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, mint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolBaseTokenAccountAddress(pool, tokenProgram, mint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolBaseTokenAccountAccount gets the "pool_base_token_account" account.
func (inst *Migrate) GetPoolBaseTokenAccountAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(17)
}

// SetPoolQuoteTokenAccountAccount sets the "pool_quote_token_account" account.
func (inst *Migrate) SetPoolQuoteTokenAccountAccount(poolQuoteTokenAccount ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[18] = ag_solanago.Meta(poolQuoteTokenAccount).WRITE()
	return inst
}

func (inst *Migrate) findFindPoolQuoteTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// path: pool
	seeds = append(seeds, pool.Bytes())
	// path: tokenProgram
	seeds = append(seeds, tokenProgram.Bytes())
	// path: wsolMint
	seeds = append(seeds, wsolMint.Bytes())

	programID := Addresses["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPoolQuoteTokenAccountAddressWithBumpSeed calculates PoolQuoteTokenAccount account address with given seeds and a known bump seed.
func (inst *Migrate) FindPoolQuoteTokenAccountAddressWithBumpSeed(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPoolQuoteTokenAccountAddress(pool, tokenProgram, wsolMint, bumpSeed)
	return
}

func (inst *Migrate) MustFindPoolQuoteTokenAccountAddressWithBumpSeed(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey, bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolQuoteTokenAccountAddress(pool, tokenProgram, wsolMint, bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPoolQuoteTokenAccountAddress finds PoolQuoteTokenAccount account address with given seeds.
func (inst *Migrate) FindPoolQuoteTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPoolQuoteTokenAccountAddress(pool, tokenProgram, wsolMint, 0)
	return
}

func (inst *Migrate) MustFindPoolQuoteTokenAccountAddress(pool ag_solanago.PublicKey, tokenProgram ag_solanago.PublicKey, wsolMint ag_solanago.PublicKey) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPoolQuoteTokenAccountAddress(pool, tokenProgram, wsolMint, 0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPoolQuoteTokenAccountAccount gets the "pool_quote_token_account" account.
func (inst *Migrate) GetPoolQuoteTokenAccountAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(18)
}

// SetToken2022ProgramAccount sets the "token_2022_program" account.
func (inst *Migrate) SetToken2022ProgramAccount(token2022Program ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[19] = ag_solanago.Meta(token2022Program)
	return inst
}

// GetToken2022ProgramAccount gets the "token_2022_program" account.
func (inst *Migrate) GetToken2022ProgramAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(19)
}

// SetAssociatedTokenProgramAccount sets the "associated_token_program" account.
func (inst *Migrate) SetAssociatedTokenProgramAccount(associatedTokenProgram ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[20] = ag_solanago.Meta(associatedTokenProgram)
	return inst
}

// GetAssociatedTokenProgramAccount gets the "associated_token_program" account.
func (inst *Migrate) GetAssociatedTokenProgramAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(20)
}

// SetPumpAmmEventAuthorityAccount sets the "pump_amm_event_authority" account.
func (inst *Migrate) SetPumpAmmEventAuthorityAccount(pumpAmmEventAuthority ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[21] = ag_solanago.Meta(pumpAmmEventAuthority)
	return inst
}

func (inst *Migrate) findFindPumpAmmEventAuthorityAddress(knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x5f5f6576656e745f617574686f72697479
	seeds = append(seeds, []byte{byte(0x5f), byte(0x5f), byte(0x65), byte(0x76), byte(0x65), byte(0x6e), byte(0x74), byte(0x5f), byte(0x61), byte(0x75), byte(0x74), byte(0x68), byte(0x6f), byte(0x72), byte(0x69), byte(0x74), byte(0x79)})

	programID := Addresses["pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"]

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, programID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, programID)
	}
	return
}

// FindPumpAmmEventAuthorityAddressWithBumpSeed calculates PumpAmmEventAuthority account address with given seeds and a known bump seed.
func (inst *Migrate) FindPumpAmmEventAuthorityAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindPumpAmmEventAuthorityAddress(bumpSeed)
	return
}

func (inst *Migrate) MustFindPumpAmmEventAuthorityAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPumpAmmEventAuthorityAddress(bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindPumpAmmEventAuthorityAddress finds PumpAmmEventAuthority account address with given seeds.
func (inst *Migrate) FindPumpAmmEventAuthorityAddress() (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindPumpAmmEventAuthorityAddress(0)
	return
}

func (inst *Migrate) MustFindPumpAmmEventAuthorityAddress() (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindPumpAmmEventAuthorityAddress(0)
	if err != nil {
		panic(err)
	}
	return
}

// GetPumpAmmEventAuthorityAccount gets the "pump_amm_event_authority" account.
func (inst *Migrate) GetPumpAmmEventAuthorityAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(21)
}

// SetEventAuthorityAccount sets the "event_authority" account.
func (inst *Migrate) SetEventAuthorityAccount(eventAuthority ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[22] = ag_solanago.Meta(eventAuthority)
	return inst
}

func (inst *Migrate) findFindEventAuthorityAddress(knownBumpSeed uint8) (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	var seeds [][]byte
	// const: 0x5f5f6576656e745f617574686f72697479
	seeds = append(seeds, []byte{byte(0x5f), byte(0x5f), byte(0x65), byte(0x76), byte(0x65), byte(0x6e), byte(0x74), byte(0x5f), byte(0x61), byte(0x75), byte(0x74), byte(0x68), byte(0x6f), byte(0x72), byte(0x69), byte(0x74), byte(0x79)})

	if knownBumpSeed != 0 {
		seeds = append(seeds, []byte{byte(bumpSeed)})
		pda, err = ag_solanago.CreateProgramAddress(seeds, ProgramID)
	} else {
		pda, bumpSeed, err = ag_solanago.FindProgramAddress(seeds, ProgramID)
	}
	return
}

// FindEventAuthorityAddressWithBumpSeed calculates EventAuthority account address with given seeds and a known bump seed.
func (inst *Migrate) FindEventAuthorityAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey, err error) {
	pda, _, err = inst.findFindEventAuthorityAddress(bumpSeed)
	return
}

func (inst *Migrate) MustFindEventAuthorityAddressWithBumpSeed(bumpSeed uint8) (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindEventAuthorityAddress(bumpSeed)
	if err != nil {
		panic(err)
	}
	return
}

// FindEventAuthorityAddress finds EventAuthority account address with given seeds.
func (inst *Migrate) FindEventAuthorityAddress() (pda ag_solanago.PublicKey, bumpSeed uint8, err error) {
	pda, bumpSeed, err = inst.findFindEventAuthorityAddress(0)
	return
}

func (inst *Migrate) MustFindEventAuthorityAddress() (pda ag_solanago.PublicKey) {
	pda, _, err := inst.findFindEventAuthorityAddress(0)
	if err != nil {
		panic(err)
	}
	return
}

// GetEventAuthorityAccount gets the "event_authority" account.
func (inst *Migrate) GetEventAuthorityAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(22)
}

// SetProgramAccount sets the "program" account.
func (inst *Migrate) SetProgramAccount(program ag_solanago.PublicKey) *Migrate {
	inst.AccountMetaSlice[23] = ag_solanago.Meta(program)
	return inst
}

// GetProgramAccount gets the "program" account.
func (inst *Migrate) GetProgramAccount() *ag_solanago.AccountMeta {
	return inst.AccountMetaSlice.Get(23)
}

func (inst *Migrate) AddRemainingAccounts(remainingAccounts []ag_solanago.PublicKey) *Migrate {
	accounts := 24
	for i, _ := range remainingAccounts {
		index := accounts + i
		inst.AccountMetaSlice[index] = ag_solanago.Meta(remainingAccounts[i]).WRITE()
	}
	return inst
}

func (inst Migrate) Build() *Instruction {
	return &Instruction{BaseVariant: ag_binary.BaseVariant{
		Impl:   inst,
		TypeID: Instruction_Migrate,
	}}
}

// ValidateAndBuild validates the instruction parameters and accounts;
// if there is a validation error, it returns the error.
// Otherwise, it builds and returns the instruction.
func (inst Migrate) ValidateAndBuild() (*Instruction, error) {
	if err := inst.Validate(); err != nil {
		return nil, err
	}
	return inst.Build(), nil
}

func (inst *Migrate) Validate() error {
	// Check whether all (required) accounts are set:
	{
		if inst.AccountMetaSlice[0] == nil {
			return errors.New("accounts.Global is not set")
		}
		if inst.AccountMetaSlice[1] == nil {
			return errors.New("accounts.WithdrawAuthority is not set")
		}
		if inst.AccountMetaSlice[2] == nil {
			return errors.New("accounts.Mint is not set")
		}
		if inst.AccountMetaSlice[3] == nil {
			return errors.New("accounts.BondingCurve is not set")
		}
		if inst.AccountMetaSlice[4] == nil {
			return errors.New("accounts.AssociatedBondingCurve is not set")
		}
		if inst.AccountMetaSlice[5] == nil {
			return errors.New("accounts.User is not set")
		}
		if inst.AccountMetaSlice[6] == nil {
			return errors.New("accounts.SystemProgram is not set")
		}
		if inst.AccountMetaSlice[7] == nil {
			return errors.New("accounts.TokenProgram is not set")
		}
		if inst.AccountMetaSlice[8] == nil {
			return errors.New("accounts.PumpAmm is not set")
		}
		if inst.AccountMetaSlice[9] == nil {
			return errors.New("accounts.Pool is not set")
		}
		if inst.AccountMetaSlice[10] == nil {
			return errors.New("accounts.PoolAuthority is not set")
		}
		if inst.AccountMetaSlice[11] == nil {
			return errors.New("accounts.PoolAuthorityMintAccount is not set")
		}
		if inst.AccountMetaSlice[12] == nil {
			return errors.New("accounts.PoolAuthorityWsolAccount is not set")
		}
		if inst.AccountMetaSlice[13] == nil {
			return errors.New("accounts.AmmGlobalConfig is not set")
		}
		if inst.AccountMetaSlice[14] == nil {
			return errors.New("accounts.WsolMint is not set")
		}
		if inst.AccountMetaSlice[15] == nil {
			return errors.New("accounts.LpMint is not set")
		}
		if inst.AccountMetaSlice[16] == nil {
			return errors.New("accounts.UserPoolTokenAccount is not set")
		}
		if inst.AccountMetaSlice[17] == nil {
			return errors.New("accounts.PoolBaseTokenAccount is not set")
		}
		if inst.AccountMetaSlice[18] == nil {
			return errors.New("accounts.PoolQuoteTokenAccount is not set")
		}
		if inst.AccountMetaSlice[19] == nil {
			return errors.New("accounts.Token2022Program is not set")
		}
		if inst.AccountMetaSlice[20] == nil {
			return errors.New("accounts.AssociatedTokenProgram is not set")
		}
		if inst.AccountMetaSlice[21] == nil {
			return errors.New("accounts.PumpAmmEventAuthority is not set")
		}
		if inst.AccountMetaSlice[22] == nil {
			return errors.New("accounts.EventAuthority is not set")
		}
		if inst.AccountMetaSlice[23] == nil {
			return errors.New("accounts.Program is not set")
		}
	}
	return nil
}

func (inst *Migrate) EncodeToTree(parent ag_treeout.Branches) {
	parent.Child(ag_format.Program(ProgramName, ProgramID)).
		//
		ParentFunc(func(programBranch ag_treeout.Branches) {
			programBranch.Child(ag_format.Instruction("Migrate")).
				//
				ParentFunc(func(instructionBranch ag_treeout.Branches) {

					// Parameters of the instruction:
					instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {})

					// Accounts of the instruction:
					instructionBranch.Child("Accounts[len=24]").ParentFunc(func(accountsBranch ag_treeout.Branches) {
						accountsBranch.Child(ag_format.Meta("                  global", inst.AccountMetaSlice.Get(0)))
						accountsBranch.Child(ag_format.Meta("      withdraw_authority", inst.AccountMetaSlice.Get(1)))
						accountsBranch.Child(ag_format.Meta("                    mint", inst.AccountMetaSlice.Get(2)))
						accountsBranch.Child(ag_format.Meta("           bonding_curve", inst.AccountMetaSlice.Get(3)))
						accountsBranch.Child(ag_format.Meta("associated_bonding_curve", inst.AccountMetaSlice.Get(4)))
						accountsBranch.Child(ag_format.Meta("                    user", inst.AccountMetaSlice.Get(5)))
						accountsBranch.Child(ag_format.Meta("          system_program", inst.AccountMetaSlice.Get(6)))
						accountsBranch.Child(ag_format.Meta("           token_program", inst.AccountMetaSlice.Get(7)))
						accountsBranch.Child(ag_format.Meta("                pump_amm", inst.AccountMetaSlice.Get(8)))
						accountsBranch.Child(ag_format.Meta("                    pool", inst.AccountMetaSlice.Get(9)))
						accountsBranch.Child(ag_format.Meta("          pool_authority", inst.AccountMetaSlice.Get(10)))
						accountsBranch.Child(ag_format.Meta("    pool_authority_mint_", inst.AccountMetaSlice.Get(11)))
						accountsBranch.Child(ag_format.Meta("    pool_authority_wsol_", inst.AccountMetaSlice.Get(12)))
						accountsBranch.Child(ag_format.Meta("       amm_global_config", inst.AccountMetaSlice.Get(13)))
						accountsBranch.Child(ag_format.Meta("               wsol_mint", inst.AccountMetaSlice.Get(14)))
						accountsBranch.Child(ag_format.Meta("                 lp_mint", inst.AccountMetaSlice.Get(15)))
						accountsBranch.Child(ag_format.Meta("        user_pool_token_", inst.AccountMetaSlice.Get(16)))
						accountsBranch.Child(ag_format.Meta("        pool_base_token_", inst.AccountMetaSlice.Get(17)))
						accountsBranch.Child(ag_format.Meta("       pool_quote_token_", inst.AccountMetaSlice.Get(18)))
						accountsBranch.Child(ag_format.Meta("      token_2022_program", inst.AccountMetaSlice.Get(19)))
						accountsBranch.Child(ag_format.Meta("associated_token_program", inst.AccountMetaSlice.Get(20)))
						accountsBranch.Child(ag_format.Meta("pump_amm_event_authority", inst.AccountMetaSlice.Get(21)))
						accountsBranch.Child(ag_format.Meta("         event_authority", inst.AccountMetaSlice.Get(22)))
						accountsBranch.Child(ag_format.Meta("                 program", inst.AccountMetaSlice.Get(23)))
					})
				})
		})
}

func (obj Migrate) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
	return nil
}
func (obj *Migrate) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
	return nil
}

// NewMigrateInstruction declares a new Migrate instruction with the provided parameters and accounts.
func NewMigrateInstruction(
	// Accounts:
	global ag_solanago.PublicKey,
	withdrawAuthority ag_solanago.PublicKey,
	mint ag_solanago.PublicKey,
	bondingCurve ag_solanago.PublicKey,
	associatedBondingCurve ag_solanago.PublicKey,
	user ag_solanago.PublicKey,
	systemProgram ag_solanago.PublicKey,
	tokenProgram ag_solanago.PublicKey,
	pumpAmm ag_solanago.PublicKey,
	pool ag_solanago.PublicKey,
	poolAuthority ag_solanago.PublicKey,
	poolAuthorityMintAccount ag_solanago.PublicKey,
	poolAuthorityWsolAccount ag_solanago.PublicKey,
	ammGlobalConfig ag_solanago.PublicKey,
	wsolMint ag_solanago.PublicKey,
	lpMint ag_solanago.PublicKey,
	userPoolTokenAccount ag_solanago.PublicKey,
	poolBaseTokenAccount ag_solanago.PublicKey,
	poolQuoteTokenAccount ag_solanago.PublicKey,
	token2022Program ag_solanago.PublicKey,
	associatedTokenProgram ag_solanago.PublicKey,
	pumpAmmEventAuthority ag_solanago.PublicKey,
	eventAuthority ag_solanago.PublicKey,
	program ag_solanago.PublicKey) *Migrate {
	return NewMigrateInstructionBuilder().
		SetGlobalAccount(global).
		SetWithdrawAuthorityAccount(withdrawAuthority).
		SetMintAccount(mint).
		SetBondingCurveAccount(bondingCurve).
		SetAssociatedBondingCurveAccount(associatedBondingCurve).
		SetUserAccount(user).
		SetSystemProgramAccount(systemProgram).
		SetTokenProgramAccount(tokenProgram).
		SetPumpAmmAccount(pumpAmm).
		SetPoolAccount(pool).
		SetPoolAuthorityAccount(poolAuthority).
		SetPoolAuthorityMintAccountAccount(poolAuthorityMintAccount).
		SetPoolAuthorityWsolAccountAccount(poolAuthorityWsolAccount).
		SetAmmGlobalConfigAccount(ammGlobalConfig).
		SetWsolMintAccount(wsolMint).
		SetLpMintAccount(lpMint).
		SetUserPoolTokenAccountAccount(userPoolTokenAccount).
		SetPoolBaseTokenAccountAccount(poolBaseTokenAccount).
		SetPoolQuoteTokenAccountAccount(poolQuoteTokenAccount).
		SetToken2022ProgramAccount(token2022Program).
		SetAssociatedTokenProgramAccount(associatedTokenProgram).
		SetPumpAmmEventAuthorityAccount(pumpAmmEventAuthority).
		SetEventAuthorityAccount(eventAuthority).
		SetProgramAccount(program)
}
