zo-sdk 0.0.12 → 0.0.14

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 (54) hide show
  1. package/dist/api.cjs +469 -0
  2. package/dist/{api.d.ts → api.d.cts} +6 -5
  3. package/dist/api.d.cts.map +1 -0
  4. package/dist/api.d.mts +26 -0
  5. package/dist/api.d.mts.map +1 -0
  6. package/dist/api.mjs +465 -0
  7. package/dist/consts/deployments-mainnet.json +87 -15
  8. package/dist/consts/deployments-testnet.json +23 -23
  9. package/dist/consts/{index.js → index.cjs} +8 -12
  10. package/dist/consts/{index.d.ts → index.d.cts} +1 -0
  11. package/dist/consts/index.d.cts.map +1 -0
  12. package/dist/consts/index.d.mts +66 -0
  13. package/dist/consts/index.d.mts.map +1 -0
  14. package/dist/consts/index.mjs +92 -0
  15. package/dist/consts/price_id_to_object_id.mainnet.json +8 -1
  16. package/dist/{data.js → data.cjs} +246 -155
  17. package/dist/{data.d.ts → data.d.cts} +9 -8
  18. package/dist/data.d.cts.map +1 -0
  19. package/dist/data.d.mts +221 -0
  20. package/dist/data.d.mts.map +1 -0
  21. package/dist/data.mjs +841 -0
  22. package/dist/{index.js → index.cjs} +5 -6
  23. package/dist/index.d.cts +6 -0
  24. package/dist/index.d.cts.map +1 -0
  25. package/dist/index.d.mts +6 -0
  26. package/dist/index.d.mts.map +1 -0
  27. package/dist/index.mjs +5 -0
  28. package/dist/{oracle.js → oracle.cjs} +51 -8
  29. package/dist/{oracle.d.ts → oracle.d.cts} +7 -6
  30. package/dist/oracle.d.cts.map +1 -0
  31. package/dist/oracle.d.mts +24 -0
  32. package/dist/oracle.d.mts.map +1 -0
  33. package/dist/oracle.mjs +173 -0
  34. package/dist/{utils.js → utils.cjs} +1 -2
  35. package/dist/{utils.d.ts → utils.d.cts} +5 -4
  36. package/dist/utils.d.cts.map +1 -0
  37. package/dist/utils.d.mts +46 -0
  38. package/dist/utils.d.mts.map +1 -0
  39. package/dist/utils.mjs +128 -0
  40. package/package.json +23 -13
  41. package/src/consts/deployments-mainnet.json +87 -15
  42. package/src/consts/deployments-testnet.json +23 -23
  43. package/src/consts/index.ts +1 -1
  44. package/src/consts/price_id_to_object_id.mainnet.json +8 -1
  45. package/tsconfig.json +19 -9
  46. package/babel.config.js +0 -11
  47. package/dist/api.js +0 -400
  48. package/dist/api.js.map +0 -1
  49. package/dist/consts/index.js.map +0 -1
  50. package/dist/data.js.map +0 -1
  51. package/dist/index.d.ts +0 -5
  52. package/dist/index.js.map +0 -1
  53. package/dist/oracle.js.map +0 -1
  54. package/dist/utils.js.map +0 -1
