@scallop-io/sui-scallop-sdk 2.2.3-pyth-sponsored-transaction-alpha.3 → 2.2.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/index.d.mts +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +28 -10
- package/src/builders/oracles/pyth.ts +1 -2
- package/src/models/scallopBuilder.ts +1 -0
- package/src/types/builder/core.ts +27 -4
package/package.json
CHANGED
|
@@ -314,7 +314,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
314
314
|
collateralCoinName,
|
|
315
315
|
obligationId,
|
|
316
316
|
obligationKey,
|
|
317
|
-
|
|
317
|
+
updateOracleOptions
|
|
318
318
|
) => {
|
|
319
319
|
const obligationInfo = await requireObligationInfo(
|
|
320
320
|
builder,
|
|
@@ -325,7 +325,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
325
325
|
const updateCoinNames = await builder.utils.getObligationCoinNames(
|
|
326
326
|
obligationInfo.obligationId
|
|
327
327
|
);
|
|
328
|
-
await updateOracles(
|
|
328
|
+
await updateOracles(
|
|
329
|
+
builder,
|
|
330
|
+
txBlock,
|
|
331
|
+
updateCoinNames,
|
|
332
|
+
updateOracleOptions
|
|
333
|
+
);
|
|
329
334
|
return txBlock.takeCollateral(
|
|
330
335
|
obligationInfo.obligationId,
|
|
331
336
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
@@ -388,7 +393,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
388
393
|
poolCoinName,
|
|
389
394
|
obligationId,
|
|
390
395
|
obligationKey,
|
|
391
|
-
|
|
396
|
+
updateOracleOptions
|
|
392
397
|
) => {
|
|
393
398
|
const obligationInfo = await requireObligationInfo(
|
|
394
399
|
builder,
|
|
@@ -401,7 +406,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
401
406
|
obligationInfo.obligationId
|
|
402
407
|
)) ?? [];
|
|
403
408
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
404
|
-
await updateOracles(
|
|
409
|
+
await updateOracles(
|
|
410
|
+
builder,
|
|
411
|
+
txBlock,
|
|
412
|
+
updateCoinNames,
|
|
413
|
+
updateOracleOptions
|
|
414
|
+
);
|
|
405
415
|
return txBlock.borrow(
|
|
406
416
|
obligationInfo.obligationId,
|
|
407
417
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
@@ -415,7 +425,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
415
425
|
borrowReferral,
|
|
416
426
|
obligationId,
|
|
417
427
|
obligationKey,
|
|
418
|
-
|
|
428
|
+
updateOracleOptions
|
|
419
429
|
) => {
|
|
420
430
|
const obligationInfo = await requireObligationInfo(
|
|
421
431
|
builder,
|
|
@@ -428,9 +438,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
428
438
|
obligationInfo.obligationId
|
|
429
439
|
)) ?? [];
|
|
430
440
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
431
|
-
await updateOracles(
|
|
432
|
-
|
|
433
|
-
|
|
441
|
+
await updateOracles(
|
|
442
|
+
builder,
|
|
443
|
+
txBlock,
|
|
444
|
+
updateCoinNames,
|
|
445
|
+
updateOracleOptions
|
|
446
|
+
);
|
|
434
447
|
return txBlock.borrowWithReferral(
|
|
435
448
|
obligationInfo.obligationId,
|
|
436
449
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
@@ -462,8 +475,13 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
462
475
|
if (leftCoin) txBlock.transferObjects([leftCoin], sender);
|
|
463
476
|
return txBlock.repay(obligationInfo.obligationId, takeCoin, poolCoinName);
|
|
464
477
|
},
|
|
465
|
-
updateAssetPricesQuick: async (assetCoinNames) => {
|
|
466
|
-
return await updateOracles(
|
|
478
|
+
updateAssetPricesQuick: async (assetCoinNames, updateOracleOptions) => {
|
|
479
|
+
return await updateOracles(
|
|
480
|
+
builder,
|
|
481
|
+
txBlock,
|
|
482
|
+
assetCoinNames,
|
|
483
|
+
updateOracleOptions
|
|
484
|
+
);
|
|
467
485
|
},
|
|
468
486
|
};
|
|
469
487
|
};
|
|
@@ -99,12 +99,11 @@ export const updatePythPriceFeeds = async (
|
|
|
99
99
|
builder.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
|
|
100
100
|
);
|
|
101
101
|
|
|
102
|
-
// iterate through the endpoints
|
|
103
102
|
const endpoints = builder.utils.pythEndpoints ?? [
|
|
104
103
|
...builder.constants.whitelist.pythEndpoints,
|
|
105
104
|
];
|
|
106
105
|
|
|
107
|
-
//
|
|
106
|
+
// iterate through the endpoints
|
|
108
107
|
for (const endpoint of endpoints) {
|
|
109
108
|
try {
|
|
110
109
|
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
@@ -96,6 +96,7 @@ class ScallopBuilder implements ScallopBuilderInterface {
|
|
|
96
96
|
* @param assetCoinName - Specific support asset coin name.
|
|
97
97
|
* @param amount - Amount of coins to be selected.
|
|
98
98
|
* @param sender - Sender address.
|
|
99
|
+
* @param isSponsored - Whether the transaction is a sponsored transaction.
|
|
99
100
|
* @return Take coin and left coin.
|
|
100
101
|
*/
|
|
101
102
|
async selectCoin(
|
|
@@ -94,14 +94,24 @@ export type CoreQuickMethods = {
|
|
|
94
94
|
collateralCoinName: string,
|
|
95
95
|
obligationId?: SuiObjectArg,
|
|
96
96
|
obligationKey?: SuiObjectArg,
|
|
97
|
-
|
|
97
|
+
updateOracleOptions?: {
|
|
98
|
+
usePythPullModel?: boolean;
|
|
99
|
+
useOnChainXOracleList?: boolean;
|
|
100
|
+
sponsoredFeeds?: string[];
|
|
101
|
+
isSponsoredTx?: boolean;
|
|
102
|
+
}
|
|
98
103
|
) => Promise<TransactionResult>;
|
|
99
104
|
borrowQuick: (
|
|
100
105
|
amount: number,
|
|
101
106
|
poolCoinName: string,
|
|
102
107
|
obligationId?: SuiObjectArg,
|
|
103
108
|
obligationKey?: SuiObjectArg,
|
|
104
|
-
|
|
109
|
+
updateOracleOptions?: {
|
|
110
|
+
usePythPullModel?: boolean;
|
|
111
|
+
useOnChainXOracleList?: boolean;
|
|
112
|
+
sponsoredFeeds?: string[];
|
|
113
|
+
isSponsoredTx?: boolean;
|
|
114
|
+
}
|
|
105
115
|
) => Promise<TransactionResult>;
|
|
106
116
|
borrowWithReferralQuick: (
|
|
107
117
|
amount: number,
|
|
@@ -109,7 +119,12 @@ export type CoreQuickMethods = {
|
|
|
109
119
|
borrowReferral: SuiObjectArg,
|
|
110
120
|
obligationId?: SuiObjectArg,
|
|
111
121
|
obligationKey?: SuiObjectArg,
|
|
112
|
-
|
|
122
|
+
updateOracleOptions?: {
|
|
123
|
+
usePythPullModel?: boolean;
|
|
124
|
+
useOnChainXOracleList?: boolean;
|
|
125
|
+
sponsoredFeeds?: string[];
|
|
126
|
+
isSponsoredTx?: boolean;
|
|
127
|
+
}
|
|
113
128
|
) => Promise<TransactionResult>;
|
|
114
129
|
depositQuick: (
|
|
115
130
|
amount: number,
|
|
@@ -126,7 +141,15 @@ export type CoreQuickMethods = {
|
|
|
126
141
|
obligationId?: SuiObjectArg,
|
|
127
142
|
isSponsoredTx?: boolean
|
|
128
143
|
) => Promise<void>;
|
|
129
|
-
updateAssetPricesQuick: (
|
|
144
|
+
updateAssetPricesQuick: (
|
|
145
|
+
assetCoinNames?: string[],
|
|
146
|
+
updateOracleOptions?: {
|
|
147
|
+
usePythPullModel?: boolean;
|
|
148
|
+
useOnChainXOracleList?: boolean;
|
|
149
|
+
sponsoredFeeds?: string[];
|
|
150
|
+
isSponsoredTx?: boolean;
|
|
151
|
+
}
|
|
152
|
+
) => Promise<void>;
|
|
130
153
|
};
|
|
131
154
|
|
|
132
155
|
export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock &
|