@scallop-io/sui-scallop-sdk 0.47.1 → 0.47.3

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.mjs CHANGED
@@ -3421,7 +3421,7 @@ var getBindedObligationId = async ({
3421
3421
  };
3422
3422
  var getBindedVeScaKey = async ({
3423
3423
  address
3424
- }, obliationId) => {
3424
+ }, obligationId) => {
3425
3425
  const borrowIncentiveObjectId = address.get("borrowIncentive.object");
3426
3426
  const incentiveAccountsId = address.get("borrowIncentive.incentiveAccounts");
3427
3427
  const corePkg = address.get("core.object");
@@ -3438,7 +3438,7 @@ var getBindedVeScaKey = async ({
3438
3438
  parentId: incentiveAccountsTableId,
3439
3439
  name: {
3440
3440
  type: `${borrowIncentiveObjectId}::typed_id::TypedID<${corePkg}::obligation::Obligation>`,
3441
- value: obliationId
3441
+ value: obligationId
3442
3442
  }
3443
3443
  });
3444
3444
  if (bindedIncentiveAcc?.data?.content?.dataType !== "moveObject")
@@ -4734,12 +4734,13 @@ import {
4734
4734
  SuiPythClient,
4735
4735
  SuiPriceServiceConnection as SuiPriceServiceConnection2
4736
4736
  } from "@pythnetwork/pyth-sui-js";
4737
- var updateOracles = async (builder, txBlock, assetCoinNames) => {
4737
+ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
4738
+ const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
4738
4739
  assetCoinNames = assetCoinNames ?? [
4739
4740
  .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4740
4741
  ];
4741
4742
  const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
4742
- if (rules.includes("pyth")) {
4743
+ if (usePythPullModel && rules.includes("pyth")) {
4743
4744
  const pythClient = new SuiPythClient(
4744
4745
  builder.suiKit.client(),
4745
4746
  builder.address.get("core.oracles.pyth.state"),
@@ -5487,15 +5488,240 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
5487
5488
  };
5488
5489
 
5489
5490
  // src/builders/borrowIncentiveBuilder.ts
5490
- import { TransactionBlock as TransactionBlock4 } from "@mysten/sui.js/transactions";
5491
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID6 } from "@mysten/sui.js/utils";
5492
- import { SuiTxBlock as SuiKitTxBlock4 } from "@scallop-io/sui-kit";
5491
+ import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
5492
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui.js/utils";
5493
+ import { SuiTxBlock as SuiKitTxBlock3 } from "@scallop-io/sui-kit";
5494
+ var requireObligationInfo2 = async (...params) => {
5495
+ const [builder, txBlock, obligationId, obligationKey] = params;
5496
+ if (params.length === 4 && obligationId && obligationKey && typeof obligationId === "string") {
5497
+ const obligationLocked = await getObligationLocked(
5498
+ builder.cache,
5499
+ obligationId
5500
+ );
5501
+ return { obligationId, obligationKey, obligationLocked };
5502
+ }
5503
+ const sender = requireSender(txBlock);
5504
+ const obligations = await getObligations(builder, sender);
5505
+ if (obligations.length === 0) {
5506
+ throw new Error(`No obligation found for sender ${sender}`);
5507
+ }
5508
+ const selectedObligation = obligations.find(
5509
+ (obligation) => obligation.id === obligationId || obligation.keyId === obligationKey
5510
+ ) ?? obligations[0];
5511
+ return {
5512
+ obligationId: selectedObligation.id,
5513
+ obligationKey: selectedObligation.keyId,
5514
+ obligationLocked: selectedObligation.locked
5515
+ };
5516
+ };
5517
+ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
5518
+ const borrowIncentiveIds = {
5519
+ borrowIncentivePkg: builder.address.get("borrowIncentive.id"),
5520
+ query: builder.address.get("borrowIncentive.query"),
5521
+ config: builder.address.get("borrowIncentive.config"),
5522
+ incentivePools: builder.address.get("borrowIncentive.incentivePools"),
5523
+ incentiveAccounts: builder.address.get(
5524
+ "borrowIncentive.incentiveAccounts"
5525
+ ),
5526
+ obligationAccessStore: builder.address.get("core.obligationAccessStore")
5527
+ };
5528
+ const veScaIds = {
5529
+ table: builder.address.get("vesca.table"),
5530
+ treasury: builder.address.get("vesca.treasury"),
5531
+ config: builder.address.get("vesca.config")
5532
+ };
5533
+ return {
5534
+ stakeObligation: (obligationId, obligationKey) => {
5535
+ txBlock.moveCall(
5536
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
5537
+ [
5538
+ borrowIncentiveIds.config,
5539
+ borrowIncentiveIds.incentivePools,
5540
+ borrowIncentiveIds.incentiveAccounts,
5541
+ obligationKey,
5542
+ obligationId,
5543
+ borrowIncentiveIds.obligationAccessStore,
5544
+ SUI_CLOCK_OBJECT_ID5
5545
+ ]
5546
+ );
5547
+ },
5548
+ stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
5549
+ txBlock.moveCall(
5550
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
5551
+ [
5552
+ borrowIncentiveIds.config,
5553
+ borrowIncentiveIds.incentivePools,
5554
+ borrowIncentiveIds.incentiveAccounts,
5555
+ obligationKey,
5556
+ obligationId,
5557
+ borrowIncentiveIds.obligationAccessStore,
5558
+ veScaIds.config,
5559
+ veScaIds.treasury,
5560
+ veScaIds.table,
5561
+ veScaKey,
5562
+ SUI_CLOCK_OBJECT_ID5
5563
+ ],
5564
+ []
5565
+ );
5566
+ },
5567
+ unstakeObligation: (obligationId, obligationKey) => {
5568
+ txBlock.moveCall(
5569
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
5570
+ [
5571
+ borrowIncentiveIds.config,
5572
+ borrowIncentiveIds.incentivePools,
5573
+ borrowIncentiveIds.incentiveAccounts,
5574
+ obligationKey,
5575
+ obligationId,
5576
+ SUI_CLOCK_OBJECT_ID5
5577
+ ]
5578
+ );
5579
+ },
5580
+ claimBorrowIncentive: (obligationId, obligationKey, coinName, rewardCoinName) => {
5581
+ const rewardCoinNames = builder.utils.getBorrowIncentiveRewardCoinName(coinName);
5582
+ if (rewardCoinNames.includes(rewardCoinName) === false) {
5583
+ throw new Error(`Invalid reward coin name ${rewardCoinName}`);
5584
+ }
5585
+ const rewardType = builder.utils.parseCoinType(rewardCoinName);
5586
+ return txBlock.moveCall(
5587
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
5588
+ [
5589
+ borrowIncentiveIds.config,
5590
+ borrowIncentiveIds.incentivePools,
5591
+ borrowIncentiveIds.incentiveAccounts,
5592
+ obligationKey,
5593
+ obligationId,
5594
+ SUI_CLOCK_OBJECT_ID5
5595
+ ],
5596
+ [rewardType]
5597
+ );
5598
+ },
5599
+ deactivateBoost: (obligation, veScaKey) => {
5600
+ return txBlock.moveCall(
5601
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
5602
+ [
5603
+ borrowIncentiveIds.config,
5604
+ borrowIncentiveIds.incentivePools,
5605
+ borrowIncentiveIds.incentiveAccounts,
5606
+ obligation,
5607
+ veScaKey,
5608
+ SUI_CLOCK_OBJECT_ID5
5609
+ ]
5610
+ );
5611
+ }
5612
+ };
5613
+ };
5614
+ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5615
+ return {
5616
+ stakeObligationQuick: async (obligation, obligationKey) => {
5617
+ const {
5618
+ obligationId: obligationArg,
5619
+ obligationKey: obligationKeyArg,
5620
+ obligationLocked
5621
+ } = await requireObligationInfo2(
5622
+ builder,
5623
+ txBlock,
5624
+ obligation,
5625
+ obligationKey
5626
+ );
5627
+ const unstakeObligationBeforeStake = !!txBlock.txBlock.blockData.transactions.find(
5628
+ (txn) => txn.kind === "MoveCall" && (txn.target === `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` || txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`)
5629
+ );
5630
+ if (!obligationLocked || unstakeObligationBeforeStake) {
5631
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
5632
+ }
5633
+ },
5634
+ stakeObligationWithVeScaQuick: async (obligation, obligationKey, veScaKey) => {
5635
+ const {
5636
+ obligationId: obligationArg,
5637
+ obligationKey: obligationKeyArg,
5638
+ obligationLocked
5639
+ } = await requireObligationInfo2(
5640
+ builder,
5641
+ txBlock,
5642
+ obligation,
5643
+ obligationKey
5644
+ );
5645
+ const unstakeObligationBeforeStake = !!txBlock.txBlock.blockData.transactions.find(
5646
+ (txn) => txn.kind === "MoveCall" && (txn.target === `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` || txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`)
5647
+ );
5648
+ if (!obligationLocked || unstakeObligationBeforeStake) {
5649
+ const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
5650
+ if (veScaKey && veScaKey !== bindedVeScaKey || !bindedVeScaKey) {
5651
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
5652
+ } else {
5653
+ txBlock.stakeObligationWithVesca(
5654
+ obligationArg,
5655
+ obligationKeyArg,
5656
+ bindedVeScaKey
5657
+ );
5658
+ }
5659
+ }
5660
+ },
5661
+ unstakeObligationQuick: async (obligation, obligationKey) => {
5662
+ const {
5663
+ obligationId: obligationArg,
5664
+ obligationKey: obligationKeyArg,
5665
+ obligationLocked
5666
+ } = await requireObligationInfo2(
5667
+ builder,
5668
+ txBlock,
5669
+ obligation,
5670
+ obligationKey
5671
+ );
5672
+ if (obligationLocked) {
5673
+ txBlock.unstakeObligation(obligationArg, obligationKeyArg);
5674
+ }
5675
+ },
5676
+ claimBorrowIncentiveQuick: async (coinName, rewardCoinName, obligation, obligationKey) => {
5677
+ const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo2(
5678
+ builder,
5679
+ txBlock,
5680
+ obligation,
5681
+ obligationKey
5682
+ );
5683
+ return txBlock.claimBorrowIncentive(
5684
+ obligationArg,
5685
+ obligationKeyArg,
5686
+ coinName,
5687
+ rewardCoinName
5688
+ );
5689
+ }
5690
+ };
5691
+ };
5692
+ var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
5693
+ const txBlock = initTxBlock instanceof TransactionBlock3 ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
5694
+ const normalMethod = generateBorrowIncentiveNormalMethod({
5695
+ builder,
5696
+ txBlock
5697
+ });
5698
+ const normalTxBlock = new Proxy(txBlock, {
5699
+ get: (target, prop) => {
5700
+ if (prop in normalMethod) {
5701
+ return Reflect.get(normalMethod, prop);
5702
+ }
5703
+ return Reflect.get(target, prop);
5704
+ }
5705
+ });
5706
+ const quickMethod = generateBorrowIncentiveQuickMethod({
5707
+ builder,
5708
+ txBlock: normalTxBlock
5709
+ });
5710
+ return new Proxy(normalTxBlock, {
5711
+ get: (target, prop) => {
5712
+ if (prop in quickMethod) {
5713
+ return Reflect.get(quickMethod, prop);
5714
+ }
5715
+ return Reflect.get(target, prop);
5716
+ }
5717
+ });
5718
+ };
5493
5719
 
