zo-sdk 0.1.2 → 0.1.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.
Files changed (183) hide show
  1. package/dist/abstract/BaseAPI.cjs +3 -4
  2. package/dist/abstract/BaseAPI.cjs.map +1 -1
  3. package/dist/abstract/BaseAPI.d.cts +13 -13
  4. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  5. package/dist/abstract/BaseAPI.d.mts +13 -13
  6. package/dist/abstract/BaseAPI.d.mts.map +1 -1
  7. package/dist/abstract/BaseAPI.mjs +3 -4
  8. package/dist/abstract/BaseAPI.mjs.map +1 -1
  9. package/dist/abstract/BaseDataAPI.cjs +2 -2
  10. package/dist/abstract/BaseDataAPI.cjs.map +1 -1
  11. package/dist/abstract/BaseDataAPI.d.cts +2 -2
  12. package/dist/abstract/BaseDataAPI.d.cts.map +1 -1
  13. package/dist/abstract/BaseDataAPI.d.mts +2 -2
  14. package/dist/abstract/BaseDataAPI.d.mts.map +1 -1
  15. package/dist/abstract/BaseDataAPI.mjs +2 -2
  16. package/dist/abstract/BaseDataAPI.mjs.map +1 -1
  17. package/dist/abstract/index.cjs +3 -3
  18. package/dist/abstract/index.cjs.map +1 -1
  19. package/dist/abstract/index.d.cts +1 -1
  20. package/dist/abstract/index.d.cts.map +1 -1
  21. package/dist/abstract/index.d.mts +1 -1
  22. package/dist/abstract/index.d.mts.map +1 -1
  23. package/dist/abstract/index.mjs +1 -1
  24. package/dist/abstract/index.mjs.map +1 -1
  25. package/dist/api.cjs +2 -1
  26. package/dist/api.cjs.map +1 -1
  27. package/dist/api.d.cts.map +1 -1
  28. package/dist/api.d.mts.map +1 -1
  29. package/dist/api.mjs +2 -1
  30. package/dist/api.mjs.map +1 -1
  31. package/dist/bcs.cjs.map +1 -1
  32. package/dist/bcs.d.cts.map +1 -1
  33. package/dist/bcs.d.mts.map +1 -1
  34. package/dist/bcs.mjs.map +1 -1
  35. package/dist/consts/deployments-slp-mainnet.json +0 -70
  36. package/dist/consts/deployments-usdz-mainnet.json +1 -133
  37. package/dist/consts/index.cjs +56 -15
  38. package/dist/consts/index.cjs.map +1 -1
  39. package/dist/consts/index.d.cts.map +1 -1
  40. package/dist/consts/index.d.mts.map +1 -1
  41. package/dist/consts/index.mjs +56 -15
  42. package/dist/consts/index.mjs.map +1 -1
  43. package/dist/factory/SDKFactory.cjs +21 -14
  44. package/dist/factory/SDKFactory.cjs.map +1 -1
  45. package/dist/factory/SDKFactory.d.cts +4 -4
  46. package/dist/factory/SDKFactory.d.cts.map +1 -1
  47. package/dist/factory/SDKFactory.d.mts +4 -4
  48. package/dist/factory/SDKFactory.d.mts.map +1 -1
  49. package/dist/factory/SDKFactory.mjs +22 -15
  50. package/dist/factory/SDKFactory.mjs.map +1 -1
  51. package/dist/implementations/SLPAPI.cjs +143 -110
  52. package/dist/implementations/SLPAPI.cjs.map +1 -1
  53. package/dist/implementations/SLPAPI.d.cts +49 -47
  54. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  55. package/dist/implementations/SLPAPI.d.mts +49 -47
  56. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  57. package/dist/implementations/SLPAPI.mjs +143 -110
  58. package/dist/implementations/SLPAPI.mjs.map +1 -1
  59. package/dist/implementations/SLPDataAPI.cjs +98 -89
  60. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  61. package/dist/implementations/SLPDataAPI.d.cts +21 -21
  62. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  63. package/dist/implementations/SLPDataAPI.d.mts +21 -21
  64. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  65. package/dist/implementations/SLPDataAPI.mjs +98 -89
  66. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  67. package/dist/implementations/USDZAPI.cjs +128 -84
  68. package/dist/implementations/USDZAPI.cjs.map +1 -1
  69. package/dist/implementations/USDZAPI.d.cts +46 -45
  70. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  71. package/dist/implementations/USDZAPI.d.mts +46 -45
  72. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  73. package/dist/implementations/USDZAPI.mjs +128 -84
  74. package/dist/implementations/USDZAPI.mjs.map +1 -1
  75. package/dist/implementations/USDZDataAPI.cjs +48 -47
  76. package/dist/implementations/USDZDataAPI.cjs.map +1 -1
  77. package/dist/implementations/USDZDataAPI.d.cts +19 -19
  78. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  79. package/dist/implementations/USDZDataAPI.d.mts +19 -19
  80. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  81. package/dist/implementations/USDZDataAPI.mjs +49 -48
  82. package/dist/implementations/USDZDataAPI.mjs.map +1 -1
  83. package/dist/implementations/ZLPAPI.cjs +137 -89
  84. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  85. package/dist/implementations/ZLPAPI.d.cts +50 -48
  86. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  87. package/dist/implementations/ZLPAPI.d.mts +50 -48
  88. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  89. package/dist/implementations/ZLPAPI.mjs +137 -89
  90. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  91. package/dist/implementations/ZLPDataAPI.cjs +62 -63
  92. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  93. package/dist/implementations/ZLPDataAPI.d.cts +19 -19
  94. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  95. package/dist/implementations/ZLPDataAPI.d.mts +19 -19
  96. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  97. package/dist/implementations/ZLPDataAPI.mjs +63 -64
  98. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  99. package/dist/implementations/index.cjs +5 -5
  100. package/dist/implementations/index.cjs.map +1 -1
  101. package/dist/implementations/index.d.cts +2 -2
  102. package/dist/implementations/index.d.cts.map +1 -1
  103. package/dist/implementations/index.d.mts +2 -2
  104. package/dist/implementations/index.d.mts.map +1 -1
  105. package/dist/implementations/index.mjs +2 -2
  106. package/dist/implementations/index.mjs.map +1 -1
  107. package/dist/index.cjs +9 -9
  108. package/dist/index.cjs.map +1 -1
  109. package/dist/index.d.cts +6 -6
  110. package/dist/index.d.cts.map +1 -1
  111. package/dist/index.d.mts +6 -6
  112. package/dist/index.d.mts.map +1 -1
  113. package/dist/index.mjs +6 -6
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/interfaces/base.cjs +0 -1
  116. package/dist/interfaces/base.cjs.map +1 -1
  117. package/dist/interfaces/base.d.cts +57 -57
  118. package/dist/interfaces/base.d.cts.map +1 -1
  119. package/dist/interfaces/base.d.mts +57 -57
  120. package/dist/interfaces/base.d.mts.map +1 -1
  121. package/dist/interfaces/base.mjs +1 -1
  122. package/dist/interfaces/base.mjs.map +1 -1
  123. package/dist/interfaces/index.d.cts +4 -4
  124. package/dist/interfaces/index.d.cts.map +1 -1
  125. package/dist/interfaces/index.d.mts +4 -4
  126. package/dist/interfaces/index.d.mts.map +1 -1
  127. package/dist/interfaces/slp.cjs +0 -2
  128. package/dist/interfaces/slp.cjs.map +1 -1
  129. package/dist/interfaces/slp.d.cts +5 -5
  130. package/dist/interfaces/slp.d.cts.map +1 -1
  131. package/dist/interfaces/slp.d.mts +5 -5
  132. package/dist/interfaces/slp.d.mts.map +1 -1
  133. package/dist/interfaces/slp.mjs +1 -2
  134. package/dist/interfaces/slp.mjs.map +1 -1
  135. package/dist/interfaces/usdz.d.cts +1 -1
  136. package/dist/interfaces/usdz.d.cts.map +1 -1
  137. package/dist/interfaces/usdz.d.mts +1 -1
  138. package/dist/interfaces/usdz.d.mts.map +1 -1
  139. package/dist/interfaces/zlp.d.cts +5 -5
  140. package/dist/interfaces/zlp.d.cts.map +1 -1
  141. package/dist/interfaces/zlp.d.mts +5 -5
  142. package/dist/interfaces/zlp.d.mts.map +1 -1
  143. package/dist/oracle.cjs +12 -2
  144. package/dist/oracle.cjs.map +1 -1
  145. package/dist/oracle.d.cts +4 -3
  146. package/dist/oracle.d.cts.map +1 -1
  147. package/dist/oracle.d.mts +4 -3
  148. package/dist/oracle.d.mts.map +1 -1
  149. package/dist/oracle.mjs +13 -3
  150. package/dist/oracle.mjs.map +1 -1
  151. package/dist/utils.cjs +1 -1
  152. package/dist/utils.cjs.map +1 -1
  153. package/dist/utils.d.cts.map +1 -1
  154. package/dist/utils.d.mts.map +1 -1
  155. package/dist/utils.mjs +1 -1
  156. package/dist/utils.mjs.map +1 -1
  157. package/eslint.config.mjs +18 -0
  158. package/package.json +16 -15
  159. package/src/abstract/BaseAPI.ts +55 -49
  160. package/src/abstract/BaseDataAPI.ts +19 -17
  161. package/src/abstract/index.ts +1 -1
  162. package/src/api.ts +3 -1
  163. package/src/bcs.ts +9 -9
  164. package/src/consts/deployments-slp-mainnet.json +0 -70
  165. package/src/consts/deployments-usdz-mainnet.json +1 -133
  166. package/src/consts/index.ts +61 -16
  167. package/src/factory/SDKFactory.ts +49 -41
  168. package/src/implementations/SLPAPI.ts +299 -210
  169. package/src/implementations/SLPDataAPI.ts +163 -146
  170. package/src/implementations/USDZAPI.ts +238 -133
  171. package/src/implementations/USDZDataAPI.ts +79 -74
  172. package/src/implementations/ZLPAPI.ts +296 -174
  173. package/src/implementations/ZLPDataAPI.ts +93 -88
  174. package/src/implementations/index.ts +3 -3
  175. package/src/index.ts +17 -17
  176. package/src/interfaces/base.ts +123 -116
  177. package/src/interfaces/index.ts +14 -17
  178. package/src/interfaces/slp.ts +20 -19
  179. package/src/interfaces/usdz.ts +13 -13
  180. package/src/interfaces/zlp.ts +22 -21
  181. package/src/oracle.ts +25 -5
  182. package/src/utils.ts +9 -9
  183. package/tsconfig.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "zo-sdk",
