@scallop-io/sui-scallop-sdk 1.4.15-rc.2 → 1.4.15-rc.3
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/poolAddress.d.ts +1 -0
- package/dist/index.js +167 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -79
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +4 -2
- package/dist/queries/poolAddressesQuery.d.ts +2 -0
- package/dist/types/builder/core.d.ts +3 -3
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +1 -1
- package/src/constants/poolAddress.ts +135 -71
- package/src/models/scallopCache.ts +50 -2
- package/src/models/scallopClient.ts +1 -0
- package/src/models/scallopQuery.ts +10 -7
- package/src/queries/coreQuery.ts +30 -10
- package/src/queries/poolAddressesQuery.ts +6 -0
- package/src/queries/portfolioQuery.ts +1 -1
- package/src/types/builder/core.ts +3 -2
|
@@ -388,7 +388,7 @@ export declare class ScallopQuery {
|
|
|
388
388
|
* @return All obligation accounts information.
|
|
389
389
|
*/
|
|
390
390
|
getObligationAccounts(ownerAddress?: string, args?: {
|
|
391
|
-
indexer
|
|
391
|
+
indexer?: boolean;
|
|
392
392
|
}): Promise<{
|
|
393
393
|
[x: string]: import("../types").ObligationAccount | undefined;
|
|
394
394
|
}>;
|
|
@@ -405,7 +405,7 @@ export declare class ScallopQuery {
|
|
|
405
405
|
*/
|
|
406
406
|
getObligationAccount(obligationId: string, ownerAddress?: string, args?: {
|
|
407
407
|
indexer?: boolean;
|
|
408
|
-
}): Promise<import("../types").ObligationAccount>;
|
|
408
|
+
}): Promise<import("../types").ObligationAccount | undefined>;
|
|
409
409
|
/**
|
|
410
410
|
* Get total value locked.
|
|
411
411
|
*
|
|
@@ -571,5 +571,7 @@ export declare class ScallopQuery {
|
|
|
571
571
|
supplyLimitKey?: string;
|
|
572
572
|
borrowLimitKey?: string;
|
|
573
573
|
isolatedAssetKey?: string;
|
|
574
|
+
coinDecimalId?: string;
|
|
575
|
+
borrowIncentivePoolId?: string;
|
|
574
576
|
}>>>;
|
|
575
577
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
|
|
2
2
|
import type { Argument, TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { ScallopBuilder } from '../../models';
|
|
4
4
|
import type { SupportCollateralCoins, SupportPoolCoins, SupportAssetCoins } from '../constant';
|
|
@@ -27,10 +27,10 @@ export type CoreNormalMethods = {
|
|
|
27
27
|
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
28
28
|
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
29
29
|
borrow: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
30
|
-
borrowWithReferral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, borrowReferral: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
30
|
+
borrowWithReferral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, borrowReferral: SuiObjectArg, amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
31
31
|
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => void;
|
|
32
32
|
repay: (obligation: SuiObjectArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
33
|
-
borrowFlashLoan: (amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
33
|
+
borrowFlashLoan: (amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
34
34
|
repayFlashLoan: (coin: SuiObjectArg, loan: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
35
35
|
};
|
|
36
36
|
export type CoreQuickMethods = {
|
package/package.json
CHANGED
|
@@ -189,7 +189,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
189
189
|
coreIds.market,
|
|
190
190
|
coreIds.coinDecimalsRegistry,
|
|
191
191
|
borrowReferral,
|
|
192
|
-
txBlock.pure.u64(amount),
|
|
192
|
+
typeof amount === 'number' ? txBlock.pure.u64(amount) : amount,
|
|
193
193
|
coreIds.xOracle,
|
|
194
194
|
SUI_CLOCK_OBJECT_ID,
|
|
195
195
|
],
|
|
@@ -17,9 +17,36 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
17
17
|
supplyLimitKey?: string;
|
|
18
18
|
borrowLimitKey?: string;
|
|
19
19
|
isolatedAssetKey?: string;
|
|
20
|
+
coinDecimalId?: string;
|
|
20
21
|
}
|
|
21
22
|
>
|
|
22
23
|
> = {
|
|
24
|
+
usdc: {
|
|
25
|
+
lendingPoolAddress:
|
|
26
|
+
'0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f',
|
|
27
|
+
collateralPoolAddress:
|
|
28
|
+
'0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af',
|
|
29
|
+
borrowDynamic:
|
|
30
|
+
'0x77837ecd4f26fac9a410fff594f2c0bd3288904a15492ca77cb8a52684dbb866',
|
|
31
|
+
interestModel:
|
|
32
|
+
'0xaae3f179d63009380cbdcb9acb12907afc9c3cb79cc3460be296a9c6d28f3ff3',
|
|
33
|
+
riskModel:
|
|
34
|
+
'0x198b24db213bfeb8b3c80ae63dde92e32fd24984d25da8233ff777b851edd574',
|
|
35
|
+
borrowFeeKey:
|
|
36
|
+
'0xd37c5316cfe0a5967d14264fa6b423f880518b294a1ee6581ccbb49ccc401fb8',
|
|
37
|
+
supplyLimitKey:
|
|
38
|
+
'0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24',
|
|
39
|
+
borrowLimitKey:
|
|
40
|
+
'0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1',
|
|
41
|
+
isolatedAssetKey: undefined,
|
|
42
|
+
spool: '0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918',
|
|
43
|
+
spoolReward:
|
|
44
|
+
'0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166',
|
|
45
|
+
sCoinTreasury:
|
|
46
|
+
'0xbe6b63021f3d82e0e7e977cdd718ed7c019cf2eba374b7b546220402452f938e',
|
|
47
|
+
coinDecimalId:
|
|
48
|
+
'0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6',
|
|
49
|
+
},
|
|
23
50
|
sbeth: {
|
|
24
51
|
lendingPoolAddress:
|
|
25
52
|
'0xaa34c938e0394e5186c7dc626ad69be96af2194b23fdc6ac1c63090e399f5ba4',
|
|
@@ -40,28 +67,36 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
40
67
|
isolatedAssetKey: undefined,
|
|
41
68
|
spool: undefined,
|
|
42
69
|
spoolReward: undefined,
|
|
70
|
+
sCoinTreasury:
|
|
71
|
+
'0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
|
|
72
|
+
coinDecimalId:
|
|
73
|
+
'0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0',
|
|
43
74
|
},
|
|
44
|
-
|
|
75
|
+
weth: {
|
|
45
76
|
lendingPoolAddress:
|
|
46
|
-
'
|
|
77
|
+
'0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c',
|
|
47
78
|
collateralPoolAddress:
|
|
48
|
-
'
|
|
79
|
+
'0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
|
|
49
80
|
borrowDynamic:
|
|
50
|
-
'
|
|
81
|
+
'0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445',
|
|
51
82
|
interestModel:
|
|
52
|
-
'
|
|
83
|
+
'0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9',
|
|
53
84
|
riskModel:
|
|
54
|
-
'
|
|
85
|
+
'0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5',
|
|
55
86
|
borrowFeeKey:
|
|
56
|
-
'
|
|
87
|
+
'0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3',
|
|
57
88
|
supplyLimitKey:
|
|
58
|
-
'
|
|
89
|
+
'0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509',
|
|
59
90
|
borrowLimitKey:
|
|
60
|
-
'
|
|
91
|
+
'0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6',
|
|
61
92
|
isolatedAssetKey: undefined,
|
|
62
|
-
spool: '
|
|
93
|
+
spool: '0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787',
|
|
63
94
|
spoolReward:
|
|
64
|
-
'
|
|
95
|
+
'0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077',
|
|
96
|
+
sCoinTreasury:
|
|
97
|
+
'0x4b7f5da0e306c9d52490a0c1d4091e653d6b89778b9b4f23c877e534e4d9cd21',
|
|
98
|
+
coinDecimalId:
|
|
99
|
+
'0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f',
|
|
65
100
|
},
|
|
66
101
|
wbtc: {
|
|
67
102
|
lendingPoolAddress:
|
|
@@ -83,6 +118,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
83
118
|
isolatedAssetKey: undefined,
|
|
84
119
|
spool: undefined,
|
|
85
120
|
spoolReward: undefined,
|
|
121
|
+
sCoinTreasury:
|
|
122
|
+
'0xe2883934ea42c99bc998bbe0f01dd6d27aa0e27a56455707b1b34e6a41c20baa',
|
|
123
|
+
coinDecimalId:
|
|
124
|
+
'0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd',
|
|
86
125
|
},
|
|
87
126
|
wusdc: {
|
|
88
127
|
lendingPoolAddress:
|
|
@@ -105,28 +144,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
105
144
|
spool: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
106
145
|
spoolReward:
|
|
107
146
|
'0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
'
|
|
112
|
-
collateralPoolAddress:
|
|
113
|
-
'0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
|
|
114
|
-
borrowDynamic:
|
|
115
|
-
'0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445',
|
|
116
|
-
interestModel:
|
|
117
|
-
'0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9',
|
|
118
|
-
riskModel:
|
|
119
|
-
'0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5',
|
|
120
|
-
borrowFeeKey:
|
|
121
|
-
'0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3',
|
|
122
|
-
supplyLimitKey:
|
|
123
|
-
'0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509',
|
|
124
|
-
borrowLimitKey:
|
|
125
|
-
'0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6',
|
|
126
|
-
isolatedAssetKey: undefined,
|
|
127
|
-
spool: '0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787',
|
|
128
|
-
spoolReward:
|
|
129
|
-
'0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077',
|
|
147
|
+
sCoinTreasury:
|
|
148
|
+
'0x50c5cfcbcca3aaacab0984e4d7ad9a6ad034265bebb440f0d1cd688ec20b2548',
|
|
149
|
+
coinDecimalId:
|
|
150
|
+
'0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189',
|
|
130
151
|
},
|
|
131
152
|
wusdt: {
|
|
132
153
|
lendingPoolAddress:
|
|
@@ -149,6 +170,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
149
170
|
spool: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
150
171
|
spoolReward:
|
|
151
172
|
'0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
173
|
+
sCoinTreasury:
|
|
174
|
+
'0x1f02e2fed702b477732d4ad6044aaed04f2e8e586a169153694861a901379df0',
|
|
175
|
+
coinDecimalId:
|
|
176
|
+
'0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c',
|
|
152
177
|
},
|
|
153
178
|
sui: {
|
|
154
179
|
lendingPoolAddress:
|
|
@@ -171,6 +196,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
171
196
|
spool: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
172
197
|
spoolReward:
|
|
173
198
|
'0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
199
|
+
sCoinTreasury:
|
|
200
|
+
'0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b',
|
|
201
|
+
coinDecimalId:
|
|
202
|
+
'0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3',
|
|
174
203
|
},
|
|
175
204
|
wapt: {
|
|
176
205
|
lendingPoolAddress:
|
|
@@ -190,28 +219,9 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
190
219
|
isolatedAssetKey: undefined,
|
|
191
220
|
spool: undefined,
|
|
192
221
|
spoolReward: undefined,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
'0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a',
|
|
197
|
-
collateralPoolAddress:
|
|
198
|
-
'0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341',
|
|
199
|
-
borrowDynamic:
|
|
200
|
-
'0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81',
|
|
201
|
-
interestModel:
|
|
202
|
-
'0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70',
|
|
203
|
-
riskModel:
|
|
204
|
-
'0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312',
|
|
205
|
-
borrowFeeKey:
|
|
206
|
-
'0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9',
|
|
207
|
-
supplyLimitKey:
|
|
208
|
-
'0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028',
|
|
209
|
-
borrowLimitKey:
|
|
210
|
-
'0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8',
|
|
211
|
-
isolatedAssetKey: undefined,
|
|
212
|
-
spool: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
213
|
-
spoolReward:
|
|
214
|
-
'0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
222
|
+
sCoinTreasury: undefined,
|
|
223
|
+
coinDecimalId:
|
|
224
|
+
'0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8',
|
|
215
225
|
},
|
|
216
226
|
wsol: {
|
|
217
227
|
lendingPoolAddress:
|
|
@@ -233,6 +243,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
233
243
|
isolatedAssetKey: undefined,
|
|
234
244
|
spool: undefined,
|
|
235
245
|
spoolReward: undefined,
|
|
246
|
+
sCoinTreasury:
|
|
247
|
+
'0x760fd66f5be869af4382fa32b812b3c67f0eca1bb1ed7a5578b21d56e1848819',
|
|
248
|
+
coinDecimalId:
|
|
249
|
+
'0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e',
|
|
236
250
|
},
|
|
237
251
|
cetus: {
|
|
238
252
|
lendingPoolAddress:
|
|
@@ -255,6 +269,36 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
255
269
|
spool: '0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e',
|
|
256
270
|
spoolReward:
|
|
257
271
|
'0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f',
|
|
272
|
+
sCoinTreasury:
|
|
273
|
+
'0xa283c63488773c916cb3d6c64109536160d5eb496caddc721eb39aad2977d735',
|
|
274
|
+
coinDecimalId:
|
|
275
|
+
'0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da',
|
|
276
|
+
},
|
|
277
|
+
afsui: {
|
|
278
|
+
lendingPoolAddress:
|
|
279
|
+
'0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a',
|
|
280
|
+
collateralPoolAddress:
|
|
281
|
+
'0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341',
|
|
282
|
+
borrowDynamic:
|
|
283
|
+
'0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81',
|
|
284
|
+
interestModel:
|
|
285
|
+
'0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70',
|
|
286
|
+
riskModel:
|
|
287
|
+
'0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312',
|
|
288
|
+
borrowFeeKey:
|
|
289
|
+
'0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9',
|
|
290
|
+
supplyLimitKey:
|
|
291
|
+
'0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028',
|
|
292
|
+
borrowLimitKey:
|
|
293
|
+
'0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8',
|
|
294
|
+
isolatedAssetKey: undefined,
|
|
295
|
+
spool: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
296
|
+
spoolReward:
|
|
297
|
+
'0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
298
|
+
sCoinTreasury:
|
|
299
|
+
'0x55f4dfe9e40bc4cc11c70fcb1f3daefa2bdc330567c58d4f0792fbd9f9175a62',
|
|
300
|
+
coinDecimalId:
|
|
301
|
+
'0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d',
|
|
258
302
|
},
|
|
259
303
|
hasui: {
|
|
260
304
|
lendingPoolAddress:
|
|
@@ -277,6 +321,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
277
321
|
spool: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
278
322
|
spoolReward:
|
|
279
323
|
'0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
324
|
+
sCoinTreasury:
|
|
325
|
+
'0x404ccc1404d74a90eb6f9c9d4b6cda6d417fb03189f80d9070a35e5dab1df0f5',
|
|
326
|
+
coinDecimalId:
|
|
327
|
+
'0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24',
|
|
280
328
|
},
|
|
281
329
|
vsui: {
|
|
282
330
|
lendingPoolAddress:
|
|
@@ -299,6 +347,10 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
299
347
|
spool: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
300
348
|
spoolReward:
|
|
301
349
|
'0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
350
|
+
sCoinTreasury:
|
|
351
|
+
'0xc06688ee1af25abc286ffb1d18ce273d1d5907cd1064c25f4e8ca61ea989c1d1',
|
|
352
|
+
coinDecimalId:
|
|
353
|
+
'0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd',
|
|
302
354
|
},
|
|
303
355
|
sca: {
|
|
304
356
|
lendingPoolAddress:
|
|
@@ -320,45 +372,57 @@ export const POOL_ADDRESSES: OptionalKeys<
|
|
|
320
372
|
isolatedAssetKey: undefined,
|
|
321
373
|
spool: undefined,
|
|
322
374
|
spoolReward: undefined,
|
|
375
|
+
sCoinTreasury:
|
|
376
|
+
'0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529',
|
|
377
|
+
coinDecimalId:
|
|
378
|
+
'0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844',
|
|
323
379
|
},
|
|
324
|
-
|
|
380
|
+
fud: {
|
|
325
381
|
lendingPoolAddress:
|
|
326
|
-
'
|
|
382
|
+
'0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231',
|
|
327
383
|
collateralPoolAddress: undefined,
|
|
328
384
|
borrowDynamic:
|
|
329
|
-
'
|
|
385
|
+
'0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
|
|
330
386
|
interestModel:
|
|
331
|
-
'
|
|
387
|
+
'0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303',
|
|
332
388
|
riskModel: undefined,
|
|
333
389
|
borrowFeeKey:
|
|
334
|
-
'
|
|
390
|
+
'0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529',
|
|
335
391
|
supplyLimitKey:
|
|
336
|
-
'
|
|
392
|
+
'0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d',
|
|
337
393
|
borrowLimitKey:
|
|
338
|
-
'
|
|
394
|
+
'0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8',
|
|
339
395
|
isolatedAssetKey:
|
|
340
|
-
'
|
|
396
|
+
'0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2',
|
|
341
397
|
spool: undefined,
|
|
342
398
|
spoolReward: undefined,
|
|
399
|
+
sCoinTreasury:
|
|
400
|
+
'0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867',
|
|
401
|
+
coinDecimalId:
|
|
402
|
+
'0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e',
|
|
343
403
|
},
|
|
344
|
-
|
|
404
|
+
deep: {
|
|
345
405
|
lendingPoolAddress:
|
|
346
|
-
'
|
|
406
|
+
'0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
|
|
347
407
|
collateralPoolAddress: undefined,
|
|
348
408
|
borrowDynamic:
|
|
349
|
-
'
|
|
409
|
+
'0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3',
|
|
350
410
|
interestModel:
|
|
351
|
-
'
|
|
411
|
+
'0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69',
|
|
352
412
|
riskModel: undefined,
|
|
353
413
|
borrowFeeKey:
|
|
354
|
-
'
|
|
414
|
+
'0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2',
|
|
355
415
|
supplyLimitKey:
|
|
356
|
-
'
|
|
416
|
+
'0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
|
|
357
417
|
borrowLimitKey:
|
|
358
|
-
'
|
|
418
|
+
'0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
|
|
359
419
|
isolatedAssetKey:
|
|
360
|
-
'
|
|
420
|
+
'0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3',
|
|
361
421
|
spool: undefined,
|
|
362
422
|
spoolReward: undefined,
|
|
423
|
+
sCoinTreasury:
|
|
424
|
+
'0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
|
|
425
|
+
coinDecimalId:
|
|
426
|
+
'0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
|
|
363
427
|
},
|
|
364
428
|
};
|
|
@@ -231,15 +231,44 @@ export class ScallopCache {
|
|
|
231
231
|
* @returns Promise<PaginatedObjectsResponse>
|
|
232
232
|
*/
|
|
233
233
|
public async queryGetOwnedObjects(input: GetOwnedObjectsParams) {
|
|
234
|
+
// TODO: This query need its own separate rate limiter (as owned objects can theoretically be infinite), need a better way to handle this
|
|
234
235
|
return this.queryClient.fetchQuery({
|
|
235
236
|
retry: this.retryFn,
|
|
236
237
|
retryDelay: 1000,
|
|
237
238
|
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
238
239
|
queryFn: async () => {
|
|
239
|
-
|
|
240
|
+
const results = await callWithRateLimit(
|
|
240
241
|
this.tokenBucket,
|
|
241
242
|
async () => await this.client.getOwnedObjects(input)
|
|
242
243
|
);
|
|
244
|
+
if (results && results.data.length > 0) {
|
|
245
|
+
results.data
|
|
246
|
+
.filter(
|
|
247
|
+
(
|
|
248
|
+
result
|
|
249
|
+
): result is typeof result &
|
|
250
|
+
NonNullable<{ data: SuiObjectData }> => !!result.data
|
|
251
|
+
)
|
|
252
|
+
.forEach((result) => {
|
|
253
|
+
this.queryClient.setQueriesData(
|
|
254
|
+
{
|
|
255
|
+
exact: false,
|
|
256
|
+
queryKey: queryKeys.rpc.getObject(
|
|
257
|
+
result.data.objectId,
|
|
258
|
+
input.options ?? {}
|
|
259
|
+
),
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
data: result.data,
|
|
263
|
+
error: null,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
updatedAt: Date.now(),
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return results;
|
|
243
272
|
},
|
|
244
273
|
});
|
|
245
274
|
}
|
|
@@ -268,9 +297,28 @@ export class ScallopCache {
|
|
|
268
297
|
retryDelay: (attemptIndex) => Math.min(1000 * attemptIndex, 8000),
|
|
269
298
|
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
270
299
|
queryFn: async () => {
|
|
271
|
-
|
|
300
|
+
const result = await callWithRateLimit(this.tokenBucket, () =>
|
|
272
301
|
this.client.getDynamicFieldObject(input)
|
|
273
302
|
);
|
|
303
|
+
if (result?.data) {
|
|
304
|
+
this.queryClient.setQueriesData(
|
|
305
|
+
{
|
|
306
|
+
exact: false,
|
|
307
|
+
queryKey: queryKeys.rpc.getObject(result?.data.objectId, {
|
|
308
|
+
showContent: true,
|
|
309
|
+
showOwner: true,
|
|
310
|
+
}),
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
data: result.data,
|
|
314
|
+
error: null,
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
updatedAt: Date.now(),
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return result;
|
|
274
322
|
},
|
|
275
323
|
});
|
|
276
324
|
}
|
|
@@ -965,6 +965,7 @@ export class ScallopClient {
|
|
|
965
965
|
const rewardCoinsCollection: Record<string, TransactionResult[]> = {};
|
|
966
966
|
const obligationAccount =
|
|
967
967
|
await this.query.getObligationAccount(obligationId);
|
|
968
|
+
if (!obligationAccount) throw new Error('Obligation not found');
|
|
968
969
|
const rewardCoinNames = Object.values(obligationAccount.borrowIncentives)
|
|
969
970
|
.flatMap(({ rewards }) =>
|
|
970
971
|
rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
getLendings,
|
|
26
26
|
getLending,
|
|
27
27
|
getObligationAccounts,
|
|
28
|
-
getObligationAccount,
|
|
29
28
|
getTotalValueLocked,
|
|
30
29
|
queryVeScaKeyIdFromReferralBindings,
|
|
31
30
|
getBindedObligationId,
|
|
@@ -615,7 +614,7 @@ export class ScallopQuery {
|
|
|
615
614
|
*/
|
|
616
615
|
public async getObligationAccounts(
|
|
617
616
|
ownerAddress: string = this.walletAddress,
|
|
618
|
-
args?: { indexer
|
|
617
|
+
args?: { indexer?: boolean }
|
|
619
618
|
) {
|
|
620
619
|
return await getObligationAccounts(this, ownerAddress, args?.indexer);
|
|
621
620
|
}
|
|
@@ -636,12 +635,16 @@ export class ScallopQuery {
|
|
|
636
635
|
ownerAddress: string = this.walletAddress,
|
|
637
636
|
args?: { indexer?: boolean }
|
|
638
637
|
) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
obligationId
|
|
642
|
-
ownerAddress,
|
|
643
|
-
args?.indexer
|
|
638
|
+
const results = await this.getObligationAccounts(ownerAddress, args);
|
|
639
|
+
return Object.values(results).find(
|
|
640
|
+
(obligation) => obligation?.obligationId === obligationId
|
|
644
641
|
);
|
|
642
|
+
// return await getObligationAccount(
|
|
643
|
+
// this,
|
|
644
|
+
// obligationId,
|
|
645
|
+
// ownerAddress,
|
|
646
|
+
// args?.indexer
|
|
647
|
+
// );
|
|
645
648
|
}
|
|
646
649
|
|
|
647
650
|
/**
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
calculateMarketCollateralData,
|
|
14
14
|
parseObjectAs,
|
|
15
15
|
} from '../utils';
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
SuiObjectResponse,
|
|
18
|
+
SuiObjectData,
|
|
19
|
+
SuiParsedData,
|
|
20
|
+
} from '@mysten/sui/client';
|
|
17
21
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
18
22
|
import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
|
|
19
23
|
import {
|
|
@@ -902,14 +906,32 @@ export const getObligations = async (
|
|
|
902
906
|
const keyObjects = keyObjectsResponse.filter((ref) => !!ref.data);
|
|
903
907
|
|
|
904
908
|
const obligations: Obligation[] = [];
|
|
909
|
+
// fetch all obligations with multi get objects
|
|
910
|
+
const obligationsObjects = await queryMultipleObjects(
|
|
911
|
+
address.cache,
|
|
912
|
+
keyObjects
|
|
913
|
+
.map((ref) => ref.data?.content)
|
|
914
|
+
.filter(
|
|
915
|
+
(content): content is SuiParsedData & { dataType: 'moveObject' } =>
|
|
916
|
+
content?.dataType === 'moveObject'
|
|
917
|
+
)
|
|
918
|
+
.map((content) => (content.fields as any).ownership.fields.of),
|
|
919
|
+
{
|
|
920
|
+
showContent: true,
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
|
|
905
924
|
await Promise.allSettled(
|
|
906
|
-
keyObjects.map(async ({ data }) => {
|
|
925
|
+
keyObjects.map(async ({ data }, idx) => {
|
|
907
926
|
const keyId = data?.objectId;
|
|
908
927
|
const content = data?.content;
|
|
909
928
|
if (keyId && content && 'fields' in content) {
|
|
910
929
|
const fields = content.fields as any;
|
|
911
930
|
const obligationId = String(fields.ownership.fields.of);
|
|
912
|
-
const locked = await getObligationLocked(
|
|
931
|
+
const locked = await getObligationLocked(
|
|
932
|
+
address.cache,
|
|
933
|
+
obligationsObjects[idx]
|
|
934
|
+
);
|
|
913
935
|
obligations.push({ id: obligationId, keyId, locked });
|
|
914
936
|
}
|
|
915
937
|
})
|
|
@@ -929,7 +951,7 @@ export const getObligationLocked = async (
|
|
|
929
951
|
cache: ScallopCache,
|
|
930
952
|
obligation: string | SuiObjectData
|
|
931
953
|
) => {
|
|
932
|
-
const
|
|
954
|
+
const obligationObjectData =
|
|
933
955
|
typeof obligation === 'string'
|
|
934
956
|
? (
|
|
935
957
|
await cache.queryGetObject(obligation, {
|
|
@@ -939,13 +961,11 @@ export const getObligationLocked = async (
|
|
|
939
961
|
: obligation;
|
|
940
962
|
let obligationLocked = false;
|
|
941
963
|
if (
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
'lock_key' in
|
|
964
|
+
obligationObjectData &&
|
|
965
|
+
obligationObjectData?.content?.dataType === 'moveObject' &&
|
|
966
|
+
'lock_key' in obligationObjectData.content.fields
|
|
945
967
|
) {
|
|
946
|
-
obligationLocked = Boolean(
|
|
947
|
-
obligationObjectResponse.content.fields.lock_key
|
|
948
|
-
);
|
|
968
|
+
obligationLocked = Boolean(obligationObjectData.content.fields.lock_key);
|
|
949
969
|
}
|
|
950
970
|
|
|
951
971
|
return obligationLocked;
|
|
@@ -19,6 +19,8 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
19
19
|
supplyLimitKey?: string;
|
|
20
20
|
borrowLimitKey?: string;
|
|
21
21
|
isolatedAssetKey?: string;
|
|
22
|
+
coinDecimalId?: string;
|
|
23
|
+
borrowIncentivePoolId?: string;
|
|
22
24
|
}
|
|
23
25
|
>
|
|
24
26
|
> = {};
|
|
@@ -117,6 +119,9 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
117
119
|
// @ts-ignore
|
|
118
120
|
`scoin.coins.s${coinName}.treasury`
|
|
119
121
|
);
|
|
122
|
+
const coinDecimalId = query.address.get(
|
|
123
|
+
`core.coins.${coinName}.metaData`
|
|
124
|
+
);
|
|
120
125
|
results[coinName as SupportPoolCoins] = {
|
|
121
126
|
lendingPoolAddress: addresses[0],
|
|
122
127
|
collateralPoolAddress: addresses[1],
|
|
@@ -130,6 +135,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
|
|
|
130
135
|
spool,
|
|
131
136
|
spoolReward: rewardPool,
|
|
132
137
|
sCoinTreasury,
|
|
138
|
+
coinDecimalId,
|
|
133
139
|
};
|
|
134
140
|
|
|
135
141
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
@@ -366,7 +366,7 @@ export const getObligationAccount = async (
|
|
|
366
366
|
coinPrices =
|
|
367
367
|
coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
|
|
368
368
|
coinAmounts =
|
|
369
|
-
coinAmounts
|
|
369
|
+
coinAmounts ?? (await query.getCoinAmounts(coinNames, ownerAddress));
|
|
370
370
|
|
|
371
371
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] =
|
|
372
372
|
await Promise.all([
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
3
|
SuiObjectArg,
|
|
4
|
+
SuiTxArg,
|
|
4
5
|
} from '@scallop-io/sui-kit';
|
|
5
6
|
import type { Argument, TransactionResult } from '@mysten/sui/transactions';
|
|
6
7
|
import type { ScallopBuilder } from '../../models';
|
|
@@ -65,7 +66,7 @@ export type CoreNormalMethods = {
|
|
|
65
66
|
obligation: SuiObjectArg,
|
|
66
67
|
obligationKey: SuiObjectArg,
|
|
67
68
|
borrowReferral: SuiObjectArg,
|
|
68
|
-
amount: number,
|
|
69
|
+
amount: number | SuiTxArg,
|
|
69
70
|
poolCoinName: SupportPoolCoins
|
|
70
71
|
) => TransactionResult;
|
|
71
72
|
borrowEntry: (
|
|
@@ -80,7 +81,7 @@ export type CoreNormalMethods = {
|
|
|
80
81
|
poolCoinName: SupportPoolCoins
|
|
81
82
|
) => void;
|
|
82
83
|
borrowFlashLoan: (
|
|
83
|
-
amount: number,
|
|
84
|
+
amount: number | SuiTxArg,
|
|
84
85
|
poolCoinName: SupportPoolCoins
|
|
85
86
|
) => TransactionResult;
|
|
86
87
|
repayFlashLoan: (
|