@scallop-io/sui-scallop-sdk 0.46.48 → 0.46.49
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.js +9 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/scallopClient.ts +6 -3
- package/src/queries/priceQuery.ts +3 -22
- package/dist/test.d.ts +0 -1
- package/src/test.ts +0 -19
package/dist/index.mjs
CHANGED
|
@@ -3245,26 +3245,10 @@ var getPythPrice = async (query, assetCoinName, priceFeedObject) => {
|
|
|
3245
3245
|
return 0;
|
|
3246
3246
|
};
|
|
3247
3247
|
var getPythPrices = async (query, assetCoinNames) => {
|
|
3248
|
-
const seen = {};
|
|
3249
|
-
const pythFeedObjectIds = assetCoinNames.map((assetCoinName) => {
|
|
3250
|
-
const pythFeedObjectId = query.address.get(
|
|
3251
|
-
`core.coins.${assetCoinName}.oracle.pyth.feedObject`
|
|
3252
|
-
);
|
|
3253
|
-
if (seen[pythFeedObjectId])
|
|
3254
|
-
return null;
|
|
3255
|
-
seen[pythFeedObjectId] = true;
|
|
3256
|
-
return pythFeedObjectId;
|
|
3257
|
-
}).filter((item) => !!item);
|
|
3258
|
-
const priceFeedObjects = await query.cache.queryGetObjects(
|
|
3259
|
-
pythFeedObjectIds,
|
|
3260
|
-
{
|
|
3261
|
-
showContent: true
|
|
3262
|
-
}
|
|
3263
|
-
);
|
|
3264
3248
|
return (await Promise.all(
|
|
3265
|
-
|
|
3266
|
-
coinName:
|
|
3267
|
-
price: await getPythPrice(query,
|
|
3249
|
+
assetCoinNames.map(async (assetCoinName) => ({
|
|
3250
|
+
coinName: assetCoinName,
|
|
3251
|
+
price: await getPythPrice(query, assetCoinName)
|
|
3268
3252
|
}))
|
|
3269
3253
|
)).reduce(
|
|
3270
3254
|
(prev, curr) => {
|
|
@@ -7266,12 +7250,12 @@ var ScallopClient = class {
|
|
|
7266
7250
|
const txBlock = this.builder.createTxBlock();
|
|
7267
7251
|
const sender = walletAddress || this.walletAddress;
|
|
7268
7252
|
txBlock.setSender(sender);
|
|
7269
|
-
const
|
|
7253
|
+
const sCoin = await txBlock.unstakeQuick(
|
|
7270
7254
|
amount,
|
|
7271
7255
|
stakeMarketCoinName,
|
|
7272
7256
|
stakeAccountId
|
|
7273
7257
|
);
|
|
7274
|
-
txBlock.transferObjects([
|
|
7258
|
+
txBlock.transferObjects([sCoin], sender);
|
|
7275
7259
|
if (sign) {
|
|
7276
7260
|
return await this.suiKit.signAndSendTxn(
|
|
7277
7261
|
txBlock
|
|
@@ -7287,12 +7271,15 @@ var ScallopClient = class {
|
|
|
7287
7271
|
const stakeMarketCoin = await txBlock.unstakeQuick(
|
|
7288
7272
|
amount,
|
|
7289
7273
|
stakeMarketCoinName,
|
|
7290
|
-
stakeAccountId
|
|
7274
|
+
stakeAccountId,
|
|
7275
|
+
false
|
|
7291
7276
|
);
|
|
7292
7277
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
7293
7278
|
if (stakeMarketCoin) {
|
|
7294
7279
|
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
7295
7280
|
txBlock.transferObjects([coin], sender);
|
|
7281
|
+
} else {
|
|
7282
|
+
throw new Error(`No stake found for ${stakeMarketCoinName}`);
|
|
7296
7283
|
}
|
|
7297
7284
|
if (sign) {
|
|
7298
7285
|
return await this.suiKit.signAndSendTxn(
|