@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.js
CHANGED
|
@@ -3319,26 +3319,10 @@ var getPythPrice = async (query, assetCoinName, priceFeedObject) => {
|
|
|
3319
3319
|
return 0;
|
|
3320
3320
|
};
|
|
3321
3321
|
var getPythPrices = async (query, assetCoinNames) => {
|
|
3322
|
-
const seen = {};
|
|
3323
|
-
const pythFeedObjectIds = assetCoinNames.map((assetCoinName) => {
|
|
3324
|
-
const pythFeedObjectId = query.address.get(
|
|
3325
|
-
`core.coins.${assetCoinName}.oracle.pyth.feedObject`
|
|
3326
|
-
);
|
|
3327
|
-
if (seen[pythFeedObjectId])
|
|
3328
|
-
return null;
|
|
3329
|
-
seen[pythFeedObjectId] = true;
|
|
3330
|
-
return pythFeedObjectId;
|
|
3331
|
-
}).filter((item) => !!item);
|
|
3332
|
-
const priceFeedObjects = await query.cache.queryGetObjects(
|
|
3333
|
-
pythFeedObjectIds,
|
|
3334
|
-
{
|
|
3335
|
-
showContent: true
|
|
3336
|
-
}
|
|
3337
|
-
);
|
|
3338
3322
|
return (await Promise.all(
|
|
3339
|
-
|
|
3340
|
-
coinName:
|
|
3341
|
-
price: await getPythPrice(query,
|
|
3323
|
+
assetCoinNames.map(async (assetCoinName) => ({
|
|
3324
|
+
coinName: assetCoinName,
|
|
3325
|
+
price: await getPythPrice(query, assetCoinName)
|
|
3342
3326
|
}))
|
|
3343
3327
|
)).reduce(
|
|
3344
3328
|
(prev, curr) => {
|
|
@@ -7326,12 +7310,12 @@ var ScallopClient = class {
|
|
|
7326
7310
|
const txBlock = this.builder.createTxBlock();
|
|
7327
7311
|
const sender = walletAddress || this.walletAddress;
|
|
7328
7312
|
txBlock.setSender(sender);
|
|
7329
|
-
const
|
|
7313
|
+
const sCoin = await txBlock.unstakeQuick(
|
|
7330
7314
|
amount,
|
|
7331
7315
|
stakeMarketCoinName,
|
|
7332
7316
|
stakeAccountId
|
|
7333
7317
|
);
|
|
7334
|
-
txBlock.transferObjects([
|
|
7318
|
+
txBlock.transferObjects([sCoin], sender);
|
|
7335
7319
|
if (sign) {
|
|
7336
7320
|
return await this.suiKit.signAndSendTxn(
|
|
7337
7321
|
txBlock
|
|
@@ -7347,12 +7331,15 @@ var ScallopClient = class {
|
|
|
7347
7331
|
const stakeMarketCoin = await txBlock.unstakeQuick(
|
|
7348
7332
|
amount,
|
|
7349
7333
|
stakeMarketCoinName,
|
|
7350
|
-
stakeAccountId
|
|
7334
|
+
stakeAccountId,
|
|
7335
|
+
false
|
|
7351
7336
|
);
|
|
7352
7337
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
7353
7338
|
if (stakeMarketCoin) {
|
|
7354
7339
|
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
7355
7340
|
txBlock.transferObjects([coin], sender);
|
|
7341
|
+
} else {
|
|
7342
|
+
throw new Error(`No stake found for ${stakeMarketCoinName}`);
|
|
7356
7343
|
}
|
|
7357
7344
|
if (sign) {
|
|
7358
7345
|
return await this.suiKit.signAndSendTxn(
|