zo-sdk 0.1.29 → 0.1.31

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 (40) hide show
  1. package/dist/consts/deployments-slp-mainnet.json +1 -1
  2. package/dist/implementations/SLPAPI.cjs +121 -47
  3. package/dist/implementations/SLPAPI.cjs.map +1 -1
  4. package/dist/implementations/SLPAPI.d.cts +6 -3
  5. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  6. package/dist/implementations/SLPAPI.d.mts +6 -3
  7. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  8. package/dist/implementations/SLPAPI.mjs +121 -47
  9. package/dist/implementations/SLPAPI.mjs.map +1 -1
  10. package/dist/implementations/SLPDataAPI.cjs +50 -3
  11. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  12. package/dist/implementations/SLPDataAPI.d.cts +6 -1
  13. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  14. package/dist/implementations/SLPDataAPI.d.mts +6 -1
  15. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  16. package/dist/implementations/SLPDataAPI.mjs +50 -3
  17. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  18. package/dist/implementations/ZLPAPI.cjs +82 -0
  19. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  20. package/dist/implementations/ZLPAPI.d.cts +3 -0
  21. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  22. package/dist/implementations/ZLPAPI.d.mts +3 -0
  23. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  24. package/dist/implementations/ZLPAPI.mjs +82 -0
  25. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  26. package/dist/interfaces/base.d.cts +4 -3
  27. package/dist/interfaces/base.d.cts.map +1 -1
  28. package/dist/interfaces/base.d.mts +4 -3
  29. package/dist/interfaces/base.d.mts.map +1 -1
  30. package/dist/interfaces/slp.d.cts +21 -0
  31. package/dist/interfaces/slp.d.cts.map +1 -1
  32. package/dist/interfaces/slp.d.mts +21 -0
  33. package/dist/interfaces/slp.d.mts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/consts/deployments-slp-mainnet.json +1 -1
  36. package/src/implementations/SLPAPI.ts +173 -46
  37. package/src/implementations/SLPDataAPI.ts +57 -6
  38. package/src/implementations/ZLPAPI.ts +113 -1
  39. package/src/interfaces/base.ts +10 -3
  40. package/src/interfaces/slp.ts +26 -1
@@ -6,6 +6,7 @@
6
6
  import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
7
7
  import { KioskTransaction } from '@mysten/kiosk'
8
8
  import type { SuiClient } from '@mysten/sui/client'
9
+ import type { TransactionObjectArgument } from '@mysten/sui/transactions'
9
10
  import { Transaction } from '@mysten/sui/transactions'
10
11
  import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
11
12
 
@@ -221,6 +222,76 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
221
222
  return tx
222
223
  }
223
224
 
225
+ public async depositWithPtb(
226
+ coin: string,
227
+ depositObject: TransactionObjectArgument,
228
+ minAmountOut = 0,
229
+ referralAddress?: string,
230
+ sender?: string,
231
+ tx?: Transaction,
232
+ sponsoredTx?: boolean,
233
+ suiCoinObjectsForPythUpdate?: string[],
234
+ ): Promise<Transaction> {
235
+ if (!tx) {
236
+ tx = new Transaction()
237
+ }
238
+
239
+ // Add referral if needed
240
+ if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
241
+ tx = await this.addReferral(referralAddress, tx)
242
+ }
243
+
244
+ // Initialize oracle transaction
245
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
246
+
247
+ // Handle sponsored transaction case
248
+ if (sponsoredTx) {
249
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
250
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
251
+
252
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
253
+
254
+ tx.moveCall({
255
+ target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
256
+ typeArguments: [
257
+ `${this.consts.sudoCore.package}::slp::SLP`,
258
+ this.consts.coins[coin].module,
259
+ ],
260
+ arguments: [
261
+ tx.object(this.consts.sudoCore.market),
262
+ tx.object(this.consts.sudoCore.rebaseFeeModel),
263
+ depositObject,
264
+ tx.pure.u64(minAmountOut),
265
+ vaultsValuation,
266
+ symbolsValuation,
267
+ ],
268
+ })
269
+ return tx
270
+ }
271
+
272
+ // Handle non-sponsored transaction case
273
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
274
+
275
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
276
+
277
+ tx.moveCall({
278
+ target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
279
+ typeArguments: [
280
+ `${this.consts.sudoCore.package}::slp::SLP`,
281
+ this.consts.coins[coin].module,
282
+ ],
283
+ arguments: [
284
+ tx.object(this.consts.sudoCore.market),
285
+ tx.object(this.consts.sudoCore.rebaseFeeModel),
286
+ depositObject,
287
+ tx.pure.u64(minAmountOut),
288
+ vaultsValuation,
289
+ symbolsValuation,
290
+ ],
291
+ })
292
+ return tx
293
+ }
294
+
224
295
  /**
225
296
  * Withdraws collateral from SLP vault using Sudo SDK approach
226
297
  */