5494
5720
  // src/builders/vescaBuilder.ts
5495
5721
  import {
5496
- SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5,
5497
- TransactionBlock as TransactionBlock3,
5498
- SuiTxBlock as SuiKitTxBlock3
5722
+ SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID6,
5723
+ TransactionBlock as TransactionBlock4,
5724
+ SuiTxBlock as SuiKitTxBlock4
5499
5725
  } from "@scallop-io/sui-kit";
5500
5726
  var requireVeSca = async (...params) => {
5501
5727
  const [builder, txBlock, veScaKey] = params;
@@ -5511,7 +5737,7 @@ var requireVeSca = async (...params) => {
5511
5737
  if (veScas.length === 0) {
5512
5738
  return void 0;
5513
5739
  }
5514
- return veScas[0];
5740
+ return veScaKey ? veScas.find(({ keyId }) => veScaKey === keyId) : veScas[0];
5515
5741
  };
5516
5742
  var generateNormalVeScaMethod = ({
5517
5743
  builder,
@@ -5533,7 +5759,7 @@ var generateNormalVeScaMethod = ({
5533
5759
  veScaIds.treasury,
5534
5760
  scaCoin,
5535
5761
  unlockAtInSecondTimestamp,
5536
- SUI_CLOCK_OBJECT_ID5
5762
+ SUI_CLOCK_OBJECT_ID6
5537
5763
  ],
5538
5764
  []
5539
5765
  );
@@ -5547,7 +5773,7 @@ var generateNormalVeScaMethod = ({
5547
5773
  veScaIds.table,
5548
5774
  veScaIds.treasury,
5549
5775
  newUnlockAtInSecondTimestamp,
5550
- SUI_CLOCK_OBJECT_ID5
5776
+ SUI_CLOCK_OBJECT_ID6
5551
5777
  ],
5552
5778
  []
5553
5779
  );
@@ -5561,7 +5787,7 @@ var generateNormalVeScaMethod = ({
5561
5787
  veScaIds.table,
5562
5788
  veScaIds.treasury,
5563
5789
  scaCoin,
5564
- SUI_CLOCK_OBJECT_ID5
5790
+ SUI_CLOCK_OBJECT_ID6
5565
5791
  ],
5566
5792
  []
5567
5793
  );
@@ -5576,7 +5802,7 @@ var generateNormalVeScaMethod = ({
5576
5802
  veScaIds.treasury,
5577
5803
  scaCoin,
5578
5804
  newUnlockAtInSecondTimestamp,
5579
- SUI_CLOCK_OBJECT_ID5
5805
+ SUI_CLOCK_OBJECT_ID6
5580
5806
  ],
5581
5807
  []
5582
5808
  );
@@ -5589,7 +5815,7 @@ var generateNormalVeScaMethod = ({
5589
5815
  veScaKey,
5590
5816
  veScaIds.table,
5591
5817
  veScaIds.treasury,
5592
- SUI_CLOCK_OBJECT_ID5
5818
+ SUI_CLOCK_OBJECT_ID6
5593
5819
  ],
5594
5820
  []
5595
5821
  );
@@ -5744,7 +5970,7 @@ var generateQuickVeScaMethod = ({
5744
5970
  };
5745
5971
  };
5746
5972
  var newVeScaTxBlock = (builder, initTxBlock) => {
5747
- const txBlock = initTxBlock instanceof TransactionBlock3 ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
5973
+ const txBlock = initTxBlock instanceof TransactionBlock4 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
5748
5974
  const normalMethod = generateNormalVeScaMethod({
5749
5975
  builder,
5750
5976
  txBlock
@@ -5771,241 +5997,6 @@ var newVeScaTxBlock = (builder, initTxBlock) => {
5771
5997
  });
5772
5998
  };
5773
5999
 
5774
- // src/builders/borrowIncentiveBuilder.ts
5775
- var requireObligationInfo2 = async (...params) => {
5776
- const [builder, txBlock, obligationId, obligationKey] = params;
5777
- if (params.length === 4 && obligationId && obligationKey && typeof obligationId === "string") {
5778
- const obligationLocked = await getObligationLocked(
5779
- builder.cache,
5780
- obligationId
5781
- );
5782
- return { obligationId, obligationKey, obligationLocked };
5783
- }
5784
- const sender = requireSender(txBlock);
5785
- const obligations = await getObligations(builder, sender);
5786
- if (obligations.length === 0) {
5787
- throw new Error(`No obligation found for sender ${sender}`);
5788
- }
5789
- const selectedObligation = obligations.find(
5790
- (obligation) => obligation.id === obligationId || obligation.keyId === obligationKey
5791
- ) ?? obligations[0];
5792
- return {
5793
- obligationId: selectedObligation.id,
5794
- obligationKey: selectedObligation.keyId,
5795
- obligationLocked: selectedObligation.locked
5796
- };
5797
- };
5798
- var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
5799
- const borrowIncentiveIds = {
5800
- borrowIncentivePkg: builder.address.get("borrowIncentive.id"),
5801
- query: builder.address.get("borrowIncentive.query"),
5802
- config: builder.address.get("borrowIncentive.config"),
5803
- incentivePools: builder.address.get("borrowIncentive.incentivePools"),
5804
- incentiveAccounts: builder.address.get(
5805
- "borrowIncentive.incentiveAccounts"
5806
- ),
5807
- obligationAccessStore: builder.address.get("core.obligationAccessStore")
5808
- };
5809
- const veScaIds = {
5810
- table: builder.address.get("vesca.table"),
5811
- treasury: builder.address.get("vesca.treasury"),
5812
- config: builder.address.get("vesca.config")
5813
- };
5814
- return {
5815
- stakeObligation: (obligationId, obligationKey) => {
5816
- txBlock.moveCall(
5817
- `${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
5818
- [
5819
- borrowIncentiveIds.config,
5820
- borrowIncentiveIds.incentivePools,
5821
- borrowIncentiveIds.incentiveAccounts,
5822
- obligationKey,
5823
- obligationId,
5824
- borrowIncentiveIds.obligationAccessStore,
5825
- SUI_CLOCK_OBJECT_ID6
5826
- ]
5827
- );
5828
- },
5829
- stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
5830
- txBlock.moveCall(
5831
- `${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
5832
- [
5833
- borrowIncentiveIds.config,
5834
- borrowIncentiveIds.incentivePools,
5835
- borrowIncentiveIds.incentiveAccounts,
5836
- obligationKey,
5837
- obligationId,
5838
- borrowIncentiveIds.obligationAccessStore,
5839
- veScaIds.config,
5840
- veScaIds.treasury,
5841
- veScaIds.table,
5842
- veScaKey,
5843
- SUI_CLOCK_OBJECT_ID6
5844
- ],
5845
- []
5846
- );
5847
- },
5848
- unstakeObligation: (obligationId, obligationKey) => {
5849
- txBlock.moveCall(
5850
- `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
5851
- [
5852
- borrowIncentiveIds.config,
5853
- borrowIncentiveIds.incentivePools,
5854
- borrowIncentiveIds.incentiveAccounts,
5855
- obligationKey,
5856
- obligationId,
5857
- SUI_CLOCK_OBJECT_ID6
5858
- ]
5859
- );
5860
- },
5861
- claimBorrowIncentive: (obligationId, obligationKey, coinName, rewardCoinName) => {
5862
- const rewardCoinNames = builder.utils.getBorrowIncentiveRewardCoinName(coinName);
5863
- if (rewardCoinNames.includes(rewardCoinName) === false) {
5864
- throw new Error(`Invalid reward coin name ${rewardCoinName}`);
5865
- }
5866
- const rewardType = builder.utils.parseCoinType(rewardCoinName);
5867
- return txBlock.moveCall(
5868
- `${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
5869
- [
5870
- borrowIncentiveIds.config,
5871
- borrowIncentiveIds.incentivePools,
5872
- borrowIncentiveIds.incentiveAccounts,
5873
- obligationKey,
5874
- obligationId,
5875
- SUI_CLOCK_OBJECT_ID6
5876
- ],
5877
- [rewardType]
5878
- );
5879
- },
5880
- deactivateBoost: (obligation, veScaKey) => {
5881
- return txBlock.moveCall(
5882
- `${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
5883
- [
5884
- borrowIncentiveIds.config,
5885
- borrowIncentiveIds.incentivePools,
5886
- borrowIncentiveIds.incentiveAccounts,
5887
- obligation,
5888
- veScaKey,
5889
- SUI_CLOCK_OBJECT_ID6
5890
- ]
5891
- );
5892
- }
5893
- };
5894
- };
5895
- var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
5896
- return {
5897
- stakeObligationQuick: async (obligation, obligationKey) => {
5898
- const {
5899
- obligationId: obligationArg,
5900
- obligationKey: obligationKeyArg,
5901
- obligationLocked
5902
- } = await requireObligationInfo2(
5903
- builder,
5904
- txBlock,
5905
- obligation,
5906
- obligationKey
5907
- );
5908
- const unstakeObligationBeforeStake = !!txBlock.txBlock.blockData.transactions.find(
5909
- (txn) => txn.kind === "MoveCall" && (txn.target === `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` || txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`)
5910
- );
5911
- if (!obligationLocked || unstakeObligationBeforeStake) {
5912
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
5913
- }
5914
- },
5915
- stakeObligationWithVeScaQuick: async (obligation, obligationKey, veScaKey) => {
5916
- const {
5917
- obligationId: obligationArg,
5918
- obligationKey: obligationKeyArg,
5919
- obligationLocked
5920
- } = await requireObligationInfo2(
5921
- builder,
5922
- txBlock,
5923
- obligation,
5924
- obligationKey
5925
- );
5926
- const unstakeObligationBeforeStake = !!txBlock.txBlock.blockData.transactions.find(
5927
- (txn) => txn.kind === "MoveCall" && (txn.target === `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` || txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`)
5928
- );
5929
- if (!obligationLocked || unstakeObligationBeforeStake) {
5930
- const veSca = await requireVeSca(builder, txBlock, veScaKey);
5931
- if (veSca) {
5932
- const bindedObligationId = await getBindedObligationId(
5933
- builder,
5934
- veSca.keyId
5935
- );
5936
- if ((!bindedObligationId || bindedObligationId === obligationArg) && veSca.currentVeScaBalance > 0) {
5937
- txBlock.stakeObligationWithVesca(
5938
- obligationArg,
5939
- obligationKeyArg,
5940
- veSca.keyId
5941
- );
5942
- } else {
5943
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
5944
- }
5945
- } else {
5946
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
5947
- }
5948
- }
5949
- },
5950
- unstakeObligationQuick: async (obligation, obligationKey) => {
5951
- const {
5952
- obligationId: obligationArg,
5953
- obligationKey: obligationKeyArg,
5954
- obligationLocked
5955
- } = await requireObligationInfo2(
5956
- builder,
5957
- txBlock,
5958
- obligation,
5959
- obligationKey
5960
- );
5961
- if (obligationLocked) {
5962
- txBlock.unstakeObligation(obligationArg, obligationKeyArg);
5963
- }
5964
- },
5965
- claimBorrowIncentiveQuick: async (coinName, rewardCoinName, obligation, obligationKey) => {
5966
- const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo2(
5967
- builder,
5968
- txBlock,
5969
- obligation,
5970
- obligationKey
5971
- );
5972
- return txBlock.claimBorrowIncentive(
5973
- obligationArg,
5974
- obligationKeyArg,
5975
- coinName,
5976
- rewardCoinName
5977
- );
5978
- }
5979
- };
5980
- };
5981
- var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
5982
- const txBlock = initTxBlock instanceof TransactionBlock4 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
5983
- const normalMethod = generateBorrowIncentiveNormalMethod({
5984
- builder,
5985
- txBlock
5986
- });
5987
- const normalTxBlock = new Proxy(txBlock, {
5988
- get: (target, prop) => {
5989
- if (prop in normalMethod) {
5990
- return Reflect.get(normalMethod, prop);
5991
- }
5992
- return Reflect.get(target, prop);
5993
- }
5994
- });
5995
- const quickMethod = generateBorrowIncentiveQuickMethod({
5996
- builder,
5997
- txBlock: normalTxBlock
5998
- });
5999
- return new Proxy(normalTxBlock, {
6000
- get: (target, prop) => {
6001
- if (prop in quickMethod) {
6002
- return Reflect.get(quickMethod, prop);
6003
- }
6004
- return Reflect.get(target, prop);
6005
- }
6006
- });
6007
- };
6008
-
6009
6000
  // src/builders/referralBuilder.ts
6010
6001
  import {
6011
6002
  SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID7,
@@ -7940,11 +7931,15 @@ var Scallop = class {
7940
7931
  *
7941
7932
  * @return Scallop Builder.
7942
7933
  */
7943
- async createScallopBuilder() {
7934
+ async createScallopBuilder(params) {
7944
7935
  if (!this.address.getAddresses())
7945
7936
  await this.address.read();
7946
- const scallopBuilder = new ScallopBuilder(this.params, {
7947
- query: await this.createScallopQuery()
7937
+ const builderParams = {
7938
+ ...this.params,
7939
+ ...params
7940
+ };
7941
+ const scallopBuilder = new ScallopBuilder(builderParams, {
7942
+ query: await this.createScallopQuery(builderParams)
7948
7943
  });
7949
7944
  return scallopBuilder;
7950
7945
  }
@@ -7954,13 +7949,16 @@ var Scallop = class {
7954
7949
  * @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.
7955
7950
  * @return Scallop Client.
7956
7951
  */
7957
- async createScallopClient(walletAddress) {
7952
+ async createScallopClient(params) {
7958
7953
  if (!this.address.getAddresses())
7959
7954
  await this.address.read();
7960
- const scallopClient = new ScallopClient(
7961
- { ...this.params, walletAddress },
7962
- { builder: await this.createScallopBuilder() }
7963
- );
7955
+ const clientParams = {
7956
+ ...this.params,
7957
+ ...params
7958
+ };
7959
+ const scallopClient = new ScallopClient(clientParams, {
7960
+ builder: await this.createScallopBuilder(clientParams)
7961
+ });
7964
7962
  return scallopClient;
7965
7963
  }
7966
7964
  /**
@@ -7968,11 +7966,15 @@ var Scallop = class {
7968
7966
  *
7969
7967
  * @return Scallop Query.
7970
7968
  */
7971
- async createScallopQuery() {
7969
+ async createScallopQuery(params) {
7972
7970
  if (!this.address.getAddresses())
7973
7971
  await this.address.read();
7974
- const scallopQuery = new ScallopQuery(this.params, {
7975
- utils: await this.createScallopUtils()
7972
+ const queryParams = {
7973
+ ...this.params,
7974
+ ...params
7975
+ };
7976
+ const scallopQuery = new ScallopQuery(queryParams, {
7977
+ utils: await this.createScallopUtils(queryParams)
7976
7978
  });
7977
7979
  return scallopQuery;
7978
7980
  }
@@ -7992,12 +7994,18 @@ var Scallop = class {
7992
7994
  *
7993
7995
  * @return Scallop Utils.
7994
7996
  */
7995
- async createScallopUtils() {
7997
+ async createScallopUtils(params) {
7996
7998
  if (!this.address.getAddresses())
7997
7999
  await this.address.read();
7998
- const scallopUtils = new ScallopUtils(this.params, {
7999
- address: this.address
8000
- });
8000
+ const scallopUtils = new ScallopUtils(
8001
+ {
8002
+ ...this.params,
8003
+ ...params
8004
+ },
8005
+ {
8006
+ address: this.address
8007
+ }
8008
+ );
8001
8009
  return scallopUtils;
8002
8010
  }
8003
8011
  };