3
- "version": "0.1.2",
3
+ "type": "module",
4
+ "version": "0.1.4",
5
+ "author": "zo",
4
6
  "exports": {
5
7
  ".": {
6
8
  "import": {
@@ -16,26 +18,25 @@
16
18
  "main": "./dist/index.cjs",
17
19
  "module": "./dist/index.mjs",
18
20
  "types": "dist/index.d.ts",
19
- "keywords": [],
20
- "author": "",
21
- "license": "MIT",
22
- "devDependencies": {
23
- "@ts-bridge/cli": "^0.6.3",
24
- "tsx": "^4.19.3",
25
- "typescript": "^5.8.2"
21
+ "scripts": {
22
+ "build": "ts-bridge build --project ./tsconfig.json --clean",
23
+ "pub": "pnpm build && npm publish",
24
+ "serve": "tsx dist/index.js",
25
+ "start": "tsx src/index.ts",
26
+ "test": "vitest"
26
27
  },
27
28
  "dependencies": {
28
29
  "@mysten/bcs": "^1.1.0",
29
30
  "@mysten/kiosk": "^0.12.17",
30
31
  "@mysten/sui": "^1.34.0",
31
- "@pythnetwork/pyth-sui-js": "2.1.0",
32
+ "@pythnetwork/pyth-sui-js": "2.2.0",
32
33
  "decimal.js": "10.4.3"
33
34
  },
34
- "scripts": {
35
- "build": "ts-bridge build --project ./tsconfig.json --clean",
36
- "serve": "tsx dist/index.js",
37
- "start": "tsx src/index.ts",
38
- "pub": "pnpm build && npm publish",
39
- "test": "vitest"
35
+ "devDependencies": {
36
+ "@ts-bridge/cli": "^0.6.3",
37
+ "eslint": "^9.32.0",
38
+ "eslint-config-hyoban": "^4.0.9",
39
+ "tsx": "^4.19.3",
40
+ "typescript": "^5.8.2"
40
41
  }
41
42
  }
@@ -3,14 +3,15 @@
3
3
  * Extends BaseDataAPI with trading functionality
4
4
  */
5
5
 
6
+ import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
6
7
  import type { SuiClient } from '@mysten/sui/client'
7
8
  import { Transaction } from '@mysten/sui/transactions'
8
9
  import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
9
- import type { Network, LPToken } from '../consts'
10
+
11
+ import type { LPToken, Network } from '../consts'
10
12
  import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE } from '../consts'
11
13
  import type { IBaseAPI, IBaseCredential } from '../interfaces'
12
14
  import { BaseDataAPI } from './BaseDataAPI'
13
- import { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
14
15
 
15
16
  export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
16
17
  constructor(
@@ -18,7 +19,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
18
19
  provider: SuiClient,
19
20
  apiEndpoint: string,
20
21
  connectionURL: string,
21
- lpToken: LPToken
22
+ lpToken: LPToken,
22
23
  ) {
23
24
  super(network, provider, apiEndpoint, connectionURL, lpToken)
24
25
  }
@@ -27,14 +28,14 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
27
28
  * Processes coin objects for transactions
28
29
  * Handles SUI gas coin and merges multiple coin objects if needed
29
30
  */
30
- protected processCoins(tx: Transaction, coin: string, coinObjects: string[]) {
31
- if (coin === 'sui') {
31
+ protected processCoins(tx: Transaction, coin: string, coinObjects: string[], sponsoredTx = false) {
32
+ if (coin === 'sui' && !sponsoredTx) {
32
33
  return tx.gas
33
34
  }
34
35
  if (coinObjects.length > 1) {
35
36
  tx.mergeCoins(
36
37
  tx.object(coinObjects[0]),
37
- coinObjects.slice(1).map(coinObject => tx.object(coinObject))
38
+ coinObjects.slice(1).map(coinObject => tx.object(coinObject)),
38
39
  )
39
40
  }
40
41
  return tx.object(coinObjects[0])
@@ -67,14 +68,19 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
67
68
  amount: number,
68
69
  minAmountOut?: number,
69
70
  referralAddress?: string,
70
- sender?: string
71
+ sender?: string,
72
+ sponsoredTx?: boolean,
73
+ suiCoinObjectsForPythUpdate?: string[],
74
+ isDepositingSui?: boolean,
71
75
  ): Promise<Transaction>
72
76
 
73
77
  public abstract withdraw(
74
78
  coin: string,
75
79
  lpCoinObjects: string[],
76
80
  amount: number,
77
- minAmountOut?: number
81
+ minAmountOut?: number,
82
+ sponsoredTx?: boolean,
83
+ suiCoinObjectsForPythUpdate?: string[],
78
84
  ): Promise<Transaction>
79
85
 
80
86
  public abstract swap(
@@ -90,14 +96,14 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
90
96
  amount: bigint,
91
97
  pool: string,
92
98
  tx?: Transaction
93
- ): Promise<Transaction>
99
+ ): Transaction
94
100
 
95
101
  public abstract unstake(
96
102
  credentials: IBaseCredential[],
97
103
  amount: bigint,
98
104
  pool: string,
99
105
  tx?: Transaction
100
- ): Promise<Transaction>
106
+ ): Transaction
101
107
 
102
108
  // Trading operations
103
109
  public abstract openPosition(
@@ -138,19 +144,19 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
138
144
 
139
145
  public abstract decreaseMultiPositions(
140
146
  positions: Array<{
141
- pcpId: string,
142
- collateralToken: string,
143
- indexToken: string,
144
- amount: bigint,
145
- long: boolean,
146
- indexPrice: number,
147
- collateralPrice: number,
148
- isTriggerOrder?: boolean,
149
- isTakeProfitOrder?: boolean,
150
- isIocOrder?: boolean,
151
- pricesSlippage?: number,
152
- collateralSlippage?: number,
153
- relayerFee?: bigint,
147
+ pcpId: string
148
+ collateralToken: string
149
+ indexToken: string
150
+ amount: bigint
151
+ long: boolean
152
+ indexPrice: number
153
+ collateralPrice: number
154
+ isTriggerOrder?: boolean
155
+ isTakeProfitOrder?: boolean
156
+ isIocOrder?: boolean
157
+ pricesSlippage?: number
158
+ collateralSlippage?: number
159
+ relayerFee?: bigint
154
160
  coinObjects?: string[]
155
161
  }>, tx?: Transaction
156
162
  ): Promise<Transaction>
@@ -179,18 +185,18 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
179
185
  long: boolean,
180
186
  type: string,
181
187
  isV11Order?: boolean
182
- ): Promise<Transaction>
188
+ ): Transaction
183
189
 
184
190
  public abstract cancelMultiOrders(
185
191
  orders: Array<{
186
- orderCapId: string,
187
- collateralToken: string,
188
- indexToken: string,
189
- long: boolean,
190
- type: string,
192
+ orderCapId: string
193
+ collateralToken: string
194
+ indexToken: string
195
+ long: boolean
196
+ type: string
191
197
  isV11Order?: boolean
192
198
  }>, tx?: Transaction
193
- ): Promise<Transaction>
199
+ ): Transaction
194
200
 
195
201
  public abstract clearClosedPosition(
196
202
  pcpId: string,
@@ -263,19 +269,19 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
263
269
 
264
270
  public abstract decreaseMultiPositionsWithSCard(
265
271
  positions: Array<{
266
- pcpId: string,
267
- collateralToken: string,
268
- indexToken: string,
269
- amount: bigint,
270
- long: boolean,
271
- indexPrice: number,
272
- collateralPrice: number,
273
- isTriggerOrder?: boolean,
274
- isTakeProfitOrder?: boolean,
275
- isIocOrder?: boolean,
276
- pricesSlippage?: number,
277
- collateralSlippage?: number,
278
- relayerFee?: bigint,
272
+ pcpId: string
273
+ collateralToken: string
274
+ indexToken: string
275
+ amount: bigint
276
+ long: boolean
277
+ indexPrice: number
278
+ collateralPrice: number
279
+ isTriggerOrder?: boolean
280
+ isTakeProfitOrder?: boolean
281
+ isIocOrder?: boolean
282
+ pricesSlippage?: number
283
+ collateralSlippage?: number
284
+ relayerFee?: bigint
279
285
  coinObjects?: string[]
280
286
  }>,
281
287
  kioskClient: KioskClient,
@@ -290,7 +296,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
290
296
  kioskClient: KioskClient,
291
297
  kioskCap: KioskOwnerCap,
292
298
  scard: string,
293
- ): Promise<Transaction>
299
+ ): Transaction
294
300
 
295
301
  // Miscellaneous
296
302
  public abstract addReferral(
@@ -310,7 +316,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
310
316
  collateralToken: string,
311
317
  indexToken: string,
312
318
  long: boolean
313
- ): Promise<Transaction>
319
+ ): Transaction
314
320
 
315
321
  public abstract adminDecreasePosition(
316
322
  positionId: string,
@@ -323,7 +329,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
323
329
  collateralPrice?: number,
324
330
  collateralSlippage?: number,
325
331
  relayerFee?: bigint
326
- ): Promise<Transaction>
332
+ ): Transaction
327
333
 
