zo-sdk 0.0.4 → 0.0.5

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/.gitattributes +4 -0
  2. package/.prettierrc.js +5 -0
  3. package/babel.config.js +11 -0
  4. package/dist/api.cjs +466 -0
  5. package/dist/api.d.cts +26 -0
  6. package/dist/api.d.cts.map +1 -0
  7. package/dist/api.d.mts +26 -0
  8. package/dist/api.d.mts.map +1 -0
  9. package/dist/api.mjs +462 -0
  10. package/dist/consts/deployments-mainnet.json +28 -0
  11. package/dist/consts/deployments-testnet.json +93 -0
  12. package/dist/consts/index.cjs +101 -0
  13. package/dist/consts/index.d.cts +66 -0
  14. package/dist/consts/index.d.cts.map +1 -0
  15. package/dist/consts/index.d.mts +66 -0
  16. package/dist/consts/index.d.mts.map +1 -0
  17. package/dist/consts/index.mjs +94 -0
  18. package/dist/consts/price_id_to_object_id.mainnet.json +1 -0
  19. package/dist/consts/price_id_to_object_id.testnet.json +17 -0
  20. package/dist/consts/staking/deployments-mainnet.json +12 -0
  21. package/dist/consts/staking/deployments-testnet.json +11 -0
  22. package/dist/data.cjs +844 -0
  23. package/dist/data.d.cts +221 -0
  24. package/dist/data.d.cts.map +1 -0
  25. package/dist/data.d.mts +221 -0
  26. package/dist/data.d.mts.map +1 -0
  27. package/dist/data.mjs +840 -0
  28. package/dist/index.cjs +21 -0
  29. package/dist/index.d.cts +6 -0
  30. package/dist/index.d.cts.map +1 -0
  31. package/dist/index.d.mts +6 -0
  32. package/dist/index.d.mts.map +1 -0
  33. package/dist/index.mjs +5 -0
  34. package/dist/oracle.cjs +178 -0
  35. package/dist/oracle.d.cts +24 -0
  36. package/dist/oracle.d.cts.map +1 -0
  37. package/dist/oracle.d.mts +24 -0
  38. package/dist/oracle.d.mts.map +1 -0
  39. package/dist/oracle.mjs +173 -0
  40. package/dist/utils.cjs +144 -0
  41. package/dist/utils.d.cts +46 -0
  42. package/dist/utils.d.cts.map +1 -0
  43. package/dist/utils.d.mts +46 -0
  44. package/dist/utils.d.mts.map +1 -0
  45. package/dist/utils.mjs +129 -0
  46. package/package.json +3 -2
