zo-sdk 0.1.19 → 0.1.21
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/abstract/BaseDataAPI.d.cts +2 -2
- package/dist/abstract/BaseDataAPI.d.cts.map +1 -1
- package/dist/abstract/BaseDataAPI.d.mts +2 -2
- package/dist/abstract/BaseDataAPI.d.mts.map +1 -1
- package/dist/consts/deployments-zlp-mainnet.json +16 -0
- package/dist/consts/deployments-zlp-testnet.json +16 -0
- package/dist/consts/index.cjs.map +1 -1
- package/dist/consts/index.d.cts +10 -0
- package/dist/consts/index.d.cts.map +1 -1
- package/dist/consts/index.d.mts +10 -0
- package/dist/consts/index.d.mts.map +1 -1
- package/dist/consts/index.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +32 -54
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.d.cts +2 -2
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/SLPDataAPI.d.mts +2 -2
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +32 -54
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +1 -1
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +1 -1
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +1 -1
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +1 -1
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +45 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +2 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +2 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +45 -0
- 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/dist/interfaces/zlp.d.cts +2 -0
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +2 -0
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/package.json +8 -8
- package/src/abstract/BaseDataAPI.ts +2 -2
- package/src/consts/deployments-zlp-mainnet.json +16 -0
- package/src/consts/deployments-zlp-testnet.json +16 -0
- package/src/consts/index.ts +10 -0
- package/src/implementations/SLPDataAPI.ts +41 -71
- package/src/implementations/USDZAPI.ts +1 -1
- package/src/implementations/ZLPAPI.ts +63 -0
- package/src/interfaces/base.ts +2 -2
- package/src/interfaces/zlp.ts +15 -0
|
@@ -326,47 +326,33 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
|
|
|
326
326
|
public async getPositionInfoList(
|
|
327
327
|
positionCapInfoList: ISLPPositionCapInfo[],
|
|
328
328
|
owner: string,
|
|
329
|
-
batchSize = 10,
|
|
330
329
|
): Promise<ISLPPositionInfo[]> {
|
|
331
330
|
const positionInfoList: ISLPPositionInfo[] = []
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const positionRaw = await this.provider.getDynamicFieldObject({
|
|
340
|
-
parentId: this.consts.sudoCore.positionsParent,
|
|
341
|
-
name: {
|
|
342
|
-
type: `${this.consts.sudoCore.package}::market::PositionName<${
|
|
343
|
-
positionCapInfo.symbol0
|
|
344
|
-
}, ${positionCapInfo.symbol1}, ${
|
|
345
|
-
this.consts.sudoCore.package
|
|
331
|
+
await Promise.all(
|
|
332
|
+
positionCapInfoList.map(async (positionCapInfo) => {
|
|
333
|
+
const positionRaw = await this.provider.getDynamicFieldObject({
|
|
334
|
+
parentId: this.consts.sudoCore.positionsParent,
|
|
335
|
+
name: {
|
|
336
|
+
type: `${this.consts.sudoCore.package}::market::PositionName<${positionCapInfo.symbol0
|
|
337
|
+
}, ${positionCapInfo.symbol1}, ${this.consts.sudoCore.package
|
|
346
338
|
}::market::${positionCapInfo.long ? 'LONG' : 'SHORT'}>`,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
},
|
|
339
|
+
value: {
|
|
340
|
+
owner,
|
|
341
|
+
id: positionCapInfo.positionCapId,
|
|
351
342
|
},
|
|
352
|
-
}
|
|
343
|
+
},
|
|
344
|
+
})
|
|
353
345
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
catch (error) {
|
|
364
|
-
// Position might have been deleted after force settlement
|
|
365
|
-
console.warn(`Failed to parse position info for position cap ID ${positionCapInfo.positionCapId}: ${error}`)
|
|
366
|
-
// Continue with next position without adding this one to the list
|
|
346
|
+
if (positionRaw?.data?.content) {
|
|
347
|
+
positionInfoList.push(
|
|
348
|
+
await this.parsePositionInfo(
|
|
349
|
+
positionRaw,
|
|
350
|
+
positionCapInfo.positionCapId,
|
|
351
|
+
),
|
|
352
|
+
)
|
|
367
353
|
}
|
|
368
|
-
})
|
|
369
|
-
|
|
354
|
+
}),
|
|
355
|
+
)
|
|
370
356
|
|
|
371
357
|
return positionInfoList.sort((a, b) =>
|
|
372
358
|
a.openTimestamp > b.openTimestamp ? 1 : -1,
|
|
@@ -822,47 +808,31 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
|
|
|
822
808
|
public async getOrderInfoList(
|
|
823
809
|
orderCapInfoList: ISLPOrderCapInfo[],
|
|
824
810
|
owner: string,
|
|
825
|
-
batchSize = 10,
|
|
826
811
|
): Promise<ISLPOrderInfo[]> {
|
|
827
812
|
const orderInfoList: ISLPOrderInfo[] = []
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
parentId: this.consts.sudoCore.ordersParent,
|
|
837
|
-
name: {
|
|
838
|
-
type: `${this.consts.sudoCore.package}::market::OrderName<${
|
|
839
|
-
orderCapInfo.symbol0
|
|
840
|
-
}, ${orderCapInfo.symbol1}, ${
|
|
841
|
-
this.consts.sudoCore.package
|
|
842
|
-
}::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${
|
|
843
|
-
this.consts.coins.sui.module
|
|
813
|
+
await Promise.all(
|
|
814
|
+
orderCapInfoList.map(async (orderCapInfo) => {
|
|
815
|
+
const orderRaw = await this.provider.getDynamicFieldObject({
|
|
816
|
+
parentId: this.consts.sudoCore.ordersParent,
|
|
817
|
+
name: {
|
|
818
|
+
type: `${this.consts.sudoCore.package}::market::OrderName<${orderCapInfo.symbol0
|
|
819
|
+
}, ${orderCapInfo.symbol1}, ${this.consts.sudoCore.package
|
|
820
|
+
}::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${this.consts.coins.sui.module
|
|
844
821
|
}>`,
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
},
|
|
822
|
+
value: {
|
|
823
|
+
owner,
|
|
824
|
+
id: orderCapInfo.orderCapId,
|
|
825
|
+
position_id: {
|
|
826
|
+
vec: orderCapInfo.positionId ? [orderCapInfo.positionId] : [],
|
|
851
827
|
},
|
|
852
828
|
},
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
)
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
console.warn(`Failed to parse order info for order cap ID ${orderCapInfo.orderCapId}: ${error}`)
|
|
861
|
-
// Continue with next order without adding this one to the list
|
|
862
|
-
}
|
|
863
|
-
}))
|
|
864
|
-
}
|
|
865
|
-
|
|
829
|
+
},
|
|
830
|
+
})
|
|
831
|
+
orderInfoList.push(
|
|
832
|
+
this.parseOrderInfo(orderRaw, orderCapInfo.orderCapId),
|
|
833
|
+
)
|
|
834
|
+
}),
|
|
835
|
+
)
|
|
866
836
|
return orderInfoList.sort((a, b) => (a.createdAt > b.createdAt ? 1 : -1))
|
|
867
837
|
}
|
|
868
838
|
|
|
@@ -113,7 +113,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
113
113
|
throw new Error(`Method not implemented in ${this.constructor.name}.`)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
public getPositionInfoList(_positionCapInfoList: IBasePositionCapInfo[], _owner: string
|
|
116
|
+
public getPositionInfoList(_positionCapInfoList: IBasePositionCapInfo[], _owner: string): Promise<IBasePositionInfo[]> {
|
|
117
117
|
throw new Error(`Method not implemented in ${this.constructor.name}.`)
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -1390,4 +1390,67 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1390
1390
|
|
|
1391
1391
|
return tx
|
|
1392
1392
|
}
|
|
1393
|
+
|
|
1394
|
+
// V2 Lootbox Methods for new contract
|
|
1395
|
+
public adminIssueLootboxV2(
|
|
1396
|
+
coin: string,
|
|
1397
|
+
tiers: number[],
|
|
1398
|
+
beneficiaries: string[],
|
|
1399
|
+
amounts: number[],
|
|
1400
|
+
titles: string[],
|
|
1401
|
+
descriptions: string[],
|
|
1402
|
+
tx: Transaction,
|
|
1403
|
+
): void {
|
|
1404
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
1405
|
+
if (coin !== 'zlp') {
|
|
1406
|
+
module = this.consts.coins[coin].module
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
for (const [i, beneficiary] of beneficiaries.entries()) {
|
|
1410
|
+
const moveCallArgs = {
|
|
1411
|
+
target: `${this.consts.zoLootboxV2.package}::lootbox::admin_issue_lootbox`,
|
|
1412
|
+
typeArguments: [module],
|
|
1413
|
+
arguments: [
|
|
1414
|
+
tx.object(this.consts.zoLootboxV2.adminCap),
|
|
1415
|
+
tx.object(this.consts.zoLootboxV2.lootboxTreasury),
|
|
1416
|
+
tx.pure.u8(tiers[i]),
|
|
1417
|
+
tx.pure.address(beneficiary),
|
|
1418
|
+
tx.pure.u64(amounts[i]),
|
|
1419
|
+
tx.pure.bool(amounts[i] > 0),
|
|
1420
|
+
tx.pure.string(titles[i]),
|
|
1421
|
+
tx.pure.string(descriptions[i]),
|
|
1422
|
+
tx.object(`${this.consts.zoLootboxV2.lootboxSettings}`),
|
|
1423
|
+
],
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
tx.moveCall(moveCallArgs)
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
public openLootboxV2(
|
|
1431
|
+
coin: string,
|
|
1432
|
+
lootbox: string,
|
|
1433
|
+
): Transaction {
|
|
1434
|
+
const tx = new Transaction()
|
|
1435
|
+
|
|
1436
|
+
let module = `${this.consts.zoCore.package}::zlp::ZLP`
|
|
1437
|
+
let metadata = this.consts.zoCore.zlpMetadata
|
|
1438
|
+
if (coin !== 'zlp') {
|
|
1439
|
+
module = this.consts.coins[coin].module
|
|
1440
|
+
metadata = this.consts.coins[coin].metadata
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
tx.moveCall({
|
|
1444
|
+
target: `${this.consts.zoLootboxV2.package}::lootbox::open_lootbox`,
|
|
1445
|
+
typeArguments: [module],
|
|
1446
|
+
arguments: [
|
|
1447
|
+
tx.object(this.consts.zoLootboxV2.lootboxTreasury),
|
|
1448
|
+
tx.object(lootbox),
|
|
1449
|
+
tx.object(metadata),
|
|
1450
|
+
tx.object(this.consts.zoLootboxV2.lootboxSettings),
|
|
1451
|
+
],
|
|
1452
|
+
})
|
|
1453
|
+
|
|
1454
|
+
return tx
|
|
1455
|
+
}
|
|
1393
1456
|
}
|
package/src/interfaces/base.ts
CHANGED
|
@@ -238,9 +238,9 @@ export interface IBaseDataAPI {
|
|
|
238
238
|
|
|
239
239
|
// User data methods
|
|
240
240
|
getPositionCapInfoList: (owner: string) => Promise<IBasePositionCapInfo[]>
|
|
241
|
-
getPositionInfoList: (positionCapInfoList: IBasePositionCapInfo[], owner: string
|
|
241
|
+
getPositionInfoList: (positionCapInfoList: IBasePositionCapInfo[], owner: string) => Promise<IBasePositionInfo[]>
|
|
242
242
|
getOrderCapInfoList: (owner: string) => Promise<IBaseOrderCapInfo[]>
|
|
243
|
-
getOrderInfoList: (orderCapInfoList: IBaseOrderCapInfo[], owner: string
|
|
243
|
+
getOrderInfoList: (orderCapInfoList: IBaseOrderCapInfo[], owner: string) => Promise<IBaseOrderInfo[]>
|
|
244
244
|
getHistory: (trader: string, page: number, limit: number, orderType?: string, symbol?: string) => Promise<IBaseHistoryResponse>
|
|
245
245
|
|
|
246
246
|
// Staking methods
|
package/src/interfaces/zlp.ts
CHANGED
|
@@ -118,4 +118,19 @@ export interface IZLPAPI extends IBaseAPI {
|
|
|
118
118
|
coin: string,
|
|
119
119
|
lootbox: string
|
|
120
120
|
) => Transaction
|
|
121
|
+
|
|
122
|
+
adminIssueLootboxV2: (
|
|
123
|
+
coin: string,
|
|
124
|
+
tiers: number[],
|
|
125
|
+
beneficiaries: string[],
|
|
126
|
+
amounts: number[],
|
|
127
|
+
titles: string[],
|
|
128
|
+
descriptions: string[],
|
|
129
|
+
tx: Transaction,
|
|
130
|
+
) => void
|
|
131
|
+
|
|
132
|
+
openLootboxV2: (
|
|
133
|
+
coin: string,
|
|
134
|
+
lootbox: string
|
|
135
|
+
) => Transaction
|
|
121
136
|
}
|