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

package pump

import (
	"fmt"
	ag_binary "github.com/gagliardetto/binary"
	ag_solanago "github.com/gagliardetto/solana-go"
)

type BondingCurveAccount struct {
	VirtualTokenReserves uint64
	VirtualSolReserves   uint64
	RealTokenReserves    uint64
	RealSolReserves      uint64
	TokenTotalSupply     uint64
	Complete             bool
	Creator              ag_solanago.PublicKey
}

var BondingCurveAccountDiscriminator = [8]byte{23, 183, 248, 55, 96, 216, 172, 96}

func (obj BondingCurveAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
	// Write account discriminator:
	err = encoder.WriteBytes(BondingCurveAccountDiscriminator[:], false)
	if err != nil {
		return err
	}
	// Serialize `VirtualTokenReserves` param:
	err = encoder.Encode(obj.VirtualTokenReserves)
	if err != nil {
		return err
	}
	// Serialize `VirtualSolReserves` param:
	err = encoder.Encode(obj.VirtualSolReserves)
	if err != nil {
		return err
	}
	// Serialize `RealTokenReserves` param:
	err = encoder.Encode(obj.RealTokenReserves)
	if err != nil {
		return err
	}
	// Serialize `RealSolReserves` param:
	err = encoder.Encode(obj.RealSolReserves)
	if err != nil {
		return err
	}
	// Serialize `TokenTotalSupply` param:
	err = encoder.Encode(obj.TokenTotalSupply)
	if err != nil {
		return err
	}
	// Serialize `Complete` param:
	err = encoder.Encode(obj.Complete)
	if err != nil {
		return err
	}
	// Serialize `Creator` param:
	err = encoder.Encode(obj.Creator)
	if err != nil {
		return err
	}
	return nil
}

func (obj *BondingCurveAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
	// Read and check account discriminator:
	{
		discriminator, err := decoder.ReadTypeID()
		if err != nil {
			return err
		}
		if !discriminator.Equal(BondingCurveAccountDiscriminator[:]) {
			return fmt.Errorf(
				"wrong discriminator: wanted %s, got %s",
				"[23 183 248 55 96 216 172 96]",
				fmt.Sprint(discriminator[:]))
		}
	}
	// Deserialize `VirtualTokenReserves`:
	err = decoder.Decode(&obj.VirtualTokenReserves)
	if err != nil {
		return err
	}
	// Deserialize `VirtualSolReserves`:
	err = decoder.Decode(&obj.VirtualSolReserves)
	if err != nil {
		return err
	}
	// Deserialize `RealTokenReserves`:
	err = decoder.Decode(&obj.RealTokenReserves)
	if err != nil {
		return err
	}
	// Deserialize `RealSolReserves`:
	err = decoder.Decode(&obj.RealSolReserves)
	if err != nil {
		return err
	}
	// Deserialize `TokenTotalSupply`:
	err = decoder.Decode(&obj.TokenTotalSupply)
	if err != nil {
		return err
	}
	// Deserialize `Complete`:
	err = decoder.Decode(&obj.Complete)
	if err != nil {
		return err
	}
	// Deserialize `Creator`:
	err = decoder.Decode(&obj.Creator)
	if err != nil {
		return err
	}
	return nil
}

type GlobalAccount struct {
	// Unused
	Initialized                 bool
	Authority                   ag_solanago.PublicKey
	FeeRecipient                ag_solanago.PublicKey
	InitialVirtualTokenReserves uint64
	InitialVirtualSolReserves   uint64
	InitialRealTokenReserves    uint64
	TokenTotalSupply            uint64
	FeeBasisPoints              uint64
	WithdrawAuthority           ag_solanago.PublicKey

	// Unused
	EnableMigrate         bool
	PoolMigrationFee      uint64
	CreatorFeeBasisPoints uint64
	FeeRecipients         [7]ag_solanago.PublicKey
	SetCreatorAuthority   ag_solanago.PublicKey
}

var GlobalAccountDiscriminator = [8]byte{167, 232, 232, 177, 200, 108, 114, 127}

