Documentation ¶
Index ¶
- Constants
- type BiToken
- type Client
- func (receiver Client) Chain10Exponent() (uint64, bool)
- func (receiver Client) ChainCode() string
- func (receiver Client) ChainID() uint64
- func (receiver Client) ChainName() string
- func (receiver Client) CurrentBlockNumber() (*big.Int, error)
- func (receiver Client) Logs(fromBlockNumber *big.Int, toBlockNumber *big.Int) (Logs, error)
- func (receiver Client) PositionAddress(tokenID tokenid.TokenID) (ethaddr.Address, error)
- func (receiver Client) URI(tokenID tokenid.TokenID) (string, error)
- type Log
- type Logs
- type PrincipalToken
- type Token
- type TokenType
- type YieldToken
Constants ¶
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) 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 ¶
HoleskyClient returns a client for the pyecon contract on the holesky blockchain-network.
func (Client) Chain10Exponent ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) PositionAddress ¶
PositionAddress calls the "positionAddress" method on the pyecon contract, and return the address of the position-contract.
type PrincipalToken ¶
type PrincipalToken interface { Token }
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 YieldToken ¶
type YieldToken interface { Token }