utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BPOWPRECISION ...
	BPOWPRECISION = new(big.Int).Div(
		BONE(),
		new(big.Int).Exp(big.NewInt(10), big.NewInt(10), nil),
	)
)
View Source
var (
	// SwapFee 2.5% in wei
	SwapFee = big.NewInt(25000000000000000)
)

Functions

func BONE

func BONE() *big.Int

BONE ...

func Badd

func Badd(a, b *big.Int) *big.Int

Badd ...

func Bdiv

func Bdiv(a, b *big.Int) *big.Int

Bdiv ... TODO(bonedaddy): right now we check for division by 0 and return 0 however this may not be good

func Bfloor

func Bfloor(a *big.Int) *big.Int

Bfloor ...

func Bmul

func Bmul(a, b *big.Int) *big.Int

Bmul ...

func BoostGasPrice added in v0.0.4

func BoostGasPrice(reportedPrice *big.Int, minimum *big.Int, multiplier *big.Int) *big.Int

BoostGasPrice is used to override the reported gas price if it is lower than the minimum while also multiplying the overall gas price to ensure faster block inclusion

func Bpow

func Bpow(base, exp *big.Int) *big.Int

Bpow ...

func Bpowapprox

func Bpowapprox(base, exp, precision *big.Int) *big.Int

Bpowapprox ...

func Bpowi

func Bpowi(a, n *big.Int) *big.Int

Bpowi ...

func Bsub

func Bsub(a, b *big.Int) *big.Int

Bsub ...

func Bsubsign

func Bsubsign(a, b *big.Int) (*big.Int, bool)

Bsubsign ...

func Btoi

func Btoi(a *big.Int) *big.Int

Btoi ...

func CalcGasCost

func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int

CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)

func CalcSpotPrice

func CalcSpotPrice(
	tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, swapFee *big.Int,
) *big.Int

CalcSpotPrice is used to calculate the spot price of a given asset

func GetChangePercentageBig

func GetChangePercentageBig(final, start *big.Int) float64

GetChangePercentageBig returns the change percentage for two big.Int ypes

func GetGasPrice added in v0.0.4

func GetGasPrice(ctx context.Context, backend bind.ContractBackend, minimum, multiplier *big.Int) (*big.Int, error)

GetGasPrice returns a gas price as reported by the oracle, overriding it if it is lower than the minimum, while also applying a multiplier

func IsValidAddress

func IsValidAddress(iaddress interface{}) bool

IsValidAddress validate hex address

func IsZeroAddress

func IsZeroAddress(iaddress interface{}) bool

IsZeroAddress validate if it's a 0 address

func NewAccount

func NewAccount(keyFileDir, keyPass string) (accounts.Account, error)

NewAccount returns a new ethereum account as generated by `geth account new`

func PoolTokensFor

func PoolTokensFor(bindings *sigmacore.Sigmacore, backend bind.ContractBackend) (map[string]common.Address, error)

PoolTokensFor is similar go-indexed/bclient's version but for easier testing

func PublicKeyBytesToAddress

func PublicKeyBytesToAddress(publicKey []byte) common.Address

PublicKeyBytesToAddress ...

func SigRSV

func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)

SigRSV signatures R S V returned as arrays

func ToDecimal

func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal

ToDecimal wei to decimals

func ToWei

func ToWei(iamount interface{}, decimals int) *big.Int

ToWei decimals to wei

Types

type Authorizer

type Authorizer struct {
	sync.Mutex // bind.TransactOpts is not thread safe
	*bind.TransactOpts
}

Authorizer wraps ethereum transactopts

func NewAuthorizer

func NewAuthorizer(keyFile, keyPass string) (*Authorizer, error)

NewAuthorizer returns an Authorizer object

func NewAuthorizerFromPK

func NewAuthorizerFromPK(pk *ecdsa.PrivateKey) *Authorizer

NewAuthorizerFromPK returns an authorizer from a private key

type Breaker added in v0.0.4

type Breaker interface {
	SetPublicSwap(opts *bind.TransactOpts, pool common.Address, enabled bool) (*types.Transaction, error)
	CircuitBreaker(opts *bind.CallOpts) (common.Address, error)
}

Breaker is a minimal interface needed for circuit breaker designed to allow for easier testing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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