@@ -267,6 +338,52 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
267
338
  return tx
268
339
  }
269
340
 
341
+ public async withdrawPtb(
342
+ coin: string,
343
+ lpCoinObjects: string[],
344
+ amount: number,
345
+ minAmountOut = 0,
346
+ tx?: Transaction,
347
+ sponsoredTx?: boolean,
348
+ suiCoinObjectsForPythUpdate?: string[],
349
+ ): Promise<TransactionObjectArgument> {
350
+ if (!tx) {
351
+ tx = new Transaction()
352
+ }
353
+
354
+ // Initialize oracle transaction
355
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
356
+
357
+ if (sponsoredTx) {
358
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
359
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
360
+ }
361
+ else {
362
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
363
+ }
364
+
365
+ const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false)
366
+ const [withdrawObject] = tx.splitCoins(slpCoinObject, [tx.pure.u64(amount)])
367
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
368
+
369
+ const [withdrawCoin] = tx.moveCall({
370
+ target: `${this.consts.sudoCore.upgradedPackage}::market::withdraw_ptb`,
371
+ typeArguments: [
372
+ `${this.consts.sudoCore.package}::slp::SLP`,
373
+ this.consts.coins[coin].module,
374
+ ],
375
+ arguments: [
376
+ tx.object(this.consts.sudoCore.market),
377
+ tx.object(this.consts.sudoCore.rebaseFeeModel),
378
+ withdrawObject,
379
+ tx.pure.u64(minAmountOut),
380
+ vaultsValuation,
381
+ symbolsValuation,
382
+ ],
383
+ })
384
+ return withdrawCoin
385
+ }
386
+
270
387
  public async swap(
271
388
  fromToken: string,
272
389
  toToken: string,
@@ -522,35 +639,32 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
522
639
 
523
640
  // Handle oracle initialization and coin processing
524
641
  let suiCoinObject
525
- let feeObject
526
642
  if (sponsoredTx) {
527
643
  suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
528
- feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
529
644
  tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
530
645
  }
531
646
  else {
532
- feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
533
647
  tx = await this.initOracleTxb([collateralToken, indexToken], tx)
534
648
  }
535
649
 
536
650
  // Process coin splitting
537
- const [depositObject] = this.processCoinSplitting(
651
+ const [depositObject, feeObject] = this.processCoinSplitting(
538
652
  tx,
539
653
  collateralToken,
540
654
  coinObjects,
541
- [tx.pure.u64(collateralAmount)],
655
+ [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)],
542
656
  sponsoredTx,
543
657
  suiCoinObject,
544
658
  )
545
659
 
546
660
  tx.moveCall({
547
- target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_v1_2`,
661
+ target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_v2_1`,
548
662
  typeArguments: [
549
663
  `${this.consts.sudoCore.package}::slp::SLP`,
550
664
  this.consts.coins[collateralToken].module,
551
665
  this.consts.coins[indexToken].module,
552
666
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
553
- this.consts.coins.sui.module,
667
+ this.consts.coins[collateralToken].module,
554
668
  ],
555
669
  arguments: [
556
670
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -569,7 +683,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
569
683
  tx.pure.u64(reserveAmount),
570
684
  tx.pure.u256(adjustCollateralPrice),
571
685
  tx.pure.u256(adjustPrice),
572
- tx.pure.bool(isLimitOrder),
573
686
  ],
574
687
  })
575
688
  return tx
@@ -596,6 +709,10 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
596
709
  sponsoredTx?: boolean,
597
710
  suiCoinObjectsForPythUpdate?: string[],
598
711
  ): Promise<Transaction> {
712
+ if (!coinObjects) {
713
+ throw new Error(`${this.constructor.name}: coinObjects is required`)
714
+ }
715
+
599
716
  let tx = new Transaction()
600
717
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
601
718
 
@@ -620,25 +737,31 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
620
737
 
621
738
  // Handle oracle initialization and coin processing
622
739
  let suiCoinObject
623
- let feeObject
740
+ const [feeObject] = this.processCoinSplitting(
741
+ tx,
742
+ collateralToken,
743
+ coinObjects,
744
+ [tx.pure.u64(relayerFee)],
745
+ sponsoredTx,
746
+ suiCoinObject,
747
+ )
748
+
624
749
  if (sponsoredTx) {
625
750
  suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
626
- feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
627
751
  tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
628
752
  }
629
753
  else {
630
- feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
631
754
  tx = await this.initOracleTxb([collateralToken, indexToken], tx)
632
755
  }
633
756
 
634
757
  tx.moveCall({
635
- target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_2`,
758
+ target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v2_1`,
636
759
  typeArguments: [
637
760
  `${this.consts.sudoCore.package}::slp::SLP`,
638
761
  this.consts.coins[collateralToken].module,
639
762
  this.consts.coins[indexToken].module,
640
763
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
641
- this.consts.coins.sui.module,
764
+ this.consts.coins[collateralToken].module,
642
765
  ],
643
766
  arguments: [
644
767
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -656,7 +779,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
656
779
  tx.pure.u64(amount),
657
780
  tx.pure.u256(adjustCollateralPrice),
658
781
  tx.pure.u256(adjustPrice),
659
- tx.pure.bool(isTriggerOrder),
660
782
  ],
661
783
  })
662
784
 
@@ -740,13 +862,13 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
740
862
  )
