currency

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CELOCurrency = Currency{
	Address: common.ZeroAddress,
	// contains filtered or unexported fields
}
View Source
var NoopExchangeRate = ExchangeRate{common.Big1, common.Big1}

NoopExchangeRate represents an exchange rate of 1 to 1

Functions

func CurrencyWhitelist

func CurrencyWhitelist(vmRunner vm.EVMRunner) ([]common.Address, error)

CurrencyWhitelist retrieves the list of currencies that can be used to pay transaction fees

func GetBalanceOf

func GetBalanceOf(vmRunner vm.EVMRunner, accountOwner common.Address, contractAddress common.Address) (result *big.Int, err error)

GetBalanceOf returns an account's balance on a given ERC20 currency

func IsWhitelisted

func IsWhitelisted(vmRunner vm.EVMRunner, feeCurrency *common.Address) bool

IsWhitelisted indicates if a currency is whitelisted for transaction fee payments

Types

type Currency

type Currency struct {
	Address common.Address
	// contains filtered or unexported fields
}

Currency represent a system currency than can be converted to CELO Two currencies are deemed equal if they have the same address

func (*Currency) CmpToCurrency

func (c *Currency) CmpToCurrency(currencyAmount *big.Int, sndCurrencyAmount *big.Int, sndCurrency *Currency) int

CmpToCurrency compares a currency amount to an amount in a different currency

func (*Currency) FromCELO

func (c *Currency) FromCELO(celoAmount *big.Int) *big.Int

FromCELO converts an CELO amount to a currency tokens amount

func (*Currency) ToCELO

func (c *Currency) ToCELO(tokenAmount *big.Int) *big.Int

ToCELO converts an currency's token amount to a CELO amount

type CurrencyManager

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

CurrencyManager provides an interface to access different fee currencies on a given point in time (header,state) and doing comparison or fetching exchange rates

It's implements an internal cache to avoid perfoming duplicated EVM calls

func NewManager

func NewManager(vmRunner vm.EVMRunner) *CurrencyManager

NewManager creates a new CurrencyManager

func (*CurrencyManager) CmpValues

func (cc *CurrencyManager) CmpValues(val1 *big.Int, currencyAddr1 *common.Address, val2 *big.Int, currencyAddr2 *common.Address) int

CmpValues compares values of potentially different currencies

func (*CurrencyManager) GetCurrency

func (cc *CurrencyManager) GetCurrency(currencyAddress *common.Address) (*Currency, error)

GetCurrency retrieves fee currency

type ExchangeRate

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

ExchangeRate represent the exchangeRate [Base -> Token] Follows the equation: 1 base * ExchangeRate = X token

func GetExchangeRate

func GetExchangeRate(vmRunner vm.EVMRunner, currencyAddress *common.Address) (*ExchangeRate, error)

GetExchangeRate retrieves currency-to-CELO exchange rate

func NewExchangeRate

func NewExchangeRate(numerator *big.Int, denominator *big.Int) (*ExchangeRate, error)

NewExchangeRate creates an exchange rate. Requires numerator >=0 && denominator >= 0

func (*ExchangeRate) FromBase

func (er *ExchangeRate) FromBase(goldAmount *big.Int) *big.Int

FromGold converts from base to token

func (*ExchangeRate) ToBase

func (er *ExchangeRate) ToBase(tokenAmount *big.Int) *big.Int

ToBase converts from token to base

Jump to

Keyboard shortcuts

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