@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.46.48",
3
+ "version": "0.46.49",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -742,12 +742,12 @@ export class ScallopClient {
742
742
  const sender = walletAddress || this.walletAddress;
743
743
  txBlock.setSender(sender);
744
744
 
745
- const marketCoin = await txBlock.unstakeQuick(
745
+ const sCoin = await txBlock.unstakeQuick(
746
746
  amount,
747
747
  stakeMarketCoinName,
748
748
  stakeAccountId
749
749
  );
750
- txBlock.transferObjects([marketCoin], sender);
750
+ txBlock.transferObjects([sCoin], sender);
751
751
 
752
752
  if (sign) {
753
753
  return (await this.suiKit.signAndSendTxn(
@@ -793,13 +793,16 @@ export class ScallopClient {
793
793
  const stakeMarketCoin = await txBlock.unstakeQuick(
794
794
  amount,
795
795
  stakeMarketCoinName,
796
- stakeAccountId
796
+ stakeAccountId,
797
+ false
797
798
  );
798
799
  const stakeCoinName =
799
800
  this.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
800
801
  if (stakeMarketCoin) {
801
802
  const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
802
803
  txBlock.transferObjects([coin], sender);
804
+ } else {
805
+ throw new Error(`No stake found for ${stakeMarketCoinName}`);
803
806
  }
804
807
 
805
808
  if (sign) {
@@ -61,30 +61,11 @@ export const getPythPrices = async (
61
61
  query: ScallopQuery,
62
62
  assetCoinNames: SupportAssetCoins[]
63
63
  ) => {
64
- const seen: Record<string, boolean> = {};
65
- const pythFeedObjectIds = assetCoinNames
66
- .map((assetCoinName) => {
67
- const pythFeedObjectId = query.address.get(
68
- `core.coins.${assetCoinName}.oracle.pyth.feedObject`
69
- );
70
- if (seen[pythFeedObjectId]) return null;
71
-
72
- seen[pythFeedObjectId] = true;
73
- return pythFeedObjectId;
74
- })
75
- .filter((item) => !!item) as string[];
76
- const priceFeedObjects = await query.cache.queryGetObjects(
77
- pythFeedObjectIds,
78
- {
79
- showContent: true,
80
- }
81
- );
82
-
83
64
  return (
84
65
  await Promise.all(
85
- priceFeedObjects.map(async (priceFeedObject, idx) => ({
86
- coinName: assetCoinNames[idx],
87
- price: await getPythPrice(query, assetCoinNames[idx], priceFeedObject),
66
+ assetCoinNames.map(async (assetCoinName) => ({
67
+ coinName: assetCoinName,
68
+ price: await getPythPrice(query, assetCoinName),
88
69
  }))
89
70
  )
90
71
  ).reduce(
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/src/test.ts DELETED
@@ -1,19 +0,0 @@
1
- import { Scallop } from './models';
2
- import * as dotenv from 'dotenv';
3
- dotenv.config();
4
- const scallop = new Scallop({
5
- secretKey: process.env.SECRET_KEY as string,
6
- });
7
-
8
- const main = async () => {
9
- const query = await scallop.createScallopQuery();
10
-
11
- const res = await query.getVeScas(
12
- '0xd1a70cfe7332e994a950b9c570e93def4b6d2ec53b34ff5c0cc9946226a7cf3d'
13
- );
14
- console.dir(res, { depth: null });
15
- };
16
- main()
17
- .then()
18
- .catch(console.error)
19
- .finally(() => process.exit(0));