741
863
 
742
864
  tx.moveCall({
743
- target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_2`,
865
+ target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v2_1`,
744
866
  typeArguments: [
745
867
  `${this.consts.sudoCore.package}::slp::SLP`,
746
868
  this.consts.coins[collateralToken].module,
747
869
  this.consts.coins[indexToken].module,
748
870
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
749
- this.consts.coins.sui.module,
871
+ this.consts.coins[collateralToken].module,
750
872
  ],
751
873
  arguments: [
752
874
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -764,7 +886,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
764
886
  tx.pure.u64(amount),
765
887
  tx.pure.u256(adjustCollateralPrice),
766
888
  tx.pure.u256(adjustPrice),
767
- tx.pure.bool(isTriggerOrder),
768
889
  ],
769
890
  })
770
891
  }
@@ -872,16 +993,17 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
872
993
  indexToken: string,
873
994
  long: boolean,
874
995
  type: string,
996
+ isV11Order?: boolean,
875
997
  ): Transaction {
876
998
  const tx = new Transaction()
877
999
  let functionName = ''
878
1000
  switch (type) {
879
1001
  case 'OPEN_POSITION': {
880
- functionName = 'clear_open_position_order_v1_1'
1002
+ functionName = 'clear_open_position_order_unified'
881
1003
  break
882
1004
  }
883
1005
  case 'DECREASE_POSITION': {
884
- functionName = 'clear_decrease_position_order_v1_1'
1006
+ functionName = 'clear_decrease_position_order_unified'
885
1007
  break
886
1008
  }
887
1009
  default: {
@@ -895,7 +1017,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
895
1017
  this.consts.coins[collateralToken].module,
896
1018
  this.consts.coins[indexToken].module,
897
1019
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
898
- this.consts.coins.sui.module,
1020
+ isV11Order ? this.consts.coins.sui.module : this.consts.coins[collateralToken].module,
899
1021
  ],
900
1022
  arguments: [
901
1023
  tx.object(this.consts.sudoCore.market),
@@ -921,17 +1043,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
921
1043
  }
922
1044
 
923
1045
  for (const order of orders) {
924
- const { orderCapId, collateralToken, indexToken, long, type, isV11Order } = order
1046
+ const { orderCapId, collateralToken, indexToken, long, type } = order
925
1047
  let functionName = ''
926
1048
  switch (type) {
927
1049
  case 'OPEN_POSITION': {
928
- functionName = isV11Order ? 'clear_open_position_order_v1_1' : 'clear_open_position_order_v1_1'
1050
+ functionName = 'clear_open_position_order_unified'
929
1051
  break
930
1052
  }
931
1053
  case 'DECREASE_POSITION': {
932
- functionName = isV11Order
933
- ? 'clear_decrease_position_order_v1_1'
934
- : 'clear_decrease_position_order_v1_1'
1054
+ functionName = 'clear_decrease_position_order_unified'
935
1055
  break
936
1056
  }
937
1057
  default: {
@@ -979,15 +1099,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
979
1099
  indexToken: string,
980
1100
  long: boolean,
981
1101
  tx: Transaction,
1102
+ isV11Order = true,
982
1103
  ): void {
983
1104
  tx.moveCall({
984
- target: `${this.consts.sudoCore.upgradedPackage}::market::clear_open_position_order_v1_1`,
1105
+ target: `${this.consts.sudoCore.upgradedPackage}::market::clear_open_position_order_unified`,
985
1106
  typeArguments: [
986
1107
  `${this.consts.sudoCore.package}::slp::SLP`,
987
1108
  this.consts.coins[collateralToken].module,
988
1109
  this.consts.coins[indexToken].module,
989
1110
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
990
- this.consts.coins.sui.module,
1111
+ isV11Order ? this.consts.coins.sui.module : this.consts.coins[collateralToken].module,
991
1112
  ],
992
1113
  arguments: [
993
1114
  tx.object(this.consts.sudoCore.market),
@@ -1002,15 +1123,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1002
1123
  indexToken: string,
1003
1124
  long: boolean,
1004
1125
  tx: Transaction,
1126
+ isV11Order = true,
1005
1127
  ): void {
1006
1128
  tx.moveCall({
1007
- target: `${this.consts.sudoCore.upgradedPackage}::market::clear_decrease_position_order_v1_1`,
1129
+ target: `${this.consts.sudoCore.upgradedPackage}::market::clear_decrease_position_order_unified`,
1008
1130
  typeArguments: [
1009
1131
  `${this.consts.sudoCore.package}::slp::SLP`,
1010
1132
  this.consts.coins[collateralToken].module,
1011
1133
  this.consts.coins[indexToken].module,
1012
1134
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
1013
- this.consts.coins.sui.module,
1135
+ isV11Order ? this.consts.coins.sui.module : this.consts.coins[collateralToken].module,
1014
1136
  ],
1015
1137
  arguments: [
1016
1138
  tx.object(this.consts.sudoCore.market),
@@ -1069,35 +1191,32 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1069
1191
 
1070
1192
  // Handle oracle initialization and coin processing
1071
1193
  let suiCoinObject
1072
- let feeObject
1073
1194
  if (sponsoredTx) {
1074
1195
  suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1075
- feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1076
1196
  tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1077
1197
  }
1078
1198
  else {
1079
- feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1080
1199
  tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1081
1200
  }
1082
1201
 
1083
1202
  // Process coin splitting
1084
- const [depositObject] = this.processCoinSplitting(
1203
+ const [depositObject, feeObject] = this.processCoinSplitting(
1085
1204
  tx,
1086
1205
  collateralToken,
1087
1206
  coinObjects,
1088
- [tx.pure.u64(collateralAmount)],
1207
+ [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)],
1089
1208
  sponsoredTx,
1090
1209
  suiCoinObject,
1091
1210
  )
1092
1211
 
1093
1212
  tx.moveCall({
1094
- target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_v1_3`,
1213
+ target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_with_scard_v1`,
1095
1214
  typeArguments: [
1096
1215
  `${this.consts.sudoCore.package}::slp::SLP`,
1097
1216
  this.consts.coins[collateralToken].module,
1098
1217
  this.consts.coins[indexToken].module,
1099
1218
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
1100
- this.consts.coins.sui.module,
1219
+ this.consts.coins[collateralToken].module,
1101
1220
  ],
1102
1221
  arguments: [
1103
1222
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -1116,7 +1235,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1116
1235
  tx.pure.u64(reserveAmount),
1117
1236
  tx.pure.u256(adjustCollateralPrice),
1118
1237
  tx.pure.u256(adjustPrice),
1119
- tx.pure.bool(isLimitOrder),
1120
1238
  sudoCard,
1121
1239
  ],
1122
1240
  })
@@ -1152,6 +1270,10 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1152
1270
  sponsoredTx?: boolean,
1153
1271
  suiCoinObjectsForPythUpdate?: string[],
1154
1272
  ): Promise<Transaction> {
1273
+ if (!coinObjects) {
1274
+ throw new Error(`${this.constructor.name}: coinObjects is required`)
1275
+ }
1276
+
1155
1277
  let tx = new Transaction()
1156
1278
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
1157
1279
 
@@ -1187,25 +1309,32 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1187
1309
 
1188
1310
  // Handle oracle initialization and coin processing
1189
1311
  let suiCoinObject
1190
- let feeObject
1191
1312
  if (sponsoredTx) {
1192
1313
  suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1193
- feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1194
1314
  tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1195
1315
  }
1196
1316
  else {
1197
- feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1198
1317
  tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1199
1318
  }
1200
1319
 
1320
+ // Process coin splitting
1321
+ const [feeObject] = this.processCoinSplitting(
1322
+ tx,
1323
+ collateralToken,
1324
+ coinObjects,
1325
+ [tx.pure.u64(relayerFee)],
1326
+ sponsoredTx,
1327
+ suiCoinObject,
1328
+ )
1329
+
1201
1330
  tx.moveCall({
1202
- target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_3`,
1331
+ target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v1`,
1203
1332
  typeArguments: [
1204
1333
  `${this.consts.sudoCore.package}::slp::SLP`,
1205
1334
  this.consts.coins[collateralToken].module,
1206
1335
  this.consts.coins[indexToken].module,
1207
1336
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
1208
- this.consts.coins.sui.module,
1337
+ this.consts.coins[collateralToken].module,
1209
1338
  ],
1210
1339
  arguments: [
1211
1340
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -1223,7 +1352,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1223
1352
  tx.pure.u64(amount),
1224
1353
  tx.pure.u256(adjustCollateralPrice),
1225
1354
  tx.pure.u256(adjustPrice),
1226
- tx.pure.bool(isTriggerOrder),
1227
1355
  sudoCard,
1228
1356
  ],
1229
1357
  })
@@ -1329,13 +1457,13 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1329
1457
  )
1330
1458
 
1331
1459
  tx.moveCall({
1332
- target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_3`,
1460
+ target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v1`,
1333
1461
  typeArguments: [
1334
1462
  `${this.consts.sudoCore.package}::slp::SLP`,
1335
1463
  this.consts.coins[collateralToken].module,
1336
1464
  this.consts.coins[indexToken].module,
1337
1465
  `${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
1338
- this.consts.coins.sui.module,
1466
+ this.consts.coins[collateralToken].module,
1339
1467
  ],
1340
1468
  arguments: [
1341
1469
  tx.object(SUI_CLOCK_OBJECT_ID),
@@ -1353,7 +1481,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1353
1481
  tx.pure.u64(amount),
1354
1482
  tx.pure.u256(adjustCollateralPrice),
1355
1483
  tx.pure.u256(adjustPrice),
1356
- tx.pure.bool(isTriggerOrder),
1357
1484
  sudoCard,
1358
1485
  ],
1359
1486
  })
@@ -30,6 +30,7 @@ import type {
30
30
  ISLPReservingFeeModel,
31
31
  ISLPStaked,
32
32
  ISLPStakePool,
33
+ ISLPSymbolConfig,
33
34
  ISLPSymbolInfo,
34
35
  ISLPVaultInfo,
35
36
  } from '../interfaces'
@@ -323,6 +324,28 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
323
324
  return await this.parseSymbolInfo(rawData, long)
324
325
  }
325
326
 
327
+ /**
328
+ * Gets SLP symbol configuration
329
+ */
330
+ public async getSymbolConfig(indexToken: string, long: boolean): Promise<ISLPSymbolConfig | null> {
331
+ this.validateCache()
332
+ try {
333
+ const rawData = await this.provider.getDynamicFieldObject({
334
+ parentId: this.consts.sudoCore.market,
335
+ name: {
336
+ type: `${this.consts.sudoCore.package}::market::SymbolName<${this.consts.coins[indexToken].module}, ${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}>`,
337
+ value: { dummy_field: false },
338
+ },
339
+ })
340
+ return SLPDataAPI.parseSymbolConfig(rawData)
341
+ }
342
+ catch {
343
+ // If the dynamic field doesn't exist, return null
344
+ console.error('Symbol Config Not Found')
345
+ return null
346
+ }
347
+ }
348
+
326
349
  public async getPositionInfoList(
327
350
  positionCapInfoList: ISLPPositionCapInfo[],
328
351
  owner: string,
@@ -520,9 +543,10 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
520
543
  const credentials = rawCredentialsData
521
544
  .filter(
522
545
  (item: any) =>
523
- item.data.type ===
524
- `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.sudoCore.package}::slp::SLP, ${this.consts.sudoCore.package}::slp::SLP>`
525
- ).map((item: any) =>
546
+ item.data.type
547
+ === `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.sudoCore.package}::slp::SLP, ${this.consts.sudoCore.package}::slp::SLP>`,
548
+ )
549
+ .map((item: any) =>
526
550
  SLPDataAPI.parseCredential(item, pool),
527
551
  )
528
552
  return {
@@ -902,8 +926,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
902
926
  name: {
903
927
  type: `${this.consts.sudoCore.package}::market::OrderName<${orderCapInfo.symbol0
904
928
  }, ${orderCapInfo.symbol1}, ${this.consts.sudoCore.package
905
- }::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${this.consts.coins.sui.module
906
- }>`,
929
+ }::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${orderCapInfo.symbol0}>`,
907
930
  value: {
908
931
  owner,
909
932
  id: orderCapInfo.orderCapId,
@@ -1030,6 +1053,29 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1030
1053
  }
1031
1054
  }
1032
1055
 
1056
+ private static parseSymbolConfig(raw: any): ISLPSymbolConfig {
1057
+ const { fields } = raw.data.content
1058
+
1059
+ return {
1060
+ id: fields.id.id,
1061
+ max_opening_size: parseValue(fields.max_opening_size),
1062
+ max_opening_size_enabled: fields.max_opening_size_enabled,
1063
+ max_opening_size_per_position: parseValue(fields.max_opening_size_per_position),
1064
+ max_opening_size_per_position_enabled: fields.max_opening_size_per_position_enabled,
1065
+ instant_exit_fee_config: {
1066
+ instant_exit_tier_1_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_1_duration_threshold),
1067
+ instant_exit_tier_1_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_bps.fields.value),
1068
+ instant_exit_tier_1_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_enabled,
1069
+ instant_exit_tier_2_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_2_duration_threshold),
1070
+ instant_exit_tier_2_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_bps.fields.value),
1071
+ instant_exit_tier_2_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_enabled,
1072
+ instant_exit_tier_3_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_3_duration_threshold),
1073
+ instant_exit_tier_3_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_bps.fields.value),
1074
+ instant_exit_tier_3_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_enabled,
1075
+ },
1076
+ }
1077
+ }
1078
+
1033
1079
  private static parseRebaseFeeModel(raw: any): ISLPRebaseFeeModel {
1034
1080
  const { fields } = raw.data.content
1035
1081
 
@@ -1201,6 +1247,9 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1201
1247
  const orderType = content.fields.value.type.includes('OpenPositionOrder')
1202
1248
  ? 'OPEN_POSITION'
1203
1249
  : 'DECREASE_POSITION'
1250
+ const orderVersion = content.fields.value.type.includes('V2')
1251
+ ? 'V2'
1252
+ : 'V1_1'
1204
1253
 
1205
1254
  const ret: ISLPOrderInfo = {
1206
1255
  id: content.fields.id.id,
@@ -1221,6 +1270,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1221
1270
  feeAmount: BigInt(fields.fee),
1222
1271
  long: dataType.includes('::market::LONG'),
1223
1272
  orderType,
1273
+ orderVersion,
1224
1274
  createdAt: parseValue(fields.created_at),
1225
1275
  }
1226
1276
 
@@ -1281,7 +1331,8 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1281
1331
  // Use appropriate refresh method based on version
1282
1332
  if (isNewVersion) {
1283
1333
  SLPDataAPI.refreshPoolV2(pool, Math.floor(Date.now() / 1000))
1284
- } else {
1334
+ }
1335
+ else {
1285
1336
  SLPDataAPI.refreshPool(pool, Math.floor(Date.now() / 1000))
1286
1337
  }
1287
1338