diff --git a/bookkeeper/storage/select_total_coins.sql b/bookkeeper/storage/select_total_coins.sql index f9fbac3..54b3e79 100644 --- a/bookkeeper/storage/select_total_coins.sql +++ b/bookkeeper/storage/select_total_coins.sql @@ -2,7 +2,7 @@ WITH active_users AS ( SELECT DISTINCT ON (id, created_at) - created_at, id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum, balance_for_tminus1, balance_t2_ethereum + created_at, id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum FROM %[1]v WHERE created_at IN [ '%[2]v' ] AND kyc_step_passed >= %[3]v @@ -13,10 +13,10 @@ WITH SELECT req_date FROM VALUES('req_date DateTime',('%[4]v')) ) SELECT req_date AS created_at, - id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum, balance_for_tminus1, balance_t2_ethereum + id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum FROM (SELECT DISTINCT ON (id, created_at) created_at, - id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum, balance_for_tminus1, balance_t2_ethereum + id, id_t0, id_tminus1, pre_staking_allocation, pre_staking_bonus, balance_solo, balance_solo_ethereum, balance_t0, balance_t0_ethereum, balance_for_t0, balance_t1_ethereum FROM %[1]v WHERE (id, created_at) GLOBAL IN ( SELECT id, max(created_at) @@ -34,17 +34,12 @@ WITH SELECT created_at, id_t0, SUM(balance_for_t0) AS balance_t1 FROM valid_users GROUP BY created_at, id_t0 - ), - valid_t2_users AS ( - SELECT created_at, id_tminus1, SUM(balance_for_tminus1) AS balance_t2 - FROM valid_users - GROUP BY created_at, id_tminus1 ) SELECT - u.created_at AS created_at, - SUM(((u.balance_solo+IF(t0.id != 0, u.balance_t0, 0)+t1.balance_t1+t2.balance_t2) * (100.0 - u.pre_staking_allocation)) / 100.0) AS balance_total_standard, - SUM(((u.balance_solo+IF(t0.id != 0, u.balance_t0, 0)+t1.balance_t1+t2.balance_t2) * (100.0 + u.pre_staking_bonus) * u.pre_staking_allocation) / 10000.0) AS balance_total_pre_staking, - SUM(u.balance_solo_ethereum+u.balance_t0_ethereum+u.balance_t1_ethereum+u.balance_t2_ethereum) AS balance_total_ethereum + u.created_at AS created_at, + SUM(((u.balance_solo+IF(t0.id != 0, u.balance_t0, 0)+t1.balance_t1) * (100.0 - u.pre_staking_allocation)) / 100.0) AS balance_total_standard, + SUM(((u.balance_solo+IF(t0.id != 0, u.balance_t0, 0)+t1.balance_t1) * (100.0 + u.pre_staking_bonus) * u.pre_staking_allocation) / 10000.0) AS balance_total_pre_staking, + SUM(u.balance_solo_ethereum+u.balance_t0_ethereum+u.balance_t1_ethereum) AS balance_total_ethereum FROM valid_users u GLOBAL LEFT JOIN valid_users t0 @@ -53,7 +48,4 @@ ON t0.id = u.id_t0 GLOBAL LEFT JOIN valid_t1_users t1 ON t1.id_t0 = u.id AND t1.created_at = u.created_at - GLOBAL LEFT JOIN valid_t2_users t2 - ON t2.id_tminus1 = u.id - AND t2.created_at = u.created_at GROUP BY u.created_at \ No newline at end of file diff --git a/go.mod b/go.mod index 08ef61c..2cc7107 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/ethereum/go-ethereum v1.14.5 github.com/goccy/go-json v0.10.3 github.com/hashicorp/go-multierror v1.1.1 - github.com/ice-blockchain/eskimo v1.349.0 + github.com/ice-blockchain/eskimo v1.351.0 github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb github.com/ice-blockchain/wintr v1.143.0 github.com/imroc/req/v3 v3.43.7 @@ -27,12 +27,12 @@ require ( require ( cloud.google.com/go v0.115.0 // indirect - cloud.google.com/go/auth v0.6.0 // indirect + cloud.google.com/go/auth v0.6.1 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect + cloud.google.com/go/compute/metadata v0.4.0 // indirect cloud.google.com/go/firestore v1.15.0 // indirect - cloud.google.com/go/iam v1.1.9 // indirect - cloud.google.com/go/longrunning v0.5.8 // indirect + cloud.google.com/go/iam v1.1.10 // indirect + cloud.google.com/go/longrunning v0.5.9 // indirect cloud.google.com/go/storage v1.42.0 // indirect cosmossdk.io/math v1.3.0 // indirect dario.cat/mergo v1.0.0 // indirect @@ -208,7 +208,7 @@ require ( golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect - google.golang.org/api v0.186.0 // indirect + google.golang.org/api v0.187.0 // indirect google.golang.org/appengine/v2 v2.0.6 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/go.sum b/go.sum index 5671feb..e0cf8ac 100644 --- a/go.sum +++ b/go.sum @@ -1,18 +1,18 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= -cloud.google.com/go/auth v0.6.0 h1:5x+d6b5zdezZ7gmLWD1m/xNjnaQ2YDhmIz/HH3doy1g= -cloud.google.com/go/auth v0.6.0/go.mod h1:b4acV+jLQDyjwm4OXHYjNvRi4jvGBzHWJRtJcy+2P4g= +cloud.google.com/go/auth v0.6.1 h1:T0Zw1XM5c1GlpN2HYr2s+m3vr1p2wy+8VN+Z1FKxW38= +cloud.google.com/go/auth v0.6.1/go.mod h1:eFHG7zDzbXHKmjJddFG/rBlcGp6t25SwRUiEQSlO4x4= cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cloud.google.com/go/compute/metadata v0.4.0 h1:vHzJCWaM4g8XIcm8kopr3XmDA4Gy/lblD3EhhSux05c= +cloud.google.com/go/compute/metadata v0.4.0/go.mod h1:SIQh1Kkb4ZJ8zJ874fqVkslA29PRXuleyj6vOzlbK7M= cloud.google.com/go/firestore v1.15.0 h1:/k8ppuWOtNuDHt2tsRV42yI21uaGnKDEQnRFeBpbFF8= cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk= -cloud.google.com/go/iam v1.1.9 h1:oSkYLVtVme29uGYrOcKcvJRht7cHJpYD09GM9JaR0TE= -cloud.google.com/go/iam v1.1.9/go.mod h1:Nt1eDWNYH9nGQg3d/mY7U1hvfGmsaG9o/kLGoLoLXjQ= -cloud.google.com/go/longrunning v0.5.8 h1:QThI5BFSlYlS7K0wnABCdmKsXbG/htLc3nTPzrfOgeU= -cloud.google.com/go/longrunning v0.5.8/go.mod h1:oJDErR/mm5h44gzsfjQlxd6jyjFvuBPOxR1TLy2+cQk= +cloud.google.com/go/iam v1.1.10 h1:ZSAr64oEhQSClwBL670MsJAW5/RLiC6kfw3Bqmd5ZDI= +cloud.google.com/go/iam v1.1.10/go.mod h1:iEgMq62sg8zx446GCaijmA2Miwg5o3UbO+nI47WHJps= +cloud.google.com/go/longrunning v0.5.9 h1:haH9pAuXdPAMqHvzX0zlWQigXT7B0+CL4/2nXXdBo5k= +cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c= cloud.google.com/go/storage v1.42.0 h1:4QtGpplCVt1wz6g5o1ifXd656P5z+yNgzdw1tVfp0cU= cloud.google.com/go/storage v1.42.0/go.mod h1:HjMXRFq65pGKFn6hxj6x3HCyR41uSB72Z0SO/Vn6JFQ= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= @@ -300,8 +300,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ice-blockchain/eskimo v1.349.0 h1:qGBHxgzhbvmzJVwn/JGo5yDSjlROlFqPy7UXTG131EI= -github.com/ice-blockchain/eskimo v1.349.0/go.mod h1:S+7t4TiU9AEYgowYDELyt0GgGEzHzHlM4Gv4SR3QF1E= +github.com/ice-blockchain/eskimo v1.351.0 h1:igc4PZwU0enDBAG+QX5WmSvfM8BZ55mh1cGZc2YHbdY= +github.com/ice-blockchain/eskimo v1.351.0/go.mod h1:ODsZC4RYZQc8dOXW8JzwK9SBzDXxFYEauYpBMiTlBoo= github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk= github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8= github.com/ice-blockchain/wintr v1.143.0 h1:KID/M01KN1jl7mlDF+VnIBScR7uT277mJtebYtemSF0= @@ -676,8 +676,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -google.golang.org/api v0.186.0 h1:n2OPp+PPXX0Axh4GuSsL5QL8xQCTb2oDwyzPnQvqUug= -google.golang.org/api v0.186.0/go.mod h1:hvRbBmgoje49RV3xqVXrmP6w93n6ehGgIVPYrGtBFFc= +google.golang.org/api v0.187.0 h1:Mxs7VATVC2v7CY+7Xwm4ndkX71hpElcvx0D1Ji/p1eo= +google.golang.org/api v0.187.0/go.mod h1:KIHlTc4x7N7gKKuVsdmfBXN13yEEWXWFURWY6SBp2gk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine/v2 v2.0.6 h1:LvPZLGuchSBslPBp+LAhihBeGSiRh1myRoYK4NtuBIw=