@scallop-io/sui-scallop-sdk 0.46.48 → 0.46.50

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 CHANGED
@@ -1603,11 +1603,11 @@ var ScallopAddress = class {
1603
1603
  };
1604
1604
 
1605
1605
  // src/models/scallopClient.ts
1606
- var import_utils23 = require("@mysten/sui.js/utils");
1606
+ var import_utils24 = require("@mysten/sui.js/utils");
1607
1607
  var import_sui_kit13 = require("@scallop-io/sui-kit");
1608
1608
 
1609
1609
  // src/models/scallopUtils.ts
1610
- var import_utils9 = require("@mysten/sui.js/utils");
1610
+ var import_utils10 = require("@mysten/sui.js/utils");
1611
1611
  var import_sui_kit4 = require("@scallop-io/sui-kit");
1612
1612
  var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
1613
1613
 
@@ -2036,7 +2036,7 @@ var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolData, pars
2036
2036
  (0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
2037
2037
  weightScale
2038
2038
  )
2039
- ).dividedBy(weightedStakedValue).isFinite() ? rewardValueForYear.multipliedBy(
2039
+ ).dividedBy(weightedStakedValue).isFinite() && parsedBorrowIncentivePoolPointData.points > 0 ? rewardValueForYear.multipliedBy(
2040
2040
  (0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
2041
2041
  weightScale
2042
2042
  )
@@ -3319,27 +3319,44 @@ 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);
3322
+ const pythPriceFeedIds = assetCoinNames.reduce(
3323
+ (prev, assetCoinName) => {
3324
+ const pythPriceFeed = query.address.get(
3325
+ `core.coins.${assetCoinName}.oracle.pyth.feedObject`
3326
+ );
3327
+ if (!prev[pythPriceFeed]) {
3328
+ prev[pythPriceFeed] = [assetCoinName];
3329
+ } else {
3330
+ prev[pythPriceFeed].push(assetCoinName);
3331
+ }
3332
+ return prev;
3333
+ },
3334
+ {}
3335
+ );
3332
3336
  const priceFeedObjects = await query.cache.queryGetObjects(
3333
- pythFeedObjectIds,
3334
- {
3335
- showContent: true
3336
- }
3337
+ Object.keys(pythPriceFeedIds),
3338
+ { showContent: true }
3339
+ );
3340
+ const assetToPriceFeedMapping = priceFeedObjects.reduce(
3341
+ (prev, priceFeedObject) => {
3342
+ pythPriceFeedIds[priceFeedObject.objectId].forEach((assetCoinName) => {
3343
+ prev[assetCoinName] = priceFeedObject;
3344
+ });
3345
+ return prev;
3346
+ },
3347
+ {}
3337
3348
  );
