zo-sdk 0.1.13 → 0.1.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.
- 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/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 +4 -4
- package/dist/implementations/USDZDataAPI.cjs.map +1 -1
- package/dist/implementations/USDZDataAPI.mjs +4 -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/package.json +1 -1
- package/src/api.ts +121 -100
- package/src/consts/deployments-usdz-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 +4 -4
- package/src/implementations/ZLPAPI.ts +18 -18
- package/src/implementations/ZLPDataAPI.ts +4 -4
package/src/data.ts
CHANGED
|
@@ -201,12 +201,12 @@ export interface IStakePool {
|
|
|
201
201
|
|
|
202
202
|
export interface IMarketValidationResult {
|
|
203
203
|
handledVaults: Record<string, {
|
|
204
|
-
weight: number
|
|
205
|
-
value: number
|
|
206
|
-
}
|
|
207
|
-
totalWeight: number
|
|
208
|
-
totalVaultsValue: number
|
|
209
|
-
marketValue: number
|
|
204
|
+
weight: number
|
|
205
|
+
value: number
|
|
206
|
+
}>
|
|
207
|
+
totalWeight: number
|
|
208
|
+
totalVaultsValue: number
|
|
209
|
+
marketValue: number
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
export class DataAPI extends OracleAPI {
|
|
@@ -248,7 +248,7 @@ export class DataAPI extends OracleAPI {
|
|
|
248
248
|
|
|
249
249
|
valuateVaults = (tx: Transaction) => {
|
|
250
250
|
const vaultsValuation = tx.moveCall({
|
|
251
|
-
target: `${this.consts.zoCore.
|
|
251
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_vaults_valuation`,
|
|
252
252
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
253
253
|
arguments: [
|
|
254
254
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -259,7 +259,7 @@ export class DataAPI extends OracleAPI {
|
|
|
259
259
|
const vault = this.consts.zoCore.vaults[key]
|
|
260
260
|
tx.moveCall({
|
|
261
261
|
// todo
|
|
262
|
-
target: `${this.consts.zoCore.
|
|
262
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_vault`,
|
|
263
263
|
typeArguments: [
|
|
264
264
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
265
265
|
this.consts.coins[key].module,
|
|
@@ -277,7 +277,7 @@ export class DataAPI extends OracleAPI {
|
|
|
277
277
|
|
|
278
278
|
valuateSymbols = (tx: Transaction) => {
|
|
279
279
|
const symbolsValuation = tx.moveCall({
|
|
280
|
-
target: `${this.consts.zoCore.
|
|
280
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_symbols_valuation`,
|
|
281
281
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
282
282
|
arguments: [
|
|
283
283
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -288,7 +288,7 @@ export class DataAPI extends OracleAPI {
|
|
|
288
288
|
const [direction, token] = parseSymbolKey(key)
|
|
289
289
|
const symbol = this.consts.zoCore.symbols[key]
|
|
290
290
|
tx.moveCall({
|
|
291
|
-
target: `${this.consts.zoCore.
|
|
291
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_symbol`,
|
|
292
292
|
typeArguments: [
|
|
293
293
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
294
294
|
this.consts.coins[token].module,
|
|
@@ -322,8 +322,8 @@ export class DataAPI extends OracleAPI {
|
|
|
322
322
|
*/
|
|
323
323
|
validateMarketValuation = (tx: Transaction) => {
|
|
324
324
|
// First, create the valuations using existing methods
|
|
325
|
-
const vaultsValuation = this.valuateVaults(tx)
|
|
326
|
-
const symbolsValuation = this.valuateSymbols(tx)
|
|
325
|
+
const vaultsValuation = this.valuateVaults(tx)
|
|
326
|
+
const symbolsValuation = this.valuateSymbols(tx)
|
|
327
327
|
|
|
328
328
|
// Call the validate_market_valuation Move function
|
|
329
329
|
const result = tx.moveCall({
|
|
@@ -334,9 +334,9 @@ export class DataAPI extends OracleAPI {
|
|
|
334
334
|
vaultsValuation,
|
|
335
335
|
symbolsValuation,
|
|
336
336
|
],
|
|
337
|
-
})
|
|
337
|
+
})
|
|
338
338
|
|
|
339
|
-
return result
|
|
339
|
+
return result
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
#parseMarketInfo(raw: any): IMarketInfo {
|
|
@@ -715,9 +715,9 @@ export class DataAPI extends OracleAPI {
|
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
public async getPositionCapInfoList(owner: string): Promise<IPositionCapInfo[]> {
|
|
718
|
-
const positionCapInfoList: IPositionCapInfo[] = []
|
|
719
|
-
let cursor: string | undefined | null
|
|
720
|
-
let hasNextPage = true
|
|
718
|
+
const positionCapInfoList: IPositionCapInfo[] = []
|
|
719
|
+
let cursor: string | undefined | null
|
|
720
|
+
let hasNextPage = true
|
|
721
721
|
|
|
722
722
|
while (hasNextPage) {
|
|
723
723
|
const positionCaps = await this.provider.getOwnedObjects({
|
|
@@ -753,7 +753,7 @@ export class DataAPI extends OracleAPI {
|
|
|
753
753
|
return positionCapInfoList
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
-
public async getPositionInfoList(positionCapInfoList: IPositionCapInfo[], owner: string, batchSize
|
|
756
|
+
public async getPositionInfoList(positionCapInfoList: IPositionCapInfo[], owner: string, batchSize = 10) {
|
|
757
757
|
const positionInfoList: IPositionInfo[] = []
|
|
758
758
|
|
|
759
759
|
// Process in batches of 10
|
|
@@ -773,7 +773,8 @@ export class DataAPI extends OracleAPI {
|
|
|
773
773
|
},
|
|
774
774
|
})
|
|
775
775
|
positionInfoList.push(await this.#parsePositionInfo(positionRaw, positionCapInfo.positionCapId))
|
|
776
|
-
}
|
|
776
|
+
}
|
|
777
|
+
catch (error) {
|
|
777
778
|
// Position might have been deleted after force settlement
|
|
778
779
|
console.warn(`Failed to parse position info for position cap ID ${positionCapInfo.positionCapId}: ${error}`)
|
|
779
780
|
// Continue with next position without adding this one to the list
|
|
@@ -785,82 +786,83 @@ export class DataAPI extends OracleAPI {
|
|
|
785
786
|
}
|
|
786
787
|
|
|
787
788
|
// find all open positions by positionsParent
|
|
788
|
-
public async getOpenPositions(batchSize
|
|
789
|
-
let positionDynamicFields: DynamicFieldInfo[] = []
|
|
790
|
-
let _continue = true
|
|
791
|
-
let cursor
|
|
789
|
+
public async getOpenPositions(batchSize = 50, symbol = 'sui') {
|
|
790
|
+
let positionDynamicFields: DynamicFieldInfo[] = []
|
|
791
|
+
let _continue = true
|
|
792
|
+
let cursor
|
|
792
793
|
while (_continue) {
|
|
793
794
|
// data here will be a list of dynamic fields containing name and value
|
|
794
|
-
const { data, nextCursor, hasNextPage }
|
|
795
|
-
await this.provider.getDynamicFields({
|
|
795
|
+
const { data, nextCursor, hasNextPage }
|
|
796
|
+
= await this.provider.getDynamicFields({
|
|
796
797
|
parentId: this.consts.zoCore.positionsParent,
|
|
797
798
|
cursor,
|
|
798
|
-
})
|
|
799
|
+
})
|
|
799
800
|
|
|
800
|
-
positionDynamicFields = positionDynamicFields.concat(data)
|
|
801
|
-
_continue = hasNextPage
|
|
802
|
-
cursor = nextCursor
|
|
801
|
+
positionDynamicFields = positionDynamicFields.concat(data)
|
|
802
|
+
_continue = hasNextPage
|
|
803
|
+
cursor = nextCursor
|
|
803
804
|
}
|
|
804
805
|
|
|
805
806
|
// Filter by symbol if provided
|
|
806
|
-
if (symbol && this.consts.coins[symbol]) {
|
|
807
|
-
|
|
808
|
-
positionDynamicFields = positionDynamicFields.filter(field => {
|
|
809
|
-
// Extract the second coin module from PositionName<coin1, coin2, direction>
|
|
810
|
-
const typeStr = field.name?.type;
|
|
811
|
-
if (!typeStr) return false;
|
|
812
|
-
|
|
813
|
-
const match = typeStr.match(/PositionName<([^,]+),\s*([^,]+),\s*([^>]+)>/);
|
|
814
|
-
if (!match) return false;
|
|
815
|
-
|
|
816
|
-
const secondCoin = match[2].trim();
|
|
817
|
-
return secondCoin === coinModule;
|
|
818
|
-
});
|
|
819
|
-
} else {
|
|
820
|
-
return [];
|
|
807
|
+
if (!(symbol && this.consts.coins[symbol])) {
|
|
808
|
+
return []
|
|
821
809
|
}
|
|
810
|
+
const coinModule = symbol === 'sui' ? '0x2::sui::SUI' : this.consts.coins[symbol].module
|
|
811
|
+
positionDynamicFields = positionDynamicFields.filter((field) => {
|
|
812
|
+
// Extract the second coin module from PositionName<coin1, coin2, direction>
|
|
813
|
+
const typeStr = field.name?.type
|
|
814
|
+
if (!typeStr)
|
|
815
|
+
return false
|
|
816
|
+
|
|
817
|
+
const match = typeStr.match(/PositionName<([^,]+),\s*([^,]+),\s*([^>]+)>/)
|
|
818
|
+
if (!match)
|
|
819
|
+
return false
|
|
820
|
+
|
|
821
|
+
const secondCoin = match[2].trim()
|
|
822
|
+
return secondCoin === coinModule
|
|
823
|
+
})
|
|
822
824
|
|
|
823
825
|
// then we query by dynamic field names and order by time
|
|
824
|
-
const positionInfoList: IPositionInfo[] = []
|
|
825
|
-
|
|
826
|
+
const positionInfoList: IPositionInfo[] = []
|
|
827
|
+
|
|
826
828
|
// Process in batches of 50 (or specified batchSize)
|
|
827
829
|
for (let i = 0; i < positionDynamicFields.length; i += batchSize) {
|
|
828
|
-
const batch = positionDynamicFields.slice(i, i + batchSize)
|
|
829
|
-
|
|
830
|
+
const batch = positionDynamicFields.slice(i, i + batchSize)
|
|
831
|
+
|
|
830
832
|
await Promise.all(
|
|
831
|
-
batch.map(async positionDynamicField => {
|
|
833
|
+
batch.map(async (positionDynamicField) => {
|
|
832
834
|
const positionRaw = await this.provider.getDynamicFieldObject({
|
|
833
835
|
parentId: this.consts.zoCore.positionsParent,
|
|
834
836
|
name: positionDynamicField.name,
|
|
835
|
-
})
|
|
837
|
+
})
|
|
836
838
|
|
|
837
839
|
if (positionRaw?.data?.content) {
|
|
838
840
|
// @ts-ignore
|
|
839
841
|
if (positionRaw?.data?.content?.fields?.value?.fields?.closed) {
|
|
840
842
|
// skip closed positions
|
|
841
|
-
return
|
|
843
|
+
return
|
|
842
844
|
}
|
|
843
845
|
const positionInfo = await this.#parsePositionInfo(
|
|
844
846
|
positionRaw,
|
|
845
847
|
positionDynamicField.objectId,
|
|
846
|
-
)
|
|
848
|
+
)
|
|
847
849
|
if (positionInfo) {
|
|
848
|
-
positionInfoList.push(positionInfo)
|
|
850
|
+
positionInfoList.push(positionInfo)
|
|
849
851
|
}
|
|
850
852
|
}
|
|
851
853
|
}),
|
|
852
|
-
)
|
|
854
|
+
)
|
|
853
855
|
}
|
|
854
856
|
|
|
855
857
|
return positionInfoList
|
|
856
858
|
.filter(positionInfo => !positionInfo.closed)
|
|
857
|
-
.sort((a, b) => (a.openTimestamp > b.openTimestamp ? 1 : -1))
|
|
859
|
+
.sort((a, b) => (a.openTimestamp > b.openTimestamp ? 1 : -1))
|
|
858
860
|
}
|
|
859
861
|
|
|
860
862
|
public async getOrderCapInfoList(owner: string): Promise<IOrderCapInfo[]> {
|
|
861
|
-
const orderCapInfoList: IOrderCapInfo[] = []
|
|
862
|
-
let cursor: string | undefined | null
|
|
863
|
-
let hasNextPage = true
|
|
863
|
+
const orderCapInfoList: IOrderCapInfo[] = []
|
|
864
|
+
let cursor: string | undefined | null
|
|
865
|
+
let hasNextPage = true
|
|
864
866
|
|
|
865
867
|
while (hasNextPage) {
|
|
866
868
|
const orderCaps = await this.provider.getOwnedObjects({
|
|
@@ -890,14 +892,14 @@ export class DataAPI extends OracleAPI {
|
|
|
890
892
|
}
|
|
891
893
|
}
|
|
892
894
|
|
|
893
|
-
hasNextPage = orderCaps.hasNextPage
|
|
894
|
-
cursor = orderCaps.nextCursor
|
|
895
|
+
hasNextPage = orderCaps.hasNextPage
|
|
896
|
+
cursor = orderCaps.nextCursor
|
|
895
897
|
}
|
|
896
898
|
|
|
897
899
|
return orderCapInfoList
|
|
898
900
|
}
|
|
899
901
|
|
|
900
|
-
public async getOrderInfoList(orderCapInfoList: IOrderCapInfo[], owner: string, batchSize
|
|
902
|
+
public async getOrderInfoList(orderCapInfoList: IOrderCapInfo[], owner: string, batchSize = 10) {
|
|
901
903
|
const orderInfoList: IOrderInfo[] = []
|
|
902
904
|
|
|
903
905
|
// Process in batches of 10
|
|
@@ -921,7 +923,8 @@ export class DataAPI extends OracleAPI {
|
|
|
921
923
|
},
|
|
922
924
|
})
|
|
923
925
|
orderInfoList.push(this.#parseOrderInfo(orderRaw, orderCapInfo.orderCapId))
|
|
924
|
-
}
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
925
928
|
// Order might have been deleted
|
|
926
929
|
console.warn(`Failed to parse order info for order cap ID ${orderCapInfo.orderCapId}: ${error}`)
|
|
927
930
|
// Continue with next order without adding this one to the list
|
|
@@ -1032,7 +1035,7 @@ export class DataAPI extends OracleAPI {
|
|
|
1032
1035
|
page = 1,
|
|
1033
1036
|
limit = 20,
|
|
1034
1037
|
orderType?: string,
|
|
1035
|
-
symbol?: string
|
|
1038
|
+
symbol?: string,
|
|
1036
1039
|
) => {
|
|
1037
1040
|
const params = new URLSearchParams({
|
|
1038
1041
|
trader,
|
|
@@ -467,7 +467,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
|
|
|
467
467
|
const symbol_ = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
468
468
|
const currentTimestamp = Number.parseInt((Date.now() / 1000).toFixed(0), 10)
|
|
469
469
|
const symbol = tx.moveCall({
|
|
470
|
-
target: `${this.consts.sudoCore.
|
|
470
|
+
target: `${this.consts.sudoCore.upgradedPackage}::market::symbol`,
|
|
471
471
|
typeArguments: [
|
|
472
472
|
`${this.consts.sudoCore.package}::slp::SLP`,
|
|
473
473
|
this.consts.coins[indexToken].module,
|
|
@@ -495,7 +495,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
|
|
|
495
495
|
arguments: [symbol, aggPrice, tx.pure.bool(long)],
|
|
496
496
|
})
|
|
497
497
|
const LpSupplyAmount = tx.moveCall({
|
|
498
|
-
target: `${this.consts.sudoCore.
|
|
498
|
+
target: `${this.consts.sudoCore.upgradedPackage}::market::lp_supply_amount`,
|
|
499
499
|
typeArguments: [`${this.consts.sudoCore.package}::slp::SLP`],
|
|
500
500
|
arguments: [tx.object(this.consts.sudoCore.market)],
|
|
501
501
|
})
|
|
@@ -155,7 +155,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
155
155
|
|
|
156
156
|
public clearClosedPosition(pcpId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction): void {
|
|
157
157
|
tx.moveCall({
|
|
158
|
-
target: `${this.consts.zoCore.
|
|
158
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::clear_closed_position`,
|
|
159
159
|
typeArguments: [
|
|
160
160
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
161
161
|
this.consts.coins[collateralToken].module,
|
|
@@ -169,7 +169,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
169
169
|
public clearOpenPositionOrder(orderCapId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction, isV11Order?: boolean): void {
|
|
170
170
|
const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order'
|
|
171
171
|
tx.moveCall({
|
|
172
|
-
target: `${this.consts.zoCore.
|
|
172
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
173
173
|
typeArguments: [
|
|
174
174
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
175
175
|
this.consts.coins[collateralToken].module,
|
|
@@ -184,7 +184,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
184
184
|
public clearDecreasePositionOrder(orderCapId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction, isV11Order?: boolean): void {
|
|
185
185
|
const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order'
|
|
186
186
|
tx.moveCall({
|
|
187
|
-
target: `${this.consts.zoCore.
|
|
187
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
188
188
|
typeArguments: [
|
|
189
189
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
190
190
|
this.consts.coins[collateralToken].module,
|
|
@@ -265,7 +265,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
265
265
|
)
|
|
266
266
|
|
|
267
267
|
tx.moveCall({
|
|
268
|
-
target: `${this.consts.zoCore.
|
|
268
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_with_scard`,
|
|
269
269
|
typeArguments: [
|
|
270
270
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
271
271
|
this.consts.coins[collateralToken].module,
|
|
@@ -374,7 +374,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
374
374
|
)
|
|
375
375
|
|
|
376
376
|
tx.moveCall({
|
|
377
|
-
target: `${this.consts.zoCore.
|
|
377
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
378
378
|
typeArguments: [
|
|
379
379
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
380
380
|
this.consts.coins[collateralToken].module,
|
|
@@ -501,7 +501,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
501
501
|
)
|
|
502
502
|
|
|
503
503
|
tx.moveCall({
|
|
504
|
-
target: `${this.consts.zoCore.
|
|
504
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
505
505
|
typeArguments: [
|
|
506
506
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
507
507
|
this.consts.coins[collateralToken].module,
|
|
@@ -574,7 +574,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
574
574
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
575
575
|
|
|
576
576
|
tx.moveCall({
|
|
577
|
-
target: `${this.consts.zoCore.
|
|
577
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
578
578
|
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`, this.consts.coins[coin].module],
|
|
579
579
|
arguments: [
|
|
580
580
|
tx.object(this.consts.zoCore.market),
|
|
@@ -598,7 +598,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
598
598
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
599
599
|
|
|
600
600
|
tx.moveCall({
|
|
601
|
-
target: `${this.consts.zoCore.
|
|
601
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
602
602
|
typeArguments: [
|
|
603
603
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
604
604
|
this.consts.coins[coin].module,
|
|
@@ -643,7 +643,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
643
643
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
644
644
|
|
|
645
645
|
tx.moveCall({
|
|
646
|
-
target: `${this.consts.zoCore.
|
|
646
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::withdraw`,
|
|
647
647
|
typeArguments: [
|
|
648
648
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
649
649
|
this.consts.coins[coin].module,
|
|
@@ -673,7 +673,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
673
673
|
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
674
674
|
|
|
675
675
|
tx.moveCall({
|
|
676
|
-
target: `${this.consts.zoCore.
|
|
676
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::swap`,
|
|
677
677
|
typeArguments: [
|
|
678
678
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
679
679
|
this.consts.coins[fromToken].module,
|
|
@@ -748,7 +748,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
748
748
|
)
|
|
749
749
|
|
|
750
750
|
tx.moveCall({
|
|
751
|
-
target: `${this.consts.zoCore.
|
|
751
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position`,
|
|
752
752
|
typeArguments: [
|
|
753
753
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
754
754
|
this.consts.coins[collateralToken].module,
|
|
@@ -835,7 +835,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
835
835
|
)
|
|
836
836
|
|
|
837
837
|
tx.moveCall({
|
|
838
|
-
target: `${this.consts.zoCore.
|
|
838
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
839
839
|
typeArguments: [
|
|
840
840
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
841
841
|
this.consts.coins[collateralToken].module,
|
|
@@ -935,7 +935,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
935
935
|
)
|
|
936
936
|
|
|
937
937
|
tx.moveCall({
|
|
938
|
-
target: `${this.consts.zoCore.
|
|
938
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
939
939
|
typeArguments: [
|
|
940
940
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
941
941
|
this.consts.coins[collateralToken].module,
|
|
@@ -998,7 +998,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
998
998
|
)
|
|
999
999
|
|
|
1000
1000
|
tx.moveCall({
|
|
1001
|
-
target: `${this.consts.zoCore.
|
|
1001
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::pledge_in_position`,
|
|
1002
1002
|
typeArguments: [
|
|
1003
1003
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1004
1004
|
this.consts.coins[collateralToken].module,
|
|
@@ -1032,7 +1032,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1032
1032
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
1033
1033
|
|
|
1034
1034
|
tx.moveCall({
|
|
1035
|
-
target: `${this.consts.zoCore.
|
|
1035
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::redeem_from_position`,
|
|
1036
1036
|
typeArguments: [
|
|
1037
1037
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1038
1038
|
this.consts.coins[collateralToken].module,
|
|
@@ -1080,7 +1080,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
1082
|
tx.moveCall({
|
|
1083
|
-
target: `${this.consts.zoCore.
|
|
1083
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
1084
1084
|
typeArguments: [
|
|
1085
1085
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1086
1086
|
this.consts.coins[collateralToken].module,
|
|
@@ -1128,7 +1128,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
1130
|
tx.moveCall({
|
|
1131
|
-
target: `${this.consts.zoCore.
|
|
1131
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
1132
1132
|
typeArguments: [
|
|
1133
1133
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1134
1134
|
this.consts.coins[collateralToken].module,
|
|
@@ -1150,7 +1150,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1150
1150
|
tx = new Transaction()
|
|
1151
1151
|
}
|
|
1152
1152
|
tx.moveCall({
|
|
1153
|
-
target: `${this.consts.zoCore.
|
|
1153
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::add_new_referral`,
|
|
1154
1154
|
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`],
|
|
1155
1155
|
arguments: [tx.object(this.consts.zoCore.market), tx.object(referralAddress)],
|
|
1156
1156
|
})
|
|
@@ -1210,7 +1210,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1210
1210
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
1211
1211
|
|
|
1212
1212
|
tx.moveCall({
|
|
1213
|
-
target: `${this.consts.zoCore.
|
|
1213
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_close_position`,
|
|
1214
1214
|
typeArguments: [
|
|
1215
1215
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1216
1216
|
this.consts.coins[collateralToken].module,
|
|
@@ -1246,7 +1246,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1246
1246
|
tx: Transaction,
|
|
1247
1247
|
): void {
|
|
1248
1248
|
tx.moveCall({
|
|
1249
|
-
target: `${this.consts.zoCore.
|
|
1249
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_clear_closed_position`,
|
|
1250
1250
|
typeArguments: [
|
|
1251
1251
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1252
1252
|
this.consts.coins[collateralToken].module,
|
|
@@ -54,7 +54,7 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
|
|
|
54
54
|
*/
|
|
55
55
|
public valuateVaults(tx: Transaction) {
|
|
56
56
|
const vaultsValuation = tx.moveCall({
|
|
57
|
-
target: `${this.consts.zoCore.
|
|
57
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_vaults_valuation`,
|
|
58
58
|
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`],
|
|
59
59
|
arguments: [
|
|
60
60
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -65,7 +65,7 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
|
|
|
65
65
|
for (const key of Object.keys(this.consts.zoCore.vaults)) {
|
|
66
66
|
const vault = this.consts.zoCore.vaults[key]
|
|
67
67
|
tx.moveCall({
|
|
68
|
-
target: `${this.consts.zoCore.
|
|
68
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_vault`,
|
|
69
69
|
typeArguments: [
|
|
70
70
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
71
71
|
this.consts.coins[key].module,
|
|
@@ -86,7 +86,7 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
|
|
|
86
86
|
*/
|
|
87
87
|
public valuateSymbols(tx: Transaction) {
|
|
88
88
|
const symbolsValuation = tx.moveCall({
|
|
89
|
-
target: `${this.consts.zoCore.
|
|
89
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_symbols_valuation`,
|
|
90
90
|
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`],
|
|
91
91
|
arguments: [
|
|
92
92
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -98,7 +98,7 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
|
|
|
98
98
|
const [direction, token] = parseSymbolKey(key)
|
|
99
99
|
const symbol = this.consts.zoCore.symbols[key]
|
|
100
100
|
tx.moveCall({
|
|
101
|
-
target: `${this.consts.zoCore.
|
|
101
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_symbol`,
|
|
102
102
|
typeArguments: [
|
|
103
103
|
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
104
104
|
this.consts.coins[token].module,
|
|
@@ -189,7 +189,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
189
189
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
190
190
|
|
|
191
191
|
tx.moveCall({
|
|
192
|
-
target: `${this.consts.zoCore.
|
|
192
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
193
193
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
|
|
194
194
|
arguments: [
|
|
195
195
|
tx.object(this.consts.zoCore.market),
|
|
@@ -213,7 +213,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
213
213
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
214
214
|
|
|
215
215
|
tx.moveCall({
|
|
216
|
-
target: `${this.consts.zoCore.
|
|
216
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
217
217
|
typeArguments: [
|
|
218
218
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
219
219
|
this.consts.coins[coin].module,
|
|
@@ -258,7 +258,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
258
258
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
259
259
|
|
|
260
260
|
tx.moveCall({
|
|
261
|
-
target: `${this.consts.zoCore.
|
|
261
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::withdraw`,
|
|
262
262
|
typeArguments: [
|
|
263
263
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
264
264
|
this.consts.coins[coin].module,
|
|
@@ -288,7 +288,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
288
288
|
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
289
289
|
|
|
290
290
|
tx.moveCall({
|
|
291
|
-
target: `${this.consts.zoCore.
|
|
291
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::swap`,
|
|
292
292
|
typeArguments: [
|
|
293
293
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
294
294
|
this.consts.coins[fromToken].module,
|
|
@@ -552,7 +552,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
552
552
|
)
|
|
553
553
|
|
|
554
554
|
tx.moveCall({
|
|
555
|
-
target: `${this.consts.zoCore.
|
|
555
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
556
556
|
typeArguments: [
|
|
557
557
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
558
558
|
this.consts.coins[collateralToken].module,
|
|
@@ -649,7 +649,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
649
649
|
)
|
|
650
650
|
|
|
651
651
|
tx.moveCall({
|
|
652
|
-
target: `${this.consts.zoCore.
|
|
652
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_with_scard`,
|
|
653
653
|
typeArguments: [
|
|
654
654
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
655
655
|
this.consts.coins[collateralToken].module,
|
|
@@ -759,7 +759,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
759
759
|
)
|
|
760
760
|
|
|
761
761
|
tx.moveCall({
|
|
762
|
-
target: `${this.consts.zoCore.
|
|
762
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
763
763
|
typeArguments: [
|
|
764
764
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
765
765
|
this.consts.coins[collateralToken].module,
|
|
@@ -886,7 +886,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
886
886
|
)
|
|
887
887
|
|
|
888
888
|
tx.moveCall({
|
|
889
|
-
target: `${this.consts.zoCore.
|
|
889
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
890
890
|
typeArguments: [
|
|
891
891
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
892
892
|
this.consts.coins[collateralToken].module,
|
|
@@ -958,7 +958,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
958
958
|
)
|
|
959
959
|
|
|
960
960
|
tx.moveCall({
|
|
961
|
-
target: `${this.consts.zoCore.
|
|
961
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::pledge_in_position`,
|
|
962
962
|
typeArguments: [
|
|
963
963
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
964
964
|
this.consts.coins[collateralToken].module,
|
|
@@ -992,7 +992,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
992
992
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
993
993
|
|
|
994
994
|
tx.moveCall({
|
|
995
|
-
target: `${this.consts.zoCore.
|
|
995
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::redeem_from_position`,
|
|
996
996
|
typeArguments: [
|
|
997
997
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
998
998
|
this.consts.coins[collateralToken].module,
|
|
@@ -1040,7 +1040,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
1042
|
tx.moveCall({
|
|
1043
|
-
target: `${this.consts.zoCore.
|
|
1043
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
1044
1044
|
typeArguments: [
|
|
1045
1045
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1046
1046
|
this.consts.coins[collateralToken].module,
|
|
@@ -1088,7 +1088,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
1090
|
tx.moveCall({
|
|
1091
|
-
target: `${this.consts.zoCore.
|
|
1091
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${functionName}`,
|
|
1092
1092
|
typeArguments: [
|
|
1093
1093
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1094
1094
|
this.consts.coins[collateralToken].module,
|
|
@@ -1110,7 +1110,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1110
1110
|
tx: Transaction,
|
|
1111
1111
|
): void {
|
|
1112
1112
|
tx.moveCall({
|
|
1113
|
-
target: `${this.consts.zoCore.
|
|
1113
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::clear_closed_position`,
|
|
1114
1114
|
typeArguments: [
|
|
1115
1115
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1116
1116
|
this.consts.coins[collateralToken].module,
|
|
@@ -1131,7 +1131,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1131
1131
|
): void {
|
|
1132
1132
|
const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order'
|
|
1133
1133
|
tx.moveCall({
|
|
1134
|
-
target: `${this.consts.zoCore.
|
|
1134
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
1135
1135
|
typeArguments: [
|
|
1136
1136
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1137
1137
|
this.consts.coins[collateralToken].module,
|
|
@@ -1153,7 +1153,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1153
1153
|
): void {
|
|
1154
1154
|
const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order'
|
|
1155
1155
|
tx.moveCall({
|
|
1156
|
-
target: `${this.consts.zoCore.
|
|
1156
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
1157
1157
|
typeArguments: [
|
|
1158
1158
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1159
1159
|
this.consts.coins[collateralToken].module,
|
|
@@ -1173,7 +1173,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1173
1173
|
tx = new Transaction()
|
|
1174
1174
|
}
|
|
1175
1175
|
tx.moveCall({
|
|
1176
|
-
target: `${this.consts.zoCore.
|
|
1176
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::add_new_referral`,
|
|
1177
1177
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
1178
1178
|
arguments: [tx.object(this.consts.zoCore.market), tx.object(referralAddress)],
|
|
1179
1179
|
})
|
|
@@ -1233,7 +1233,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1233
1233
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
1234
1234
|
|
|
1235
1235
|
tx.moveCall({
|
|
1236
|
-
target: `${this.consts.zoCore.
|
|
1236
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_close_position`,
|
|
1237
1237
|
typeArguments: [
|
|
1238
1238
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1239
1239
|
this.consts.coins[collateralToken].module,
|
|
@@ -1269,7 +1269,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1269
1269
|
tx: Transaction,
|
|
1270
1270
|
): void {
|
|
1271
1271
|
tx.moveCall({
|
|
1272
|
-
target: `${this.consts.zoCore.
|
|
1272
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::force_clear_closed_position`,
|
|
1273
1273
|
typeArguments: [
|
|
1274
1274
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1275
1275
|
this.consts.coins[collateralToken].module,
|