Documentation ¶
Index ¶
- Variables
- func BONE() *big.Int
- func Badd(a, b *big.Int) *big.Int
- func Bdiv(a, b *big.Int) *big.Int
- func Bfloor(a *big.Int) *big.Int
- func Bmul(a, b *big.Int) *big.Int
- func BoostGasPrice(reportedPrice *big.Int, minimum *big.Int, multiplier *big.Int) *big.Int
- func Bpow(base, exp *big.Int) *big.Int
- func Bpowapprox(base, exp, precision *big.Int) *big.Int
- func Bpowi(a, n *big.Int) *big.Int
- func Bsub(a, b *big.Int) *big.Int
- func Bsubsign(a, b *big.Int) (*big.Int, bool)
- func Btoi(a *big.Int) *big.Int
- func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int
- func CalcSpotPrice(...) *big.Int
- func GetChangePercentageBig(final, start *big.Int) float64
- func GetGasPrice(ctx context.Context, backend bind.ContractBackend, ...) (*big.Int, error)
- func IsValidAddress(iaddress interface{}) bool
- func IsZeroAddress(iaddress interface{}) bool
- func NewAccount(keyFileDir, keyPass string) (accounts.Account, error)
- func PoolTokensFor(bindings *sigmacore.Sigmacore, backend bind.ContractBackend) (map[string]common.Address, error)
- func PublicKeyBytesToAddress(publicKey []byte) common.Address
- func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)
- func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal
- func ToWei(iamount interface{}, decimals int) *big.Int
- type Authorizer
- type Breaker
Constants ¶
This section is empty.
Variables ¶
var ( // BPOWPRECISION ... BPOWPRECISION = new(big.Int).Div( BONE(), new(big.Int).Exp(big.NewInt(10), big.NewInt(10), nil), ) )
var ( // SwapFee 2.5% in wei SwapFee = big.NewInt(25000000000000000) )
Functions ¶
func Bdiv ¶
Bdiv ... TODO(bonedaddy): right now we check for division by 0 and return 0 however this may not be good
func BoostGasPrice ¶ added in v0.0.4
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 CalcGasCost ¶
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 ¶
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 ¶
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 ¶
PublicKeyBytesToAddress ...
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