-
Notifications
You must be signed in to change notification settings - Fork 44
/
common.go
45 lines (36 loc) · 1.29 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2023 The AthanorLabs/atomic-swap Authors
// SPDX-License-Identifier: LGPL-3.0-only
package coins
import (
"math/big"
"github.com/cockroachdb/apd/v3"
logging "github.com/ipfs/go-log/v2"
)
const (
// NumEtherDecimals is the number of decimal points needed to represent whole units of Wei in Ether
NumEtherDecimals = 18
// NumMoneroDecimals is the number of decimal points needed to represent whole units of piconero in XMR
NumMoneroDecimals = 12
// MaxExchangeRateDecimals is the number of decimal points we allow in an exchange rate
MaxExchangeRateDecimals = 6
// MaxCoinPrecision is a somewhat arbitrary precision upper bound (2^256 consumes 78 digits)
MaxCoinPrecision = 100
)
// RelayerFeeWei and RelayerFeeETH are the fixed 0.01 ETH fee for using a swap
// relayer to claim.
var (
RelayerFeeWei = big.NewInt(1e16)
RelayerFeeETH = NewWeiAmount(RelayerFeeWei).AsEther()
)
var (
// decimalCtx is the apd context used for math operations on our coins
decimalCtx = apd.BaseContext.WithPrecision(MaxCoinPrecision)
log = logging.Logger("coins")
)
// DecimalCtx clones and returns the apd.Context we use for coin math operations.
func DecimalCtx() *apd.Context {
// return a clone to prevent external callers from modifying our context
c := new(apd.Context)
*c = *decimalCtx
return c
}