pyecon

package module
v0.0.0-...-6836fb9 Latest Latest
Warning

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

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

README

go-pyecon

Package pyecon provides tools with working with the main pye contract, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-pyecon

GoDoc

Import

To import package pyecon use import code like the follownig:

import "github.com/reiver/go-pyecon"

Installation

To install package pyecon do the following:

GOPROXY=direct go get https://github.com/reiver/go-pyecon

Author

Package pyecon was written by Charles Iliya Krempeaux

Documentation

Index

Constants

View Source
const (
	TokenTypePrincipalToken = TokenType("pye-principal-token")
	TokenTypeYieldToken     = TokenType("pye-yield-token")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BiToken

type BiToken interface {
	BlockDigest() ethdigest.Digest
	BlockNumber() uint64
	Chain10Exponent() (uint64, bool)
	ChainCode() string
	ChainID() uint64
	ChainName() string
	ContractAddress() ethaddr.Address
	Index() uint
	Maturity() (time.Time, error)
	MintedPrincipalTokenShares() *big.Int
	MintedYieldTokenShares() *big.Int
	PositionAddress() ethaddr.Address
	PrincipalAmount() *big.Int
	PrincipalTokenID() *big.Int
	PrincipalTokenYieldPercentage() *big.Int
	Removed() bool
	Topics() []ethdigest.Digest
	TxDigest() ethdigest.Digest
	TxIndex() uint
	YieldTokenID() *big.Int

	PrincipalToken() PrincipalToken
	YieldToken() YieldToken
}

BiToken represents a bi-token. A bi-token represents the combined principal-token and yield-token.

The principal-token and yield-token pair are stored on the blockchain-network together. And when you 'fetch' the information off of the blockchain-network, you get both. BiToken represents that.

type Client

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

Client is a client for a pyecon contract on some blockchain-network.

You use this to interact with a pyecon contract.

func HoleskyClient

func HoleskyClient(rpcurl string) Client

HoleskyClient returns a client for the pyecon contract on the holesky blockchain-network.

func (Client) Chain10Exponent

func (receiver Client) Chain10Exponent() (uint64, bool)

Chain10Exponent returns the exponent of the blockchain-network this client is attached to.

The 'exponent' comes from the following equation that shows up the default-currency-code relates to the smallest-currency-code:

1 [DEFAULT-CURRENCY-CODE] = 10ⁿ [SMALLEST-CURRENCY-CODE]

(Where "n" is the value that Chain10Exponent returns.)

For example, on Ethereum:

1 ETH = 1,000,000,000,000,000,000 wei = 10¹⁸ wei

Therefore Chain10Exponent would return: 18

And also, for example, on Avalanche:

1 AVAX = 1,000,000,000 nanoAVAX = 10⁹ nanoAVAX

Therefore Chain10Exponent would return: 9

The reason this number is useful is this —

Often you will be working with numbers that aer in the smallest-currency of the blockchain-network. (Ex: "wei" rather than "ETH".) But you need to display things in the default-currency. (Ex: "ETH" rather than "wei".) So you need to do a conversion. (Ex: convert "wei" to "ETH".) The number Chain10Exponent returns will enable you to do that conversion.

For example:

var chainid uint64 = // ...

// ...

var wei *big.Int = // ...

// ...

var exponent *big.Int = new(big.Int).SetUint64( chain10.Exponent(chainid) )

var conversionDenominator *big.Int = new(big.Int).Exp(10, exponent)

var ethrat *big.Rat = new(big.Rat).SetFrac(wei, conversionDenominator)
var eth *big.Float = new(big.Float).SetRat(ethrat)

func (Client) ChainCode

func (receiver Client) ChainCode() string

ChainCode returns the (curency) chain-code of the blockchain-network this client is attached to.

See https://chainlist.org/ for the list of chain-ids mapped to (currency) chain-codes.

func (Client) ChainID

func (receiver Client) ChainID() uint64

ChainID returns the chain-id of the blockchain-network this client is attached to.

See https://chainlist.org/ for the list of chain-ids.

func (Client) ChainName

func (receiver Client) ChainName() string

ChainName returns the (human-legible) chain-name of the blockchain-network this client is attached to.

See https://chainlist.org/ for the list of chain-ids mapped to chain-names.

func (Client) CurrentBlockNumber

func (receiver Client) CurrentBlockNumber() (*big.Int, error)

CurrentBlockNumber returns the current (newest) block-number for the blockchain-network which this client is conencted to.

Each blockchain-network will (likely) have a different current (newest) blockchain-number.

And each blockchain-network's current (newest) block-number will change over time.

Example:

currentBlockNumber, err := client.CurrentBlockNumber()

func (Client) Logs

func (receiver Client) Logs(fromBlockNumber *big.Int, toBlockNumber *big.Int) (Logs, error)

Logs returns the logs for the pyecon contract on the network.

func (Client) PositionAddress

func (receiver Client) PositionAddress(tokenID tokenid.TokenID) (ethaddr.Address, error)

PositionAddress calls the "positionAddress" method on the pyecon contract, and return the address of the position-contract.

func (Client) URI

func (receiver Client) URI(tokenID tokenid.TokenID) (string, error)

URI calls the "uri" method on the pyecon contract, and return the URI to the associate metadata.

type Log

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

type Logs

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

func (*Logs) BiToken

func (receiver *Logs) BiToken() (BiToken, error)

func (*Logs) Len

func (receiver *Logs) Len() int

func (*Logs) Next

func (receiver *Logs) Next() bool

type PrincipalToken

type PrincipalToken interface {
	Token
	MintedPrincipalTokenShares() *big.Int
}

type Token

type Token interface {
	TokenID() *big.Int
	PositionAddress() ethaddr.Address
	IsPrincipalToken() bool
	IsYieldToken() bool
	TokenType() TokenType
	TokenName() string

	Chain10Exponent() (uint64, bool)
	ChainCode() string
	ChainID() uint64
	ChainName() string

	Maturity() (time.Time, error)
	PrincipalAmount() *big.Int
	PrincipalTokenYieldPercentage() *big.Int
}

type TokenType

type TokenType string

func (TokenType) String

func (receiver TokenType) String() string

type YieldToken

type YieldToken interface {
	Token
	MintedYieldTokenShares() *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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