whirlpools

package
v0.0.0-...-19dd61d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//Concentrated Liquidity Automated Market Maker (CLAMM)
	ErrWrongToken       = errors.New("ocra Whirlpools: PriceOf: token not in pool")
	ErrorWrongTypeCLAMM = errors.New("ocra Whirlpools: Not Ocra CLAMM pool")
	OCRA_PROGRAM_ID     = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
)

Functions

This section is empty.

Types

type Pool

type Pool struct {
	Name    string
	Address solana.PublicKey

	Immutables PoolOpts
	State      PoolState
	// contains filtered or unexported fields
}

func Decode

func Decode(poolBytes []byte) (*Pool, error)

func NewPool

func NewPool(client *rpc.Client, name string, poolAddress string, immutables PoolOpts) (*Pool, error)

NewPool Just like Uniswap-V3

func (Pool) Encode

func (p Pool) Encode() ([]byte, error)

func (*Pool) PriceOf

func (p *Pool) PriceOf(token string) (float64, error)

func (*Pool) UpdateState

func (p *Pool) UpdateState(ctx context.Context) error

type PoolOpts

type PoolOpts struct {
	Token0 token.Token
	Token1 token.Token
}

type PoolState

type PoolState struct {
	Blob                       [8]uint8
	WhirlpoolsConfig           solana.PublicKey
	WhirlpoolBump              [1]uint8
	TickSpacing                uint16
	TickSpacingSeed            [2]uint8
	FeeRate                    uint16
	ProtocolFeeRate            uint16
	Liquidity                  bin.Uint128
	SqrtPrice                  bin.Uint128
	TickCurrentIndex           int32
	ProtocolFeeOwedA           uint64
	ProtocolFeeOwedB           uint64
	TokenMintA                 solana.PublicKey
	TokenVaultA                solana.PublicKey
	FeeGrowthGlobalA           bin.Uint128
	TokenMintB                 solana.PublicKey
	TokenVaultB                solana.PublicKey
	FeeGrowthGlobalB           bin.Uint128
	RewardLastUpdatedTimestamp uint64
	RewardInfos                [3]WhirlpoolRewardInfo
}

type WhirlpoolRewardInfo

type WhirlpoolRewardInfo struct {
	Mint                  solana.PublicKey
	Vault                 solana.PublicKey
	Authority             solana.PublicKey
	EmissionsPerSecondX64 bin.Uint128
	GrowthGlobalX64       bin.Uint128
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL