zo-sdk 0.1.13 → 0.1.15
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.
- package/dist/api.cjs +43 -43
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +11 -11
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +11 -11
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +43 -43
- package/dist/api.mjs.map +1 -1
- package/dist/consts/deployments-usdz-mainnet.json +1 -1
- package/dist/consts/deployments-zlp-mainnet.json +1 -1
- package/dist/data.cjs +20 -22
- package/dist/data.cjs.map +1 -1
- package/dist/data.d.cts.map +1 -1
- package/dist/data.d.mts.map +1 -1
- package/dist/data.mjs +20 -22
- package/dist/data.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +2 -2
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +2 -2
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +20 -20
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.mjs +20 -20
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/USDZDataAPI.cjs +46 -4
- package/dist/implementations/USDZDataAPI.cjs.map +1 -1
- package/dist/implementations/USDZDataAPI.d.cts +6 -1
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
- package/dist/implementations/USDZDataAPI.d.mts +6 -1
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
- package/dist/implementations/USDZDataAPI.mjs +46 -4
- package/dist/implementations/USDZDataAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +18 -18
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +18 -18
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.cjs +4 -4
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +4 -4
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/interfaces/usdz.d.cts +20 -0
- package/dist/interfaces/usdz.d.cts.map +1 -1
- package/dist/interfaces/usdz.d.mts +20 -0
- package/dist/interfaces/usdz.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +121 -100
- package/src/consts/deployments-usdz-mainnet.json +1 -1
- package/src/consts/deployments-zlp-mainnet.json +1 -1
- package/src/data.ts +66 -63
- package/src/implementations/SLPDataAPI.ts +2 -2
- package/src/implementations/USDZAPI.ts +20 -20
- package/src/implementations/USDZDataAPI.ts +50 -4
- package/src/implementations/ZLPAPI.ts +18 -18
- package/src/implementations/ZLPDataAPI.ts +4 -4
- package/src/interfaces/usdz.ts +25 -1
package/src/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
/* eslint-disable class-methods-use-this */
|
|
3
|
+
import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
|
|
4
|
+
import { KioskTransaction } from '@mysten/kiosk'
|
|
3
5
|
import type { SuiClient } from '@mysten/sui/client'
|
|
4
6
|
import { Transaction } from '@mysten/sui/transactions'
|
|
5
7
|
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
|
|
6
|
-
import { KioskClient, KioskOwnerCap, KioskTransaction } from '@mysten/kiosk';
|
|
7
8
|
|
|
8
9
|
import type { Network } from './consts'
|
|
9
10
|
import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE } from './consts'
|
|
@@ -74,7 +75,7 @@ export class API extends DataAPI {
|
|
|
74
75
|
const { vaultsValuation, symbolsValuation } = this.valuate(tx)
|
|
75
76
|
|
|
76
77
|
tx.moveCall({
|
|
77
|
-
target: `${this.consts.zoCore.
|
|
78
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
78
79
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
|
|
79
80
|
arguments: [
|
|
80
81
|
tx.object(this.consts.zoCore.market),
|
|
@@ -96,7 +97,7 @@ export class API extends DataAPI {
|
|
|
96
97
|
const { vaultsValuation, symbolsValuation } = this.valuate(tx)
|
|
97
98
|
|
|
98
99
|
tx.moveCall({
|
|
99
|
-
target: `${this.consts.zoCore.
|
|
100
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::withdraw`,
|
|
100
101
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
|
|
101
102
|
arguments: [
|
|
102
103
|
tx.object(this.consts.zoCore.market),
|
|
@@ -122,8 +123,8 @@ export class API extends DataAPI {
|
|
|
122
123
|
collateralPrice: number,
|
|
123
124
|
isLimitOrder = false,
|
|
124
125
|
isIocOrder = false,
|
|
125
|
-
pricesSlippage
|
|
126
|
-
collateralSlippage
|
|
126
|
+
pricesSlippage = 0.003,
|
|
127
|
+
collateralSlippage = 0.5,
|
|
127
128
|
relayerFee = BigInt(0.5),
|
|
128
129
|
referralAddress = '',
|
|
129
130
|
sender = '',
|
|
@@ -149,7 +150,7 @@ export class API extends DataAPI {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
tx.moveCall({
|
|
152
|
-
target: `${this.consts.zoCore.
|
|
153
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position`,
|
|
153
154
|
typeArguments: [
|
|
154
155
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
155
156
|
this.consts.coins[collateralToken].module,
|
|
@@ -187,16 +188,16 @@ export class API extends DataAPI {
|
|
|
187
188
|
reserveAmount: bigint,
|
|
188
189
|
indexPrice: number,
|
|
189
190
|
collateralPrice: number,
|
|
191
|
+
kioskClient: KioskClient,
|
|
192
|
+
kioskCap: KioskOwnerCap,
|
|
193
|
+
scard: string,
|
|
190
194
|
isLimitOrder = false,
|
|
191
195
|
isIocOrder = false,
|
|
192
|
-
pricesSlippage
|
|
193
|
-
collateralSlippage
|
|
196
|
+
pricesSlippage = 0.003,
|
|
197
|
+
collateralSlippage = 0.5,
|
|
194
198
|
relayerFee = BigInt(0.5),
|
|
195
199
|
referralAddress = '',
|
|
196
200
|
sender = '',
|
|
197
|
-
kioskClient: KioskClient,
|
|
198
|
-
kioskCap: KioskOwnerCap,
|
|
199
|
-
scard: string,
|
|
200
201
|
) => {
|
|
201
202
|
let tx = new Transaction()
|
|
202
203
|
if (referralAddress && !(await this.hasReferral(sender || ''))) {
|
|
@@ -222,7 +223,7 @@ export class API extends DataAPI {
|
|
|
222
223
|
transaction: tx,
|
|
223
224
|
kioskClient,
|
|
224
225
|
cap: kioskCap,
|
|
225
|
-
})
|
|
226
|
+
})
|
|
226
227
|
|
|
227
228
|
const [sudoCard, promise] = kioskTx.borrow({
|
|
228
229
|
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
@@ -230,7 +231,7 @@ export class API extends DataAPI {
|
|
|
230
231
|
})
|
|
231
232
|
|
|
232
233
|
tx.moveCall({
|
|
233
|
-
target: `${this.consts.zoCore.
|
|
234
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_with_scard`,
|
|
234
235
|
typeArguments: [
|
|
235
236
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
236
237
|
this.consts.coins[collateralToken].module,
|
|
@@ -261,7 +262,7 @@ export class API extends DataAPI {
|
|
|
261
262
|
.return({
|
|
262
263
|
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
263
264
|
item: sudoCard,
|
|
264
|
-
promise
|
|
265
|
+
promise,
|
|
265
266
|
})
|
|
266
267
|
.finalize()
|
|
267
268
|
return tx
|
|
@@ -280,7 +281,7 @@ export class API extends DataAPI {
|
|
|
280
281
|
const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
|
|
281
282
|
|
|
282
283
|
tx.moveCall({
|
|
283
|
-
target: `${this.consts.zoCore.
|
|
284
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::pledge_in_position`,
|
|
284
285
|
typeArguments: [
|
|
285
286
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
286
287
|
this.consts.coins[collateralToken].module,
|
|
@@ -303,7 +304,7 @@ export class API extends DataAPI {
|
|
|
303
304
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
304
305
|
|
|
305
306
|
tx.moveCall({
|
|
306
|
-
target: `${this.consts.zoCore.
|
|
307
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::redeem_from_position`,
|
|
307
308
|
typeArguments: [
|
|
308
309
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
309
310
|
this.consts.coins[collateralToken].module,
|
|
@@ -337,8 +338,8 @@ export class API extends DataAPI {
|
|
|
337
338
|
isTriggerOrder = false,
|
|
338
339
|
isTakeProfitOrder = true,
|
|
339
340
|
isIocOrder = false,
|
|
340
|
-
pricesSlippage
|
|
341
|
-
collateralSlippage
|
|
341
|
+
pricesSlippage = 0.003,
|
|
342
|
+
collateralSlippage = 0.5,
|
|
342
343
|
relayerFee = BigInt(0.5),
|
|
343
344
|
) => {
|
|
344
345
|
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
@@ -352,12 +353,13 @@ export class API extends DataAPI {
|
|
|
352
353
|
let allowTrade = ALLOW_TRADE_MUST_TRADE
|
|
353
354
|
if (isTriggerOrder) {
|
|
354
355
|
allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
|
|
355
|
-
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
356
358
|
isTakeProfitOrder = true
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
tx.moveCall({
|
|
360
|
-
target: `${this.consts.zoCore.
|
|
362
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
361
363
|
typeArguments: [
|
|
362
364
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
363
365
|
this.consts.coins[collateralToken].module,
|
|
@@ -394,15 +396,15 @@ export class API extends DataAPI {
|
|
|
394
396
|
long: boolean,
|
|
395
397
|
indexPrice: number,
|
|
396
398
|
collateralPrice: number,
|
|
399
|
+
kioskClient: KioskClient,
|
|
400
|
+
kioskCap: KioskOwnerCap,
|
|
401
|
+
scard: string,
|
|
397
402
|
isTriggerOrder = false,
|
|
398
403
|
isTakeProfitOrder = true,
|
|
399
404
|
isIocOrder = false,
|
|
400
|
-
pricesSlippage
|
|
401
|
-
collateralSlippage
|
|
405
|
+
pricesSlippage = 0.003,
|
|
406
|
+
collateralSlippage = 0.5,
|
|
402
407
|
relayerFee = BigInt(0.5),
|
|
403
|
-
kioskClient: KioskClient,
|
|
404
|
-
kioskCap: KioskOwnerCap,
|
|
405
|
-
scard: string,
|
|
406
408
|
) => {
|
|
407
409
|
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
408
410
|
|
|
@@ -427,12 +429,13 @@ export class API extends DataAPI {
|
|
|
427
429
|
let allowTrade = ALLOW_TRADE_MUST_TRADE
|
|
428
430
|
if (isTriggerOrder) {
|
|
429
431
|
allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
|
|
430
|
-
}
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
431
434
|
isTakeProfitOrder = true
|
|
432
435
|
}
|
|
433
436
|
|
|
434
437
|
tx.moveCall({
|
|
435
|
-
target: `${this.consts.zoCore.
|
|
438
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
436
439
|
typeArguments: [
|
|
437
440
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
438
441
|
this.consts.coins[collateralToken].module,
|
|
@@ -462,37 +465,47 @@ export class API extends DataAPI {
|
|
|
462
465
|
.return({
|
|
463
466
|
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
464
467
|
item: sudoCard,
|
|
465
|
-
promise
|
|
468
|
+
promise,
|
|
466
469
|
})
|
|
467
470
|
.finalize()
|
|
468
471
|
return tx
|
|
469
472
|
}
|
|
470
473
|
|
|
471
474
|
decreaseMultiPositions = async (positions: Array<{
|
|
472
|
-
pcpId: string
|
|
473
|
-
collateralToken: string
|
|
474
|
-
coinObjects: string[]
|
|
475
|
-
indexToken: string
|
|
476
|
-
amount: bigint
|
|
477
|
-
long: boolean
|
|
478
|
-
indexPrice: number
|
|
479
|
-
collateralPrice: number
|
|
480
|
-
isTriggerOrder: boolean
|
|
481
|
-
isTakeProfitOrder: boolean
|
|
482
|
-
isIocOrder: boolean
|
|
483
|
-
slippage: number
|
|
484
|
-
relayerFee: bigint
|
|
475
|
+
pcpId: string
|
|
476
|
+
collateralToken: string
|
|
477
|
+
coinObjects: string[]
|
|
478
|
+
indexToken: string
|
|
479
|
+
amount: bigint
|
|
480
|
+
long: boolean
|
|
481
|
+
indexPrice: number
|
|
482
|
+
collateralPrice: number
|
|
483
|
+
isTriggerOrder: boolean
|
|
484
|
+
isTakeProfitOrder: boolean
|
|
485
|
+
isIocOrder: boolean
|
|
486
|
+
slippage: number
|
|
487
|
+
relayerFee: bigint
|
|
485
488
|
}>, tx?: Transaction) => {
|
|
486
489
|
if (!tx) {
|
|
487
|
-
tx = new Transaction()
|
|
490
|
+
tx = new Transaction()
|
|
488
491
|
}
|
|
489
|
-
tx = await this.initOracleTxb(positions.
|
|
492
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
|
|
490
493
|
|
|
491
494
|
for (const position of positions) {
|
|
492
495
|
const {
|
|
493
496
|
pcpId,
|
|
494
497
|
collateralToken,
|
|
495
|
-
coinObjects,
|
|
498
|
+
coinObjects,
|
|
499
|
+
indexToken,
|
|
500
|
+
amount,
|
|
501
|
+
long,
|
|
502
|
+
indexPrice,
|
|
503
|
+
collateralPrice,
|
|
504
|
+
isTriggerOrder,
|
|
505
|
+
isTakeProfitOrder,
|
|
506
|
+
isIocOrder,
|
|
507
|
+
slippage,
|
|
508
|
+
relayerFee,
|
|
496
509
|
} = position
|
|
497
510
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
498
511
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
@@ -505,12 +518,13 @@ export class API extends DataAPI {
|
|
|
505
518
|
let allowTrade = ALLOW_TRADE_MUST_TRADE
|
|
506
519
|
if (isTriggerOrder) {
|
|
507
520
|
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
|
|
508
|
-
}
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
509
523
|
innerIsTakeProfitOrder = true
|
|
510
524
|
}
|
|
511
525
|
|
|
512
526
|
tx.moveCall({
|
|
513
|
-
target: `${this.consts.zoCore.
|
|
527
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
514
528
|
typeArguments: [
|
|
515
529
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
516
530
|
this.consts.coins[collateralToken].module,
|
|
@@ -539,28 +553,24 @@ export class API extends DataAPI {
|
|
|
539
553
|
}
|
|
540
554
|
|
|
541
555
|
decreaseMultiPositionsWithSCard = async (positions: Array<{
|
|
542
|
-
pcpId: string
|
|
543
|
-
collateralToken: string
|
|
544
|
-
coinObjects: string[]
|
|
545
|
-
indexToken: string
|
|
546
|
-
amount: bigint
|
|
547
|
-
long: boolean
|
|
548
|
-
indexPrice: number
|
|
549
|
-
collateralPrice: number
|
|
550
|
-
isTriggerOrder: boolean
|
|
551
|
-
isTakeProfitOrder: boolean
|
|
552
|
-
isIocOrder: boolean
|
|
553
|
-
slippage: number
|
|
554
|
-
relayerFee: bigint
|
|
555
|
-
}>,
|
|
556
|
-
kioskClient: KioskClient,
|
|
557
|
-
kioskCap: KioskOwnerCap,
|
|
558
|
-
scard: string,
|
|
559
|
-
tx?: Transaction) => {
|
|
556
|
+
pcpId: string
|
|
557
|
+
collateralToken: string
|
|
558
|
+
coinObjects: string[]
|
|
559
|
+
indexToken: string
|
|
560
|
+
amount: bigint
|
|
561
|
+
long: boolean
|
|
562
|
+
indexPrice: number
|
|
563
|
+
collateralPrice: number
|
|
564
|
+
isTriggerOrder: boolean
|
|
565
|
+
isTakeProfitOrder: boolean
|
|
566
|
+
isIocOrder: boolean
|
|
567
|
+
slippage: number
|
|
568
|
+
relayerFee: bigint
|
|
569
|
+
}>, kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string, tx?: Transaction) => {
|
|
560
570
|
if (!tx) {
|
|
561
|
-
tx = new Transaction()
|
|
571
|
+
tx = new Transaction()
|
|
562
572
|
}
|
|
563
|
-
tx = await this.initOracleTxb(positions.
|
|
573
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
|
|
564
574
|
|
|
565
575
|
const kioskTx = new KioskTransaction({
|
|
566
576
|
transaction: tx,
|
|
@@ -577,7 +587,17 @@ export class API extends DataAPI {
|
|
|
577
587
|
const {
|
|
578
588
|
pcpId,
|
|
579
589
|
collateralToken,
|
|
580
|
-
coinObjects,
|
|
590
|
+
coinObjects,
|
|
591
|
+
indexToken,
|
|
592
|
+
amount,
|
|
593
|
+
long,
|
|
594
|
+
indexPrice,
|
|
595
|
+
collateralPrice,
|
|
596
|
+
isTriggerOrder,
|
|
597
|
+
isTakeProfitOrder,
|
|
598
|
+
isIocOrder,
|
|
599
|
+
slippage,
|
|
600
|
+
relayerFee,
|
|
581
601
|
} = position
|
|
582
602
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
583
603
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
@@ -590,12 +610,13 @@ export class API extends DataAPI {
|
|
|
590
610
|
let allowTrade = ALLOW_TRADE_MUST_TRADE
|
|
591
611
|
if (isTriggerOrder) {
|
|
592
612
|
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
|
|
593
|
-
}
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
594
615
|
innerIsTakeProfitOrder = true
|
|
595
616
|
}
|
|
596
617
|
|
|
597
618
|
tx.moveCall({
|
|
598
|
-
target: `${this.consts.zoCore.
|
|
619
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
599
620
|
typeArguments: [
|
|
600
621
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
601
622
|
this.consts.coins[collateralToken].module,
|
|
@@ -626,7 +647,7 @@ export class API extends DataAPI {
|
|
|
626
647
|
.return({
|
|
627
648
|
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
628
649
|
item: sudoCard,
|
|
629
|
-
promise
|
|
650
|
+
promise,
|
|
630
651
|
})
|
|
631
652
|
.finalize()
|
|
632
653
|
return tx
|
|
@@ -658,7 +679,7 @@ export class API extends DataAPI {
|
|
|
658
679
|
}
|
|
659
680
|
}
|
|
660
681
|
tx.moveCall({
|
|
661
|
-
target: `${this.consts.zoCore.
|
|
682
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
662
683
|
typeArguments: [
|
|
663
684
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
664
685
|
this.consts.coins[collateralToken].module,
|
|
@@ -671,13 +692,13 @@ export class API extends DataAPI {
|
|
|
671
692
|
return tx
|
|
672
693
|
}
|
|
673
694
|
|
|
674
|
-
cancelMultiOrder =
|
|
675
|
-
orderCapId: string
|
|
676
|
-
collateralToken: string
|
|
677
|
-
indexToken: string
|
|
678
|
-
long: boolean
|
|
679
|
-
type: string
|
|
680
|
-
isV11Order: boolean
|
|
695
|
+
cancelMultiOrder = (orders: Array<{
|
|
696
|
+
orderCapId: string
|
|
697
|
+
collateralToken: string
|
|
698
|
+
indexToken: string
|
|
699
|
+
long: boolean
|
|
700
|
+
type: string
|
|
701
|
+
isV11Order: boolean
|
|
681
702
|
}>, tx?: Transaction) => {
|
|
682
703
|
if (!tx) {
|
|
683
704
|
tx = new Transaction()
|
|
@@ -703,7 +724,7 @@ export class API extends DataAPI {
|
|
|
703
724
|
}
|
|
704
725
|
|
|
705
726
|
tx.moveCall({
|
|
706
|
-
target: `${this.consts.zoCore.
|
|
727
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
707
728
|
typeArguments: [
|
|
708
729
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
709
730
|
this.consts.coins[collateralToken].module,
|
|
@@ -729,7 +750,7 @@ export class API extends DataAPI {
|
|
|
729
750
|
const vaultsValuation = this.valuateVaults(tx)
|
|
730
751
|
|
|
731
752
|
tx.moveCall({
|
|
732
|
-
target: `${this.consts.zoCore.
|
|
753
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::swap`,
|
|
733
754
|
typeArguments: [
|
|
734
755
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
735
756
|
this.consts.coins[fromToken].module,
|
|
@@ -755,7 +776,7 @@ export class API extends DataAPI {
|
|
|
755
776
|
tx: Transaction,
|
|
756
777
|
) => {
|
|
757
778
|
tx.moveCall({
|
|
758
|
-
target: `${this.consts.zoCore.
|
|
779
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::clear_closed_position`,
|
|
759
780
|
typeArguments: [
|
|
760
781
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
761
782
|
this.consts.coins[collateralToken].module,
|
|
@@ -776,7 +797,7 @@ export class API extends DataAPI {
|
|
|
776
797
|
) => {
|
|
777
798
|
const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order'
|
|
778
799
|
tx.moveCall({
|
|
779
|
-
target: `${this.consts.zoCore.
|
|
800
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
780
801
|
typeArguments: [
|
|
781
802
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
782
803
|
this.consts.coins[collateralToken].module,
|
|
@@ -798,7 +819,7 @@ export class API extends DataAPI {
|
|
|
798
819
|
) => {
|
|
799
820
|
const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order'
|
|
800
821
|
tx.moveCall({
|
|
801
|
-
target: `${this.consts.zoCore.
|
|
822
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
802
823
|
typeArguments: [
|
|
803
824
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
804
825
|
this.consts.coins[collateralToken].module,
|
|
@@ -866,7 +887,7 @@ export class API extends DataAPI {
|
|
|
866
887
|
tx = new Transaction()
|
|
867
888
|
}
|
|
868
889
|
tx.moveCall({
|
|
869
|
-
target: `${this.consts.zoCore.
|
|
890
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::add_new_referral`,
|
|
870
891
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
871
892
|
arguments: [tx.object(this.consts.zoCore.market), tx.object(referrer)],
|
|
872
893
|
})
|
|
@@ -875,12 +896,12 @@ export class API extends DataAPI {
|
|
|
875
896
|
}
|
|
876
897
|
|
|
877
898
|
// admin methods
|
|
878
|
-
adminUpdatePriceFeed = async (collateralToken: string, indexToken: string
|
|
899
|
+
adminUpdatePriceFeed = async (collateralToken: string, indexToken: string) => {
|
|
879
900
|
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
880
901
|
return tx
|
|
881
902
|
}
|
|
882
903
|
|
|
883
|
-
adminSettlePosition =
|
|
904
|
+
adminSettlePosition = (
|
|
884
905
|
positionId: string,
|
|
885
906
|
owner: string,
|
|
886
907
|
collateralToken: string,
|
|
@@ -911,7 +932,7 @@ export class API extends DataAPI {
|
|
|
911
932
|
return tx
|
|
912
933
|
}
|
|
913
934
|
|
|
914
|
-
adminDecreasePosition =
|
|
935
|
+
adminDecreasePosition = (
|
|
915
936
|
positionId: string,
|
|
916
937
|
owner: string,
|
|
917
938
|
collateralToken: string,
|
|
@@ -924,7 +945,7 @@ export class API extends DataAPI {
|
|
|
924
945
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
925
946
|
|
|
926
947
|
tx.moveCall({
|
|
927
|
-
target: `${this.consts.zoCore.
|
|
948
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_close_position`,
|
|
928
949
|
typeArguments: [
|
|
929
950
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
930
951
|
this.consts.coins[collateralToken].module,
|
|
@@ -951,7 +972,7 @@ export class API extends DataAPI {
|
|
|
951
972
|
return tx
|
|
952
973
|
}
|
|
953
974
|
|
|
954
|
-
adminClearClosedPosition =
|
|
975
|
+
adminClearClosedPosition = (
|
|
955
976
|
positionId: string,
|
|
956
977
|
owner: string,
|
|
957
978
|
collateralToken: string,
|
|
@@ -960,7 +981,7 @@ export class API extends DataAPI {
|
|
|
960
981
|
tx: Transaction,
|
|
961
982
|
) => {
|
|
962
983
|
tx.moveCall({
|
|
963
|
-
target: `${this.consts.zoCore.
|
|
984
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_clear_closed_position`,
|
|
964
985
|
typeArguments: [
|
|
965
986
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
966
987
|
this.consts.coins[collateralToken].module,
|
|
@@ -977,25 +998,25 @@ export class API extends DataAPI {
|
|
|
977
998
|
}
|
|
978
999
|
|
|
979
1000
|
// ZO Lootbox
|
|
980
|
-
adminIssueLootbox =
|
|
1001
|
+
adminIssueLootbox = (
|
|
981
1002
|
coin: string,
|
|
982
1003
|
tiers: number[],
|
|
983
1004
|
beneficiaries: string[],
|
|
984
1005
|
amounts: number[],
|
|
985
1006
|
tx: Transaction,
|
|
986
1007
|
) => {
|
|
987
|
-
let module = this.consts.zoCore.package
|
|
1008
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
988
1009
|
if (coin !== 'zlp') {
|
|
989
1010
|
module = this.consts.coins[coin].module
|
|
990
1011
|
}
|
|
991
|
-
for (
|
|
1012
|
+
for (const [i, beneficiary] of beneficiaries.entries()) {
|
|
992
1013
|
tx.moveCall({
|
|
993
1014
|
target: `${this.consts.zoLootbox.package}::lootbox::admin_issue_lootbox`,
|
|
994
1015
|
typeArguments: [module],
|
|
995
1016
|
arguments: [
|
|
996
1017
|
tx.object(this.consts.zoLootbox.adminCap),
|
|
997
1018
|
tx.pure.u8(tiers[i]),
|
|
998
|
-
tx.pure.address(
|
|
1019
|
+
tx.pure.address(beneficiary),
|
|
999
1020
|
tx.pure.u64(amounts[i]),
|
|
1000
1021
|
tx.pure.bool(amounts[i] > 0),
|
|
1001
1022
|
tx.object(`${this.consts.zoLootbox.lootboxSettings}`),
|
|
@@ -1004,7 +1025,7 @@ export class API extends DataAPI {
|
|
|
1004
1025
|
}
|
|
1005
1026
|
}
|
|
1006
1027
|
|
|
1007
|
-
depositToPrizePool =
|
|
1028
|
+
depositToPrizePool = (
|
|
1008
1029
|
coin: string,
|
|
1009
1030
|
coinObjects: string[],
|
|
1010
1031
|
amount: number,
|
|
@@ -1013,7 +1034,7 @@ export class API extends DataAPI {
|
|
|
1013
1034
|
const coinObject = this.#processCoins(tx, coin, coinObjects)
|
|
1014
1035
|
const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
|
|
1015
1036
|
|
|
1016
|
-
let module = this.consts.zoCore.package
|
|
1037
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
1017
1038
|
if (coin !== 'zlp') {
|
|
1018
1039
|
module = this.consts.coins[coin].module
|
|
1019
1040
|
}
|
|
@@ -1030,10 +1051,10 @@ export class API extends DataAPI {
|
|
|
1030
1051
|
return tx
|
|
1031
1052
|
}
|
|
1032
1053
|
|
|
1033
|
-
withdrawFromPricePool =
|
|
1054
|
+
withdrawFromPricePool = (coin: string, amount: number) => {
|
|
1034
1055
|
const tx = new Transaction()
|
|
1035
1056
|
|
|
1036
|
-
let module = this.consts.zoCore.package
|
|
1057
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
1037
1058
|
let metadata = this.consts.zoCore.zlpMetadata
|
|
1038
1059
|
if (coin !== 'zlp') {
|
|
1039
1060
|
module = this.consts.coins[coin].module
|
|
@@ -1053,10 +1074,10 @@ export class API extends DataAPI {
|
|
|
1053
1074
|
return tx
|
|
1054
1075
|
}
|
|
1055
1076
|
|
|
1056
|
-
openLootbox =
|
|
1077
|
+
openLootbox = (coin: string, lootbox: string) => {
|
|
1057
1078
|
const tx = new Transaction()
|
|
1058
1079
|
|
|
1059
|
-
let module = this.consts.zoCore.package
|
|
1080
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
1060
1081
|
let metadata = this.consts.zoCore.zlpMetadata
|
|
1061
1082
|
if (coin !== 'zlp') {
|
|
1062
1083
|
module = this.consts.coins[coin].module
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"zo_core": {
|
|
3
3
|
"package": "0x7fd8aba1652c58b6397c799fd375e748e5053145cb7e126d303e0a1545fd1fec",
|
|
4
|
-
"upgraded_package": "
|
|
4
|
+
"upgraded_package": "0x93f66649a5c82835a8d8628ad88a85a2d67fd49d044ef6144bf7d8621da77dfd",
|
|
5
5
|
"upgrade_cap": "0x2f67d379d3b9e256a9c4079de50f4bd336dcbda1bd90d1fcd61a9cc1dc369d69",
|
|
6
6
|
"admin_cap": "0x63af8e78701327be98e0c44967389148c374f4ea7c7cf8acf64957b705ffd02d",
|
|
7
7
|
"market": "0x3310c794d0bbc4b0421d2fedc74fbd5a028b09fe4d396cd5458786f4c52fa636",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"zo_core": {
|
|
3
3
|
"package": "0xf7fade57462e56e2eff1d7adef32e4fd285b21fd81f983f407bb7110ca766cda",
|
|
4
|
-
"upgraded_package": "
|
|
4
|
+
"upgraded_package": "0x25a1d518373e465f1bff4c4ab069e160f9c30da9d9a2cb5a17f5bd645ab62ea4",
|
|
5
5
|
"upgrade_cap": "0xcc96f78abe0b868afaab05954ccc6357afb5d379a21389d6eb88dda8b1f60052",
|
|
6
6
|
"admin_cap": "0xbc10f6481f2b5d6185c73ee680aa90a60fe3854d9f638e00f7e00d3b6a88e2b8",
|
|
7
7
|
"market": "0x35c667bd8c401036103992791a924f31df0d104256a9e2313acee5b1bcf05b7e",
|