@typus/typus-perp-sdk 1.1.32-type-test → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/sentio.d.ts +5 -5
- package/dist/src/api/sentio.js +690 -541
- package/dist/src/client.d.ts +28 -0
- package/dist/src/client.js +171 -0
- package/dist/src/fetch.d.ts +554 -36
- package/dist/src/fetch.js +545 -661
- package/dist/src/generated/typus_perp/admin.d.ts +274 -0
- package/dist/src/generated/typus_perp/admin.js +321 -0
- package/dist/src/generated/typus_perp/competition.d.ts +60 -0
- package/dist/src/generated/typus_perp/competition.js +104 -0
- package/dist/src/generated/typus_perp/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/typus_perp/deps/std/type_name.js +25 -0
- package/dist/src/generated/typus_perp/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/typus_perp/deps/sui/balance.js +20 -0
- package/dist/src/generated/typus_perp/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_perp/deps/sui/object.js +16 -0
- package/dist/src/generated/typus_perp/deps/sui/object_table.d.ts +19 -0
- package/dist/src/generated/typus_perp/deps/sui/object_table.js +59 -0
- package/dist/src/generated/typus_perp/deps/sui/table.d.ts +31 -0
- package/dist/src/generated/typus_perp/deps/sui/table.js +71 -0
- package/dist/src/generated/typus_perp/deps/sui/vec_set.d.ts +18 -0
- package/dist/src/generated/typus_perp/deps/sui/vec_set.js +25 -0
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.d.ts +30 -0
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.js +67 -0
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.d.ts +32 -0
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.js +71 -0
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +15 -0
- package/dist/src/{_framework/init-loader.js → generated/typus_perp/deps/typus_framework/vault.js} +18 -10
- package/dist/src/generated/typus_perp/error.d.ts +443 -0
- package/dist/src/generated/typus_perp/error.js +788 -0
- package/dist/src/generated/typus_perp/escrow.d.ts +109 -0
- package/dist/src/generated/typus_perp/escrow.js +139 -0
- package/dist/src/generated/typus_perp/lp_pool.d.ts +1853 -0
- package/dist/src/generated/typus_perp/lp_pool.js +1483 -0
- package/dist/src/generated/typus_perp/math.d.ts +95 -0
- package/dist/src/generated/typus_perp/math.js +97 -0
- package/dist/src/generated/typus_perp/position.d.ts +1251 -0
- package/dist/src/generated/typus_perp/position.js +1393 -0
- package/dist/src/generated/typus_perp/profit_vault.d.ts +272 -0
- package/dist/src/generated/typus_perp/profit_vault.js +321 -0
- package/dist/src/generated/typus_perp/symbol.d.ts +47 -0
- package/dist/src/generated/typus_perp/symbol.js +97 -0
- package/dist/src/generated/typus_perp/trading.d.ts +2134 -0
- package/dist/src/generated/typus_perp/trading.js +2050 -0
- package/dist/src/generated/typus_perp/treasury_caps.d.ts +44 -0
- package/dist/src/generated/typus_perp/treasury_caps.js +92 -0
- package/dist/src/generated/typus_perp/user_account.d.ts +146 -0
- package/dist/src/generated/typus_perp/user_account.js +221 -0
- package/dist/src/generated/typus_stake_pool/admin.d.ts +218 -0
- package/dist/src/generated/typus_stake_pool/admin.js +247 -0
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.js +25 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/object.js +16 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.d.ts +30 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.js +37 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.d.ts +18 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.js +25 -0
- package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +1038 -0
- package/dist/src/generated/typus_stake_pool/stake_pool.js +938 -0
- package/dist/src/generated/utils/index.d.ts +11 -0
- package/dist/src/generated/utils/index.js +138 -0
- package/dist/src/grpc/graphql.d.ts +26 -0
- package/dist/src/grpc/graphql.js +126 -0
- package/dist/src/grpc/grpc.d.ts +1 -0
- package/dist/src/grpc/grpc.js +38 -0
- package/dist/src/grpc/ledgerService.js +64 -0
- package/dist/src/grpc/liveDataService.d.ts +0 -0
- package/dist/src/grpc/liveDataService.js +49 -0
- package/dist/src/index.d.ts +2 -8
- package/dist/src/index.js +30 -56
- package/dist/src/user/history.d.ts +1 -1
- package/dist/src/user/history.js +649 -679
- package/dist/src/user/order.d.ts +21 -11
- package/dist/src/user/order.js +204 -301
- package/dist/src/user/orderWithBidReceipt.d.ts +17 -6
- package/dist/src/user/orderWithBidReceipt.js +164 -224
- package/dist/src/user/tlp.d.ts +25 -25
- package/dist/src/user/tlp.js +317 -468
- package/package.json +12 -3
- package/dist/src/_dependencies/source/0x1/ascii/structs.d.ts +0 -88
- package/dist/src/_dependencies/source/0x1/ascii/structs.js +0 -398
- package/dist/src/_dependencies/source/0x1/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x1/index.js +0 -6
- package/dist/src/_dependencies/source/0x1/option/structs.d.ts +0 -50
- package/dist/src/_dependencies/source/0x1/option/structs.js +0 -271
- package/dist/src/_dependencies/source/0x1/string/structs.d.ts +0 -48
- package/dist/src/_dependencies/source/0x1/string/structs.js +0 -256
- package/dist/src/_dependencies/source/0x1/type-name/structs.d.ts +0 -49
- package/dist/src/_dependencies/source/0x1/type-name/structs.js +0 -223
- package/dist/src/_dependencies/source/0x2/bag/structs.d.ts +0 -54
- package/dist/src/_dependencies/source/0x2/bag/structs.js +0 -229
- package/dist/src/_dependencies/source/0x2/balance/structs.d.ts +0 -84
- package/dist/src/_dependencies/source/0x2/balance/structs.js +0 -386
- package/dist/src/_dependencies/source/0x2/coin/structs.d.ts +0 -406
- package/dist/src/_dependencies/source/0x2/coin/structs.js +0 -1247
- package/dist/src/_dependencies/source/0x2/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x2/index.js +0 -6
- package/dist/src/_dependencies/source/0x2/linked-table/structs.d.ts +0 -132
- package/dist/src/_dependencies/source/0x2/linked-table/structs.js +0 -438
- package/dist/src/_dependencies/source/0x2/object/structs.d.ts +0 -86
- package/dist/src/_dependencies/source/0x2/object/structs.js +0 -364
- package/dist/src/_dependencies/source/0x2/object-table/structs.d.ts +0 -54
- package/dist/src/_dependencies/source/0x2/object-table/structs.js +0 -248
- package/dist/src/_dependencies/source/0x2/sui/structs.d.ts +0 -44
- package/dist/src/_dependencies/source/0x2/sui/structs.js +0 -222
- package/dist/src/_dependencies/source/0x2/table/structs.d.ts +0 -54
- package/dist/src/_dependencies/source/0x2/table/structs.js +0 -248
- package/dist/src/_dependencies/source/0x2/table-vec/structs.d.ts +0 -59
- package/dist/src/_dependencies/source/0x2/table-vec/structs.js +0 -274
- package/dist/src/_dependencies/source/0x2/token/structs.d.ts +0 -421
- package/dist/src/_dependencies/source/0x2/token/structs.js +0 -1095
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.d.ts +0 -348
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.js +0 -1091
- package/dist/src/_dependencies/source/0x2/url/structs.d.ts +0 -49
- package/dist/src/_dependencies/source/0x2/url/structs.js +0 -223
- package/dist/src/_dependencies/source/0x2/vec-map/structs.d.ts +0 -106
- package/dist/src/_dependencies/source/0x2/vec-map/structs.js +0 -446
- package/dist/src/_dependencies/source/0x2/vec-set/structs.d.ts +0 -49
- package/dist/src/_dependencies/source/0x2/vec-set/structs.js +0 -270
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.d.ts +0 -422
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.js +0 -1084
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.d.ts +0 -130
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.js +0 -456
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.d.ts +0 -208
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.js +0 -653
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.d.ts +0 -362
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.js +0 -899
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.d.ts +0 -8
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.js +0 -11
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.js +0 -102
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/keyed-big-vector/structs.d.ts +0 -202
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/keyed-big-vector/structs.js +0 -632
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.d.ts +0 -600
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.js +0 -1459
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-object-table/structs.d.ts +0 -136
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-object-table/structs.js +0 -438
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.d.ts +0 -127
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.js +0 -430
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.d.ts +0 -957
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.js +0 -2261
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.d.ts +0 -244
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.js +0 -733
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.d.ts +0 -294
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.js +0 -892
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.d.ts +0 -73
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.js +0 -263
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.d.ts +0 -294
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.js +0 -591
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.d.ts +0 -64
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.js +0 -258
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.d.ts +0 -756
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.js +0 -1721
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.d.ts +0 -44
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.js +0 -222
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.js +0 -6
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.js +0 -89
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.d.ts +0 -135
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.js +0 -444
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs.d.ts +0 -2106
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs.js +0 -4952
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.d.ts +0 -390
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.js +0 -844
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.d.ts +0 -6
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.js +0 -9
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.js +0 -69
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.d.ts +0 -89
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.js +0 -376
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.d.ts +0 -386
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.js +0 -881
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.d.ts +0 -59
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.js +0 -274
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.d.ts +0 -974
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.js +0 -2387
- package/dist/src/_framework/init-loader.d.ts +0 -2
- package/dist/src/_framework/loader.d.ts +0 -17
- package/dist/src/_framework/loader.js +0 -108
- package/dist/src/_framework/reified.d.ts +0 -108
- package/dist/src/_framework/reified.js +0 -237
- package/dist/src/_framework/util.d.ts +0 -35
- package/dist/src/_framework/util.js +0 -396
- package/dist/src/_framework/vector.d.ts +0 -42
- package/dist/src/_framework/vector.js +0 -112
- package/dist/src/pyth.js +0 -1
- package/dist/src/typus_perp/admin/functions.d.ts +0 -59
- package/dist/src/typus_perp/admin/functions.js +0 -122
- package/dist/src/typus_perp/admin/structs.d.ts +0 -467
- package/dist/src/typus_perp/admin/structs.js +0 -1065
- package/dist/src/typus_perp/competition/functions.d.ts +0 -24
- package/dist/src/typus_perp/competition/functions.js +0 -38
- package/dist/src/typus_perp/competition/structs.d.ts +0 -80
- package/dist/src/typus_perp/competition/structs.js +0 -288
- package/dist/src/typus_perp/error/functions.d.ts +0 -73
- package/dist/src/typus_perp/error/functions.js +0 -363
- package/dist/src/typus_perp/escrow/functions.d.ts +0 -17
- package/dist/src/typus_perp/escrow/functions.js +0 -36
- package/dist/src/typus_perp/escrow/structs.d.ts +0 -160
- package/dist/src/typus_perp/escrow/structs.js +0 -324
- package/dist/src/typus_perp/index.d.ts +0 -1
- package/dist/src/typus_perp/index.js +0 -7
- package/dist/src/typus_perp/init.d.ts +0 -2
- package/dist/src/typus_perp/init.js +0 -118
- package/dist/src/typus_perp/lending/functions.d.ts +0 -15
- package/dist/src/typus_perp/lending/functions.js +0 -22
- package/dist/src/typus_perp/lp-pool/functions.d.ts +0 -460
- package/dist/src/typus_perp/lp-pool/functions.js +0 -732
- package/dist/src/typus_perp/lp-pool/structs.d.ts +0 -3705
- package/dist/src/typus_perp/lp-pool/structs.js +0 -6789
- package/dist/src/typus_perp/math/functions.d.ts +0 -29
- package/dist/src/typus_perp/math/functions.js +0 -61
- package/dist/src/typus_perp/position/functions.d.ts +0 -379
- package/dist/src/typus_perp/position/functions.js +0 -713
- package/dist/src/typus_perp/position/structs.d.ts +0 -905
- package/dist/src/typus_perp/position/structs.js +0 -1450
- package/dist/src/typus_perp/symbol/functions.d.ts +0 -9
- package/dist/src/typus_perp/symbol/functions.js +0 -24
- package/dist/src/typus_perp/symbol/structs.d.ts +0 -70
- package/dist/src/typus_perp/symbol/structs.js +0 -235
- package/dist/src/typus_perp/tlp/functions.d.ts +0 -19
- package/dist/src/typus_perp/tlp/functions.js +0 -40
- package/dist/src/typus_perp/tlp/structs.d.ts +0 -121
- package/dist/src/typus_perp/tlp/structs.js +0 -416
- package/dist/src/typus_perp/token-interface/functions.d.ts +0 -11
- package/dist/src/typus_perp/token-interface/functions.js +0 -22
- package/dist/src/typus_perp/trading/functions.d.ts +0 -812
- package/dist/src/typus_perp/trading/functions.js +0 -1218
- package/dist/src/typus_perp/trading/structs.d.ts +0 -3060
- package/dist/src/typus_perp/trading/structs.js +0 -5813
- package/dist/src/typus_perp/treasury-caps/functions.d.ts +0 -9
- package/dist/src/typus_perp/treasury-caps/functions.js +0 -36
- package/dist/src/typus_perp/treasury-caps/structs.d.ts +0 -49
- package/dist/src/typus_perp/treasury-caps/structs.js +0 -223
- package/dist/src/typus_perp/user-account/functions.d.ts +0 -36
- package/dist/src/typus_perp/user-account/functions.js +0 -70
- package/dist/src/typus_perp/user-account/structs.d.ts +0 -148
- package/dist/src/typus_perp/user-account/structs.js +0 -448
- package/dist/src/typus_stake_pool/admin/functions.d.ts +0 -49
- package/dist/src/typus_stake_pool/admin/functions.js +0 -105
- package/dist/src/typus_stake_pool/admin/structs.d.ts +0 -365
- package/dist/src/typus_stake_pool/admin/structs.js +0 -789
- package/dist/src/typus_stake_pool/index.d.ts +0 -1
- package/dist/src/typus_stake_pool/index.js +0 -7
- package/dist/src/typus_stake_pool/init.d.ts +0 -2
- package/dist/src/typus_stake_pool/init.js +0 -69
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +0 -229
- package/dist/src/typus_stake_pool/stake-pool/functions.js +0 -380
- package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +0 -2199
- package/dist/src/typus_stake_pool/stake-pool/structs.js +0 -4653
- /package/dist/src/{pyth.d.ts → grpc/ledgerService.d.ts} +0 -0
package/dist/src/api/sentio.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.getFromSentio = getFromSentio;
|
|
40
4
|
exports.getRecentTradesFromSentio = getRecentTradesFromSentio;
|
|
@@ -47,90 +11,126 @@ exports.getTlpPriceFromSentio = getTlpPriceFromSentio;
|
|
|
47
11
|
exports.getTlpComparisonFromSentio = getTlpComparisonFromSentio;
|
|
48
12
|
exports.getUserPnlFromSentio = getUserPnlFromSentio;
|
|
49
13
|
exports.getLeaderboardFromSentio = getLeaderboardFromSentio;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"api-key": "
|
|
14
|
+
const src_1 = require("../../src");
|
|
15
|
+
const headers = {
|
|
16
|
+
"api-key": "hCsD8shJaUbbiNLMKBG3oKhr9PL3H5EJ5",
|
|
53
17
|
"Content-Type": "application/json",
|
|
54
18
|
};
|
|
55
|
-
function getFromSentio(event, userAddress, startTimestamp, cranker) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
case 1:
|
|
79
|
-
response = _a.sent();
|
|
80
|
-
return [4 /*yield*/, response.json()];
|
|
81
|
-
case 2:
|
|
82
|
-
data = _a.sent();
|
|
83
|
-
// console.log(data);
|
|
84
|
-
if (data.result) {
|
|
85
|
-
return [2 /*return*/, data.result.rows];
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return [2 /*return*/, []];
|
|
89
|
-
}
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
19
|
+
async function getFromSentio(event, userAddress, startTimestamp, cranker) {
|
|
20
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
21
|
+
// add cranker fileter
|
|
22
|
+
let crankerFilter = "";
|
|
23
|
+
if (cranker) {
|
|
24
|
+
crankerFilter = "AND is_cranker == true";
|
|
25
|
+
}
|
|
26
|
+
let requestData = {
|
|
27
|
+
sqlQuery: {
|
|
28
|
+
sql: `
|
|
29
|
+
SELECT *
|
|
30
|
+
FROM ${event}
|
|
31
|
+
WHERE distinct_id = '${userAddress}' AND timestamp >= ${startTimestamp} ${crankerFilter}
|
|
32
|
+
ORDER BY timestamp DESC;
|
|
33
|
+
`,
|
|
34
|
+
size: 1000,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
let jsonData = JSON.stringify(requestData);
|
|
38
|
+
let response = await fetch(apiUrl, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers,
|
|
41
|
+
body: jsonData,
|
|
93
42
|
});
|
|
43
|
+
let data = await response.json();
|
|
44
|
+
// console.log(data);
|
|
45
|
+
if (data.result) {
|
|
46
|
+
return data.result.rows;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
94
51
|
}
|
|
95
|
-
function getRecentTradesFromSentio(base_token) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
52
|
+
async function getRecentTradesFromSentio(base_token) {
|
|
53
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
54
|
+
let tokenFilter = "";
|
|
55
|
+
if (base_token) {
|
|
56
|
+
tokenFilter = `WHERE base_token = '${(0, src_1.toSentioToken)(base_token)}'`;
|
|
57
|
+
}
|
|
58
|
+
let requestData = {
|
|
59
|
+
sqlQuery: {
|
|
60
|
+
sql: `
|
|
61
|
+
SELECT * FROM (
|
|
62
|
+
WITH
|
|
63
|
+
OpenOrder AS (
|
|
64
|
+
SELECT
|
|
65
|
+
PlaceOrder.collateral AS collateral,
|
|
66
|
+
OrderFilled.position_id AS position_id,
|
|
67
|
+
OrderFilled.base_token AS base_token,
|
|
68
|
+
PlaceOrder.transaction_hash as transaction_hash
|
|
69
|
+
FROM PlaceOrder
|
|
70
|
+
JOIN OrderFilled ON OrderFilled.order_id == PlaceOrder.order_id AND OrderFilled.base_token == PlaceOrder.base_token
|
|
71
|
+
WHERE OrderFilled.order_type == 'Open'
|
|
72
|
+
)
|
|
73
|
+
SELECT
|
|
74
|
+
PlaceOrder.timestamp as timestamp,
|
|
75
|
+
PlaceOrder.base_token as base_token,
|
|
76
|
+
PlaceOrder.collateral_token as collateral_token,
|
|
77
|
+
PlaceOrder.order_type as order_type,
|
|
78
|
+
OrderFilled.order_type as status,
|
|
79
|
+
PlaceOrder.side as side,
|
|
80
|
+
PlaceOrder.distinct_id as distinct_id,
|
|
81
|
+
price,
|
|
82
|
+
size,
|
|
83
|
+
realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,
|
|
84
|
+
OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,
|
|
85
|
+
OpenOrder.collateral as collateral,
|
|
86
|
+
PlaceOrder.transaction_hash as transaction_hash
|
|
87
|
+
FROM PlaceOrder
|
|
88
|
+
LEFT JOIN OrderFilled ON OrderFilled.order_id == PlaceOrder.order_id AND OrderFilled.base_token == PlaceOrder.base_token
|
|
89
|
+
LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash
|
|
90
|
+
LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash
|
|
91
|
+
LEFT JOIN RemovePosition ON RemovePosition.transaction_hash == OrderFilled.transaction_hash
|
|
92
|
+
LEFT JOIN OpenOrder ON OpenOrder.position_id == OrderFilled.position_id AND OpenOrder.base_token == PlaceOrder.base_token
|
|
93
|
+
${tokenFilter}
|
|
94
|
+
UNION ALL
|
|
95
|
+
SELECT
|
|
96
|
+
PlaceOrderWithBidReceipt.timestamp as timestamp,
|
|
97
|
+
PlaceOrderWithBidReceipt.base_token as base_token,
|
|
98
|
+
PlaceOrderWithBidReceipt.collateral_token as collateral_token,
|
|
99
|
+
PlaceOrderWithBidReceipt.order_type as order_type,
|
|
100
|
+
OrderFilled.order_type as status,
|
|
101
|
+
PlaceOrderWithBidReceipt.side as side,
|
|
102
|
+
PlaceOrderWithBidReceipt.distinct_id as distinct_id,
|
|
103
|
+
price,
|
|
104
|
+
size,
|
|
105
|
+
realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,
|
|
106
|
+
OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,
|
|
107
|
+
RealizeOption.exercise_balance_value as collateral_amount,
|
|
108
|
+
PlaceOrderWithBidReceipt.transaction_hash as transaction_hash
|
|
109
|
+
FROM PlaceOrderWithBidReceipt
|
|
110
|
+
JOIN OrderFilled ON OrderFilled.order_id == PlaceOrderWithBidReceipt.order_id AND OrderFilled.base_token == PlaceOrderWithBidReceipt.base_token
|
|
111
|
+
LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash
|
|
112
|
+
LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash
|
|
113
|
+
${tokenFilter}
|
|
114
|
+
) AS combined
|
|
115
|
+
ORDER BY timestamp DESC
|
|
116
|
+
`,
|
|
117
|
+
size: 100,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
let jsonData = JSON.stringify(requestData);
|
|
121
|
+
let response = await fetch(apiUrl, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers,
|
|
124
|
+
body: jsonData,
|
|
133
125
|
});
|
|
126
|
+
let data = await response.json();
|
|
127
|
+
// console.log(data);
|
|
128
|
+
if (data.result) {
|
|
129
|
+
return data.result.rows;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Inputs:
|
|
@@ -141,117 +141,100 @@ function getRecentTradesFromSentio(base_token) {
|
|
|
141
141
|
* key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
|
|
142
142
|
* value: Volume[]
|
|
143
143
|
*/
|
|
144
|
-
function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
async function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
|
|
145
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
|
|
146
|
+
let requestData = {
|
|
147
|
+
timeRange: {
|
|
148
|
+
start: `${fromTimestamp}`,
|
|
149
|
+
end: `${toTimestamp ?? now()}`,
|
|
150
|
+
step: 3600 * interval,
|
|
151
|
+
},
|
|
152
|
+
limit: 30 * 24,
|
|
153
|
+
queries: [
|
|
154
|
+
{
|
|
155
|
+
metricsQuery: {
|
|
156
|
+
query: "trading_volume_usd",
|
|
157
|
+
alias: "",
|
|
158
|
+
id: "a",
|
|
159
|
+
labelSelector: {},
|
|
160
|
+
aggregate: {
|
|
161
|
+
op: "SUM",
|
|
162
|
+
grouping: ["base_token"],
|
|
163
|
+
},
|
|
164
|
+
functions: [
|
|
165
|
+
{
|
|
166
|
+
name: "rollup_delta",
|
|
167
|
+
arguments: [
|
|
168
|
+
{
|
|
169
|
+
durationValue: {
|
|
170
|
+
value: interval,
|
|
171
|
+
unit: "h",
|
|
168
172
|
},
|
|
169
|
-
functions: [
|
|
170
|
-
{
|
|
171
|
-
name: "rollup_delta",
|
|
172
|
-
arguments: [
|
|
173
|
-
{
|
|
174
|
-
durationValue: {
|
|
175
|
-
value: interval,
|
|
176
|
-
unit: "h",
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
color: "",
|
|
183
|
-
disabled: false,
|
|
184
173
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
samples = data.results[0].matrix.samples;
|
|
203
|
-
map = new Map();
|
|
204
|
-
samples.forEach(function (sample) {
|
|
205
|
-
// console.log(samples);
|
|
206
|
-
var base_token = sample.metric.labels.base_token;
|
|
207
|
-
var values = sample.values;
|
|
208
|
-
// console.log(base_token);
|
|
209
|
-
// console.log(values);
|
|
210
|
-
map.set(base_token, values);
|
|
211
|
-
});
|
|
212
|
-
// console.log(map);
|
|
213
|
-
// console.log(map.keys());
|
|
214
|
-
// console.log(map.get("SUI")?.length);
|
|
215
|
-
return [2 /*return*/, map];
|
|
216
|
-
}
|
|
217
|
-
});
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
color: "",
|
|
178
|
+
disabled: false,
|
|
179
|
+
},
|
|
180
|
+
dataSource: "METRICS",
|
|
181
|
+
sourceName: "",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
formulas: [],
|
|
185
|
+
};
|
|
186
|
+
let jsonData = JSON.stringify(requestData);
|
|
187
|
+
let response = await fetch(apiUrl, {
|
|
188
|
+
method: "POST",
|
|
189
|
+
headers,
|
|
190
|
+
body: jsonData,
|
|
218
191
|
});
|
|
192
|
+
let data = await response.json();
|
|
193
|
+
let samples = data.results[0].matrix.samples;
|
|
194
|
+
let map = new Map();
|
|
195
|
+
samples.forEach((sample) => {
|
|
196
|
+
// console.log(samples);
|
|
197
|
+
let base_token = sample.metric.labels.base_token;
|
|
198
|
+
let values = sample.values;
|
|
199
|
+
// console.log(base_token);
|
|
200
|
+
// console.log(values);
|
|
201
|
+
map.set(base_token, values);
|
|
202
|
+
});
|
|
203
|
+
// console.log(map);
|
|
204
|
+
// console.log(map.keys());
|
|
205
|
+
// console.log(map.get("SUI")?.length);
|
|
206
|
+
return map;
|
|
219
207
|
}
|
|
220
|
-
function getMinuteTradingVolumeFromSentio(base_token, minute, size) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return [4 /*yield*/, response.json()];
|
|
242
|
-
case 2:
|
|
243
|
-
data = _a.sent();
|
|
244
|
-
// console.log(data);
|
|
245
|
-
if (data.result) {
|
|
246
|
-
return [2 /*return*/, data.result.rows];
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
return [2 /*return*/, []];
|
|
250
|
-
}
|
|
251
|
-
return [2 /*return*/];
|
|
252
|
-
}
|
|
253
|
-
});
|
|
208
|
+
async function getMinuteTradingVolumeFromSentio(base_token, minute, size) {
|
|
209
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
210
|
+
let requestData = {
|
|
211
|
+
sqlQuery: {
|
|
212
|
+
sql: `
|
|
213
|
+
SELECT
|
|
214
|
+
toDateTime(intDiv(toUnixTimestamp(timestamp), 60 * ${minute}) * 60 * ${minute}) as ts_start,
|
|
215
|
+
sum(filled_size) AS total_filled_size
|
|
216
|
+
FROM OrderFilled
|
|
217
|
+
WHERE base_token = '${(0, src_1.toSentioToken)(base_token)}'
|
|
218
|
+
GROUP BY ts_start
|
|
219
|
+
ORDER BY ts_start DESC;
|
|
220
|
+
`,
|
|
221
|
+
size,
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
let jsonData = JSON.stringify(requestData);
|
|
225
|
+
let response = await fetch(apiUrl, {
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers,
|
|
228
|
+
body: jsonData,
|
|
254
229
|
});
|
|
230
|
+
let data = await response.json();
|
|
231
|
+
// console.log(data);
|
|
232
|
+
if (data.result) {
|
|
233
|
+
return data.result.rows;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
255
238
|
}
|
|
256
239
|
function now() {
|
|
257
240
|
return Math.round(Date.now() / 1000);
|
|
@@ -259,352 +242,518 @@ function now() {
|
|
|
259
242
|
function parseTimestamp(s) {
|
|
260
243
|
return Math.round(Date.parse(s) / 1000);
|
|
261
244
|
}
|
|
262
|
-
function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
245
|
+
async function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
|
|
246
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
|
|
247
|
+
let requestData = {
|
|
248
|
+
timeRange: {
|
|
249
|
+
start: `${fromTimestamp ?? 0}`,
|
|
250
|
+
end: `${toTimestamp ?? now()}`,
|
|
251
|
+
step: 3600,
|
|
252
|
+
},
|
|
253
|
+
limit: 20,
|
|
254
|
+
queries: [
|
|
255
|
+
{
|
|
256
|
+
metricsQuery: {
|
|
257
|
+
query: "tlp_fee_usd",
|
|
258
|
+
alias: "",
|
|
259
|
+
id: "a",
|
|
260
|
+
labelSelector: {},
|
|
261
|
+
aggregate: {
|
|
262
|
+
op: "SUM",
|
|
263
|
+
grouping: [],
|
|
264
|
+
},
|
|
265
|
+
functions: [],
|
|
266
|
+
color: "",
|
|
267
|
+
disabled: true,
|
|
268
|
+
},
|
|
269
|
+
dataSource: "METRICS",
|
|
270
|
+
sourceName: "",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
metricsQuery: {
|
|
274
|
+
query: "tlp_fee_usd",
|
|
275
|
+
alias: "1",
|
|
276
|
+
id: "isolated_TYPUS",
|
|
277
|
+
labelSelector: {
|
|
278
|
+
base_token: "TYPUS",
|
|
279
|
+
},
|
|
280
|
+
aggregate: {
|
|
281
|
+
op: "SUM",
|
|
282
|
+
grouping: ["base_token"],
|
|
283
|
+
},
|
|
284
|
+
functions: [],
|
|
285
|
+
color: "",
|
|
286
|
+
disabled: false,
|
|
287
|
+
},
|
|
288
|
+
dataSource: "METRICS",
|
|
289
|
+
sourceName: "",
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
formulas: [
|
|
293
|
+
{
|
|
294
|
+
expression: "a-isolated_TYPUS",
|
|
295
|
+
alias: "0",
|
|
296
|
+
id: "main",
|
|
297
|
+
disabled: false,
|
|
298
|
+
functions: [],
|
|
299
|
+
color: "",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
cachePolicy: {
|
|
303
|
+
noCache: false,
|
|
304
|
+
cacheTtlSecs: 43200,
|
|
305
|
+
cacheRefreshTtlSecs: 1800,
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
let jsonData = JSON.stringify(requestData);
|
|
309
|
+
let response = await fetch(apiUrl, {
|
|
310
|
+
method: "POST",
|
|
311
|
+
headers,
|
|
312
|
+
body: jsonData,
|
|
313
|
+
});
|
|
314
|
+
let data = await response.json();
|
|
315
|
+
// console.dir(data, { depth: null });
|
|
316
|
+
// console.log(data.results[0].matrix.samples[0].values);
|
|
317
|
+
let map = new Map();
|
|
318
|
+
data.results.forEach((result) => {
|
|
319
|
+
// console.dir(result, { depth: null });
|
|
320
|
+
let initial_value = fromTimestamp ? result.matrix.samples[0].values.at(0).value : 0;
|
|
321
|
+
// console.log(initial_value);
|
|
322
|
+
let value = result.matrix.samples[0].values.at(-1).value - initial_value;
|
|
323
|
+
// console.log(value);
|
|
324
|
+
map.set(result.alias, value);
|
|
315
325
|
});
|
|
326
|
+
return map;
|
|
316
327
|
}
|
|
317
|
-
function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
328
|
+
async function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
|
|
329
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
|
|
330
|
+
let requestData = {
|
|
331
|
+
timeRange: {
|
|
332
|
+
start: `${fromTimestamp ?? 0}`,
|
|
333
|
+
end: `${toTimestamp ?? now()}`,
|
|
334
|
+
step: 3600,
|
|
335
|
+
},
|
|
336
|
+
limit: 20,
|
|
337
|
+
queries: [
|
|
338
|
+
{
|
|
339
|
+
metricsQuery: {
|
|
340
|
+
query: "trading_volume_usd",
|
|
341
|
+
alias: "",
|
|
342
|
+
id: "a",
|
|
343
|
+
labelSelector: {},
|
|
344
|
+
aggregate: {
|
|
345
|
+
op: "SUM",
|
|
346
|
+
grouping: [],
|
|
347
|
+
},
|
|
348
|
+
functions: [],
|
|
349
|
+
color: "",
|
|
350
|
+
disabled: true,
|
|
351
|
+
},
|
|
352
|
+
dataSource: "METRICS",
|
|
353
|
+
sourceName: "",
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
metricsQuery: {
|
|
357
|
+
query: "trading_volume_usd",
|
|
358
|
+
alias: "1",
|
|
359
|
+
id: "isolated_TYPUS",
|
|
360
|
+
labelSelector: {
|
|
361
|
+
base_token: "TYPUS",
|
|
362
|
+
},
|
|
363
|
+
aggregate: {
|
|
364
|
+
op: "SUM",
|
|
365
|
+
grouping: ["base_token"],
|
|
366
|
+
},
|
|
367
|
+
functions: [],
|
|
368
|
+
color: "",
|
|
369
|
+
disabled: false,
|
|
370
|
+
},
|
|
371
|
+
dataSource: "METRICS",
|
|
372
|
+
sourceName: "",
|
|
373
|
+
},
|
|
374
|
+
],
|
|
375
|
+
formulas: [
|
|
376
|
+
{
|
|
377
|
+
expression: "a-isolated_TYPUS",
|
|
378
|
+
alias: "0",
|
|
379
|
+
id: "main",
|
|
380
|
+
disabled: false,
|
|
381
|
+
functions: [],
|
|
382
|
+
color: "",
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
cachePolicy: {
|
|
386
|
+
noCache: false,
|
|
387
|
+
cacheTtlSecs: 43200,
|
|
388
|
+
cacheRefreshTtlSecs: 1800,
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
let jsonData = JSON.stringify(requestData);
|
|
392
|
+
let response = await fetch(apiUrl, {
|
|
393
|
+
method: "POST",
|
|
394
|
+
headers,
|
|
395
|
+
body: jsonData,
|
|
396
|
+
});
|
|
397
|
+
let data = await response.json();
|
|
398
|
+
// console.dir(data.results, { depth: null });
|
|
399
|
+
let map = new Map();
|
|
400
|
+
data.results.forEach((result) => {
|
|
401
|
+
// console.dir(result, { depth: null });
|
|
402
|
+
let initial_value = fromTimestamp ? result.matrix.samples[0].values.at(0).value : 0;
|
|
403
|
+
// console.log(initial_value);
|
|
404
|
+
let value = result.matrix.samples[0].values.at(-1).value - initial_value;
|
|
405
|
+
// console.log(value);
|
|
406
|
+
map.set(result.alias, value);
|
|
369
407
|
});
|
|
408
|
+
return map;
|
|
370
409
|
}
|
|
371
410
|
/** Returns Accumulated Users */
|
|
372
|
-
function getAccumulatedUser() {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
aggregation: {
|
|
397
|
-
countUnique: {
|
|
398
|
-
duration: {
|
|
399
|
-
value: 0,
|
|
400
|
-
unit: "day",
|
|
401
|
-
},
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
groupBy: [],
|
|
405
|
-
limit: 1,
|
|
406
|
-
functions: [],
|
|
407
|
-
disabled: false,
|
|
408
|
-
},
|
|
409
|
-
dataSource: "EVENTS",
|
|
410
|
-
sourceName: "",
|
|
411
|
+
async function getAccumulatedUser() {
|
|
412
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
|
|
413
|
+
let requestData = {
|
|
414
|
+
timeRange: {
|
|
415
|
+
start: "now-1h",
|
|
416
|
+
end: "now",
|
|
417
|
+
step: 3600,
|
|
418
|
+
timezone: "Asia/Taipei",
|
|
419
|
+
},
|
|
420
|
+
limit: 1,
|
|
421
|
+
queries: [
|
|
422
|
+
{
|
|
423
|
+
eventsQuery: {
|
|
424
|
+
resource: {
|
|
425
|
+
name: "",
|
|
426
|
+
type: "EVENTS",
|
|
427
|
+
},
|
|
428
|
+
alias: "",
|
|
429
|
+
id: "a",
|
|
430
|
+
aggregation: {
|
|
431
|
+
countUnique: {
|
|
432
|
+
duration: {
|
|
433
|
+
value: 0,
|
|
434
|
+
unit: "day",
|
|
411
435
|
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
});
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
groupBy: [],
|
|
439
|
+
limit: 1,
|
|
440
|
+
functions: [],
|
|
441
|
+
disabled: false,
|
|
442
|
+
},
|
|
443
|
+
dataSource: "EVENTS",
|
|
444
|
+
sourceName: "",
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
formulas: [],
|
|
448
|
+
};
|
|
449
|
+
let jsonData = JSON.stringify(requestData);
|
|
450
|
+
let response = await fetch(apiUrl, {
|
|
451
|
+
method: "POST",
|
|
452
|
+
headers,
|
|
453
|
+
body: jsonData,
|
|
431
454
|
});
|
|
455
|
+
let data = await response.json();
|
|
456
|
+
// console.log(data.results[0].matrix.samples[0].values[0].value);
|
|
457
|
+
let result = data.results[0].matrix.samples[0].values.at(-1).value;
|
|
458
|
+
// console.log(result);
|
|
459
|
+
return result;
|
|
432
460
|
}
|
|
433
461
|
/**
|
|
434
462
|
* Inputs:
|
|
435
463
|
* fromTimestamp: number, toTimestamp?: number
|
|
436
464
|
*
|
|
437
465
|
* Returns
|
|
438
|
-
* { timestamp: string
|
|
466
|
+
* Map<string, { timestamp: string; value: number }[]>
|
|
439
467
|
*/
|
|
440
|
-
function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
return [2 /*return*/, samples[0].values];
|
|
486
|
-
}
|
|
487
|
-
});
|
|
468
|
+
async function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
469
|
+
let apiUrl = "https://api.sentio.xyz/v1/insights/typus/typus_perp/query";
|
|
470
|
+
let requestData = {
|
|
471
|
+
timeRange: {
|
|
472
|
+
start: `${fromTimestamp ?? 0}`,
|
|
473
|
+
end: `${toTimestamp ?? now()}`,
|
|
474
|
+
step: 3600,
|
|
475
|
+
},
|
|
476
|
+
limit: 30 * 24,
|
|
477
|
+
queries: [
|
|
478
|
+
{
|
|
479
|
+
metricsQuery: {
|
|
480
|
+
query: "tlp_price",
|
|
481
|
+
alias: "",
|
|
482
|
+
id: "a",
|
|
483
|
+
labelSelector: {},
|
|
484
|
+
aggregate: null,
|
|
485
|
+
functions: [],
|
|
486
|
+
color: "",
|
|
487
|
+
disabled: false,
|
|
488
|
+
},
|
|
489
|
+
dataSource: "METRICS",
|
|
490
|
+
sourceName: "",
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
formulas: [],
|
|
494
|
+
cachePolicy: {
|
|
495
|
+
noCache: false,
|
|
496
|
+
cacheTtlSecs: 43200,
|
|
497
|
+
cacheRefreshTtlSecs: 1800,
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
let jsonData = JSON.stringify(requestData);
|
|
501
|
+
let response = await fetch(apiUrl, {
|
|
502
|
+
method: "POST",
|
|
503
|
+
headers,
|
|
504
|
+
body: jsonData,
|
|
505
|
+
});
|
|
506
|
+
let data = await response.json();
|
|
507
|
+
// console.dir(data, { depth: null });
|
|
508
|
+
let samples = data.results[0].matrix.samples;
|
|
509
|
+
// console.log(samples[0].values);
|
|
510
|
+
let map = new Map();
|
|
511
|
+
samples.forEach((sample) => {
|
|
512
|
+
map.set(sample.metric.labels.index, sample.values);
|
|
488
513
|
});
|
|
514
|
+
return map;
|
|
489
515
|
}
|
|
490
|
-
function getTlpComparisonFromSentio(startTimestamp, endTimestamp) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
516
|
+
async function getTlpComparisonFromSentio(startTimestamp, endTimestamp) {
|
|
517
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
518
|
+
let requestData = {
|
|
519
|
+
sqlQuery: {
|
|
520
|
+
sql: `
|
|
521
|
+
with
|
|
522
|
+
tlp_hourly as (
|
|
523
|
+
select
|
|
524
|
+
toStartOfHour(timestamp + interval 30 minute) as hour,
|
|
525
|
+
argMin(value, abs(toUnixTimestamp(timestamp) - toUnixTimestamp(toStartOfHour(timestamp + interval 30 minute)))) as tlp_price
|
|
526
|
+
from tlp_price
|
|
527
|
+
WHERE timestamp >= ${startTimestamp} and timestamp < ${endTimestamp}
|
|
528
|
+
group by hour
|
|
529
|
+
),
|
|
530
|
+
|
|
531
|
+
sui_hourly as (
|
|
532
|
+
select
|
|
533
|
+
toStartOfHour(time + interval 30 minute) as hour,
|
|
534
|
+
argMin(price, abs(toUnixTimestamp(time) - toUnixTimestamp(toStartOfHour(time + interval 30 minute)))) as sui_price
|
|
535
|
+
from 'token.prices'
|
|
536
|
+
where symbol = 'sui'
|
|
537
|
+
and time >= ${startTimestamp} and time < ${endTimestamp}
|
|
538
|
+
group by hour
|
|
539
|
+
),
|
|
540
|
+
|
|
541
|
+
merged as (
|
|
542
|
+
select
|
|
543
|
+
t.hour,
|
|
544
|
+
t.tlp_price,
|
|
545
|
+
s.sui_price
|
|
546
|
+
from tlp_hourly t
|
|
547
|
+
join sui_hourly s
|
|
548
|
+
on t.hour = s.hour
|
|
549
|
+
),
|
|
550
|
+
|
|
551
|
+
base as (
|
|
552
|
+
select min(hour) as base_hour
|
|
553
|
+
from merged
|
|
554
|
+
),
|
|
555
|
+
base_prices as (
|
|
556
|
+
select
|
|
557
|
+
anyIf(m.tlp_price, m.hour = b.base_hour) as base_tlp,
|
|
558
|
+
anyIf(m.sui_price, m.hour = b.base_hour) as base_sui
|
|
559
|
+
from merged m
|
|
560
|
+
cross join base b
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
select
|
|
564
|
+
m.hour,
|
|
565
|
+
m.tlp_price,
|
|
566
|
+
m.sui_price,
|
|
567
|
+
100 * m.tlp_price / bp.base_tlp as tlp_value,
|
|
568
|
+
100 * m.sui_price / bp.base_sui as sui_value,
|
|
569
|
+
0.6 * (100 * m.sui_price / bp.base_sui) + 0.4 * 100 as portfolio_60sui_40usdc
|
|
570
|
+
from merged m
|
|
571
|
+
cross join base_prices bp
|
|
572
|
+
order by m.hour;
|
|
573
|
+
`,
|
|
574
|
+
size: 10000,
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
let jsonData = JSON.stringify(requestData);
|
|
578
|
+
let response = await fetch(apiUrl, {
|
|
579
|
+
method: "POST",
|
|
580
|
+
headers,
|
|
581
|
+
body: jsonData,
|
|
524
582
|
});
|
|
583
|
+
let data = await response.json();
|
|
584
|
+
// console.log(data);
|
|
585
|
+
if (data.result) {
|
|
586
|
+
return data.result.rows;
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
return [];
|
|
590
|
+
}
|
|
525
591
|
}
|
|
526
|
-
function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
592
|
+
async function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
|
|
593
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
594
|
+
let userFilter = "";
|
|
595
|
+
if (userAddress) {
|
|
596
|
+
userFilter = `AND address == '${userAddress}'`;
|
|
597
|
+
}
|
|
598
|
+
let requestData = {
|
|
599
|
+
sqlQuery: {
|
|
600
|
+
sql: `
|
|
601
|
+
WITH
|
|
602
|
+
Pnl_history as (
|
|
603
|
+
SELECT
|
|
604
|
+
timestamp as time,
|
|
605
|
+
CAST( realized_pnl AS Float64 ) as Trader_PnlUSD,
|
|
606
|
+
filled_size * filled_price as volumeUSD,
|
|
607
|
+
distinct_id as address
|
|
608
|
+
from OrderFilled
|
|
609
|
+
WHERE timestamp >= ${startTimestamp} and timestamp < ${endTimestamp}
|
|
610
|
+
UNION ALL
|
|
611
|
+
SELECT
|
|
612
|
+
timestamp as time,
|
|
613
|
+
CAST(value_for_lp_pool_usd + liquidator_fee_usd AS Float64) * (-1) as Trader_PnlUSD,
|
|
614
|
+
0 as volumeUSD,
|
|
615
|
+
distinct_id as address
|
|
616
|
+
from Liquidate -- collateral liquidate, liquidate fee不算
|
|
617
|
+
WHERE timestamp >= ${startTimestamp} and timestamp < ${endTimestamp}
|
|
618
|
+
UNION ALL
|
|
619
|
+
SELECT
|
|
620
|
+
timestamp as time,
|
|
621
|
+
CAST(realized_funding_fee_usd AS Float64) * (-1) as Trader_PnlUSD,
|
|
622
|
+
0 as volumeUSD,
|
|
623
|
+
distinct_id as address
|
|
624
|
+
from 'RealizeFunding' -- funding fee 正的是 user paid to pool
|
|
625
|
+
WHERE timestamp >= ${startTimestamp} and timestamp < ${endTimestamp}
|
|
626
|
+
UNION ALL
|
|
627
|
+
SELECT
|
|
628
|
+
timestamp as time,
|
|
629
|
+
CAST(
|
|
630
|
+
user_remaining_in_usd + (realized_loss_value - exercise_balance_value) * (user_remaining_in_usd / user_remaining_value) AS Float64
|
|
631
|
+
) as Trader_PnlUSD,
|
|
632
|
+
0 as volumeUSD,
|
|
633
|
+
distinct_id as address
|
|
634
|
+
from 'RealizeOption'
|
|
635
|
+
WHERE timestamp >= ${startTimestamp} and timestamp < ${endTimestamp}
|
|
636
|
+
),
|
|
637
|
+
sum_Trader_PnlUSD as (
|
|
638
|
+
SELECT
|
|
639
|
+
sum(Trader_PnlUSD) as Trader_PnlUSD,
|
|
640
|
+
sum(volumeUSD) as volumeUSD,
|
|
641
|
+
address
|
|
642
|
+
from Pnl_history
|
|
643
|
+
GROUP BY address
|
|
644
|
+
)
|
|
645
|
+
SELECT
|
|
646
|
+
*
|
|
647
|
+
from sum_Trader_PnlUSD
|
|
648
|
+
where address not in (
|
|
649
|
+
'0xc9ea1b9c3542551189cf26a08f5ca5ed7964aef34c14d06c888d30c8d91867e4',
|
|
650
|
+
'0x83d2cb640ee252bae6b01bd6104c4afc69071e67b688db85a029ce452c61f11c',
|
|
651
|
+
'0x39770d149a9bc9d9639314fca2c380e9061c0d230737635762c5bcc61dee13d0',
|
|
652
|
+
'0x834d17f7b2e167cae224325a17b49babffe168182c418caa0c63a92d6f70b83a',
|
|
653
|
+
'0xd35ae21660aee607ee21e104d093d03643d36efbf79df669092c4411308ed2e2',
|
|
654
|
+
'0xe6cbba68c446f52cf8211c12ae79179233c8f9cec5e0b5008418ec339ca72fea'
|
|
655
|
+
)
|
|
656
|
+
${userFilter}
|
|
657
|
+
order by Trader_PnlUSD desc
|
|
658
|
+
`,
|
|
659
|
+
size: 100,
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
let jsonData = JSON.stringify(requestData);
|
|
663
|
+
let response = await fetch(apiUrl, {
|
|
664
|
+
method: "POST",
|
|
665
|
+
headers,
|
|
666
|
+
body: jsonData,
|
|
564
667
|
});
|
|
668
|
+
let data = await response.json();
|
|
669
|
+
// console.log(data);
|
|
670
|
+
if (data.result) {
|
|
671
|
+
return data.result.rows;
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
return [];
|
|
675
|
+
}
|
|
565
676
|
}
|
|
566
|
-
function getLeaderboardFromSentio(startTs, endTs) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
677
|
+
async function getLeaderboardFromSentio(startTs, endTs) {
|
|
678
|
+
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
679
|
+
let size = (10 * (endTs - startTs)) / 60 / 60 / 24; // day * 10
|
|
680
|
+
let requestData = {
|
|
681
|
+
sqlQuery: {
|
|
682
|
+
sql: `
|
|
683
|
+
WITH
|
|
684
|
+
event AS (
|
|
685
|
+
SELECT
|
|
686
|
+
timestamp,
|
|
687
|
+
toDate(timestamp - INTERVAL 3 HOUR) AS logical_date,
|
|
688
|
+
toDate(timestamp - INTERVAL 3 HOUR) AS date,
|
|
689
|
+
score/power(10, 9) AS volume,
|
|
690
|
+
distinct_id
|
|
691
|
+
FROM Score
|
|
692
|
+
),
|
|
693
|
+
sum_vol AS (
|
|
694
|
+
SELECT
|
|
695
|
+
logical_date,
|
|
696
|
+
distinct_id,
|
|
697
|
+
sum(volume) AS total_volume
|
|
698
|
+
FROM event
|
|
699
|
+
GROUP BY logical_date, distinct_id
|
|
700
|
+
),
|
|
701
|
+
ranked AS (
|
|
702
|
+
SELECT
|
|
703
|
+
*,
|
|
704
|
+
row_number() OVER (PARTITION BY logical_date ORDER BY total_volume DESC) AS rk
|
|
705
|
+
FROM sum_vol
|
|
706
|
+
),
|
|
707
|
+
top10 AS (
|
|
708
|
+
SELECT *
|
|
709
|
+
FROM ranked
|
|
710
|
+
WHERE rk <= 10
|
|
711
|
+
),
|
|
712
|
+
top10_sum AS (
|
|
713
|
+
SELECT
|
|
714
|
+
logical_date,
|
|
715
|
+
sum(total_volume) AS top10_total_volume
|
|
716
|
+
FROM top10
|
|
717
|
+
GROUP BY logical_date
|
|
718
|
+
)
|
|
719
|
+
SELECT
|
|
720
|
+
toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
|
|
721
|
+
t.distinct_id as Address,
|
|
722
|
+
t.total_volume as Trading_Vol,
|
|
723
|
+
cast(t.total_volume AS Decimal256(18)) / cast(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
|
|
724
|
+
Volume_Share_Top10 * 150 as PrizePool_Share
|
|
725
|
+
FROM top10 t
|
|
726
|
+
JOIN top10_sum s ON t.logical_date = s.logical_date
|
|
727
|
+
WHERE Date >= ${startTs} AND Date < ${endTs}
|
|
728
|
+
ORDER BY
|
|
729
|
+
Date DESC,
|
|
730
|
+
t.rk ASC,
|
|
731
|
+
Volume_Share_Top10
|
|
732
|
+
|
|
733
|
+
`,
|
|
734
|
+
size,
|
|
735
|
+
},
|
|
736
|
+
};
|
|
737
|
+
let jsonData = JSON.stringify(requestData);
|
|
738
|
+
let response = await fetch(apiUrl, {
|
|
739
|
+
method: "POST",
|
|
740
|
+
headers,
|
|
741
|
+
body: jsonData,
|
|
601
742
|
});
|
|
743
|
+
let data = await response.json();
|
|
744
|
+
// console.log(data);
|
|
745
|
+
if (data.result) {
|
|
746
|
+
return data.result.rows;
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
return [];
|
|
750
|
+
}
|
|
602
751
|
}
|
|
603
752
|
// getRecentTradesFromSentio().then((x) => console.log(x));
|
|
604
753
|
// getAccumulatedUser().then((x) => console.log(x));
|
|
605
754
|
// getTradingVolumeFromSentio(1747008000, 1, 1747011600);
|
|
606
755
|
// getTlpPriceFromSentio(0).then((x) => console.dir(x, { depth: null }));
|
|
607
|
-
// getTotalVolumeFromSentio(
|
|
756
|
+
// getTotalVolumeFromSentio().then((x) => console.log(x));
|
|
608
757
|
// getTlpFeeFromSentio(0).then((x) => console.log(x));
|
|
609
758
|
// getUserPnlFromSentio(parseTimestamp("2025-06-24 11:00:00"), parseTimestamp("2025-07-08 11:00:00")).then((x) => console.log(x));
|
|
610
759
|
// getMinuteTradingVolumeFromSentio("SUI", 30, 10).then((x) => console.log(x));
|