@scallop-io/sui-scallop-sdk 2.2.2 → 2.2.3-pyth-sponsored-transaction-alpha.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +13 -4
- package/src/builders/oracles/index.ts +17 -14
- package/src/builders/oracles/pyth.ts +12 -4
- package/src/types/builder/core.ts +4 -2
package/package.json
CHANGED
|
@@ -382,7 +382,13 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
382
382
|
if (!marketCoin) throw new Error(`No market coin for ${poolCoinName}`);
|
|
383
383
|
return txBlock.withdraw(marketCoin, poolCoinName);
|
|
384
384
|
},
|
|
385
|
-
borrowQuick: async (
|
|
385
|
+
borrowQuick: async (
|
|
386
|
+
amount,
|
|
387
|
+
poolCoinName,
|
|
388
|
+
obligationId,
|
|
389
|
+
obligationKey,
|
|
390
|
+
isSponsoredTx = false
|
|
391
|
+
) => {
|
|
386
392
|
const obligationInfo = await requireObligationInfo(
|
|
387
393
|
builder,
|
|
388
394
|
txBlock,
|
|
@@ -394,7 +400,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
394
400
|
obligationInfo.obligationId
|
|
395
401
|
)) ?? [];
|
|
396
402
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
397
|
-
await updateOracles(builder, txBlock, updateCoinNames);
|
|
403
|
+
await updateOracles(builder, txBlock, updateCoinNames, { isSponsoredTx });
|
|
398
404
|
return txBlock.borrow(
|
|
399
405
|
obligationInfo.obligationId,
|
|
400
406
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
@@ -407,7 +413,8 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
407
413
|
poolCoinName,
|
|
408
414
|
borrowReferral,
|
|
409
415
|
obligationId,
|
|
410
|
-
obligationKey
|
|
416
|
+
obligationKey,
|
|
417
|
+
isSponsoredTx = false
|
|
411
418
|
) => {
|
|
412
419
|
const obligationInfo = await requireObligationInfo(
|
|
413
420
|
builder,
|
|
@@ -420,7 +427,9 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
420
427
|
obligationInfo.obligationId
|
|
421
428
|
)) ?? [];
|
|
422
429
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
423
|
-
await updateOracles(builder, txBlock, updateCoinNames
|
|
430
|
+
await updateOracles(builder, txBlock, updateCoinNames, {
|
|
431
|
+
isSponsoredTx,
|
|
432
|
+
});
|
|
424
433
|
return txBlock.borrowWithReferral(
|
|
425
434
|
obligationInfo.obligationId,
|
|
426
435
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
@@ -22,19 +22,21 @@ export const updateOracles = async (
|
|
|
22
22
|
builder: ScallopBuilder,
|
|
23
23
|
txBlock: SuiKitTxBlock,
|
|
24
24
|
assetCoinNames: string[] = [...builder.constants.whitelist.lending],
|
|
25
|
-
options
|
|
26
|
-
usePythPullModel
|
|
27
|
-
useOnChainXOracleList
|
|
28
|
-
sponsoredFeeds
|
|
29
|
-
|
|
30
|
-
usePythPullModel: true,
|
|
31
|
-
useOnChainXOracleList: true,
|
|
32
|
-
sponsoredFeeds: [],
|
|
25
|
+
options?: {
|
|
26
|
+
usePythPullModel?: boolean;
|
|
27
|
+
useOnChainXOracleList?: boolean;
|
|
28
|
+
sponsoredFeeds?: string[];
|
|
29
|
+
isSponsoredTx?: boolean;
|
|
33
30
|
}
|
|
34
31
|
) => {
|
|
32
|
+
const usePythPullModel =
|
|
33
|
+
options?.usePythPullModel ?? builder.usePythPullModel;
|
|
34
|
+
const useOnChainXOracleList =
|
|
35
|
+
options?.useOnChainXOracleList ?? builder.useOnChainXOracleList;
|
|
35
36
|
const sponsoredFeeds = new Set(
|
|
36
|
-
|
|
37
|
+
options?.sponsoredFeeds ?? builder.sponsoredFeeds
|
|
37
38
|
);
|
|
39
|
+
const isSponsoredTx = options?.isSponsoredTx ?? false;
|
|
38
40
|
|
|
39
41
|
// Validate the sponsoredFeeds content.
|
|
40
42
|
sponsoredFeeds.forEach((feed) => {
|
|
@@ -43,10 +45,6 @@ export const updateOracles = async (
|
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
const usePythPullModel = builder.usePythPullModel ?? options.usePythPullModel;
|
|
47
|
-
const useOnChainXOracleList =
|
|
48
|
-
builder.useOnChainXOracleList ?? options.useOnChainXOracleList;
|
|
49
|
-
|
|
50
48
|
const xOracleList = useOnChainXOracleList
|
|
51
49
|
? await builder.query.getAssetOracles()
|
|
52
50
|
: X_ORACLE_LIST;
|
|
@@ -92,7 +90,12 @@ export const updateOracles = async (
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
if (needToUpdatePythPriceFeeds.length > 0) {
|
|
95
|
-
await updatePythPriceFeeds(
|
|
93
|
+
await updatePythPriceFeeds(
|
|
94
|
+
builder,
|
|
95
|
+
needToUpdatePythPriceFeeds,
|
|
96
|
+
txBlock,
|
|
97
|
+
isSponsoredTx
|
|
98
|
+
);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -8,12 +8,19 @@ import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
|
8
8
|
export const updatePythPriceFeeds = async (
|
|
9
9
|
builder: ScallopBuilder,
|
|
10
10
|
assetCoinNames: string[],
|
|
11
|
-
txBlock: SuiKitTxBlock
|
|
11
|
+
txBlock: SuiKitTxBlock,
|
|
12
|
+
isSponsoredTx: boolean = false
|
|
12
13
|
) => {
|
|
13
14
|
const pythClient = new SuiPythClient(
|
|
14
15
|
builder.suiKit.client,
|
|
15
16
|
builder.address.get('core.oracles.pyth.state'),
|
|
16
|
-
builder.address.get('core.oracles.pyth.wormholeState')
|
|
17
|
+
builder.address.get('core.oracles.pyth.wormholeState'),
|
|
18
|
+
{
|
|
19
|
+
defaultPackageId:
|
|
20
|
+
'0xa6f9bec2f9748656b6af8aafb5d7bc1a0d5faf25ac9645fc7f447822cd509325',
|
|
21
|
+
gasStationId:
|
|
22
|
+
'0xa8b8dcc9880166edb57b53e05f8df7364d31b5d9b7d107fd27f0b69cf338b687',
|
|
23
|
+
}
|
|
17
24
|
);
|
|
18
25
|
const priceIds = assetCoinNames.map((assetCoinName) =>
|
|
19
26
|
builder.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
|
|
@@ -29,9 +36,10 @@ export const updatePythPriceFeeds = async (
|
|
|
29
36
|
const priceUpdateData =
|
|
30
37
|
await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
31
38
|
await pythClient.updatePriceFeeds(
|
|
32
|
-
txBlock.txBlock,
|
|
39
|
+
txBlock.txBlock,
|
|
33
40
|
priceUpdateData,
|
|
34
|
-
priceIds
|
|
41
|
+
priceIds,
|
|
42
|
+
isSponsoredTx
|
|
35
43
|
);
|
|
36
44
|
|
|
37
45
|
break;
|
|
@@ -99,14 +99,16 @@ export type CoreQuickMethods = {
|
|
|
99
99
|
amount: number,
|
|
100
100
|
poolCoinName: string,
|
|
101
101
|
obligationId?: SuiObjectArg,
|
|
102
|
-
obligationKey?: SuiObjectArg
|
|
102
|
+
obligationKey?: SuiObjectArg,
|
|
103
|
+
isSponsoredTx?: boolean
|
|
103
104
|
) => Promise<TransactionResult>;
|
|
104
105
|
borrowWithReferralQuick: (
|
|
105
106
|
amount: number,
|
|
106
107
|
poolCoinName: string,
|
|
107
108
|
borrowReferral: SuiObjectArg,
|
|
108
109
|
obligationId?: SuiObjectArg,
|
|
109
|
-
obligationKey?: SuiObjectArg
|
|
110
|
+
obligationKey?: SuiObjectArg,
|
|
111
|
+
isSponsoredTx?: boolean
|
|
110
112
|
) => Promise<TransactionResult>;
|
|
111
113
|
depositQuick: (
|
|
112
114
|
amount: number,
|