@scallop-io/sui-scallop-sdk 0.47.2 → 1.3.0-alpha.1

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.
Files changed (70) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +2 -2
  2. package/dist/builders/coreBuilder.d.ts +2 -2
  3. package/dist/builders/index.d.ts +2 -2
  4. package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
  5. package/dist/builders/oracle.d.ts +4 -1
  6. package/dist/builders/referralBuilder.d.ts +2 -2
  7. package/dist/builders/sCoinBuilder.d.ts +2 -2
  8. package/dist/builders/spoolBuilder.d.ts +2 -2
  9. package/dist/builders/vescaBuilder.d.ts +2 -2
  10. package/dist/constants/common.d.ts +4 -4
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/vesca.d.ts +3 -3
  13. package/dist/index.js +125 -96
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +128 -102
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/models/scallop.d.ts +5 -5
  18. package/dist/models/scallopBuilder.d.ts +10 -8
  19. package/dist/models/scallopCache.d.ts +5 -9
  20. package/dist/models/scallopClient.d.ts +2 -2
  21. package/dist/models/scallopQuery.d.ts +1 -1
  22. package/dist/models/scallopUtils.d.ts +2 -2
  23. package/dist/queries/coreQuery.d.ts +3 -3
  24. package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
  25. package/dist/queries/priceQuery.d.ts +1 -1
  26. package/dist/queries/vescaQuery.d.ts +1 -1
  27. package/dist/test.d.ts +1 -0
  28. package/dist/types/builder/borrowIncentive.d.ts +1 -1
  29. package/dist/types/builder/core.d.ts +16 -16
  30. package/dist/types/builder/spool.d.ts +3 -3
  31. package/dist/types/builder/vesca.d.ts +5 -5
  32. package/dist/types/model.d.ts +8 -7
  33. package/dist/types/query/vesca.d.ts +1 -1
  34. package/dist/utils/query.d.ts +1 -1
  35. package/dist/utils/util.d.ts +1 -0
  36. package/package.json +13 -9
  37. package/src/builders/borrowIncentiveBuilder.ts +9 -14
  38. package/src/builders/coreBuilder.ts +15 -15
  39. package/src/builders/index.ts +2 -2
  40. package/src/builders/loyaltyProgramBuilder.ts +5 -5
  41. package/src/builders/oracle.ts +13 -6
  42. package/src/builders/referralBuilder.ts +6 -6
  43. package/src/builders/sCoinBuilder.ts +5 -8
  44. package/src/builders/spoolBuilder.ts +9 -9
  45. package/src/builders/vescaBuilder.ts +5 -5
  46. package/src/constants/common.ts +4 -4
  47. package/src/constants/index.ts +1 -1
  48. package/src/constants/vesca.ts +5 -6
  49. package/src/models/scallop.ts +39 -16
  50. package/src/models/scallopBuilder.ts +14 -7
  51. package/src/models/scallopCache.ts +43 -34
  52. package/src/models/scallopClient.ts +8 -6
  53. package/src/models/scallopQuery.ts +2 -2
  54. package/src/models/scallopUtils.ts +3 -3
  55. package/src/queries/borrowIncentiveQuery.ts +1 -1
  56. package/src/queries/coreQuery.ts +4 -4
  57. package/src/queries/loyaltyProgramQuery.ts +1 -1
  58. package/src/queries/priceQuery.ts +1 -1
  59. package/src/queries/sCoinQuery.ts +2 -2
  60. package/src/queries/spoolQuery.ts +4 -5
  61. package/src/queries/vescaQuery.ts +6 -3
  62. package/src/test.ts +26 -0
  63. package/src/types/address.ts +26 -26
  64. package/src/types/builder/borrowIncentive.ts +1 -1
  65. package/src/types/builder/core.ts +26 -28
  66. package/src/types/builder/spool.ts +2 -3
  67. package/src/types/builder/vesca.ts +5 -9
  68. package/src/types/model.ts +11 -10
  69. package/src/types/query/vesca.ts +1 -1
  70. package/src/utils/query.ts +1 -1
package/dist/index.mjs CHANGED
@@ -240,13 +240,6 @@ var sCoinIds = {
240
240
  swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
241
241
  };
242
242
 
