@scallop-io/sui-scallop-sdk 1.4.7 → 1.4.9
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/constants/common.d.ts +6 -6
- package/dist/constants/enum.d.ts +2 -2
- package/dist/constants/poolAddress.d.ts +1 -1
- package/dist/index.js +135 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -70
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +55 -41
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -0
- package/dist/queries/coreQuery.d.ts +1 -0
- package/dist/queries/poolAddressesQuery.d.ts +2 -2
- package/dist/queries/portfolioQuery.d.ts +46 -39
- package/dist/queries/priceQuery.d.ts +2 -0
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/coinGecko.ts +1 -0
- package/src/constants/common.ts +4 -1
- package/src/constants/enum.ts +38 -20
- package/src/constants/poolAddress.ts +47 -18
- package/src/constants/pyth.ts +1 -0
- package/src/constants/testAddress.ts +3 -0
- package/src/models/scallop.ts +1 -0
- package/src/models/scallopCache.ts +1 -1
- package/src/models/scallopQuery.ts +8 -1
- package/src/queries/poolAddressesQuery.ts +7 -6
- package/src/queries/portfolioQuery.ts +54 -29
|
@@ -17,7 +17,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
17
17
|
supplyLimitKey?: string;
|
|
18
18
|
borrowLimitKey?: string;
|
|
19
19
|
isolatedAssetKey?: string;
|
|
20
|
-
|
|
20
|
+
coinMetadataId?: string;
|
|
21
21
|
sCoinType?: string;
|
|
22
22
|
}
|
|
23
23
|
>
|
|
@@ -47,11 +47,40 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
47
47
|
'0xbe6b63021f3d82e0e7e977cdd718ed7c019cf2eba374b7b546220402452f938e',
|
|
48
48
|
sCoinType:
|
|
49
49
|
'0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
|
|
50
|
-
|
|
50
|
+
coinMetadataId:
|
|
51
51
|
'0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6',
|
|
52
52
|
coinType:
|
|
53
53
|
'dba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
|
|
54
54
|
},
|
|
55
|
+
sbusdt: {
|
|
56
|
+
lendingPoolAddress:
|
|
57
|
+
'0x958ca02058a7dd8b00e26ed6988f45d7c2834ae2a47ee4c4a8fdedea155f18ca',
|
|
58
|
+
collateralPoolAddress:
|
|
59
|
+
'0x63c861f97192ceab2dabb1e74649ae87a9e36c33aaedcc43e40a811d3a39e653',
|
|
60
|
+
borrowDynamic:
|
|
61
|
+
'0xf1ef9a19881ed6ddeb88f361c83f37c592ec5b9c64fe715383f63ccc094be205',
|
|
62
|
+
interestModel:
|
|
63
|
+
'0x62c46e4667c4fa69a29030ecbc0f661c61365d02adc3810b08b11cfd8f42ca1c',
|
|
64
|
+
riskModel:
|
|
65
|
+
'0x59d5f3dbcd14a0aab6ee6e2879803e10b0a752119d19c4ac0bd389d71dc8c2bf',
|
|
66
|
+
borrowFeeKey:
|
|
67
|
+
'0xa418990ad042e97cca61830476483933b9e026970fc33451072b2627ccb31da2',
|
|
68
|
+
supplyLimitKey:
|
|
69
|
+
'0x93641bfb62ea40760f0c15911b4ec0eb866f8725e36b0ca9a786775d93629139',
|
|
70
|
+
borrowLimitKey:
|
|
71
|
+
'0x953a9b8d5353abb38db21a2cbbc5c54f8f23348895acb26cbe2c0ab61b54635d',
|
|
72
|
+
isolatedAssetKey: undefined,
|
|
73
|
+
spool: undefined,
|
|
74
|
+
spoolReward: undefined,
|
|
75
|
+
sCoinTreasury:
|
|
76
|
+
'0x58bdf6a9752e3a60144d0b70e8608d630dfd971513e2b2bfa7282f5eaa7d04d8',
|
|
77
|
+
sCoinType:
|
|
78
|
+
'0xb1d7df34829d1513b73ba17cb7ad90c88d1e104bb65ab8f62f13e0cc103783d3::scallop_sb_usdt::SCALLOP_SB_USDT',
|
|
79
|
+
coinMetadataId:
|
|
80
|
+
'0xda61b33ac61ed4c084bbda65a2229459ed4eb2185729e70498538f0688bec3cc',
|
|
81
|
+
coinType:
|
|
82
|
+
'0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT',
|
|
83
|
+
},
|
|
55
84
|
sbeth: {
|
|
56
85
|
lendingPoolAddress:
|
|
57
86
|
'0xaa34c938e0394e5186c7dc626ad69be96af2194b23fdc6ac1c63090e399f5ba4',
|
|
@@ -76,7 +105,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
76
105
|
'0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
|
|
77
106
|
sCoinType:
|
|
78
107
|
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
79
|
-
|
|
108
|
+
coinMetadataId:
|
|
80
109
|
'0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0',
|
|
81
110
|
coinType:
|
|
82
111
|
'd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH',
|
|
@@ -106,7 +135,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
106
135
|
'0x4b7f5da0e306c9d52490a0c1d4091e653d6b89778b9b4f23c877e534e4d9cd21',
|
|
107
136
|
sCoinType:
|
|
108
137
|
'0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH',
|
|
109
|
-
|
|
138
|
+
coinMetadataId:
|
|
110
139
|
'0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f',
|
|
111
140
|
coinType:
|
|
112
141
|
'af8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN',
|
|
@@ -135,7 +164,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
135
164
|
'0xe2883934ea42c99bc998bbe0f01dd6d27aa0e27a56455707b1b34e6a41c20baa',
|
|
136
165
|
sCoinType:
|
|
137
166
|
'0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC',
|
|
138
|
-
|
|
167
|
+
coinMetadataId:
|
|
139
168
|
'0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd',
|
|
140
169
|
coinType:
|
|
141
170
|
'027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',
|
|
@@ -165,7 +194,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
165
194
|
'0x50c5cfcbcca3aaacab0984e4d7ad9a6ad034265bebb440f0d1cd688ec20b2548',
|
|
166
195
|
sCoinType:
|
|
167
196
|
'0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
168
|
-
|
|
197
|
+
coinMetadataId:
|
|
169
198
|
'0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189',
|
|
170
199
|
coinType:
|
|
171
200
|
'5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
|
|
@@ -195,7 +224,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
195
224
|
'0x1f02e2fed702b477732d4ad6044aaed04f2e8e586a169153694861a901379df0',
|
|
196
225
|
sCoinType:
|
|
197
226
|
'0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
198
|
-
|
|
227
|
+
coinMetadataId:
|
|
199
228
|
'0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c',
|
|
200
229
|
coinType:
|
|
201
230
|
'c060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',
|
|
@@ -225,7 +254,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
225
254
|
'0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b',
|
|
226
255
|
sCoinType:
|
|
227
256
|
'0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
228
|
-
|
|
257
|
+
coinMetadataId:
|
|
229
258
|
'0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3',
|
|
230
259
|
coinType:
|
|
231
260
|
'0000000000000000000000000000000000000000000000000000000000000002::sui::SUI',
|
|
@@ -250,7 +279,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
250
279
|
spoolReward: undefined,
|
|
251
280
|
sCoinTreasury: undefined,
|
|
252
281
|
sCoinType: undefined,
|
|
253
|
-
|
|
282
|
+
coinMetadataId:
|
|
254
283
|
'0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8',
|
|
255
284
|
coinType:
|
|
256
285
|
'3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37::coin::COIN',
|
|
@@ -280,7 +309,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
280
309
|
'0xa283c63488773c916cb3d6c64109536160d5eb496caddc721eb39aad2977d735',
|
|
281
310
|
sCoinType:
|
|
282
311
|
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
283
|
-
|
|
312
|
+
coinMetadataId:
|
|
284
313
|
'0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da',
|
|
285
314
|
coinType:
|
|
286
315
|
'06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS',
|
|
@@ -309,7 +338,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
309
338
|
'0x760fd66f5be869af4382fa32b812b3c67f0eca1bb1ed7a5578b21d56e1848819',
|
|
310
339
|
sCoinType:
|
|
311
340
|
'0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL',
|
|
312
|
-
|
|
341
|
+
coinMetadataId:
|
|
313
342
|
'0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e',
|
|
314
343
|
coinType:
|
|
315
344
|
'b7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',
|
|
@@ -339,7 +368,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
339
368
|
'0x55f4dfe9e40bc4cc11c70fcb1f3daefa2bdc330567c58d4f0792fbd9f9175a62',
|
|
340
369
|
sCoinType:
|
|
341
370
|
'0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI',
|
|
342
|
-
|
|
371
|
+
coinMetadataId:
|
|
343
372
|
'0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d',
|
|
344
373
|
coinType:
|
|
345
374
|
'f325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI',
|
|
@@ -369,7 +398,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
369
398
|
'0x404ccc1404d74a90eb6f9c9d4b6cda6d417fb03189f80d9070a35e5dab1df0f5',
|
|
370
399
|
sCoinType:
|
|
371
400
|
'0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI',
|
|
372
|
-
|
|
401
|
+
coinMetadataId:
|
|
373
402
|
'0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24',
|
|
374
403
|
coinType:
|
|
375
404
|
'bde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI',
|
|
@@ -399,7 +428,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
399
428
|
'0xc06688ee1af25abc286ffb1d18ce273d1d5907cd1064c25f4e8ca61ea989c1d1',
|
|
400
429
|
sCoinType:
|
|
401
430
|
'0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI',
|
|
402
|
-
|
|
431
|
+
coinMetadataId:
|
|
403
432
|
'0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd',
|
|
404
433
|
coinType:
|
|
405
434
|
'549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT',
|
|
@@ -428,7 +457,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
428
457
|
'0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529',
|
|
429
458
|
sCoinType:
|
|
430
459
|
'0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
431
|
-
|
|
460
|
+
coinMetadataId:
|
|
432
461
|
'0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844',
|
|
433
462
|
coinType:
|
|
434
463
|
'7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA',
|
|
@@ -456,7 +485,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
456
485
|
'0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867',
|
|
457
486
|
sCoinType:
|
|
458
487
|
'0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
|
|
459
|
-
|
|
488
|
+
coinMetadataId:
|
|
460
489
|
'0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e',
|
|
461
490
|
coinType:
|
|
462
491
|
'76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD',
|
|
@@ -484,7 +513,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
484
513
|
'0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
|
|
485
514
|
sCoinType:
|
|
486
515
|
'0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
|
|
487
|
-
|
|
516
|
+
coinMetadataId:
|
|
488
517
|
'0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
|
|
489
518
|
coinType:
|
|
490
519
|
'deeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
|
|
@@ -513,7 +542,7 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
513
542
|
'0xdad9bc6293e694f67a5274ea51b596e0bdabfafc585ae6d7e82888e65f1a03e0',
|
|
514
543
|
sCoinType:
|
|
515
544
|
'0x6711551c1e7652a270d9fbf0eee25d99594c157cde3cb5fbb49035eb59b1b001::scallop_fdusd::SCALLOP_FDUSD',
|
|
516
|
-
|
|
545
|
+
coinMetadataId:
|
|
517
546
|
'0xdebee5265a67c186ed87fe93303d33dfe1de53e3b4fd7d9329c2852860acd3e7',
|
|
518
547
|
coinType:
|
|
519
548
|
'f16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD',
|
package/src/constants/pyth.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const PYTH_ENDPOINTS: {
|
|
|
10
10
|
export const PYTH_FEED_IDS: Record<SupportPoolCoins, string> = {
|
|
11
11
|
usdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
12
12
|
sbeth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
13
|
+
sbusdt: '2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
|
|
13
14
|
weth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
14
15
|
wbtc: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
|
15
16
|
wusdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
package/src/models/scallop.ts
CHANGED
|
@@ -325,7 +325,7 @@ export class ScallopCache {
|
|
|
325
325
|
* @returns Promise<PaginatedObjectsResponse>
|
|
326
326
|
*/
|
|
327
327
|
public async queryGetOwnedObjects(input: GetOwnedObjectsParams) {
|
|
328
|
-
// TODO: This query need its own separate rate limiter (as owned objects can theoretically be infinite), need a better way to handle this
|
|
328
|
+
// @TODO: This query need its own separate rate limiter (as owned objects can theoretically be infinite), need a better way to handle this
|
|
329
329
|
return this.queryClient.fetchQuery({
|
|
330
330
|
retry: this.retryFn,
|
|
331
331
|
retryDelay: 1000,
|
|
@@ -577,13 +577,18 @@ export class ScallopQuery {
|
|
|
577
577
|
public async getLendings(
|
|
578
578
|
poolCoinNames?: SupportPoolCoins[],
|
|
579
579
|
ownerAddress: string = this.walletAddress,
|
|
580
|
-
args?: {
|
|
580
|
+
args?: {
|
|
581
|
+
indexer?: boolean;
|
|
582
|
+
marketPools?: MarketPools;
|
|
583
|
+
coinPrices?: CoinPrices;
|
|
584
|
+
}
|
|
581
585
|
) {
|
|
582
586
|
return await getLendings(
|
|
583
587
|
this,
|
|
584
588
|
poolCoinNames,
|
|
585
589
|
ownerAddress,
|
|
586
590
|
args?.marketPools,
|
|
591
|
+
args?.coinPrices,
|
|
587
592
|
args?.indexer
|
|
588
593
|
);
|
|
589
594
|
}
|
|
@@ -622,12 +627,14 @@ export class ScallopQuery {
|
|
|
622
627
|
collaterals: MarketCollaterals;
|
|
623
628
|
pools: MarketPools;
|
|
624
629
|
};
|
|
630
|
+
coinPrices?: CoinPrices;
|
|
625
631
|
}
|
|
626
632
|
) {
|
|
627
633
|
return await getObligationAccounts(
|
|
628
634
|
this,
|
|
629
635
|
ownerAddress,
|
|
630
636
|
args?.market,
|
|
637
|
+
args?.coinPrices,
|
|
631
638
|
args?.indexer
|
|
632
639
|
);
|
|
633
640
|
}
|
|
@@ -20,7 +20,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
20
20
|
supplyLimitKey?: string;
|
|
21
21
|
borrowLimitKey?: string;
|
|
22
22
|
isolatedAssetKey?: string;
|
|
23
|
-
|
|
23
|
+
coinMetadataId?: string;
|
|
24
24
|
borrowIncentivePoolId?: string;
|
|
25
25
|
coinType?: string;
|
|
26
26
|
}
|
|
@@ -80,7 +80,8 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
80
80
|
},
|
|
81
81
|
})
|
|
82
82
|
)?.data?.objectId;
|
|
83
|
-
} catch (
|
|
83
|
+
} catch (e: any) {
|
|
84
|
+
console.error(e.message);
|
|
84
85
|
return undefined;
|
|
85
86
|
}
|
|
86
87
|
};
|
|
@@ -123,7 +124,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
123
124
|
// @ts-ignore
|
|
124
125
|
`scoin.coins.s${coinName}.treasury`
|
|
125
126
|
);
|
|
126
|
-
const
|
|
127
|
+
const coinMetadataId = query.address.get(
|
|
127
128
|
`core.coins.${coinName}.metaData`
|
|
128
129
|
);
|
|
129
130
|
results[coinName as SupportPoolCoins] = {
|
|
@@ -140,11 +141,11 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
140
141
|
spoolReward: rewardPool,
|
|
141
142
|
sCoinTreasury,
|
|
142
143
|
sCoinType,
|
|
143
|
-
|
|
144
|
-
coinType
|
|
144
|
+
coinMetadataId,
|
|
145
|
+
coinType: `0x${coinType}`,
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
148
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
148
149
|
})
|
|
149
150
|
);
|
|
150
151
|
|
|
@@ -47,6 +47,7 @@ export const getLendings = async (
|
|
|
47
47
|
poolCoinNames: SupportPoolCoins[] = [...SUPPORT_POOLS],
|
|
48
48
|
ownerAddress?: string,
|
|
49
49
|
marketPools?: MarketPools,
|
|
50
|
+
coinPrices?: CoinPrices,
|
|
50
51
|
indexer: boolean = false
|
|
51
52
|
) => {
|
|
52
53
|
const marketCoinNames = poolCoinNames.map((poolCoinName) =>
|
|
@@ -56,7 +57,7 @@ export const getLendings = async (
|
|
|
56
57
|
(SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
|
|
57
58
|
) as SupportStakeMarketCoins[];
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
|
|
60
61
|
marketPools =
|
|
61
62
|
marketPools ??
|
|
62
63
|
(
|
|
@@ -321,12 +322,15 @@ export const getObligationAccounts = async (
|
|
|
321
322
|
pools: MarketPools;
|
|
322
323
|
collaterals: MarketCollaterals;
|
|
323
324
|
},
|
|
325
|
+
coinPrices?: CoinPrices,
|
|
324
326
|
indexer: boolean = false
|
|
325
327
|
) => {
|
|
326
328
|
market = market ?? (await query.getMarketPools(undefined, { indexer }));
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
coinPrices =
|
|
330
|
+
coinPrices ??
|
|
331
|
+
(await query.getAllCoinPrices({
|
|
332
|
+
marketPools: market.pools,
|
|
333
|
+
}));
|
|
330
334
|
const [coinAmounts, obligations] = await Promise.all([
|
|
331
335
|
query.getCoinAmounts(undefined, ownerAddress),
|
|
332
336
|
query.getObligations(ownerAddress),
|
|
@@ -856,20 +860,26 @@ export const getUserPortfolio = async (
|
|
|
856
860
|
walletAddress: string,
|
|
857
861
|
indexer: boolean = false
|
|
858
862
|
) => {
|
|
859
|
-
const
|
|
860
|
-
const
|
|
863
|
+
const coinPrices = await query.utils.getCoinPrices();
|
|
864
|
+
const market = await query.getMarketPools(undefined, { indexer, coinPrices });
|
|
865
|
+
|
|
866
|
+
const [lendings, obligationAccounts, borrowIncentivePools, veScas] =
|
|
861
867
|
await Promise.all([
|
|
862
868
|
query.getLendings(undefined, walletAddress, {
|
|
863
869
|
indexer,
|
|
864
870
|
marketPools: market.pools,
|
|
871
|
+
coinPrices,
|
|
865
872
|
}),
|
|
866
873
|
query.getObligationAccounts(walletAddress, {
|
|
867
874
|
indexer,
|
|
868
875
|
market: market,
|
|
876
|
+
coinPrices,
|
|
869
877
|
}),
|
|
870
878
|
query.getBorrowIncentivePools(undefined, {
|
|
871
879
|
marketPools: market.pools,
|
|
880
|
+
coinPrices,
|
|
872
881
|
}),
|
|
882
|
+
query.getVeScas({ walletAddress, excludeEmpty: true }),
|
|
873
883
|
]);
|
|
874
884
|
|
|
875
885
|
// get pending rewards (spool and borrow incentive)
|
|
@@ -988,31 +998,45 @@ export const getUserPortfolio = async (
|
|
|
988
998
|
}
|
|
989
999
|
>
|
|
990
1000
|
);
|
|
1001
|
+
|
|
1002
|
+
const parsedVeScas = veScas.map(
|
|
1003
|
+
({ keyId, lockedScaCoin, currentVeScaBalance, unlockAt }) => ({
|
|
1004
|
+
veScaKey: keyId,
|
|
1005
|
+
coinPrice: coinPrices.sca ?? 0,
|
|
1006
|
+
lockedScaInCoin: lockedScaCoin,
|
|
1007
|
+
lockedScaInUsd: lockedScaCoin * (coinPrices.sca ?? 0),
|
|
1008
|
+
currentVeScaBalance,
|
|
1009
|
+
remainingLockPeriodInDays:
|
|
1010
|
+
unlockAt - Date.now() > 0 ? (unlockAt - Date.now()) / 86400000 : 0,
|
|
1011
|
+
unlockAt,
|
|
1012
|
+
})
|
|
1013
|
+
);
|
|
1014
|
+
|
|
991
1015
|
return {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1016
|
+
totalSupplyValue: parsedLendings.reduce((acc, curr) => {
|
|
1017
|
+
acc += curr.suppliedValue;
|
|
1018
|
+
return acc;
|
|
1019
|
+
}, 0),
|
|
1020
|
+
...parsedObligationAccounts.reduce(
|
|
1021
|
+
(acc, curr) => {
|
|
1022
|
+
acc.totalDebtValue += curr.totalDebtsInUsd;
|
|
1023
|
+
acc.totalCollateralValue += curr.totalCollateralInUsd;
|
|
995
1024
|
return acc;
|
|
996
|
-
},
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
totalCollateralValue: number;
|
|
1012
|
-
}
|
|
1013
|
-
),
|
|
1014
|
-
obligations: parsedObligationAccounts,
|
|
1015
|
-
},
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
totalDebtValue: 0,
|
|
1028
|
+
totalCollateralValue: 0,
|
|
1029
|
+
} as {
|
|
1030
|
+
totalDebtValue: number;
|
|
1031
|
+
totalCollateralValue: number;
|
|
1032
|
+
}
|
|
1033
|
+
),
|
|
1034
|
+
totalLockedScaValue: parsedVeScas.reduce((acc, curr) => {
|
|
1035
|
+
acc += curr.lockedScaInUsd;
|
|
1036
|
+
return acc;
|
|
1037
|
+
}, 0),
|
|
1038
|
+
lendings: parsedLendings,
|
|
1039
|
+
borrowings: parsedObligationAccounts,
|
|
1016
1040
|
pendingRewards: {
|
|
1017
1041
|
lendings: Object.entries(pendingLendingRewards).reduce(
|
|
1018
1042
|
(acc, [key, value]) => {
|
|
@@ -1037,5 +1061,6 @@ export const getUserPortfolio = async (
|
|
|
1037
1061
|
[] as any
|
|
1038
1062
|
),
|
|
1039
1063
|
},
|
|
1064
|
+
veScas: parsedVeScas,
|
|
1040
1065
|
};
|
|
1041
1066
|
};
|