@scallop-io/sui-scallop-sdk 2.0.0-alpha.9 → 2.0.1
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/README.md +29 -5
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/builders/oracles/index.ts +0 -15
- package/src/constants/common.ts +0 -125
- package/src/constants/testAddress.ts +9 -5
- package/src/models/scallop.ts +14 -1
- package/src/models/scallopBuilder.ts +0 -42
- package/src/models/scallopConstants.ts +16 -3
- package/src/models/scallopQuery.ts +0 -7
- package/src/models/scallopUtils.ts +3 -1
- package/src/queries/coreQuery.ts +0 -15
- package/src/queries/poolAddressesQuery.ts +0 -2
- package/src/queries/portfolioQuery.ts +3 -4
- package/src/queries/xOracleQuery.ts +0 -10
- package/src/types/builder/core.ts +2 -23
- package/src/types/constant/common.ts +1 -0
- package/src/types/query/portfolio.ts +3 -2
- package/src/builders/oracles/switchboard.ts +0 -270
- package/src/constants/pyth.ts +0 -25
package/package.json
CHANGED
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
} from 'src/types';
|
|
10
10
|
import { xOracleList as X_ORACLE_LIST } from 'src/constants';
|
|
11
11
|
import { updatePythPriceFeeds } from './pyth';
|
|
12
|
-
// import { updateSwitchboardAggregators } from './switchboard';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Update the price of the oracle for multiple coin.
|
|
@@ -66,20 +65,6 @@ export const updateOracles = async (
|
|
|
66
65
|
await updatePythPriceFeeds(builder, assetCoinNames, txBlock);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
// Handle Switchboard on-demand aggregator
|
|
70
|
-
// if (flattenedRules.has('switchboard')) {
|
|
71
|
-
// const switchboardAssetCoinNames = assetCoinNames.filter((assetCoinName) =>
|
|
72
|
-
// filterAssetCoinNames(assetCoinName, 'switchboard')
|
|
73
|
-
// );
|
|
74
|
-
// if (switchboardAssetCoinNames.length > 0) {
|
|
75
|
-
// await updateSwitchboardAggregators(
|
|
76
|
-
// builder,
|
|
77
|
-
// switchboardAssetCoinNames,
|
|
78
|
-
// txBlock
|
|
79
|
-
// );
|
|
80
|
-
// }
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
68
|
// Remove duplicate coin names.
|
|
84
69
|
const updateAssetCoinNames = [...new Set(assetCoinNames)];
|
|
85
70
|
for (const assetCoinName of updateAssetCoinNames) {
|
package/src/constants/common.ts
CHANGED
|
@@ -4,134 +4,9 @@ export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io' as const;
|
|
|
4
4
|
export const IS_VE_SCA_TEST: boolean = false;
|
|
5
5
|
export const USE_TEST_ADDRESS: boolean = false;
|
|
6
6
|
|
|
7
|
-
// export const ADDRESS_ID =
|
|
8
|
-
// IS_VE_SCA_TEST || USE_TEST_ADDRESS
|
|
9
|
-
// ? ('65fb07c39c845425d71d7b18' as const)
|
|
10
|
-
// : ('67c44a103fe1b8c454eb9699' as const);
|
|
11
|
-
// : ('66f8e7ed9bb9e07fdfb86bbb' as const);
|
|
12
|
-
|
|
13
7
|
export const SCA_COIN_TYPE = IS_VE_SCA_TEST
|
|
14
8
|
? (`0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524::sca::SCA` as const)
|
|
15
9
|
: ('0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA' as const);
|
|
16
10
|
|
|
17
11
|
export const OLD_BORROW_INCENTIVE_PROTOCOL_ID =
|
|
18
12
|
'0xc63072e7f5f4983a2efaf5bdba1480d5e7d74d57948e1c7cc436f8e22cbeb410' as const;
|
|
19
|
-
|
|
20
|
-
// export const SUPPORT_POOLS = [
|
|
21
|
-
// 'usdc', // native USDC
|
|
22
|
-
// 'sbeth', // sui bridge ETH
|
|
23
|
-
// 'sbusdt', // sui bridge USDT
|
|
24
|
-
// 'sbwbtc', // sui bridge WBTC
|
|
25
|
-
// 'weth',
|
|
26
|
-
// 'wbtc',
|
|
27
|
-
// 'wusdc',
|
|
28
|
-
// 'wusdt',
|
|
29
|
-
// 'sui',
|
|
30
|
-
// 'wapt',
|
|
31
|
-
// 'wsol',
|
|
32
|
-
// 'cetus',
|
|
33
|
-
// 'afsui',
|
|
34
|
-
// 'hasui',
|
|
35
|
-
// 'vsui',
|
|
36
|
-
// 'sca',
|
|
37
|
-
// 'fud',
|
|
38
|
-
// 'deep',
|
|
39
|
-
// 'fdusd',
|
|
40
|
-
// 'blub',
|
|
41
|
-
// 'musd',
|
|
42
|
-
// 'ns',
|
|
43
|
-
// 'usdy',
|
|
44
|
-
// ] as const;
|
|
45
|
-
|
|
46
|
-
// export const SUPPORT_COLLATERALS = [
|
|
47
|
-
// 'usdc', // native USDC
|
|
48
|
-
// 'sbeth', // sui bridge ETH
|
|
49
|
-
// 'sbusdt', // sui bridge USDT
|
|
50
|
-
// 'sbwbtc', // sui bridge WBTC
|
|
51
|
-
// 'weth',
|
|
52
|
-
// 'wbtc',
|
|
53
|
-
// 'wusdc',
|
|
54
|
-
// 'wusdt',
|
|
55
|
-
// 'sui',
|
|
56
|
-
// 'wapt',
|
|
57
|
-
// 'wsol',
|
|
58
|
-
// 'cetus',
|
|
59
|
-
// 'afsui',
|
|
60
|
-
// 'hasui',
|
|
61
|
-
// 'vsui',
|
|
62
|
-
// 'sca',
|
|
63
|
-
// 'fdusd',
|
|
64
|
-
// 'usdy',
|
|
65
|
-
// ] as const;
|
|
66
|
-
|
|
67
|
-
// export const SUPPORT_SPOOLS = [
|
|
68
|
-
// 'susdc',
|
|
69
|
-
// 'sweth',
|
|
70
|
-
// 'ssui',
|
|
71
|
-
// 'swusdc',
|
|
72
|
-
// 'swusdt',
|
|
73
|
-
// 'scetus',
|
|
74
|
-
// 'safsui',
|
|
75
|
-
// 'shasui',
|
|
76
|
-
// 'svsui',
|
|
77
|
-
// ] as const;
|
|
78
|
-
|
|
79
|
-
// export const SUPPORT_SCOIN = [
|
|
80
|
-
// 'susdc',
|
|
81
|
-
// 'ssbeth',
|
|
82
|
-
// 'ssbusdt',
|
|
83
|
-
// 'ssbwbtc',
|
|
84
|
-
// 'ssui',
|
|
85
|
-
// 'swusdc',
|
|
86
|
-
// 'swusdt',
|
|
87
|
-
// 'safsui',
|
|
88
|
-
// 'shasui',
|
|
89
|
-
// 'svsui',
|
|
90
|
-
// 'sweth',
|
|
91
|
-
// 'ssca',
|
|
92
|
-
// 'scetus',
|
|
93
|
-
// 'swsol',
|
|
94
|
-
// 'swbtc',
|
|
95
|
-
// 'sdeep',
|
|
96
|
-
// 'sfud',
|
|
97
|
-
// 'sfdusd',
|
|
98
|
-
// 'sblub',
|
|
99
|
-
// 'smusd',
|
|
100
|
-
// 'sns',
|
|
101
|
-
// 'susdy',
|
|
102
|
-
// ] as const;
|
|
103
|
-
|
|
104
|
-
// export const SUPPORT_SUI_BRIDGE = ['sbeth', 'sbusdt', 'sbwbtc'] as const;
|
|
105
|
-
// export const SUPPORT_WORMHOLE = [
|
|
106
|
-
// 'wusdc',
|
|
107
|
-
// 'wusdt',
|
|
108
|
-
// 'weth',
|
|
109
|
-
// 'wbtc',
|
|
110
|
-
// 'wapt',
|
|
111
|
-
// 'wsol',
|
|
112
|
-
// ] as const;
|
|
113
|
-
|
|
114
|
-
// export const SUPPORT_SPOOLS_REWARDS = ['sui'] as const;
|
|
115
|
-
|
|
116
|
-
// export const SUPPORT_BORROW_INCENTIVE_POOLS = [...SUPPORT_POOLS] as const;
|
|
117
|
-
|
|
118
|
-
// export const SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
119
|
-
// ...SUPPORT_POOLS,
|
|
120
|
-
// ...SUPPORT_SCOIN,
|
|
121
|
-
// ] as const;
|
|
122
|
-
// export const SUPPORT_ORACLES = ['supra', 'switchboard', 'pyth'] as const;
|
|
123
|
-
|
|
124
|
-
// export const SUPPORT_PACKAGES = [
|
|
125
|
-
// 'coinDecimalsRegistry',
|
|
126
|
-
// 'math',
|
|
127
|
-
// 'whitelist',
|
|
128
|
-
// 'x',
|
|
129
|
-
// 'protocol',
|
|
130
|
-
// 'protocolWhitelist',
|
|
131
|
-
// 'query',
|
|
132
|
-
// 'supra',
|
|
133
|
-
// 'pyth',
|
|
134
|
-
// 'switchboard',
|
|
135
|
-
// 'xOracle',
|
|
136
|
-
// 'testCoin',
|
|
137
|
-
// ] as const;
|
|
@@ -122,12 +122,16 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
122
122
|
'0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90',
|
|
123
123
|
primaryPriceUpdatePolicyObject:
|
|
124
124
|
'0xbcd908d0ee6d63d726e61676f3feeec3d19817f4849bbecf372dd3399f247f6b',
|
|
125
|
+
// '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee' // prod
|
|
125
126
|
secondaryPriceUpdatePolicyObject:
|
|
126
127
|
'0x624a6f120777bb30e718b86e836c205ef4229448052377dc3d78272a6662b2c0',
|
|
128
|
+
// '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705' // prod
|
|
127
129
|
primaryPriceUpdatePolicyVecsetId:
|
|
128
130
|
'0xfb1330aa028ed6a159b742c71b5a79b3b6824cf71efa40ea82b52486ad209264',
|
|
131
|
+
// '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c', // prod
|
|
129
132
|
secondaryPriceUpdatePolicyVecsetId:
|
|
130
133
|
'0x4b827acc73f3f53f808dd73a7ee0a60ae61e84322176bece72b26467030b467c',
|
|
134
|
+
// '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3' // prod
|
|
131
135
|
supra: {
|
|
132
136
|
registry: '',
|
|
133
137
|
registryCap: '',
|
|
@@ -304,7 +308,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
304
308
|
coinType:
|
|
305
309
|
'0x88618204de2dfdc2597681a8441ee726b0dc13494c41e319c3264eb7b35fea90::scallop_sui::SCALLOP_SUI',
|
|
306
310
|
metaData: '',
|
|
307
|
-
symbol: '',
|
|
311
|
+
symbol: 'sSUI',
|
|
308
312
|
treasury:
|
|
309
313
|
'0x03f1d94a40bd9f5d556bacb5c5245732b185572f6a29b36ad8b555d9a8a24f09',
|
|
310
314
|
},
|
|
@@ -312,7 +316,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
312
316
|
coinType:
|
|
313
317
|
'0x9f64a180373a6b66595025ae16a4ab701f0af1dd5c7ce1ac91dc112e52c2a3f8::scallop_sca::SCALLOP_SCA',
|
|
314
318
|
metaData: '',
|
|
315
|
-
symbol: '',
|
|
319
|
+
symbol: 'sSCA',
|
|
316
320
|
treasury:
|
|
317
321
|
'0x1b05d2cd8b20dba19da073a54195fc52d2f438ea19dea0713bae7a7dab308199',
|
|
318
322
|
},
|
|
@@ -321,7 +325,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
321
325
|
'0x55ed015f9f006c0c96ad36ebe3b3570d088e8498f52defea48e5634c110e485c::scallop_usdc::SCALLOP_USDC',
|
|
322
326
|
treasury:
|
|
323
327
|
'0x6ef82ef94472dcb8c2cdeac8df38874024c08570ca165986ba56d1e38fe0c0a3',
|
|
324
|
-
symbol: '',
|
|
328
|
+
symbol: 'sUSDC',
|
|
325
329
|
metaData:
|
|
326
330
|
'0x763a21eba338e00bc684aaad80491c89eea5f247b59c47df45b17610c9ad58f2',
|
|
327
331
|
},
|
|
@@ -329,7 +333,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
329
333
|
coinType:
|
|
330
334
|
'0x34f0a2e793e1f79ceac72cfe3bb95f65541da449418289ccd12922d16140c882::scallop_deep::SCALLOP_DEEP',
|
|
331
335
|
metaData: '',
|
|
332
|
-
symbol: '',
|
|
336
|
+
symbol: 'sDEEP',
|
|
333
337
|
treasury:
|
|
334
338
|
'0x71d41465cf2d16fa0206126526bebdf65c8871d1fcfbd0c2237db2306afd67ba',
|
|
335
339
|
},
|
|
@@ -337,7 +341,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
337
341
|
coinType:
|
|
338
342
|
'0x3b23c05f917052255a0b16a534dbd4446911aa4a30bd3497cdf5b736551e7ef8::scallop_fud::SCALLOP_FUD',
|
|
339
343
|
metaData: '',
|
|
340
|
-
symbol: '',
|
|
344
|
+
symbol: 'sFUD',
|
|
341
345
|
treasury:
|
|
342
346
|
'0x858c492d51425b922c040c1a389e185b3b00d565e7d72ead1a81dc733104660d',
|
|
343
347
|
},
|
package/src/models/scallop.ts
CHANGED
|
@@ -78,12 +78,25 @@ export class Scallop {
|
|
|
78
78
|
* @param id - The API id of the addresses.
|
|
79
79
|
* @return Scallop Address.
|
|
80
80
|
*/
|
|
81
|
-
public async getScallopAddress(id
|
|
81
|
+
public async getScallopAddress(id: string = this.params.addressId) {
|
|
82
82
|
await this.address.read(id);
|
|
83
83
|
|
|
84
84
|
return this.address;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Get a scallop constants instance that already has initial data.
|
|
89
|
+
* @returns Scallop Constants
|
|
90
|
+
*/
|
|
91
|
+
public async getScallopConstants(params?: Partial<ScallopConstantsParams>) {
|
|
92
|
+
await this.initConstants({
|
|
93
|
+
...this.params,
|
|
94
|
+
...params,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return this.constants;
|
|
98
|
+
}
|
|
99
|
+
|
|
87
100
|
/**
|
|
88
101
|
* Create a scallop builder instance that already has initial data.
|
|
89
102
|
*
|
|
@@ -220,48 +220,6 @@ export class ScallopBuilder {
|
|
|
220
220
|
args?: (SuiTxArg | SuiVecTxArg | SuiObjectArg | SuiAmountsArg)[],
|
|
221
221
|
typeArgs?: string[]
|
|
222
222
|
) {
|
|
223
|
-
// Disable for now
|
|
224
|
-
// const resolvedQueryTarget =
|
|
225
|
-
// await this.cache.queryGetNormalizedMoveFunction(target);
|
|
226
|
-
// if (!resolvedQueryTarget) throw new Error('Invalid query target');
|
|
227
|
-
|
|
228
|
-
// const { parameters } = resolvedQueryTarget;
|
|
229
|
-
// try {
|
|
230
|
-
// // we can try resolve the args first
|
|
231
|
-
// const resolvedArgs = await Promise.all(
|
|
232
|
-
// (args ?? []).map(async (arg, idx) => {
|
|
233
|
-
// if (typeof arg !== 'string') return arg;
|
|
234
|
-
|
|
235
|
-
// const cachedData = (await this.cache.queryGetObject(arg))?.data;
|
|
236
|
-
// if (!cachedData) return arg;
|
|
237
|
-
|
|
238
|
-
// const owner = cachedData.owner;
|
|
239
|
-
// if (!owner || typeof owner !== 'object' || !('Shared' in owner))
|
|
240
|
-
// return {
|
|
241
|
-
// objectId: cachedData.objectId,
|
|
242
|
-
// version: cachedData.version,
|
|
243
|
-
// digest: cachedData.digest,
|
|
244
|
-
// };
|
|
245
|
-
|
|
246
|
-
// const parameter = parameters[idx];
|
|
247
|
-
// if (
|
|
248
|
-
// typeof parameter !== 'object' ||
|
|
249
|
-
// !('MutableReference' in parameter || 'Reference' in parameter)
|
|
250
|
-
// )
|
|
251
|
-
// return arg;
|
|
252
|
-
|
|
253
|
-
// return {
|
|
254
|
-
// objectId: cachedData.objectId,
|
|
255
|
-
// initialSharedVersion: owner.Shared.initial_shared_version,
|
|
256
|
-
// mutable: 'MutableReference' in parameter,
|
|
257
|
-
// };
|
|
258
|
-
// })
|
|
259
|
-
// );
|
|
260
|
-
// return txb.moveCall(target, resolvedArgs, typeArgs);
|
|
261
|
-
// } catch (e: any) {
|
|
262
|
-
// console.error(e.message);
|
|
263
|
-
// return txb.moveCall(target, args, typeArgs);
|
|
264
|
-
// }
|
|
265
223
|
return txb.moveCall(target, args, typeArgs);
|
|
266
224
|
}
|
|
267
225
|
}
|
|
@@ -36,6 +36,7 @@ export class ScallopConstants {
|
|
|
36
36
|
scoin: new Set(),
|
|
37
37
|
spool: new Set(),
|
|
38
38
|
borrowIncentiveRewards: new Set(),
|
|
39
|
+
rewardsAsPoint: new Set(),
|
|
39
40
|
suiBridge: new Set(),
|
|
40
41
|
wormhole: new Set(),
|
|
41
42
|
oracles: new Set(),
|
|
@@ -98,10 +99,22 @@ export class ScallopConstants {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
get isInitialized() {
|
|
102
|
+
const REQUIRED_WHITELIST_KEYS = [
|
|
103
|
+
'lending',
|
|
104
|
+
'collateral',
|
|
105
|
+
'borrowing',
|
|
106
|
+
'packages',
|
|
107
|
+
'scoin',
|
|
108
|
+
'spool',
|
|
109
|
+
'oracles',
|
|
110
|
+
'pythEndpoints',
|
|
111
|
+
] as const;
|
|
101
112
|
return (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
this.isAddressInitialized && // address is initialized
|
|
114
|
+
!this.isEmptyObject(this._poolAddresses) && // poolAddresses is initialized
|
|
115
|
+
REQUIRED_WHITELIST_KEYS.every(
|
|
116
|
+
(t) => this.whitelist[t] && this.whitelist[t].size > 0
|
|
117
|
+
) // whitelist is initialized
|
|
105
118
|
);
|
|
106
119
|
}
|
|
107
120
|
|
|
@@ -234,13 +234,6 @@ export class ScallopQuery {
|
|
|
234
234
|
) {
|
|
235
235
|
const marketPools = await this.getMarketPools(undefined, args);
|
|
236
236
|
return marketPools.pools[poolCoinName];
|
|
237
|
-
// return await getMarketPool(
|
|
238
|
-
// this,
|
|
239
|
-
// poolCoinName,
|
|
240
|
-
// args?.indexer,
|
|
241
|
-
// args?.marketObject,
|
|
242
|
-
// args?.coinPrice
|
|
243
|
-
// );
|
|
244
237
|
}
|
|
245
238
|
|
|
246
239
|
/**
|
|
@@ -554,7 +554,9 @@ export class ScallopUtils {
|
|
|
554
554
|
public getSupportedPoolAddresses(): PoolAddress[] {
|
|
555
555
|
return this.constants.poolAddresses
|
|
556
556
|
? Object.values(this.constants.poolAddresses).filter(
|
|
557
|
-
(
|
|
557
|
+
(poolAddress): poolAddress is PoolAddress =>
|
|
558
|
+
poolAddress !== undefined &&
|
|
559
|
+
this.constants.whitelist.lending.has(poolAddress.coinName)
|
|
558
560
|
)
|
|
559
561
|
: [];
|
|
560
562
|
}
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -405,21 +405,6 @@ export const getMarketPools = async (
|
|
|
405
405
|
const collaterals: MarketCollaterals = {};
|
|
406
406
|
|
|
407
407
|
if (indexer) {
|
|
408
|
-
// const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
409
|
-
|
|
410
|
-
// const updateMarketPool = (marketPool: MarketPool) => {
|
|
411
|
-
// if (!poolCoinNames.includes(marketPool.coinName)) return;
|
|
412
|
-
// marketPool.coinPrice =
|
|
413
|
-
// coinPrices[marketPool.coinName] ?? marketPool.coinPrice;
|
|
414
|
-
// marketPool.coinWrappedType = query.utils.getCoinWrappedType(
|
|
415
|
-
// marketPool.coinName
|
|
416
|
-
// );
|
|
417
|
-
// pools[marketPool.coinName] = marketPool;
|
|
418
|
-
// };
|
|
419
|
-
|
|
420
|
-
// Object.values(marketPoolsIndexer).forEach(updateMarketPool);
|
|
421
|
-
|
|
422
|
-
// return pools;
|
|
423
408
|
const marketIndexer = await query.indexer.getMarket();
|
|
424
409
|
|
|
425
410
|
const updatePools = (item: MarketPool) => {
|
|
@@ -193,9 +193,7 @@ export const getPoolAddresses = async (
|
|
|
193
193
|
spoolReward: '',
|
|
194
194
|
};
|
|
195
195
|
const _spoolData = addressApiResponse.spool.pools[`s${coinName}`];
|
|
196
|
-
// @ts-ignore
|
|
197
196
|
if (_spoolData) {
|
|
198
|
-
// @ts-ignore
|
|
199
197
|
const { id: spool, rewardPoolId: spoolReward } = _spoolData;
|
|
200
198
|
spoolData = {
|
|
201
199
|
spool,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
CoinAmounts,
|
|
14
14
|
CoinPrices,
|
|
15
15
|
TotalValueLocked,
|
|
16
|
-
|
|
16
|
+
ObligationBorrowIncentiveReward,
|
|
17
17
|
MarketPools,
|
|
18
18
|
MarketCollaterals,
|
|
19
19
|
} from '../types';
|
|
@@ -146,8 +146,6 @@ export const getLending = async (
|
|
|
146
146
|
},
|
|
147
147
|
})
|
|
148
148
|
: undefined;
|
|
149
|
-
// some pool does not have spool
|
|
150
|
-
// if (!spool) throw new Error(`Failed to fetch spool for ${poolCoinName}`);
|
|
151
149
|
|
|
152
150
|
stakeAccounts =
|
|
153
151
|
stakeAccounts || query.constants.whitelist.spool.has(marketCoinName)
|
|
@@ -534,7 +532,7 @@ export const getObligationAccount = async (
|
|
|
534
532
|
const coinName = poolCoinName as string;
|
|
535
533
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
536
534
|
if (borrowIncentivePool) {
|
|
537
|
-
const rewards:
|
|
535
|
+
const rewards: ObligationBorrowIncentiveReward[] = [];
|
|
538
536
|
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
539
537
|
([key, accountPoint]) => {
|
|
540
538
|
const poolPoint =
|
|
@@ -590,6 +588,7 @@ export const getObligationAccount = async (
|
|
|
590
588
|
symbol: poolPoint.symbol,
|
|
591
589
|
coinDecimal: poolPoint.coinDecimal,
|
|
592
590
|
coinPrice: poolPoint.coinPrice,
|
|
591
|
+
weightedBorrowAmount: accountBorrowedAmount.toNumber(),
|
|
593
592
|
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
594
593
|
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
595
594
|
boostValue,
|
|
@@ -2,11 +2,6 @@ import { SuiObjectResponse } from '@mysten/sui/client';
|
|
|
2
2
|
import { ScallopAddress, ScallopUtils } from 'src/models';
|
|
3
3
|
import { SupportOracleType, xOracleRuleType } from 'src/types';
|
|
4
4
|
|
|
5
|
-
// const PRIMARY_PRICE_UPDATE_POLICY =
|
|
6
|
-
// '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee';
|
|
7
|
-
// const SECONDARY_PRICE_UPDDATE_POLICY =
|
|
8
|
-
// '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705';
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* Query the price update policy table ids. Usually the value for these table will be constant.
|
|
12
7
|
* @param query
|
|
@@ -43,11 +38,6 @@ export const getPriceUpdatePolicies = async (
|
|
|
43
38
|
};
|
|
44
39
|
};
|
|
45
40
|
|
|
46
|
-
// const PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID =
|
|
47
|
-
// '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c';
|
|
48
|
-
// const SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID =
|
|
49
|
-
// '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3';
|
|
50
|
-
|
|
51
41
|
export const getAssetOracles = async (
|
|
52
42
|
utils: ScallopUtils,
|
|
53
43
|
ruleType: xOracleRuleType
|
|
@@ -21,54 +21,38 @@ type ObligationKey = NestedResult;
|
|
|
21
21
|
type ObligationHotPotato = NestedResult;
|
|
22
22
|
|
|
23
23
|
export type CoreNormalMethods = {
|
|
24
|
-
// openObligation: () => Promise<
|
|
25
24
|
openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
|
|
26
25
|
returnObligation: (
|
|
27
26
|
obligation: SuiObjectArg,
|
|
28
27
|
obligationHotPotato: SuiObjectArg
|
|
29
|
-
// ) => Promise<void>;
|
|
30
28
|
) => void;
|
|
31
|
-
// openObligationEntry: () => Promise<void>;
|
|
32
29
|
openObligationEntry: () => void;
|
|
33
30
|
addCollateral: (
|
|
34
31
|
obligation: SuiObjectArg,
|
|
35
32
|
coin: SuiObjectArg,
|
|
36
33
|
collateralCoinName: string
|
|
37
|
-
// ) => Promise<void>;
|
|
38
34
|
) => void;
|
|
39
35
|
takeCollateral: (
|
|
40
36
|
obligation: SuiObjectArg,
|
|
41
37
|
obligationKey: SuiObjectArg,
|
|
42
38
|
amount: number,
|
|
43
39
|
collateralCoinName: string
|
|
44
|
-
// ) => Promise<TransactionResult>;
|
|
45
|
-
) => TransactionResult;
|
|
46
|
-
deposit: (
|
|
47
|
-
coin: SuiObjectArg,
|
|
48
|
-
poolCoinName: string
|
|
49
|
-
// ) => Promise<TransactionResult>;
|
|
50
|
-
) => TransactionResult;
|
|
51
|
-
depositEntry: (
|
|
52
|
-
coin: SuiObjectArg,
|
|
53
|
-
poolCoinName: string
|
|
54
|
-
// ) => Promise<TransactionResult>;
|
|
55
40
|
) => TransactionResult;
|
|
41
|
+
deposit: (coin: SuiObjectArg, poolCoinName: string) => TransactionResult;
|
|
42
|
+
depositEntry: (coin: SuiObjectArg, poolCoinName: string) => TransactionResult;
|
|
56
43
|
withdraw: (
|
|
57
44
|
marketCoin: SuiObjectArg,
|
|
58
45
|
poolCoinName: string
|
|
59
|
-
// ) => Promise<TransactionResult>;
|
|
60
46
|
) => TransactionResult;
|
|
61
47
|
withdrawEntry: (
|
|
62
48
|
marketCoin: SuiObjectArg,
|
|
63
49
|
poolCoinName: string
|
|
64
|
-
// ) => Promise<TransactionResult>;
|
|
65
50
|
) => TransactionResult;
|
|
66
51
|
borrow: (
|
|
67
52
|
obligation: SuiObjectArg,
|
|
68
53
|
obligationKey: SuiObjectArg,
|
|
69
54
|
amount: number,
|
|
70
55
|
poolCoinName: string
|
|
71
|
-
// ) => Promise<TransactionResult>;
|
|
72
56
|
) => TransactionResult;
|
|
73
57
|
borrowWithReferral: (
|
|
74
58
|
obligation: SuiObjectArg,
|
|
@@ -76,31 +60,26 @@ export type CoreNormalMethods = {
|
|
|
76
60
|
borrowReferral: SuiObjectArg,
|
|
77
61
|
amount: number | SuiTxArg,
|
|
78
62
|
poolCoinName: string
|
|
79
|
-
// ) => Promise<TransactionResult>;
|
|
80
63
|
) => TransactionResult;
|
|
81
64
|
borrowEntry: (
|
|
82
65
|
obligation: SuiObjectArg,
|
|
83
66
|
obligationKey: SuiObjectArg,
|
|
84
67
|
amount: number,
|
|
85
68
|
poolCoinName: string
|
|
86
|
-
// ) => Promise<TransactionResult>;
|
|
87
69
|
) => TransactionResult;
|
|
88
70
|
repay: (
|
|
89
71
|
obligation: SuiObjectArg,
|
|
90
72
|
coin: SuiObjectArg,
|
|
91
73
|
poolCoinName: string
|
|
92
|
-
// ) => Promise<void>;
|
|
93
74
|
) => void;
|
|
94
75
|
borrowFlashLoan: (
|
|
95
76
|
amount: number | SuiTxArg,
|
|
96
77
|
poolCoinName: string
|
|
97
|
-
// ) => Promise<TransactionResult>;
|
|
98
78
|
) => TransactionResult;
|
|
99
79
|
repayFlashLoan: (
|
|
100
80
|
coin: SuiObjectArg,
|
|
101
81
|
loan: SuiObjectArg,
|
|
102
82
|
poolCoinName: string
|
|
103
|
-
// ) => Promise<void>;
|
|
104
83
|
) => void;
|
|
105
84
|
};
|
|
106
85
|
|
|
@@ -108,12 +108,13 @@ export type ObligationDebt = {
|
|
|
108
108
|
availableRepayCoin: number;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
export type
|
|
111
|
+
export type ObligationBorrowIncentiveReward = {
|
|
112
112
|
coinName: string;
|
|
113
113
|
coinType: string;
|
|
114
114
|
symbol: string;
|
|
115
115
|
coinDecimal: number;
|
|
116
116
|
coinPrice: number;
|
|
117
|
+
weightedBorrowAmount: number;
|
|
117
118
|
availableClaimCoin: number;
|
|
118
119
|
availableClaimAmount: number;
|
|
119
120
|
boostValue: number;
|
|
@@ -125,7 +126,7 @@ export type ObligationBorrowIncentive = {
|
|
|
125
126
|
symbol: string;
|
|
126
127
|
coinDecimal: number;
|
|
127
128
|
coinPrice: number;
|
|
128
|
-
rewards:
|
|
129
|
+
rewards: ObligationBorrowIncentiveReward[];
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
export type TotalValueLocked = {
|