diff --git a/.gitignore b/.gitignore index 7eb00ebf..477207c3 100644 --- a/.gitignore +++ b/.gitignore @@ -15,11 +15,10 @@ go-sidecar /internal/tests/testdata/*.sql !/internal/tests/testdata/**/generateExpectedResults.sql !/internal/tests/testdata/**/*generateExpectedResults.sql -!sqlite-extensions +sqlite-extensions /*.tar /sidecar-data __pycache__ test-db *.dylib *.dylib.dSYM -/sqlite-extensions/build diff --git a/Makefile b/Makefile index c120ea5c..9d0e8676 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,9 @@ PROJECT_ROOT = $(shell pwd) CGO_CFLAGS = "-I$(PROJECT_ROOT)/sqlite-extensions" CGO_LDFLAGS = "-L$(PROJECT_ROOT)/sqlite-extensions/build/lib -lcalculations -Wl,-rpath,$(PROJECT_ROOT)/sqlite-extensions/build/lib" -PYTHONPATH = $(PROJECT_ROOT)/sqlite-extensions CGO_ENABLED = 1 GO=$(shell which go) -ALL_FLAGS=CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) PYTHONPATH=$(PYTHONPATH) CGO_ENABLED=$(CGO_ENABLED) +ALL_FLAGS=CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) deps/dev: ${GO} install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 diff --git a/cmd/debugger/main.go b/cmd/debugger/main.go index e45f3e0f..f633caa1 100644 --- a/cmd/debugger/main.go +++ b/cmd/debugger/main.go @@ -168,7 +168,7 @@ staker_weight_sum AS ( -- Calculate staker proportion of tokens for each reward and snapshot staker_proportion AS ( SELECT *, - calculate_staker_proportion(staker_weight, total_weight) as staker_proportion + staker_weight(staker_weight, total_weight) as staker_proportion FROM staker_weight_sum ), -- Calculate total tokens to the (staker, operator) pair diff --git a/internal/sqlite/sqlite_test.go b/internal/sqlite/sqlite_test.go index 067740c4..c9dd5e70 100644 --- a/internal/sqlite/sqlite_test.go +++ b/internal/sqlite/sqlite_test.go @@ -6,7 +6,6 @@ import ( "github.com/Layr-Labs/go-sidecar/internal/logger" "github.com/Layr-Labs/go-sidecar/internal/tests" "github.com/Layr-Labs/go-sidecar/internal/types/numbers" - "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "math/big" "strings" @@ -401,16 +400,6 @@ func Test_Sqlite(t *testing.T) { }) t.Run("Should call subtract_big to determine nile staker token total", func(t *testing.T) { values := [][]string{ - []string{"17169644785714300", "1716964478571430", "15452680307142870"}, - []string{"13047198500000000", "1304719850000000", "11742478650000000"}, - []string{"13045523500000000", "1304552350000000", "11740971150000000"}, - []string{"247865428857143000", "24786542885714300", "223078885971428700"}, - []string{"1565636357214280000", "156563635721428000", "1409072721492852000"}, - []string{"260967146714285000", "26096714671428500", "234870432042856500"}, - []string{"65248491499999900", "6524849149999990", "58723642349999910"}, - []string{"930521285714285", "93052128571429", "837469157142856"}, - []string{"182449737714286000", "18244973771428600", "164204763942857400"}, - []string{"130482029071428000", "13048202907142800", "117433826164285200"}, []string{"130499930214286000", "13049993021428600", "117449937192857400"}, []string{"13048257857142800", "1304825785714280", "11743432071428520"}, []string{"13048983500000000", "1304898350000000", "11744085150000000"}, @@ -873,97 +862,232 @@ func Test_Sqlite(t *testing.T) { } }) - t.Run("Should call pre_nile_tokens_per_day", func(t *testing.T) { - expectedRoundedValue := "1428571428571427000000000000000000000" - amount := "1428571428571428571428571428571428571.4142857142857143" - - query := `select pre_nile_tokens_per_day(@amount) as amt` - - var result string - res := grm.Raw(query, sql.Named("amount", amount)).Scan(&result) - assert.Nil(t, res.Error) - - assert.Equal(t, expectedRoundedValue, result) - - }) - t.Run("Should call big_gt", func(t *testing.T) { - query := `select big_gt('100', '1') as gt` - - var result string - res := grm.Raw(query).Scan(&result) - assert.Nil(t, res.Error) + t.Run("Should calculate staker_weight", func(t *testing.T) { + values := [][]string{ + []string{"13158805058146234", "1000000000000000000", "13158805058146234000000000000000000"}, + []string{"9999364785152858", "1000000000000000000", "9999364785152858000000000000000000"}, + []string{"9998081065486055", "1000000000000000000", "9998081065486055000000000000000000"}, + []string{"189963909570445811", "1000000000000000000", "189963909570445811000000000000000000"}, + []string{"1199902724321458843", "1000000000000000000", "1199902724321458843000000000000000000"}, + []string{"200005057929420026", "1000000000000000000", "200005057929420026000000000000000000"}, + []string{"50006403057525667", "1000000000000000000", "50006403057525667000000000000000000"}, + []string{"713150974062098", "1000000000000000000", "713150974062098000000000000000000"}, + []string{"139829364839022106", "1000000000000000000", "139829364839022106000000000000000000"}, + []string{"100001345456859160", "1000000000000000000", "100001345456859160000000000000000000"}, + []string{"100015064883912861", "1000000000000000000", "100015064883912861000000000000000000"}, + []string{"10000176664164377", "1000000000000000000", "10000176664164377000000000000000000"}, + []string{"10000732792609186", "1000000000000000000", "10000732792609186000000000000000000"}, + []string{"129536536258621628", "1000000000000000000", "129536536258621628000000000000000000"}, + []string{"89986529087712698", "1000000000000000000", "89986529087712698000000000000000000"}, + []string{"20264086525799182", "1000000000000000000", "20264086525799182000000000000000000"}, + []string{"10001033984234808", "1000000000000000000", "10001033984234808000000000000000000"}, + []string{"19998808971092736", "1000000000000000000", "19998808971092736000000000000000000"}, + []string{"10000252896470999", "1000000000000000000", "10000252896470999000000000000000000"}, + []string{"10001661669275669", "1000000000000000000", "10001661669275669000000000000000000"}, + []string{"10000252896470999", "1000000000000000000", "10000252896470999000000000000000000"}, + []string{"1000139432872258", "1000000000000000000", "1000139432872258000000000000000000"}, + []string{"10000523122233921", "1000000000000000000", "10000523122233921000000000000000000"}, + []string{"108794543161201484", "1000000000000000000", "108794543161201484000000000000000000"}, + []string{"2299904805372099", "1000000000000000000", "2299904805372099000000000000000000"}, + []string{"39994957302141046", "1000000000000000000", "39994957302141046000000000000000000"}, + []string{"10000252896470999", "1000000000000000000", "10000252896470999000000000000000000"}, + []string{"2159994041550644", "1000000000000000000", "2159994041550644000000000000000000"}, + []string{"20001336759567112", "1000000000000000000", "20001336759567112000000000000000000"}, + []string{"10000292534902202", "1000000000000000000", "10000292534902202000000000000000000"}, + []string{"17001612282874646", "1000000000000000000", "17001612282874646000000000000000000"}, + []string{"231392865505452729", "1000000000000000000", "231392865505452729000000000000000000"}, + []string{"20003963525374208", "1000000000000000000", "20003963525374208000000000000000000"}, + []string{"9699637649482331", "1000000000000000000", "9699637649482331000000000000000000"}, + []string{"89992671119371290", "1000000000000000000", "89992671119371290000000000000000000"}, + []string{"10000097319601699", "1000000000000000000", "10000097319601699000000000000000000"}, + []string{"150020579831281257", "1000000000000000000", "150020579831281257000000000000000000"}, + []string{"140001883639602", "1000000000000000000", "140001883639602000000000000000000"}, + []string{"99990867261032430", "1000000000000000000", "99990867261032430000000000000000000"}, + []string{"8999127766375318", "1000000000000000000", "8999127766375318000000000000000000"}, + []string{"149994396641479371", "1000000000000000000", "149994396641479371000000000000000000"}, + []string{"1999925288553057", "1000000000000000000", "1999925288553057000000000000000000"}, + []string{"9999972414586314", "1000000000000000000", "9999972414586314000000000000000000"}, + []string{"4998532688913282", "1000000000000000000", "4998532688913282000000000000000000"}, + []string{"9999886339713653", "1000000000000000000", "9999886339713653000000000000000000"}, + []string{"399940129278723107", "1000000000000000000", "399940129278723107000000000000000000"}, + []string{"10000969575399225", "1000000000000000000", "10000969575399225000000000000000000"}, + []string{"260015207465923335", "1000000000000000000", "260015207465923335000000000000000000"}, + []string{"10420877317096921", "1000000000000000000", "10420877317096921000000000000000000"}, + []string{"9999992293003591", "1000000000000000000", "9999992293003591000000000000000000"}, + []string{"19999088400836594", "1000000000000000000", "19999088400836594000000000000000000"}, + []string{"149991067283195529", "1000000000000000000", "149991067283195529000000000000000000"}, + []string{"9999325189405631", "1000000000000000000", "9999325189405631000000000000000000"}, + []string{"3400411111942158", "1000000000000000000", "3400411111942158000000000000000000"}, + []string{"2713521828358300", "1000000000000000000", "2713521828358300000000000000000000"}, + []string{"50006971643613936", "1000000000000000000", "50006971643613936000000000000000000"}, + []string{"9994968850883750", "1000000000000000000", "9994968850883750000000000000000000"}, + []string{"89994640369917315", "1000000000000000000", "89994640369917315000000000000000000"}, + []string{"9999905203944115", "1000000000000000000", "9999905203944115000000000000000000"}, + []string{"1000137198875208", "1000000000000000000", "1000137198875208000000000000000000"}, + []string{"20119167253950711", "1000000000000000000", "20119167253950711000000000000000000"}, + []string{"399980839626450", "1000000000000000000", "399980839626450000000000000000000"}, + []string{"9999886339713653", "1000000000000000000", "9999886339713653000000000000000000"}, + []string{"1000141804762845", "1000000000000000000", "1000141804762845000000000000000000"}, + []string{"9000453889405794", "1000000000000000000", "9000453889405794000000000000000000"}, + []string{"1519923764752078", "1000000000000000000", "1519923764752078000000000000000000"}, + []string{"22004135637469614", "1000000000000000000", "22004135637469614000000000000000000"}, + []string{"6800904002516954", "1000000000000000000", "6800904002516954000000000000000000"}, + []string{"26400667646683442", "1000000000000000000", "26400667646683442000000000000000000"}, + []string{"40001639538742316", "1000000000000000000", "40001639538742316000000000000000000"}, + []string{"10000886258782987", "1000000000000000000", "10000886258782987000000000000000000"}, + []string{"49996039082111120", "1000000000000000000", "49996039082111120000000000000000000"}, + []string{"99995636121212778", "1000000000000000000", "99995636121212778000000000000000000"}, + []string{"9999972414586314", "1000000000000000000", "9999972414586314000000000000000000"}, + []string{"9999458955488709", "1000000000000000000", "9999458955488709000000000000000000"}, + []string{"20000434613056493", "1000000000000000000", "20000434613056493000000000000000000"}, + []string{"10001801566334099", "1000000000000000000", "10001801566334099000000000000000000"}, + []string{"10000176664164377", "1000000000000000000", "10000176664164377000000000000000000"}, + []string{"19899046771415971", "1000000000000000000", "19899046771415971000000000000000000"}, + []string{"9999586110313474", "1000000000000000000", "9999586110313474000000000000000000"}, + []string{"55000740001272537", "1000000000000000000", "55000740001272537000000000000000000"}, + []string{"10000732792609186", "1000000000000000000", "10000732792609186000000000000000000"}, + []string{"4999943169856827", "1000000000000000000", "4999943169856827000000000000000000"}, + []string{"10999344934101003", "1000000000000000000", "10999344934101003000000000000000000"}, + []string{"10000176664164377", "1000000000000000000", "10000176664164377000000000000000000"}, + []string{"10001418047628453", "1000000000000000000", "10001418047628453000000000000000000"}, + []string{"99994400740112833", "1000000000000000000", "99994400740112833000000000000000000"}, + []string{"90011291802189283", "1000000000000000000", "90011291802189283000000000000000000"}, + []string{"40005018578750792", "1000000000000000000", "40005018578750792000000000000000000"}, + []string{"129719054320668439", "1000000000000000000", "129719054320668439000000000000000000"}, + []string{"10000732792609186", "1000000000000000000", "10000732792609186000000000000000000"}, + []string{"319976776748853840", "1000000000000000000", "319976776748853840000000000000000000"}, + []string{"20000395457384652", "1000000000000000000", "20000395457384652000000000000000000"}, + []string{"100009695753992276", "1000000000000000000", "100009695753992276000000000000000000"}, + []string{"10000647038790859", "1000000000000000000", "10000647038790859000000000000000000"}, + []string{"10000409884685577", "1000000000000000000", "10000409884685577000000000000000000"}, + []string{"499994316985682", "1000000000000000000", "499994316985682000000000000000000"}, + []string{"10001418047628453", "1000000000000000000", "10001418047628453000000000000000000"}, + []string{"10000176664164377", "1000000000000000000", "10000176664164377000000000000000000"}, + []string{"29999659019140964", "1000000000000000000", "29999659019140964000000000000000000"}, + } - assert.Equal(t, "1", result) - }) - t.Run("Should call numeric_multiply_c", func(t *testing.T) { - query := `select numeric_multiply_c('100', '.1')` + for _, v := range values { + shares := v[0] + multiplier := v[1] + expectedResult := v[2] - var result string - res := grm.Raw(query).Scan(&result) - assert.Nil(t, res.Error) + query := `select staker_weight(@shares, @multiplier) as amt` + var result string + res := grm.Raw(query, sql.Named("shares", shares), sql.Named("multiplier", multiplier)).Scan(&result) + assert.Nil(t, res.Error) - assert.Equal(t, "10.0", result) + assert.Equal(t, expectedResult, result, "shares: %s, multiplier %s", shares, multiplier) + } }) - t.Run("Should call calculate_staker_proportion", func(t *testing.T) { + t.Run("Should calculate staker_proportion", func(t *testing.T) { values := [][]string{ - []string{"2586595906852124520000000000000000000", "78563914570073760561000000000000000000", "0.03292346010260200000"}, - []string{"75370449903508156204000000000000000000", "78563914570073760561000000000000000000", "0.95935201696553300000"}, - []string{"596939049887864861000000000000000000", "78563914570073760561000000000000000000", "0.00759813271976700000"}, - []string{"9929709825614976000000000000000000", "78563914570073760561000000000000000000", "0.00012639021209600000"}, - []string{"2586595906852124520000000000000000000", "78563914570073760561000000000000000000", "0.03292346010260200000"}, - []string{"75370449903508156204000000000000000000", "78563914570073760561000000000000000000", "0.95935201696553300000"}, - []string{"596939049887864861000000000000000000", "78563914570073760561000000000000000000", "0.00759813271976700000"}, - []string{"9929709825614976000000000000000000", "78563914570073760561000000000000000000", "0.00012639021209600000"}, - []string{"2000000000000000000000000000000000000000", "2000000000000000000000000000000000000000", "1.00000000000000000000"}, - []string{"2000000000000000000000000000000000000000", "2000000000000000000000000000000000000000", "1.00000000000000000000"}, + []string{"2586595906852124520000000000000000000", "172903758432139976825000000000000000000", "0.014959743676522"}, + []string{"112607037019262979531000000000000000000", "172903758432139976825000000000000000000", "0.651270036234973"}, + []string{"23922257075907518899000000000000000000", "172903758432139976825000000000000000000", "0.138355911362657"}, + []string{"1180752781363484185000000000000000000", "172903758432139976825000000000000000000", "0.006828959601979"}, + []string{"32000246889040389853000000000000000000", "172903758432139976825000000000000000000", "0.185075484646562"}, + []string{"596939049887864861000000000000000000", "172903758432139976825000000000000000000", "0.003452435362312"}, + []string{"9929709825614976000000000000000000", "172903758432139976825000000000000000000", "0.000057429114992"}, + []string{"2586595906852124520000000000000000000", "672903758432139976825000000000000000000", "0.003843931430668"}, + []string{"112607037019262979531000000000000000000", "672903758432139976825000000000000000000", "0.167344936936652"}, + []string{"23922257075907518899000000000000000000", "672903758432139976825000000000000000000", "0.035550785348035"}, + []string{"1180752781363484185000000000000000000", "672903758432139976825000000000000000000", "0.0017547127157"}, + []string{"32000246889040389853000000000000000000", "672903758432139976825000000000000000000", "0.047555458693826"}, + []string{"500596939049887864861000000000000000000", "672903758432139976825000000000000000000", "0.743935418366921"}, + []string{"9929709825614976000000000000000000", "672903758432139976825000000000000000000", "0.000014756508194"}, } for _, v := range values { stakerWeight := v[0] totalWeight := v[1] - stakerProportion := v[2] - - query := `select calculate_staker_proportion(@stakerWeight, @totalWeight)` + expectedResult := v[2] + query := `select staker_proportion(@stakerWeight, @totalWeight) as amt` var result string res := grm.Raw(query, sql.Named("stakerWeight", stakerWeight), sql.Named("totalWeight", totalWeight)).Scan(&result) assert.Nil(t, res.Error) - resultDecimal, _ := decimal.NewFromString(result) - expectedDecimal, _ := decimal.NewFromString(stakerProportion) - - assert.Equal(t, resultDecimal.Equal(expectedDecimal), true) - } - }) - - t.Run("Should use the bytesToHex function", func(t *testing.T) { - query := ` - with json_values as ( - select - cast('{"newWithdrawalRoot": [218, 200, 138, 86, 38, 9, 156, 119, 73, 13, 168, 40, 209, 43, 238, 83, 234, 177, 230, 73, 120, 205, 255, 143, 255, 216, 51, 209, 137, 100, 163, 233] }' as text) as json_col - from (select 1) - ) - select - bytes_to_hex(json_extract(json_col, '$.newWithdrawalRoot')) AS withdrawal_hex - from json_values - limit 1 - ` - - type results struct { - WithdrawalHex string + assert.Equal(t, expectedResult, result, "stakerWeight: %s, totalWeight %s", stakerWeight, totalWeight) } - - hexValue := &results{} - res := grm.Raw(query).Scan(&hexValue) - - expectedBytes := []byte{218, 200, 138, 86, 38, 9, 156, 119, 73, 13, 168, 40, 209, 43, 238, 83, 234, 177, 230, 73, 120, 205, 255, 143, 255, 216, 51, 209, 137, 100, 163, 233} - - assert.Nil(t, res.Error) - assert.Equal(t, strings.ToLower(hex.EncodeToString(expectedBytes)), hexValue.WithdrawalHex) }) t.Run("Should call calc_tokens_per_day", func(t *testing.T) { values := [][]string{ + []string{"1000000000000000000000000", "604800", "142857142857142857142857"}, + []string{"1000000000000000000000000", "604800", "142857142857142857142857"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"1000000000000000000000000000000", "6048000", "14285714285714285714285714286"}, + []string{"1000000000000000000000000000000", "6048000", "14285714285714285714285714286"}, + []string{"1000000000000000000000000000000", "1814400", "47619047619047619047619047619"}, + []string{"1000000000000000000000000000000", "1814400", "47619047619047619047619047619"}, + []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, + []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, + []string{"1000000000", "1814400", "47619047.619047619048"}, + []string{"1000000000", "1814400", "47619047.619047619048"}, + []string{"99999999999999999999999999999999999999", "1209600", "7142857142857142857142857142857142857"}, + []string{"99999999999999999999999999999999999999", "1209600", "7142857142857142857142857142857142857"}, + []string{"195999999000000000", "6048000", "2799999985714285.7143"}, + []string{"195999999000000000", "6048000", "2799999985714285.7143"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"1000000000000000000000000000000", "3628800", "23809523809523809523809523810"}, + []string{"1000000000000000000000000000000", "3628800", "23809523809523809523809523810"}, + []string{"1000000000000000000000000000000", "3628800", "23809523809523809523809523810"}, + []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, + []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, + []string{"99999999999999999999999999999999999999", "2419200", "3571428571428571428571428571428571429"}, + []string{"99999999999999999999999999999999999999", "2419200", "3571428571428571428571428571428571429"}, + []string{"100000000000000000000", "4838400", "1785714285714285714"}, + []string{"100000000000000000000", "4838400", "1785714285714285714"}, + []string{"1000000000000000000000000000000", "1814400", "47619047619047619047619047619"}, + []string{"1000000000000000000000000000000", "1814400", "47619047619047619047619047619"}, + []string{"1550000000000000000000000000000", "2419200", "55357142857142857142857142857"}, + []string{"1550000000000000000000000000000", "2419200", "55357142857142857142857142857"}, + []string{"1550000000000000000000000000000", "3628800", "36904761904761904761904761905"}, + []string{"1550000000000000000000000000000", "3628800", "36904761904761904761904761905"}, + []string{"10000000000000000000", "6048000", "142857142857142857"}, + []string{"10000000000000000000", "6048000", "142857142857142857"}, + []string{"10000000000000000000", "1209600", "714285714285714286"}, + []string{"10000000000000000000", "1209600", "714285714285714286"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, + []string{"10000000000000000000", "1814400", "476190476190476190"}, []string{"9999000000000000000000", "604800", "1428428571428571428571"}, []string{"1", "1209600", "0.07142857142857142857"}, []string{"1000000000000000000000", "604800", "142857142857142857143"}, @@ -984,9 +1108,21 @@ func Test_Sqlite(t *testing.T) { []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, + []string{"1000000000000000000000", "604800", "142857142857142857143"}, []string{"5000000000000000000000000", "6048000", "71428571428571428571429"}, []string{"5000000000000000000000000", "6048000", "71428571428571428571429"}, []string{"10000000", "1209600", "714285.714285714286"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, + []string{"1000000000000000000000000", "2419200", "35714285714285714285714"}, []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, @@ -1002,13 +1138,13 @@ func Test_Sqlite(t *testing.T) { []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, } - for _, v := range values[:10] { + for _, v := range values { amount := v[0] duration := v[1] expectedResult := v[2] var result string - query := `select calc_tokens_per_day(@amount, @duration)` + query := `select tokens_per_day(@amount, @duration)` res := grm.Raw(query, sql.Named("amount", amount), sql.Named("duration", duration)).Scan(&result) assert.Nil(t, res.Error) @@ -1018,51 +1154,329 @@ func Test_Sqlite(t *testing.T) { }) t.Run("Should call calc_tokens_per_day_decimal", func(t *testing.T) { values := [][]string{ - []string{"9999000000000000000000", "604800", "1428428571428571428571"}, - []string{"1", "1209600", "0"}, - []string{"1000000000000000000000", "604800", "142857142857142857143"}, + []string{"10000000000000000000000", "2419200", "357142857142857142857"}, []string{"100000000000000000000", "604800", "14285714285714285714"}, []string{"100000000000000000000", "604800", "14285714285714285714"}, - []string{"99999999999999999999999999999999999999", "2419200", "3571428571428571428571428571428571429"}, - []string{"99999999999999999999999999999999999999", "2419200", "3571428571428571428571428571428571429"}, - []string{"10000000", "1209600", "714285"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"5000000000000000", "604800", "714285714285714"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"100000000000000000", "2419200", "3571428571428571"}, + []string{"10000000000000000000", "1209600", "714285714285714286"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, + []string{"11000000000000000000", "2419200", "392857142857142857"}, []string{"1000000000000000000", "604800", "142857142857142857"}, - []string{"1222333444000000000000000000", "604800", "174619063428571428571428571"}, - []string{"9998887771000000000000000000", "604800", "1428412538714285714285714286"}, - []string{"9998887771000000000000000000", "604800", "1428412538714285714285714286"}, - []string{"100", "604800", "14"}, - []string{"100000000000000000000000000000000", "604800", "14285714285714285714285714285714"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, - []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, - []string{"1000000000000000000000000000000", "1209600", "71428571428571428571428571429"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, - []string{"5000000000000000000000000", "6048000", "71428571428571428571429"}, - []string{"5000000000000000000000000", "6048000", "71428571428571428571429"}, - []string{"10000000", "1209600", "714285"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, - []string{"1000000000000000000000000000000", "2419200", "35714285714285714285714285714"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, - []string{"1000000000000000000000000000", "5443200", "15873015873015873015873016"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"1000000000000000000", "604800", "142857142857142857"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"87000000000000000000", "2419200", "3107142857142857143"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"500000000000000000", "1209600", "35714285714285714"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"100000000000000000", "604800", "14285714285714286"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"7000000000000000000", "2419200", "250000000000000000"}, + []string{"500000000000000000", "604800", "71428571428571429"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"101000000000000000000", "604800", "14428571428571428571"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"10000000000000000000", "604800", "1428571428571428571"}, + []string{"10000000000000000000", "604800", "1428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"1000000000000000000000", "1209600", "71428571428571428571"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"100000000000000000000", "604800", "14285714285714285714"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"1000000000000000", "2419200", "35714285714285"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"10500000000000000000000", "1209600", "750000000000000000000"}, + []string{"3500000000000000000000", "1209600", "250000000000000000000"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"5000000000000000000", "2419200", "178571428571428571"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"49000000000000000000000", "6048000", "700000000000000000000"}, + []string{"21000000000000000000000", "6048000", "300000000000000000000"}, + []string{"70000000000000000000000", "6048000", "1000000000000000000000"}, + []string{"1931130771097684615384620", "3628800", "45979304073754395604396"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"5793392313293053846153848", "3628800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"321855128516280769230770", "604800", "45979304073754395604396"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, + []string{"965565385548842307692308", "604800", "137937912221263186813187"}, } - for _, v := range values[:10] { + for _, v := range values { amount := v[0] duration := v[1] expectedResult := v[2] var result string - query := `select calc_tokens_per_day_decimal(@amount, @duration)` + query := `select tokens_per_day_decimal(@amount, @duration)` res := grm.Raw(query, sql.Named("amount", amount), sql.Named("duration", duration)).Scan(&result) assert.Nil(t, res.Error) @@ -1070,7 +1484,42 @@ func Test_Sqlite(t *testing.T) { } }) - t.Run("Should add two really big numbers that are stored as strings", func(t *testing.T) { + + t.Run("Should call big_gt", func(t *testing.T) { + query := `select big_gt('100', '1') as gt` + + var result string + res := grm.Raw(query).Scan(&result) + assert.Nil(t, res.Error) + + assert.Equal(t, "1", result) + }) + t.Run("Should use the bytesToHex function", func(t *testing.T) { + query := ` + with json_values as ( + select + cast('{"newWithdrawalRoot": [218, 200, 138, 86, 38, 9, 156, 119, 73, 13, 168, 40, 209, 43, 238, 83, 234, 177, 230, 73, 120, 205, 255, 143, 255, 216, 51, 209, 137, 100, 163, 233] }' as text) as json_col + from (select 1) + ) + select + bytes_to_hex(json_extract(json_col, '$.newWithdrawalRoot')) AS withdrawal_hex + from json_values + limit 1 + ` + + type results struct { + WithdrawalHex string + } + + hexValue := &results{} + res := grm.Raw(query).Scan(&hexValue) + + expectedBytes := []byte{218, 200, 138, 86, 38, 9, 156, 119, 73, 13, 168, 40, 209, 43, 238, 83, 234, 177, 230, 73, 120, 205, 255, 143, 255, 216, 51, 209, 137, 100, 163, 233} + + assert.Nil(t, res.Error) + assert.Equal(t, strings.ToLower(hex.EncodeToString(expectedBytes)), hexValue.WithdrawalHex) + }) + t.Run("Should call add_big", func(t *testing.T) { shares1 := "1670000000000000000000" shares2 := "1670000000000000000000" @@ -1100,7 +1549,7 @@ func Test_Sqlite(t *testing.T) { query := ` select - sum_big_c(shares) as total + add_big(shares) as total from shares ` var total string diff --git a/internal/types/numbers/numbersData_test.go b/internal/types/numbers/numbersData_test.go deleted file mode 100644 index 3fcc00c2..00000000 --- a/internal/types/numbers/numbersData_test.go +++ /dev/null @@ -1,559 +0,0 @@ -package numbers - -var ( - operatorAmazonTokens = [][]string{ - []string{"2262498437750000", "226249843775000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"1200335945500000", "120033594550000"}, - []string{"2579821510500000", "257982151050000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"97982205000000", "9798220500000"}, - []string{"2731616159750000", "273161615975000"}, - []string{"1468013852500000", "146801385250000"}, - []string{"1460746763500000", "146074676350000"}, - []string{"97982205000000", "9798220500000"}, - []string{"2160308386500000", "216030838650000"}, - []string{"2173632496000000", "217363249600000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1205181123750000", "120518112375000"}, - []string{"1692326232750000", "169232623275000"}, - []string{"19596441000000", "1959644100000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"2766886967000000", "276688696700000"}, - []string{"1421109574750000", "142110957475000"}, - []string{"1327025256750000", "132702525675000"}, - []string{"1513152979750000", "151315297975000"}, - []string{"1724319284250000", "172431928425000"}, - []string{"1881072278500000", "188107227850000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"2767046562250000", "276704656225000"}, - []string{"1771544047250000", "177154404725000"}, - []string{"979822051749999", "97982205175000"}, - []string{"2766618839500000", "276661883950000"}, - []string{"1111499405000000", "111149940500000"}, - []string{"1256537372500000", "125653737250000"}, - []string{"1311309356750000", "131130935675000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"1476639073750000", "147663907375000"}, - []string{"619368817749999", "61936881775000"}, - []string{"2351572924250000", "235157292425000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"38824366794750000", "3882436679475000"}, - []string{"1329923441750000", "132992344175000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"1171094469500000", "117109446950000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"2164538730000000", "216453873000000"}, - []string{"2094265522500000", "209426552250000"}, - []string{"1448972310750000", "144897231075000"}, - []string{"1077804257000000", "107780425700000"}, - []string{"1403751361500000", "140375136150000"}, - []string{"979822051749999", "97982205175000"}, - } - - operatorNileTokens = [][]string{ - []string{"2262498437749998", "226249843775000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1200335945499999", "120033594550000"}, - []string{"2579821510499997", "257982151050000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"97982205000000", "9798220500000"}, - []string{"2731616159749997", "273161615975000"}, - []string{"1468013852499999", "146801385250000"}, - []string{"1460746763499999", "146074676350000"}, - []string{"97982205000000", "9798220500000"}, - []string{"2160308386499998", "216030838650000"}, - []string{"2173632495999998", "217363249600000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1205181123749999", "120518112375000"}, - []string{"1692326232749998", "169232623275000"}, - []string{"19596441000000", "1959644100000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766886966999997", "276688696700000"}, - []string{"1421109574749999", "142110957475000"}, - []string{"1327025256749999", "132702525675000"}, - []string{"1513152979749999", "151315297975000"}, - []string{"1724319284249998", "172431928425000"}, - []string{"1881072278499998", "188107227850000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2767046562249997", "276704656225000"}, - []string{"1771544047249998", "177154404725000"}, - []string{"979822051749999", "97982205175000"}, - []string{"2766618839499997", "276661883950000"}, - []string{"1111499404999999", "111149940500000"}, - []string{"1256537372499999", "125653737250000"}, - []string{"1311309356749999", "131130935675000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1476639073749999", "147663907375000"}, - []string{"619368817749999", "61936881775000"}, - []string{"2351572924249998", "235157292425000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"38824366794749960", "3882436679474996"}, - []string{"1329923441749999", "132992344175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1171094469499999", "117109446950000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2164538729999998", "216453873000000"}, - []string{"2094265522499998", "209426552250000"}, - []string{"1448972310749999", "144897231075000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1403751361499999", "140375136150000"}, - []string{"979822051749999", "97982205175000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1085802969749999", "108580296975000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1124308426749999", "112430842675000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1182901487499999", "118290148750000"}, - []string{"1372466011999999", "137246601200000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1120320939499999", "112032093950000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2813743578249997", "281374357825000"}, - []string{"1997209544499998", "199720954450000"}, - []string{"342937718000000", "34293771800000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2504518724749998", "250451872475000"}, - []string{"489911025749999", "48991102575000"}, - []string{"1169357997749999", "116935799775000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1263158553749999", "126315855375000"}, - []string{"1094640640499999", "109464064050000"}, - []string{"1284065770249999", "128406577025000"}, - []string{"1521653686749998", "152165368675000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1695020089999998", "169502009000000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1089590665249999", "108959066525000"}, - []string{"4333353594249996", "433335359425000"}, - []string{"979822051749999", "97982205175000"}, - []string{"2766860861499997", "276686086150000"}, - []string{"3737419616999996", "373741961700000"}, - []string{"1682669036499998", "168266903650000"}, - []string{"979822051749999", "97982205175000"}, - []string{"718515954363749200", "71851595436374920"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3350684550249997", "335068455025000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766670760499997", "276667076050000"}, - []string{"1139779232999999", "113977923300000"}, - []string{"1294703182249999", "129470318225000"}, - []string{"1401943427499999", "140194342750000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"8661942075499991", "866194207549999"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"979822051749999", "97982205175000"}, - []string{"9798220500000", "979822050000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1329616345749999", "132961634575000"}, - []string{"2285721732999998", "228572173300000"}, - []string{"440830750000", "44083075000"}, - []string{"1309869932249999", "130986993225000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2767143131249997", "276714313125000"}, - []string{"1087449895749999", "108744989575000"}, - []string{"1440582461749999", "144058246175000"}, - []string{"1437596903499999", "143759690350000"}, - []string{"3739760468499996", "373976046850000"}, - []string{"1228930342749999", "122893034275000"}, - []string{"1668502454499998", "166850245450000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"20400709468749976", "2040070946874998"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1501152824749998", "150115282475000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1588788984249999", "158878898425000"}, - []string{"97982205000000", "9798220500000"}, - []string{"2766955102999997", "276695510300000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1213777201499999", "121377720150000"}, - []string{"2766522236999998", "276652223700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1518724180249999", "151872418025000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"102040547000000", "10204054700000"}, - []string{"1521663646499999", "152166364650000"}, - []string{"2766883311999998", "276688331200000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1239913664499999", "123991366450000"}, - []string{"1083648329249999", "108364832925000"}, - []string{"2766567664499997", "276656766450000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"121497934250000", "12149793425000"}, - []string{"1489329518749999", "148932951875000"}, - []string{"705471877249999", "70547187725000"}, - []string{"1365074446999999", "136507444700000"}, - []string{"148259503000000", "14825950300000"}, - []string{"120582017500000", "12058201750000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3458772690249997", "345877269025000"}, - []string{"1096846600499999", "109684660050000"}, - []string{"2642116312499998", "264211631250000"}, - []string{"1186049670749999", "118604967075000"}, - []string{"3379361777249997", "337936177725000"}, - []string{"1073027971999999", "107302797200000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2205003116999998", "220500311700000"}, - []string{"1400476333249999", "140047633325000"}, - []string{"1334754243499999", "133475424350000"}, - []string{"75000261135249920", "7500026113524992"}, - []string{"2766917160499997", "276691716050000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"4081356354749996", "408135635475000"}, - []string{"115064965500000", "11506496550000"}, - []string{"140863986000000", "14086398600000"}, - []string{"1421544889999999", "142154489000000"}, - []string{"1249751425499999", "124975142550000"}, - []string{"1522711647499999", "152271164750000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766928990999997", "276692899100000"}, - []string{"1251222885499999", "125122288550000"}, - []string{"1804670182999998", "180467018300000"}, - []string{"1286074936749999", "128607493675000"}, - []string{"22474595357499976", "2247459535749998"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766772303499997", "276677230350000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1636477811999998", "163647781200000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766759761749998", "276675976175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2367891235249998", "236789123525000"}, - []string{"2111355676249998", "211135567625000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1335070157749999", "133507015775000"}, - []string{"1088824402499999", "108882440250000"}, - []string{"1591863078499998", "159186307850000"}, - []string{"1093209052249999", "109320905225000"}, - []string{"1231725361499999", "123172536150000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1188849744499999", "118884974450000"}, - []string{"1325974469749999", "132597446975000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1170727959499999", "117072795950000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766687807749997", "276668780775000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1195382903249999", "119538290325000"}, - []string{"131740039000000", "13174003900000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1584454986249999", "158445498625000"}, - []string{"1496388154999999", "149638815500000"}, - []string{"2783380170999997", "278338017100000"}, - []string{"2766853466749997", "276685346675000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1259437513249999", "125943751325000"}, - []string{"2559660094249998", "255966009425000"}, - []string{"97982205000000", "9798220500000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"7828778194249992", "782877819424999"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1138055195249999", "113805519525000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1192936111999999", "119293611200000"}, - []string{"1117604526499999", "111760452650000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"391928820500000", "39192882050000"}, - []string{"1671343943749998", "167134394375000"}, - []string{"1237619152499999", "123761915250000"}, - []string{"1461227295249999", "146122729525000"}, - []string{"536422250000", "53642225000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"746783849749999", "74678384975000"}, - []string{"8686889065749991", "868688906574999"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3577907333749997", "357790733375000"}, - []string{"9798220500000", "979822050000"}, - []string{"2766688656499997", "276668865650000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1190360713999999", "119036071400000"}, - []string{"1372170432249999", "137217043225000"}, - []string{"1180097737749999", "118009773775000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1231665739249999", "123166573925000"}, - []string{"1250928951499999", "125092895150000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1122446018749999", "112244601875000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3465020847749997", "346502084775000"}, - []string{"497502843250000", "49750284325000"}, - []string{"2766694622499997", "276669462250000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"9799200250000", "979920025000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3393183871249997", "339318387125000"}, - []string{"1224777564749999", "122477756475000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766784225749997", "276678422575000"}, - []string{"1084088666249999", "108408866625000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"120671798250000", "12067179825000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1207335820749999", "120733582075000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1708717776499998", "170871777650000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2171666879249998", "217166687925000"}, - []string{"2766540531749997", "276654053175000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1139514050249999", "113951405025000"}, - []string{"1347136987749999", "134713698775000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2373897634749998", "237389763475000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1296568008249999", "129656800825000"}, - []string{"1747592574499998", "174759257450000"}, - []string{"1718446376999998", "171844637700000"}, - []string{"97982205000000", "9798220500000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1126212608249999", "112621260825000"}, - []string{"1382620828249999", "138262082825000"}, - []string{"1827529957249998", "182752995725000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766997874749997", "276699787475000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3558586463999997", "355858646400000"}, - []string{"148139296000000", "14813929600000"}, - []string{"1228361717249999", "122836171725000"}, - []string{"1120021586249999", "112002158625000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"75838000000", "7583800000"}, - []string{"2813176036999997", "281317603700000"}, - []string{"1126418676499999", "112641867650000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1168952628749999", "116895262875000"}, - []string{"1286002109999999", "128600211000000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1106691471749999", "110669147175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2767147036499997", "276714703650000"}, - []string{"2766894477499997", "276689447750000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1221210601249999", "122121060125000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1474944833499998", "147494483350000"}, - []string{"3355500944749997", "335550094475000"}, - []string{"36042871697249960", "3604287169724996"}, - []string{"1077804256999999", "107780425700000"}, - []string{"103861137250000", "10386113725000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"7982080906749991", "798208090674999"}, - []string{"1077804256999999", "107780425700000"}, - []string{"6600292500000", "660029250000"}, - []string{"158317476750000", "15831747675000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1266130821999999", "126613082200000"}, - []string{"1087461430249999", "108746143025000"}, - []string{"1925894882749998", "192589488275000"}, - []string{"109489270750000", "10948927075000"}, - []string{"3011552248749997", "301155224875000"}, - []string{"5302500000", "530250000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1295497476749999", "129549747675000"}, - []string{"1514257759249998", "151425775925000"}, - []string{"1973412247749998", "197341224775000"}, - []string{"2612205589999997", "261220559000000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1215310149499999", "121531014950000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1087895020499999", "108789502050000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"147078692250000", "14707869225000"}, - []string{"2464874880999998", "246487488100000"}, - []string{"1166980098249999", "116698009825000"}, - []string{"734866538749999", "73486653875000"}, - []string{"2163704354999998", "216370435500000"}, - []string{"1281449592249999", "128144959225000"}, - []string{"1198409126249999", "119840912625000"}, - []string{"2767120898499997", "276712089850000"}, - []string{"1959088190749998", "195908819075000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1170951049999999", "117095105000000"}, - []string{"1154675041749999", "115467504175000"}, - []string{"1134384833499999", "113438483350000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1194101009249999", "119410100925000"}, - []string{"1388429900249999", "138842990025000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1122446018749999", "112244601875000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1731852292499998", "173185229250000"}, - []string{"1396115605249999", "139611560525000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1081755392249999", "108175539225000"}, - []string{"1115170505749999", "111517050575000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1880982576249998", "188098257625000"}, - []string{"1253732266249999", "125373226625000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"117578912750000", "11757891275000"}, - []string{"2766816535749997", "276681653575000"}, - []string{"1151717784499999", "115171778450000"}, - []string{"1073440472499999", "107344047250000"}, - []string{"1842220677249998", "184222067725000"}, - []string{"1444291238499999", "144429123850000"}, - []string{"185920687750000", "18592068775000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766739048249997", "276673904825000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1111127251249999", "111112725125000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2495212757249998", "249521275725000"}, - []string{"1109533228999999", "110953322900000"}, - []string{"1204528088999999", "120452808900000"}, - []string{"2767240998749997", "276724099875000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"27022701521749972", "2702270152174997"}, - []string{"1133721705999999", "113372170600000"}, - []string{"2766637369749997", "276663736975000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"979822051749999", "97982205175000"}, - []string{"861929137749999", "86192913775000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"3503727170499996", "350372717050000"}, - []string{"1060787189499999", "106078718950000"}, - []string{"979822051749999", "97982205175000"}, - []string{"2045249932249998", "204524993225000"}, - []string{"482354676250000", "48235467625000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1397360907249999", "139736090725000"}, - []string{"1175341173499999", "117534117350000"}, - []string{"2767044838249997", "276704483825000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1449542205249999", "144954220525000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2321707502749998", "232170750275000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1513531123249999", "151353112325000"}, - []string{"2740460193499997", "274046019350000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1149339404999999", "114933940500000"}, - []string{"1151809466249999", "115180946625000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1249904385249999", "124990438525000"}, - []string{"1096106635999999", "109610663600000"}, - []string{"6898005302249993", "689800530224999"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2766392857999997", "276639285800000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2921368330249997", "292136833025000"}, - []string{"1369704807999999", "136970480800000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"5006256564499995", "500625656450000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"109740069750000", "10974006975000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1346236941999999", "134623694200000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1103601738249999", "110360173825000"}, - []string{"2704308862999998", "270430886300000"}, - []string{"864763585499999", "86476358550000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1576305397999998", "157630539800000"}, - []string{"147299275500000", "14729927550000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1321185449499999", "132118544950000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1244374005749999", "124437400575000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"979822051749999", "97982205175000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"2175404280999998", "217540428100000"}, - []string{"2324262255249998", "232426225525000"}, - []string{"1087602477499999", "108760247750000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1226466551749999", "122646655175000"}, - []string{"2797069106499997", "279706910650000"}, - []string{"1122461615499999", "112246161550000"}, - []string{"1156738466749999", "115673846675000"}, - []string{"5920104740249994", "592010474024999"}, - []string{"1077804256999999", "107780425700000"}, - []string{"1077804256999999", "107780425700000"}, - []string{"13604498250000", "1360449825000"}, - []string{"1367625821749999", "136762582175000"}, - } -) diff --git a/internal/types/numbers/numbers_test.go b/internal/types/numbers/numbers_test.go index 1f736e0d..5603b29a 100644 --- a/internal/types/numbers/numbers_test.go +++ b/internal/types/numbers/numbers_test.go @@ -39,11 +39,6 @@ func roundToEven(f *big.Float) *big.Float { } func Test_Numbers(t *testing.T) { - if err := InitPython(); err != nil { - t.Error(err) - } - defer FinalizePython() - t.Run("Test that big.Int can produce negative numbers", func(t *testing.T) { startingNum := big.Int{} startingNum.SetString("10", 10) @@ -154,733 +149,4 @@ func Test_Numbers(t *testing.T) { assert.Equal(t, "0.999999999999999", one.Div(two).String()) }) - - //t.Run("Test CalculateStakerProportion", func(t *testing.T) { - // stakerWeight := "2586595906852124520000000000000000000" - // totalWeight := "78563914570073760561000000000000000000" - // - // amount, err := CalculateStakerProportion(stakerWeight, totalWeight) - // assert.Nil(t, err) - // assert.Equal(t, "1428571428571428571428571428571428571.4142857142857143", amount) - //}) - t.Run("Test CalcRawTokensPerDay", func(t *testing.T) { - amountStr := "99999999999999999999999999999999999999" - duration := uint64(6048000) - - amount, err := CalcRawTokensPerDay(amountStr, duration) - assert.Nil(t, err) - assert.Equal(t, "1428571428571428571428571428571428571.4142857142857143", amount) - }) - t.Run("Test PostNileTokensPerDay", func(t *testing.T) { - duration := uint64(6048000) - amountStr := "99999999999999999999999999999999999999" - expectedFloorValue := "1428571428571428571428571428571428571" - - amount, err := CalcRawTokensPerDay(amountStr, duration) - assert.Nil(t, err) - - amount, err = PostNileTokensPerDay(amount) - assert.Nil(t, err) - assert.Equal(t, expectedFloorValue, amount) - }) - t.Run("Test PreNileTokensPerDay", func(t *testing.T) { - duration := uint64(6048000) - amountStr := "99999999999999999999999999999999999999" - expectedRoundedValue := "1428571428571427000000000000000000000" - - amount, err := CalcRawTokensPerDay(amountStr, duration) - assert.Nil(t, err) - - amount, err = PreNileTokensPerDay(amount) - assert.Nil(t, err) - assert.Equal(t, expectedRoundedValue, amount) - }) - - t.Run("Staker tokens", func(t *testing.T) { - t.Run("Should correctly calculate the amazon token rewards for stakers", func(t *testing.T) { - values := [][]string{ - []string{"0.000009049993751000000000", "249999999999999740000", "2262498437750000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000004801343782000000000", "249999999999999740000", "1200335945500000"}, - []string{"0.000010319286042000000000", "249999999999999740000", "2579821510500000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000010926464639000000000", "249999999999999740000", "2731616159750000"}, - []string{"0.000005872055410000000000", "249999999999999740000", "1468013852500000"}, - []string{"0.000005842987054000000000", "249999999999999740000", "1460746763500000"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000008641233546000000000", "249999999999999740000", "2160308386500000"}, - []string{"0.000008694529984000000000", "249999999999999740000", "2173632496000000"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000004820724495000000000", "249999999999999740000", "1205181123750000"}, - []string{"0.000006769304931000000000", "249999999999999740000", "1692326232750000"}, - []string{"0.000000078385764000000000", "249999999999999740000", "19596441000000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000011067547868000000000", "249999999999999740000", "2766886967000000"}, - []string{"0.000005684438299000000000", "249999999999999740000", "1421109574750000"}, - []string{"0.000005308101027000000000", "249999999999999740000", "1327025256750000"}, - []string{"0.000006052611919000000000", "249999999999999740000", "1513152979750000"}, - []string{"0.000006897277137000000000", "249999999999999740000", "1724319284250000"}, - []string{"0.000007524289114000000000", "249999999999999740000", "1881072278500000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000011068186249000000000", "249999999999999740000", "2767046562250000"}, - []string{"0.000007086176189000000000", "249999999999999740000", "1771544047250000"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - []string{"0.000011066475358000000000", "249999999999999740000", "2766618839500000"}, - []string{"0.000004445997620000000000", "249999999999999740000", "1111499405000000"}, - []string{"0.000005026149490000000000", "249999999999999740000", "1256537372500000"}, - []string{"0.000005245237427000000000", "249999999999999740000", "1311309356750000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000005906556295000000000", "249999999999999740000", "1476639073750000"}, - []string{"0.000002477475271000000000", "249999999999999740000", "619368817749999"}, - []string{"0.000009406291697000000000", "249999999999999740000", "2351572924250000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.00015529746717900000", "249999999999999740000", "38824366794750000"}, - []string{"0.000005319693767000000000", "249999999999999740000", "1329923441750000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000004684377878000000000", "249999999999999740000", "1171094469500000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000008658154920000000000", "249999999999999740000", "2164538730000000"}, - []string{"0.000008377062090000000000", "249999999999999740000", "2094265522500000"}, - []string{"0.000005795889243000000000", "249999999999999740000", "1448972310750000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804257000000"}, - []string{"0.000005615005446000000000", "249999999999999740000", "1403751361500000"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - } - - for i, value := range values { - stakerProportion := value[0] - tokensPerDay := value[1] - expectedValue := value[2] - result, err := CalculateAmazonStakerTokenRewards(stakerProportion, tokensPerDay) - assert.Nil(t, err) - - assert.Equal(t, expectedValue, result, fmt.Sprintf("row %d: '%s' - '%s' - '%s'", i, stakerProportion, tokensPerDay, expectedValue)) - } - - }) - t.Run("Should correctly calculate the nile token rewards for stakers", func(t *testing.T) { - values := [][]string{ - []string{"0.000009049993751000000000", "249999999999999740000", "2262498437749998"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000004801343782000000000", "249999999999999740000", "1200335945499999"}, - []string{"0.000010319286042000000000", "249999999999999740000", "2579821510499997"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000010926464639000000000", "249999999999999740000", "2731616159749997"}, - []string{"0.000005872055410000000000", "249999999999999740000", "1468013852499999"}, - []string{"0.000005842987054000000000", "249999999999999740000", "1460746763499999"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000008641233546000000000", "249999999999999740000", "2160308386499998"}, - []string{"0.000008694529984000000000", "249999999999999740000", "2173632495999998"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000000391928820000000000", "249999999999999740000", "97982205000000"}, - []string{"0.000004820724495000000000", "249999999999999740000", "1205181123749999"}, - []string{"0.000006769304931000000000", "249999999999999740000", "1692326232749998"}, - []string{"0.000000078385764000000000", "249999999999999740000", "19596441000000"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000011067547868000000000", "249999999999999740000", "2766886966999997"}, - []string{"0.000005684438299000000000", "249999999999999740000", "1421109574749999"}, - []string{"0.000005308101027000000000", "249999999999999740000", "1327025256749999"}, - []string{"0.000006052611919000000000", "249999999999999740000", "1513152979749999"}, - []string{"0.000006897277137000000000", "249999999999999740000", "1724319284249998"}, - []string{"0.000007524289114000000000", "249999999999999740000", "1881072278499998"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000011068186249000000000", "249999999999999740000", "2767046562249997"}, - []string{"0.000007086176189000000000", "249999999999999740000", "1771544047249998"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - []string{"0.000011066475358000000000", "249999999999999740000", "2766618839499997"}, - []string{"0.000004445997620000000000", "249999999999999740000", "1111499404999999"}, - []string{"0.000005026149490000000000", "249999999999999740000", "1256537372499999"}, - []string{"0.000005245237427000000000", "249999999999999740000", "1311309356749999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000005906556295000000000", "249999999999999740000", "1476639073749999"}, - []string{"0.000002477475271000000000", "249999999999999740000", "619368817749999"}, - []string{"0.000009406291697000000000", "249999999999999740000", "2351572924249998"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.00015529746717900000", "249999999999999740000", "38824366794749960"}, - []string{"0.000005319693767000000000", "249999999999999740000", "1329923441749999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000004684377878000000000", "249999999999999740000", "1171094469499999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000008658154920000000000", "249999999999999740000", "2164538729999998"}, - []string{"0.000008377062090000000000", "249999999999999740000", "2094265522499998"}, - []string{"0.000005795889243000000000", "249999999999999740000", "1448972310749999"}, - []string{"0.000004311217028000000000", "249999999999999740000", "1077804256999999"}, - []string{"0.000005615005446000000000", "249999999999999740000", "1403751361499999"}, - []string{"0.000003919288207000000000", "249999999999999740000", "979822051749999"}, - } - - for i, value := range values { - stakerProportion := value[0] - tokensPerDay := value[1] - expectedValue := value[2] - result, err := CalculateNileStakerTokenRewards(stakerProportion, tokensPerDay) - assert.Nil(t, err) - - assert.Equal(t, expectedValue, result, fmt.Sprintf("row %d: '%s' - '%s' - '%s'", i, stakerProportion, tokensPerDay, expectedValue)) - } - }) - t.Run("Should correctly calculate the post-nile token rewards for stakers", func(t *testing.T) { - values := [][]string{ - []string{"0.000009049993751", "249999999999999740000", "2262498437749997", "2262498437749997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004801343782", "249999999999999740000", "1200335945499998", "1200335945499998.8"}, - []string{"0.000010319286042", "249999999999999740000", "2579821510499997", "2579821510499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000010926464639", "249999999999999740000", "2731616159749997", "2731616159749997"}, - []string{"0.00000587205541", "249999999999999740000", "1468013852499998", "1468013852499998.5"}, - []string{"0.000005842987054", "249999999999999740000", "1460746763499998", "1460746763499998.5"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000008641233546", "249999999999999740000", "2160308386499998", "2160308386499998"}, - []string{"0.000008694529984", "249999999999999740000", "2173632495999997", "2173632495999997.8"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004820724495", "249999999999999740000", "1205181123749998", "1205181123749998.8"}, - []string{"0.000006769304931", "249999999999999740000", "1692326232749998", "1692326232749998.2"}, - []string{"0.000000078385764", "249999999999999740000", "19596440999999", "19596440999999.98"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067547868", "249999999999999740000", "2766886966999997", "2766886966999997"}, - []string{"0.000005684438299", "249999999999999740000", "1421109574749998", "1421109574749998.5"}, - []string{"0.000005308101027", "249999999999999740000", "1327025256749998", "1327025256749998.5"}, - []string{"0.000006052611919", "249999999999999740000", "1513152979749998", "1513152979749998.5"}, - []string{"0.000006897277137", "249999999999999740000", "1724319284249998", "1724319284249998.2"}, - []string{"0.000007524289114", "249999999999999740000", "1881072278499998", "1881072278499998"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011068186249", "249999999999999740000", "2767046562249997", "2767046562249997"}, - []string{"0.000007086176189", "249999999999999740000", "1771544047249998", "1771544047249998.2"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000011066475358", "249999999999999740000", "2766618839499997", "2766618839499997"}, - []string{"0.00000444599762", "249999999999999740000", "1111499404999998", "1111499404999998.8"}, - []string{"0.00000502614949", "249999999999999740000", "1256537372499998", "1256537372499998.8"}, - []string{"0.000005245237427", "249999999999999740000", "1311309356749998", "1311309356749998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005906556295", "249999999999999740000", "1476639073749998", "1476639073749998.5"}, - []string{"0.000002477475271", "249999999999999740000", "619368817749999", "619368817749999.4"}, - []string{"0.000009406291697", "249999999999999740000", "2351572924249997", "2351572924249997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000155297467179", "249999999999999740000", "38824366794749960", "38824366794749960"}, - []string{"0.000005319693767", "249999999999999740000", "1329923441749998", "1329923441749998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004684377878", "249999999999999740000", "1171094469499998", "1171094469499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000865815492", "249999999999999740000", "2164538729999997", "2164538729999997.5"}, - []string{"0.00000837706209", "249999999999999740000", "2094265522499997", "2094265522499997.8"}, - []string{"0.000005795889243", "249999999999999740000", "1448972310749998", "1448972310749998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005615005446", "249999999999999740000", "1403751361499998", "1403751361499998.5"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004343211879", "249999999999999740000", "1085802969749998", "1085802969749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004497233707", "249999999999999740000", "1124308426749998", "1124308426749998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000473160595", "249999999999999740000", "1182901487499998", "1182901487499998.8"}, - []string{"0.000005489864048", "249999999999999740000", "1372466011999998", "1372466011999998.5"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004481283758", "249999999999999740000", "1120320939499998", "1120320939499998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011254974313", "249999999999999740000", "2813743578249997", "2813743578249997"}, - []string{"0.000007988838178", "249999999999999740000", "1997209544499998", "1997209544499998"}, - []string{"0.000001371750872", "249999999999999740000", "342937717999999", "342937717999999.6"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000010018074899", "249999999999999740000", "2504518724749997", "2504518724749997.5"}, - []string{"0.000001959644103", "249999999999999740000", "489911025749999", "489911025749999.44"}, - []string{"0.000004677431991", "249999999999999740000", "1169357997749998", "1169357997749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005052634215", "249999999999999740000", "1263158553749998", "1263158553749998.8"}, - []string{"0.000004378562562", "249999999999999740000", "1094640640499998", "1094640640499998.9"}, - []string{"0.000005136263081", "249999999999999740000", "1284065770249998", "1284065770249998.5"}, - []string{"0.000006086614747", "249999999999999740000", "1521653686749998", "1521653686749998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000678008036", "249999999999999740000", "1695020089999998", "1695020089999998"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004358362661", "249999999999999740000", "1089590665249998", "1089590665249998.8"}, - []string{"0.000017333414377", "249999999999999740000", "4333353594249995", "4333353594249995.5"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000011067443446", "249999999999999740000", "2766860861499997", "2766860861499997"}, - []string{"0.000014949678468", "249999999999999740000", "3737419616999996", "3737419616999996"}, - []string{"0.000006730676146", "249999999999999740000", "1682669036499998", "1682669036499998.2"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.002874063817455", "249999999999999740000", "718515954363749250", "718515954363749250"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000013402738201", "249999999999999740000", "3350684550249996", "3350684550249996.5"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011066683042", "249999999999999740000", "2766670760499997", "2766670760499997"}, - []string{"0.000004559116932", "249999999999999740000", "1139779232999998", "1139779232999998.8"}, - []string{"0.000005178812729", "249999999999999740000", "1294703182249998", "1294703182249998.8"}, - []string{"0.00000560777371", "249999999999999740000", "1401943427499998", "1401943427499998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000034647768302", "249999999999999740000", "8661942075499991", "8661942075499991"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000000039192882", "249999999999999740000", "9798220499999", "9798220499999.99"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005318465383", "249999999999999740000", "1329616345749998", "1329616345749998.8"}, - []string{"0.000009142886932", "249999999999999740000", "2285721732999997", "2285721732999997.5"}, - []string{"0.000000001763323", "249999999999999740000", "440830749999", "440830749999.9995"}, - []string{"0.000005239479729", "249999999999999740000", "1309869932249998", "1309869932249998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011068572525", "249999999999999740000", "2767143131249997", "2767143131249997"}, - []string{"0.000004349799583", "249999999999999740000", "1087449895749998", "1087449895749998.9"}, - []string{"0.000005762329847", "249999999999999740000", "1440582461749998", "1440582461749998.5"}, - []string{"0.000005750387614", "249999999999999740000", "1437596903499998", "1437596903499998.5"}, - []string{"0.000014959041874", "249999999999999740000", "3739760468499996", "3739760468499996"}, - []string{"0.000004915721371", "249999999999999740000", "1228930342749998", "1228930342749998.8"}, - []string{"0.000006674009818", "249999999999999740000", "1668502454499998", "1668502454499998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000081602837875", "249999999999999740000", "20400709468749976", "20400709468749976"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006004611299", "249999999999999740000", "1501152824749998", "1501152824749998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006355155937", "249999999999999740000", "1588788984249998", "1588788984249998.5"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000011067820412", "249999999999999740000", "2766955102999997", "2766955102999997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004855108806", "249999999999999740000", "1213777201499998", "1213777201499998.8"}, - []string{"0.000011066088948", "249999999999999740000", "2766522236999997", "2766522236999997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006074896721", "249999999999999740000", "1518724180249998", "1518724180249998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000408162188", "249999999999999740000", "102040546999999", "102040546999999.89"}, - []string{"0.000006086654586", "249999999999999740000", "1521663646499998", "1521663646499998.5"}, - []string{"0.000011067533248", "249999999999999740000", "2766883311999997", "2766883311999997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004959654658", "249999999999999740000", "1239913664499998", "1239913664499998.8"}, - []string{"0.000004334593317", "249999999999999740000", "1083648329249998", "1083648329249998.9"}, - []string{"0.000011066270658", "249999999999999740000", "2766567664499997", "2766567664499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000485991737", "249999999999999740000", "121497934249999", "121497934249999.86"}, - []string{"0.000005957318075", "249999999999999740000", "1489329518749998", "1489329518749998.5"}, - []string{"0.000002821887509", "249999999999999740000", "705471877249999", "705471877249999.2"}, - []string{"0.000005460297788", "249999999999999740000", "1365074446999998", "1365074446999998.5"}, - []string{"0.000000593038012", "249999999999999740000", "148259502999999", "148259502999999.84"}, - []string{"0.00000048232807", "249999999999999740000", "120582017499999", "120582017499999.88"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000013835090761", "249999999999999740000", "3458772690249996", "3458772690249996.5"}, - []string{"0.000004387386402", "249999999999999740000", "1096846600499998", "1096846600499998.9"}, - []string{"0.00001056846525", "249999999999999740000", "2642116312499997", "2642116312499997.5"}, - []string{"0.000004744198683", "249999999999999740000", "1186049670749998", "1186049670749998.8"}, - []string{"0.000013517447109", "249999999999999740000", "3379361777249996", "3379361777249996.5"}, - []string{"0.000004292111888", "249999999999999740000", "1073027971999998", "1073027971999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000008820012468", "249999999999999740000", "2205003116999997", "2205003116999997.5"}, - []string{"0.000005601905333", "249999999999999740000", "1400476333249998", "1400476333249998.5"}, - []string{"0.000005339016974", "249999999999999740000", "1334754243499998", "1334754243499998.5"}, - []string{"0.000300001044541", "249999999999999740000", "75000261135249920", "75000261135249920"}, - []string{"0.000011067668642", "249999999999999740000", "2766917160499997", "2766917160499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000016325425419", "249999999999999740000", "4081356354749995", "4081356354749995.5"}, - []string{"0.000000460259862", "249999999999999740000", "115064965499999", "115064965499999.88"}, - []string{"0.000000563455944", "249999999999999740000", "140863985999999", "140863985999999.88"}, - []string{"0.00000568617956", "249999999999999740000", "1421544889999998", "1421544889999998.5"}, - []string{"0.000004999005702", "249999999999999740000", "1249751425499998", "1249751425499998.5"}, - []string{"0.00000609084659", "249999999999999740000", "1522711647499998", "1522711647499998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067715964", "249999999999999740000", "2766928990999997", "2766928990999997"}, - []string{"0.000005004891542", "249999999999999740000", "1251222885499998", "1251222885499998.8"}, - []string{"0.000007218680732", "249999999999999740000", "1804670182999998", "1804670182999998"}, - []string{"0.000005144299747", "249999999999999740000", "1286074936749998", "1286074936749998.8"}, - []string{"0.00008989838143", "249999999999999740000", "22474595357499976", "22474595357499976"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067089214", "249999999999999740000", "2766772303499997", "2766772303499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006545911248", "249999999999999740000", "1636477811999998", "1636477811999998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067039047", "249999999999999740000", "2766759761749997", "2766759761749997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000009471564941", "249999999999999740000", "2367891235249997", "2367891235249997.5"}, - []string{"0.000008445422705", "249999999999999740000", "2111355676249997", "2111355676249997.8"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005340280631", "249999999999999740000", "1335070157749998", "1335070157749998.5"}, - []string{"0.00000435529761", "249999999999999740000", "1088824402499998", "1088824402499998.9"}, - []string{"0.000006367452314", "249999999999999740000", "1591863078499998", "1591863078499998.2"}, - []string{"0.000004372836209", "249999999999999740000", "1093209052249998", "1093209052249998.9"}, - []string{"0.000004926901446", "249999999999999740000", "1231725361499998", "1231725361499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004755398978", "249999999999999740000", "1188849744499998", "1188849744499998.8"}, - []string{"0.000005303897879", "249999999999999740000", "1325974469749998", "1325974469749998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004682911838", "249999999999999740000", "1170727959499998", "1170727959499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011066751231", "249999999999999740000", "2766687807749997", "2766687807749997"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004781531613", "249999999999999740000", "1195382903249998", "1195382903249998.8"}, - []string{"0.000000526960156", "249999999999999740000", "131740038999999", "131740038999999.86"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006337819945", "249999999999999740000", "1584454986249998", "1584454986249998.5"}, - []string{"0.00000598555262", "249999999999999740000", "1496388154999998", "1496388154999998.5"}, - []string{"0.000011133520684", "249999999999999740000", "2783380170999997", "2783380170999997"}, - []string{"0.000011067413867", "249999999999999740000", "2766853466749997", "2766853466749997"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005037750053", "249999999999999740000", "1259437513249998", "1259437513249998.8"}, - []string{"0.000010238640377", "249999999999999740000", "2559660094249997", "2559660094249997.5"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000031315112777", "249999999999999740000", "7828778194249992", "7828778194249992"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004552220781", "249999999999999740000", "1138055195249998", "1138055195249998.8"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004771744448", "249999999999999740000", "1192936111999998", "1192936111999998.8"}, - []string{"0.000004470418106", "249999999999999740000", "1117604526499998", "1117604526499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000001567715282", "249999999999999740000", "391928820499999", "391928820499999.56"}, - []string{"0.000006685375775", "249999999999999740000", "1671343943749998", "1671343943749998.2"}, - []string{"0.00000495047661", "249999999999999740000", "1237619152499998", "1237619152499998.8"}, - []string{"0.000005844909181", "249999999999999740000", "1461227295249998", "1461227295249998.5"}, - []string{"0.000000002145689", "249999999999999740000", "536422249999", "536422249999.99945"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000002987135399", "249999999999999740000", "746783849749999", "746783849749999.2"}, - []string{"0.000034747556263", "249999999999999740000", "8686889065749991", "8686889065749991"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000014311629335", "249999999999999740000", "3577907333749996", "3577907333749996.5"}, - []string{"0.000000039192882", "249999999999999740000", "9798220499999", "9798220499999.99"}, - []string{"0.000011066754626", "249999999999999740000", "2766688656499997", "2766688656499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004761442856", "249999999999999740000", "1190360713999998", "1190360713999998.8"}, - []string{"0.000005488681729", "249999999999999740000", "1372170432249998", "1372170432249998.5"}, - []string{"0.000004720390951", "249999999999999740000", "1180097737749998", "1180097737749998.8"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004926662957", "249999999999999740000", "1231665739249998", "1231665739249998.8"}, - []string{"0.000005003715806", "249999999999999740000", "1250928951499998", "1250928951499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004489784075", "249999999999999740000", "1122446018749998", "1122446018749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000013860083391", "249999999999999740000", "3465020847749996", "3465020847749996.5"}, - []string{"0.000001990011373", "249999999999999740000", "497502843249999", "497502843249999.5"}, - []string{"0.00001106677849", "249999999999999740000", "2766694622499997", "2766694622499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000039196801", "249999999999999740000", "9799200249999", "9799200249999.99"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000013572735485", "249999999999999740000", "3393183871249996", "3393183871249996.5"}, - []string{"0.000004899110259", "249999999999999740000", "1224777564749998", "1224777564749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067136903", "249999999999999740000", "2766784225749997", "2766784225749997"}, - []string{"0.000004336354665", "249999999999999740000", "1084088666249998", "1084088666249998.9"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000482687193", "249999999999999740000", "120671798249999", "120671798249999.86"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004829343283", "249999999999999740000", "1207335820749998", "1207335820749998.8"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000006834871106", "249999999999999740000", "1708717776499998", "1708717776499998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000008686667517", "249999999999999740000", "2171666879249998", "2171666879249998"}, - []string{"0.000011066162127", "249999999999999740000", "2766540531749997", "2766540531749997"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004558056201", "249999999999999740000", "1139514050249999", "1139514050249999"}, - []string{"0.000005388547951", "249999999999999740000", "1347136987749998", "1347136987749998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000009495590539", "249999999999999740000", "2373897634749997", "2373897634749997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005186272033", "249999999999999740000", "1296568008249998", "1296568008249998.8"}, - []string{"0.000006990370298", "249999999999999740000", "1747592574499998", "1747592574499998"}, - []string{"0.000006873785508", "249999999999999740000", "1718446376999998", "1718446376999998"}, - []string{"0.00000039192882", "249999999999999740000", "97982204999999", "97982204999999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004504850433", "249999999999999740000", "1126212608249998", "1126212608249998.8"}, - []string{"0.000005530483313", "249999999999999740000", "1382620828249998", "1382620828249998.5"}, - []string{"0.000007310119829", "249999999999999740000", "1827529957249998", "1827529957249998.2"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011067991499", "249999999999999740000", "2766997874749997", "2766997874749997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000014234345856", "249999999999999740000", "3558586463999996", "3558586463999996.5"}, - []string{"0.000000592557184", "249999999999999740000", "148139295999999", "148139295999999.84"}, - []string{"0.000004913446869", "249999999999999740000", "1228361717249998", "1228361717249998.8"}, - []string{"0.000004480086345", "249999999999999740000", "1120021586249998", "1120021586249998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000000303352", "249999999999999740000", "75837999999", "75837999999.99992"}, - []string{"0.000011252704148", "249999999999999740000", "2813176036999997", "2813176036999997"}, - []string{"0.000004505674706", "249999999999999740000", "1126418676499999", "1126418676499999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004675810515", "249999999999999740000", "1168952628749998", "1168952628749998.8"}, - []string{"0.00000514400844", "249999999999999740000", "1286002109999998", "1286002109999998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004426765887", "249999999999999740000", "1106691471749998", "1106691471749998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011068588146", "249999999999999740000", "2767147036499997", "2767147036499997"}, - []string{"0.00001106757791", "249999999999999740000", "2766894477499997", "2766894477499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004884842405", "249999999999999740000", "1221210601249998", "1221210601249998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005899779334", "249999999999999740000", "1474944833499998", "1474944833499998.2"}, - []string{"0.000013422003779", "249999999999999740000", "3355500944749996", "3355500944749996.5"}, - []string{"0.000144171486789", "249999999999999740000", "36042871697249960", "36042871697249960"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000415444549", "249999999999999740000", "103861137249999", "103861137249999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000031928323627", "249999999999999740000", "7982080906749991", "7982080906749991"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000002640117", "249999999999999740000", "6600292499999", "6600292499999.993"}, - []string{"0.000000633269907", "249999999999999740000", "158317476749999", "158317476749999.84"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005064523288", "249999999999999740000", "1266130821999998", "1266130821999998.8"}, - []string{"0.000004349845721", "249999999999999740000", "1087461430249999", "1087461430249999"}, - []string{"0.000007703579531", "249999999999999740000", "1925894882749998", "1925894882749998.2"}, - []string{"0.000000437957083", "249999999999999740000", "109489270749999", "109489270749999.89"}, - []string{"0.000012046208995", "249999999999999740000", "3011552248749997", "3011552248749997"}, - []string{"0.00000000002121", "249999999999999740000", "5302499999", "5302499999.999994"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005181989907", "249999999999999740000", "1295497476749998", "1295497476749998.5"}, - []string{"0.000006057031037", "249999999999999740000", "1514257759249998", "1514257759249998.2"}, - []string{"0.000007893648991", "249999999999999740000", "1973412247749997", "1973412247749997.8"}, - []string{"0.00001044882236", "249999999999999740000", "2612205589999997", "2612205589999997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004861240598", "249999999999999740000", "1215310149499998", "1215310149499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004351580082", "249999999999999740000", "1087895020499999", "1087895020499999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000588314769", "249999999999999740000", "147078692249999", "147078692249999.84"}, - []string{"0.000009859499524", "249999999999999740000", "2464874880999997", "2464874880999997.5"}, - []string{"0.000004667920393", "249999999999999740000", "1166980098249999", "1166980098249999"}, - []string{"0.000002939466155", "249999999999999740000", "734866538749999", "734866538749999.2"}, - []string{"0.00000865481742", "249999999999999740000", "2163704354999997", "2163704354999997.8"}, - []string{"0.000005125798369", "249999999999999740000", "1281449592249998", "1281449592249998.5"}, - []string{"0.000004793636505", "249999999999999740000", "1198409126249998", "1198409126249998.8"}, - []string{"0.000011068483594", "249999999999999740000", "2767120898499997", "2767120898499997"}, - []string{"0.000007836352763", "249999999999999740000", "1959088190749998", "1959088190749998"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.0000046838042", "249999999999999740000", "1170951049999998", "1170951049999998.8"}, - []string{"0.000004618700167", "249999999999999740000", "1154675041749998", "1154675041749998.8"}, - []string{"0.000004537539334", "249999999999999740000", "1134384833499998", "1134384833499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004776404037", "249999999999999740000", "1194101009249998", "1194101009249998.8"}, - []string{"0.000005553719601", "249999999999999740000", "1388429900249998", "1388429900249998.5"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004489784075", "249999999999999740000", "1122446018749998", "1122446018749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000692740917", "249999999999999740000", "1731852292499998", "1731852292499998.2"}, - []string{"0.000005584462421", "249999999999999740000", "1396115605249998", "1396115605249998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004327021569", "249999999999999740000", "1081755392249998", "1081755392249998.9"}, - []string{"0.000004460682023", "249999999999999740000", "1115170505749998", "1115170505749998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000007523930305", "249999999999999740000", "1880982576249998", "1880982576249998"}, - []string{"0.000005014929065", "249999999999999740000", "1253732266249998", "1253732266249998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000470315651", "249999999999999740000", "117578912749999", "117578912749999.88"}, - []string{"0.000011067266143", "249999999999999740000", "2766816535749997", "2766816535749997"}, - []string{"0.000004606871138", "249999999999999740000", "1151717784499998", "1151717784499998.8"}, - []string{"0.00000429376189", "249999999999999740000", "1073440472499998", "1073440472499998.9"}, - []string{"0.000007368882709", "249999999999999740000", "1842220677249998", "1842220677249998"}, - []string{"0.000005777164954", "249999999999999740000", "1444291238499998", "1444291238499998.5"}, - []string{"0.000000743682751", "249999999999999740000", "185920687749999", "185920687749999.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011066956193", "249999999999999740000", "2766739048249997", "2766739048249997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004444509005", "249999999999999740000", "1111127251249998", "1111127251249998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000009980851029", "249999999999999740000", "2495212757249997", "2495212757249997.5"}, - []string{"0.000004438132916", "249999999999999740000", "1109533228999998", "1109533228999998.9"}, - []string{"0.000004818112356", "249999999999999740000", "1204528088999998", "1204528088999998.8"}, - []string{"0.000011068963995", "249999999999999740000", "2767240998749997", "2767240998749997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000108090806087", "249999999999999740000", "27022701521749972", "27022701521749972"}, - []string{"0.000004534886824", "249999999999999740000", "1133721705999998", "1133721705999998.8"}, - []string{"0.000011066549479", "249999999999999740000", "2766637369749997", "2766637369749997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000003447716551", "249999999999999740000", "861929137749999", "861929137749999.1"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000014014908682", "249999999999999740000", "3503727170499996", "3503727170499996"}, - []string{"0.000004243148758", "249999999999999740000", "1060787189499998", "1060787189499998.9"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000008180999729", "249999999999999740000", "2045249932249997", "2045249932249997.8"}, - []string{"0.000001929418705", "249999999999999740000", "482354676249999", "482354676249999.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005589443629", "249999999999999740000", "1397360907249998", "1397360907249998.5"}, - []string{"0.000004701364694", "249999999999999740000", "1175341173499998", "1175341173499998.8"}, - []string{"0.000011068179353", "249999999999999740000", "2767044838249997", "2767044838249997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005798168821", "249999999999999740000", "1449542205249998", "1449542205249998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000009286830011", "249999999999999740000", "2321707502749997", "2321707502749997.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000006054124493", "249999999999999740000", "1513531123249998", "1513531123249998.5"}, - []string{"0.000010961840774", "249999999999999740000", "2740460193499997", "2740460193499997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.00000459735762", "249999999999999740000", "1149339404999998", "1149339404999998.8"}, - []string{"0.000004607237865", "249999999999999740000", "1151809466249998", "1151809466249998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004999617541", "249999999999999740000", "1249904385249998", "1249904385249998.8"}, - []string{"0.000004384426544", "249999999999999740000", "1096106635999998", "1096106635999998.8"}, - []string{"0.000027592021209", "249999999999999740000", "6898005302249993", "6898005302249993"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011065571432", "249999999999999740000", "2766392857999997", "2766392857999997"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000011685473321", "249999999999999740000", "2921368330249997", "2921368330249997"}, - []string{"0.000005478819232", "249999999999999740000", "1369704807999998", "1369704807999998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000020025026258", "249999999999999740000", "5006256564499995", "5006256564499995"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000438960279", "249999999999999740000", "109740069749999", "109740069749999.89"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005384947768", "249999999999999740000", "1346236941999998", "1346236941999998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004414406953", "249999999999999740000", "1103601738249998", "1103601738249998.8"}, - []string{"0.000010817235452", "249999999999999740000", "2704308862999997", "2704308862999997.5"}, - []string{"0.000003459054342", "249999999999999740000", "864763585499999", "864763585499999"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000006305221592", "249999999999999740000", "1576305397999998", "1576305397999998.2"}, - []string{"0.000000589197102", "249999999999999740000", "147299275499999", "147299275499999.84"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000005284741798", "249999999999999740000", "1321185449499998", "1321185449499998.5"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004977496023", "249999999999999740000", "1244374005749998", "1244374005749998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000003919288207", "249999999999999740000", "979822051749999", "979822051749999"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000008701617124", "249999999999999740000", "2175404280999997", "2175404280999997.8"}, - []string{"0.000009297049021", "249999999999999740000", "2324262255249997", "2324262255249997.5"}, - []string{"0.00000435040991", "249999999999999740000", "1087602477499998", "1087602477499998.8"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004905866207", "249999999999999740000", "1226466551749998", "1226466551749998.8"}, - []string{"0.000011188276426", "249999999999999740000", "2797069106499997", "2797069106499997"}, - []string{"0.000004489846462", "249999999999999740000", "1122461615499998", "1122461615499998.9"}, - []string{"0.000004626953867", "249999999999999740000", "1156738466749999", "1156738466749999"}, - []string{"0.000023680418961", "249999999999999740000", "5920104740249994", "5920104740249994"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000004311217028", "249999999999999740000", "1077804256999998", "1077804256999998.9"}, - []string{"0.000000054417993", "249999999999999740000", "13604498249999", "13604498249999.986"}, - []string{"0.000005470503287", "249999999999999740000", "1367625821749998", "1367625821749998.5"}, - } - - for i, value := range values { - stakerProportion := value[0] - tokensPerDayDecimal := value[1] - expectedValue := value[2] - result, err := CalculatePostNileStakerTokenRewards(stakerProportion, tokensPerDayDecimal) - assert.Nil(t, err) - - assert.Equal(t, expectedValue, result, fmt.Sprintf("row %d: '%s' - '%s' - '%s'", i, stakerProportion, tokensPerDayDecimal, expectedValue)) - } - }) - }) - - t.Run("Operator tokens", func(t *testing.T) { - t.Run("Should calculate operator amazon fork tokens correctly", func(t *testing.T) { - for _, value := range operatorAmazonTokens { - totalStakerOperatorPayout := value[0] - expectedValue := value[1] - - result, err := CalculateAmazonOperatorTokens(totalStakerOperatorPayout) - assert.Nil(t, err) - assert.Equal(t, expectedValue, result) - } - }) - t.Run("Should calculate nile fork tokens correctly", func(t *testing.T) { - for _, value := range operatorNileTokens { - totalStakerOperatorPayout := value[0] - expectedValue := value[1] - - result, err := CalculateNileOperatorTokens(totalStakerOperatorPayout) - assert.Nil(t, err) - assert.Equal(t, expectedValue, result) - } - }) - }) - t.Run("Should use the C implementation of big_gt", func(t *testing.T) { - t.Run("A should be greater than B", func(t *testing.T) { - a := "10" - b := "5" - - result, err := BigGt(a, b) - assert.Nil(t, err) - assert.True(t, result) - }) - t.Run("A should be less than B", func(t *testing.T) { - a := "5" - b := "10" - - result, err := BigGt(a, b) - assert.Nil(t, err) - assert.False(t, result) - }) - - }) } diff --git a/internal/types/numbers/tokenCalculations.go b/internal/types/numbers/tokenCalculations.go deleted file mode 100644 index 76c88afd..00000000 --- a/internal/types/numbers/tokenCalculations.go +++ /dev/null @@ -1,133 +0,0 @@ -package numbers - -import ( - "fmt" - "github.com/shopspring/decimal" -) - -/* -#include -#include "calculations.h" -*/ -import "C" -import "unsafe" - -func InitPython() error { - // if C.init_python() == 0 { - // return errors.New("failed to initialize python") - // } - return nil -} - -func FinalizePython() { - // C.finalize_python() -} - -// CalculateAmazonStakerTokenRewards calculates the Amazon token rewards for a given staker proportion and tokens per day -// cast(staker_proportion * tokens_per_day AS DECIMAL(38,0)) -func CalculateAmazonStakerTokenRewards(stakerProportion string, tokensPerDay string) (string, error) { - cSp := C.CString(stakerProportion) - cTpd := C.CString(tokensPerDay) - defer C.free(unsafe.Pointer(cSp)) - defer C.free(unsafe.Pointer(cTpd)) - - cResult := C._amazon_staker_token_rewards(cSp, cTpd) - defer C.free(unsafe.Pointer(cResult)) - - return C.GoString(cResult), nil -} - -// CalculateNileStakerTokenRewards calculates the tokens to be rewarded for a given staker proportion and tokens per day -// (staker_proportion * tokens_per_day)::text::decimal(38,0) -func CalculateNileStakerTokenRewards(stakerProportion string, tokensPerDay string) (string, error) { - cSp := C.CString(stakerProportion) - cTpd := C.CString(tokensPerDay) - defer C.free(unsafe.Pointer(cSp)) - defer C.free(unsafe.Pointer(cTpd)) - - cResult := C._nile_staker_token_rewards(cSp, cTpd) - defer C.free(unsafe.Pointer(cResult)) - - return C.GoString(cResult), nil -} - -// CalculatePostNileStakerTokenRewards calculates the tokens to be rewarded for a given staker proportion and tokens per day -// FLOOR(staker_proportion * tokens_per_day_decimal) -func CalculatePostNileStakerTokenRewards(stakerProportion string, tokensPerDay string) (string, error) { - cSp := C.CString(stakerProportion) - cTpd := C.CString(tokensPerDay) - defer C.free(unsafe.Pointer(cSp)) - defer C.free(unsafe.Pointer(cTpd)) - - cResult := C._staker_token_rewards(cSp, cTpd) - defer C.free(unsafe.Pointer(cResult)) - - return C.GoString(cResult), nil -} - -// CalculateAmazonOperatorTokens calculates the operator payout portion for rewards (10% of total) -// -// cast(total_staker_operator_payout * 0.10 AS DECIMAL(38,0)) -func CalculateAmazonOperatorTokens(totalStakerPayout string) (string, error) { - tsp := C.CString(totalStakerPayout) - defer C.free(unsafe.Pointer(tsp)) - - cResult := C._amazon_operator_token_rewards(tsp) - defer C.free(unsafe.Pointer(cResult)) - - return C.GoString(cResult), nil -} - -// CalculateNileOperatorTokens calculates the operator payout portion for rewards (10% of total) -// -// (total_staker_operator_payout * 0.10)::text::decimal(38,0) -func CalculateNileOperatorTokens(totalStakerPayout string) (string, error) { - tsp := C.CString(totalStakerPayout) - defer C.free(unsafe.Pointer(tsp)) - - cResult := C._nile_operator_token_rewards(tsp) - defer C.free(unsafe.Pointer(cResult)) - - return C.GoString(cResult), nil -} - -// CalculatePostNileOperatorTokens calculates the operator payout portion for rewards (10% of total) -// -// floor(total_staker_operator_payout * 0.10) -func CalculatePostNileOperatorTokens(totalStakerPayout string) (string, error) { - tpd, err := decimal.NewFromString(totalStakerPayout) - if err != nil { - return "", err - } - - return tpd.Mul(decimal.NewFromFloat(0.10)).Floor().String(), nil -} - -// PreNileTokensPerDay calculates the tokens per day for pre-nile rewards, rounded to 15 sigfigs -// -// Not gonna lie, this is pretty annoying that it has to be this way, but in order to support backwards compatibility -// with the current/old rewards system where postgres was lossy, we have to do this. -func PreNileTokensPerDay(tokensPerDay string) (string, error) { - fmt.Printf("PreNileTokensPerDay: %s\n", tokensPerDay) - cTokens := C.CString(tokensPerDay) - defer C.free(unsafe.Pointer(cTokens)) - - fmt.Printf("Calling pre_nile_tokens_per_day\n") - result := C._pre_nile_tokens_per_day(cTokens) - fmt.Printf("Successfully called") - defer C.free(unsafe.Pointer(result)) - - resultStr := C.GoString(result) - fmt.Printf("PreNileTokensPerDay Result: %+v\n", resultStr) - return resultStr, nil -} - -func BigGt(a, b string) (bool, error) { - aVal := C.CString(a) - defer C.free(unsafe.Pointer(aVal)) - bVal := C.CString(b) - defer C.free(unsafe.Pointer(bVal)) - - result := C._big_gt(aVal, bVal) - return result == 1, nil -} diff --git a/pkg/rewards/2_goldStakerRewardAmounts.go b/pkg/rewards/2_goldStakerRewardAmounts.go index f5ddcbe9..686607e7 100644 --- a/pkg/rewards/2_goldStakerRewardAmounts.go +++ b/pkg/rewards/2_goldStakerRewardAmounts.go @@ -114,7 +114,7 @@ staker_weight_sum AS ( -- Calculate staker proportion of tokens for each reward and snapshot staker_proportion AS ( SELECT *, - calculate_staker_proportion(staker_weight, total_weight) as staker_proportion + staker_weight(staker_weight, total_weight) as staker_proportion FROM staker_weight_sum ), -- Calculate total tokens to the (staker, operator) pair diff --git a/pkg/rewards/4_goldRewardsForAll.go b/pkg/rewards/4_goldRewardsForAll.go index e32d9017..831aef1e 100644 --- a/pkg/rewards/4_goldRewardsForAll.go +++ b/pkg/rewards/4_goldRewardsForAll.go @@ -79,7 +79,7 @@ staker_weight_sum AS ( -- Calculate staker token proportion staker_proportion AS ( SELECT *, - calculate_staker_proportion(staker_weight, total_staker_weight) as staker_proportion + staker_weight(staker_weight, total_staker_weight) as staker_proportion FROM staker_weight_sum ), -- Calculate total tokens to staker diff --git a/pkg/rewards/5_goldRfaeStakers.go b/pkg/rewards/5_goldRfaeStakers.go index c6c63fdd..4e98e631 100644 --- a/pkg/rewards/5_goldRfaeStakers.go +++ b/pkg/rewards/5_goldRfaeStakers.go @@ -107,7 +107,7 @@ staker_weight_sum AS ( -- Calculate staker proportion of tokens for each reward and snapshot staker_proportion AS ( SELECT *, - calculate_staker_proportion(staker_weight, total_weight) as staker_proportion + staker_weight(staker_weight, total_weight) as staker_proportion FROM staker_weight_sum ), -- Calculate total tokens to the (staker, operator) pair diff --git a/pkg/rewards/rewards_test.go b/pkg/rewards/rewards_test.go index ac59c0b4..bbdfe395 100644 --- a/pkg/rewards/rewards_test.go +++ b/pkg/rewards/rewards_test.go @@ -7,7 +7,6 @@ import ( "github.com/Layr-Labs/go-sidecar/internal/sqlite/migrations" "github.com/Layr-Labs/go-sidecar/internal/tests" "github.com/Layr-Labs/go-sidecar/internal/tests/sqlite" - "github.com/Layr-Labs/go-sidecar/internal/types/numbers" "github.com/stretchr/testify/assert" "go.uber.org/zap" "gorm.io/gorm" @@ -137,10 +136,6 @@ func Test_Rewards(t *testing.T) { return } - if err := numbers.InitPython(); err != nil { - t.Fatal(err) - } - dbFileName, cfg, grm, l, err := setupRewards() fmt.Printf("Using db file: %+v\n", dbFileName)