@scallop-io/sui-scallop-sdk 0.44.13 → 0.44.15

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.
@@ -5,7 +5,7 @@ export declare const PROTOCOL_OBJECT_ID = "0xefe8b36d5b2e43728cc323298626b831778
5
5
  export declare const BORROW_FEE_PROTOCOL_ID = "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
6
6
  export declare const SUPPORT_POOLS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui", "vsui"];
7
7
  export declare const SUPPORT_COLLATERALS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui", "vsui"];
8
- export declare const SUPPORT_SPOOLS: readonly ["ssui", "susdc", "susdt"];
8
+ export declare const SUPPORT_SPOOLS: readonly ["ssui", "susdc", "susdt", "safsui", "shasui", "svsui"];
9
9
  export declare const SUPPORT_SPOOLS_REWARDS: readonly ["sui"];
10
10
  export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["sui", "usdc", "usdt"];
11
11
  export declare const SUPPORT_BORROW_INCENTIVE_REWARDS: readonly ["sui"];
package/dist/index.js CHANGED
@@ -94,7 +94,14 @@ var SUPPORT_COLLATERALS = [
94
94
  "hasui",
95
95
  "vsui"
96
96
  ];
97
- var SUPPORT_SPOOLS = ["ssui", "susdc", "susdt"];
97
+ var SUPPORT_SPOOLS = [
98
+ "ssui",
99
+ "susdc",
100
+ "susdt",
101
+ "safsui",
102
+ "shasui",
103
+ "svsui"
104
+ ];
98
105
  var SUPPORT_SPOOLS_REWARDS = ["sui"];
99
106
  var SUPPORT_BORROW_INCENTIVE_POOLS = ["sui", "usdc", "usdt"];
100
107
  var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui"];
@@ -168,12 +175,18 @@ var marketCoins = {
168
175
  var stakeMarketCoins = {
169
176
  ssui: "ssui",
170
177
  susdc: "susdc",
171
- susdt: "susdt"
178
+ susdt: "susdt",
179
+ safsui: "safsui",
180
+ shasui: "shasui",
181
+ svsui: "svsui"
172
182
  };
173
183
  var spoolRewardCoins = {
174
184
  ssui: "sui",
175
185
  susdc: "sui",
176
- susdt: "sui"
186
+ susdt: "sui",
187
+ safsui: "sui",
188
+ shasui: "sui",
189
+ svsui: "sui"
177
190
  };
178
191
  var borrowIncentiveRewardCoins = {
179
192
  sui: "sui",
@@ -401,6 +414,22 @@ var EMPTY_ADDRESSES = {
401
414
  susdc: {
402
415
  id: "",
403
416
  rewardPoolId: ""
417
+ },
418
+ susdt: {
419
+ id: "",
420
+ rewardPoolId: ""
421
+ },
422
+ safsui: {
423
+ id: "",
424
+ rewardPoolId: ""
425
+ },
426
+ shasui: {
427
+ id: "",
428
+ rewardPoolId: ""
429
+ },
430
+ svsui: {
431
+ id: "",
432
+ rewardPoolId: ""
404
433
  }
405
434
  }
406
435
  },
@@ -2007,7 +2036,10 @@ var getStakeAccounts = async (query, ownerAddress) => {
2007
2036
  const stakeAccounts = {
2008
2037
  ssui: [],
2009
2038
  susdc: [],
2010
- susdt: []
2039
+ susdt: [],
2040
+ safsui: [],
2041
+ shasui: [],
2042
+ svsui: []
2011
2043
  };
2012
2044
  const stakeMarketCoinTypes = Object.keys(stakeAccounts).reduce(
2013
2045
  (types, stakeMarketCoinName) => {
@@ -2064,6 +2096,39 @@ var getStakeAccounts = async (query, ownerAddress) => {
2064
2096
  points,
2065
2097
  totalPoints
2066
2098
  });
2099
+ } else if ((0, import_utils4.normalizeStructTag)(type) === stakeMarketCoinTypes.safsui) {
2100
+ stakeAccounts.safsui.push({
2101
+ id,
2102
+ type: (0, import_utils4.normalizeStructTag)(type),
2103
+ stakePoolId,
2104
+ stakeType: (0, import_utils4.normalizeStructTag)(stakeType),
2105
+ staked,
2106
+ index,
2107
+ points,
2108
+ totalPoints
2109
+ });
2110
+ } else if ((0, import_utils4.normalizeStructTag)(type) === stakeMarketCoinTypes.shasui) {
2111
+ stakeAccounts.shasui.push({
2112
+ id,
2113
+ type: (0, import_utils4.normalizeStructTag)(type),
2114
+ stakePoolId,
2115
+ stakeType: (0, import_utils4.normalizeStructTag)(stakeType),
2116
+ staked,
2117
+ index,
2118
+ points,
2119
+ totalPoints
2120
+ });
2121
+ } else if ((0, import_utils4.normalizeStructTag)(type) === stakeMarketCoinTypes.svsui) {
2122
+ stakeAccounts.svsui.push({
2123
+ id,
2124
+ type: (0, import_utils4.normalizeStructTag)(type),
2125
+ stakePoolId,
2126
+ stakeType: (0, import_utils4.normalizeStructTag)(stakeType),
2127
+ staked,
2128
+ index,
2129
+ points,
2130
+ totalPoints
2131
+ });
2067
2132
  }
2068
2133
  }
2069
2134
  }
