@scallop-io/sui-scallop-sdk 1.4.15-rc.1 → 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.
@@ -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: boolean;
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
  *
@@ -564,11 +564,14 @@ export declare class ScallopQuery {
564
564
  borrowDynamic?: string;
565
565
  spoolReward?: string;
566
566
  spool?: string;
567
+ sCoinTreasury?: string;
567
568
  interestModel?: string;
568
569
  riskModel?: string;
569
570
  borrowFeeKey?: string;
570
571
  supplyLimitKey?: string;
571
572
  borrowLimitKey?: string;
572
573
  isolatedAssetKey?: string;
574
+ coinDecimalId?: string;
575
+ borrowIncentivePoolId?: string;
573
576
  }>>>;
574
577
  }
@@ -6,10 +6,13 @@ export declare const getAllAddresses: (query: ScallopQuery) => Promise<OptionalK
6
6
  borrowDynamic?: string;
7
7
  spoolReward?: string;
8
8
  spool?: string;
9
+ sCoinTreasury?: string;
9
10
  interestModel?: string;
10
11
  riskModel?: string;
11
12
  borrowFeeKey?: string;
12
13
  supplyLimitKey?: string;
13
14
  borrowLimitKey?: string;
14
15
  isolatedAssetKey?: string;
16
+ coinDecimalId?: string;
17
+ borrowIncentivePoolId?: string;
15
18
  }>>>;
@@ -1,5 +1,6 @@
1
+ import type { SuiObjectData } from '@mysten/sui/client';
1
2
  import type { ScallopQuery, ScallopUtils } from '../models';
2
- import type { MarketPool, Spool, StakePool, StakeRewardPool, StakeAccounts, SupportStakeMarketCoins, CoinPrices, MarketPools } from '../types';
3
+ import type { Spool, StakePool, StakeRewardPool, StakeAccounts, SupportStakeMarketCoins, CoinPrices, MarketPools } from '../types';
3
4
  /**
4
5
  * Get spools data.
5
6
  *
@@ -29,7 +30,10 @@ export declare const getSpools: (query: ScallopQuery, stakeMarketCoinNames?: Sup
29
30
  * @param coinPrices - The coin prices.
30
31
  * @return Spool data.
31
32
  */
