merge transactions and update
This commit is contained in:
@@ -6,6 +6,14 @@ import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
func BigIntETHToFloat64(value *big.Int) float64 {
|
||||
f := new(big.Float).SetInt(value)
|
||||
scale := new(big.Float).SetFloat64(1e18) // USDT 精度 6 位
|
||||
f.Quo(f, scale)
|
||||
result, _ := f.Float64()
|
||||
return result
|
||||
}
|
||||
|
||||
func BigIntUSDTToFloat64(value *big.Int) float64 {
|
||||
f := new(big.Float).SetInt(value)
|
||||
scale := new(big.Float).SetFloat64(1e6) // USDT 精度 6 位
|
||||
@@ -26,6 +34,16 @@ func Float64ToBigIntUSDT(amount float64) *big.Int {
|
||||
return bigAmount
|
||||
}
|
||||
|
||||
const ETHDecimals = 18
|
||||
|
||||
func Float64ToBigIntETH(amount float64) *big.Int {
|
||||
// 乘上精度系数
|
||||
scale := math.Pow10(ETHDecimals)
|
||||
bigAmount := new(big.Int)
|
||||
bigAmount.SetInt64(int64(amount * scale))
|
||||
return bigAmount
|
||||
}
|
||||
|
||||
func Slice_delete(arr []any, index int) []any {
|
||||
if index < 0 || index >= len(arr) {
|
||||
// 处理越界
|
||||
|
||||
Reference in New Issue
Block a user