328
334
  public abstract adminClearClosedPosition(
329
335
  positionId: string,
@@ -332,7 +338,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
332
338
  indexToken: string,
333
339
  long: boolean,
334
340
  tx: Transaction
335
- ): Promise<void>
341
+ ): void
336
342
 
337
343
  /**
338
344
  * Helper method to initialize oracle transaction block
@@ -356,7 +362,7 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
356
362
  * Helper method to create move call arguments array
357
363
  */
358
364
  protected createMoveCallArgs(tx: Transaction, args: any[]): any[] {
359
- return args.map(arg => {
365
+ return args.map((arg) => {
360
366
  if (typeof arg === 'string' && arg.startsWith('0x')) {
361
367
  return tx.object(arg)
362
368
  }
@@ -426,4 +432,4 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
426
432
  throw new Error('Collateral amount must be greater than 0')
427
433
  }
428
434
  }
429
- }
435
+ }
@@ -5,22 +5,23 @@
5
5
 
6
6
  import type { SuiClient } from '@mysten/sui/client'
7
7
  import type { Transaction } from '@mysten/sui/transactions'
8
- import type { Network, LPToken } from '../consts'
8
+
9
+ import type { LPToken, Network } from '../consts'
9
10
  import type {
10
11
  IBaseDataAPI,
11
- IBaseMarketValuationInfo,
12
+ IBaseHistoryResponse,
12
13
  IBaseMarketInfo,
13
- IBaseVaultInfo,
14
- IBaseSymbolInfo,
15
- IBasePositionInfo,
16
- IBasePositionConfig,
17
- IBasePositionCapInfo,
18
- IBaseOrderInfo,
14
+ IBaseMarketValuationInfo,
19
15
  IBaseOrderCapInfo,
20
- IBaseHistoryResponse,
21
- IBaseStaked,
16
+ IBaseOrderInfo,
17
+ IBasePositionCapInfo,
18
+ IBasePositionConfig,
19
+ IBasePositionInfo,
22
20
  IBaseRebaseFeeModel,
23
- IBaseStakePool
21
+ IBaseStaked,
22
+ IBaseStakePool,
23
+ IBaseSymbolInfo,
24
+ IBaseVaultInfo,
24
25
  } from '../interfaces'
25
26
  import { OracleAPI } from '../oracle'
26
27
 
@@ -44,7 +45,7 @@ export abstract class BaseDataAPI extends OracleAPI implements IBaseDataAPI {
44
45
  provider: SuiClient,
45
46
  apiEndpoint: string,
46
47
  connectionURL: string,
47
- lpToken: LPToken
48
+ lpToken: LPToken,
48
49
  ) {
49
50
  super(network, provider, connectionURL, lpToken)
50
51
  this.provider = provider
@@ -135,7 +136,7 @@ export abstract class BaseDataAPI extends OracleAPI implements IBaseDataAPI {
135
136
  // Abstract methods that must be implemented by concrete classes
136
137
  public abstract valuateVaults(tx: Transaction): any
137
138
  public abstract valuateSymbols(tx: Transaction): any
138
- public abstract valuate(tx: Transaction): { vaultsValuation: any; symbolsValuation: any }
139
+ public abstract valuate(tx: Transaction): { vaultsValuation: any, symbolsValuation: any }
139
140
  public abstract valuateMarket(): Promise<IBaseMarketValuationInfo>
140
141
 
141
142
  public abstract fundingFeeRate(indexToken: string, long: boolean, sender?: string): Promise<number>
@@ -170,7 +171,8 @@ export abstract class BaseDataAPI extends OracleAPI implements IBaseDataAPI {
170
171
  throw new Error(`HTTP error! status: ${response.status}`)
171
172
  }
172
173
  return await response.json()
173
- } catch (error) {
174
+ }
175
+ catch (error) {
174
176
  console.error(`Error fetching data from ${endpoint}:`, error)
175
177
  throw error
176
178
  }
@@ -181,10 +183,10 @@ export abstract class BaseDataAPI extends OracleAPI implements IBaseDataAPI {
181
183
  */
182
184
  protected parseNumericValue(value: any, decimals = 0): number {
183
185
  if (typeof value === 'string') {
184
- return Number(value) / Math.pow(10, decimals)
186
+ return Number(value) / 10 ** decimals
185
187
  }
186
188
  if (typeof value === 'bigint') {
187
- return Number(value) / Math.pow(10, decimals)
189
+ return Number(value) / 10 ** decimals
188
190
  }
189
191
  return Number(value) || 0
190
192
  }
@@ -201,4 +203,4 @@ export abstract class BaseDataAPI extends OracleAPI implements IBaseDataAPI {
201
203
  }
202
204
  return BigInt(Number(value) || 0)
203
205
  }
204
- }
206
+ }
@@ -3,5 +3,5 @@
3
3
  * Provides common functionality and enforces interface contracts
