zo-sdk 0.1.89 → 0.1.91
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/consts/deployments-slp-mainnet.json +2 -2
- package/dist/implementations/SLPAPI.cjs +54 -58
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +2 -2
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +2 -2
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +54 -58
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +52 -58
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +2 -2
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +2 -2
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +52 -58
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +52 -58
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +2 -2
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +2 -2
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +52 -58
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/interfaces/base.d.cts +2 -2
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +2 -2
- package/dist/interfaces/base.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/consts/deployments-slp-mainnet.json +2 -2
- package/src/implementations/SLPAPI.ts +53 -74
- package/src/implementations/USDZAPI.ts +52 -74
- package/src/implementations/ZLPAPI.ts +51 -74
- package/src/interfaces/base.ts +2 -0
|
@@ -1356,26 +1356,25 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1356
1356
|
collateralSlippage?: number
|
|
1357
1357
|
relayerFee?: bigint
|
|
1358
1358
|
coinObjects?: string[]
|
|
1359
|
-
}>, tx?: Transaction, sponsoredTx?: boolean, suiCoinObjectsForPythUpdate?: string[]): Promise<Transaction> {
|
|
1360
|
-
|
|
1361
|
-
tx = new Transaction()
|
|
1362
|
-
}
|
|
1359
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, suiCoinObjectsForPythUpdate?: string[], feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
|
|
1360
|
+
const transaction = tx ?? new Transaction()
|
|
1363
1361
|
|
|
1364
1362
|
// Handle oracle initialization and coin processing
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1363
|
+
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
1364
|
+
const suiCoinObject = sponsoredTx
|
|
1365
|
+
? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
1366
|
+
: undefined
|
|
1367
|
+
await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject)
|
|
1368
|
+
|
|
1369
|
+
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
1370
|
+
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
1372
1371
|
}
|
|
1373
1372
|
|
|
1374
|
-
for (const position of positions) {
|
|
1373
|
+
for (const [i, position] of positions.entries()) {
|
|
1374
|
+
const feeObject = feeObjects[i]
|
|
1375
1375
|
const {
|
|
1376
1376
|
pcpId,
|
|
1377
1377
|
collateralToken,
|
|
1378
|
-
coinObjects = [],
|
|
1379
1378
|
indexToken,
|
|
1380
1379
|
amount,
|
|
1381
1380
|
long,
|
|
@@ -1386,7 +1385,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1386
1385
|
isIocOrder = false,
|
|
1387
1386
|
pricesSlippage = 0.003,
|
|
1388
1387
|
collateralSlippage = 0.5,
|
|
1389
|
-
relayerFee = BigInt(0.5),
|
|
1390
1388
|
} = position
|
|
1391
1389
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
1392
1390
|
|
|
@@ -1402,17 +1400,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1402
1400
|
innerIsTakeProfitOrder = true
|
|
1403
1401
|
}
|
|
1404
1402
|
|
|
1405
|
-
|
|
1406
|
-
const [feeObject] = this.processCoinSplitting(
|
|
1407
|
-
tx,
|
|
1408
|
-
collateralToken,
|
|
1409
|
-
coinObjects,
|
|
1410
|
-
[tx.pure.u64(relayerFee)],
|
|
1411
|
-
sponsoredTx,
|
|
1412
|
-
suiCoinObject,
|
|
1413
|
-
)
|
|
1414
|
-
|
|
1415
|
-
tx.moveCall({
|
|
1403
|
+
transaction.moveCall({
|
|
1416
1404
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_v2`,
|
|
1417
1405
|
typeArguments: [
|
|
1418
1406
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
@@ -1422,22 +1410,22 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1422
1410
|
this.consts.coins[collateralToken].module,
|
|
1423
1411
|
],
|
|
1424
1412
|
arguments: [
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1413
|
+
transaction.object(SUI_CLOCK_OBJECT_ID),
|
|
1414
|
+
transaction.object(this.consts.zoCore.market),
|
|
1415
|
+
transaction.object(pcpId),
|
|
1416
|
+
transaction.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
1417
|
+
transaction.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
1430
1418
|
feeObject,
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1419
|
+
transaction.pure.u8(allowTrade),
|
|
1420
|
+
transaction.pure.bool(innerIsTakeProfitOrder),
|
|
1421
|
+
transaction.pure.u64(amount),
|
|
1422
|
+
transaction.pure.u256(adjustCollateralPrice),
|
|
1423
|
+
transaction.pure.u256(adjustPrice),
|
|
1424
|
+
transaction.pure.u256(indexPriceThreshold),
|
|
1437
1425
|
],
|
|
1438
1426
|
})
|
|
1439
1427
|
}
|
|
1440
|
-
return
|
|
1428
|
+
return transaction
|
|
1441
1429
|
}
|
|
1442
1430
|
|
|
1443
1431
|
public async openPositionWithSCard(
|
|
@@ -2223,23 +2211,23 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2223
2211
|
tx?: Transaction,
|
|
2224
2212
|
sponsoredTx?: boolean,
|
|
2225
2213
|
suiCoinObjectsForPythUpdate?: string[],
|
|
2214
|
+
feeObjects?: TransactionObjectArgument[],
|
|
2226
2215
|
): Promise<Transaction> {
|
|
2227
|
-
|
|
2228
|
-
tx = new Transaction()
|
|
2229
|
-
}
|
|
2216
|
+
const transaction = tx ?? new Transaction()
|
|
2230
2217
|
|
|
2231
2218
|
// Handle oracle initialization and coin processing
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2219
|
+
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
2220
|
+
const suiCoinObject = sponsoredTx
|
|
2221
|
+
? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
2222
|
+
: undefined
|
|
2223
|
+
await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject)
|
|
2224
|
+
|
|
2225
|
+
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
2226
|
+
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
2239
2227
|
}
|
|
2240
2228
|
|
|
2241
2229
|
const kioskTx = new KioskTransaction({
|
|
2242
|
-
transaction
|
|
2230
|
+
transaction,
|
|
2243
2231
|
kioskClient,
|
|
2244
2232
|
cap: kioskCap,
|
|
2245
2233
|
})
|
|
@@ -2249,7 +2237,8 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2249
2237
|
itemId: scard,
|
|
2250
2238
|
})
|
|
2251
2239
|
|
|
2252
|
-
for (const position of positions) {
|
|
2240
|
+
for (const [i, position] of positions.entries()) {
|
|
2241
|
+
const feeObject = feeObjects[i]
|
|
2253
2242
|
const {
|
|
2254
2243
|
pcpId,
|
|
2255
2244
|
collateralToken,
|
|
@@ -2263,8 +2252,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2263
2252
|
isIocOrder = false,
|
|
2264
2253
|
pricesSlippage = 0.003,
|
|
2265
2254
|
collateralSlippage = 0.5,
|
|
2266
|
-
relayerFee = BigInt(0.5),
|
|
2267
|
-
coinObjects = [],
|
|
2268
2255
|
} = position
|
|
2269
2256
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
2270
2257
|
|
|
@@ -2280,17 +2267,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2280
2267
|
innerIsTakeProfitOrder = true
|
|
2281
2268
|
}
|
|
2282
2269
|
|
|
2283
|
-
|
|
2284
|
-
const [feeObject] = this.processCoinSplitting(
|
|
2285
|
-
tx,
|
|
2286
|
-
collateralToken,
|
|
2287
|
-
coinObjects,
|
|
2288
|
-
[tx.pure.u64(relayerFee)],
|
|
2289
|
-
sponsoredTx,
|
|
2290
|
-
suiCoinObject,
|
|
2291
|
-
)
|
|
2292
|
-
|
|
2293
|
-
tx.moveCall({
|
|
2270
|
+
transaction.moveCall({
|
|
2294
2271
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
2295
2272
|
typeArguments: [
|
|
2296
2273
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
@@ -2300,18 +2277,18 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2300
2277
|
this.consts.coins[collateralToken].module,
|
|
2301
2278
|
],
|
|
2302
2279
|
arguments: [
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2280
|
+
transaction.object(SUI_CLOCK_OBJECT_ID),
|
|
2281
|
+
transaction.object(this.consts.zoCore.market),
|
|
2282
|
+
transaction.object(pcpId),
|
|
2283
|
+
transaction.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
2284
|
+
transaction.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
2308
2285
|
feeObject,
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2286
|
+
transaction.pure.u8(allowTrade),
|
|
2287
|
+
transaction.pure.bool(innerIsTakeProfitOrder),
|
|
2288
|
+
transaction.pure.u64(amount),
|
|
2289
|
+
transaction.pure.u256(adjustCollateralPrice),
|
|
2290
|
+
transaction.pure.u256(adjustPrice),
|
|
2291
|
+
transaction.pure.u256(indexPriceThreshold),
|
|
2315
2292
|
sudoCard,
|
|
2316
2293
|
],
|
|
2317
2294
|
})
|
|
@@ -2324,7 +2301,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2324
2301
|
promise,
|
|
2325
2302
|
})
|
|
2326
2303
|
.finalize()
|
|
2327
|
-
return
|
|
2304
|
+
return transaction
|
|
2328
2305
|
}
|
|
2329
2306
|
|
|
2330
2307
|
/**
|
package/src/interfaces/base.ts
CHANGED
|
@@ -483,6 +483,7 @@ export interface IBaseAPI {
|
|
|
483
483
|
tx?: Transaction,
|
|
484
484
|
sponsoredTx?: boolean,
|
|
485
485
|
suiCoinObjectsForPythUpdate?: string[],
|
|
486
|
+
feeObjects?: TransactionObjectArgument[],
|
|
486
487
|
) => Promise<Transaction>
|
|
487
488
|
|
|
488
489
|
pledgeInPosition: (
|
|
@@ -762,6 +763,7 @@ export interface IBaseAPI {
|
|
|
762
763
|
tx?: Transaction,
|
|
763
764
|
sponsoredTx?: boolean,
|
|
764
765
|
suiCoinObjectsForPythUpdate?: string[],
|
|
766
|
+
feeObjects?: TransactionObjectArgument[],
|
|
765
767
|
) => Promise<Transaction>
|
|
766
768
|
|
|
767
769
|
claimTokenFromSCard: (
|