zo-sdk 0.1.12 → 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 +46 -4
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.cts +6 -1
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.mts +6 -1
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +46 -4
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/interfaces/zlp.d.cts +20 -0
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +20 -0
- package/dist/interfaces/zlp.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/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 +50 -4
- package/src/interfaces/zlp.ts +25 -1
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
IZLPPositionInfo,
|
|
27
27
|
IZLPRebaseFeeModel,
|
|
28
28
|
IZLPReservingFeeModel,
|
|
29
|
+
IZLPSymbolConfig,
|
|
29
30
|
IZLPSymbolInfo,
|
|
30
31
|
IZLPVaultInfo,
|
|
31
32
|
} from '../interfaces'
|
|
@@ -54,7 +55,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
54
55
|
*/
|
|
55
56
|
public valuateVaults(tx: Transaction) {
|
|
56
57
|
const vaultsValuation = tx.moveCall({
|
|
57
|
-
target: `${this.consts.zoCore.
|
|
58
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_vaults_valuation`,
|
|
58
59
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
59
60
|
arguments: [
|
|
60
61
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -65,7 +66,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
65
66
|
for (const key of Object.keys(this.consts.zoCore.vaults)) {
|
|
66
67
|
const vault = this.consts.zoCore.vaults[key]
|
|
67
68
|
tx.moveCall({
|
|
68
|
-
target: `${this.consts.zoCore.
|
|
69
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_vault`,
|
|
69
70
|
typeArguments: [
|
|
70
71
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
71
72
|
this.consts.coins[key].module,
|
|
@@ -86,7 +87,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
86
87
|
*/
|
|
87
88
|
public valuateSymbols(tx: Transaction) {
|
|
88
89
|
const symbolsValuation = tx.moveCall({
|
|
89
|
-
target: `${this.consts.zoCore.
|
|
90
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_symbols_valuation`,
|
|
90
91
|
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`],
|
|
91
92
|
arguments: [
|
|
92
93
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -98,7 +99,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
98
99
|
const [direction, token] = parseSymbolKey(key)
|
|
99
100
|
const symbol = this.consts.zoCore.symbols[key]
|
|
100
101
|
tx.moveCall({
|
|
101
|
-
target: `${this.consts.zoCore.
|
|
102
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_symbol`,
|
|
102
103
|
typeArguments: [
|
|
103
104
|
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
104
105
|
this.consts.coins[token].module,
|
|
@@ -233,6 +234,28 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
233
234
|
return ZLPDataAPI.parsePositionConfig(rawData)
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Gets ZLP symbol configuration
|
|
239
|
+
*/
|
|
240
|
+
public async getSymbolConfig(indexToken: string, long: boolean): Promise<IZLPSymbolConfig | null> {
|
|
241
|
+
this.validateCache()
|
|
242
|
+
try {
|
|
243
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
244
|
+
parentId: this.consts.zoCore.market,
|
|
245
|
+
name: {
|
|
246
|
+
type: `${this.consts.zoCore.package}::market::SymbolName<${this.consts.coins[indexToken].module}, ${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}>`,
|
|
247
|
+
value: { dummy_field: false },
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
return ZLPDataAPI.parseSymbolConfig(rawData)
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// If the dynamic field doesn't exist, return null
|
|
254
|
+
console.error('Symbol Config Not Found')
|
|
255
|
+
return null
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
236
259
|
public async getPositionCapInfoList(owner: string): Promise<IZLPPositionCapInfo[]> {
|
|
237
260
|
const positionCapInfoList: IZLPPositionCapInfo[] = []
|
|
238
261
|
let cursor: string | undefined | null
|
|
@@ -736,6 +759,29 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
736
759
|
}
|
|
737
760
|
}
|
|
738
761
|
|
|
762
|
+
private static parseSymbolConfig(raw: any): IZLPSymbolConfig {
|
|
763
|
+
const { fields } = raw.data.content
|
|
764
|
+
|
|
765
|
+
return {
|
|
766
|
+
id: fields.id.id,
|
|
767
|
+
max_opening_size: parseValue(fields.max_opening_size),
|
|
768
|
+
max_opening_size_enabled: fields.max_opening_size_enabled,
|
|
769
|
+
max_opening_size_per_position: parseValue(fields.max_opening_size_per_position),
|
|
770
|
+
max_opening_size_per_position_enabled: fields.max_opening_size_per_position_enabled,
|
|
771
|
+
instant_exit_fee_config: {
|
|
772
|
+
instant_exit_tier_1_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_1_duration_threshold),
|
|
773
|
+
instant_exit_tier_1_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_bps.fields.value),
|
|
774
|
+
instant_exit_tier_1_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_enabled,
|
|
775
|
+
instant_exit_tier_2_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_2_duration_threshold),
|
|
776
|
+
instant_exit_tier_2_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_bps.fields.value),
|
|
777
|
+
instant_exit_tier_2_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_enabled,
|
|
778
|
+
instant_exit_tier_3_duration_threshold: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_3_duration_threshold),
|
|
779
|
+
instant_exit_tier_3_fee_bps: parseValue(fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_bps.fields.value),
|
|
780
|
+
instant_exit_tier_3_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_enabled,
|
|
781
|
+
},
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
739
785
|
private async parsePositionInfo(raw: any, id_: string): Promise<IZLPPositionInfo> {
|
|
740
786
|
const { content } = raw.data
|
|
741
787
|
const { fields } = content
|
package/src/interfaces/zlp.ts
CHANGED
|
@@ -66,8 +66,32 @@ export interface IZLPCredential extends IBaseCredential {
|
|
|
66
66
|
// ZLP-specific credential fields can be added here
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// ZLP Symbol Config interfaces
|
|
70
|
+
export interface IZLPPositionInstantExitFeeConfig {
|
|
71
|
+
instant_exit_tier_1_duration_threshold: number
|
|
72
|
+
instant_exit_tier_1_fee_bps: number
|
|
73
|
+
instant_exit_tier_1_fee_enabled: boolean
|
|
74
|
+
instant_exit_tier_2_duration_threshold: number
|
|
75
|
+
instant_exit_tier_2_fee_bps: number
|
|
76
|
+
instant_exit_tier_2_fee_enabled: boolean
|
|
77
|
+
instant_exit_tier_3_duration_threshold: number
|
|
78
|
+
instant_exit_tier_3_fee_bps: number
|
|
79
|
+
instant_exit_tier_3_fee_enabled: boolean
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface IZLPSymbolConfig {
|
|
83
|
+
id: string
|
|
84
|
+
max_opening_size: number
|
|
85
|
+
max_opening_size_enabled: boolean
|
|
86
|
+
max_opening_size_per_position: number
|
|
87
|
+
max_opening_size_per_position_enabled: boolean
|
|
88
|
+
instant_exit_fee_config: IZLPPositionInstantExitFeeConfig
|
|
89
|
+
}
|
|
90
|
+
|
|
69
91
|
// ZLP-specific data API interface
|
|
70
|
-
export interface IZLPDataAPI extends IBaseDataAPI {
|
|
92
|
+
export interface IZLPDataAPI extends IBaseDataAPI {
|
|
93
|
+
getSymbolConfig: (indexToken: string, long: boolean) => Promise<IZLPSymbolConfig | null>
|
|
94
|
+
}
|
|
71
95
|
|
|
72
96
|
// ZLP-specific API interface
|
|
73
97
|
export interface IZLPAPI extends IBaseAPI {
|