func (obj GlobalAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
	// Write account discriminator:
	err = encoder.WriteBytes(GlobalAccountDiscriminator[:], false)
	if err != nil {
		return err
	}
	// Serialize `Initialized` param:
	err = encoder.Encode(obj.Initialized)
	if err != nil {
		return err
	}
	// Serialize `Authority` param:
	err = encoder.Encode(obj.Authority)
	if err != nil {
		return err
	}
	// Serialize `FeeRecipient` param:
	err = encoder.Encode(obj.FeeRecipient)
	if err != nil {
		return err
	}
	// Serialize `InitialVirtualTokenReserves` param:
	err = encoder.Encode(obj.InitialVirtualTokenReserves)
	if err != nil {
		return err
	}
	// Serialize `InitialVirtualSolReserves` param:
	err = encoder.Encode(obj.InitialVirtualSolReserves)
	if err != nil {
		return err
	}
	// Serialize `InitialRealTokenReserves` param:
	err = encoder.Encode(obj.InitialRealTokenReserves)
	if err != nil {
		return err
	}
	// Serialize `TokenTotalSupply` param:
	err = encoder.Encode(obj.TokenTotalSupply)
	if err != nil {
		return err
	}
	// Serialize `FeeBasisPoints` param:
	err = encoder.Encode(obj.FeeBasisPoints)
	if err != nil {
		return err
	}
	// Serialize `WithdrawAuthority` param:
	err = encoder.Encode(obj.WithdrawAuthority)
	if err != nil {
		return err
	}
	// Serialize `EnableMigrate` param:
	err = encoder.Encode(obj.EnableMigrate)
	if err != nil {
		return err
	}
	// Serialize `PoolMigrationFee` param:
	err = encoder.Encode(obj.PoolMigrationFee)
	if err != nil {
		return err
	}
	// Serialize `CreatorFeeBasisPoints` param:
	err = encoder.Encode(obj.CreatorFeeBasisPoints)
	if err != nil {
		return err
	}
	// Serialize `FeeRecipients` param:
	err = encoder.Encode(obj.FeeRecipients)
	if err != nil {
		return err
	}
	// Serialize `SetCreatorAuthority` param:
	err = encoder.Encode(obj.SetCreatorAuthority)
	if err != nil {
		return err
	}
	return nil
}

func (obj *GlobalAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
	// Read and check account discriminator:
	{
		discriminator, err := decoder.ReadTypeID()
		if err != nil {
			return err
		}
		if !discriminator.Equal(GlobalAccountDiscriminator[:]) {
			return fmt.Errorf(
				"wrong discriminator: wanted %s, got %s",
				"[167 232 232 177 200 108 114 127]",
				fmt.Sprint(discriminator[:]))
		}
	}
	// Deserialize `Initialized`:
	err = decoder.Decode(&obj.Initialized)
	if err != nil {
		return err
	}
	// Deserialize `Authority`:
	err = decoder.Decode(&obj.Authority)
	if err != nil {
		return err
	}
	// Deserialize `FeeRecipient`:
	err = decoder.Decode(&obj.FeeRecipient)
	if err != nil {
		return err
	}
	// Deserialize `InitialVirtualTokenReserves`:
	err = decoder.Decode(&obj.InitialVirtualTokenReserves)
	if err != nil {
		return err
	}
	// Deserialize `InitialVirtualSolReserves`:
	err = decoder.Decode(&obj.InitialVirtualSolReserves)
	if err != nil {
		return err
	}
	// Deserialize `InitialRealTokenReserves`:
	err = decoder.Decode(&obj.InitialRealTokenReserves)
	if err != nil {
		return err
	}
	// Deserialize `TokenTotalSupply`:
	err = decoder.Decode(&obj.TokenTotalSupply)
	if err != nil {
		return err
	}
	// Deserialize `FeeBasisPoints`:
	err = decoder.Decode(&obj.FeeBasisPoints)
	if err != nil {
		return err
	}
	// Deserialize `WithdrawAuthority`:
	err = decoder.Decode(&obj.WithdrawAuthority)
	if err != nil {
		return err
	}
	// Deserialize `EnableMigrate`:
	err = decoder.Decode(&obj.EnableMigrate)
	if err != nil {
		return err
	}
	// Deserialize `PoolMigrationFee`:
	err = decoder.Decode(&obj.PoolMigrationFee)
	if err != nil {
		return err
	}
	// Deserialize `CreatorFeeBasisPoints`:
	err = decoder.Decode(&obj.CreatorFeeBasisPoints)
	if err != nil {
		return err
	}
	// Deserialize `FeeRecipients`:
	err = decoder.Decode(&obj.FeeRecipients)
	if err != nil {
		return err
	}
	// Deserialize `SetCreatorAuthority`:
	err = decoder.Decode(&obj.SetCreatorAuthority)
	if err != nil {
		return err
	}
	return nil
}
