zo-sdk 0.0.51 → 0.1.0
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/README.md +272 -20
- package/dist/abstract/BaseAPI.cjs +117 -0
- package/dist/abstract/BaseAPI.cjs.map +1 -0
- package/dist/abstract/BaseAPI.d.cts +131 -0
- package/dist/abstract/BaseAPI.d.cts.map +1 -0
- package/dist/abstract/BaseAPI.d.mts +131 -0
- package/dist/abstract/BaseAPI.d.mts.map +1 -0
- package/dist/abstract/BaseAPI.mjs +113 -0
- package/dist/abstract/BaseAPI.mjs.map +1 -0
- package/dist/abstract/BaseDataAPI.cjs +139 -0
- package/dist/abstract/BaseDataAPI.cjs.map +1 -0
- package/dist/abstract/BaseDataAPI.d.cts +89 -0
- package/dist/abstract/BaseDataAPI.d.cts.map +1 -0
- package/dist/abstract/BaseDataAPI.d.mts +89 -0
- package/dist/abstract/BaseDataAPI.d.mts.map +1 -0
- package/dist/abstract/BaseDataAPI.mjs +135 -0
- package/dist/abstract/BaseDataAPI.mjs.map +1 -0
- package/dist/abstract/index.cjs +12 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +7 -0
- package/dist/abstract/index.d.cts.map +1 -0
- package/dist/abstract/index.d.mts +7 -0
- package/dist/abstract/index.d.mts.map +1 -0
- package/dist/abstract/index.mjs +7 -0
- package/dist/abstract/index.mjs.map +1 -0
- package/dist/bcs.cjs +42 -0
- package/dist/bcs.cjs.map +1 -0
- package/dist/bcs.d.cts +91 -0
- package/dist/bcs.d.cts.map +1 -0
- package/dist/bcs.d.mts +91 -0
- package/dist/bcs.d.mts.map +1 -0
- package/dist/bcs.mjs +39 -0
- package/dist/bcs.mjs.map +1 -0
- package/dist/consts/deployments-slp-mainnet.json +710 -0
- package/dist/consts/deployments-slp-testnet.json +109 -0
- package/dist/consts/deployments-usdz-mainnet.json +180 -0
- package/dist/consts/deployments-usdz-testnet.json +98 -0
- package/dist/consts/{deployments-mainnet.json → deployments-zlp-mainnet.json} +278 -42
- package/dist/consts/index.cjs +40 -8
- package/dist/consts/index.cjs.map +1 -1
- package/dist/consts/index.d.cts +81 -11
- package/dist/consts/index.d.cts.map +1 -1
- package/dist/consts/index.d.mts +81 -11
- package/dist/consts/index.d.mts.map +1 -1
- package/dist/consts/index.mjs +39 -7
- package/dist/consts/index.mjs.map +1 -1
- package/dist/consts/price_id_to_object_id.mainnet.json +9 -1
- package/dist/factory/SDKFactory.cjs +185 -0
- package/dist/factory/SDKFactory.cjs.map +1 -0
- package/dist/factory/SDKFactory.d.cts +74 -0
- package/dist/factory/SDKFactory.d.cts.map +1 -0
- package/dist/factory/SDKFactory.d.mts +74 -0
- package/dist/factory/SDKFactory.d.mts.map +1 -0
- package/dist/factory/SDKFactory.mjs +179 -0
- package/dist/factory/SDKFactory.mjs.map +1 -0
- package/dist/implementations/SLPAPI.cjs +829 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -0
- package/dist/implementations/SLPAPI.d.cts +120 -0
- package/dist/implementations/SLPAPI.d.cts.map +1 -0
- package/dist/implementations/SLPAPI.d.mts +120 -0
- package/dist/implementations/SLPAPI.d.mts.map +1 -0
- package/dist/implementations/SLPAPI.mjs +825 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -0
- package/dist/implementations/SLPDataAPI.cjs +916 -0
- package/dist/implementations/SLPDataAPI.cjs.map +1 -0
- package/dist/implementations/SLPDataAPI.d.cts +102 -0
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/SLPDataAPI.d.mts +102 -0
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/SLPDataAPI.mjs +912 -0
- package/dist/implementations/SLPDataAPI.mjs.map +1 -0
- package/dist/implementations/USDZAPI.cjs +522 -0
- package/dist/implementations/USDZAPI.cjs.map +1 -0
- package/dist/implementations/USDZAPI.d.cts +118 -0
- package/dist/implementations/USDZAPI.d.cts.map +1 -0
- package/dist/implementations/USDZAPI.d.mts +118 -0
- package/dist/implementations/USDZAPI.d.mts.map +1 -0
- package/dist/implementations/USDZAPI.mjs +518 -0
- package/dist/implementations/USDZAPI.mjs.map +1 -0
- package/dist/implementations/USDZDataAPI.cjs +697 -0
- package/dist/implementations/USDZDataAPI.cjs.map +1 -0
- package/dist/implementations/USDZDataAPI.d.cts +86 -0
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -0
- package/dist/implementations/USDZDataAPI.d.mts +86 -0
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -0
- package/dist/implementations/USDZDataAPI.mjs +693 -0
- package/dist/implementations/USDZDataAPI.mjs.map +1 -0
- package/dist/implementations/ZLPAPI.cjs +809 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -0
- package/dist/implementations/ZLPAPI.d.cts +121 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPAPI.d.mts +121 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPAPI.mjs +805 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.cjs +724 -0
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.cts +83 -0
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.mts +83 -0
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPDataAPI.mjs +720 -0
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -0
- package/dist/implementations/index.cjs +22 -0
- package/dist/implementations/index.cjs.map +1 -0
- package/dist/implementations/index.d.cts +11 -0
- package/dist/implementations/index.d.cts.map +1 -0
- package/dist/implementations/index.d.mts +11 -0
- package/dist/implementations/index.d.mts.map +1 -0
- package/dist/implementations/index.mjs +13 -0
- package/dist/implementations/index.mjs.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +45 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces/base.cjs +8 -0
- package/dist/interfaces/base.cjs.map +1 -0
- package/dist/interfaces/base.d.cts +293 -0
- package/dist/interfaces/base.d.cts.map +1 -0
- package/dist/interfaces/base.d.mts +293 -0
- package/dist/interfaces/base.d.mts.map +1 -0
- package/dist/interfaces/base.mjs +6 -0
- package/dist/interfaces/base.mjs.map +1 -0
- package/dist/interfaces/index.cjs +29 -0
- package/dist/interfaces/index.cjs.map +1 -0
- package/dist/interfaces/index.d.cts +13 -0
- package/dist/interfaces/index.d.cts.map +1 -0
- package/dist/interfaces/index.d.mts +13 -0
- package/dist/interfaces/index.d.mts.map +1 -0
- package/dist/interfaces/index.mjs +13 -0
- package/dist/interfaces/index.mjs.map +1 -0
- package/dist/interfaces/slp.cjs +9 -0
- package/dist/interfaces/slp.cjs.map +1 -0
- package/dist/interfaces/slp.d.cts +115 -0
- package/dist/interfaces/slp.d.cts.map +1 -0
- package/dist/interfaces/slp.d.mts +115 -0
- package/dist/interfaces/slp.d.mts.map +1 -0
- package/dist/interfaces/slp.mjs +7 -0
- package/dist/interfaces/slp.mjs.map +1 -0
- package/dist/interfaces/usdz.cjs +7 -0
- package/dist/interfaces/usdz.cjs.map +1 -0
- package/dist/interfaces/usdz.d.cts +40 -0
- package/dist/interfaces/usdz.d.cts.map +1 -0
- package/dist/interfaces/usdz.d.mts +40 -0
- package/dist/interfaces/usdz.d.mts.map +1 -0
- package/dist/interfaces/usdz.mjs +6 -0
- package/dist/interfaces/usdz.mjs.map +1 -0
- package/dist/interfaces/zlp.cjs +7 -0
- package/dist/interfaces/zlp.cjs.map +1 -0
- package/dist/interfaces/zlp.d.cts +45 -0
- package/dist/interfaces/zlp.d.cts.map +1 -0
- package/dist/interfaces/zlp.d.mts +45 -0
- package/dist/interfaces/zlp.d.mts.map +1 -0
- package/dist/interfaces/zlp.mjs +6 -0
- package/dist/interfaces/zlp.mjs.map +1 -0
- package/dist/oracle.cjs +7 -35
- package/dist/oracle.cjs.map +1 -1
- package/dist/oracle.d.cts +3 -4
- package/dist/oracle.d.cts.map +1 -1
- package/dist/oracle.d.mts +3 -4
- package/dist/oracle.d.mts.map +1 -1
- package/dist/oracle.mjs +8 -32
- package/dist/oracle.mjs.map +1 -1
- package/package.json +1 -1
- package/src/abstract/BaseAPI.ts +429 -0
- package/src/abstract/BaseDataAPI.ts +204 -0
- package/src/abstract/index.ts +7 -0
- package/src/bcs.ts +45 -0
- package/src/consts/deployments-slp-mainnet.json +710 -0
- package/src/consts/deployments-slp-testnet.json +109 -0
- package/src/consts/deployments-usdz-mainnet.json +180 -0
- package/src/consts/deployments-usdz-testnet.json +98 -0
- package/src/consts/{deployments-mainnet.json → deployments-zlp-mainnet.json} +279 -43
- package/src/consts/index.ts +134 -39
- package/src/consts/price_id_to_object_id.mainnet.json +10 -2
- package/src/factory/SDKFactory.ts +282 -0
- package/src/implementations/SLPAPI.ts +1207 -0
- package/src/implementations/SLPDataAPI.ts +1188 -0
- package/src/implementations/USDZAPI.ts +715 -0
- package/src/implementations/USDZDataAPI.ts +826 -0
- package/src/implementations/ZLPAPI.ts +1130 -0
- package/src/implementations/ZLPDataAPI.ts +856 -0
- package/src/implementations/index.ts +14 -0
- package/src/index.ts +53 -0
- package/src/interfaces/base.ts +556 -0
- package/src/interfaces/index.ts +45 -0
- package/src/interfaces/slp.ts +156 -0
- package/src/interfaces/usdz.ts +71 -0
- package/src/interfaces/zlp.ts +96 -0
- package/src/oracle.ts +12 -42
- package/tsconfig.json +4 -2
- package/dist/consts/staking/deployments-mainnet.json +0 -12
- package/dist/consts/staking/deployments-testnet.json +0 -11
- package/src/consts/staking/deployments-mainnet.json +0 -12
- package/src/consts/staking/deployments-testnet.json +0 -11
- /package/dist/consts/{deployments-testnet.json → deployments-zlp-testnet.json} +0 -0
- /package/src/consts/{deployments-testnet.json → deployments-zlp-testnet.json} +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SLP-specific interfaces and types
|
|
3
|
+
* Extends base interfaces with SLP-specific implementations for Sudo SDK
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Transaction } from '@mysten/sui/transactions'
|
|
7
|
+
import type {
|
|
8
|
+
IBaseMarketValuationInfo,
|
|
9
|
+
IBaseVaultInfo,
|
|
10
|
+
IBaseSymbolInfo,
|
|
11
|
+
IBaseMarketInfo,
|
|
12
|
+
IBasePositionInfo,
|
|
13
|
+
IBaseOrderInfo,
|
|
14
|
+
IBaseHistory,
|
|
15
|
+
IBaseStakePool,
|
|
16
|
+
IBaseCredential,
|
|
17
|
+
IBaseDataAPI,
|
|
18
|
+
IBaseAPI,
|
|
19
|
+
IBasePositionCapInfo,
|
|
20
|
+
IBaseOrderCapInfo,
|
|
21
|
+
IBaseStaked,
|
|
22
|
+
IBasePositionConfig,
|
|
23
|
+
IBaseFundingFeeModel,
|
|
24
|
+
IBaseReservingFeeModel,
|
|
25
|
+
IBaseRebaseFeeModel
|
|
26
|
+
} from './base'
|
|
27
|
+
import { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
|
|
28
|
+
|
|
29
|
+
// SLP-specific interfaces
|
|
30
|
+
export interface ISLPMarketValuationInfo extends IBaseMarketValuationInfo { }
|
|
31
|
+
|
|
32
|
+
export interface ISLPVaultInfo extends IBaseVaultInfo { }
|
|
33
|
+
|
|
34
|
+
export interface ISLPSymbolInfo extends IBaseSymbolInfo { }
|
|
35
|
+
|
|
36
|
+
export interface ISLPFundingFeeModel extends IBaseFundingFeeModel { }
|
|
37
|
+
|
|
38
|
+
export interface ISLPReservingFeeModel extends IBaseReservingFeeModel { }
|
|
39
|
+
|
|
40
|
+
export interface ISLPRebaseFeeModel extends IBaseRebaseFeeModel { }
|
|
41
|
+
|
|
42
|
+
export interface ISLPMarketInfo extends IBaseMarketInfo { }
|
|
43
|
+
|
|
44
|
+
export interface ISLPPositionInfo extends IBasePositionInfo { }
|
|
45
|
+
|
|
46
|
+
export interface ISLPPositionConfig extends IBasePositionConfig { }
|
|
47
|
+
|
|
48
|
+
export interface ISLPPositionCapInfo extends IBasePositionCapInfo { }
|
|
49
|
+
|
|
50
|
+
export interface ISLPOrderInfo extends IBaseOrderInfo { }
|
|
51
|
+
|
|
52
|
+
export interface ISLPOrderCapInfo extends IBaseOrderCapInfo { }
|
|
53
|
+
|
|
54
|
+
export interface ISLPHistory extends IBaseHistory { }
|
|
55
|
+
|
|
56
|
+
export interface ISLPStaked extends IBaseStaked { }
|
|
57
|
+
|
|
58
|
+
export interface ISLPStakePool extends IBaseStakePool { }
|
|
59
|
+
|
|
60
|
+
export interface ISLPCredential extends IBaseCredential { }
|
|
61
|
+
|
|
62
|
+
// Sudo SDK specific data structures
|
|
63
|
+
export interface ISudoMarket {
|
|
64
|
+
lpSupply: bigint
|
|
65
|
+
lpSupplyWithDecimals: number
|
|
66
|
+
totalValue: number
|
|
67
|
+
apr?: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ISudoVault {
|
|
71
|
+
symbol: string
|
|
72
|
+
liquidity: bigint
|
|
73
|
+
reservedAmount: bigint
|
|
74
|
+
enabled: boolean
|
|
75
|
+
weight: number
|
|
76
|
+
lastUpdate: number
|
|
77
|
+
totalValue: number
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ISudoSymbol {
|
|
81
|
+
name: string
|
|
82
|
+
openingSize: bigint
|
|
83
|
+
openingAmount: bigint
|
|
84
|
+
fundingRate: number
|
|
85
|
+
long: boolean
|
|
86
|
+
lastUpdate: number
|
|
87
|
+
totalOpenInterest: number
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ISudoPosition {
|
|
91
|
+
id: string
|
|
92
|
+
owner: string
|
|
93
|
+
symbol: string
|
|
94
|
+
size: bigint
|
|
95
|
+
collateralAmount: bigint
|
|
96
|
+
long: boolean
|
|
97
|
+
lastUpdate: number
|
|
98
|
+
unrealizedPnl: number
|
|
99
|
+
liquidationPrice: number
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ISudoOrder {
|
|
103
|
+
id: string
|
|
104
|
+
owner: string
|
|
105
|
+
symbol: string
|
|
106
|
+
size: bigint
|
|
107
|
+
triggerPrice: number
|
|
108
|
+
long: boolean
|
|
109
|
+
createdAt: number
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ISudoHistory {
|
|
113
|
+
owner: string
|
|
114
|
+
txid: string
|
|
115
|
+
id: string
|
|
116
|
+
timestamp: number
|
|
117
|
+
action: string
|
|
118
|
+
symbol: string
|
|
119
|
+
price: number
|
|
120
|
+
size: number
|
|
121
|
+
pnl: number
|
|
122
|
+
fee: number
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ISudoStaked {
|
|
126
|
+
credentials: ISudoStakeCredential[]
|
|
127
|
+
amount: bigint
|
|
128
|
+
claimable: bigint
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ISudoStakeCredential {
|
|
132
|
+
id: string
|
|
133
|
+
poolId: string
|
|
134
|
+
amount: bigint
|
|
135
|
+
lockUntil: number
|
|
136
|
+
claimable: bigint
|
|
137
|
+
rewardRate: number
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// SLP-specific data API interface
|
|
141
|
+
export interface ISLPDataAPI extends IBaseDataAPI {
|
|
142
|
+
// SLP-specific data api methods can be added here
|
|
143
|
+
getCumulativeApr(): Promise<number>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// SLP-specific API interface
|
|
147
|
+
export interface ISLPAPI extends IBaseAPI {
|
|
148
|
+
// SLP-specific api methods can be added here
|
|
149
|
+
claimTokenFromSCard(
|
|
150
|
+
token: string,
|
|
151
|
+
coinObjects: string[],
|
|
152
|
+
kioskClient: KioskClient,
|
|
153
|
+
kioskCap: KioskOwnerCap,
|
|
154
|
+
scard: string
|
|
155
|
+
): Promise<Transaction>
|
|
156
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* USDZ-specific interfaces and types
|
|
3
|
+
* Extends base interfaces with USDZ-specific implementations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IBaseMarketValuationInfo,
|
|
8
|
+
IBaseVaultInfo,
|
|
9
|
+
IBaseSymbolInfo,
|
|
10
|
+
IBaseMarketInfo,
|
|
11
|
+
IBasePositionInfo,
|
|
12
|
+
IBaseOrderInfo,
|
|
13
|
+
IBaseHistory,
|
|
14
|
+
IBaseStakePool,
|
|
15
|
+
IBaseCredential,
|
|
16
|
+
IBaseDataAPI,
|
|
17
|
+
IBaseAPI,
|
|
18
|
+
IBaseFundingFeeModel,
|
|
19
|
+
IBasePositionConfig,
|
|
20
|
+
IBasePositionCapInfo,
|
|
21
|
+
IBaseReservingFeeModel,
|
|
22
|
+
IBaseOrderCapInfo,
|
|
23
|
+
IBaseRebaseFeeModel
|
|
24
|
+
} from './base'
|
|
25
|
+
|
|
26
|
+
// USDZ-specific interfaces
|
|
27
|
+
export interface IUSDZMarketValuationInfo extends IBaseMarketValuationInfo { }
|
|
28
|
+
|
|
29
|
+
export interface IUSDZVaultInfo extends IBaseVaultInfo { }
|
|
30
|
+
|
|
31
|
+
export interface IUSDZReservingFeeModel extends IBaseReservingFeeModel { }
|
|
32
|
+
|
|
33
|
+
export interface IUSDZFundingFeeModel extends IBaseFundingFeeModel { }
|
|
34
|
+
|
|
35
|
+
export interface IUSDZRebaseFeeModel extends IBaseRebaseFeeModel { }
|
|
36
|
+
|
|
37
|
+
export interface IUSDZSymbolInfo extends IBaseSymbolInfo { }
|
|
38
|
+
|
|
39
|
+
export interface IUSDZMarketInfo extends IBaseMarketInfo {
|
|
40
|
+
// USDZ-specific market info fields can be added here
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IUSDZPositionInfo extends IBasePositionInfo {
|
|
44
|
+
// USDZ-specific position fields can be added here
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IUSDZPositionConfig extends IBasePositionConfig { }
|
|
48
|
+
|
|
49
|
+
export interface IUSDZPositionCapInfo extends IBasePositionCapInfo { }
|
|
50
|
+
|
|
51
|
+
export interface IUSDZOrderInfo extends IBaseOrderInfo { }
|
|
52
|
+
|
|
53
|
+
export interface IUSDZOrderCapInfo extends IBaseOrderCapInfo { }
|
|
54
|
+
|
|
55
|
+
export interface IUSDZHistory extends IBaseHistory {
|
|
56
|
+
// USDZ-specific history fields can be added here
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IUSDZStakePool extends IBaseStakePool {
|
|
60
|
+
// USDZ-specific stake pool fields can be added here
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface IUSDZCredential extends IBaseCredential {
|
|
64
|
+
// USDZ-specific credential fields can be added here
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// USDZ-specific data API interface
|
|
68
|
+
export interface IUSDZDataAPI extends IBaseDataAPI { }
|
|
69
|
+
|
|
70
|
+
// USDZ-specific API interface
|
|
71
|
+
export interface IUSDZAPI extends IBaseAPI { }
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZLP-specific interfaces and types
|
|
3
|
+
* Extends base interfaces with ZLP-specific implementations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Transaction } from '@mysten/sui/transactions'
|
|
7
|
+
import type {
|
|
8
|
+
IBaseMarketValuationInfo,
|
|
9
|
+
IBaseVaultInfo,
|
|
10
|
+
IBaseSymbolInfo,
|
|
11
|
+
IBaseMarketInfo,
|
|
12
|
+
IBasePositionInfo,
|
|
13
|
+
IBaseOrderInfo,
|
|
14
|
+
IBaseHistory,
|
|
15
|
+
IBaseStakePool,
|
|
16
|
+
IBaseCredential,
|
|
17
|
+
IBaseDataAPI,
|
|
18
|
+
IBaseAPI,
|
|
19
|
+
IBaseFundingFeeModel,
|
|
20
|
+
IBasePositionConfig,
|
|
21
|
+
IBasePositionCapInfo,
|
|
22
|
+
IBaseReservingFeeModel,
|
|
23
|
+
IBaseOrderCapInfo,
|
|
24
|
+
IBaseRebaseFeeModel
|
|
25
|
+
} from './base'
|
|
26
|
+
|
|
27
|
+
// ZLP-specific interfaces
|
|
28
|
+
export interface IZLPMarketValuationInfo extends IBaseMarketValuationInfo { }
|
|
29
|
+
|
|
30
|
+
export interface IZLPVaultInfo extends IBaseVaultInfo { }
|
|
31
|
+
|
|
32
|
+
export interface IZLPReservingFeeModel extends IBaseReservingFeeModel { }
|
|
33
|
+
|
|
34
|
+
export interface IZLPFundingFeeModel extends IBaseFundingFeeModel { }
|
|
35
|
+
|
|
36
|
+
export interface IZLPRebaseFeeModel extends IBaseRebaseFeeModel { }
|
|
37
|
+
|
|
38
|
+
export interface IZLPSymbolInfo extends IBaseSymbolInfo { }
|
|
39
|
+
|
|
40
|
+
export interface IZLPMarketInfo extends IBaseMarketInfo {
|
|
41
|
+
// ZLP-specific market info fields can be added here
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IZLPPositionInfo extends IBasePositionInfo {
|
|
45
|
+
// ZLP-specific position fields can be added here
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IZLPPositionConfig extends IBasePositionConfig { }
|
|
49
|
+
|
|
50
|
+
export interface IZLPPositionCapInfo extends IBasePositionCapInfo { }
|
|
51
|
+
|
|
52
|
+
export interface IZLPOrderInfo extends IBaseOrderInfo { }
|
|
53
|
+
|
|
54
|
+
export interface IZLPOrderCapInfo extends IBaseOrderCapInfo { }
|
|
55
|
+
|
|
56
|
+
export interface IZLPHistory extends IBaseHistory {
|
|
57
|
+
// ZLP-specific history fields can be added here
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IZLPStakePool extends IBaseStakePool {
|
|
61
|
+
// ZLP-specific stake pool fields can be added here
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IZLPCredential extends IBaseCredential {
|
|
65
|
+
// ZLP-specific credential fields can be added here
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ZLP-specific data API interface
|
|
69
|
+
export interface IZLPDataAPI extends IBaseDataAPI { }
|
|
70
|
+
|
|
71
|
+
// ZLP-specific API interface
|
|
72
|
+
export interface IZLPAPI extends IBaseAPI {
|
|
73
|
+
adminIssueLootbox(
|
|
74
|
+
coin: string,
|
|
75
|
+
tiers: number[],
|
|
76
|
+
beneficiaries: string[],
|
|
77
|
+
amounts: number[],
|
|
78
|
+
tx: Transaction,
|
|
79
|
+
): Promise<void>
|
|
80
|
+
|
|
81
|
+
depositToPrizePool(
|
|
82
|
+
coin: string,
|
|
83
|
+
coinObjects: string[],
|
|
84
|
+
amount: number,
|
|
85
|
+
): Promise<Transaction>
|
|
86
|
+
|
|
87
|
+
withdrawFromPricePool(
|
|
88
|
+
coin: string,
|
|
89
|
+
amount: number
|
|
90
|
+
): Promise<Transaction>
|
|
91
|
+
|
|
92
|
+
openLootbox(
|
|
93
|
+
coin: string,
|
|
94
|
+
lootbox: string
|
|
95
|
+
): Promise<Transaction>
|
|
96
|
+
}
|
package/src/oracle.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { PriceFeed } from '@pythnetwork/pyth-sui-js'
|
|
|
4
4
|
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js'
|
|
5
5
|
|
|
6
6
|
import type { IConsts } from './consts'
|
|
7
|
-
import { getConsts, getPriceIdToPythFeeder, getPythFeederToId, getPythFeederToPriceId, Network } from './consts'
|
|
8
|
-
import jsonFile from './consts/price_id_to_object_id.mainnet.json'
|
|
7
|
+
import { getConsts, getPriceIdToPythFeeder, getPythFeederToId, getPythFeederToPriceId, Network, LPToken } from './consts'
|
|
9
8
|
import { createJsonRpcProvider } from './utils'
|
|
10
9
|
|
|
11
10
|
export class OracleAPI {
|
|
@@ -24,9 +23,10 @@ export class OracleAPI {
|
|
|
24
23
|
provider: SuiClient | null,
|
|
25
24
|
// todo 需要从配置文件中获取
|
|
26
25
|
connectionURL: string,
|
|
26
|
+
lpToken: LPToken = LPToken.ZLP,
|
|
27
27
|
) {
|
|
28
28
|
this.network = network
|
|
29
|
-
this.consts = getConsts(network)
|
|
29
|
+
this.consts = getConsts(network, lpToken)
|
|
30
30
|
this.connectionURL = connectionURL
|
|
31
31
|
this.PythFeederToPriceId = getPythFeederToPriceId(network)
|
|
32
32
|
this.PythFeederToId = getPythFeederToId(network)
|
|
@@ -43,7 +43,7 @@ export class OracleAPI {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async getOraclePrice(tokenId: string) {
|
|
46
|
+
async getOraclePrice(tokenId: string): Promise<PriceFeed> {
|
|
47
47
|
this.validateCache()
|
|
48
48
|
if (this.priceCache[tokenId]) {
|
|
49
49
|
return this.priceCache[tokenId]
|
|
@@ -56,7 +56,7 @@ export class OracleAPI {
|
|
|
56
56
|
return res[0]
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async getOraclePrices(tokens: string[]) {
|
|
59
|
+
async getOraclePrices(tokens: string[]): Promise<PriceFeed[]> {
|
|
60
60
|
const connection = new SuiPriceServiceConnection(this.connectionURL, {
|
|
61
61
|
priceFeedRequestConfig: {
|
|
62
62
|
binary: true,
|
|
@@ -65,11 +65,11 @@ export class OracleAPI {
|
|
|
65
65
|
const pythObjectIds = tokens.map(token => this.consts.pythFeeder.feeder[token])
|
|
66
66
|
const priceFeedIds = pythObjectIds.map(pythObjectId => `0x${this.PythFeederToPriceId[pythObjectId]}`)
|
|
67
67
|
const price = await connection.getLatestPriceFeeds(priceFeedIds)
|
|
68
|
-
return price
|
|
68
|
+
return price || []
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// memory leak
|
|
72
|
-
async subOraclePrices(tokens: string[], callback: (price: PriceFeed) => void) {
|
|
72
|
+
async subOraclePrices(tokens: string[], callback: (price: PriceFeed) => void): Promise<() => void> {
|
|
73
73
|
const connection = new SuiPriceServiceConnection(this.connectionURL, {
|
|
74
74
|
priceFeedRequestConfig: {
|
|
75
75
|
binary: true,
|
|
@@ -88,20 +88,22 @@ export class OracleAPI {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
async initOracleTxb(tokens: string[], tx?: Transaction) {
|
|
91
|
+
async initOracleTxb(tokens: string[], tx?: Transaction): Promise<Transaction> {
|
|
92
92
|
let tx_ = tx
|
|
93
93
|
if (!tx_) {
|
|
94
94
|
tx_ = new Transaction()
|
|
95
95
|
}
|
|
96
96
|
// Remove redundant tokens first
|
|
97
|
-
const uniqueTokens =
|
|
97
|
+
const uniqueTokens = Array.from(new Set(tokens))
|
|
98
98
|
|
|
99
99
|
const connection = new SuiPriceServiceConnection(this.connectionURL, {
|
|
100
100
|
priceFeedRequestConfig: {
|
|
101
101
|
binary: true,
|
|
102
102
|
},
|
|
103
103
|
})
|
|
104
|
-
|
|
104
|
+
let pythObjectIds = uniqueTokens.map(token => this.consts.pythFeeder.feeder[token])
|
|
105
|
+
// remove dupe object ids. If any of the object ids are duplicates the call will fail
|
|
106
|
+
pythObjectIds = [...new Set(pythObjectIds)].filter(Boolean)
|
|
105
107
|
const needUpdateObjectIds = (await this.provider.multiGetObjects({
|
|
106
108
|
ids: pythObjectIds,
|
|
107
109
|
options: {
|
|
@@ -127,35 +129,3 @@ export class OracleAPI {
|
|
|
127
129
|
return tx_
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
|
|
131
|
-
export async function generatePriceIdToObjectIdJson() {
|
|
132
|
-
const provider = createJsonRpcProvider(Network.MAINNET)
|
|
133
|
-
const wormholeStateId = '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c'
|
|
134
|
-
const pythStateId = '0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8'
|
|
135
|
-
const client = new SuiPythClient(provider, pythStateId, wormholeStateId)
|
|
136
|
-
const ret: any = {}
|
|
137
|
-
|
|
138
|
-
const entries = Object.keys(jsonFile)
|
|
139
|
-
|
|
140
|
-
// 使用 Promise.all 并行处理所有请求
|
|
141
|
-
await Promise.all(
|
|
142
|
-
entries.map(async (key) => {
|
|
143
|
-
try {
|
|
144
|
-
const pythObjectId = await client.getPriceFeedObjectId(key)
|
|
145
|
-
if (pythObjectId) {
|
|
146
|
-
ret[key] = pythObjectId
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
console.warn(`Failed to get pythObjectId for key: ${key}`)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
console.error(`Error getting pythObjectId for key ${key}:`, error)
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
return ret
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// generatePriceIdToObjectIdJson()
|
package/tsconfig.json
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
"outDir": "./dist",
|
|
14
14
|
"rootDir": "./src",
|
|
15
15
|
"lib": ["ES2020", "DOM"],
|
|
16
|
-
"resolveJsonModule": true
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"downlevelIteration": true,
|
|
18
|
+
"allowSyntheticDefaultImports": true
|
|
17
19
|
},
|
|
18
20
|
"include": ["src/**/*"],
|
|
19
21
|
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
20
|
-
}
|
|
22
|
+
}
|
|
File without changes
|
|
File without changes
|