3338
3349
  return (await Promise.all(
3339
- priceFeedObjects.map(async (priceFeedObject, idx) => ({
3340
- coinName: assetCoinNames[idx],
3341
- price: await getPythPrice(query, assetCoinNames[idx], priceFeedObject)
3342
- }))
3350
+ Object.entries(assetToPriceFeedMapping).map(
3351
+ async ([assetCoinName, priceFeedObject]) => ({
3352
+ coinName: assetCoinName,
3353
+ price: await getPythPrice(
3354
+ query,
3355
+ assetCoinName,
3356
+ priceFeedObject
3357
+ )
3358
+ })
3359
+ )
3343
3360
  )).reduce(
3344
3361
  (prev, curr) => {
3345
3362
  prev[curr.coinName] = curr.price;
@@ -4313,6 +4330,7 @@ var getSCoinAmount = async (query, sCoinName, ownerAddress) => {
4313
4330
  };
4314
4331
 
4315
4332
  // src/models/scallopQuery.ts
4333
+ var import_utils9 = require("@mysten/sui.js/utils");
4316
4334
  var ScallopQuery = class {
4317
4335
  constructor(params, instance) {
4318
4336
  this.params = params;
@@ -4332,6 +4350,9 @@ var ScallopQuery = class {
4332
4350
  query: this
4333
4351
  });
4334
4352
  this.indexer = new ScallopIndexer(this.params, { cache: this.cache });
4353
+ this.walletAddress = (0, import_utils9.normalizeSuiAddress)(
4354
+ params?.walletAddress || this.suiKit.currentAddress()
4355
+ );
4335
4356
  }
4336
4357
  /**
4337
4358
  * Request the scallop API to initialize data.
@@ -4410,7 +4431,7 @@ var ScallopQuery = class {
4410
4431
  * @param ownerAddress - The owner address.
4411
4432
  * @return Obligations data.
4412
4433
  */
4413
- async getObligations(ownerAddress) {
4434
+ async getObligations(ownerAddress = this.walletAddress) {
4414
4435
  return await getObligations(this, ownerAddress);
4415
4436
  }
4416
4437
  /**
@@ -4429,7 +4450,7 @@ var ScallopQuery = class {
4429
4450
  * @param ownerAddress - The owner address.
4430
4451
  * @return All coin amounts.
4431
4452
  */
4432
- async getCoinAmounts(assetCoinNames, ownerAddress) {
4453
+ async getCoinAmounts(assetCoinNames, ownerAddress = this.walletAddress) {
4433
4454
  return await getCoinAmounts(this, assetCoinNames, ownerAddress);
4434
4455
  }
4435
4456
  /**
@@ -4439,7 +4460,7 @@ var ScallopQuery = class {
4439
4460
  * @param ownerAddress - The owner address.
4440
4461
  * @return Coin amount.
4441
4462
  */
4442
- async getCoinAmount(assetCoinName, ownerAddress) {
4463
+ async getCoinAmount(assetCoinName, ownerAddress = this.walletAddress) {
4443
4464
  return await getCoinAmount(this, assetCoinName, ownerAddress);
4444
4465
  }
4445
4466
  /**
@@ -4449,7 +4470,7 @@ var ScallopQuery = class {
4449
4470
  * @param ownerAddress - The owner address.
4450
4471
  * @return All market market coin amounts.
4451
4472
  */
4452
- async getMarketCoinAmounts(marketCoinNames, ownerAddress) {
4473
+ async getMarketCoinAmounts(marketCoinNames, ownerAddress = this.walletAddress) {
4453
4474
  return await getMarketCoinAmounts(this, marketCoinNames, ownerAddress);
4454
4475
  }
4455
4476
  /**
@@ -4459,7 +4480,7 @@ var ScallopQuery = class {
4459
4480
  * @param ownerAddress - The owner address.
4460
4481
  * @return Market market coin amount.
4461
4482
  */
4462
- async getMarketCoinAmount(marketCoinName, ownerAddress) {
4483
+ async getMarketCoinAmount(marketCoinName, ownerAddress = this.walletAddress) {
4463
4484
  return await getMarketCoinAmount(this, marketCoinName, ownerAddress);
4464
4485
  }
4465
4486
  /**
@@ -4507,7 +4528,7 @@ var ScallopQuery = class {
4507
4528
  * @param ownerAddress - The owner address.
4508
4529
  * @return All Stake accounts data.
4509
4530
  */
4510
- async getAllStakeAccounts(ownerAddress) {
4531
+ async getAllStakeAccounts(ownerAddress = this.walletAddress) {
4511
4532
  return await getStakeAccounts(this, ownerAddress);
4512
4533
  }
4513
4534
  /**
@@ -4517,7 +4538,7 @@ var ScallopQuery = class {
4517
4538
  * @param ownerAddress - The owner address.
4518
4539
  * @return Stake accounts data.
4519
4540
  */
4520
- async getStakeAccounts(stakeMarketCoinName, ownerAddress) {
4541
+ async getStakeAccounts(stakeMarketCoinName, ownerAddress = this.walletAddress) {
4521
4542
  const allStakeAccount = await this.getAllStakeAccounts(ownerAddress);
4522
4543
  return allStakeAccount[stakeMarketCoinName] ?? [];
4523
4544
  }
@@ -4622,7 +4643,7 @@ var ScallopQuery = class {
4622
4643
  * @param indexer - Whether to use indexer.
4623
4644
  * @return All lending and spool infomation.
4624
4645
  */
4625
- async getLendings(poolCoinNames, ownerAddress, indexer = false) {
4646
+ async getLendings(poolCoinNames, ownerAddress = this.walletAddress, indexer = false) {
4626
4647
  return await getLendings(this, poolCoinNames, ownerAddress, indexer);
4627
4648
  }
4628
4649
  /**
@@ -4633,7 +4654,7 @@ var ScallopQuery = class {
4633
4654
  * @param indexer - Whether to use indexer.
4634
4655
  * @return Lending pool data.
4635
4656
  */
4636
- async getLending(poolCoinName, ownerAddress, indexer = false) {
4657
+ async getLending(poolCoinName, ownerAddress = this.walletAddress, indexer = false) {
4637
4658
  return await getLending(this, poolCoinName, ownerAddress, indexer);
4638
4659
  }
4639
4660
  /**
@@ -4646,7 +4667,7 @@ var ScallopQuery = class {
4646
4667
  * @param indexer - Whether to use indexer.
4647
4668
  * @return All obligation accounts information.
4648
4669
  */
4649
- async getObligationAccounts(ownerAddress, indexer = false) {
4670
+ async getObligationAccounts(ownerAddress = this.walletAddress, indexer = false) {
4650
4671
  return await getObligationAccounts(this, ownerAddress, indexer);
4651
4672
  }
4652
4673
  /**
@@ -4660,7 +4681,7 @@ var ScallopQuery = class {
4660
4681
  * @param indexer - Whether to use indexer.
4661
4682
  * @return Borrowing and collateral information.
4662
4683
  */
4663
- async getObligationAccount(obligationId, ownerAddress, indexer = false) {
4684
+ async getObligationAccount(obligationId, ownerAddress = this.walletAddress, indexer = false) {
4664
4685
  return await getObligationAccount(
4665
4686
  this,
4666
4687
  obligationId,
@@ -4742,7 +4763,7 @@ var ScallopQuery = class {
4742
4763
  * @param ownerAddress - The owner address.
4743
4764
  * @return All market sCoin amounts.
4744
4765
  */
4745
- async getSCoinAmounts(sCoinNames, ownerAddress) {
4766
+ async getSCoinAmounts(sCoinNames, ownerAddress = this.walletAddress) {
4746
4767
  return await getSCoinAmounts(this, sCoinNames, ownerAddress);
4747
4768
  }
4748
4769
  /**
@@ -4752,7 +4773,7 @@ var ScallopQuery = class {
4752
4773
  * @param ownerAddress - The owner address.
4753
4774
  * @return sCoin amount.
4754
4775
  */
4755
- async getSCoinAmount(sCoinName, ownerAddress) {
4776
+ async getSCoinAmount(sCoinName, ownerAddress = this.walletAddress) {
4756
4777
  const parsedSCoinName = this.utils.parseSCoinName(sCoinName);
4757
4778
  return parsedSCoinName ? await getSCoinAmount(this, parsedSCoinName, ownerAddress) : 0;
4758
4779
  }
@@ -4857,7 +4878,7 @@ var ScallopUtils = class {
4857
4878
  throw Error(`Coin ${coinName} is not supported`);
4858
4879
  }
4859
4880
  if (coinName === "sui")
4860
- return (0, import_utils9.normalizeStructTag)(`${coinPackageId}::sui::SUI`);
4881
+ return (0, import_utils10.normalizeStructTag)(`${coinPackageId}::sui::SUI`);
4861
4882
  const wormHolePckageIds = [
4862
4883
  this._address.get("core.coins.usdc.id") ?? wormholeCoinIds.usdc,
4863
4884
  this._address.get("core.coins.usdt.id") ?? wormholeCoinIds.usdt,
@@ -4932,7 +4953,7 @@ var ScallopUtils = class {
4932
4953
  return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
4933
4954
  }
4934
4955
  parseCoinNameFromType(coinType) {
4935
- coinType = (0, import_utils9.normalizeStructTag)(coinType);
4956
+ coinType = (0, import_utils10.normalizeStructTag)(coinType);
4936
4957
  const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
4937
4958
  const coinTypeMatch = coinType.match(coinTypeRegex);
4938
4959
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
@@ -4996,7 +5017,7 @@ var ScallopUtils = class {
4996
5017
  * @param coinType - The coin type, default is 0x2::SUI::SUI.
4997
5018
  * @return The selected transaction coin arguments.
4998
5019
  */
4999
- async selectCoins(amount, coinType = import_utils9.SUI_TYPE_ARG, ownerAddress) {
5020
+ async selectCoins(amount, coinType = import_utils10.SUI_TYPE_ARG, ownerAddress) {
5000
5021
  ownerAddress = ownerAddress || this._suiKit.currentAddress();
5001
5022
  const coins = await this._suiKit.suiInteractor.selectCoins(
5002
5023
  ownerAddress,
@@ -5177,16 +5198,16 @@ var ScallopUtils = class {
5177
5198
  };
5178
5199
 
5179
5200
  // src/models/scallopBuilder.ts
5180
- var import_utils22 = require("@mysten/sui.js/utils");
5201
+ var import_utils23 = require("@mysten/sui.js/utils");
5181
5202
  var import_sui_kit12 = require("@scallop-io/sui-kit");
5182
5203
 
5183
5204
  // src/builders/coreBuilder.ts
5184
5205
  var import_transactions = require("@mysten/sui.js/transactions");
5185
- var import_utils12 = require("@mysten/sui.js/utils");
5206
+ var import_utils13 = require("@mysten/sui.js/utils");
5186
5207
  var import_sui_kit5 = require("@scallop-io/sui-kit");
5187
5208
 
5188
5209
  // src/builders/oracle.ts
5189
- var import_utils11 = require("@mysten/sui.js/utils");
5210
+ var import_utils12 = require("@mysten/sui.js/utils");
5190
5211
  var import_pyth_sui_js2 = require("@pythnetwork/pyth-sui-js");
5191
5212
  var updateOracles = async (builder, txBlock, assetCoinNames) => {
5192
5213
  assetCoinNames = assetCoinNames ?? [
@@ -5300,27 +5321,27 @@ var priceUpdateRequest = (txBlock, packageId, xOracleId, coinType) => {
5300
5321
  var confirmPriceUpdateRequest = (txBlock, packageId, xOracleId, request, coinType) => {
5301
5322
  const target = `${packageId}::x_oracle::confirm_price_update_request`;
5302
5323
  const typeArgs = [coinType];
5303
- txBlock.moveCall(target, [xOracleId, request, import_utils11.SUI_CLOCK_OBJECT_ID], typeArgs);
5324
+ txBlock.moveCall(target, [xOracleId, request, import_utils12.SUI_CLOCK_OBJECT_ID], typeArgs);
5304
5325
  return txBlock;
5305
5326
  };
5306
5327
  var updateSupraPrice = (txBlock, packageId, request, holderId, registryId, coinType) => {
5307
5328
  txBlock.moveCall(
5308
5329
  `${packageId}::rule::set_price`,
5309
- [request, holderId, registryId, import_utils11.SUI_CLOCK_OBJECT_ID],
5330
+ [request, holderId, registryId, import_utils12.SUI_CLOCK_OBJECT_ID],
5310
5331
  [coinType]
5311
5332
  );
5312
5333
  };
5313
5334
  var updateSwitchboardPrice = (txBlock, packageId, request, aggregatorId, registryId, coinType) => {
5314
5335
  txBlock.moveCall(
5315
5336
  `${packageId}::rule::set_price`,
5316
- [request, aggregatorId, registryId, import_utils11.SUI_CLOCK_OBJECT_ID],
5337
+ [request, aggregatorId, registryId, import_utils12.SUI_CLOCK_OBJECT_ID],
5317
5338
  [coinType]
5318
5339
  );
5319
5340
  };
5320
5341
  var updatePythPrice = (txBlock, packageId, request, stateId, feedObjectId, registryId, coinType) => {
5321
5342
  txBlock.moveCall(
5322
5343
  `${packageId}::rule::set_price`,
5323
- [request, stateId, feedObjectId, registryId, import_utils11.SUI_CLOCK_OBJECT_ID],
5344
+ [request, stateId, feedObjectId, registryId, import_utils12.SUI_CLOCK_OBJECT_ID],
5324
5345
  [coinType]
5325
5346
  );
5326
5347
  };
@@ -5391,7 +5412,7 @@ var generateCoreNormalMethod = ({
5391
5412
  coreIds.coinDecimalsRegistry,
5392
5413
  amount,
5393
5414
  coreIds.xOracle,
5394
- import_utils12.SUI_CLOCK_OBJECT_ID
5415
+ import_utils13.SUI_CLOCK_OBJECT_ID
5395
5416
  ],
5396
5417
  [coinType]
5397
5418
  );
@@ -5400,7 +5421,7 @@ var generateCoreNormalMethod = ({
5400
5421
  const coinType = builder.utils.parseCoinType(poolCoinName);
5401
5422
  return txBlock.moveCall(
5402
5423
  `${coreIds.protocolPkg}::mint::mint`,
5403
- [coreIds.version, coreIds.market, coin, import_utils12.SUI_CLOCK_OBJECT_ID],
5424
+ [coreIds.version, coreIds.market, coin, import_utils13.SUI_CLOCK_OBJECT_ID],
5404
5425
  [coinType]
5405
5426
  );
5406
5427
  },
@@ -5408,7 +5429,7 @@ var generateCoreNormalMethod = ({
5408
5429
  const coinType = builder.utils.parseCoinType(poolCoinName);
5409
5430
  return txBlock.moveCall(
5410
5431
  `${coreIds.protocolPkg}::mint::mint_entry`,
5411
- [coreIds.version, coreIds.market, coin, import_utils12.SUI_CLOCK_OBJECT_ID],
5432
+ [coreIds.version, coreIds.market, coin, import_utils13.SUI_CLOCK_OBJECT_ID],
5412
5433
  [coinType]
5413
5434
  );
5414
5435
  },
@@ -5416,7 +5437,7 @@ var generateCoreNormalMethod = ({
5416
5437
  const coinType = builder.utils.parseCoinType(poolCoinName);
5417
5438
  return txBlock.moveCall(
5418
5439
  `${coreIds.protocolPkg}::redeem::redeem`,
5419
- [coreIds.version, coreIds.market, marketCoin, import_utils12.SUI_CLOCK_OBJECT_ID],
5440
+ [coreIds.version, coreIds.market, marketCoin, import_utils13.SUI_CLOCK_OBJECT_ID],
5420
5441
  [coinType]
5421
5442
  );
5422
5443
  },
@@ -5424,7 +5445,7 @@ var generateCoreNormalMethod = ({
5424
5445
  const coinType = builder.utils.parseCoinType(poolCoinName);
5425
5446
  return txBlock.moveCall(
5426
5447
  `${coreIds.protocolPkg}::redeem::redeem_entry`,
5427
- [coreIds.version, coreIds.market, marketCoin, import_utils12.SUI_CLOCK_OBJECT_ID],
5448
+ [coreIds.version, coreIds.market, marketCoin, import_utils13.SUI_CLOCK_OBJECT_ID],
5428
5449
  [coinType]
5429
5450
  );
5430
5451
  },
@@ -5440,7 +5461,7 @@ var generateCoreNormalMethod = ({
5440
5461
  coreIds.coinDecimalsRegistry,
5441
5462
  amount,
5442
5463
  coreIds.xOracle,
5443
- import_utils12.SUI_CLOCK_OBJECT_ID
5464
+ import_utils13.SUI_CLOCK_OBJECT_ID
5444
5465
  ],
5445
5466
  [coinType]
5446
5467
  );
@@ -5458,7 +5479,7 @@ var generateCoreNormalMethod = ({
5458
5479
  borrowReferral,
5459
5480
  amount,
5460
5481
  coreIds.xOracle,
5461
- import_utils12.SUI_CLOCK_OBJECT_ID
5482
+ import_utils13.SUI_CLOCK_OBJECT_ID
5462
5483
  ],
5463
5484
  [coinType, referralWitnessType]
5464
5485
  );
@@ -5475,7 +5496,7 @@ var generateCoreNormalMethod = ({
5475
5496
  coreIds.coinDecimalsRegistry,
5476
5497
  amount,
5477
5498
  coreIds.xOracle,
5478
- import_utils12.SUI_CLOCK_OBJECT_ID
5499
+ import_utils13.SUI_CLOCK_OBJECT_ID
5479
5500
  ],
5480
5501
  [coinType]
5481
5502
  );
@@ -5489,7 +5510,7 @@ var generateCoreNormalMethod = ({
5489
5510
  obligation,
5490
5511
  coreIds.market,
5491
5512
  coin,
5492
- import_utils12.SUI_CLOCK_OBJECT_ID
5513
+ import_utils13.SUI_CLOCK_OBJECT_ID
5493
5514
  ],
5494
5515
  [coinType]
5495
5516
  );
@@ -5724,7 +5745,7 @@ var newCoreTxBlock = (builder, initTxBlock) => {
5724
5745
 
5725
5746
  // src/builders/spoolBuilder.ts
5726
5747
  var import_transactions2 = require("@mysten/sui.js/transactions");
5727
- var import_utils14 = require("@mysten/sui.js/utils");
5748
+ var import_utils15 = require("@mysten/sui.js/utils");
5728
5749
  var import_sui_kit6 = require("@scallop-io/sui-kit");
5729
5750
  var requireStakeAccountIds = async (...params) => {
5730
5751
  const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
@@ -5780,7 +5801,7 @@ var generateSpoolNormalMethod = ({
5780
5801
  );
5781
5802
  return txBlock.moveCall(
5782
5803
  `${spoolIds.spoolPkg}::user::new_spool_account`,
5783
- [stakePoolId, import_utils14.SUI_CLOCK_OBJECT_ID],
5804
+ [stakePoolId, import_utils15.SUI_CLOCK_OBJECT_ID],
5784
5805
  [marketCoinType]
5785
5806
  );
5786
5807
  },
@@ -5791,7 +5812,7 @@ var generateSpoolNormalMethod = ({
5791
5812
  );
5792
5813
  txBlock.moveCall(
5793
5814
  `${spoolIds.spoolPkg}::user::stake`,
5794
- [stakePoolId, stakeAccount, coin, import_utils14.SUI_CLOCK_OBJECT_ID],
5815
+ [stakePoolId, stakeAccount, coin, import_utils15.SUI_CLOCK_OBJECT_ID],
5795
5816
  [marketCoinType]
5796
5817
  );
5797
5818
  },
@@ -5802,7 +5823,7 @@ var generateSpoolNormalMethod = ({
5802
5823
  );
5803
5824
  return txBlock.moveCall(
5804
5825
  `${spoolIds.spoolPkg}::user::unstake`,
5805
- [stakePoolId, stakeAccount, amount, import_utils14.SUI_CLOCK_OBJECT_ID],
5826
+ [stakePoolId, stakeAccount, amount, import_utils15.SUI_CLOCK_OBJECT_ID],
5806
5827
  [marketCoinType]
5807
5828
  );
5808
5829
  },
@@ -5818,7 +5839,7 @@ var generateSpoolNormalMethod = ({
5818
5839
  const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
5819
5840
  return txBlock.moveCall(
5820
5841
  `${spoolIds.spoolPkg}::user::redeem_rewards`,
5821
- [stakePoolId, rewardPoolId, stakeAccount, import_utils14.SUI_CLOCK_OBJECT_ID],
5842
+ [stakePoolId, rewardPoolId, stakeAccount, import_utils15.SUI_CLOCK_OBJECT_ID],
5822
5843
  [marketCoinType, rewardCoinType]
5823
5844
  );
5824
5845
  }
@@ -5975,7 +5996,7 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
5975
5996
 
5976
5997
  // src/builders/borrowIncentiveBuilder.ts
5977
5998
  var import_transactions3 = require("@mysten/sui.js/transactions");
5978
- var import_utils17 = require("@mysten/sui.js/utils");
5999
+ var import_utils18 = require("@mysten/sui.js/utils");
5979
6000
  var import_sui_kit8 = require("@scallop-io/sui-kit");
5980
6001
 
5981
6002
  // src/builders/vescaBuilder.ts
@@ -6301,7 +6322,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6301
6322
  obligationKey,
6302
6323
  obligationId,
6303
6324
  borrowIncentiveIds.obligationAccessStore,
6304
- import_utils17.SUI_CLOCK_OBJECT_ID
6325
+ import_utils18.SUI_CLOCK_OBJECT_ID
6305
6326
  ]
6306
6327
  );
6307
6328
  },
@@ -6319,7 +6340,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6319
6340
  veScaIds.treasury,
6320
6341
  veScaIds.table,
6321
6342
  veScaKey,
6322
- import_utils17.SUI_CLOCK_OBJECT_ID
6343
+ import_utils18.SUI_CLOCK_OBJECT_ID
6323
6344
  ],
6324
6345
  []
6325
6346
  );
@@ -6333,7 +6354,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6333
6354
  borrowIncentiveIds.incentiveAccounts,
6334
6355
  obligationKey,
6335
6356
  obligationId,
6336
- import_utils17.SUI_CLOCK_OBJECT_ID
6357
+ import_utils18.SUI_CLOCK_OBJECT_ID
6337
6358
  ]
6338
6359
  );
6339
6360
  },
@@ -6351,7 +6372,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6351
6372
  borrowIncentiveIds.incentiveAccounts,
6352
6373
  obligationKey,
6353
6374
  obligationId,
6354
- import_utils17.SUI_CLOCK_OBJECT_ID
6375
+ import_utils18.SUI_CLOCK_OBJECT_ID
6355
6376
  ],
6356
6377
  [rewardType]
6357
6378
  );
@@ -6365,7 +6386,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6365
6386
  borrowIncentiveIds.incentiveAccounts,
6366
6387
  obligation,
6367
6388
  veScaKey,
6368
- import_utils17.SUI_CLOCK_OBJECT_ID
6389
+ import_utils18.SUI_CLOCK_OBJECT_ID
6369
6390
  ]
6370
6391
  );
6371
6392
  }
@@ -6844,7 +6865,7 @@ var ScallopBuilder = class {
6844
6865
  query: this.query,
6845
6866
  cache: this.cache
6846
6867
  });
6847
- this.walletAddress = (0, import_utils22.normalizeSuiAddress)(
6868
+ this.walletAddress = (0, import_utils23.normalizeSuiAddress)(
6848
6869
  params?.walletAddress || this.suiKit.currentAddress()
6849
6870
  );
6850
6871
  this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
@@ -6882,7 +6903,7 @@ var ScallopBuilder = class {
6882
6903
  * @param sender - Sender address.
6883
6904
  * @return Take coin and left coin.
6884
6905
  */
6885
- async selectCoin(txBlock, assetCoinName, amount, sender) {
6906
+ async selectCoin(txBlock, assetCoinName, amount, sender = this.walletAddress) {
6886
6907
  const coinType = this.utils.parseCoinType(assetCoinName);
6887
6908
  const coins = await this.utils.selectCoins(amount, coinType, sender);
6888
6909
  const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
@@ -6897,7 +6918,7 @@ var ScallopBuilder = class {
6897
6918
  * @param sender - Sender address.
6898
6919
  * @return Take coin and left coin.
6899
6920
  */
6900
- async selectMarketCoin(txBlock, marketCoinName, amount, sender) {
6921
+ async selectMarketCoin(txBlock, marketCoinName, amount, sender = this.walletAddress) {
6901
6922
  const marketCoinType = this.utils.parseMarketCoinType(marketCoinName);
6902
6923
  const coins = await this.utils.selectCoins(amount, marketCoinType, sender);
6903
6924
  const totalAmount = coins.reduce((prev, coin) => {
@@ -6919,7 +6940,7 @@ var ScallopBuilder = class {
6919
6940
  * @param sender - Sender address.
6920
6941
  * @return Take coin and left coin.
6921
6942
  */
6922
- async selectSCoin(txBlock, sCoinName, amount, sender) {
6943
+ async selectSCoin(txBlock, sCoinName, amount, sender = this.walletAddress) {
6923
6944
  const sCoinType = this.utils.parseSCoinType(sCoinName);
6924
6945
  const coins = await this.utils.selectCoins(amount, sCoinType, sender);
6925
6946
  const totalAmount = coins.reduce((prev, coin) => {
@@ -6979,7 +7000,7 @@ var ScallopClient = class {
6979
7000
  utils: this.utils,
6980
7001
  cache: this.cache
6981
7002
  });
6982
- this.walletAddress = (0, import_utils23.normalizeSuiAddress)(
7003
+ this.walletAddress = (0, import_utils24.normalizeSuiAddress)(
6983
7004
  params?.walletAddress || this.suiKit.currentAddress()
6984
7005
  );
6985
7006
  }
@@ -7326,12 +7347,12 @@ var ScallopClient = class {
7326
7347
  const txBlock = this.builder.createTxBlock();
7327
7348
  const sender = walletAddress || this.walletAddress;
7328
7349
  txBlock.setSender(sender);
7329
- const marketCoin = await txBlock.unstakeQuick(
7350
+ const sCoin = await txBlock.unstakeQuick(
7330
7351
  amount,
7331
7352
  stakeMarketCoinName,
7332
7353
  stakeAccountId
7333
7354
  );
7334
- txBlock.transferObjects([marketCoin], sender);
7355
+ txBlock.transferObjects([sCoin], sender);
7335
7356
  if (sign) {
7336
7357
  return await this.suiKit.signAndSendTxn(
7337
7358
  txBlock
@@ -7347,12 +7368,15 @@ var ScallopClient = class {
7347
7368
  const stakeMarketCoin = await txBlock.unstakeQuick(
7348
7369
  amount,
7349
7370
  stakeMarketCoinName,
7350
- stakeAccountId
7371
+ stakeAccountId,
7372
+ false
7351
7373
  );
7352
7374
  const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
7353
7375
  if (stakeMarketCoin) {
7354
7376
  const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
7355
7377
  txBlock.transferObjects([coin], sender);
7378
+ } else {
7379
+ throw new Error(`No stake found for ${stakeMarketCoinName}`);
7356
7380
  }
7357
7381
  if (sign) {
7358
7382
  return await this.suiKit.signAndSendTxn(