243
- // src/constants/vesca.ts
244
- var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
245
- var MAX_LOCK_ROUNDS = 1460;
246
- var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
247
- var MIN_INITIAL_LOCK_AMOUNT = 1e10;
248
- var MIN_TOP_UP_AMOUNT = 1e9;
249
-
250
243
  // src/constants/flashloan.ts
251
244
  var FlashLoanFeeObjectMap = {
252
245
  vsui: "0x0069cddee7a5c0b1d34beb5ef0620f978096525f1830b055f38b110f40d73fbb",
@@ -263,6 +256,13 @@ var FlashLoanFeeObjectMap = {
263
256
  wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
264
257
  };
265
258
 
259
+ // src/constants/vesca.ts
260
+ var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
261
+ var MAX_LOCK_ROUNDS = 1460;
262
+ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
263
+ var MIN_INITIAL_LOCK_AMOUNT = 1e10;
264
+ var MIN_TOP_UP_AMOUNT = 1e9;
265
+
266
266
  // src/models/scallop.ts
267
267
  import { SuiKit as SuiKit7 } from "@scallop-io/sui-kit";
268
268
 
@@ -391,7 +391,7 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
391
391
 
392
392
  // src/utils/query.ts
393
393
  import BigNumber from "bignumber.js";
394
- import { normalizeStructTag, parseStructTag } from "@mysten/sui.js/utils";
394
+ import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
395
395
  var parseOriginMarketPoolData = (originMarketPoolData) => {
396
396
  return {
397
397
  coinType: normalizeStructTag(originMarketPoolData.type.name),
@@ -928,21 +928,40 @@ var ScallopCache = class {
928
928
  refetchType
929
929
  });
930
930
  }
931
- /**
932
- * @description Cache protocol config call for 60 seconds.
933
- * @returns Promise<ProtocolConfig>
934
- */
935
- async getProtocolConfig() {
936
- return await this.queryClient.fetchQuery({
937
- queryKey: ["getProtocolConfig"],
938
- queryFn: async () => {
939
- return await callWithRateLimit(
940
- this.tokenBucket,
941
- () => this.client.getProtocolConfig()
942
- );
943
- },
944
- staleTime: 3e4
945
- });
931
+ async resolveArgs(txb, args) {
932
+ return await Promise.all(
933
+ args.map(async (arg) => {
934
+ if (typeof arg === "string") {
935
+ const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
936
+ if (!objData)
937
+ return arg;
938
+ const owner = objData?.owner;
939
+ if (!owner)
940
+ return arg;
941
+ if ("Shared" in owner) {
942
+ return txb.sharedObjectRef({
943
+ objectId: objData.objectId,
944
+ initialSharedVersion: owner.Shared.initial_shared_version,
945
+ mutable: true
946
+ });
947
+ } else {
948
+ return txb.objectRef({
949
+ objectId: objData.objectId,
950
+ version: objData.version,
951
+ digest: objData.digest
952
+ });
953
+ }
954
+ } else if ("objectId" in arg && "version" in arg && "digest" in arg) {
955
+ return txb.objectRef({
956
+ objectId: arg.objectId,
957
+ version: arg.version,
958
+ digest: arg.digest
959
+ });
960
+ } else {
961
+ return arg;
962
+ }
963
+ })
964
+ );
946
965
  }
947
966
  /**
948
967
  * @description Provides cache for inspectTxn of the SuiKit.
@@ -956,20 +975,8 @@ var ScallopCache = class {
956
975
  typeArgs
957
976
  }) {
958
977
  const txBlock = new SuiTxBlock();
959
- const resolvedArgs = await Promise.all(
960
- args.map(async (arg) => {
961
- if (typeof arg === "string") {
962
- return (await this.queryGetObject(arg, { showContent: true }))?.data;
963
- }
964
- return arg;
965
- })
966
- );
978
+ const resolvedArgs = await this.resolveArgs(txBlock, args);
967
979
  txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
968
- const txBytes = await txBlock.txBlock.build({
969
- client: this.client,
970
- onlyTransactionKind: true,
971
- protocolConfig: await this.getProtocolConfig() ?? void 0
972
- });
973
980
  const query = await this.queryClient.fetchQuery({
974
981
  queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
975
982
  "inspectTxn",
@@ -980,7 +987,7 @@ var ScallopCache = class {
980
987
  queryFn: async () => {
981
988
  return await callWithRateLimit(
982
989
  this.tokenBucket,
983
- () => this.suiKit.inspectTxn(txBytes)
990
+ () => this.suiKit.inspectTxn(txBlock)
984
991
  );
985
992
  }
986
993
  });
@@ -2201,16 +2208,16 @@ var ScallopAddress = class {
2201
2208
  };
2202
2209
 
2203
2210
  // src/models/scallopClient.ts
2204
- import { normalizeSuiAddress as normalizeSuiAddress4 } from "@mysten/sui.js/utils";
2211
+ import { normalizeSuiAddress as normalizeSuiAddress4 } from "@mysten/sui/utils";
2205
2212
  import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
2206
2213
 
2207
2214
  // src/models/scallopUtils.ts
2208
- import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui.js/utils";
2215
+ import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
2209
2216
  import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
2210
2217
  import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
2211
2218
 
2212
2219
  // src/queries/coreQuery.ts
2213
- import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui.js/utils";
2220
+ import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
2214
2221
  import BigNumber2 from "bignumber.js";
2215
2222
 
2216
2223
  // src/queries/supplyLimit.ts
@@ -2865,7 +2872,7 @@ var getFlashLoanFees = async (query, assetNames) => {
2865
2872
  };
2866
2873
 
2867
2874
  // src/queries/spoolQuery.ts
2868
- import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui.js/utils";
2875
+ import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
2869
2876
  var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
2870
2877
  const stakeCoinNames = stakeMarketCoinNames.map(
2871
2878
  (stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
@@ -3261,7 +3268,7 @@ var getStakeRewardPool = async ({
3261
3268
  };
3262
3269
 
3263
3270
  // src/queries/borrowIncentiveQuery.ts
3264
- import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
3271
+ import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
3265
3272
  import BigNumber3 from "bignumber.js";
3266
3273
  var queryBorrowIncentivePools = async (address) => {
3267
3274
  const queryPkgId = address.get("borrowIncentive.query");
@@ -4048,8 +4055,9 @@ var getTotalValueLocked = async (query, indexer = false) => {
4048
4055
  // src/queries/vescaQuery.ts
4049
4056
  import BigNumber5 from "bignumber.js";
4050
4057
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
4051
- import { bcs } from "@mysten/sui.js/bcs";
4058
+ import { bcs } from "@mysten/sui/bcs";
4052
4059
  import { z as zod2 } from "zod";
4060
+ import assert from "assert";
4053
4061
  var getVescaKeys = async (utils, ownerAddress) => {
4054
4062
  const owner = ownerAddress || utils.suiKit.currentAddress();
4055
4063
  const veScaObjId = utils.address.get("vesca.object");
@@ -4183,7 +4191,8 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
4183
4191
  if (results && results[1].returnValues) {
4184
4192
  const value = Uint8Array.from(results[1].returnValues[0][0]);
4185
4193
  const type = results[1].returnValues[0][1];
4186
- return bcs.de(type, value);
4194
+ assert(type === "u64", "Result type is not u64");
4195
+ return bcs.u64().parse(value);
4187
4196
  }
4188
4197
  return "0";
4189
4198
  };
@@ -4720,28 +4729,30 @@ var ScallopUtils = class {
4720
4729
  };
4721
4730
 
4722
4731
  // src/models/scallopBuilder.ts
4723
- import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui.js/utils";
4732
+ import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
4724
4733
  import { SuiKit as SuiKit5 } from "@scallop-io/sui-kit";
4725
4734
 
4726
4735
  // src/builders/coreBuilder.ts
4727
- import { TransactionBlock } from "@mysten/sui.js/transactions";
4728
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui.js/utils";
4736
+ import { Transaction } from "@mysten/sui/transactions";
4737
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui/utils";
4729
4738
  import { SuiTxBlock as SuiKitTxBlock } from "@scallop-io/sui-kit";
4730
4739
 
4731
4740
  // src/builders/oracle.ts
4732
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui.js/utils";
4741
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui/utils";
4733
4742
  import {
4734
4743
  SuiPythClient,
4735
4744
  SuiPriceServiceConnection as SuiPriceServiceConnection2
4736
4745
  } from "@pythnetwork/pyth-sui-js";
4737
- var updateOracles = async (builder, txBlock, assetCoinNames) => {
4746
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
4747
+ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
4748
+ const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
4738
4749
  assetCoinNames = assetCoinNames ?? [
4739
4750
  .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4740
4751
  ];
4741
4752
  const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
4742
- if (rules.includes("pyth")) {
4753
+ if (usePythPullModel && rules.includes("pyth")) {
4743
4754
  const pythClient = new SuiPythClient(
4744
- builder.suiKit.client(),
4755
+ builder.oldSuiClient,
4745
4756
  builder.address.get("core.oracles.pyth.state"),
4746
4757
  builder.address.get("core.oracles.pyth.wormholeState")
4747
4758
  );
@@ -4754,7 +4765,8 @@ var updateOracles = async (builder, txBlock, assetCoinNames) => {
4754
4765
  const pythConnection = new SuiPriceServiceConnection2(endpoint);
4755
4766
  const priceUpdateData = await pythConnection.getPriceFeedsUpdateData(priceIds);
4756
4767
  await pythClient.updatePriceFeeds(
4757
- txBlock.txBlock,
4768
+ TransactionBlock.from(txBlock.serialize()),
4769
+ // convert txBlock to TransactionBlock because pyth sdk not support new @mysten/sui yet
4758
4770
  priceUpdateData,
4759
4771
  priceIds
4760
4772
  );
@@ -4935,7 +4947,7 @@ var generateCoreNormalMethod = ({
4935
4947
  obligationKey,
4936
4948
  coreIds.market,
4937
4949
  coreIds.coinDecimalsRegistry,
4938
- amount,
4950
+ txBlock.pure.u64(amount),
4939
4951
  coreIds.xOracle,
4940
4952
  SUI_CLOCK_OBJECT_ID3
4941
4953
  ],
@@ -5002,7 +5014,7 @@ var generateCoreNormalMethod = ({
5002
5014
  coreIds.market,
5003
5015
  coreIds.coinDecimalsRegistry,
5004
5016
  borrowReferral,
5005
- amount,
5017
+ txBlock.pure.u64(amount),
5006
5018
  coreIds.xOracle,
5007
5019
  SUI_CLOCK_OBJECT_ID3
5008
5020
  ],
@@ -5019,7 +5031,7 @@ var generateCoreNormalMethod = ({
5019
5031
  obligationKey,
5020
5032
  coreIds.market,
5021
5033
  coreIds.coinDecimalsRegistry,
5022
- amount,
5034
+ txBlock.pure.u64(amount),
5023
5035
  coreIds.xOracle,
5024
5036
  SUI_CLOCK_OBJECT_ID3
5025
5037
  ],
@@ -5237,7 +5249,7 @@ var generateCoreQuickMethod = ({
5237
5249
  };
5238
5250
  };
5239
5251
  var newCoreTxBlock = (builder, initTxBlock) => {
5240
- const txBlock = initTxBlock instanceof TransactionBlock ? new SuiKitTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock();
5252
+ const txBlock = initTxBlock instanceof Transaction ? new SuiKitTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock();
5241
5253
  const normalMethod = generateCoreNormalMethod({
5242
5254
  builder,
5243
5255
  txBlock
@@ -5265,8 +5277,8 @@ var newCoreTxBlock = (builder, initTxBlock) => {
5265
5277
  };
5266
5278
 
5267
5279
  // src/builders/spoolBuilder.ts
5268
- import { TransactionBlock as TransactionBlock2 } from "@mysten/sui.js/transactions";
5269
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui.js/utils";
5280
+ import { Transaction as Transaction2 } from "@mysten/sui/transactions";
5281
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui/utils";
5270
5282
  import { SuiTxBlock as SuiKitTxBlock2 } from "@scallop-io/sui-kit";
5271
5283
  var requireStakeAccountIds = async (...params) => {
5272
5284
  const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
@@ -5459,7 +5471,7 @@ var generateSpoolQuickMethod = ({
5459
5471
  };
5460
5472
  };
5461
5473
  var newSpoolTxBlock = (builder, initTxBlock) => {
5462
- const txBlock = initTxBlock instanceof TransactionBlock2 ? new SuiKitTxBlock2(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock2();
5474
+ const txBlock = initTxBlock instanceof Transaction2 ? new SuiKitTxBlock2(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock2();
5463
5475
  const normalMethod = generateSpoolNormalMethod({
5464
5476
  builder,
5465
5477
  txBlock
@@ -5487,8 +5499,8 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
5487
5499
  };
5488
5500
 
5489
5501
  // src/builders/borrowIncentiveBuilder.ts
5490
- import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
5491
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui.js/utils";
5502
+ import { Transaction as Transaction3 } from "@mysten/sui/transactions";
5503
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui/utils";
5492
5504
  import { SuiTxBlock as SuiKitTxBlock3 } from "@scallop-io/sui-kit";
5493
5505
  var requireObligationInfo2 = async (...params) => {
5494
5506
  const [builder, txBlock, obligationId, obligationKey] = params;
@@ -5646,19 +5658,14 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5646
5658
  );
5647
5659
  if (!obligationLocked || unstakeObligationBeforeStake) {
5648
5660
  const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
5649
- if (veScaKey && veScaKey !== bindedVeScaKey) {
5650
- throw new Error(
5651
- "Binded veScaKey is not equal to the provided veScaKey"
5652
- );
5653
- }
5654
- if (bindedVeScaKey) {
5661
+ if (veScaKey && veScaKey !== bindedVeScaKey || !bindedVeScaKey) {
5662
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
5663
+ } else {
5655
5664
  txBlock.stakeObligationWithVesca(
5656
5665
  obligationArg,
5657
5666
  obligationKeyArg,
5658
5667
  bindedVeScaKey
5659
5668
  );
5660
- } else {
5661
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
5662
5669
  }
5663
5670
  }
5664
5671
  },
@@ -5694,7 +5701,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5694
5701
  };
5695
5702
  };
5696
5703
  var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
5697
- const txBlock = initTxBlock instanceof TransactionBlock3 ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
5704
+ const txBlock = initTxBlock instanceof Transaction3 ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
5698
5705
  const normalMethod = generateBorrowIncentiveNormalMethod({
5699
5706
  builder,
5700
5707
  txBlock
@@ -5724,7 +5731,7 @@ var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
5724
5731
  // src/builders/vescaBuilder.ts
5725
5732
  import {
5726
5733
  SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID6,
5727
- TransactionBlock as TransactionBlock4,
5734
+ Transaction as Transaction4,
5728
5735
  SuiTxBlock as SuiKitTxBlock4
5729
5736
  } from "@scallop-io/sui-kit";
5730
5737
  var requireVeSca = async (...params) => {
@@ -5974,7 +5981,7 @@ var generateQuickVeScaMethod = ({
5974
5981
  };
5975
5982
  };
5976
5983
  var newVeScaTxBlock = (builder, initTxBlock) => {
5977
- const txBlock = initTxBlock instanceof TransactionBlock4 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
5984
+ const txBlock = initTxBlock instanceof Transaction4 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
5978
5985
  const normalMethod = generateNormalVeScaMethod({
5979
5986
  builder,
5980
5987
  txBlock
@@ -6005,7 +6012,7 @@ var newVeScaTxBlock = (builder, initTxBlock) => {
6005
6012
  import {
6006
6013
  SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID7,
6007
6014
  SuiTxBlock as SuiKitTxBlock5,
6008
- TransactionBlock as TransactionBlock5
6015
+ Transaction as Transaction5
6009
6016
  } from "@scallop-io/sui-kit";
6010
6017
  var generateReferralNormalMethod = ({
6011
6018
  builder,
@@ -6028,7 +6035,7 @@ var generateReferralNormalMethod = ({
6028
6035
  `${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
6029
6036
  [
6030
6037
  referralIds.referralBindings,
6031
- txBlock.pure(veScaKeyId),
6038
+ txBlock.pure.id(veScaKeyId),
6032
6039
  veScaTable,
6033
6040
  SUI_CLOCK_OBJECT_ID7
6034
6041
  ],
@@ -6112,7 +6119,7 @@ var generateReferralQuickMethod = ({
6112
6119
  };
6113
6120
  };
6114
6121
  var newReferralTxBlock = (builder, initTxBlock) => {
6115
- const txBlock = initTxBlock instanceof TransactionBlock5 ? new SuiKitTxBlock5(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock5();
6122
+ const txBlock = initTxBlock instanceof Transaction5 ? new SuiKitTxBlock5(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock5();
6116
6123
  const normalMethod = generateReferralNormalMethod({
6117
6124
  builder,
6118
6125
  txBlock
@@ -6140,7 +6147,7 @@ var newReferralTxBlock = (builder, initTxBlock) => {
6140
6147
  };
6141
6148
 
6142
6149
  // src/builders/loyaltyProgramBuilder.ts
6143
- import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
6150
+ import { Transaction as Transaction6 } from "@mysten/sui/transactions";
6144
6151
  import { SuiTxBlock as SuiKitTxBlock6 } from "@scallop-io/sui-kit";
6145
6152
  var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
6146
6153
  const loyaltyProgramIds = {
@@ -6181,7 +6188,7 @@ var generateLoyaltyProgramQuickMethod = ({
6181
6188
  };
6182
6189
  };
6183
6190
  var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
6184
- const txBlock = initTxBlock instanceof TransactionBlock6 ? new SuiKitTxBlock6(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock6();
6191
+ const txBlock = initTxBlock instanceof Transaction6 ? new SuiKitTxBlock6(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock6();
6185
6192
  const normalMethod = generateLoyaltyProgramNormalMethod({
6186
6193
  builder,
6187
6194
  txBlock
@@ -6209,10 +6216,7 @@ var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
6209
6216
  };
6210
6217
 
6211
6218
  // src/builders/sCoinBuilder.ts
6212
- import {
6213
- TransactionBlock as TransactionBlock7,
6214
- SuiTxBlock as SuiKitTxBlock7
6215
- } from "@scallop-io/sui-kit";
6219
+ import { Transaction as Transaction7, SuiTxBlock as SuiKitTxBlock7 } from "@scallop-io/sui-kit";
6216
6220
  var generateSCoinNormalMethod = ({
6217
6221
  builder,
6218
6222
  txBlock
@@ -6273,7 +6277,7 @@ var generateSCoinQuickMethod = ({
6273
6277
  };
6274
6278
  };
6275
6279
  var newSCoinTxBlock = (builder, initTxBlock) => {
6276
- const txBlock = initTxBlock instanceof TransactionBlock7 ? new SuiKitTxBlock7(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock7();
6280
+ const txBlock = initTxBlock instanceof Transaction7 ? new SuiKitTxBlock7(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock7();
6277
6281
  const normalMethod = generateSCoinNormalMethod({
6278
6282
  builder,
6279
6283
  txBlock
@@ -6505,8 +6509,8 @@ var ScallopIndexer = class {
6505
6509
  };
6506
6510
 
6507
6511
  // src/queries/sCoinQuery.ts
6508
- import { bcs as bcs2 } from "@mysten/sui.js/bcs";
6509
- import assert from "assert";
6512
+ import { bcs as bcs2 } from "@mysten/sui/bcs";
6513
+ import assert2 from "assert";
6510
6514
  import BigNumber7 from "bignumber.js";
6511
6515
  var getSCoinTotalSupply = async ({
6512
6516
  utils
@@ -6527,8 +6531,8 @@ var getSCoinTotalSupply = async ({
6527
6531
  if (results && results[0].returnValues) {
6528
6532
  const value = Uint8Array.from(results[0].returnValues[0][0]);
6529
6533
  const type = results[0].returnValues[0][1];
6530
- assert(type === "u64", "Result type is not u64");
6531
- return BigNumber7(bcs2.de(type, value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
6534
+ assert2(type === "u64", "Result type is not u64");
6535
+ return BigNumber7(bcs2.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
6532
6536
  }
6533
6537
  return 0;
6534
6538
  };
@@ -6598,7 +6602,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
6598
6602
  };
6599
6603
 
6600
6604
  // src/models/scallopQuery.ts
6601
- import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui.js/utils";
6605
+ import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
6602
6606
  var ScallopQuery = class {
6603
6607
  constructor(params, instance) {
6604
6608
  this.params = params;
@@ -7086,6 +7090,7 @@ var ScallopQuery = class {
7086
7090
  };
7087
7091
 
7088
7092
  // src/models/scallopBuilder.ts
7093
+ import { SuiClient as SuiClientV0 } from "@mysten/sui.js/client";
7089
7094
  var ScallopBuilder = class {
7090
7095
  constructor(params, instance) {
7091
7096
  this.suiKit = instance?.suiKit ?? new SuiKit5(params);
@@ -7126,6 +7131,9 @@ var ScallopBuilder = class {
7126
7131
  );
7127
7132
  }
7128
7133
  this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
7134
+ this.oldSuiClient = new SuiClientV0({
7135
+ url: this.suiKit.suiInteractor.currentFullNode
7136
+ });
7129
7137
  }
7130
7138
  /**
7131
7139
  * Request the scallop API to initialize data.
@@ -7647,6 +7655,7 @@ var ScallopClient = class {
7647
7655
  false
7648
7656
  );
7649
7657
  const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
7658
+ console.log(stakeMarketCoin, stakeCoinName);
7650
7659
  if (stakeMarketCoin) {
7651
7660
  const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
7652
7661
  await this.utils.mergeSimilarCoins(
@@ -7935,11 +7944,15 @@ var Scallop = class {
7935
7944
  *
7936
7945
  * @return Scallop Builder.
7937
7946
  */
7938
- async createScallopBuilder() {
7947
+ async createScallopBuilder(params) {
7939
7948
  if (!this.address.getAddresses())
7940
7949
  await this.address.read();
7941
- const scallopBuilder = new ScallopBuilder(this.params, {
7942
- query: await this.createScallopQuery()
7950
+ const builderParams = {
7951
+ ...this.params,
7952
+ ...params
7953
+ };
7954
+ const scallopBuilder = new ScallopBuilder(builderParams, {
7955
+ query: await this.createScallopQuery(builderParams)
7943
7956
  });
7944
7957
  return scallopBuilder;
7945
7958
  }
@@ -7949,13 +7962,16 @@ var Scallop = class {
7949
7962
  * @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
7950
7963
  * @return Scallop Client.
7951
7964
  */
7952
- async createScallopClient(walletAddress) {
7965
+ async createScallopClient(params) {
7953
7966
  if (!this.address.getAddresses())
7954
7967
  await this.address.read();
7955
- const scallopClient = new ScallopClient(
7956
- { ...this.params, walletAddress },
7957
- { builder: await this.createScallopBuilder() }
7958
- );
7968
+ const clientParams = {
7969
+ ...this.params,
7970
+ ...params
7971
+ };
7972
+ const scallopClient = new ScallopClient(clientParams, {
7973
+ builder: await this.createScallopBuilder(clientParams)
7974
+ });
7959
7975
  return scallopClient;
7960
7976
  }
7961
7977
  /**
@@ -7963,11 +7979,15 @@ var Scallop = class {
7963
7979
  *
7964
7980
  * @return Scallop Query.
7965
7981
  */
7966
- async createScallopQuery() {
7982
+ async createScallopQuery(params) {
7967
7983
  if (!this.address.getAddresses())
7968
7984
  await this.address.read();
7969
- const scallopQuery = new ScallopQuery(this.params, {
7970
- utils: await this.createScallopUtils()
7985
+ const queryParams = {
7986
+ ...this.params,
7987
+ ...params
7988
+ };
7989
+ const scallopQuery = new ScallopQuery(queryParams, {
7990
+ utils: await this.createScallopUtils(queryParams)
7971
7991
  });
7972
7992
  return scallopQuery;
7973
7993
  }
@@ -7987,12 +8007,18 @@ var Scallop = class {
7987
8007
  *
7988
8008
  * @return Scallop Utils.
7989
8009
  */
7990
- async createScallopUtils() {
8010
+ async createScallopUtils(params) {
7991
8011
  if (!this.address.getAddresses())
7992
8012
  await this.address.read();
7993
- const scallopUtils = new ScallopUtils(this.params, {
7994
- address: this.address
7995
- });
8013
+ const scallopUtils = new ScallopUtils(
8014
+ {
8015
+ ...this.params,
8016
+ ...params
8017
+ },
8018
+ {
8019
+ address: this.address
8020
+ }
8021
+ );
7996
8022
  return scallopUtils;
7997
8023
  }
7998
8024
  };