@typus/typus-sdk 1.2.66 → 1.2.68
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/lib/config.json +155 -0
- package/lib/mainnet.json +2 -2
- package/lib/utils/api/defillama/tvl.d.ts +1 -0
- package/lib/utils/api/defillama/tvl.js +59 -0
- package/lib/utils/{leader-board.d.ts → api/sentio/leader-board.d.ts} +0 -7
- package/lib/utils/api/sentio/leader-board.js +104 -0
- package/lib/utils/api/sentio/reward-generated.d.ts +10 -0
- package/lib/utils/api/sentio/reward-generated.js +256 -0
- package/lib/utils/locked-period-vault/user-entry.d.ts +81 -0
- package/lib/utils/locked-period-vault/user-entry.js +101 -0
- package/lib/utils/typus-dov-single-v2/user-history.js +22 -3
- package/package.json +1 -1
- package/lib/utils/leader-board.js +0 -333
package/lib/config.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"MAINNET": {
|
|
3
|
+
"RPC_ENDPOINT": "https://fullnode.mainnet.sui.io:443",
|
|
4
|
+
"TYPUS_VERSION": "",
|
|
5
|
+
"TGLD_COIN_METADATA": "",
|
|
6
|
+
"TGLD_TOKEN_POLICY": "",
|
|
7
|
+
"NFT_TRANSFER_POLICY": "0x55475b9e16d9a0176dcef37f83a1921b15f2cbd2711a5f30b9d952c0c8f5f957",
|
|
8
|
+
"PACKAGE_ORIGIN": {
|
|
9
|
+
"DOV_SINGLE": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
|
|
10
|
+
"FRAMEWORK": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
|
|
11
|
+
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
|
|
12
|
+
"NFT": "0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196",
|
|
13
|
+
"ORACLE": "0x855eb2d260ee42b898266e6df90bfd3c4ed821ccb253a352c159c223244a4b8a",
|
|
14
|
+
"TYPUS": ""
|
|
15
|
+
},
|
|
16
|
+
"PACKAGE": {
|
|
17
|
+
"DOV_SINGLE": "0x1ee07392805d5b26a1c248b5739b768d426579ac1f4aeb50152f7ca06d3e2a00",
|
|
18
|
+
"FRAMEWORK": "0x6e3a0fa749edd4808a9f827f9b49b02b319d221b8391b01a94974e4b09393591",
|
|
19
|
+
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
|
|
20
|
+
"NFT": "0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196",
|
|
21
|
+
"ORACLE": "0x978f65df8570a075298598a9965c18de9087f9e888eb3430fe20334f5c554cfd",
|
|
22
|
+
"TYPUS": ""
|
|
23
|
+
},
|
|
24
|
+
"REGISTRY": {
|
|
25
|
+
"AIRDROP": "",
|
|
26
|
+
"DOV_SINGLE": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
|
|
27
|
+
"LEADERBOARD": "",
|
|
28
|
+
"MFUD": "0xb8d7e7ab783e56700c0212bd9f0938bba9dd3e7241c149e6c52b21334ec45ece",
|
|
29
|
+
"TGLD": "",
|
|
30
|
+
"USER": ""
|
|
31
|
+
},
|
|
32
|
+
"TOKEN": {
|
|
33
|
+
"FUD": "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD",
|
|
34
|
+
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d::mfud::MFUD",
|
|
35
|
+
"SUI": "0x2::sui::SUI",
|
|
36
|
+
"TGLD": ""
|
|
37
|
+
},
|
|
38
|
+
"ORACLE": {
|
|
39
|
+
"APT": "0x401ed2a4de92950351c54edaa9a8dce5e38bdb6b06e248935c6f6f7d361a99d6",
|
|
40
|
+
"CETUS": "0xaedaa2e76661471924c1ca7edae069317cbe082798dd3bfa31694dc873102532",
|
|
41
|
+
"JUP": "0xd4a5fe0b48a6f8cbe528b5760462f0d9cad8080c8aebb1a9c63c2176c58fb3b3",
|
|
42
|
+
"NAVX": "0x726c5bafa4e8240d36bb42493c82bca30b920e2bcab1da1dca973322352e9f63",
|
|
43
|
+
"SCA": "0x8eb94035d6d54ad6b444dd67310b9ff54a05a54ecf77d5b22a43a75495774bb6",
|
|
44
|
+
"SOL": "0x9712ad1cba00a437fb669e4df1a59568e4267bd8a8ce989452fb63c9f00b59ab",
|
|
45
|
+
"SUI": "0xeb6b3e3300ff884604ead6172b0aeadee3854980cab65a7feb57300b04b74cc1",
|
|
46
|
+
"TURBOS": "0x819ff07b5768d7b9b428b69b123140f6a74b04eaa978a4cbab9055025bd1536d",
|
|
47
|
+
"WBTC": "0x61813dc2e46dba41b14507857827f0ed7e99b0be242548828769728b81c8fab5",
|
|
48
|
+
"WETH": "0x253bbaaa35275240cf6df03258489707ea059762831e4102ebaabafd442bc935"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"TESTNET": {
|
|
52
|
+
"RPC_ENDPOINT": "https://fullnode.testnet.sui.io:443",
|
|
53
|
+
"TYPUS_VERSION": "0x2edc980f55e31ba3c660f4e2650e915fd47fb33b524b01a52a116719adac8be7",
|
|
54
|
+
"TGLD_COIN_METADATA": "0xf77f8aabe64dccef0e568f2ef58a6ca74bdfb31786507cc35b7626a4df0d0ebc",
|
|
55
|
+
"TGLD_TOKEN_POLICY": "0x17875c2f772053cd148bd2b8b8a40160db3f841825d8963192f8394d5c18974c",
|
|
56
|
+
"NFT_TRANSFER_POLICY": "0x1c62271ecc443c3d92a8fe8f5662e877856d26b971d967f66937a65f55160831",
|
|
57
|
+
"PACKAGE_ORIGIN": {
|
|
58
|
+
"DOV_SINGLE": "0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f",
|
|
59
|
+
"FRAMEWORK": "0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded",
|
|
60
|
+
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c",
|
|
61
|
+
"NFT": "0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828",
|
|
62
|
+
"ORACLE": "0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73",
|
|
63
|
+
"TYPUS": "0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277"
|
|
64
|
+
},
|
|
65
|
+
"PACKAGE": {
|
|
66
|
+
"DOV_SINGLE": "0xbbf2e2662033fceead636974e50221ec04a0dfd082cd1a32e3b1f90c11ed7aa5",
|
|
67
|
+
"FRAMEWORK": "0xa304e225551b619b07c06d8965462b268138b2c5774fd22ad8853ef91fbb9771",
|
|
68
|
+
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c",
|
|
69
|
+
"NFT": "0x0f5162014f18686640b8d0adefd60c3fe5b377413ec4f1e77001c67d96f8501a",
|
|
70
|
+
"ORACLE": "0x71fbc7acaf513561dabdeb846e7dd5288108e56edb0b6de8d4999c4dfce21f66",
|
|
71
|
+
"TYPUS": "0xc0d2e234cd1211a0f7b0bac8798d6e8fa8ab5db29d779245c4c4280eb6d16b94"
|
|
72
|
+
},
|
|
73
|
+
"REGISTRY": {
|
|
74
|
+
"AIRDROP": "0xfb2fbf261f6050d100bcd026ffa0076e088506b1bec26313947239303e2a0224",
|
|
75
|
+
"DOV_SINGLE": "0x0285cbf4aa8585be6c978235d11d06fa35773266ede040d38d34e1d79b049460",
|
|
76
|
+
"LEADERBOARD": "0x4faabe5a4a509a145fc9bae95761d34c11571da4cb25d681f06ffcbadbc355e7",
|
|
77
|
+
"MFUD": "0x7ad87901531693f1baa541712947860dcc543617e11b14993ad70d20daf159c6",
|
|
78
|
+
"TGLD": "0x2118b4056c89d90a6dc40d198fbe239cb8e83f7ea20daaf4ea53341c7fdb043c",
|
|
79
|
+
"USER": "0x5f1894a3680949111a7530d63ceda6857d31521ab2de625e9f826cae17c9a7f3"
|
|
80
|
+
},
|
|
81
|
+
"TOKEN": {
|
|
82
|
+
"FUD": "0x461efa7ee5aa1b27e44450d79e2104e7fc0991461e9eb1c2a3fc1f44cd554856::fud::FUD",
|
|
83
|
+
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c::mfud::MFUD",
|
|
84
|
+
"SUI": "0x2::sui::SUI",
|
|
85
|
+
"TGLD": "0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::tgld::TGLD",
|
|
86
|
+
"USDT": "0xa38dad920880f81ea514de6db007d3a84e9116a29c60b3e69bbe418c2d9f553c::usdt::USDT"
|
|
87
|
+
},
|
|
88
|
+
"ORACLE": {
|
|
89
|
+
"AFSUI": "0xacd75f051b8be445226f92d873fbf9bbc26fe25cec5708b1aeec44286dbbef5b",
|
|
90
|
+
"APT": "0x984e79d6cf30cc518e5e69dacacfa8db3e5f0674535c533061a7990c8a714c48",
|
|
91
|
+
"BUCK": "0x22ef75c17468f6ed24574f26011f7fcf61a7b983009c9ba6cacc28ae24ff1782",
|
|
92
|
+
"CETUS": "0xe8142c490363475a4ad0b9af02ac5a543962584f3a99cdb8754d909be6ec550d",
|
|
93
|
+
"INJ": "0xcdf04e2c9f400a713dc46748bc6eddddf472e669e604d13ed1eae8895a46d6c9",
|
|
94
|
+
"JUP": "0xd4a5fe0b48a6f8cbe528b5760462f0d9cad8080c8aebb1a9c63c2176c58fb3b3",
|
|
95
|
+
"NAVX": "0x726c5bafa4e8240d36bb42493c82bca30b920e2bcab1da1dca973322352e9f63",
|
|
96
|
+
"SCA": "0x8eb94035d6d54ad6b444dd67310b9ff54a05a54ecf77d5b22a43a75495774bb6",
|
|
97
|
+
"SEI": "0x3ad81c9951cb4e2e8908c184cea7e9cb52822ef7679f166ef9acf870bfc8e4f2",
|
|
98
|
+
"SOL": "0x0edabd97c679967e00d508c766fb4be0195890f96343bd3a58e10fa5e8063c96",
|
|
99
|
+
"SUI": "0x770f17817e809f22d3cf3ba5f452056622a31dd6a1db7c60c94c5a598aff9a29",
|
|
100
|
+
"TURBOS": "0x9fb8a445ba7ed37251f0ccd778b6cd7010174734562a18921d0684d4e01afe34",
|
|
101
|
+
"USDY": "0x604408004efddc03323cd6f6a72b98695dbdced57a630ca2622e6b96fc94a3f6",
|
|
102
|
+
"WBTC": "0xaa72a2b370cf45a7b1363a2b9e3f0c57c05863375b984e2ca0928973574404f2",
|
|
103
|
+
"WETH": "0x0ac9f9275eb0ac33b7f59741b1df67a6783af2db6d2a4e5aba8ce350d5b6b260"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"MOVEMENT": {
|
|
107
|
+
"RPC_ENDPOINT": "https://sui.devnet.m2.movementlabs.xyz:443",
|
|
108
|
+
"TYPUS_VERSION": "0x78f91a4142a62881bc5ac6f84d43144e02ba32ddec3e0bb2985f6980d044032a",
|
|
109
|
+
"PACKAGE_ORIGIN": {
|
|
110
|
+
"DOV_SINGLE": "0x773fbd026bcdffa6ca746c995a440b711e4b55fb220a6552e12041ede12a5b6b",
|
|
111
|
+
"FRAMEWORK": "0x421b30b0ebf1a60834adaa946cbb8fd0595c42d90c99bfac79a7f450b55c1a44",
|
|
112
|
+
"ORACLE": "0xbf0ff0490f2c33fe0dfea8407cca4c4d4be30a877f5dbffcbad1a078673845da",
|
|
113
|
+
"TOKEN": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e",
|
|
114
|
+
"TYPUS": "0xc7dc8f963a06a3675d9d423435d65c1144b0df1a17aa67b2ec7acabad96be2a4"
|
|
115
|
+
},
|
|
116
|
+
"PACKAGE": {
|
|
117
|
+
"DOV_SINGLE": "0x773fbd026bcdffa6ca746c995a440b711e4b55fb220a6552e12041ede12a5b6b",
|
|
118
|
+
"FRAMEWORK": "0x421b30b0ebf1a60834adaa946cbb8fd0595c42d90c99bfac79a7f450b55c1a44",
|
|
119
|
+
"ORACLE": "0xbf0ff0490f2c33fe0dfea8407cca4c4d4be30a877f5dbffcbad1a078673845da",
|
|
120
|
+
"TOKEN": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e",
|
|
121
|
+
"TYPUS": "0xc7dc8f963a06a3675d9d423435d65c1144b0df1a17aa67b2ec7acabad96be2a4"
|
|
122
|
+
},
|
|
123
|
+
"REGISTRY": {
|
|
124
|
+
"AIRDROP": "0x4300030cda3b3c4774f2bf108fc0461e9d48f6ab91ddd38da80cd4e51f509303",
|
|
125
|
+
"DOV_SINGLE": "0x2cdcf02854b3d75bb3abd2589a20f1288e2b80a4e7021fd8ade30c765d4b477b",
|
|
126
|
+
"LEADERBOARD": "0xf7991a4cbd5ec7977c9950d77ee0e944e8e84b768048ca9c3296acd7226cdcf9"
|
|
127
|
+
},
|
|
128
|
+
"TOKEN_REGISTRY": {
|
|
129
|
+
"BTC": "0x811bed2a13066c606638d71e695799022752291c94e46c334511a837cee7603f",
|
|
130
|
+
"ETH": "0x07323910600d887a12694c8c5dd3c61d919d711a8f34236d385d88a4881b08b5",
|
|
131
|
+
"SOL": "0x10dcc6468670b773e0ab1cbdb57e5e0fd79f29ec259bdbd45ba81a7b9675106c",
|
|
132
|
+
"USDC": "0x6ad27e79cd914de17e68a4cd2a564de65e9cce4b57798c93e96354d8a00e965e",
|
|
133
|
+
"USDT": "0xf9a3d1334132dd916e65abf23680d618b39de0fed6c92a338f30895fe0b134fe"
|
|
134
|
+
},
|
|
135
|
+
"TOKEN": {
|
|
136
|
+
"SUI": "0x2::sui::SUI",
|
|
137
|
+
"BTC": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e::btc::BTC",
|
|
138
|
+
"ETH": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e::eth::ETH",
|
|
139
|
+
"SOL": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e::sol::SOL",
|
|
140
|
+
"USDC": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e::usdc::USDC",
|
|
141
|
+
"USDT": "0xad00cb50c52af6e61b2dc45e7c80a4e0bf6149a5e45b08623fcec33a83361d2e::usdt::USDT"
|
|
142
|
+
},
|
|
143
|
+
"ORACLE_MANAGER_CAP": {
|
|
144
|
+
"SUIUSDC": "0xcda9da5c6fc39bde7adae554b192d9a50c5ff65b8e0c815d646623ab065d63b4",
|
|
145
|
+
"SUIUSDT": "0xcda9da5c6fc39bde7adae554b192d9a50c5ff65b8e0c815d646623ab065d63b4"
|
|
146
|
+
},
|
|
147
|
+
"ORACLE": {
|
|
148
|
+
"SUIUSDC": "0xf7d081223650168e7e7ea02fc2289e6e0795decdbeddb951c1609937b9dfe0cf",
|
|
149
|
+
"SUIUSDT": "0xf26ff14cc14e9342139d6a6c45775f98f006f8d39c8e8dee0aadf8127ce9118f"
|
|
150
|
+
},
|
|
151
|
+
"VAULT": {
|
|
152
|
+
"0": "2hkoQrhPcvch8CMtVx3XkwPDjDDEwr89bkn8Qq5VAg24"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
package/lib/mainnet.json
CHANGED
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"SCALLOP_MARKET": "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
|
|
31
31
|
"SCALLOP_REWARD_POOL_FOR_SUI": "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
|
|
32
32
|
"SCALLOP_REWARD_POOL_FOR_USDC": "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
|
|
33
|
-
"VERSION": "2.
|
|
33
|
+
"VERSION": "2.22.3",
|
|
34
34
|
"EXP_GUESS_PACKAGE": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
|
|
35
35
|
"EXP_GUESS_PACKAGE_ORIGIN": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
|
|
36
36
|
"EXP_GUESS_REGISTRY": "0x70c6cbe6764b315cee1b24f483a0fc8307f047f1fab2a0d4438624845e6ba3f2",
|
|
37
37
|
"FRAMEWORK_PACKAGE": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
|
|
38
|
-
"SINGLE_COLLATERAL_PACKAGE": "
|
|
38
|
+
"SINGLE_COLLATERAL_PACKAGE": "0x1ee07392805d5b26a1c248b5739b768d426579ac1f4aeb50152f7ca06d3e2a00",
|
|
39
39
|
"SINGLE_COLLATERAL_PACKAGE_ORIGIN": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
|
|
40
40
|
"SINGLE_COLLATERAL_REGISTRY": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
|
|
41
41
|
"SINGLE_COLLATERAL_PORTFOLIO_VAULT_REGISTRY": "0xa1a186d050e3172ef4701c16048c99b11f785969874fa2642b9cbcf59cde7fc0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTvl(): Promise<number>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getTvl = void 0;
|
|
40
|
+
function getTvl() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var response, data;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0: return [4 /*yield*/, fetch("https://api.llama.fi/tvl/typus-finance", {
|
|
46
|
+
method: "GET",
|
|
47
|
+
})];
|
|
48
|
+
case 1:
|
|
49
|
+
response = _a.sent();
|
|
50
|
+
return [4 /*yield*/, response.json()];
|
|
51
|
+
case 2:
|
|
52
|
+
data = _a.sent();
|
|
53
|
+
// console.log(data);
|
|
54
|
+
return [2 /*return*/, data];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.getTvl = getTvl;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
2
|
-
export declare function getBidderLeaderBoard(startTimestamp?: string, end?: string): Promise<LeaderBoard[]>;
|
|
3
|
-
interface LeaderBoard {
|
|
4
|
-
user: string;
|
|
5
|
-
score: number;
|
|
6
|
-
}
|
|
7
1
|
export interface ExpLeaderBoard {
|
|
8
2
|
nft_id: string;
|
|
9
3
|
total_exp_earn: number;
|
|
@@ -11,4 +5,3 @@ export interface ExpLeaderBoard {
|
|
|
11
5
|
}
|
|
12
6
|
export declare function getExpLeaderBoardWithOwner(expLeaderBoard: ExpLeaderBoard[], ownerMap: Map<string, string>): Promise<ExpLeaderBoard[]>;
|
|
13
7
|
export declare function getExpLeaderBoard(startTimestamp: string, endTimestamp?: string): Promise<ExpLeaderBoard[]>;
|
|
14
|
-
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// const apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
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;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getExpLeaderBoard = exports.getExpLeaderBoardWithOwner = void 0;
|
|
41
|
+
function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
return [2 /*return*/, expLeaderBoard.map(function (l) {
|
|
45
|
+
l.owner = ownerMap.get(l.nft_id);
|
|
46
|
+
return l;
|
|
47
|
+
})];
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.getExpLeaderBoardWithOwner = getExpLeaderBoardWithOwner;
|
|
52
|
+
var headers = {
|
|
53
|
+
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
};
|
|
56
|
+
function getExpLeaderBoard(startTimestamp, endTimestamp) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var apiUrl, _endTimestamp, requestData, jsonData, response, data;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
63
|
+
_endTimestamp = endTimestamp ? endTimestamp : "9999999999";
|
|
64
|
+
requestData = {
|
|
65
|
+
sqlQuery: {
|
|
66
|
+
// sql: `SELECT S.distinct_id AS owner, SUM(E.exp_earn) AS total_exp_earn
|
|
67
|
+
// FROM ExpUp E
|
|
68
|
+
// JOIN (
|
|
69
|
+
// SELECT number, distinct_id
|
|
70
|
+
// FROM StakeNft
|
|
71
|
+
// WHERE (number, timestamp) IN (
|
|
72
|
+
// SELECT number, MAX(timestamp) AS max_timestamp
|
|
73
|
+
// FROM StakeNft
|
|
74
|
+
// GROUP BY number
|
|
75
|
+
// )
|
|
76
|
+
// ) S ON E.number = S.number
|
|
77
|
+
// WHERE E.timestamp >= ${startTimestamp} && E.timestamp < ${_endTimestamp}
|
|
78
|
+
// GROUP BY owner
|
|
79
|
+
// ORDER BY total_exp_earn DESC;`,
|
|
80
|
+
sql: "\n SELECT E.nft_id as nft_id, SUM(E.exp_earn) as total_exp_earn\n FROM ExpUp E\n WHERE E.timestamp >= ".concat(startTimestamp, " && E.timestamp < ").concat(_endTimestamp, "\n GROUP BY nft_id\n ORDER BY total_exp_earn DESC;\n "),
|
|
81
|
+
size: 200,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
jsonData = JSON.stringify(requestData);
|
|
85
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: headers,
|
|
88
|
+
body: jsonData,
|
|
89
|
+
})];
|
|
90
|
+
case 1:
|
|
91
|
+
response = _a.sent();
|
|
92
|
+
return [4 /*yield*/, response.json()];
|
|
93
|
+
case 2:
|
|
94
|
+
data = _a.sent();
|
|
95
|
+
return [2 /*return*/, data.result.rows];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.getExpLeaderBoard = getExpLeaderBoard;
|
|
101
|
+
// (async () => {
|
|
102
|
+
// const res1 = await getExpLeaderBoard("0");
|
|
103
|
+
// console.log(res1);
|
|
104
|
+
// })();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getTotalDepositorIncentive(): Promise<TokenAmount>;
|
|
2
|
+
export declare function getTotalPremium(): Promise<number>;
|
|
3
|
+
export declare function getTotalProfitSharingClaimed(): Promise<TokenAmount[]>;
|
|
4
|
+
import { SuiClient } from "@mysten/sui.js/client";
|
|
5
|
+
export declare function getTotalProfitSharing(provider: SuiClient): Promise<TokenAmount[]>;
|
|
6
|
+
interface TokenAmount {
|
|
7
|
+
token: string;
|
|
8
|
+
total_amount: string;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,256 @@
|
|
|
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;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.getTotalProfitSharing = exports.getTotalProfitSharingClaimed = exports.getTotalPremium = exports.getTotalDepositorIncentive = void 0;
|
|
51
|
+
var headers = {
|
|
52
|
+
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
};
|
|
55
|
+
function getTotalDepositorIncentive() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
62
|
+
requestData = {
|
|
63
|
+
sqlQuery: {
|
|
64
|
+
sql: "\n SELECT SUM(E.depositor_incentive_value) as incentive\n FROM Delivery E\n ",
|
|
65
|
+
size: 2000000,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
jsonData = JSON.stringify(requestData);
|
|
69
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: headers,
|
|
72
|
+
body: jsonData,
|
|
73
|
+
})];
|
|
74
|
+
case 1:
|
|
75
|
+
response = _a.sent();
|
|
76
|
+
return [4 /*yield*/, response.json()];
|
|
77
|
+
case 2:
|
|
78
|
+
data = _a.sent();
|
|
79
|
+
return [2 /*return*/, { token: "SUI", total_amount: data.result.rows[0].incentive }];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.getTotalDepositorIncentive = getTotalDepositorIncentive;
|
|
85
|
+
function getTotalPremium() {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
|
|
92
|
+
requestData = {
|
|
93
|
+
timeRange: {
|
|
94
|
+
start: "now",
|
|
95
|
+
end: "now",
|
|
96
|
+
step: 3600,
|
|
97
|
+
timezone: "Europe/Paris",
|
|
98
|
+
},
|
|
99
|
+
limit: 1,
|
|
100
|
+
queries: [
|
|
101
|
+
{
|
|
102
|
+
metricsQuery: {
|
|
103
|
+
query: "PremiumUSD",
|
|
104
|
+
alias: "",
|
|
105
|
+
id: "a",
|
|
106
|
+
labelSelector: {},
|
|
107
|
+
aggregate: {
|
|
108
|
+
op: "SUM",
|
|
109
|
+
grouping: ["chain"],
|
|
110
|
+
},
|
|
111
|
+
functions: [
|
|
112
|
+
{
|
|
113
|
+
name: "sum_over_time",
|
|
114
|
+
arguments: [
|
|
115
|
+
{
|
|
116
|
+
durationValue: {
|
|
117
|
+
value: 520,
|
|
118
|
+
unit: "w",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
disabled: false,
|
|
125
|
+
},
|
|
126
|
+
dataSource: "METRICS",
|
|
127
|
+
sourceName: "",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
formulas: [],
|
|
131
|
+
};
|
|
132
|
+
jsonData = JSON.stringify(requestData);
|
|
133
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: headers,
|
|
136
|
+
body: jsonData,
|
|
137
|
+
})];
|
|
138
|
+
case 1:
|
|
139
|
+
response = _a.sent();
|
|
140
|
+
return [4 /*yield*/, response.json()];
|
|
141
|
+
case 2:
|
|
142
|
+
data = _a.sent();
|
|
143
|
+
return [2 /*return*/, data.results[0].matrix.samples[0].values[0].value];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.getTotalPremium = getTotalPremium;
|
|
149
|
+
function getTotalProfitSharingClaimed() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
156
|
+
requestData = {
|
|
157
|
+
sqlQuery: {
|
|
158
|
+
sql: "\n SELECT token, SUM(amount) AS total_amount\n FROM ClaimProfitSharing\n GROUP BY token;\n ",
|
|
159
|
+
size: 2000000,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
jsonData = JSON.stringify(requestData);
|
|
163
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
164
|
+
method: "POST",
|
|
165
|
+
headers: headers,
|
|
166
|
+
body: jsonData,
|
|
167
|
+
})];
|
|
168
|
+
case 1:
|
|
169
|
+
response = _a.sent();
|
|
170
|
+
return [4 /*yield*/, response.json()];
|
|
171
|
+
case 2:
|
|
172
|
+
data = _a.sent();
|
|
173
|
+
return [2 /*return*/, data.result.rows];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.getTotalProfitSharingClaimed = getTotalProfitSharingClaimed;
|
|
179
|
+
function getTotalProfitSharing(provider) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var hasNextPage, cursor, datas, result, tokenAmountMap, datas_1, datas_1_1, data, token, value, amount, sum, tokenAmount, _a, _b, x;
|
|
182
|
+
var e_1, _c, e_2, _d;
|
|
183
|
+
return __generator(this, function (_e) {
|
|
184
|
+
switch (_e.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
hasNextPage = true;
|
|
187
|
+
cursor = undefined;
|
|
188
|
+
datas = [];
|
|
189
|
+
_e.label = 1;
|
|
190
|
+
case 1:
|
|
191
|
+
if (!hasNextPage) return [3 /*break*/, 3];
|
|
192
|
+
return [4 /*yield*/, provider.queryEvents({
|
|
193
|
+
query: {
|
|
194
|
+
MoveEventType: "0x80ff0830313b36bb65ab927af811037f8b175d6e83c43f906b8f55d9263eea99::tails_staking::ProfitSharingEvent",
|
|
195
|
+
},
|
|
196
|
+
order: "descending",
|
|
197
|
+
cursor: cursor,
|
|
198
|
+
})];
|
|
199
|
+
case 2:
|
|
200
|
+
result = _e.sent();
|
|
201
|
+
hasNextPage = result.hasNextPage;
|
|
202
|
+
cursor = result.nextCursor;
|
|
203
|
+
// @ts-ignore
|
|
204
|
+
datas = datas.concat(result.data);
|
|
205
|
+
return [3 /*break*/, 1];
|
|
206
|
+
case 3:
|
|
207
|
+
tokenAmountMap = new Map();
|
|
208
|
+
try {
|
|
209
|
+
for (datas_1 = __values(datas), datas_1_1 = datas_1.next(); !datas_1_1.done; datas_1_1 = datas_1.next()) {
|
|
210
|
+
data = datas_1_1.value;
|
|
211
|
+
token = (0, token_1.typeArgToAsset)(data.parsedJson.token.name);
|
|
212
|
+
value = data.parsedJson.value;
|
|
213
|
+
amount = value / Math.pow(10, (0, token_1.assetToDecimal)(token));
|
|
214
|
+
// const week = Math.round(Number(data.timestampMs) / 24 / 3600 / 1000);
|
|
215
|
+
if (tokenAmountMap.has(token)) {
|
|
216
|
+
sum = tokenAmountMap.get(token);
|
|
217
|
+
tokenAmountMap.set(token, sum + Number(amount));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
tokenAmountMap.set(token, Number(amount));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
225
|
+
finally {
|
|
226
|
+
try {
|
|
227
|
+
if (datas_1_1 && !datas_1_1.done && (_c = datas_1.return)) _c.call(datas_1);
|
|
228
|
+
}
|
|
229
|
+
finally { if (e_1) throw e_1.error; }
|
|
230
|
+
}
|
|
231
|
+
tokenAmount = [];
|
|
232
|
+
try {
|
|
233
|
+
for (_a = __values(tokenAmountMap.entries()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
234
|
+
x = _b.value;
|
|
235
|
+
tokenAmount.push({ token: x[0], total_amount: x[1].toString() });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
239
|
+
finally {
|
|
240
|
+
try {
|
|
241
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
242
|
+
}
|
|
243
|
+
finally { if (e_2) throw e_2.error; }
|
|
244
|
+
}
|
|
245
|
+
return [2 /*return*/, tokenAmount];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
exports.getTotalProfitSharing = getTotalProfitSharing;
|
|
251
|
+
var token_1 = require("../../token");
|
|
252
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
return [2 /*return*/];
|
|
255
|
+
});
|
|
256
|
+
}); })();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TransactionBlock, TransactionObjectArgument } from "@mysten/sui.js/transactions";
|
|
2
|
+
/**
|
|
3
|
+
public fun lock_receipt(
|
|
4
|
+
registry: &mut Registry,
|
|
5
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
6
|
+
index: u64,
|
|
7
|
+
receipt: TypusDepositReceipt, // from tails_staking::deposit result or owned
|
|
8
|
+
split_active_share: u64,
|
|
9
|
+
split_warmup_share: u64,
|
|
10
|
+
clock: &Clock,
|
|
11
|
+
ctx: &mut TxContext
|
|
12
|
+
): TypusDepositReceipt
|
|
13
|
+
*/
|
|
14
|
+
export declare function getLockReceiptTx(input: {
|
|
15
|
+
tx: TransactionBlock;
|
|
16
|
+
lockedVaultPackageId: string;
|
|
17
|
+
typusDovSingleRegistry: string;
|
|
18
|
+
lockedVaultRegistry: string;
|
|
19
|
+
index: string;
|
|
20
|
+
receipt: TransactionObjectArgument;
|
|
21
|
+
split_active_share: string;
|
|
22
|
+
split_warmup_share: string;
|
|
23
|
+
}): TransactionBlock;
|
|
24
|
+
/**
|
|
25
|
+
public fun leave(
|
|
26
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
27
|
+
index: u64,
|
|
28
|
+
clock: &Clock,
|
|
29
|
+
ctx: &mut TxContext
|
|
30
|
+
)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLeaveTx(input: {
|
|
33
|
+
tx: TransactionBlock;
|
|
34
|
+
lockedVaultPackageId: string;
|
|
35
|
+
lockedVaultRegistry: string;
|
|
36
|
+
index: string;
|
|
37
|
+
}): TransactionBlock;
|
|
38
|
+
/**
|
|
39
|
+
public fun unlock_receipt(
|
|
40
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
41
|
+
index: u64,
|
|
42
|
+
ctx: &mut TxContext
|
|
43
|
+
)
|
|
44
|
+
*/
|
|
45
|
+
export declare function getUnlockReceiptTx(input: {
|
|
46
|
+
tx: TransactionBlock;
|
|
47
|
+
lockedVaultPackageId: string;
|
|
48
|
+
lockedVaultRegistry: string;
|
|
49
|
+
index: string;
|
|
50
|
+
}): TransactionBlock;
|
|
51
|
+
/**
|
|
52
|
+
public fun withdraw_incentive<T>(
|
|
53
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
54
|
+
index: u64,
|
|
55
|
+
ctx: &mut TxContext
|
|
56
|
+
): Coin<T>
|
|
57
|
+
*/
|
|
58
|
+
export declare function getWithdrawIncentiveTx(input: {
|
|
59
|
+
tx: TransactionBlock;
|
|
60
|
+
lockedVaultPackageId: string;
|
|
61
|
+
lockedVaultRegistry: string;
|
|
62
|
+
index: string;
|
|
63
|
+
sender: string;
|
|
64
|
+
}): TransactionBlock;
|
|
65
|
+
/**
|
|
66
|
+
public fun withdraw_premium<D_TOKEN, B_TOKEN>(
|
|
67
|
+
registry: &mut Registry,
|
|
68
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
69
|
+
index: u64,
|
|
70
|
+
ctx: &mut TxContext
|
|
71
|
+
): Coin<B_TOKEN>
|
|
72
|
+
*/
|
|
73
|
+
export declare function getWithdrawPremiumTx(input: {
|
|
74
|
+
tx: TransactionBlock;
|
|
75
|
+
lockedVaultPackageId: string;
|
|
76
|
+
typusDovSingleRegistry: string;
|
|
77
|
+
lockedVaultRegistry: string;
|
|
78
|
+
index: string;
|
|
79
|
+
sender: string;
|
|
80
|
+
typeArguments: string[];
|
|
81
|
+
}): TransactionBlock;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWithdrawPremiumTx = exports.getWithdrawIncentiveTx = exports.getUnlockReceiptTx = exports.getLeaveTx = exports.getLockReceiptTx = void 0;
|
|
4
|
+
var constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
public fun lock_receipt(
|
|
7
|
+
registry: &mut Registry,
|
|
8
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
9
|
+
index: u64,
|
|
10
|
+
receipt: TypusDepositReceipt, // from tails_staking::deposit result or owned
|
|
11
|
+
split_active_share: u64,
|
|
12
|
+
split_warmup_share: u64,
|
|
13
|
+
clock: &Clock,
|
|
14
|
+
ctx: &mut TxContext
|
|
15
|
+
): TypusDepositReceipt
|
|
16
|
+
*/
|
|
17
|
+
function getLockReceiptTx(input) {
|
|
18
|
+
input.tx.moveCall({
|
|
19
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::lock_receipt"),
|
|
20
|
+
typeArguments: [],
|
|
21
|
+
arguments: [
|
|
22
|
+
input.tx.object(input.typusDovSingleRegistry),
|
|
23
|
+
input.tx.object(input.lockedVaultRegistry),
|
|
24
|
+
input.tx.pure(input.index),
|
|
25
|
+
input.receipt,
|
|
26
|
+
input.tx.pure(input.split_active_share),
|
|
27
|
+
input.tx.pure(input.split_warmup_share),
|
|
28
|
+
input.tx.pure(constants_1.CLOCK),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
return input.tx;
|
|
32
|
+
}
|
|
33
|
+
exports.getLockReceiptTx = getLockReceiptTx;
|
|
34
|
+
/**
|
|
35
|
+
public fun leave(
|
|
36
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
37
|
+
index: u64,
|
|
38
|
+
clock: &Clock,
|
|
39
|
+
ctx: &mut TxContext
|
|
40
|
+
)
|
|
41
|
+
*/
|
|
42
|
+
function getLeaveTx(input) {
|
|
43
|
+
input.tx.moveCall({
|
|
44
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::leave"),
|
|
45
|
+
typeArguments: [],
|
|
46
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index), input.tx.pure(constants_1.CLOCK)],
|
|
47
|
+
});
|
|
48
|
+
return input.tx;
|
|
49
|
+
}
|
|
50
|
+
exports.getLeaveTx = getLeaveTx;
|
|
51
|
+
/**
|
|
52
|
+
public fun unlock_receipt(
|
|
53
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
54
|
+
index: u64,
|
|
55
|
+
ctx: &mut TxContext
|
|
56
|
+
)
|
|
57
|
+
*/
|
|
58
|
+
function getUnlockReceiptTx(input) {
|
|
59
|
+
input.tx.moveCall({
|
|
60
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::unlock_receipt"),
|
|
61
|
+
typeArguments: [],
|
|
62
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
63
|
+
});
|
|
64
|
+
return input.tx;
|
|
65
|
+
}
|
|
66
|
+
exports.getUnlockReceiptTx = getUnlockReceiptTx;
|
|
67
|
+
/**
|
|
68
|
+
public fun withdraw_incentive<T>(
|
|
69
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
70
|
+
index: u64,
|
|
71
|
+
ctx: &mut TxContext
|
|
72
|
+
): Coin<T>
|
|
73
|
+
*/
|
|
74
|
+
function getWithdrawIncentiveTx(input) {
|
|
75
|
+
var coin = input.tx.moveCall({
|
|
76
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::withdraw_incentive"),
|
|
77
|
+
typeArguments: ["0x2::sui::SUI"],
|
|
78
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
79
|
+
});
|
|
80
|
+
input.tx.transferObjects([coin], input.sender);
|
|
81
|
+
return input.tx;
|
|
82
|
+
}
|
|
83
|
+
exports.getWithdrawIncentiveTx = getWithdrawIncentiveTx;
|
|
84
|
+
/**
|
|
85
|
+
public fun withdraw_premium<D_TOKEN, B_TOKEN>(
|
|
86
|
+
registry: &mut Registry,
|
|
87
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
88
|
+
index: u64,
|
|
89
|
+
ctx: &mut TxContext
|
|
90
|
+
): Coin<B_TOKEN>
|
|
91
|
+
*/
|
|
92
|
+
function getWithdrawPremiumTx(input) {
|
|
93
|
+
var coin = input.tx.moveCall({
|
|
94
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::withdraw_premium"),
|
|
95
|
+
typeArguments: input.typeArguments,
|
|
96
|
+
arguments: [input.tx.object(input.typusDovSingleRegistry), input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
97
|
+
});
|
|
98
|
+
input.tx.transferObjects([coin], input.sender);
|
|
99
|
+
return input.tx;
|
|
100
|
+
}
|
|
101
|
+
exports.getWithdrawPremiumTx = getWithdrawPremiumTx;
|
|
@@ -304,10 +304,25 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
304
304
|
Action = "Rebate";
|
|
305
305
|
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
306
306
|
break;
|
|
307
|
-
case "ClaimProfitSharingEvent":
|
|
307
|
+
// case "ClaimProfitSharingEvent":
|
|
308
|
+
// var token = typeArgToAsset("0x" + event.parsedJson!.token.name);
|
|
309
|
+
// var amount = Number(event.parsedJson!.value) / 10 ** assetToDecimal(token)!;
|
|
310
|
+
// Action = "Claim Profit Sharing";
|
|
311
|
+
// Amount = `${BigNumber(amount).toFixed()} ${token}`;
|
|
312
|
+
// Tails = `#${event.parsedJson!.number}`;
|
|
313
|
+
// break;
|
|
314
|
+
case "ClaimProfitSharingEventV2":
|
|
308
315
|
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
309
316
|
amount = Number(event.parsedJson.value) / Math.pow(10, (0, token_1.assetToDecimal)(token));
|
|
310
|
-
|
|
317
|
+
// dice_profit, exp_profit
|
|
318
|
+
switch (event.parsedJson.name) {
|
|
319
|
+
case "dice_profit":
|
|
320
|
+
Action = "Harvest Dice Profit";
|
|
321
|
+
break;
|
|
322
|
+
case "exp_profit":
|
|
323
|
+
Action = "Harvest Leaderboard Prize";
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
311
326
|
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
312
327
|
Tails = "#".concat(event.parsedJson.number);
|
|
313
328
|
break;
|
|
@@ -396,7 +411,7 @@ function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
|
|
|
396
411
|
};
|
|
397
412
|
requestData = {
|
|
398
413
|
sqlQuery: {
|
|
399
|
-
sql: "\n SELECT *\n FROM NewBid N\n JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
|
|
414
|
+
sql: "\n SELECT *\n FROM NewBid N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
|
|
400
415
|
size: 1000,
|
|
401
416
|
},
|
|
402
417
|
};
|
|
@@ -413,6 +428,10 @@ function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
|
|
|
413
428
|
data = _a.sent();
|
|
414
429
|
return [2 /*return*/, data.result.rows.map(function (x) {
|
|
415
430
|
var _a = __read(parseVaultInfo(vaults, x.index, "NewBidEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
431
|
+
if (x.number == "0" && x.exp_earn == "0") {
|
|
432
|
+
x.number = undefined;
|
|
433
|
+
x.exp_earn = undefined;
|
|
434
|
+
}
|
|
416
435
|
var txHistory = {
|
|
417
436
|
Index: x.index,
|
|
418
437
|
Period: Period,
|
package/package.json
CHANGED
|
@@ -1,333 +0,0 @@
|
|
|
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;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.getExpLeaderBoard = exports.getExpLeaderBoardWithOwner = exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
|
|
56
|
-
var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
|
|
57
|
-
var headers = {
|
|
58
|
-
"api-key": "oBOW8DsO1izVrINCy6Tmxga9YcWeOL87O",
|
|
59
|
-
"Content-Type": "application/json",
|
|
60
|
-
};
|
|
61
|
-
var depositorRequestData = {
|
|
62
|
-
timeRange: {
|
|
63
|
-
start: "-7d",
|
|
64
|
-
end: "now",
|
|
65
|
-
step: 3600,
|
|
66
|
-
},
|
|
67
|
-
limit: 200,
|
|
68
|
-
queries: [
|
|
69
|
-
{
|
|
70
|
-
metricsQuery: {
|
|
71
|
-
query: "depositTvl",
|
|
72
|
-
alias: "",
|
|
73
|
-
id: "a",
|
|
74
|
-
labelSelector: {},
|
|
75
|
-
aggregate: {
|
|
76
|
-
op: "SUM",
|
|
77
|
-
grouping: ["user", "coin_symbol"],
|
|
78
|
-
},
|
|
79
|
-
functions: [],
|
|
80
|
-
disabled: true,
|
|
81
|
-
},
|
|
82
|
-
dataSource: "METRICS",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
priceQuery: {
|
|
86
|
-
id: "b",
|
|
87
|
-
alias: "",
|
|
88
|
-
coinId: [
|
|
89
|
-
{
|
|
90
|
-
symbol: "SUI",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
symbol: "USDC",
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
disabled: true,
|
|
97
|
-
},
|
|
98
|
-
dataSource: "PRICE",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
formulas: [
|
|
102
|
-
{
|
|
103
|
-
expression: "a*b",
|
|
104
|
-
alias: "{{user}}",
|
|
105
|
-
id: "A",
|
|
106
|
-
disabled: false,
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
};
|
|
110
|
-
function getDepositorLeaderBoard(start, end, step) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
var jsonData, response, data, samples, len_1, leader_board, userScoreMap, result, e_1;
|
|
113
|
-
return __generator(this, function (_a) {
|
|
114
|
-
switch (_a.label) {
|
|
115
|
-
case 0:
|
|
116
|
-
if (start) {
|
|
117
|
-
depositorRequestData.timeRange.start = start;
|
|
118
|
-
}
|
|
119
|
-
if (end) {
|
|
120
|
-
depositorRequestData.timeRange.end = end;
|
|
121
|
-
}
|
|
122
|
-
if (step) {
|
|
123
|
-
depositorRequestData.timeRange.step = step;
|
|
124
|
-
}
|
|
125
|
-
jsonData = JSON.stringify(depositorRequestData);
|
|
126
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
127
|
-
method: "POST",
|
|
128
|
-
headers: headers,
|
|
129
|
-
body: jsonData,
|
|
130
|
-
})];
|
|
131
|
-
case 1:
|
|
132
|
-
response = _a.sent();
|
|
133
|
-
_a.label = 2;
|
|
134
|
-
case 2:
|
|
135
|
-
_a.trys.push([2, 4, , 5]);
|
|
136
|
-
return [4 /*yield*/, response.json()];
|
|
137
|
-
case 3:
|
|
138
|
-
data = _a.sent();
|
|
139
|
-
samples = data.results[0].matrix.samples;
|
|
140
|
-
len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0) - 1;
|
|
141
|
-
leader_board = samples
|
|
142
|
-
.map(function (element) {
|
|
143
|
-
// console.log("metric:", element.metric, "values: ", element.values);
|
|
144
|
-
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
145
|
-
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / len_1; }, 0);
|
|
146
|
-
return {
|
|
147
|
-
user: element.metric.labels.user,
|
|
148
|
-
score: sum,
|
|
149
|
-
};
|
|
150
|
-
})
|
|
151
|
-
.filter(function (element) { return element.score != 0; });
|
|
152
|
-
userScoreMap = leader_board.reduce(function (map, obj) {
|
|
153
|
-
if (map[obj.user]) {
|
|
154
|
-
map[obj.user] += obj.score;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
map[obj.user] = obj.score;
|
|
158
|
-
}
|
|
159
|
-
return map;
|
|
160
|
-
}, {});
|
|
161
|
-
result = Object.entries(userScoreMap).map(function (_a) {
|
|
162
|
-
var _b = __read(_a, 2), user = _b[0], score = _b[1];
|
|
163
|
-
return ({ user: user, score: score });
|
|
164
|
-
});
|
|
165
|
-
result.sort(function (a, b) { return b.score - a.score; });
|
|
166
|
-
// console.log(result);
|
|
167
|
-
return [2 /*return*/, result];
|
|
168
|
-
case 4:
|
|
169
|
-
e_1 = _a.sent();
|
|
170
|
-
return [2 /*return*/, []];
|
|
171
|
-
case 5: return [2 /*return*/];
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
exports.getDepositorLeaderBoard = getDepositorLeaderBoard;
|
|
177
|
-
var bidderRequestData = {
|
|
178
|
-
timeRange: {
|
|
179
|
-
start: "-7d",
|
|
180
|
-
end: "now",
|
|
181
|
-
step: 3600,
|
|
182
|
-
},
|
|
183
|
-
limit: 200,
|
|
184
|
-
queries: [
|
|
185
|
-
{
|
|
186
|
-
metricsQuery: {
|
|
187
|
-
query: "totalNewBid",
|
|
188
|
-
alias: "",
|
|
189
|
-
id: "a",
|
|
190
|
-
labelSelector: {},
|
|
191
|
-
aggregate: {
|
|
192
|
-
op: "SUM",
|
|
193
|
-
grouping: ["user"],
|
|
194
|
-
},
|
|
195
|
-
functions: [],
|
|
196
|
-
disabled: false,
|
|
197
|
-
},
|
|
198
|
-
dataSource: "METRICS",
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
};
|
|
202
|
-
function getBidderLeaderBoard(startTimestamp, end) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
-
var jsonData, response, data, samples, leader_board, userScoreMap, result, e_2;
|
|
205
|
-
return __generator(this, function (_a) {
|
|
206
|
-
switch (_a.label) {
|
|
207
|
-
case 0:
|
|
208
|
-
if (startTimestamp) {
|
|
209
|
-
bidderRequestData.timeRange.start = startTimestamp;
|
|
210
|
-
}
|
|
211
|
-
if (end) {
|
|
212
|
-
bidderRequestData.timeRange.end = end;
|
|
213
|
-
}
|
|
214
|
-
jsonData = JSON.stringify(bidderRequestData);
|
|
215
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
216
|
-
method: "POST",
|
|
217
|
-
headers: headers,
|
|
218
|
-
body: jsonData,
|
|
219
|
-
})];
|
|
220
|
-
case 1:
|
|
221
|
-
response = _a.sent();
|
|
222
|
-
_a.label = 2;
|
|
223
|
-
case 2:
|
|
224
|
-
_a.trys.push([2, 4, , 5]);
|
|
225
|
-
return [4 /*yield*/, response.json()];
|
|
226
|
-
case 3:
|
|
227
|
-
data = _a.sent();
|
|
228
|
-
samples = data.results[0].matrix.samples;
|
|
229
|
-
leader_board = samples
|
|
230
|
-
.map(function (element) {
|
|
231
|
-
// console.log("metric:", element.metric, "values: ", element.values);
|
|
232
|
-
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
233
|
-
var a = 0;
|
|
234
|
-
var log_0 = element.values.at(0);
|
|
235
|
-
if (log_0.timestamp == startTimestamp) {
|
|
236
|
-
a = log_0.value;
|
|
237
|
-
}
|
|
238
|
-
var b = element.values.at(-1).value;
|
|
239
|
-
return {
|
|
240
|
-
user: element.metric.labels.user,
|
|
241
|
-
score: b - a,
|
|
242
|
-
};
|
|
243
|
-
})
|
|
244
|
-
.filter(function (element) { return element.score != 0; });
|
|
245
|
-
userScoreMap = leader_board.reduce(function (map, obj) {
|
|
246
|
-
if (map[obj.user]) {
|
|
247
|
-
map[obj.user] += obj.score;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
map[obj.user] = obj.score;
|
|
251
|
-
}
|
|
252
|
-
return map;
|
|
253
|
-
}, {});
|
|
254
|
-
result = Object.entries(userScoreMap).map(function (_a) {
|
|
255
|
-
var _b = __read(_a, 2), user = _b[0], score = _b[1];
|
|
256
|
-
return ({ user: user, score: score });
|
|
257
|
-
});
|
|
258
|
-
result.sort(function (a, b) { return b.score - a.score; });
|
|
259
|
-
// console.log(result);
|
|
260
|
-
return [2 /*return*/, result];
|
|
261
|
-
case 4:
|
|
262
|
-
e_2 = _a.sent();
|
|
263
|
-
return [2 /*return*/, []];
|
|
264
|
-
case 5: return [2 /*return*/];
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
exports.getBidderLeaderBoard = getBidderLeaderBoard;
|
|
270
|
-
function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
|
|
271
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
-
return __generator(this, function (_a) {
|
|
273
|
-
return [2 /*return*/, expLeaderBoard.map(function (l) {
|
|
274
|
-
l.owner = ownerMap.get(l.nft_id);
|
|
275
|
-
return l;
|
|
276
|
-
})];
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
exports.getExpLeaderBoardWithOwner = getExpLeaderBoardWithOwner;
|
|
281
|
-
function getExpLeaderBoard(startTimestamp, endTimestamp) {
|
|
282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var apiUrl, headers, _endTimestamp, requestData, jsonData, response, data;
|
|
284
|
-
return __generator(this, function (_a) {
|
|
285
|
-
switch (_a.label) {
|
|
286
|
-
case 0:
|
|
287
|
-
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
288
|
-
headers = {
|
|
289
|
-
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
290
|
-
"Content-Type": "application/json",
|
|
291
|
-
};
|
|
292
|
-
_endTimestamp = endTimestamp ? endTimestamp : "9999999999";
|
|
293
|
-
requestData = {
|
|
294
|
-
sqlQuery: {
|
|
295
|
-
// sql: `SELECT S.distinct_id AS owner, SUM(E.exp_earn) AS total_exp_earn
|
|
296
|
-
// FROM ExpUp E
|
|
297
|
-
// JOIN (
|
|
298
|
-
// SELECT number, distinct_id
|
|
299
|
-
// FROM StakeNft
|
|
300
|
-
// WHERE (number, timestamp) IN (
|
|
301
|
-
// SELECT number, MAX(timestamp) AS max_timestamp
|
|
302
|
-
// FROM StakeNft
|
|
303
|
-
// GROUP BY number
|
|
304
|
-
// )
|
|
305
|
-
// ) S ON E.number = S.number
|
|
306
|
-
// WHERE E.timestamp >= ${startTimestamp} && E.timestamp < ${_endTimestamp}
|
|
307
|
-
// GROUP BY owner
|
|
308
|
-
// ORDER BY total_exp_earn DESC;`,
|
|
309
|
-
sql: "\n SELECT E.nft_id as nft_id, SUM(E.exp_earn) as total_exp_earn\n FROM ExpUp E\n WHERE E.timestamp >= ".concat(startTimestamp, " && E.timestamp < ").concat(_endTimestamp, "\n GROUP BY nft_id\n ORDER BY total_exp_earn DESC;\n "),
|
|
310
|
-
size: 200,
|
|
311
|
-
},
|
|
312
|
-
};
|
|
313
|
-
jsonData = JSON.stringify(requestData);
|
|
314
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
315
|
-
method: "POST",
|
|
316
|
-
headers: headers,
|
|
317
|
-
body: jsonData,
|
|
318
|
-
})];
|
|
319
|
-
case 1:
|
|
320
|
-
response = _a.sent();
|
|
321
|
-
return [4 /*yield*/, response.json()];
|
|
322
|
-
case 2:
|
|
323
|
-
data = _a.sent();
|
|
324
|
-
return [2 /*return*/, data.result.rows];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
exports.getExpLeaderBoard = getExpLeaderBoard;
|
|
330
|
-
// (async () => {
|
|
331
|
-
// let res = await getExpLeaderBoard("1709539200", "1709625600");
|
|
332
|
-
// console.log(res);
|
|
333
|
-
// })();
|