@scallop-io/sui-scallop-sdk 2.0.13-merge-split-ve-sca-alpha.3 → 2.0.13-merge-split-ve-sca-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.0.13-merge-split-ve-sca-alpha.3",
3
+ "version": "2.0.13-merge-split-ve-sca-alpha.4",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -224,7 +224,9 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
224
224
  (txn.target ===
225
225
  `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
226
226
  txn.target ===
227
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`)
227
+ `${builder.address.get('borrowIncentive.id')}::user::unstake_v2` ||
228
+ txn.target ===
229
+ `${builder.address.get('borrowIncentive.id')}::user::unstake`)
228
230
  );
229
231
 
230
232
  if (!obligationLocked || unstakeObligationBeforeStake) {
@@ -254,7 +256,9 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
254
256
  (txn.target ===
255
257
  `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
256
258
  txn.target ===
257
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`)
259
+ `${builder.address.get('borrowIncentive.id')}::user::unstake_v2` ||
260
+ txn.target ===
261
+ `${builder.address.get('borrowIncentive.id')}::user::unstake`)
258
262
  );
259
263
 
260
264
  if (!obligationLocked || unstakeObligationBeforeStake) {
@@ -426,7 +426,16 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
426
426
  veScaKey,
427
427
  builder.address.get('vesca.subsTable')
428
428
  );
429
- if (isKeyInSubTable) {
429
+
430
+ const unstakeObligationBeforeStake =
431
+ !!txBlock.txBlock.blockData.transactions.find(
432
+ (txn) =>
433
+ txn.kind === 'MoveCall' &&
434
+ txn.target ===
435
+ `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`
436
+ );
437
+
438
+ if (isKeyInSubTable && !unstakeObligationBeforeStake) {
430
439
  throw new Error(
431
440
  'Key cannot be in the subs table, please call unsubscribe vesca or unstake obligation first'
432
441
  );
@@ -455,9 +464,18 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
455
464
  ),
456
465
  ]);
457
466
 
458
- console.log({ isTargetInSubTable, isSourceInSubTable });
467
+ const unstakeObligationBeforeStake =
468
+ !!txBlock.txBlock.blockData.transactions.find(
469
+ (txn) =>
470
+ txn.kind === 'MoveCall' &&
471
+ txn.target ===
472
+ `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`
473
+ );
459
474
 
460
- if (isTargetInSubTable || isSourceInSubTable) {
475
+ if (
476
+ (isTargetInSubTable || isSourceInSubTable) &&
477
+ !unstakeObligationBeforeStake
478
+ ) {
461
479
  throw new Error(
462
480
  'Both target and source cannot be in the subs table. Please call unsubscribe vesca or unstake obligation first'
463
481
  );