package/dist/api.mjs ADDED
@@ -0,0 +1,465 @@
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, feeObject] = tx.splitCoins(coinObject, [
92
+ tx.pure.u64(collateralAmount),
93
+ tx.pure.u64(relayerFee)
94
+ ]);
95
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
96
+ const adjustPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, indexPrice, long, isLimitOrder ? 0 : slippage);
97
+ const adjustCollateralPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, collateralPrice, false, 0.5);
98
+ let allowTrade = ALLOW_TRADE_MUST_TRADE;
99
+ if (isLimitOrder) {
100
+ allowTrade = isIocOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
101
+ }
102
+ tx.moveCall({
103
+ target: `${this.consts.zoCore.package}::market::open_position`,
104
+ typeArguments: [
105
+ `${this.consts.zoCore.package}::zlp::ZLP`,
106
+ this.consts.coins[collateralToken].module,
107
+ this.consts.coins[indexToken].module,
108
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
109
+ this.consts.coins[collateralToken].module,
110
+ ],
111
+ arguments: [
112
+ tx.object(SUI_CLOCK_OBJECT_ID),
113
+ tx.object(this.consts.zoCore.market),
114
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
115
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
116
+ tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
117
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
118
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
119
+ depositObject,
120
+ feeObject,
121
+ tx.pure.u8(allowTrade),
122
+ tx.pure.u64(size),
123
+ tx.pure.u64(reserveAmount),
124
+ tx.pure.u256(adjustCollateralPrice),
125
+ tx.pure.u256(adjustPrice),
126
+ ],
127
+ });
128
+ return tx;
129
+ }
130
+ });
131
+ Object.defineProperty(this, "pledgeInPosition", {
132
+ enumerable: true,
133
+ configurable: true,
134
+ writable: true,
135
+ value: async (pcpId, collateralToken, indexToken, amount, coinObjects, long) => {
136
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
137
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, collateralToken, coinObjects);
138
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)]);
139
+ tx.moveCall({
140
+ target: `${this.consts.zoCore.package}::market::pledge_in_position`,
141
+ typeArguments: [
142
+ `${this.consts.zoCore.package}::zlp::ZLP`,
143
+ this.consts.coins[collateralToken].module,
144
+ this.consts.coins[indexToken].module,
145
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
146
+ ],
147
+ arguments: [
148
+ tx.object(this.consts.zoCore.market),
149
+ tx.object(pcpId),
150
+ depositObject,
151
+ ],
152
+ });
153
+ return tx;
154
+ }
155
+ });
156
+ Object.defineProperty(this, "redeemFromPosition", {
157
+ enumerable: true,
158
+ configurable: true,
159
+ writable: true,
160
+ value: async (pcpId, collateralToken, indexToken, amount, long) => {
161
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
162
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
163
+ tx.moveCall({
164
+ target: `${this.consts.zoCore.package}::market::redeem_from_position`,
165
+ typeArguments: [
166
+ `${this.consts.zoCore.package}::zlp::ZLP`,
167
+ this.consts.coins[collateralToken].module,
168
+ this.consts.coins[indexToken].module,
169
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
170
+ ],
171
+ arguments: [
172
+ tx.object(SUI_CLOCK_OBJECT_ID),
173
+ tx.object(this.consts.zoCore.market),
174
+ tx.object(pcpId),
175
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
176
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
177
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
178
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
179
+ tx.pure.u64(amount),
180
+ ],
181
+ });
182
+ return tx;
183
+ }
184
+ });
185
+ Object.defineProperty(this, "decreasePosition", {
186
+ enumerable: true,
187
+ configurable: true,
188
+ writable: true,
189
+ value: async (pcpId, collateralToken, coinObjects, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, slippage = 0.003, relayerFee = BigInt(1)) => {
190
+ const tx = await this.initOracleTxb([collateralToken, indexToken]);
191
+ const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
192
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, collateralToken, coinObjects);
193
+ const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)]);
194
+ const adjustPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, indexPrice, !long, isTriggerOrder ? 0 : slippage);
195
+ const adjustCollateralPrice = __classPrivateFieldGet(this, _API_instances, "m", _API_processSlippage).call(this, collateralPrice, false, 0.5);
196
+ let allowTrade = ALLOW_TRADE_MUST_TRADE;
197
+ if (isTriggerOrder) {
198
+ allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
199
+ }
200
+ else {
201
+ isTakeProfitOrder = true;
202
+ }
203
+ /* console.log('isTriggerOrder:', isTriggerOrder)
204
+ console.log('isIocOrder:', isIocOrder)
205
+ console.log('isTakeProfitOrder:', isTakeProfitOrder)
206
+ console.log('adjustPrice:', adjustPrice)
207
+ console.log('allowTrade:', allowTrade)
208
+ console.log('isTriggerOrder:', isTriggerOrder)
209
+ console.log('isTakeProfitOrder:', isTakeProfitOrder) */
210
+ tx.moveCall({
211
+ target: `${this.consts.zoCore.package}::market::decrease_position`,
212
+ typeArguments: [
213
+ `${this.consts.zoCore.package}::zlp::ZLP`,
214
+ this.consts.coins[collateralToken].module,
215
+ this.consts.coins[indexToken].module,
216
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
217
+ this.consts.coins[collateralToken].module,
218
+ ],
219
+ arguments: [
220
+ tx.object(SUI_CLOCK_OBJECT_ID),
221
+ tx.object(this.consts.zoCore.market),
222
+ tx.object(pcpId),
223
+ tx.object(this.consts.zoCore.vaults[collateralToken].reservingFeeModel),
224
+ tx.object(this.consts.zoCore.symbols[symbol].fundingFeeModel),
225
+ tx.object(this.consts.pythFeeder.feeder[collateralToken]),
226
+ tx.object(this.consts.pythFeeder.feeder[indexToken]),
227
+ feeObject,
228
+ tx.pure.u8(allowTrade),
229
+ tx.pure.bool(isTakeProfitOrder),
230
+ tx.pure.u64(amount),
231
+ tx.pure.u256(adjustCollateralPrice),
232
+ tx.pure.u256(adjustPrice),
233
+ ],
234
+ });
235
+ return tx;
236
+ }
237
+ });
238
+ Object.defineProperty(this, "cancelOrder", {
239
+ enumerable: true,
240
+ configurable: true,
241
+ writable: true,
242
+ value: (orderCapId, collateralToken, indexToken, long, type, isV11Order = false) => {
243
+ const tx = new Transaction();
244
+ let functionName = '';
245
+ switch (type) {
246
+ case 'OPEN_POSITION': {
247
+ functionName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
248
+ break;
249
+ }
250
+ case 'DECREASE_POSITION': {
251
+ functionName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order';
252
+ break;
253
+ }
254
+ default: {
255
+ throw new Error('invalid order type');
256
+ }
257
+ }
258
+ tx.moveCall({
259
+ target: `${this.consts.zoCore.package}::market::${functionName}`,
260
+ typeArguments: [
261
+ `${this.consts.zoCore.package}::zlp::ZLP`,
262
+ this.consts.coins[collateralToken].module,
263
+ this.consts.coins[indexToken].module,
264
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
265
+ this.consts.coins[collateralToken].module,
266
+ ],
267
+ arguments: [
268
+ tx.object(this.consts.zoCore.market),
269
+ tx.object(orderCapId),
270
+ ],
271
+ });
272
+ return tx;
273
+ }
274
+ });
275
+ Object.defineProperty(this, "swap", {
276
+ enumerable: true,
277
+ configurable: true,
278
+ writable: true,
279
+ value: async (fromToken, toToken, fromAmount, fromCoinObjects) => {
280
+ const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults));
281
+ const fromCoinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, fromToken, fromCoinObjects);
282
+ const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)]);
283
+ const vaultsValuation = this.valuateVaults(tx);
284
+ tx.moveCall({
285
+ target: `${this.consts.zoCore.package}::market::swap`,
286
+ typeArguments: [
287
+ `${this.consts.zoCore.package}::zlp::ZLP`,
288
+ this.consts.coins[fromToken].module,
289
+ this.consts.coins[toToken].module,
290
+ ],
291
+ arguments: [
292
+ tx.object(this.consts.zoCore.market),
293
+ tx.object(this.consts.zoCore.rebaseFeeModel),
294
+ fromDepositObject,
295
+ // FIXME: minAmountOut
296
+ tx.pure.u64(0),
297
+ vaultsValuation,
298
+ ],
299
+ });
300
+ return tx;
301
+ }
302
+ });
303
+ Object.defineProperty(this, "clearClosedPosition", {
304
+ enumerable: true,
305
+ configurable: true,
306
+ writable: true,
307
+ value: (pcpId, collateralToken, indexToken, long, tx) => {
308
+ tx.moveCall({
309
+ target: `${this.consts.zoCore.package}::market::clear_closed_position`,
310
+ typeArguments: [
311
+ `${this.consts.zoCore.package}::zlp::ZLP`,
312
+ this.consts.coins[collateralToken].module,
313
+ this.consts.coins[indexToken].module,
314
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
315
+ ],
316
+ arguments: [
317
+ tx.object(this.consts.zoCore.market),
318
+ tx.object(pcpId),
319
+ ],
320
+ });
321
+ }
322
+ });
323
+ Object.defineProperty(this, "clearOpenPositionOrder", {
324
+ enumerable: true,
325
+ configurable: true,
326
+ writable: true,
327
+ value: (orderCapId, collateralToken, indexToken, long, tx, isV11Order = false) => {
328
+ const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
329
+ tx.moveCall({
330
+ target: `${this.consts.zoCore.package}::market::${funcName}`,
331
+ typeArguments: [
332
+ `${this.consts.zoCore.package}::zlp::ZLP`,
333
+ this.consts.coins[collateralToken].module,
334
+ this.consts.coins[indexToken].module,
335
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
336
+ this.consts.coins[collateralToken].module,
337
+ ],
338
+ arguments: [
339
+ tx.object(this.consts.zoCore.market),
340
+ tx.object(orderCapId),
341
+ ],
342
+ });
343
+ }
344
+ });
345
+ Object.defineProperty(this, "clearDecreasePositionOrder", {
346
+ enumerable: true,
347
+ configurable: true,
348
+ writable: true,
349
+ value: (orderCapId, collateralToken, indexToken, long, tx, isV11Order = false) => {
350
+ const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order';
351
+ tx.moveCall({
352
+ target: `${this.consts.zoCore.package}::market::${funcName}`,
353
+ typeArguments: [
354
+ `${this.consts.zoCore.package}::zlp::ZLP`,
355
+ this.consts.coins[collateralToken].module,
356
+ this.consts.coins[indexToken].module,
357
+ `${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
358
+ this.consts.coins[collateralToken].module,
359
+ ],
360
+ arguments: [
361
+ tx.object(this.consts.zoCore.market),
362
+ tx.object(orderCapId),
363
+ ],
364
+ });
365
+ }
366
+ });
367
+ Object.defineProperty(this, "stake", {
368
+ enumerable: true,
369
+ configurable: true,
370
+ writable: true,
371
+ value: (coinObjects, amount, pool, tx) => {
372
+ if (!tx) {
373
+ tx = new Transaction();
374
+ }
375
+ const coinObject = __classPrivateFieldGet(this, _API_processCoins, "f").call(this, tx, 'zlp', coinObjects);
376
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)]);
377
+ tx.moveCall({
378
+ target: `${this.consts.zoStaking.package}::pool::deposit`,
379
+ typeArguments: [
380
+ `${this.consts.zoCore.package}::zlp::ZLP`,
381
+ this.consts.coins.sui.module,
382
+ ],
383
+ arguments: [
384
+ tx.object(pool),
385
+ tx.object(SUI_CLOCK_OBJECT_ID),
386
+ depositObject,
387
+ ],
388
+ });
389
+ return tx;
390
+ }
391
+ });
392
+ Object.defineProperty(this, "unstake", {
393
+ enumerable: true,
394
+ configurable: true,
395
+ writable: true,
396
+ value: (credentials, amount, pool, tx) => {
397
+ if (!tx) {
398
+ tx = new Transaction();
399
+ }
400
+ for (const credential of credentials) {
401
+ // eslint-disable-next-line unicorn/prefer-math-min-max
402
+ const withdrawAmount = amount < credential.amount ? amount : credential.amount;
403
+ amount -= withdrawAmount;
404
+ tx.moveCall({
405
+ target: `0xdb353cb79a88d5ee83b7c0ca0249662a1facab17ba62879080ea3d61b9d21112::pool::withdraw`,
406
+ typeArguments: [
407
+ `${this.consts.zoCore.package}::zlp::ZLP`,
408
+ this.consts.coins.sui.module,
409
+ ],
410
+ arguments: [
411
+ tx.object(pool),
412
+ tx.object(SUI_CLOCK_OBJECT_ID),
413
+ tx.object(credential.id),
414
+ tx.pure.u64(withdrawAmount),
415
+ ],
416
+ });
417
+ if (credential.amount === BigInt(0)) {
418
+ tx.moveCall({
419
+ target: `${this.consts.zoStaking.package}::pool::clear_empty_credential`,
420
+ typeArguments: [
421
+ `${this.consts.zoCore.package}::zlp::ZLP`,
422
+ this.consts.coins.sui.module,
423
+ ],
424
+ arguments: [
425
+ tx.object(credential.id),
426
+ ],
427
+ });
428
+ }
429
+ }
430
+ return tx;
431
+ }
432
+ });
433
+ Object.defineProperty(this, "addReferral", {
434
+ enumerable: true,
435
+ configurable: true,
436
+ writable: true,
437
+ value: (referrer, tx) => {
438
+ if (!tx) {
439
+ tx = new Transaction();
440
+ }
441
+ tx.moveCall({
442
+ target: `${this.consts.zoCore.package}::market::add_new_referral`,
443
+ typeArguments: [
444
+ `${this.consts.zoCore.package}::zlp::ZLP`,
445
+ ],
446
+ arguments: [
447
+ tx.object(this.consts.zoCore.market),
448
+ tx.object(referrer),
449
+ ],
450
+ });
451
+ return tx;
452
+ }
453
+ });
454
+ }
455
+ static getInstance(network, provider, apiEndpoint, connectionURL) {
456
+ if (!API.instance) {
457
+ API.instance = new API(network, provider, apiEndpoint, connectionURL);
458
+ }
459
+ return API.instance;
460
+ }
461
+ }
462
+ _API_processCoins = new WeakMap(), _API_instances = new WeakSet(), _API_processSlippage = function _API_processSlippage(indexPrice, long, slippage) {
463
+ const raw = long ? (indexPrice * (1 + slippage)) : (indexPrice * (1 - slippage));
464
+ return BigInt(Math.round(raw * 1e18));
465
+ };
@@ -1,18 +1,52 @@
1
1
  {
2
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": {}
3
+ "package": "0xce6a4384ceb1306efdb45cd0b093a7a49669a998749c59e614be8cfdf1352530",
4
+ "upgrade_cap": "0x0b703c8e709ce86bcb1468ed47047b0d7020c72beca0a907a17b0e17bdb0f54c",
5
+ "admin_cap": "0x4a152188f491e6b0c58115369318f9b50bf15e685322f2ef8e9a68e71638eb15",
6
+ "market": "0x94314e176d16ad0c77d0f3326ea5914db01d037fa0db644b1bf545dbe482bfb8",
7
+ "zlp_metadata": "0x3a3ab1dbcc939ee71669aed0fe885c7c3b23e17021ff2f877929f9c88d97ee60",
8
+ "rebase_fee_model": "0xa4a426e677da3a3358648978ae7510c17261ce12302287ccbdc61d48e54fdbd6",
9
+ "referrals_parent": "0x32f369c166cddb21db5369bb90ff8e462ca5f4f21e0eabae5e5d1a0d4154f6e8",
10
+ "vaults_parent": "0x3299e9ee800425afcfd51339cb53a8d0f73856e2ec1268d73caa8d5213068635",
11
+ "symbols_parent": "0x89975b6ec33ac0e53766229c3b642e817708bbd7299cda7509d6fabf5cd14069",
12
+ "positions_parent": "0x7e7870464138f3c7eaa7b1398813b86169d76bf74fcb8b55d68409e40ee68c41",
13
+ "orders_parent": "0x3c5f69a5166afe5459e21c64615e8f3a6111adf60e6f30a0fafd9df5e2ee07d4",
14
+ "vaults": {
15
+ "usdt": {
16
+ "weight": "50000000000000000",
17
+ "reserving_fee_model": "0xab77fbcb9c02c3ab36acf7ea6dacde6e4d4ece6e0d18cf692aeb8af4355c8087"
18
+ },
19
+ "sui": {
20
+ "weight": "200000000000000000",
21
+ "reserving_fee_model": "0xbfd086e19531fae3dedba1ff1f22321810783fcbff74f7dd802941f385a649b5"
22
+ },
23
+ "nusdc": {
24
+ "weight": "50000000000000000",
25
+ "reserving_fee_model": "0x6aba9dd9d842e5afb48f56e6c557f306dd3b438482cde9661e98d5e4c946baa5"
26
+ }
27
+ },
28
+ "symbols": {
29
+ "long_btc": {
30
+ "supported_collaterals": ["usdt"],
31
+ "funding_fee_model": "0x170dca23442b842c592bfe97f769eeb9dc1e3f91211ab82b601150f0d7cbba5f",
32
+ "position_config": "0x63021a70938256c4b70163e52123566a4c704caab067b5468ac6bedc97d3bd93"
33
+ },
34
+ "short_btc": {
35
+ "supported_collaterals": ["usdt"],
36
+ "funding_fee_model": "0x2cd4ad4a33f7d87211e2d096cd9ef6de99338fe7f8de5face4b00a13df2f44a4",
37
+ "position_config": "0xb29751c5539afb5d2b514bba53d825b5b0eeebb9b18d2928da9bc368a4ef537f"
38
+ },
39
+ "long_eth": {
40
+ "supported_collaterals": ["usdt"],
41
+ "funding_fee_model": "0x26a0cb7d6258c0afa6f7b68f88ba7873bd19dcd343dece854451134f0b2fb2cb",
42
+ "position_config": "0xea3e608b6097b17e3a17ae406ac463818bcdd122fe168368f5ba53994f74643b"
43
+ },
44
+ "short_eth": {
45
+ "supported_collaterals": ["usdt"],
46
+ "funding_fee_model": "0x68513b9675b03c33bceb680dee18468f2148cdea513687e21e3d3b630508b17d",
47
+ "position_config": "0x8a2a300e9f4fc471eba474e9b2e40244522394efc71a10803219425cdc1cadee"
48
+ }
49
+ }
16
50
  },
17
51
  "pyth_feeder": {
18
52
  "package": "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e",
@@ -22,7 +56,45 @@
22
56
  "package": "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
23
57
  "state": "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
24
58
  },
25
- "feeder": {}
59
+ "feeder": {
60
+ "sui": "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37",
61
+ "btc": "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2",
62
+ "eth": "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab",
63
+ "nusdc": "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab",
64
+ "usdt": "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572",
65
+ "deep": "0x8c7f3a322b94cc69db2a2ac575cbd94bf5766113324c3a3eceac91e3e88a51ed"
66
+ }
26
67
  },
27
- "coins": {}
68
+ "coins": {
69
+ "sui": {
70
+ "decimals": 9,
71
+ "module": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
72
+ "metadata": "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3"
73
+ },
74
+ "btc": {
75
+ "decimals": 8,
76
+ "module": "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN",
77
+ "metadata": "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd"
78
+ },
79
+ "eth": {
80
+ "decimals": 8,
81
+ "module": "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",
82
+ "metadata": "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f"
83
+ },
84
+ "nusdc": {
85
+ "decimals": 6,
86
+ "module": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
87
+ "metadata": "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6"
88
+ },
89
+ "usdt": {
90
+ "decimals": 6,
91
+ "module": "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",
92
+ "metadata": "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c"
93
+ },
94
+ "deep": {
95
+ "decimals": 6,
96
+ "module": "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",
97
+ "metadata": "0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0"
98
+ }
99
+ }
28
100
  }
@@ -1,46 +1,46 @@
1
1
  {
2
2
  "zo_core": {
3
- "package": "0xec6db545c6fa70a67b0b4122ee9068f6fc186fbcca93c2021f257be08b020d29",
4
- "upgrade_cap": "0x4ac4eaa60e2c3d9c905a6b19a8915de161360e717e7fb7c825eaffabc8a4f37d",
5
- "admin_cap": "0x8fc34ddcf92ec04108258399afa264fb6bf6948adea3feda3b4a0853fd52e2d9",
6
- "market": "0x82cfe3d857ad2e5feecd64762548ded75a000896391217fbc9ff9509e81d5472",
7
- "zlp_metadata": "0xabe892092d7bdf78b57654f50df88c34cdaab019af970814a459da394ef765c6",
8
- "rebase_fee_model": "0xabb420bb3e2be80244f854e4de3cbd70ac242f3271848393a4322ca7aacf3f3d",
9
- "referrals_parent": "0xf5ccc36426095a8857fd27891907f2242e9399b4443df66fd86f2f47d94afc34",
10
- "vaults_parent": "0x574b14c9b7a3b4f78eee68e820d15f5ecbac7a7508bcc1dbf3380e8b0725a0bd",
11
- "symbols_parent": "0xc348082a5c6a3d2483db637c78f28bd1961d7ba0de10a5318716d703fb8466f5",
12
- "positions_parent": "0x21a40a58b29aba0c024e678858d3c1cfb00eba4858af641bacc6eac5e78d1fb5",
13
- "orders_parent": "0x9b5d81641dc2ac6c2a225fdd75d32321896a096c38b33cecbe73a59a32b5224e",
3
+ "package": "0x7edfa7f292c8b623ca79bd2cd84e2d0e00eba76115a105b1437157cda307127f",
4
+ "upgrade_cap": "0xa94cef1809098efc654e5c7bdd584f60b4523c71ce935886e9c91efa0da807fd",
5
+ "admin_cap": "0x3c5714f2faa3cac854b2b1227114f1840133ab852dd48bfa0a3557720de03906",
6
+ "market": "0x77a3f0ee8b2dfbc570914629eb2cc5812a986108b336c840d77e69ba45bd8ba0",
7
+ "zlp_metadata": "0x3aedadbcdc1cf254fabc69110f9cf9fcbcc121c39347c4c75ad92903db8bd6eb",
8
+ "rebase_fee_model": "0x3375eb8b5082d1c52ab7d62c94a8f850f012f9cb4a03d96737b7256a31be4071",
9
+ "referrals_parent": "0xe51a4e8663280bf14e42a4f8e63141b45dc45c74fcf0470b17a96a2a625e80f9",
10
+ "vaults_parent": "0x1fc28cf4326a83533b127d5e072827c12995a0934b81513d5a5bcbae1038a8c2",
11
+ "symbols_parent": "0xc6eade51827828d28733b12f930b756b3cd78cdea0ad3e9773ca70d6ce30fdbd",
12
+ "positions_parent": "0xa3c40a6facbca7871ec1e6e51418b76d9f8200bcfeaa690b6687be9efcde04b9",
13
+ "orders_parent": "0x2a988712c811b8c063fee45e5bda61b3237e91ac3a94d542ef738bf0c56f0eae",
14
14
  "vaults": {
15
15
  "usdt": {
16
- "weight": "50000000000000000",
17
- "reserving_fee_model": "0xe2d1ea0df536ec62fbce793e294594a6fb5122cecfd1a0ae76caff7bcc303c49"
16
+ "weight": "100000000000000000",
17
+ "reserving_fee_model": "0xcd5f7a1cdb21d5bbd8d017682a3d5e854641ea5a84e639a320a6a4c702c4b8c8"
18
18
  },
19
19
  "sui": {
20
- "weight": "50000000000000000",
21
- "reserving_fee_model": "0x1ae6c6868efec5c9bb9897d75f0d1d62704a12079da614dc310a1898b2a1d2c6"
20
+ "weight": "100000000000000000",
21
+ "reserving_fee_model": "0xd0aaf3e8acad869a16b56fcd1c2f29ed9fbe5b10fc05290d65557547211107a1"
22
22
  }
23
23
  },
24
24
  "symbols": {
25
25
  "long_btc": {
26
26
  "supported_collaterals": ["usdt"],
27
- "funding_fee_model": "0x200c498ec92ebc835bda11f4d225bc91c44e73d711606f787990fe83b8692bac",
28
- "position_config": "0x12997666d278c42223161b596efdb79f86210970acd4aacfc711e6bb3c20f6d7"
27
+ "funding_fee_model": "0x016af381b6fc9933a816b54c32599b36ceca42f2889eddebc0230d48fc4910a0",
28
+ "position_config": "0x383f9600cf086829922b8e4b67a533edf60c104c42ddedd43b02994470e55b74"
29
29
  },
30
30
  "short_btc": {
31
31
  "supported_collaterals": ["usdt"],
32
- "funding_fee_model": "0x3a6a3e71460e8c143ed7fe296a77a45723b6ea61c10aa45e9c48bd3a352f93f5",
33
- "position_config": "0xe5f6e4e9b7c070c54cdd6ae2826bf6bc32441085a4ffd263f4eaa97d3711e120"
32
+ "funding_fee_model": "0x699530a75af4a4d58cab4f58485e30e65a438528345746b523b3d83e49465178",
33
+ "position_config": "0xcec1a314f020ab3bd602f9f481a6a686560c8c35e3dae6c88d3176444fc100dd"
34
34
  },
35
35
  "long_eth": {
36
36
  "supported_collaterals": ["usdt"],
37
- "funding_fee_model": "0x096b4495fd183baab7e0a440920a92523b1a287d11875ad79db39ba685a2f87f",
38
- "position_config": "0x7ca6ff396247d1538949fed3728fac334e75f66914026ef9a0dba6bbb3b749e7"
37
+ "funding_fee_model": "0x1e6ebf6f39b43a4feb775d50fc2eac0b12371c36b3ae937027820025dbc03c8a",
38
+ "position_config": "0xb9b536e0f8e9fcae28a48476fd0000208c1e288b5b1b23af07e7aad05d71b139"
39
39
  },
40
40
  "short_eth": {
41
41
  "supported_collaterals": ["usdt"],
42
- "funding_fee_model": "0x84c2473239acf91bcb760beb4df59a1e11399924e87c1016b08d60f8cacde811",
43
- "position_config": "0xfc9ca4b88ca9ada838fb87eebe24667b06d76c8c8f0a07e107e7939b1abbddc8"
42
+ "funding_fee_model": "0x92f488d758ddf483be3b90f6bc9dbc79cecd3fe6b5339e710e35ffb28435d612",
43
+ "position_config": "0xd4b0cd45c96df2e1c571e51e4729f5752037ba0f6a5ffc6dd6269083b0226b31"
44
44
  }
45
45
  }
46
46
  },