32
- export declare const getSpool: (query: ScallopQuery, marketCoinName: SupportStakeMarketCoins, indexer?: boolean, marketPool?: MarketPool, coinPrices?: CoinPrices) => Promise<Spool | undefined>;
33
+ export declare const getSpool: (query: ScallopQuery, marketCoinName: SupportStakeMarketCoins, indexer?: boolean, coinPrices?: CoinPrices, requiredObjects?: {
34
+ spool: SuiObjectData;
35
+ spoolReward: SuiObjectData;
36
+ }) => Promise<Spool>;
33
37
  /**
34
38
  * Get all stake accounts of the owner.
35
39
  *
package/dist/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -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 = {
@@ -32,6 +32,26 @@ export type OriginSpoolData = {
32
32
  createdAt: string;
33
33
  lastUpdate: string;
34
34
  };
35
+ export type SpoolData = {
36
+ created_at: string;
37
+ distributed_point: string;
38
+ distributed_point_per_period: string;
39
+ id: {
40
+ id: string;
41
+ };
42
+ index: string;
43
+ last_update: string;
44
+ max_distributed_point: string;
45
+ max_stakes: string;
46
+ point_distribution_time: string;
47
+ stake_type: {
48
+ type: string;
49
+ fields: {
50
+ name: string;
51
+ };
52
+ };
53
+ stakes: string;
54
+ };
35
55
  export type ParsedSpoolData = {
36
56
  stakeType: string;
37
57
  maxPoint: number;
@@ -4,3 +4,4 @@ export * from './util';
4
4
  export * from './tokenBucket';
5
5
  export * from './indexer';
6
6
  export * from './core';
7
+ export * from './tokenBucket';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.4.15-rc.1",
3
+ "version": "1.4.15-rc.3",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -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
  ],
@@ -9,6 +9,7 @@ export const POOL_ADDRESSES: OptionalKeys<
9
9
  collateralPoolAddress?: string; // not all pool has collateral
10
10
  spool?: string;
11
11
  spoolReward?: string;
12
+ sCoinTreasury?: string;
12
13
  borrowDynamic?: string;
13
14
  interestModel?: string;
14
15
  riskModel?: string;
@@ -16,9 +17,36 @@ export const POOL_ADDRESSES: OptionalKeys<
16
17
  supplyLimitKey?: string;
17
18
  borrowLimitKey?: string;
18
19
  isolatedAssetKey?: string;
20
+ coinDecimalId?: string;
19
21
  }
20
22
  >
21
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
+ },
22
50
  sbeth: {
23
51
  lendingPoolAddress:
24
52
  '0xaa34c938e0394e5186c7dc626ad69be96af2194b23fdc6ac1c63090e399f5ba4',
@@ -39,28 +67,36 @@ export const POOL_ADDRESSES: OptionalKeys<
39
67
  isolatedAssetKey: undefined,
40
68
  spool: undefined,
41
69
  spoolReward: undefined,
70
+ sCoinTreasury:
71
+ '0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
72
+ coinDecimalId:
73
+ '0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0',
42
74
  },
43
- usdc: {
75
+ weth: {
44
76
  lendingPoolAddress:
45
- '0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f',
77
+ '0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c',
46
78
  collateralPoolAddress:
47
- '0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af',
79
+ '0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
48
80
  borrowDynamic:
49
- '0x77837ecd4f26fac9a410fff594f2c0bd3288904a15492ca77cb8a52684dbb866',
81
+ '0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445',
50
82
  interestModel:
51
- '0xaae3f179d63009380cbdcb9acb12907afc9c3cb79cc3460be296a9c6d28f3ff3',
83
+ '0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9',
52
84
  riskModel:
53
- '0x198b24db213bfeb8b3c80ae63dde92e32fd24984d25da8233ff777b851edd574',
85
+ '0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5',
54
86
  borrowFeeKey:
55
- '0xd37c5316cfe0a5967d14264fa6b423f880518b294a1ee6581ccbb49ccc401fb8',
87
+ '0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3',
56
88
  supplyLimitKey:
57
- '0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24',
89
+ '0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509',
58
90
  borrowLimitKey:
59
- '0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1',
91
+ '0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6',
60
92
  isolatedAssetKey: undefined,
61
- spool: '0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918',
93
+ spool: '0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787',
62
94
  spoolReward:
63
- '0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166',
95
+ '0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077',
96
+ sCoinTreasury:
97
+ '0x4b7f5da0e306c9d52490a0c1d4091e653d6b89778b9b4f23c877e534e4d9cd21',
98
+ coinDecimalId:
99
+ '0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f',
64
100
  },
65
101
  wbtc: {
66
102
  lendingPoolAddress:
@@ -82,6 +118,10 @@ export const POOL_ADDRESSES: OptionalKeys<
82
118
  isolatedAssetKey: undefined,
83
119
  spool: undefined,
84
120
  spoolReward: undefined,
121
+ sCoinTreasury:
122
+ '0xe2883934ea42c99bc998bbe0f01dd6d27aa0e27a56455707b1b34e6a41c20baa',
123
+ coinDecimalId:
124
+ '0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd',
85
125
  },
86
126
  wusdc: {
87
127
  lendingPoolAddress:
@@ -104,28 +144,10 @@ export const POOL_ADDRESSES: OptionalKeys<
104
144
  spool: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
105
145
  spoolReward:
106
146
  '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
107
- },
108
- weth: {
109
- lendingPoolAddress:
110
- '0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c',
111
- collateralPoolAddress:
112
- '0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
113
- borrowDynamic:
114
- '0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445',
115
- interestModel:
116
- '0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9',
117
- riskModel:
118
- '0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5',
119
- borrowFeeKey:
120
- '0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3',
121
- supplyLimitKey:
122
- '0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509',
123
- borrowLimitKey:
124
- '0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6',
125
- isolatedAssetKey: undefined,
126
- spool: '0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787',
127
- spoolReward:
128
- '0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077',
147
+ sCoinTreasury:
148
+ '0x50c5cfcbcca3aaacab0984e4d7ad9a6ad034265bebb440f0d1cd688ec20b2548',
149
+ coinDecimalId:
150
+ '0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189',
129
151
  },
130
152
  wusdt: {
131
153
  lendingPoolAddress:
@@ -148,6 +170,10 @@ export const POOL_ADDRESSES: OptionalKeys<
148
170
  spool: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
149
171
  spoolReward:
150
172
  '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
173
+ sCoinTreasury:
174
+ '0x1f02e2fed702b477732d4ad6044aaed04f2e8e586a169153694861a901379df0',
175
+ coinDecimalId:
176
+ '0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c',
151
177
  },
152
178
  sui: {
153
179
  lendingPoolAddress:
@@ -170,6 +196,10 @@ export const POOL_ADDRESSES: OptionalKeys<
170
196
  spool: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
171
197
  spoolReward:
172
198
  '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
199
+ sCoinTreasury:
200
+ '0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b',
201
+ coinDecimalId:
202
+ '0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3',
173
203
  },
174
204
  wapt: {
175
205
  lendingPoolAddress:
@@ -189,28 +219,9 @@ export const POOL_ADDRESSES: OptionalKeys<
189
219
  isolatedAssetKey: undefined,
190
220
  spool: undefined,
191
221
  spoolReward: undefined,
192
- },
193
- afsui: {
194
- lendingPoolAddress:
195
- '0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a',
196
- collateralPoolAddress:
197
- '0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341',
198
- borrowDynamic:
199
- '0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81',
200
- interestModel:
201
- '0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70',
202
- riskModel:
203
- '0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312',
204
- borrowFeeKey:
205
- '0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9',
206
- supplyLimitKey:
207
- '0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028',
208
- borrowLimitKey:
209
- '0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8',
210
- isolatedAssetKey: undefined,
211
- spool: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
212
- spoolReward:
213
- '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
222
+ sCoinTreasury: undefined,
223
+ coinDecimalId:
224
+ '0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8',
214
225
  },
215
226
  wsol: {
216
227
  lendingPoolAddress:
@@ -232,6 +243,10 @@ export const POOL_ADDRESSES: OptionalKeys<
232
243
  isolatedAssetKey: undefined,
233
244
  spool: undefined,
234
245
  spoolReward: undefined,
246
+ sCoinTreasury:
247
+ '0x760fd66f5be869af4382fa32b812b3c67f0eca1bb1ed7a5578b21d56e1848819',
248
+ coinDecimalId:
249
+ '0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e',
235
250
  },
236
251
  cetus: {
237
252
  lendingPoolAddress:
@@ -254,6 +269,36 @@ export const POOL_ADDRESSES: OptionalKeys<
254
269
  spool: '0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e',
255
270
  spoolReward:
256
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',
257
302
  },
258
303
  hasui: {
259
304
  lendingPoolAddress:
@@ -276,6 +321,10 @@ export const POOL_ADDRESSES: OptionalKeys<
276
321
  spool: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
277
322
  spoolReward:
278
323
  '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
324
+ sCoinTreasury:
325
+ '0x404ccc1404d74a90eb6f9c9d4b6cda6d417fb03189f80d9070a35e5dab1df0f5',
326
+ coinDecimalId:
327
+ '0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24',
279
328
  },
280
329
  vsui: {
281
330
  lendingPoolAddress:
@@ -298,6 +347,10 @@ export const POOL_ADDRESSES: OptionalKeys<
298
347
  spool: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
299
348
  spoolReward:
300
349
  '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
350
+ sCoinTreasury:
351
+ '0xc06688ee1af25abc286ffb1d18ce273d1d5907cd1064c25f4e8ca61ea989c1d1',
352
+ coinDecimalId:
353
+ '0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd',
301
354
  },
302
355
  sca: {
303
356
  lendingPoolAddress:
@@ -319,45 +372,57 @@ export const POOL_ADDRESSES: OptionalKeys<
319
372
  isolatedAssetKey: undefined,
320
373
  spool: undefined,
321
374
  spoolReward: undefined,
375
+ sCoinTreasury:
376
+ '0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529',
377
+ coinDecimalId:
378
+ '0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844',
322
379
  },
323
- deep: {
380
+ fud: {
324
381
  lendingPoolAddress:
325
- '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
382
+ '0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231',
326
383
  collateralPoolAddress: undefined,
327
384
  borrowDynamic:
328
- '0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3',
385
+ '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
329
386
  interestModel:
330
- '0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69',
387
+ '0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303',
331
388
  riskModel: undefined,
332
389
  borrowFeeKey:
333
- '0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2',
390
+ '0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529',
334
391
  supplyLimitKey:
335
- '0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
392
+ '0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d',
336
393
  borrowLimitKey:
337
- '0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
394
+ '0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8',
338
395
  isolatedAssetKey:
339
- '0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3',
396
+ '0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2',
340
397
  spool: undefined,
341
398
  spoolReward: undefined,
399
+ sCoinTreasury:
400
+ '0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867',
401
+ coinDecimalId:
402
+ '0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e',
342
403
  },
343
- fud: {
404
+ deep: {
344
405
  lendingPoolAddress:
345
- '0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231',
406
+ '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
346
407
  collateralPoolAddress: undefined,
347
408
  borrowDynamic:
348
- '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
409
+ '0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3',
349
410
  interestModel:
350
- '0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303',
411
+ '0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69',
351
412
  riskModel: undefined,
352
413
  borrowFeeKey:
353
- '0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529',
414
+ '0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2',
354
415
  supplyLimitKey:
355
- '0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d',
416
+ '0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
356
417
  borrowLimitKey:
357
- '0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8',
418
+ '0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
358
419
  isolatedAssetKey:
359
- '0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2',
420
+ '0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3',
360
421
  spool: undefined,
361
422
  spoolReward: undefined,
423
+ sCoinTreasury:
424
+ '0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
425
+ coinDecimalId:
426
+ '0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
362
427
  },
363
428
  };
@@ -1,2 +1,2 @@
1
- export const DEFAULT_TOKENS_PER_INTERVAL = 50;
1
+ export const DEFAULT_TOKENS_PER_INTERVAL = 10;
2
2
  export const DEFAULT_INTERVAL_IN_MS = 250;
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './constants';
2
2
  export * from './models';
3
3
  export type * from './types';
4
+ export * from './utils/tokenBucket';
@@ -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
- return await callWithRateLimit(
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
- return await callWithRateLimit(this.tokenBucket, () =>
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)
@@ -14,11 +14,9 @@ import {
14
14
  getStakeRewardPool,
15
15
  getPythPrice,
16
16
  getMarketPools,
17
- // getMarketPool,
18
17
  getMarketCollaterals,
19
18
  getMarketCollateral,
20
19
  getSpools,
21
- getSpool,
22
20
  queryBorrowIncentiveAccounts,
23
21
  getCoinAmounts,
24
22
  getCoinAmount,
@@ -27,7 +25,6 @@ import {
27
25
  getLendings,
28
26
  getLending,
29
27
  getObligationAccounts,
30
- getObligationAccount,
31
28
  getTotalValueLocked,
32
29
  queryVeScaKeyIdFromReferralBindings,
33
30
  getBindedObligationId,
@@ -422,13 +419,8 @@ export class ScallopQuery {
422
419
  indexer?: boolean;
423
420
  }
424
421
  ) {
425
- return await getSpool(
426
- this,
427
- stakeMarketCoinName,
428
- args?.indexer,
429
- args?.marketPool,
430
- args?.coinPrices
431
- );
422
+ const spools = await this.getSpools(undefined, args);
423
+ return spools[stakeMarketCoinName];
432
424
  }
433
425
 
434
426
  /**
@@ -622,7 +614,7 @@ export class ScallopQuery {
622
614
  */
623
615
  public async getObligationAccounts(
624
616
  ownerAddress: string = this.walletAddress,
625
- args?: { indexer: boolean }
617
+ args?: { indexer?: boolean }
626
618
  ) {
627
619
  return await getObligationAccounts(this, ownerAddress, args?.indexer);
628
620
  }
@@ -643,12 +635,16 @@ export class ScallopQuery {
643
635
  ownerAddress: string = this.walletAddress,
644
636
  args?: { indexer?: boolean }
645
637
  ) {
646
- return await getObligationAccount(
647
- this,
648
- obligationId,
649
- ownerAddress,
650
- args?.indexer
638
+ const results = await this.getObligationAccounts(ownerAddress, args);
639
+ return Object.values(results).find(
640
+ (obligation) => obligation?.obligationId === obligationId
651
641
  );
642
+ // return await getObligationAccount(
643
+ // this,
644
+ // obligationId,
645
+ // ownerAddress,
646
+ // args?.indexer
647
+ // );
652
648
  }
653
649
 
654
650
  /**