4
4
  */
5
5
 
6
+ export { BaseAPI } from './BaseAPI'
6
7
  export { BaseDataAPI } from './BaseDataAPI'
7
- export { BaseAPI } from './BaseAPI'
package/src/api.ts CHANGED
@@ -62,10 +62,12 @@ export class API extends DataAPI {
62
62
  referralAddress = '',
63
63
  sender = '',
64
64
  ) => {
65
- let tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder))
65
+ let tx = new Transaction()
66
+ tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder), tx)
66
67
  if (referralAddress && !(await this.hasReferral(sender || ''))) {
67
68
  tx = await this.addReferral(referralAddress, tx)
68
69
  }
70
+
69
71
  const coinObject = this.#processCoins(tx, coin, coinObjects)
70
72
  const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
71
73
 
package/src/bcs.ts CHANGED
@@ -1,29 +1,29 @@
1
- import { bcs } from '@mysten/bcs';
1
+ import { bcs } from '@mysten/bcs'
2
2
 
3
- export const Rate = bcs.u128();
4
- export const Decimal = bcs.u256();
3
+ export const Rate = bcs.u128()
4
+ export const Decimal = bcs.u256()
5
5
 
6
6
  export const SDecimal = bcs.struct('SDecimal', {
7
7
  is_positive: bcs.bool(),
8
8
  value: bcs.u256(),
9
- });
9
+ })
10
10
 
