anchor

package
v0.0.0-...-f75a87c Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 8 Imported by: 0

README

Psyoptions & Zetamarkets uses Anchor (+ Serum), a framework for Solana's Sealevel runtime providing several convenient developer tools for writing smart contracts. https://github.com/project-serum/anchor

We want to automcatically query all the available options from Psyoptions/Zeta. To do so, we will use anchor-go which generates Go clients for Solana programs (smart contracts) written using the anchor framework.

go get github.com/gagliardetto/anchor-go
go run github.com/gagliardetto/anchor-go --src=idl.json

For PsyOptions (Zeta is coded way too diffrently), we actually only need the structure:

type OptionMarket struct {
	OptionMint                  ag_solanago.PublicKey
	WriterTokenMint             ag_solanago.PublicKey
	UnderlyingAssetMint         ag_solanago.PublicKey
	QuoteAssetMint              ag_solanago.PublicKey
	UnderlyingAmountPerContract uint64
	QuoteAmountPerContract      uint64
	ExpirationUnixTimestamp     int64
	UnderlyingAssetPool         ag_solanago.PublicKey
	QuoteAssetPool              ag_solanago.PublicKey
	MintFeeAccount              ag_solanago.PublicKey
	ExerciseFeeAccount          ag_solanago.PublicKey
	Expired                     bool
	BumpSeed                    uint8
}

from the file accounts.go

idl file is copied from :

curl https://raw.githubusercontent.com/mithraiclabs/psyoptions-ts/master/packages/psy-american/src/idl.json -o idl.json

But it can also be generated using the anchor cli doing something like:

anchor idl parse -f lib.rs -o idl.json

Note: There are 2 Solana go libraries and they are pretty similar:

github.com/gagliardetto/solana-go

github.com/streamingfast/solana-go

We were using the second one but since anchor-go is from the same authors as the first one, we also have to use that lib. In a perfect world, we should only use one of them but that would require some refactoring that I am not doing now.

Documentation

Index

Constants

View Source
const (
	SOLAddress  = "So11111111111111111111111111111111111111112"
	SOLDecimals = 9

	BTCAddress  = "9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E"
	BTCDecimals = 6

	USDCAddress  = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
	USDCDecimals = 6

	ETHAddress  = "2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk"
	EthDecimals = 6

	MSOLAddress  = "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"
	MSOLDecimals = 9

	PAIAddress  = "Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"
	PAIDecimals = 6

	ARBAddress  = "9tzZzEHsKnwFL1A3DyFJwj36KnZj3gZ7g4srWp9YTEoh"
	ARBDecimals = 8
)

https://raw.githubusercontent.com/mithraiclabs/psyoptions-ts/e5fa046466c87c3f427ea5308a9e4fd5fbf96162/packages/psy-token-registry/src/mainnet.ts

View Source
const (
	PsyOptionsProgramID = "R2y9ip6mxmWUj4pt54jP2hz2dgvMozy9VTSwMWE7evs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	// contains filtered or unexported fields
}

func Query

func Query() ([]Option, error)

func (*Option) Asset

func (o *Option) Asset() string

func (*Option) ContractSize

func (o *Option) ContractSize() float64

func (*Option) Expiration

func (o *Option) Expiration() string

Expiration will be used in .Name() when fixed.

func (*Option) IsCall

func (o *Option) IsCall() bool

func (*Option) IsExpired

func (o *Option) IsExpired() bool

the Options have a field "Expired"(bool) but it is not set to false even for expired hence the function. INFO: copy from opyn.go. should make a proper function we keep an option even 2 days after expiry mainly because not all protocol stop at expiry or right before TODO re-check later.

func (*Option) Name

func (o *Option) Name() string

func (*Option) OptionMarketAddress

func (o *Option) OptionMarketAddress() solana.PublicKey

func (*Option) OptionType

func (o *Option) OptionType() string

func (*Option) Quote

func (o *Option) Quote() string

func (*Option) QuotePerContract

func (o *Option) QuotePerContract() float64

func (*Option) QuotePublicKey

func (o *Option) QuotePublicKey() solana.PublicKey

func (*Option) SerumMarketAddress

func (o *Option) SerumMarketAddress() solana.PublicKey

func (*Option) Strike

func (o *Option) Strike() float64

func (*Option) UnderlyingPerContract

func (o *Option) UnderlyingPerContract() float64

Directories

Path Synopsis
generated

Jump to

Keyboard shortcuts

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