merge transactions and update

This commit is contained in:
lzx
2025-10-31 13:46:58 +08:00
parent 056bc05b75
commit 8d7da5d345
12 changed files with 1154 additions and 975 deletions

View File

@@ -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) {
// 处理越界