11
11
  export const SRate = bcs.struct('SRate', {
12
12
  is_positive: bcs.bool(),
13
13
  value: bcs.u128(),
14
- });
14
+ })
15
15
 
16
16
  // Agg price
17
17
  export const AggPrice = bcs.struct('AggPrice', {
18
18
  price: bcs.u256(), // Decimal
19
19
  precision: bcs.u64(),
20
- });
20
+ })
21
21
 
22
22
  // Market
23
23
  export const VaultInfo = bcs.struct('VaultInfo', {
24
24
  price: AggPrice,
25
25
  value: bcs.u256(), // Decimal
26
- });
26
+ })
27
27
 
28
28
  export const VaultsValuation = bcs.struct('VaultsValuation', {
29
29
  timestamp: bcs.u64(),
@@ -34,7 +34,7 @@ export const VaultsValuation = bcs.struct('VaultsValuation', {
34
34
  })),
35
35
  total_weight: bcs.u256(), // Decimal
36
36
  value: bcs.u256(), // Decimal
37
- });
37
+ })
38
38
 
39
39
  export const SymbolsValuation = bcs.struct('SymbolsValuation', {
40
40
  timestamp: bcs.u64(),
@@ -42,4 +42,4 @@ export const SymbolsValuation = bcs.struct('SymbolsValuation', {
42
42
  lp_supply_amount: bcs.u256(), // Decimal
43
43
  handled: bcs.vector(bcs.string()), // vector<TypeName>
44
44
  value: SDecimal,
45
- });
45
+ })
@@ -524,56 +524,6 @@
524
524
  "module": "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS",
