zo-sdk 0.1.62 → 0.1.64

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 (46) hide show
  1. package/dist/consts/deployments-usdz-mainnet.json +37 -5
  2. package/dist/consts/price_id_to_object_id.mainnet.json +3 -1
  3. package/dist/implementations/SLPAPI.cjs +544 -0
  4. package/dist/implementations/SLPAPI.cjs.map +1 -1
  5. package/dist/implementations/SLPAPI.d.cts +49 -0
  6. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  7. package/dist/implementations/SLPAPI.d.mts +49 -0
  8. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  9. package/dist/implementations/SLPAPI.mjs +544 -0
  10. package/dist/implementations/SLPAPI.mjs.map +1 -1
  11. package/dist/implementations/SLPDataAPI.cjs +48 -9
  12. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  13. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  14. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  15. package/dist/implementations/SLPDataAPI.mjs +49 -10
  16. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  17. package/dist/implementations/USDZAPI.cjs +544 -0
  18. package/dist/implementations/USDZAPI.cjs.map +1 -1
  19. package/dist/implementations/USDZAPI.d.cts +49 -0
  20. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  21. package/dist/implementations/USDZAPI.d.mts +49 -0
  22. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  23. package/dist/implementations/USDZAPI.mjs +544 -0
  24. package/dist/implementations/USDZAPI.mjs.map +1 -1
  25. package/dist/implementations/USDZDataAPI.cjs +47 -7
  26. package/dist/implementations/USDZDataAPI.cjs.map +1 -1
  27. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  28. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  29. package/dist/implementations/USDZDataAPI.mjs +47 -7
  30. package/dist/implementations/USDZDataAPI.mjs.map +1 -1
  31. package/dist/implementations/ZLPAPI.cjs +2 -6
  32. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  33. package/dist/implementations/ZLPAPI.d.cts +2 -2
  34. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  35. package/dist/implementations/ZLPAPI.d.mts +2 -2
  36. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  37. package/dist/implementations/ZLPAPI.mjs +2 -6
  38. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  39. package/package.json +1 -1
  40. package/src/consts/deployments-usdz-mainnet.json +37 -5
  41. package/src/consts/price_id_to_object_id.mainnet.json +3 -1
  42. package/src/implementations/SLPAPI.ts +884 -26
  43. package/src/implementations/SLPDataAPI.ts +52 -10
  44. package/src/implementations/USDZAPI.ts +913 -55
  45. package/src/implementations/USDZDataAPI.ts +50 -7
  46. package/src/implementations/ZLPAPI.ts +2 -7
@@ -16,6 +16,7 @@ import type { Network } from '../consts'
16
16
  import { LPToken, SLP_TOKEN_DECIMALS } from '../consts'
