@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
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
3
  import type { ScallopBuilder } from 'src/models';
4
4
  import type { BorrowIncentiveTxBlock, ScallopTxBlock } from '../types';
@@ -9,4 +9,4 @@ import type { BorrowIncentiveTxBlock, ScallopTxBlock } from '../types';
9
9
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return Scallop borrow incentive txBlock.
11
11
  */
12
- export declare const newBorrowIncentiveTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => BorrowIncentiveTxBlock;
12
+ export declare const newBorrowIncentiveTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => BorrowIncentiveTxBlock;
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
3
  import type { ScallopBuilder } from '../models';
4
4
  import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types';
@@ -9,4 +9,4 @@ import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types'
9
9
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return Scallop core txBlock.
11
11
  */
12
- export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | SuiTxBlockWithSpool) => CoreTxBlock;
12
+ export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSpool) => CoreTxBlock;
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
3
  import type { ScallopBuilder } from '../models';
4
4
  import type { ScallopTxBlock } from '../types';
@@ -9,4 +9,4 @@ import type { ScallopTxBlock } from '../types';
9
9
  * @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return ScallopTxBlock.
11
11
  */
12
- export declare const newScallopTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => ScallopTxBlock;
12
+ export declare const newScallopTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ScallopTxBlock;
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
3
  import { ScallopBuilder } from 'src/models';
4
4
  import { LoyaltyProgramTxBlock, ScallopTxBlock } from 'src/types';
@@ -9,4 +9,4 @@ import { LoyaltyProgramTxBlock, ScallopTxBlock } from 'src/types';
9
9
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return Scallop loyalty program txBlock.
11
11
  */
12
- export declare const newLoyaltyProgramTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => LoyaltyProgramTxBlock;
12
+ export declare const newLoyaltyProgramTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => LoyaltyProgramTxBlock;
@@ -7,5 +7,8 @@ import type { SupportAssetCoins } from '../types';
7
7
  * @param builder - The scallop builder.
8
8
  * @param txBlock - TxBlock created by SuiKit.
9
9
  * @param assetCoinNames - Specific an array of support asset coin name.
10
+ * @param options - The options for update oracles.
10
11
  */
11
- export declare const updateOracles: (builder: ScallopBuilder, txBlock: SuiKitTxBlock, assetCoinNames?: SupportAssetCoins[]) => Promise<void>;
12
+ export declare const updateOracles: (builder: ScallopBuilder, txBlock: SuiKitTxBlock, assetCoinNames?: SupportAssetCoins[], options?: {
13
+ usePythPullModel: boolean;
14
+ }) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { ScallopBuilder } from 'src/models';
2
2
  import { ScallopTxBlock } from 'src/types';
3
- import { SuiTxBlock as SuiKitTxBlock, TransactionBlock } from '@scallop-io/sui-kit';
3
+ import { SuiTxBlock as SuiKitTxBlock, Transaction } from '@scallop-io/sui-kit';
4
4
  import { ReferralTxBlock } from 'src/types/builder/referral';
5
5
  /**
6
6
  * Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
@@ -9,4 +9,4 @@ import { ReferralTxBlock } from 'src/types/builder/referral';
9
9
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return Scallop referral txBlock.
11
11
  */
12
- export declare const newReferralTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => ReferralTxBlock;
12
+ export declare const newReferralTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ReferralTxBlock;
@@ -1,4 +1,4 @@
1
- import { TransactionBlock, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
1
+ import { Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
2
  import { ScallopBuilder } from 'src/models';
3
3
  import { BaseScallopTxBlock, SCoinTxBlock, ScallopTxBlock } from 'src/types';
4
- export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | BaseScallopTxBlock) => SCoinTxBlock;
4
+ export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | BaseScallopTxBlock) => SCoinTxBlock;
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
3
  import type { ScallopBuilder } from '../models';
4
4
  import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types';
@@ -9,4 +9,4 @@ import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types
9
9
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
10
10
  * @return Scallop spool txBlock.
11
11
  */