525
525
  "metadata": "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da"
526
526
  },
527
- "tsla": {
528
- "decimals": 8,
529
- "module": "0x18cf1190e41b499d47219f12e254e2161cd1971c3448c08ba11b55e4fa772dfd::tsla::TSLA",
530
- "metadata": "0xf7e12be1d762dd08cb8cfefdf08b3961433932f4924d3d27e9f6a9fdae2502a4"
531
- },
532
- "tlt": {
533
- "decimals": 8,
534
- "module": "0x7139bcd717ac62b46556fbb7108de847c9677bb0625c297a32cb29daf29ba193::tlt::TLT",
535
- "metadata": "0xab90698178ebc38c79794eeecb98300d23deb0ff441cfcbe2035ec2b56bdf075"
536
- },
537
- "meta": {
538
- "decimals": 8,
539
- "module": "0x9255515cc08520f7a5232ccd6ecc1c95798b8d85804a624752ddbab64e2abc4a::meta::META",
540
- "metadata": "0xe65fe0ab01272466b8bc4da1213429dba82f7ce79b98f62be2ffa4642e990eea"
541
- },
542
- "govt": {
543
- "decimals": 8,
544
- "module": "0x0e9ba9b5b517c0ee1b87bb31df86e782118e0dcab785f4070947bcc50804823c::govt::GOVT",
545
- "metadata": "0xc794a70bd9ba02630db2f7d1fafc3844a5dc20080fee4644a716f9091a950161"
546
- },
547
- "bonk": {
548
- "decimals": 5,
549
- "module": "0xaa9f5bbfb58a9028cad0f21f4231eebc486bf1b84db4ebf9ba347db53840e2d5::bonk::BONK",
550
- "metadata": "0x15f1643eccb274c1cffcb0df1ef12b9e87002594526f73245dd90e9b12c92300"
551
- },
552
- "aapl": {
553
- "decimals": 8,
554
- "module": "0x598aac960ae94f03a2c3c586412d39655e37805daf821b0fd176f05504e47e2d::aapl::AAPL",
555
- "metadata": "0xe05fcbe26d4a402b606055d4dcb311cd9c1d188494b1c054a398371465081a6b"
556
- },
557
- "coin": {
558
- "decimals": 8,
559
- "module": "0x1cad399b1e42c6a5229ed99189bb70ff5fce3ebe708b4a6b5714cad1bca7f7cc::coin::COIN",
560
- "metadata": "0x8701bfff9b10dd4ba5de8cf076a9581b5ab9c152fb9681e3ef73b5c08a7b83bb"
561
- },
562
- "mstr": {
563
- "decimals": 8,
564
- "module": "0x32ad457a75d8139943ca070c606cc0ea525ec0ac35d110994038f5fec89bfc4::mstr::MSTR",
565
- "metadata": "0xc114382883f82a0d33fb37efabb9368daf52b3e11a52558a69b338fd272f9140"
566
- },
567
- "nvda": {
568
- "decimals": 8,
569
- "module": "0x57ac28c140a6cdb704d06c681b65734ce380a49e4a5490073afb4098744bc3be::nvda::NVDA",
570
- "metadata": "0x0152500904d8f7bd43aa3b98336bee4a2e98f5c5baa903ac0134736ad919ead0"
571
- },
572
- "navx": {
573
- "decimals": 9,
574
- "module": "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
575
- "metadata": "0xdc0e051f8aab62d5ba1816bb7a03097faeccb7546c958da571d48882fd8dd0cd"
576
- },
577
527
  "tia": {
578
528
  "decimals": 6,
579
529
  "module": "0x2593cf48cd5989969c6dce24e068fd4f5bd9d9b3f97dbc3c8f4a012a7a24d7c1::tia::TIA",
@@ -584,16 +534,6 @@
584
534
  "module": "0x0791c4cacb3314fb222171450742d0cb70d804924acabd8a486f4d56cc23bebd::w::W",
585
535
  "metadata": "0xe6cc22cd66e2e2fa856f261d1e3be5e5dce8a1e90b0de2fbc41c6320a8f00324"
586
536
  },