17
17
  import type {
18
18
  IBaseHistoryResponse,
19
+ IBaseOrderType,
19
20
  ISLPCredential,
20
21
  ISLPDataAPI,
21
22
  ISLPFundingFeeModel,
@@ -36,7 +37,7 @@ import type {
36
37
  ISLPSymbolInfo,
37
38
  ISLPVaultInfo,
38
39
  } from '../interfaces'
39
- import { decimalToObject, joinSymbol, parseSymbolKey, parseValue, suiSymbolToSymbol } from '../utils'
40
+ import { joinSymbol, parseSymbolKey, parseValue, suiSymbolToSymbol } from '../utils'
40
41
 
41
42
  export interface GetCumulativeAprResponse {
42
43
  generatedAt?: string
@@ -1327,12 +1328,22 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1327
1328
  const { fields } = content.fields.value
1328
1329
 
1329
1330
  // Extract tokens from dataType
1330
- const dataType = content.type
1331
+ const dataType = content?.type
1331
1332
 
1332
- const orderType = content.fields.value.type.includes('OpenPositionOrder')
1333
- ? 'OPEN_POSITION'
1334
- : 'DECREASE_POSITION'
1335
- const orderVersion = content.fields.value.type.includes('V2')
1333
+ let orderType: IBaseOrderType
1334
+ if (content.fields.value?.type.includes('OpenPositionOrder')) {
1335
+ orderType = 'OPEN_POSITION'
1336
+ }
1337
+ else if (content.fields.value?.type.includes('OpenMarketOrder')) {
1338
+ orderType = 'OPEN_MARKET'
1339
+ }
1340
+ else if (content.fields.value?.type.includes('DecreasePositionOrder')) {
1341
+ orderType = 'DECREASE_POSITION'
1342
+ }
1343
+ else {
1344
+ orderType = 'DECREASE_MARKET'
1345
+ }
1346
+ const orderVersion = content.fields.value?.type.includes('V2')
1336
1347
  ? 'V2'
1337
1348
  : 'V1_1'
1338
1349
 
@@ -1350,23 +1361,54 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1350
1361
  dataType.split(',')[3].split('>')[0].trim(),
1351
1362
  this.consts,
1352
1363
  ),
1353
- indexPrice: decimalToObject(fields.limited_index_price.fields),
1354
- collateralPriceThreshold: parseValue(fields.collateral_price_threshold),
1364
+ // Use index_price for open orders, limited_index_price for decrease orders
1365
+ indexPrice: orderType === 'OPEN_MARKET'
1366
+ ? parseValue(fields.index_price)
1367
+ : parseValue(fields.limited_index_price?.fields?.price || fields.limited_index_price),
1368
+ collateralPriceThreshold: fields.collateral_price_threshold ? parseValue(fields.collateral_price_threshold) : 0,
1369
+ // New index price threshold
1370
+ indexPriceThreshold: fields.index_price_threshold ? parseValue(fields.index_price_threshold) : undefined,
1355
1371
  feeAmount: BigInt(fields.fee),
1356
1372
  long: dataType.includes('::market::LONG'),
1357
1373
  orderType,
1358
1374
  orderVersion,
1359
1375
  createdAt: parseValue(fields.created_at),
1376
+ v11Order: !fields.limited_index_price?.fields?.price,
1377
+ // New: referrer and scard fields
1378
+ referrer: fields.referrer,
1379
+ scardId: (
1380
+ fields.scard_id?.fields?.some?.fields?.id
1381
+ || fields.scard_id?.fields?.value?.fields?.id
1382
+ || fields.scard_id?.fields?.id
1383
+ || fields.scard_id?.id
1384
+ ),
1385
+ scardRebateRate: (() => {
1386
+ const inner = fields.scard_rebate_rate?.fields?.some ?? fields.scard_rebate_rate?.fields?.value
1387
+ return inner ? parseValue(inner) : undefined
1388
+ })(),
1360
1389
  }
1361
1390
 
1362
- if (orderType === 'OPEN_POSITION') {
1391
+ if (orderType === 'OPEN_POSITION' || orderType === 'OPEN_MARKET') {
1363
1392
  ret.openOrder = {
1364
1393
  reserveAmount: BigInt(fields.reserve_amount),
1365
1394
  collateralAmount: BigInt(fields.collateral),
1366
1395
  openAmount: BigInt(fields.open_amount),
1396
+ // New: position_config from OpenMarketOrder
1397
+ positionConfig: fields.position_config?.fields
1398
+ ? {
1399
+ decreaseFeeBps: parseValue(fields.position_config.fields.decrease_fee_bps),
1400
+ liquidationBonus: parseValue(fields.position_config.fields.liquidation_bonus),
1401
+ liquidationThreshold: parseValue(fields.position_config.fields.liquidation_threshold),
1402
+ maxLeverage: parseValue(fields.position_config.fields.max_leverage),
1403
+ minHoldingDuration: parseValue(fields.position_config.fields.min_holding_duration),
1404
+ openFeeBps: parseValue(fields.position_config.fields.open_fee_bps),
1405
+ maxReservedMultiplier: parseValue(fields.position_config.fields.max_reserved_multiplier),
1406
+ minCollateralValue: parseValue(fields.position_config.fields.min_collateral_value),
1407
+ }
1408
+ : undefined,
1367
1409
  }
1368
1410
  }
1369
- else {
1411
+ else if (orderType === 'DECREASE_POSITION' || orderType === 'DECREASE_MARKET') {
1370
1412
  ret.decreaseOrder = {
1371
1413
  decreaseAmount: BigInt(fields.decrease_amount),
1372
1414
  takeProfit: fields.take_profit,