package/dist/api.mjs ADDED
@@ -0,0 +1,462 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _API_instances, _API_processCoins, _API_processSlippage;
7
+ import { Transaction } from "@mysten/sui/transactions";
8
+ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
9
+ import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE } from "./consts/index.mjs";
10
+ import { DataAPI } from "./data.mjs";
11
+ import { joinSymbol } from "./utils.mjs";
12
+ export class API extends DataAPI {
13
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
14
+ constructor(network, provider, apiEndpoint, connectionURL) {
15
+ super(network, provider, apiEndpoint, connectionURL);
16
+ _API_instances.add(this);
17
+ _API_processCoins.set(this, (tx, coin, coinObjects) => {
18
+ if (coin === 'sui') {
19
+ return tx.gas;
20
+ }
21
+ if (coinObjects.length > 1) {
22
+ tx.mergeCoins(tx.object(coinObjects[0]), coinObjects.slice(1).map(coinObject => tx.object(coinObject)));
23
+ }
24
+ return tx.object(coinObjects[0]);
25
+ });
26
+ Object.defineProperty(this, "deposit", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: async (coin, coinObjects, amount, minAmountOut = 0) => {
31
+ const tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder));
32
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, coin, coinObjects);
33
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)]);
34
+ const { vaultsValuation, symbolsValuation, } = this.valuate(tx);
35
+ tx.moveCall({
36
+ target: `${this.consts.zoCore.package}::market::deposit`,
37
+ typeArguments: [
38
+ `${this.consts.zoCore.package}::zlp::ZLP`,
39
+ this.consts.coins[coin].module,
40
+ ],
41
+ arguments: [
42
+ tx.object(this.consts.zoCore.market),
43
+ tx.object(this.consts.zoCore.rebaseFeeModel),
44
+ depositObject,
45
+ tx.pure.u64(minAmountOut),
46
+ vaultsValuation,
47
+ symbolsValuation,
48
+ ],
49
+ });
50
+ return tx;
51
+ }
52
+ });
53
+ Object.defineProperty(this, "withdraw", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: async (coin, zlpCoinObjects, amount, minAmountOut = 0) => {
58
+ const tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder));
59
+ const zlpCoinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, 'zlp', zlpCoinObjects);
60
+ const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)]);
61
+ const { vaultsValuation, symbolsValuation, } = this.valuate(tx);
62
+ tx.moveCall({
63
+ target: `${this.consts.zoCore.package}::market::withdraw`,
64
+ typeArguments: [
65
+ `${this.consts.zoCore.package}::zlp::ZLP`,
66
+ this.consts.coins[coin].module,
67
+ ],
68
+ arguments: [
69
+ tx.object(this.consts.zoCore.market),
70
+ tx.object(this.consts.zoCore.rebaseFeeModel),
71
+ withdrawObject,
72
+ tx.pure.u64(minAmountOut),
73
+ vaultsValuation,
74
+ symbolsValuation,
75
+ ],
76
+ });
77
+ return tx;
78
+ }
79
+ });
80
+ Object.defineProperty(this, "openPosition", {
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true,
84
+ value: async (collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, slippage = 0.003, isLimitOrder = false, isIocOrder = false, relayerFee = BigInt(1), referralAddress = '', sender = '') => {
85
+ let tx = new Transaction();
86
+ if (referralAddress && !await this.hasReferral(sender || '')) {
87
+ tx = await this.addReferral(referralAddress, tx);
88
+ }
89
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx);
90
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, collateralToken, coinObjects);
91
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(collateralAmount)]);
92
+ const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]);
93
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
94
+ const adjustPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, indexPrice, long, isLimitOrder ? 0 : slippage);
95
+ const adjustCollateralPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, collateralPrice, false, 0.5);
96
+ let allowTrade = ALLOW_TRADE_MUST_TRADE;
97
+ if (isLimitOrder) {
98
+ allowTrade = isIocOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
99
+ }
100
+ tx.moveCall({
101
+ target: `${this.consts.zoCore.package}::market::open_position`,
102
+ typeArguments: [
103
+ `${this.consts.zoCore.package}::zlp::ZLP`,
104
+ this.consts.coins[collateralToken].module,
105
+ this.consts.coins[indexToken].module,
106
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
107
+ this.consts.coins.sui.module,
108
+ ],
109
+ arguments: [
110
+ tx.object(SUI_CLOCK_OBJECT_ID),
111
+ tx.object(this.consts.zoCore.market),
112
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
113
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
114
+ tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
115
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
116
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
117
+ depositObject,
118
+ feeObject,
119
+ tx.pure.u8(allowTrade),
120
+ tx.pure.u64(size),
121
+ tx.pure.u64(reserveAmount),
122
+ tx.pure.u256(adjustCollateralPrice),
123
+ tx.pure.u256(adjustPrice),
124
+ ],
125
+ });
126
+ return tx;
127
+ }
128
+ });
129
+ Object.defineProperty(this, "pledgeInPosition", {
130
+ enumerable: true,
131
+ configurable: true,
132
+ writable: true,
133
+ value: async (pcpId, collateralToken, indexToken, amount, coinObjects, long) => {
134
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
135
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, collateralToken, coinObjects);
136
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)]);
137
+ tx.moveCall({
138
+ target: `${this.consts.zoCore.package}::market::pledge_in_position`,
139
+ typeArguments: [
140
+ `${this.consts.zoCore.package}::zlp::ZLP`,
141
+ this.consts.coins[collateralToken].module,
142
+ this.consts.coins[indexToken].module,
143
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
144
+ ],
145
+ arguments: [
146
+ tx.object(this.consts.zoCore.market),
147
+ tx.object(pcpId),
148
+ depositObject,
149
+ ],
150
+ });
151
+ return tx;
152
+ }
153
+ });
154
+ Object.defineProperty(this, "redeemFromPosition", {
155
+ enumerable: true,
156
+ configurable: true,
157
+ writable: true,
158
+ value: async (pcpId, collateralToken, indexToken, amount, long) => {
159
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
160
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
161
+ tx.moveCall({
162
+ target: `${this.consts.zoCore.package}::market::redeem_from_position`,
163
+ typeArguments: [
164
+ `${this.consts.zoCore.package}::zlp::ZLP`,
165
+ this.consts.coins[collateralToken].module,
166
+ this.consts.coins[indexToken].module,
167
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
168
+ ],
169
+ arguments: [
170
+ tx.object(SUI_CLOCK_OBJECT_ID),
171
+ tx.object(this.consts.zoCore.market),
172
+ tx.object(pcpId),
173
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
174
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
175
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
176
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
177
+ tx.pure.u64(amount),
178
+ ],
179
+ });
180
+ return tx;
181
+ }
182
+ });
183
+ Object.defineProperty(this, "decreasePosition", {
184
+ enumerable: true,
185
+ configurable: true,
186
+ writable: true,
187
+ value: async (pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, slippage = 0.003, relayerFee = BigInt(1)) => {
188
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
189
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
190
+ const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]);
191
+ const adjustPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, indexPrice, !long, isTriggerOrder ? 0 : slippage);
192
+ const adjustCollateralPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, collateralPrice, false, 0.5);
193
+ let allowTrade = ALLOW_TRADE_MUST_TRADE;
194
+ if (isTriggerOrder) {
195
+ allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
196
+ }
197
+ else {
198
+ isTakeProfitOrder = true;
199
+ }
200
+ /* console.log('isTriggerOrder:', isTriggerOrder)
201
+ console.log('isIocOrder:', isIocOrder)
202
+ console.log('isTakeProfitOrder:', isTakeProfitOrder)
203
+ console.log('adjustPrice:', adjustPrice)
204
+ console.log('allowTrade:', allowTrade)
205
+ console.log('isTriggerOrder:', isTriggerOrder)
206
+ console.log('isTakeProfitOrder:', isTakeProfitOrder) */
207
+ tx.moveCall({
208
+ target: `${this.consts.zoCore.package}::market::decrease_position`,
209
+ typeArguments: [
210
+ `${this.consts.zoCore.package}::zlp::ZLP`,
211
+ this.consts.coins[collateralToken].module,
212
+ this.consts.coins[indexToken].module,
213
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
214
+ this.consts.coins.sui.module,
215
+ ],
216
+ arguments: [
217
+ tx.object(SUI_CLOCK_OBJECT_ID),
218
+ tx.object(this.consts.zoCore.market),
219
+ tx.object(pcpId),
220
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
221
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
222
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
223
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
224
+ feeObject,
225
+ tx.pure.u8(allowTrade),
226
+ tx.pure.bool(isTakeProfitOrder),
227
+ tx.pure.u64(amount),
228
+ tx.pure.u256(adjustCollateralPrice),
229
+ tx.pure.u256(adjustPrice),
230
+ ],
231
+ });
232
+ return tx;
233
+ }
234
+ });
235
+ Object.defineProperty(this, "cancelOrder", {
236
+ enumerable: true,
237
+ configurable: true,
238
+ writable: true,
239
+ value: (orderCapId, collateralToken, indexToken, long, type, isV11Order = false) => {
240
+ const tx = new Transaction();
241
+ let functionName = '';
242
+ switch (type) {
243
+ case 'OPEN_POSITION': {
244
+ functionName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
245
+ break;
246
+ }
247
+ case 'DECREASE_POSITION': {
248
+ functionName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order';
249
+ break;
250
+ }
251
+ default: {
252
+ throw new Error('invalid order type');
253
+ }
254
+ }
255
+ tx.moveCall({
256
+ target: `${this.consts.zoCore.package}::market::${functionName}`,
257
+ typeArguments: [
258
+ `${this.consts.zoCore.package}::zlp::ZLP`,
259
+ this.consts.coins[collateralToken].module,
260
+ this.consts.coins[indexToken].module,
261
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
262
+ this.consts.coins.sui.module,
263
+ ],
264
+ arguments: [
265
+ tx.object(this.consts.zoCore.market),
266
+ tx.object(orderCapId),
267
+ ],
268
+ });
269
+ return tx;
270
+ }
271
+ });
272
+ Object.defineProperty(this, "swap", {
273
+ enumerable: true,
274
+ configurable: true,
275
+ writable: true,
276
+ value: async (fromToken, toToken, fromAmount, fromCoinObjects) => {
277
+ const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults));
278
+ const fromCoinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, fromToken, fromCoinObjects);
279
+ const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)]);
280
+ const vaultsValuation = this.valuateVaults(tx);
281
+ tx.moveCall({
282
+ target: `${this.consts.zoCore.package}::market::swap`,
283
+ typeArguments: [
284
+ `${this.consts.zoCore.package}::zlp::ZLP`,
285
+ this.consts.coins[fromToken].module,
286
+ this.consts.coins[toToken].module,
287
+ ],
288
+ arguments: [
289
+ tx.object(this.consts.zoCore.market),
290
+ tx.object(this.consts.zoCore.rebaseFeeModel),
291
+ fromDepositObject,
292
+ // FIXME: minAmountOut
293
+ tx.pure.u64(0),
294
+ vaultsValuation,
295
+ ],
296
+ });
297
+ return tx;
298
+ }
299
+ });
300
+ Object.defineProperty(this, "clearClosedPosition", {
301
+ enumerable: true,
302
+ configurable: true,
303
+ writable: true,
304
+ value: (pcpId, collateralToken, indexToken, long, tx) => {
305
+ tx.moveCall({
306
+ target: `${this.consts.zoCore.package}::market::clear_closed_position`,
307
+ typeArguments: [
308
+ `${this.consts.zoCore.package}::zlp::ZLP`,
309
+ this.consts.coins[collateralToken].module,
310
+ this.consts.coins[indexToken].module,
311
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
312
+ ],
313
+ arguments: [
314
+ tx.object(this.consts.zoCore.market),
315
+ tx.object(pcpId),
316
+ ],
317
+ });
318
+ }
319
+ });
320
+ Object.defineProperty(this, "clearOpenPositionOrder", {
321
+ enumerable: true,
322
+ configurable: true,
323
+ writable: true,
324
+ value: (orderCapId, collateralToken, indexToken, long, tx, isV11Order = false) => {
325
+ const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
326
+ tx.moveCall({
327
+ target: `${this.consts.zoCore.package}::market::${funcName}`,
328
+ typeArguments: [
329
+ `${this.consts.zoCore.package}::zlp::ZLP`,
330
+ this.consts.coins[collateralToken].module,
331
+ this.consts.coins[indexToken].module,
332
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
333
+ this.consts.coins.sui.module,
334
+ ],
335
+ arguments: [
336
+ tx.object(this.consts.zoCore.market),
337
+ tx.object(orderCapId),
338
+ ],
339
+ });
340
+ }
341
+ });
342
+ Object.defineProperty(this, "clearDecreasePositionOrder", {
343
+ enumerable: true,
344
+ configurable: true,
345
+ writable: true,
346
+ value: (orderCapId, collateralToken, indexToken, long, tx, isV11Order = false) => {
347
+ const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order';
348
+ tx.moveCall({
349
+ target: `${this.consts.zoCore.package}::market::${funcName}`,
350
+ typeArguments: [
351
+ `${this.consts.zoCore.package}::zlp::ZLP`,
352
+ this.consts.coins[collateralToken].module,
353
+ this.consts.coins[indexToken].module,
354
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
355
+ this.consts.coins.sui.module,
356
+ ],
357
+ arguments: [
358
+ tx.object(this.consts.zoCore.market),
359
+ tx.object(orderCapId),
360
+ ],
361
+ });
362
+ }
363
+ });
364
+ Object.defineProperty(this, "stake", {
365
+ enumerable: true,
366
+ configurable: true,
367
+ writable: true,
368
+ value: (coinObjects, amount, pool, tx) => {
369
+ if (!tx) {
370
+ tx = new Transaction();
371
+ }
372
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, 'zlp', coinObjects);
373
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)]);
374
+ tx.moveCall({
375
+ target: `${this.consts.zoStaking.package}::pool::deposit`,
376
+ typeArguments: [
377
+ `${this.consts.zoCore.package}::zlp::ZLP`,
378
+ this.consts.coins.sui.module,
379
+ ],
380
+ arguments: [
381
+ tx.object(pool),
382
+ tx.object(SUI_CLOCK_OBJECT_ID),
383
+ depositObject,
384
+ ],
385
+ });
386
+ return tx;
387
+ }
388
+ });
389
+ Object.defineProperty(this, "unstake", {
390
+ enumerable: true,
391
+ configurable: true,
392
+ writable: true,
393
+ value: (credentials, amount, pool, tx) => {
394
+ if (!tx) {
395
+ tx = new Transaction();
396
+ }
397
+ for (const credential of credentials) {
398
+ // eslint-disable-next-line unicorn/prefer-math-min-max
399
+ const withdrawAmount = amount < credential.amount ? amount : credential.amount;
400
+ amount -= withdrawAmount;
401
+ tx.moveCall({
402
+ target: `0xdb353cb79a88d5ee83b7c0ca0249662a1facab17ba62879080ea3d61b9d21112::pool::withdraw`,
403
+ typeArguments: [
404
+ `${this.consts.zoCore.package}::zlp::ZLP`,
405
+ this.consts.coins.sui.module,
406
+ ],
407
+ arguments: [
408
+ tx.object(pool),
409
+ tx.object(SUI_CLOCK_OBJECT_ID),
410
+ tx.object(credential.id),
411
+ tx.pure.u64(withdrawAmount),
412
+ ],
413
+ });
414
+ if (credential.amount === BigInt(0)) {
415
+ tx.moveCall({
416
+ target: `${this.consts.zoStaking.package}::pool::clear_empty_credential`,
417
+ typeArguments: [
418
+ `${this.consts.zoCore.package}::zlp::ZLP`,
419
+ this.consts.coins.sui.module,
420
+ ],
421
+ arguments: [
422
+ tx.object(credential.id),
423
+ ],
424
+ });
425
+ }
426
+ }
427
+ return tx;
428
+ }
429
+ });
430
+ Object.defineProperty(this, "addReferral", {
431
+ enumerable: true,
432
+ configurable: true,
433
+ writable: true,
434
+ value: (referrer, tx) => {
435
+ if (!tx) {
436
+ tx = new Transaction();
437
+ }
438
+ tx.moveCall({
439
+ target: `${this.consts.zoCore.package}::market::add_new_referral`,
440
+ typeArguments: [
441
+ `${this.consts.zoCore.package}::zlp::ZLP`,
442
+ ],
443
+ arguments: [
444
+ tx.object(this.consts.zoCore.market),
445
+ tx.object(referrer),
446
+ ],
447
+ });
448
+ return tx;
449
+ }
450
+ });
451
+ }
452
+ static getInstance(network, provider, apiEndpoint, connectionURL) {
453
+ if (!API.instance) {
454
+ API.instance = new API(network, provider, apiEndpoint, connectionURL);
455
+ }
456
+ return API.instance;
457
+ }
458
+ }
459
+ _API_processCoins = new WeakMap(), _API_instances = new WeakSet(), _API_processSlippage = function _API_processSlippage(indexPrice, long, slippage) {
460
+ const raw = long ? (indexPrice * (1 + slippage)) : (indexPrice * (1 - slippage));
461
+ return BigInt(Math.round(raw * 1e18));
462
+ };
@@ -0,0 +1,28 @@
1
+ {
2
+ "zo_core": {
3
+ "package": "",
4
+ "upgrade_cap": "",
5
+ "admin_cap": "",
6
+ "market": "",
7
+ "zlp_metadata": "",
8
+ "rebase_fee_model": "",
9
+ "referrals_parent": "",
10
+ "vaults_parent": "",
11
+ "symbols_parent": "",
12
+ "positions_parent": "",
13
+ "orders_parent": "",
14
+ "vaults": {},
15
+ "symbols": {}
16
+ },
17
+ "pyth_feeder": {
18
+ "package": "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e",
19
+ "package_v2": "0x04e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91",
20
+ "state": "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
21
+ "wormhole": {
22
+ "package": "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
23
+ "state": "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
24
+ },
25
+ "feeder": {}
26
+ },
27
+ "coins": {}
28
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "zo_core": {
3
+ "package": "0xa7d1d1f3a8346753674223473f6b71d6c8a6ca9475da0501368f57bb6d35cc0b",
4
+ "upgrade_cap": "0x7f6bb9305da4d35576be0ffd3b56c0085db46ba4b7ce8c0022f65b683c5ad5b4",
5
+ "admin_cap": "0x2d2ef02c1fd1ba0baf144e9f7a9d7365d50dff34e6f249be0e23ad01d7a1d700",
6
+ "market": "0xf6fb5acc78a6c85bfca39719088a7ac74ab199a58097bf8fe79df75ec5f535d1",
7
+ "zlp_metadata": "0xeb6eb4bd199cd4c0699855a5337fef75df05e0ee728ed507fed7041ecd8ed910",
8
+ "rebase_fee_model": "0x285d0c1f21858db319481ae35e1d6ad735c3176df7c3eef9b95b8deed24faf7d",
9
+ "referrals_parent": "0xcf63fb9086d2f3ed710d980f48da4443144225f1024f48debeba638072998345",
10
+ "vaults_parent": "0xa1ed162b3b9c545d2cc46224750bf76e22f55a12ddedc8eacd685930f1287da6",
11
+ "symbols_parent": "0xc73cc19cb9df994db7859638373279f678f7e837ba3f29f0e54029bcc9f7f376",
12
+ "positions_parent": "0x70c9c9cb6cfe9da0c730553a22281cb9c44c647d6a0d60a656b73e27eb08497d",
13
+ "orders_parent": "0xc62365fb575103f559c147fcac8379760faf68d91914e4e0ac296fbeb78c2905",
14
+ "vaults": {
15
+ "usdt": {
16
+ "weight": "1000000000000000000",
17
+ "reserving_fee_model": "0x095aa141f72af6045b0691773ca1da621bdd50de048f78226190627521c6bb99"
18
+ }
19
+ },
20
+ "symbols": {
21
+ "long_btc": {
22
+ "supported_collaterals": [
23
+ "usdt"
24
+ ],
25
+ "funding_fee_model": "0x13e2cf849c6bcbec5c2d95897359e956612dbfd9f6eac0f2f46f9954e725118a",
26
+ "position_config": "0x6a02e6e75dba447d7c2f59ac26ce94d33039a45c07b0180e50d0e67bb1ad3f43"
27
+ },
28
+ "short_btc": {
29
+ "supported_collaterals": [
30
+ "usdt"
31
+ ],
32
+ "funding_fee_model": "0x5a5ca35b5c6e997cff46b24137353d2df70365d801cab47f45eab113193a138f",
33
+ "position_config": "0x65b1d0f4f4c4d60e3f4670331f145d70f90cf3558280bc207dc369f38c8b40bb"
34
+ },
35
+ "long_eth": {
36
+ "supported_collaterals": [
37
+ "usdt"
38
+ ],
39
+ "funding_fee_model": "0xffcf6a37a465feff40e2f003dfb9c75875d9c66da520be8ab71a787af4d15fe9",
40
+ "position_config": "0x8fd32f908c4810d51cb088a5b147d5a5e0e463db252dbffc2fed8578077de35c"
41
+ },
42
+ "short_eth": {
43
+ "supported_collaterals": [
44
+ "usdt"
45
+ ],
46
+ "funding_fee_model": "0xe0a3468419ef07a4ec1a564b32971bdd301fb8a5a900b98280074d13914f0ec0",
47
+ "position_config": "0x1f499a262fa1d30c8177b2f887f2f5423ab4c33d9a5954606739743336673dac"
48
+ }
49
+ }
50
+ },
51
+ "pyth_feeder": {
52
+ "package": "0xabf837e98c26087cba0883c0a7a28326b1fa3c5e1e2c5abdb486f9e8f594c837",
53
+ "state": "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c",
54
+ "wormhole": {
55
+ "package": "0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94",
56
+ "state": "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790"
57
+ },
58
+ "feeder": {
59
+ "btc": "0x72431a238277695d3f31e4425225a4462674ee6cceeea9d66447b210755fffba",
60
+ "sui": "0x1ebb295c789cc42b3b2a1606482cd1c7124076a0f5676718501fda8c7fd075a0",
61
+ "eth": "0x4fde30cb8a5dc3cfee1c1c358fc66dc308408827efb217247c7ba54d76ccbee9",
62
+ "sol": "0x33fbce1cad5ca155f2f5051430b23a694bc6e5de6df43e0f8aefe29f4a84336d",
63
+ "usdt": "0x956fdcbf83a26c962319f7742f5728a0a7ce59c7f0cbe13c112b259e7ee953cd"
64
+ }
65
+ },
66
+ "coins": {
67
+ "sui": {
68
+ "decimals": 9,
69
+ "module": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
70
+ "metadata": "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3"
71
+ },
72
+ "btc": {
73
+ "decimals": 6,
74
+ "module": "0x997965ea613857d34f13511fbe27f94728ab079615cd083ed24aef70516ab2e4::btc::BTC",
75
+ "metadata": "0xca50f9e2bae829ee73dc5079d3882298070b7b36451ec35f9455947163b4854e"
76
+ },
77
+ "eth": {
78
+ "decimals": 9,
79
+ "module": "0x0d3dd3ff9950dfbe34c52dbb552c36b618a3263f20f84309c9dfef7e140b6301::eth::ETH",
80
+ "metadata": "0x009c984d2d0c3afac3a598fd1ce77bb93740e8948e9665c7a7fe24046e129313"
81
+ },
82
+ "sol": {
83
+ "decimals": 9,
84
+ "module": "0x7eb2d1737cf4901218956dbd798f461a2606792da2df87b3c670e364ced35ce7::sol::SOL",
85
+ "metadata": "0xf77d6b54b007e45ea17ad9fa41821649e9ee16a9b14d3aabc2bb07b7874a90e9"
86
+ },
87
+ "usdt": {
88
+ "decimals": 6,
89
+ "module": "0x8684c115c57c725a832abe63b5cfa7268b77126a8a7a52883f602e5513c9de2d::usdt::USDT",
90
+ "metadata": "0xac3fcd1e6d7bd32d33afb1a0864b05b0adefeaddb2933ead5d5df1af21b1b741"
91
+ }
92
+ }
93
+ }