12
- export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | SuiTxBlockWithSCoin) => SpoolTxBlock;
12
+ export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSCoin) => SpoolTxBlock;
@@ -1,4 +1,4 @@
1
- import { SuiTxBlock, TransactionBlock, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
1
+ import { SuiTxBlock, Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
2
  import { ScallopBuilder } from '../models';
3
3
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
4
4
  import type { ScallopTxBlock, VeScaTxBlock } from 'src/types';
@@ -22,4 +22,4 @@ export declare const requireVeSca: (builder: ScallopBuilder, SuiTxBlock: SuiTxBl
22
22
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
23
23
  * @return Scallop borrow incentive txBlock.
24
24
  */
25
- export declare const newVeScaTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => VeScaTxBlock;
25
+ export declare const newVeScaTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => VeScaTxBlock;
@@ -1,7 +1,7 @@
1
- export declare const API_BASE_URL = "https://sui.apis.scallop.io";
2
- export declare const SDK_API_BASE_URL = "https://sdk.api.scallop.io";
3
- export declare const IS_VE_SCA_TEST = false;
4
- export declare const USE_TEST_ADDRESS = false;
1
+ export declare const API_BASE_URL: "https://sui.apis.scallop.io";
2
+ export declare const SDK_API_BASE_URL: "https://sdk.api.scallop.io";
3
+ export declare const IS_VE_SCA_TEST: boolean;
4
+ export declare const USE_TEST_ADDRESS: boolean;
5
5
  export declare const ADDRESSES_ID: "65fb07c39c845425d71d7b18" | "66f8e7ed9bb9e07fdfb86bbb";
6
6
  export declare const PROTOCOL_OBJECT_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
7
7
  export declare const BORROW_FEE_PROTOCOL_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
@@ -1,4 +1,4 @@
1
1
  export * from './common';
2
2
  export * from './enum';
3
- export * from './vesca';
4
3
  export * from './flashloan';
4
+ export * from './vesca';
@@ -1,5 +1,5 @@
1
1
  export declare const UNLOCK_ROUND_DURATION: number;
2
- export declare const MAX_LOCK_ROUNDS: number;
2
+ export declare const MAX_LOCK_ROUNDS: 1460;
3
3
  export declare const MAX_LOCK_DURATION: number;
4
- export declare const MIN_INITIAL_LOCK_AMOUNT: number;
5
- export declare const MIN_TOP_UP_AMOUNT: number;
4
+ export declare const MIN_INITIAL_LOCK_AMOUNT: 10000000000;
5
+ export declare const MIN_TOP_UP_AMOUNT: 1000000000;
package/dist/index.js CHANGED
@@ -318,13 +318,6 @@ var sCoinIds = {
318
318
  swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
319
319
  };
320
320
 
321
- // src/constants/vesca.ts
322
- var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
323
- var MAX_LOCK_ROUNDS = 1460;
324
- var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
325
- var MIN_INITIAL_LOCK_AMOUNT = 1e10;
326
- var MIN_TOP_UP_AMOUNT = 1e9;
327
-
328
321
  // src/constants/flashloan.ts
329
322
  var FlashLoanFeeObjectMap = {
330
323
  vsui: "0x0069cddee7a5c0b1d34beb5ef0620f978096525f1830b055f38b110f40d73fbb",
@@ -341,6 +334,13 @@ var FlashLoanFeeObjectMap = {
341
334
  wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
342
335
  };
343
336
 
337
+ // src/constants/vesca.ts
338
+ var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
339
+ var MAX_LOCK_ROUNDS = 1460;
340
+ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
341
+ var MIN_INITIAL_LOCK_AMOUNT = 1e10;
342
+ var MIN_TOP_UP_AMOUNT = 1e9;
343
+
344
344
  // src/models/scallop.ts
345
345
  var import_sui_kit16 = require("@scallop-io/sui-kit");
346
346
 
@@ -465,7 +465,7 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
465
465
 
466
466
  // src/utils/query.ts
467
467
  var import_bignumber = __toESM(require("bignumber.js"));
468
- var import_utils = require("@mysten/sui.js/utils");
468
+ var import_utils = require("@mysten/sui/utils");
469
469
  var parseOriginMarketPoolData = (originMarketPoolData) => {
470
470
  return {
471
471
  coinType: (0, import_utils.normalizeStructTag)(originMarketPoolData.type.name),
@@ -1002,21 +1002,40 @@ var ScallopCache = class {
1002
1002
  refetchType
1003
1003
  });
1004
1004
  }
1005
- /**
1006
- * @description Cache protocol config call for 60 seconds.
1007
- * @returns Promise<ProtocolConfig>
1008
- */
1009
- async getProtocolConfig() {
1010
- return await this.queryClient.fetchQuery({
1011
- queryKey: ["getProtocolConfig"],
1012
- queryFn: async () => {
1013
- return await callWithRateLimit(
1014
- this.tokenBucket,
1015
- () => this.client.getProtocolConfig()
1016
- );
1017
- },
1018
- staleTime: 3e4
1019
- });
1005
+ async resolveArgs(txb, args) {
1006
+ return await Promise.all(
1007
+ args.map(async (arg) => {
1008
+ if (typeof arg === "string") {
1009
+ const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
1010
+ if (!objData)
1011
+ return arg;
1012
+ const owner = objData?.owner;
1013
+ if (!owner)
1014
+ return arg;
1015
+ if ("Shared" in owner) {
1016
+ return txb.sharedObjectRef({
1017
+ objectId: objData.objectId,
1018
+ initialSharedVersion: owner.Shared.initial_shared_version,
1019
+ mutable: true
1020
+ });
1021
+ } else {
1022
+ return txb.objectRef({
1023
+ objectId: objData.objectId,
1024
+ version: objData.version,
1025
+ digest: objData.digest
1026
+ });
1027
+ }
1028
+ } else if ("objectId" in arg && "version" in arg && "digest" in arg) {
1029
+ return txb.objectRef({
1030
+ objectId: arg.objectId,
1031
+ version: arg.version,
1032
+ digest: arg.digest
1033
+ });
1034
+ } else {
1035
+ return arg;
1036
+ }
1037
+ })
1038
+ );
1020
1039
  }
1021
1040
  /**
1022
1041
  * @description Provides cache for inspectTxn of the SuiKit.
@@ -1030,20 +1049,8 @@ var ScallopCache = class {
1030
1049
  typeArgs
1031
1050
  }) {
1032
1051
  const txBlock = new import_sui_kit.SuiTxBlock();
1033
- const resolvedArgs = await Promise.all(
1034
- args.map(async (arg) => {
1035
- if (typeof arg === "string") {
1036
- return (await this.queryGetObject(arg, { showContent: true }))?.data;
1037
- }
1038
- return arg;
1039
- })
1040
- );
1052
+ const resolvedArgs = await this.resolveArgs(txBlock, args);
1041
1053
  txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
1042
- const txBytes = await txBlock.txBlock.build({
1043
- client: this.client,
1044
- onlyTransactionKind: true,
1045
- protocolConfig: await this.getProtocolConfig() ?? void 0
1046
- });
1047
1054
  const query = await this.queryClient.fetchQuery({
1048
1055
  queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
1049
1056
  "inspectTxn",
@@ -1054,7 +1061,7 @@ var ScallopCache = class {
1054
1061
  queryFn: async () => {
1055
1062
  return await callWithRateLimit(
1056
1063
  this.tokenBucket,
1057
- () => this.suiKit.inspectTxn(txBytes)
1064
+ () => this.suiKit.inspectTxn(txBlock)
1058
1065
  );
1059
1066
  }
1060
1067
  });
@@ -2275,16 +2282,16 @@ var ScallopAddress = class {
2275
2282
  };
2276
2283
 
2277
2284
  // src/models/scallopClient.ts
2278
- var import_utils25 = require("@mysten/sui.js/utils");
2285
+ var import_utils25 = require("@mysten/sui/utils");
2279
2286
  var import_sui_kit15 = require("@scallop-io/sui-kit");
2280
2287
 
2281
2288
  // src/models/scallopUtils.ts
2282
- var import_utils10 = require("@mysten/sui.js/utils");
2289
+ var import_utils10 = require("@mysten/sui/utils");
2283
2290
  var import_sui_kit4 = require("@scallop-io/sui-kit");
2284
2291
  var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
2285
2292
 
2286
2293
  // src/queries/coreQuery.ts
2287
- var import_utils3 = require("@mysten/sui.js/utils");
2294
+ var import_utils3 = require("@mysten/sui/utils");
2288
2295
  var import_bignumber2 = __toESM(require("bignumber.js"));
2289
2296
 
2290
2297
  // src/queries/supplyLimit.ts
@@ -2939,7 +2946,7 @@ var getFlashLoanFees = async (query, assetNames) => {
2939
2946
  };
2940
2947
 
2941
2948
  // src/queries/spoolQuery.ts
2942
- var import_utils5 = require("@mysten/sui.js/utils");
2949
+ var import_utils5 = require("@mysten/sui/utils");
2943
2950
  var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
2944
2951
  const stakeCoinNames = stakeMarketCoinNames.map(
2945
2952
  (stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
@@ -3335,7 +3342,7 @@ var getStakeRewardPool = async ({
3335
3342
  };
3336
3343
 
3337
3344
  // src/queries/borrowIncentiveQuery.ts
3338
- var import_utils7 = require("@mysten/sui.js/utils");
3345
+ var import_utils7 = require("@mysten/sui/utils");
3339
3346
  var import_bignumber3 = __toESM(require("bignumber.js"));
3340
3347
  var queryBorrowIncentivePools = async (address) => {
3341
3348
  const queryPkgId = address.get("borrowIncentive.query");
@@ -4122,8 +4129,9 @@ var getTotalValueLocked = async (query, indexer = false) => {
4122
4129
  // src/queries/vescaQuery.ts
4123
4130
  var import_bignumber5 = __toESM(require("bignumber.js"));
4124
4131
  var import_sui_kit3 = require("@scallop-io/sui-kit");
4125
- var import_bcs = require("@mysten/sui.js/bcs");
4132
+ var import_bcs = require("@mysten/sui/bcs");
4126
4133
  var import_zod2 = require("zod");
4134
+ var import_assert = __toESM(require("assert"));
4127
4135
  var getVescaKeys = async (utils, ownerAddress) => {
4128
4136
  const owner = ownerAddress || utils.suiKit.currentAddress();
4129
4137
  const veScaObjId = utils.address.get("vesca.object");
@@ -4257,7 +4265,8 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
4257
4265
  if (results && results[1].returnValues) {
4258
4266
  const value = Uint8Array.from(results[1].returnValues[0][0]);
4259
4267
  const type = results[1].returnValues[0][1];
4260
- return import_bcs.bcs.de(type, value);
4268
+ (0, import_assert.default)(type === "u64", "Result type is not u64");
4269
+ return import_bcs.bcs.u64().parse(value);
4261
4270
  }
4262
4271
  return "0";
4263
4272
  };
@@ -4794,25 +4803,27 @@ var ScallopUtils = class {
4794
4803
  };
4795
4804
 
4796
4805
  // src/models/scallopBuilder.ts
4797
- var import_utils24 = require("@mysten/sui.js/utils");
4806
+ var import_utils24 = require("@mysten/sui/utils");
4798
4807
  var import_sui_kit14 = require("@scallop-io/sui-kit");
4799
4808
 
4800
4809
  // src/builders/coreBuilder.ts
4801
- var import_transactions = require("@mysten/sui.js/transactions");
4802
- var import_utils13 = require("@mysten/sui.js/utils");
4810
+ var import_transactions2 = require("@mysten/sui/transactions");
4811
+ var import_utils13 = require("@mysten/sui/utils");
4803
4812
  var import_sui_kit5 = require("@scallop-io/sui-kit");
4804
4813
 
4805
4814
  // src/builders/oracle.ts
4806
- var import_utils12 = require("@mysten/sui.js/utils");
4815
+ var import_utils12 = require("@mysten/sui/utils");
4807
4816
  var import_pyth_sui_js2 = require("@pythnetwork/pyth-sui-js");
4808
- var updateOracles = async (builder, txBlock, assetCoinNames) => {
4817
+ var import_transactions = require("@mysten/sui.js/transactions");
4818
+ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
4819
+ const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
4809
4820
  assetCoinNames = assetCoinNames ?? [
4810
4821
  .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4811
4822
  ];
4812
4823
  const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
4813
- if (rules.includes("pyth")) {
4824
+ if (usePythPullModel && rules.includes("pyth")) {
4814
4825
  const pythClient = new import_pyth_sui_js2.SuiPythClient(
4815
- builder.suiKit.client(),
4826
+ builder.oldSuiClient,
4816
4827
  builder.address.get("core.oracles.pyth.state"),
4817
4828
  builder.address.get("core.oracles.pyth.wormholeState")
4818
4829
  );
@@ -4825,7 +4836,8 @@ var updateOracles = async (builder, txBlock, assetCoinNames) => {
4825
4836
  const pythConnection = new import_pyth_sui_js2.SuiPriceServiceConnection(endpoint);
4826
4837
  const priceUpdateData = await pythConnection.getPriceFeedsUpdateData(priceIds);
4827
4838
  await pythClient.updatePriceFeeds(
4828
- txBlock.txBlock,
4839
+ import_transactions.TransactionBlock.from(txBlock.serialize()),
4840
+ // convert txBlock to TransactionBlock because pyth sdk not support new @mysten/sui yet
4829
4841
  priceUpdateData,
4830
4842
  priceIds
4831
4843
  );
@@ -5006,7 +5018,7 @@ var generateCoreNormalMethod = ({
5006
5018
  obligationKey,
5007
5019
  coreIds.market,
5008
5020
  coreIds.coinDecimalsRegistry,
5009
- amount,
5021
+ txBlock.pure.u64(amount),
5010
5022
  coreIds.xOracle,
5011
5023
  import_utils13.SUI_CLOCK_OBJECT_ID
5012
5024
  ],
@@ -5073,7 +5085,7 @@ var generateCoreNormalMethod = ({
5073
5085
  coreIds.market,
5074
5086
  coreIds.coinDecimalsRegistry,
5075
5087
  borrowReferral,
5076
- amount,
5088
+ txBlock.pure.u64(amount),
5077
5089
  coreIds.xOracle,
5078
5090
  import_utils13.SUI_CLOCK_OBJECT_ID
5079
5091
  ],
@@ -5090,7 +5102,7 @@ var generateCoreNormalMethod = ({
5090
5102
  obligationKey,
5091
5103
  coreIds.market,
5092
5104
  coreIds.coinDecimalsRegistry,
5093
- amount,
5105
+ txBlock.pure.u64(amount),
5094
5106
  coreIds.xOracle,
5095
5107
  import_utils13.SUI_CLOCK_OBJECT_ID
5096
5108
  ],
@@ -5308,7 +5320,7 @@ var generateCoreQuickMethod = ({
5308
5320
  };
5309
5321
  };
5310
5322
  var newCoreTxBlock = (builder, initTxBlock) => {
5311
- const txBlock = initTxBlock instanceof import_transactions.TransactionBlock ? new import_sui_kit5.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit5.SuiTxBlock();
5323
+ const txBlock = initTxBlock instanceof import_transactions2.Transaction ? new import_sui_kit5.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit5.SuiTxBlock();
5312
5324
  const normalMethod = generateCoreNormalMethod({
5313
5325
  builder,
5314
5326
  txBlock
@@ -5336,8 +5348,8 @@ var newCoreTxBlock = (builder, initTxBlock) => {
5336
5348
  };
5337
5349
 
5338
5350
  // src/builders/spoolBuilder.ts
5339
- var import_transactions2 = require("@mysten/sui.js/transactions");
5340
- var import_utils15 = require("@mysten/sui.js/utils");
5351
+ var import_transactions3 = require("@mysten/sui/transactions");
5352
+ var import_utils15 = require("@mysten/sui/utils");
5341
5353
  var import_sui_kit6 = require("@scallop-io/sui-kit");
5342
5354
  var requireStakeAccountIds = async (...params) => {
5343
5355
  const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
@@ -5530,7 +5542,7 @@ var generateSpoolQuickMethod = ({
5530
5542
  };
5531
5543
  };
5532
5544
  var newSpoolTxBlock = (builder, initTxBlock) => {
5533
- const txBlock = initTxBlock instanceof import_transactions2.TransactionBlock ? new import_sui_kit6.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit6.SuiTxBlock();
5545
+ const txBlock = initTxBlock instanceof import_transactions3.Transaction ? new import_sui_kit6.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit6.SuiTxBlock();
5534
5546
  const normalMethod = generateSpoolNormalMethod({
5535
5547
  builder,
5536
5548
  txBlock
@@ -5558,8 +5570,8 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
5558
5570
  };
5559
5571
 
5560
5572
  // src/builders/borrowIncentiveBuilder.ts
5561
- var import_transactions3 = require("@mysten/sui.js/transactions");
5562
- var import_utils17 = require("@mysten/sui.js/utils");
5573
+ var import_transactions4 = require("@mysten/sui/transactions");
5574
+ var import_utils17 = require("@mysten/sui/utils");
5563
5575
  var import_sui_kit7 = require("@scallop-io/sui-kit");
5564
5576
  var requireObligationInfo2 = async (...params) => {
5565
5577
  const [builder, txBlock, obligationId, obligationKey] = params;
@@ -5717,19 +5729,14 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5717
5729
  );
5718
5730
  if (!obligationLocked || unstakeObligationBeforeStake) {
5719
5731
  const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
5720
- if (veScaKey && veScaKey !== bindedVeScaKey) {
5721
- throw new Error(
5722
- "Binded veScaKey is not equal to the provided veScaKey"
5723
- );
5724
- }
5725
- if (bindedVeScaKey) {
5732
+ if (veScaKey && veScaKey !== bindedVeScaKey || !bindedVeScaKey) {
5733
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
5734
+ } else {
5726
5735
  txBlock.stakeObligationWithVesca(
5727
5736
  obligationArg,
5728
5737
  obligationKeyArg,
5729
5738
  bindedVeScaKey
5730
5739
  );
5731
- } else {
5732
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
5733
5740
  }
5734
5741
  }
5735
5742
  },
@@ -5765,7 +5772,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5765
5772
  };
5766
5773
  };
5767
5774
  var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
5768
- const txBlock = initTxBlock instanceof import_transactions3.TransactionBlock ? new import_sui_kit7.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit7.SuiTxBlock();
5775
+ const txBlock = initTxBlock instanceof import_transactions4.Transaction ? new import_sui_kit7.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit7.SuiTxBlock();
5769
5776
  const normalMethod = generateBorrowIncentiveNormalMethod({
5770
5777
  builder,
5771
5778
  txBlock
@@ -6041,7 +6048,7 @@ var generateQuickVeScaMethod = ({
6041
6048
  };
6042
6049
  };
6043
6050
  var newVeScaTxBlock = (builder, initTxBlock) => {
6044
- const txBlock = initTxBlock instanceof import_sui_kit8.TransactionBlock ? new import_sui_kit8.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit8.SuiTxBlock();
6051
+ const txBlock = initTxBlock instanceof import_sui_kit8.Transaction ? new import_sui_kit8.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit8.SuiTxBlock();
6045
6052
  const normalMethod = generateNormalVeScaMethod({
6046
6053
  builder,
6047
6054
  txBlock
@@ -6091,7 +6098,7 @@ var generateReferralNormalMethod = ({
6091
6098
  `${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
6092
6099
  [
6093
6100
  referralIds.referralBindings,
6094
- txBlock.pure(veScaKeyId),
6101
+ txBlock.pure.id(veScaKeyId),
6095
6102
  veScaTable,
6096
6103
  import_sui_kit9.SUI_CLOCK_OBJECT_ID
6097
6104
  ],
@@ -6175,7 +6182,7 @@ var generateReferralQuickMethod = ({
6175
6182
  };
6176
6183
  };
6177
6184
  var newReferralTxBlock = (builder, initTxBlock) => {
6178
- const txBlock = initTxBlock instanceof import_sui_kit9.TransactionBlock ? new import_sui_kit9.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit9.SuiTxBlock();
6185
+ const txBlock = initTxBlock instanceof import_sui_kit9.Transaction ? new import_sui_kit9.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit9.SuiTxBlock();
6179
6186
  const normalMethod = generateReferralNormalMethod({
6180
6187
  builder,
6181
6188
  txBlock
@@ -6203,7 +6210,7 @@ var newReferralTxBlock = (builder, initTxBlock) => {
6203
6210
  };
6204
6211
 
6205
6212
  // src/builders/loyaltyProgramBuilder.ts
6206
- var import_transactions4 = require("@mysten/sui.js/transactions");
6213
+ var import_transactions5 = require("@mysten/sui/transactions");
6207
6214
  var import_sui_kit10 = require("@scallop-io/sui-kit");
6208
6215
  var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
6209
6216
  const loyaltyProgramIds = {
@@ -6244,7 +6251,7 @@ var generateLoyaltyProgramQuickMethod = ({
6244
6251
  };
6245
6252
  };
6246
6253
  var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
6247
- const txBlock = initTxBlock instanceof import_transactions4.TransactionBlock ? new import_sui_kit10.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit10.SuiTxBlock();
6254
+ const txBlock = initTxBlock instanceof import_transactions5.Transaction ? new import_sui_kit10.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit10.SuiTxBlock();
6248
6255
  const normalMethod = generateLoyaltyProgramNormalMethod({
6249
6256
  builder,
6250
6257
  txBlock
@@ -6333,7 +6340,7 @@ var generateSCoinQuickMethod = ({
6333
6340
  };
6334
6341
  };
6335
6342
  var newSCoinTxBlock = (builder, initTxBlock) => {
6336
- const txBlock = initTxBlock instanceof import_sui_kit11.TransactionBlock ? new import_sui_kit11.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit11.SuiTxBlock();
6343
+ const txBlock = initTxBlock instanceof import_sui_kit11.Transaction ? new import_sui_kit11.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit11.SuiTxBlock();
6337
6344
  const normalMethod = generateSCoinNormalMethod({
6338
6345
  builder,
6339
6346
  txBlock
@@ -6565,8 +6572,8 @@ var ScallopIndexer = class {
6565
6572
  };
6566
6573
 
6567
6574
  // src/queries/sCoinQuery.ts
6568
- var import_bcs2 = require("@mysten/sui.js/bcs");
6569
- var import_assert = __toESM(require("assert"));
6575
+ var import_bcs2 = require("@mysten/sui/bcs");
6576
+ var import_assert2 = __toESM(require("assert"));
6570
6577
  var import_bignumber7 = __toESM(require("bignumber.js"));
6571
6578
  var getSCoinTotalSupply = async ({
6572
6579
  utils
@@ -6587,8 +6594,8 @@ var getSCoinTotalSupply = async ({
6587
6594
  if (results && results[0].returnValues) {
6588
6595
  const value = Uint8Array.from(results[0].returnValues[0][0]);
6589
6596
  const type = results[0].returnValues[0][1];
6590
- (0, import_assert.default)(type === "u64", "Result type is not u64");
6591
- return (0, import_bignumber7.default)(import_bcs2.bcs.de(type, value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
6597
+ (0, import_assert2.default)(type === "u64", "Result type is not u64");
6598
+ return (0, import_bignumber7.default)(import_bcs2.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
6592
6599
  }
6593
6600
  return 0;
6594
6601
  };
@@ -6658,7 +6665,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
6658
6665
  };
6659
6666
 
6660
6667
  // src/models/scallopQuery.ts
6661
- var import_utils23 = require("@mysten/sui.js/utils");
6668
+ var import_utils23 = require("@mysten/sui/utils");
6662
6669
  var ScallopQuery = class {
6663
6670
  constructor(params, instance) {
6664
6671
  this.params = params;
@@ -7146,6 +7153,7 @@ var ScallopQuery = class {
7146
7153
  };
7147
7154
 
7148
7155
  // src/models/scallopBuilder.ts
7156
+ var import_client = require("@mysten/sui.js/client");
7149
7157
  var ScallopBuilder = class {
7150
7158
  constructor(params, instance) {
7151
7159
  this.suiKit = instance?.suiKit ?? new import_sui_kit14.SuiKit(params);
@@ -7186,6 +7194,9 @@ var ScallopBuilder = class {
7186
7194
  );
7187
7195
  }
7188
7196
  this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
7197
+ this.oldSuiClient = new import_client.SuiClient({
7198
+ url: this.suiKit.suiInteractor.currentFullNode
7199
+ });
7189
7200
  }
7190
7201
  /**
7191
7202
  * Request the scallop API to initialize data.
@@ -7707,6 +7718,7 @@ var ScallopClient = class {
7707
7718
  false
7708
7719
  );
7709
7720
  const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
7721
+ console.log(stakeMarketCoin, stakeCoinName);
7710
7722
  if (stakeMarketCoin) {
7711
7723
  const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
7712
7724
  await this.utils.mergeSimilarCoins(
@@ -7995,11 +8007,15 @@ var Scallop = class {
7995
8007
  *
7996
8008
  * @return Scallop Builder.
7997
8009
  */
7998
- async createScallopBuilder() {
8010
+ async createScallopBuilder(params) {
7999
8011
  if (!this.address.getAddresses())
8000
8012
  await this.address.read();
8001
- const scallopBuilder = new ScallopBuilder(this.params, {
8002
- query: await this.createScallopQuery()
8013
+ const builderParams = {
8014
+ ...this.params,
8015
+ ...params
8016
+ };
8017
+ const scallopBuilder = new ScallopBuilder(builderParams, {
8018
+ query: await this.createScallopQuery(builderParams)
8003
8019
  });
8004
8020
  return scallopBuilder;
8005
8021
  }
@@ -8009,13 +8025,16 @@ var Scallop = class {
8009
8025
  * @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.
8010
8026
  * @return Scallop Client.
8011
8027
  */
8012
- async createScallopClient(walletAddress) {
8028
+ async createScallopClient(params) {
8013
8029
  if (!this.address.getAddresses())
8014
8030
  await this.address.read();
8015
- const scallopClient = new ScallopClient(
8016
- { ...this.params, walletAddress },
8017
- { builder: await this.createScallopBuilder() }
8018
- );
8031
+ const clientParams = {
8032
+ ...this.params,
8033
+ ...params
8034
+ };
8035
+ const scallopClient = new ScallopClient(clientParams, {
8036
+ builder: await this.createScallopBuilder(clientParams)
8037
+ });
8019
8038
  return scallopClient;
8020
8039
  }
8021
8040
  /**
@@ -8023,11 +8042,15 @@ var Scallop = class {
8023
8042
  *
8024
8043
  * @return Scallop Query.
8025
8044
  */
8026
- async createScallopQuery() {
8045
+ async createScallopQuery(params) {
8027
8046
  if (!this.address.getAddresses())
8028
8047
  await this.address.read();
8029
- const scallopQuery = new ScallopQuery(this.params, {
8030
- utils: await this.createScallopUtils()
8048
+ const queryParams = {
8049
+ ...this.params,
8050
+ ...params
8051
+ };
8052
+ const scallopQuery = new ScallopQuery(queryParams, {
8053
+ utils: await this.createScallopUtils(queryParams)
8031
8054
  });
8032
8055
  return scallopQuery;
8033
8056
  }
@@ -8047,12 +8070,18 @@ var Scallop = class {
8047
8070
  *
8048
8071
  * @return Scallop Utils.
8049
8072
  */
8050
- async createScallopUtils() {
8073
+ async createScallopUtils(params) {
8051
8074
  if (!this.address.getAddresses())
8052
8075
  await this.address.read();
8053
- const scallopUtils = new ScallopUtils(this.params, {
8054
- address: this.address
8055
- });
8076
+ const scallopUtils = new ScallopUtils(
8077
+ {
8078
+ ...this.params,
8079
+ ...params
8080
+ },
8081
+ {
8082
+ address: this.address
8083
+ }
8084
+ );
8056
8085
  return scallopUtils;
8057
8086
  }
8058
8087
  };