@@ -2418,6 +2483,9 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
2418
2483
  );
2419
2484
  const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
2420
2485
  const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
2486
+ const marketCoinPrice = (0, import_bignumber3.default)(coinPrice ?? 0).multipliedBy(
2487
+ marketPool?.conversionRate ?? 1
2488
+ );
2421
2489
  const unstakedMarketAmount = (0, import_bignumber3.default)(marketCoinAmount);
2422
2490
  const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
2423
2491
  const availableSupplyAmount = (0, import_bignumber3.default)(coinAmount);
@@ -2437,6 +2505,8 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
2437
2505
  marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
2438
2506
  coinDecimal,
2439
2507
  coinPrice: coinPrice ?? 0,
2508
+ conversionRate: marketPool?.conversionRate ?? 1,
2509
+ marketCoinPrice: marketCoinPrice.toNumber(),
2440
2510
  supplyApr: marketPool?.supplyApr ?? 0,
2441
2511
  supplyApy: marketPool?.supplyApy ?? 0,
2442
2512
  rewardApr: spool?.rewardApr ?? 0,
@@ -4286,8 +4356,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
4286
4356
  obligationAccessStore: builder.address.get("core.obligationAccessStore")
4287
4357
  };
4288
4358
  return {
4289
- stakeObligation: (obligationId, obligaionKey, coinName) => {
4290
- const rewardCoinName = borrowIncentiveRewardCoins[coinName];
4359
+ stakeObligation: (obligationId, obligaionKey) => {
4360
+ const rewardCoinName = "sui";
4291
4361
  const rewardType = builder.utils.parseCoinType(rewardCoinName);
4292
4362
  txBlock.moveCall(
4293
4363
  `${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
@@ -4302,8 +4372,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
4302
4372
  [rewardType]
4303
4373
  );
4304
4374
  },
4305
- unstakeObligation: (obligationId, obligaionKey, coinName) => {
4306
- const rewardCoinName = borrowIncentiveRewardCoins[coinName];
4375
+ unstakeObligation: (obligationId, obligaionKey) => {
4376
+ const rewardCoinName = "sui";
4307
4377
  const rewardType = builder.utils.parseCoinType(rewardCoinName);
4308
4378
  txBlock.moveCall(
4309
4379
  `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
@@ -4336,7 +4406,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
4336
4406
  };
4337
4407
  var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
4338
4408
  return {
4339
- stakeObligationQuick: async (coinName, obligation, obligationKey) => {
4409
+ stakeObligationQuick: async (obligation, obligationKey) => {
4340
4410
  const {
4341
4411
  obligationId: obligationArg,
4342
4412
  obligationKey: obligationtKeyArg,
@@ -4351,10 +4421,10 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
4351
4421
  (txn) => txn.kind === "MoveCall" && txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`
4352
4422
  );
4353
4423
  if (!obligationLocked || unstakeObligationBeforeStake) {
4354
- txBlock.stakeObligation(obligationArg, obligationtKeyArg, coinName);
4424
+ txBlock.stakeObligation(obligationArg, obligationtKeyArg);
4355
4425
  }
4356
4426
  },
4357
- unstakeObligationQuick: async (coinName, obligation, obligationKey) => {
4427
+ unstakeObligationQuick: async (obligation, obligationKey) => {
4358
4428
  const {
4359
4429
  obligationId: obligationArg,
4360
4430
  obligationKey: obligationtKeyArg,
@@ -4366,7 +4436,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
4366
4436
  obligationKey
4367
4437
  );
4368
4438
  if (obligationLocked) {
4369
- txBlock.unstakeObligation(obligationArg, obligationtKeyArg, coinName);
4439
+ txBlock.unstakeObligation(obligationArg, obligationtKeyArg);
4370
4440
  }
4371
4441
  },
4372
4442
  claimBorrowIncentiveQuick: async (coinName, obligation, obligationKey) => {
@@ -4461,14 +4531,14 @@ var ScallopBuilder = class {
4461
4531
  /**
4462
4532
  * Request the scallop API to initialize data.
4463
4533
  *
4464
- * @param forece - Whether to force initialization.
4534
+ * @param force - Whether to force initialization.
4465
4535
  */
4466
- async init(forece = false) {
4467
- if (forece || !this.address.getAddresses()) {
4536
+ async init(force = false) {
4537
+ if (force || !this.address.getAddresses()) {
4468
4538
  await this.address.read();
4469
4539
  }
4470
- await this.query.init(forece);
4471
- await this.utils.init(forece);
4540
+ await this.query.init(force);
4541
+ await this.utils.init(force);
4472
4542
  }
4473
4543
  /**
4474
4544
  * Create a scallop txBlock instance that enhances transaction block.
@@ -4793,11 +4863,7 @@ var ScallopClient = class {
4793
4863
  txBlock.setSender(sender);
4794
4864
  const availableStake = SUPPORT_BORROW_INCENTIVE_POOLS.includes(poolCoinName);
4795
4865
  if (sign && availableStake) {
4796
- await txBlock.unstakeObligationQuick(
4797
- poolCoinName,
4798
- obligationId,
4799
- obligationKey
4800
- );
4866
+ await txBlock.unstakeObligationQuick(obligationId, obligationKey);
4801
4867
  }
4802
4868
  const coin = await txBlock.borrowQuick(
4803
4869
  amount,
@@ -4807,11 +4873,7 @@ var ScallopClient = class {
4807
4873
  );
4808
4874
  txBlock.transferObjects([coin], sender);
4809
4875
  if (sign && availableStake) {
4810
- await txBlock.stakeObligationQuick(
4811
- poolCoinName,
4812
- obligationId,
4813
- obligationKey
4814
- );
4876
+ await txBlock.stakeObligationQuick(obligationId, obligationKey);
4815
4877
  }
4816
4878
  if (sign) {
4817
4879
  return await this.suiKit.signAndSendTxn(
@@ -4837,19 +4899,11 @@ var ScallopClient = class {
4837
4899
  txBlock.setSender(sender);
4838
4900
  const availableStake = SUPPORT_BORROW_INCENTIVE_POOLS.includes(poolCoinName);
4839
4901
  if (sign && availableStake) {
4840
- await txBlock.unstakeObligationQuick(
4841
- poolCoinName,
4842
- obligationId,
4843
- obligationKey
4844
- );
4902
+ await txBlock.unstakeObligationQuick(obligationId, obligationKey);
4845
4903
  }
4846
4904
  await txBlock.repayQuick(amount, poolCoinName, obligationId);
4847
4905
  if (sign && availableStake) {
4848
- await txBlock.stakeObligationQuick(
4849
- poolCoinName,
4850
- obligationId,
4851
- obligationKey
4852
- );
4906
+ await txBlock.stakeObligationQuick(obligationId, obligationKey);
4853
4907
  }
4854
4908
  if (sign) {
4855
4909
  return await this.suiKit.signAndSendTxn(
@@ -4971,17 +5025,17 @@ var ScallopClient = class {
4971
5025
  /**
4972
5026
  * stake obligaion.
4973
5027
  *
4974
- * @param sign - Decide to directly sign the transaction or return the transaction block.
4975
5028
  * @param obligaionId - The obligation account object.
4976
5029
  * @param obligaionKeyId - The obligation key account object.
5030
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
4977
5031
  * @param walletAddress - The wallet address of the owner.
4978
5032
  * @return Transaction block response or transaction block
4979
5033
  */
4980
- async stakeObligation(coinName, obligaionId, obligaionKeyId, sign = true, walletAddress) {
5034
+ async stakeObligation(obligaionId, obligaionKeyId, sign = true, walletAddress) {
4981
5035
  const txBlock = this.builder.createTxBlock();
4982
5036
  const sender = walletAddress || this.walletAddress;
4983
5037
  txBlock.setSender(sender);
4984
- await txBlock.stakeObligationQuick(coinName, obligaionId, obligaionKeyId);
5038
+ await txBlock.stakeObligationQuick(obligaionId, obligaionKeyId);
4985
5039
  if (sign) {
4986
5040
  return await this.suiKit.signAndSendTxn(
4987
5041
  txBlock
@@ -4993,17 +5047,17 @@ var ScallopClient = class {
4993
5047
  /**
4994
5048
  * unstake obligaion.
4995
5049
  *
4996
- * @param sign - Decide to directly sign the transaction or return the transaction block.
4997
5050
  * @param obligaionId - The obligation account object.
4998
5051
  * @param obligaionKeyId - The obligation key account object.
5052
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
4999
5053
  * @param walletAddress - The wallet address of the owner.
5000
5054
  * @return Transaction block response or transaction block
5001
5055
  */
5002
- async unstakeObligation(coinName, obligaionId, obligaionKeyId, sign = true, walletAddress) {
5056
+ async unstakeObligation(obligaionId, obligaionKeyId, sign = true, walletAddress) {
5003
5057
  const txBlock = this.builder.createTxBlock();
5004
5058
  const sender = walletAddress || this.walletAddress;
5005
5059
  txBlock.setSender(sender);
5006
- await txBlock.unstakeObligationQuick(coinName, obligaionId, obligaionKeyId);
5060
+ await txBlock.unstakeObligationQuick(obligaionId, obligaionKeyId);
5007
5061
  if (sign) {
5008
5062
  return await this.suiKit.signAndSendTxn(
5009
5063
  txBlock