587
- "amc": {
588
- "decimals": 8,
589
- "module": "0x2fc5e4eae2142815592cc1ef431a4cced43695ed4b9e20d5229c15dff56c3159::amc::AMC",
590
- "metadata": "0x263ade9adb6ef94f561d401bb44f4168bde306b3c75e1e14158ea58a608c43cc"
591
- },
592
- "gme": {
593
- "decimals": 8,
594
- "module": "0x22ddfddc6229f20f14eb587cc27a9815b4e626c485fb02abfaf087333a1827da::gme::GME",
595
- "metadata": "0xfeb41e43761b4bb068eab6ed0e3851488892b3438fc8e646534a13615fd6284e"
596
- },
597
537
  "afSui": {
598
538
  "decimals": 9,
599
539
  "module": "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI",
@@ -604,11 +544,6 @@
604
544
  "module": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT",
605
545
  "metadata": "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd"
606
546
  },
607
- "fud": {
608
- "decimals": 5,
609
- "module": "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD",
610
- "metadata": "0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e"
611
- },
612
547
  "buck": {
613
548
  "decimals": 9,
614
549
  "module": "0xce7ff77a83ea0cb6fd39bd8748e2ec89a3f41e8efdc3f4eb123e0ca37b184db2::buck::BUCK",
@@ -664,11 +599,6 @@
664
599
  "module": "0xbac9a286efdb3520c76c2cbff789ad42c0834c857c3a249915b10d8b5bf8afac::trump::TRUMP",
665
600
  "metadata": "0xdea3d7c4b12833a89edd5f04921e800a6e34f9e8256dc514979855d5084212ba"
666
601
  },
667
- "melania": {
668
- "decimals": 6,
669
- "module": "0x4fd81bee7b8e550aa25f8cceef1e29dc7390b2bf318e262509586a4a534c648e::melania::MELANIA",
670
- "metadata": "0xe21acd598f6f4275d961e2712493127cab7697f4bc04066385d021221ffb061f"
671
- },
672
602
  "ns": {
673
603
  "decimals": 6,
674
604
  "module": "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS",