zo-sdk 0.1.2 → 0.1.3

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.
Files changed (183) hide show
  1. package/dist/abstract/BaseAPI.cjs +3 -4
  2. package/dist/abstract/BaseAPI.cjs.map +1 -1
  3. package/dist/abstract/BaseAPI.d.cts +13 -13
  4. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  5. package/dist/abstract/BaseAPI.d.mts +13 -13
  6. package/dist/abstract/BaseAPI.d.mts.map +1 -1
  7. package/dist/abstract/BaseAPI.mjs +3 -4
  8. package/dist/abstract/BaseAPI.mjs.map +1 -1
  9. package/dist/abstract/BaseDataAPI.cjs +2 -2
  10. package/dist/abstract/BaseDataAPI.cjs.map +1 -1
  11. package/dist/abstract/BaseDataAPI.d.cts +2 -2
  12. package/dist/abstract/BaseDataAPI.d.cts.map +1 -1
  13. package/dist/abstract/BaseDataAPI.d.mts +2 -2
  14. package/dist/abstract/BaseDataAPI.d.mts.map +1 -1
  15. package/dist/abstract/BaseDataAPI.mjs +2 -2
  16. package/dist/abstract/BaseDataAPI.mjs.map +1 -1
  17. package/dist/abstract/index.cjs +3 -3
  18. package/dist/abstract/index.cjs.map +1 -1
  19. package/dist/abstract/index.d.cts +1 -1
  20. package/dist/abstract/index.d.cts.map +1 -1
  21. package/dist/abstract/index.d.mts +1 -1
  22. package/dist/abstract/index.d.mts.map +1 -1
  23. package/dist/abstract/index.mjs +1 -1
  24. package/dist/abstract/index.mjs.map +1 -1
  25. package/dist/api.cjs +2 -1
  26. package/dist/api.cjs.map +1 -1
  27. package/dist/api.d.cts.map +1 -1
  28. package/dist/api.d.mts.map +1 -1
  29. package/dist/api.mjs +2 -1
  30. package/dist/api.mjs.map +1 -1
  31. package/dist/bcs.cjs.map +1 -1
  32. package/dist/bcs.d.cts.map +1 -1
  33. package/dist/bcs.d.mts.map +1 -1
  34. package/dist/bcs.mjs.map +1 -1
  35. package/dist/consts/deployments-slp-mainnet.json +0 -70
  36. package/dist/consts/deployments-usdz-mainnet.json +1 -133
  37. package/dist/consts/index.cjs +21 -14
  38. package/dist/consts/index.cjs.map +1 -1
  39. package/dist/consts/index.d.cts.map +1 -1
  40. package/dist/consts/index.d.mts.map +1 -1
  41. package/dist/consts/index.mjs +21 -14
  42. package/dist/consts/index.mjs.map +1 -1
  43. package/dist/factory/SDKFactory.cjs +21 -14
  44. package/dist/factory/SDKFactory.cjs.map +1 -1
  45. package/dist/factory/SDKFactory.d.cts +4 -4
  46. package/dist/factory/SDKFactory.d.cts.map +1 -1
  47. package/dist/factory/SDKFactory.d.mts +4 -4
  48. package/dist/factory/SDKFactory.d.mts.map +1 -1
  49. package/dist/factory/SDKFactory.mjs +22 -15
  50. package/dist/factory/SDKFactory.mjs.map +1 -1
  51. package/dist/implementations/SLPAPI.cjs +143 -110
  52. package/dist/implementations/SLPAPI.cjs.map +1 -1
  53. package/dist/implementations/SLPAPI.d.cts +49 -47
  54. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  55. package/dist/implementations/SLPAPI.d.mts +49 -47
  56. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  57. package/dist/implementations/SLPAPI.mjs +143 -110
  58. package/dist/implementations/SLPAPI.mjs.map +1 -1
  59. package/dist/implementations/SLPDataAPI.cjs +98 -89
  60. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  61. package/dist/implementations/SLPDataAPI.d.cts +21 -21
  62. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  63. package/dist/implementations/SLPDataAPI.d.mts +21 -21
  64. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  65. package/dist/implementations/SLPDataAPI.mjs +98 -89
  66. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  67. package/dist/implementations/USDZAPI.cjs +128 -84
  68. package/dist/implementations/USDZAPI.cjs.map +1 -1
  69. package/dist/implementations/USDZAPI.d.cts +46 -45
  70. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  71. package/dist/implementations/USDZAPI.d.mts +46 -45
  72. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  73. package/dist/implementations/USDZAPI.mjs +128 -84
  74. package/dist/implementations/USDZAPI.mjs.map +1 -1
  75. package/dist/implementations/USDZDataAPI.cjs +48 -47
  76. package/dist/implementations/USDZDataAPI.cjs.map +1 -1
  77. package/dist/implementations/USDZDataAPI.d.cts +19 -19
  78. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  79. package/dist/implementations/USDZDataAPI.d.mts +19 -19
  80. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  81. package/dist/implementations/USDZDataAPI.mjs +49 -48
  82. package/dist/implementations/USDZDataAPI.mjs.map +1 -1
  83. package/dist/implementations/ZLPAPI.cjs +137 -89
  84. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  85. package/dist/implementations/ZLPAPI.d.cts +50 -48
  86. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  87. package/dist/implementations/ZLPAPI.d.mts +50 -48
  88. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  89. package/dist/implementations/ZLPAPI.mjs +137 -89
  90. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  91. package/dist/implementations/ZLPDataAPI.cjs +62 -63
  92. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  93. package/dist/implementations/ZLPDataAPI.d.cts +19 -19
  94. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  95. package/dist/implementations/ZLPDataAPI.d.mts +19 -19
  96. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  97. package/dist/implementations/ZLPDataAPI.mjs +63 -64
  98. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  99. package/dist/implementations/index.cjs +5 -5
  100. package/dist/implementations/index.cjs.map +1 -1
  101. package/dist/implementations/index.d.cts +2 -2
  102. package/dist/implementations/index.d.cts.map +1 -1
  103. package/dist/implementations/index.d.mts +2 -2
  104. package/dist/implementations/index.d.mts.map +1 -1
  105. package/dist/implementations/index.mjs +2 -2
  106. package/dist/implementations/index.mjs.map +1 -1
  107. package/dist/index.cjs +9 -9
  108. package/dist/index.cjs.map +1 -1
  109. package/dist/index.d.cts +6 -6
  110. package/dist/index.d.cts.map +1 -1
  111. package/dist/index.d.mts +6 -6
  112. package/dist/index.d.mts.map +1 -1
  113. package/dist/index.mjs +6 -6
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/interfaces/base.cjs +0 -1
  116. package/dist/interfaces/base.cjs.map +1 -1
  117. package/dist/interfaces/base.d.cts +57 -57
  118. package/dist/interfaces/base.d.cts.map +1 -1
  119. package/dist/interfaces/base.d.mts +57 -57
  120. package/dist/interfaces/base.d.mts.map +1 -1
  121. package/dist/interfaces/base.mjs +1 -1
  122. package/dist/interfaces/base.mjs.map +1 -1
  123. package/dist/interfaces/index.d.cts +4 -4
  124. package/dist/interfaces/index.d.cts.map +1 -1
  125. package/dist/interfaces/index.d.mts +4 -4
  126. package/dist/interfaces/index.d.mts.map +1 -1
  127. package/dist/interfaces/slp.cjs +0 -2
  128. package/dist/interfaces/slp.cjs.map +1 -1
  129. package/dist/interfaces/slp.d.cts +5 -5
  130. package/dist/interfaces/slp.d.cts.map +1 -1
  131. package/dist/interfaces/slp.d.mts +5 -5
  132. package/dist/interfaces/slp.d.mts.map +1 -1
  133. package/dist/interfaces/slp.mjs +1 -2
  134. package/dist/interfaces/slp.mjs.map +1 -1
  135. package/dist/interfaces/usdz.d.cts +1 -1
  136. package/dist/interfaces/usdz.d.cts.map +1 -1
  137. package/dist/interfaces/usdz.d.mts +1 -1
  138. package/dist/interfaces/usdz.d.mts.map +1 -1
  139. package/dist/interfaces/zlp.d.cts +5 -5
  140. package/dist/interfaces/zlp.d.cts.map +1 -1
  141. package/dist/interfaces/zlp.d.mts +5 -5
  142. package/dist/interfaces/zlp.d.mts.map +1 -1
  143. package/dist/oracle.cjs +12 -2
  144. package/dist/oracle.cjs.map +1 -1
  145. package/dist/oracle.d.cts +4 -3
  146. package/dist/oracle.d.cts.map +1 -1
  147. package/dist/oracle.d.mts +4 -3
  148. package/dist/oracle.d.mts.map +1 -1
  149. package/dist/oracle.mjs +13 -3
  150. package/dist/oracle.mjs.map +1 -1
  151. package/dist/utils.cjs +1 -1
  152. package/dist/utils.cjs.map +1 -1
  153. package/dist/utils.d.cts.map +1 -1
  154. package/dist/utils.d.mts.map +1 -1
  155. package/dist/utils.mjs +1 -1
  156. package/dist/utils.mjs.map +1 -1
  157. package/eslint.config.mjs +18 -0
  158. package/package.json +16 -15
  159. package/src/abstract/BaseAPI.ts +55 -49
  160. package/src/abstract/BaseDataAPI.ts +19 -17
  161. package/src/abstract/index.ts +1 -1
  162. package/src/api.ts +3 -1
  163. package/src/bcs.ts +9 -9
  164. package/src/consts/deployments-slp-mainnet.json +0 -70
  165. package/src/consts/deployments-usdz-mainnet.json +1 -133
  166. package/src/consts/index.ts +22 -15
  167. package/src/factory/SDKFactory.ts +49 -41
  168. package/src/implementations/SLPAPI.ts +299 -210
  169. package/src/implementations/SLPDataAPI.ts +163 -146
  170. package/src/implementations/USDZAPI.ts +238 -133
  171. package/src/implementations/USDZDataAPI.ts +79 -74
  172. package/src/implementations/ZLPAPI.ts +296 -174
  173. package/src/implementations/ZLPDataAPI.ts +93 -88
  174. package/src/implementations/index.ts +3 -3
  175. package/src/index.ts +17 -17
  176. package/src/interfaces/base.ts +123 -116
  177. package/src/interfaces/index.ts +14 -17
  178. package/src/interfaces/slp.ts +20 -19
  179. package/src/interfaces/usdz.ts +13 -13
  180. package/src/interfaces/zlp.ts +22 -21
  181. package/src/oracle.ts +25 -5
  182. package/src/utils.ts +9 -9
  183. package/tsconfig.json +1 -1
@@ -3,13 +3,15 @@
3
3
  * Implements USDZ-specific trading and transaction methods
4
4
  */
5
5
 
6
+ import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
6
7
  import type { SuiClient } from '@mysten/sui/client'
7
8
  import { Transaction } from '@mysten/sui/transactions'
8
9
  import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
10
+
11
+ import { BaseAPI } from '../abstract'
9
12
  import type { Network } from '../consts'
10
13
  import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE, LPToken } from '../consts'
11
- import {
12
- IUSDZAPI,
14
+ import type {
13
15
  IBaseCredential,
14
16
  IBaseHistoryResponse,
15
17
  IBaseMarketInfo,
@@ -19,16 +21,15 @@ import {
19
21
  IBasePositionCapInfo,
20
22
  IBasePositionConfig,
21
23
  IBasePositionInfo,
24
+ IBaseRebaseFeeModel,
22
25
  IBaseStaked,
26
+ IBaseStakePool,
23
27
  IBaseSymbolInfo,
24
28
  IBaseVaultInfo,
25
- IBaseRebaseFeeModel,
26
- IBaseStakePool
29
+ IUSDZAPI,
27
30
  } from '../interfaces'
28
- import { BaseAPI } from '../abstract'
29
- import { USDZDataAPI } from './USDZDataAPI'
30
31
  import { joinSymbol } from '../utils'
31
- import { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
32
+ import { USDZDataAPI } from './USDZDataAPI'
32
33
 
33
34
  export class USDZAPI extends BaseAPI implements IUSDZAPI {
34
35
  public dataAPI: USDZDataAPI
@@ -37,110 +38,142 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
37
38
  network: Network,
38
39
  provider: SuiClient,
39
40
  apiEndpoint: string,
40
- connectionURL: string
41
+ connectionURL: string,
41
42
  ) {
42
43
  super(network, provider, apiEndpoint, connectionURL, LPToken.USDZ)
43
44
  this.dataAPI = new USDZDataAPI(network, provider, apiEndpoint, connectionURL)
44
45
  }
45
46
 
46
- public stake(lpCoinObjects: string[], amount: bigint, pool: string, tx?: Transaction): Promise<Transaction> {
47
- throw new Error('Method not implemented.')
47
+ public stake(_lpCoinObjects: string[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
48
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
48
49
  }
49
- public unstake(credentials: IBaseCredential[], amount: bigint, pool: string, tx?: Transaction): Promise<Transaction> {
50
- throw new Error('Method not implemented.')
50
+
51
+ public unstake(_credentials: IBaseCredential[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
52
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
51
53
  }
52
- public clearClosedPosition(pcpId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction): void {
53
- throw new Error('Method not implemented.')
54
+
55
+ public clearClosedPosition(_pcpId: string, _collateralToken: string, _indexToken: string, _long: boolean, _tx: Transaction): void {
56
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
54
57
  }
55
- public clearOpenPositionOrder(orderCapId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction, isV11Order?: boolean): void {
56
- throw new Error('Method not implemented.')
58
+
59
+ public clearOpenPositionOrder(_orderCapId: string, _collateralToken: string, _indexToken: string, _long: boolean, _tx: Transaction, _isV11Order?: boolean): void {
60
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
57
61
  }
58
- public clearDecreasePositionOrder(orderCapId: string, collateralToken: string, indexToken: string, long: boolean, tx: Transaction, isV11Order?: boolean): void {
59
- throw new Error('Method not implemented.')
62
+
63
+ public clearDecreasePositionOrder(_orderCapId: string, _collateralToken: string, _indexToken: string, _long: boolean, _tx: Transaction, _isV11Order?: boolean): void {
64
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
60
65
  }
61
- public openPositionWithSCard(collateralToken: string, indexToken: string, size: bigint, collateralAmount: bigint, coinObjects: string[], long: boolean, reserveAmount: bigint, indexPrice: number, collateralPrice: number, kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string, isLimitOrder?: boolean, isIocOrder?: boolean, pricesSlippage?: number, collateralSlippage?: number, relayerFee?: bigint, referralAddress?: string, sender?: string): Promise<Transaction> {
62
- throw new Error('Method not implemented.')
66
+
67
+ public openPositionWithSCard(_collateralToken: string, _indexToken: string, _size: bigint, _collateralAmount: bigint, _coinObjects: string[], _long: boolean, _reserveAmount: bigint, _indexPrice: number, _collateralPrice: number, _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string, _isLimitOrder?: boolean, _isIocOrder?: boolean, _pricesSlippage?: number, _collateralSlippage?: number, _relayerFee?: bigint, _referralAddress?: string, _sender?: string): Promise<Transaction> {
68
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
63
69
  }
64
- public decreasePositionWithSCard(pcpId: string, collateralToken: string, indexToken: string, amount: bigint, long: boolean, indexPrice: number, collateralPrice: number, kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string, isTriggerOrder?: boolean, isTakeProfitOrder?: boolean, isIocOrder?: boolean, pricesSlippage?: number, collateralSlippage?: number, relayerFee?: bigint, coinObjects?: string[]): Promise<Transaction> {
65
- throw new Error('Method not implemented.')
70
+
71
+ public decreasePositionWithSCard(_pcpId: string, _collateralToken: string, _indexToken: string, _amount: bigint, _long: boolean, _indexPrice: number, _collateralPrice: number, _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string, _isTriggerOrder?: boolean, _isTakeProfitOrder?: boolean, _isIocOrder?: boolean, _pricesSlippage?: number, _collateralSlippage?: number, _relayerFee?: bigint, _coinObjects?: string[]): Promise<Transaction> {
72
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
66
73
  }
67
- public decreaseMultiPositionsWithSCard(positions: Array<{ pcpId: string; collateralToken: string; indexToken: string; amount: bigint; long: boolean; indexPrice: number; collateralPrice: number; isTriggerOrder?: boolean; isTakeProfitOrder?: boolean; isIocOrder?: boolean; pricesSlippage?: number; collateralSlippage?: number; relayerFee?: bigint; coinObjects?: string[] }>, kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string, tx?: Transaction): Promise<Transaction> {
68
- throw new Error('Method not implemented.')
74
+
75
+ public decreaseMultiPositionsWithSCard(_positions: Array<{ pcpId: string, collateralToken: string, indexToken: string, amount: bigint, long: boolean, indexPrice: number, collateralPrice: number, isTriggerOrder?: boolean, isTakeProfitOrder?: boolean, isIocOrder?: boolean, pricesSlippage?: number, collateralSlippage?: number, relayerFee?: bigint, coinObjects?: string[] }>, _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string, _tx?: Transaction): Promise<Transaction> {
76
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
69
77
  }
70
- public claimTokenFromSCard(token: string, coinObjects: string[], kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string): Promise<Transaction> {
71
- throw new Error('Method not implemented.')
78
+
79
+ public claimTokenFromSCard(_token: string, _coinObjects: string[], _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string): Transaction {
80
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
72
81
  }
73
- public valuateVaults(tx: Transaction) {
74
- throw new Error('Method not implemented.')
82
+
83
+ public valuateVaults(_tx: Transaction) {
84
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
75
85
  }
76
- public valuateSymbols(tx: Transaction) {
77
- throw new Error('Method not implemented.')
86
+
87
+ public valuateSymbols(_tx: Transaction) {
88
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
78
89
  }
79
- public valuate(tx: Transaction): { vaultsValuation: any; symbolsValuation: any } {
80
- throw new Error('Method not implemented.')
90
+
91
+ public valuate(_tx: Transaction): { vaultsValuation: any, symbolsValuation: any } {
92
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
81
93
  }
94
+
82
95
  public valuateMarket(): Promise<IBaseMarketValuationInfo> {
83
- throw new Error('Method not implemented.')
96
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
84
97
  }
85
- public fundingFeeRate(indexToken: string, long: boolean): Promise<number> {
86
- throw new Error('Method not implemented.')
98
+
99
+ public fundingFeeRate(_indexToken: string, _long: boolean): Promise<number> {
100
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
87
101
  }
88
- public rebaseFeeRate(collateralToken: string, increase: boolean, amount: number): Promise<number> {
89
- throw new Error('Method not implemented.')
102
+
103
+ public rebaseFeeRate(_collateralToken: string, _increase: boolean, _amount: number): Promise<number> {
104
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
90
105
  }
91
- public reservingFeeRate(collateralToken: string, amount: number): Promise<number> {
92
- throw new Error('Method not implemented.')
106
+
107
+ public reservingFeeRate(_collateralToken: string, _amount: number): Promise<number> {
108
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
93
109
  }
94
- public calcPositionReserveFeeAmount(position: IBasePositionInfo): Promise<number> {
95
- throw new Error('Method not implemented.')
110
+
111
+ public calcPositionReserveFeeAmount(_position: IBasePositionInfo): Promise<number> {
112
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
96
113
  }
97
- public calcPositionFundingFeeValue(position: IBasePositionInfo): Promise<number> {
98
- throw new Error('Method not implemented.')
114
+
115
+ public calcPositionFundingFeeValue(_position: IBasePositionInfo): Promise<number> {
116
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
99
117
  }
118
+
100
119
  public getMarketInfo(): Promise<IBaseMarketInfo> {
101
- throw new Error('Method not implemented.')
120
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
102
121
  }
103
- public getVaultInfo(vault: string): Promise<IBaseVaultInfo> {
104
- throw new Error('Method not implemented.')
122
+
123
+ public getVaultInfo(_vault: string): Promise<IBaseVaultInfo> {
124
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
105
125
  }
106
- public getSymbolInfo(tokenId: string, long: boolean): Promise<IBaseSymbolInfo> {
107
- throw new Error('Method not implemented.')
126
+
127
+ public getSymbolInfo(_tokenId: string, _long: boolean): Promise<IBaseSymbolInfo> {
128
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
108
129
  }
109
- public getPositionConfig(indexToken: string, long: boolean): Promise<IBasePositionConfig> {
110
- throw new Error('Method not implemented.')
130
+
131
+ public getPositionConfig(_indexToken: string, _long: boolean): Promise<IBasePositionConfig> {
132
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
111
133
  }
134
+
112
135
  public getRebaseFeeModel(): Promise<IBaseRebaseFeeModel> {
113
- throw new Error('Method not implemented.')
136
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
114
137
  }
138
+
115
139
  public getOpenPositions(): Promise<IBasePositionInfo[]> {
116
- throw new Error('Method not implemented.')
140
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
117
141
  }
118
- public getPositionCapInfoList(owner: string): Promise<IBasePositionCapInfo[]> {
119
- throw new Error('Method not implemented.')
142
+
143
+ public getPositionCapInfoList(_owner: string): Promise<IBasePositionCapInfo[]> {
144
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
120
145
  }
121
- public getPositionInfoList(positionCapInfoList: IBasePositionCapInfo[], owner: string): Promise<IBasePositionInfo[]> {
122
- throw new Error('Method not implemented.')
146
+
147
+ public getPositionInfoList(_positionCapInfoList: IBasePositionCapInfo[], _owner: string): Promise<IBasePositionInfo[]> {
148
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
123
149
  }
124
- public getOrderCapInfoList(owner: string): Promise<IBaseOrderCapInfo[]> {
125
- throw new Error('Method not implemented.')
150
+
151
+ public getOrderCapInfoList(_owner: string): Promise<IBaseOrderCapInfo[]> {
152
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
126
153
  }
127
- public getOrderInfoList(orderCapInfoList: IBaseOrderCapInfo[], owner: string): Promise<IBaseOrderInfo[]> {
128
- throw new Error('Method not implemented.')
154
+
155
+ public getOrderInfoList(_orderCapInfoList: IBaseOrderCapInfo[], _owner: string): Promise<IBaseOrderInfo[]> {
156
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
129
157
  }
130
- public getHistory(trader: string, page: number, limit: number, orderType?: string, symbol?: string): Promise<IBaseHistoryResponse> {
131
- throw new Error('Method not implemented.')
158
+
159
+ public getHistory(_trader: string, _page: number, _limit: number, _orderType?: string, _symbol?: string): Promise<IBaseHistoryResponse> {
160
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
132
161
  }
133
- public getStaked(owner: string): Promise<IBaseStaked> {
134
- throw new Error('Method not implemented.')
162
+
163
+ public getStaked(_owner: string): Promise<IBaseStaked> {
164
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
135
165
  }
166
+
136
167
  public getStakePool(): Promise<IBaseStakePool> {
137
- throw new Error('Method not implemented.')
168
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
138
169
  }
139
- public hasReferral(referree: string): Promise<boolean> {
140
- throw new Error('Method not implemented.')
170
+
171
+ public hasReferral(_referree: string): Promise<boolean> {
172
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
141
173
  }
142
- public getReferralData(referree: string): Promise<any> {
143
- throw new Error('Method not implemented.')
174
+
175
+ public getReferralData(_referree: string): Promise<any> {
176
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
144
177
  }
145
178
 
146
179
  /**
@@ -150,27 +183,70 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
150
183
  coin: string,
151
184
  coinObjects: string[],
152
185
  amount: number,
153
- minAmountOut?: number,
186
+ minAmountOut = 0,
154
187
  referralAddress?: string,
155
- sender?: string
188
+ sender?: string,
189
+ sponsoredTx?: boolean,
190
+ suiCoinObjectsForPythUpdate?: string[],
191
+ isDepositingSui?: boolean,
156
192
  ): Promise<Transaction> {
157
- let tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder))
193
+ let tx = new Transaction()
194
+
195
+ // Add referral if needed
158
196
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
159
197
  tx = await this.addReferral(referralAddress, tx)
160
198
  }
161
- const coinObject = this.processCoins(tx, coin, coinObjects)
162
- const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
199
+
200
+ // Initialize oracle transaction
201
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
202
+
203
+ // Handle sponsored transaction case
204
+ if (sponsoredTx) {
205
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
206
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
207
+
208
+ // Process deposit coins
209
+ const depositObject = isDepositingSui
210
+ ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
211
+ : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
212
+
213
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
214
+
215
+ tx.moveCall({
216
+ target: `${this.consts.zoCore.package}::market::deposit`,
217
+ typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`, this.consts.coins[coin].module],
218
+ arguments: [
219
+ tx.object(this.consts.zoCore.market),
220
+ tx.object(this.consts.zoCore.rebaseFeeModel),
221
+ depositObject,
222
+ tx.pure.u64(minAmountOut),
223
+ vaultsValuation,
224
+ symbolsValuation,
225
+ ],
226
+ })
227
+ return tx
228
+ }
229
+
230
+ // Handle non-sponsored transaction case
231
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
232
+ const depositObject = tx.splitCoins(
233
+ this.processCoins(tx, coin, coinObjects, false),
234
+ [tx.pure.u64(amount)],
235
+ )[0]
163
236
 
164
237
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
165
238
 
166
239
  tx.moveCall({
167
240
  target: `${this.consts.zoCore.package}::market::deposit`,
168
- typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`, this.consts.coins[coin].module],
241
+ typeArguments: [
242
+ `${this.consts.zoCore.package}::usdz::USDZ`,
243
+ this.consts.coins[coin].module,
244
+ ],
169
245
  arguments: [
170
246
  tx.object(this.consts.zoCore.market),
171
247
  tx.object(this.consts.zoCore.rebaseFeeModel),
172
248
  depositObject,
173
- tx.pure.u64(minAmountOut || 0),
249
+ tx.pure.u64(minAmountOut),
174
250
  vaultsValuation,
175
251
  symbolsValuation,
176
252
  ],
@@ -185,22 +261,37 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
185
261
  coin: string,
186
262
  lpCoinObjects: string[],
187
263
  amount: number,
188
- minAmountOut?: number
264
+ minAmountOut = 0,
265
+ sponsoredTx?: boolean,
266
+ suiCoinObjectsForPythUpdate?: string[],
189
267
  ): Promise<Transaction> {
190
- const tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder))
191
- const usdzCoinObject = this.processCoins(tx, 'usdz', lpCoinObjects)
192
- const [withdrawObject] = tx.splitCoins(usdzCoinObject, [tx.pure.u64(amount)])
268
+ let tx = new Transaction()
193
269
 
270
+ // Initialize oracle transaction
271
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
272
+
273
+ if (sponsoredTx) {
274
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
275
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
276
+ }
277
+ else {
278
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
279
+ }
280
+ const usdzCoinObject = this.processCoins(tx, 'usdz', lpCoinObjects, false)
281
+ const [withdrawObject] = tx.splitCoins(usdzCoinObject, [tx.pure.u64(amount)])
194
282
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
195
283
 
196
284
  tx.moveCall({
197
285
  target: `${this.consts.zoCore.package}::market::withdraw`,
198
- typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`, this.consts.coins[coin].module],
286
+ typeArguments: [
287
+ `${this.consts.zoCore.package}::usdz::USDZ`,
288
+ this.consts.coins[coin].module,
289
+ ],
199
290
  arguments: [
200
291
  tx.object(this.consts.zoCore.market),
201
292
  tx.object(this.consts.zoCore.rebaseFeeModel),
202
293
  withdrawObject,
203
- tx.pure.u64(minAmountOut || 0),
294
+ tx.pure.u64(minAmountOut),
204
295
  vaultsValuation,
205
296
  symbolsValuation,
206
297
  ],
@@ -208,13 +299,12 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
208
299
  return tx
209
300
  }
210
301
 
211
-
212
302
  public async swap(
213
303
  fromToken: string,
214
304
  toToken: string,
215
305
  fromAmount: bigint,
216
306
  fromCoinObjects: string[],
217
- minAmountOut?: number
307
+ minAmountOut?: number,
218
308
  ): Promise<Transaction> {
219
309
  const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
220
310
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
@@ -258,7 +348,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
258
348
  collateralSlippage?: number,
259
349
  relayerFee?: bigint,
260
350
  referralAddress?: string,
261
- sender?: string
351
+ sender?: string,
262
352
  ): Promise<Transaction> {
263
353
  let tx = new Transaction()
264
354
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -323,11 +413,14 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
323
413
  isTriggerOrder = false,
324
414
  isTakeProfitOrder = true,
325
415
  isIocOrder = false,
326
- pricesSlippage: number = 0.003,
327
- collateralSlippage: number = 0.5,
416
+ pricesSlippage = 0.003,
417
+ collateralSlippage = 0.5,
328
418
  relayerFee = BigInt(0.5),
329
- coinObjects?: string[]
419
+ coinObjects?: string[],
330
420
  ): Promise<Transaction> {
421
+ if (!coinObjects) {
422
+ throw new Error(`${this.constructor.name}: coinObjects is required`)
423
+ }
331
424
  const tx = await this.initOracleTxb([collateralToken, indexToken])
332
425
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
333
426
  const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
@@ -339,7 +432,8 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
339
432
  let allowTrade = ALLOW_TRADE_MUST_TRADE
340
433
  if (isTriggerOrder) {
341
434
  allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
342
- } else {
435
+ }
436
+ else {
343
437
  isTakeProfitOrder = true
344
438
  }
345
439
 
@@ -373,43 +467,56 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
373
467
  }
374
468
 
375
469
  public async decreaseMultiPositions(positions: Array<{
376
- pcpId: string,
377
- collateralToken: string,
378
- coinObjects: string[],
379
- indexToken: string,
380
- amount: bigint,
381
- long: boolean,
382
- indexPrice: number,
383
- collateralPrice: number,
384
- isTriggerOrder: boolean,
385
- isTakeProfitOrder: boolean,
386
- isIocOrder: boolean,
387
- slippage: number,
388
- relayerFee: bigint,
470
+ pcpId: string
471
+ collateralToken: string
472
+ indexToken: string
473
+ amount: bigint
474
+ long: boolean
475
+ indexPrice: number
476
+ collateralPrice: number
477
+ isTriggerOrder?: boolean
478
+ isTakeProfitOrder?: boolean
479
+ isIocOrder?: boolean
480
+ pricesSlippage?: number
481
+ collateralSlippage?: number
482
+ relayerFee?: bigint
483
+ coinObjects?: string[]
389
484
  }>, tx?: Transaction): Promise<Transaction> {
390
485
  if (!tx) {
391
486
  tx = new Transaction()
392
487
  }
393
- tx = await this.initOracleTxb(positions.map(position => [position.collateralToken, position.indexToken]).flat(), tx)
488
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
394
489
 
395
490
  for (const position of positions) {
396
491
  const {
397
492
  pcpId,
398
493
  collateralToken,
399
- coinObjects, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder, isTakeProfitOrder, isIocOrder, slippage, relayerFee
494
+ coinObjects = [],
495
+ indexToken,
496
+ amount,
497
+ long,
498
+ indexPrice,
499
+ collateralPrice,
500
+ isTriggerOrder = false,
501
+ isTakeProfitOrder = true,
502
+ isIocOrder = false,
503
+ pricesSlippage = 0.003,
504
+ collateralSlippage = 0.5,
505
+ relayerFee = BigInt(0.5),
400
506
  } = position
401
507
  let innerIsTakeProfitOrder = isTakeProfitOrder
402
508
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
403
509
  const coinObject = this.processCoins(tx, collateralToken, coinObjects)
404
510
  const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
405
511
 
406
- const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : slippage)
407
- const adjustCollateralPrice = this.processSlippage(collateralPrice, false, 0.5)
512
+ const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
513
+ const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
408
514
 
409
515
  let allowTrade = ALLOW_TRADE_MUST_TRADE
410
516
  if (isTriggerOrder) {
411
517
  allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
412
- } else {
518
+ }
519
+ else {
413
520
  innerIsTakeProfitOrder = true
414
521
  }
415
522
 
@@ -451,7 +558,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
451
558
  indexToken: string,
452
559
  amount: number,
453
560
  coinObjects: string[],
454
- long: boolean
561
+ long: boolean,
455
562
  ): Promise<Transaction> {
456
563
  const tx = await this.initOracleTxb([collateralToken, indexToken])
457
564
  const coinObject = this.processCoins(tx, collateralToken, coinObjects)
@@ -503,14 +610,14 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
503
610
  return tx
504
611
  }
505
612
 
506
- public async cancelOrder(
613
+ public cancelOrder(
507
614
  orderCapId: string,
508
615
  collateralToken: string,
509
616
  indexToken: string,
510
617
  long: boolean,
511
618
  type: string,
512
- isV11Order?: boolean
513
- ): Promise<Transaction> {
619
+ isV11Order?: boolean,
620
+ ): Transaction {
514
621
  const tx = new Transaction()
515
622
  let functionName = ''
516
623
  switch (type) {
@@ -542,16 +649,17 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
542
649
  return tx
543
650
  }
544
651
 
545
- public async cancelMultiOrders(
652
+ public cancelMultiOrders(
546
653
  orders: Array<{
547
- orderCapId: string,
548
- collateralToken: string,
549
- indexToken: string,
550
- long: boolean,
551
- type: string,
654
+ orderCapId: string
655
+ collateralToken: string
656
+ indexToken: string
657
+ long: boolean
658
+ type: string
552
659
  isV11Order?: boolean
553
- }>, tx?: Transaction
554
- ): Promise<Transaction> {
660
+ }>,
661
+ tx?: Transaction,
662
+ ): Transaction {
555
663
  if (!tx) {
556
664
  tx = new Transaction()
557
665
  }
@@ -592,7 +700,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
592
700
 
593
701
  public addReferral(
594
702
  referralAddress: string,
595
- tx?: Transaction
703
+ tx?: Transaction,
596
704
  ): Transaction {
597
705
  if (!tx) {
598
706
  tx = new Transaction()
@@ -608,19 +716,19 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
608
716
 
609
717
  public async adminUpdatePriceFeed(
610
718
  collateralToken: string,
611
- indexToken: string
719
+ indexToken: string,
612
720
  ): Promise<Transaction> {
613
721
  const tx = await this.initOracleTxb([collateralToken, indexToken])
614
722
  return tx
615
723
  }
616
724
 
617
- public async adminSettlePosition(
725
+ public adminSettlePosition(
618
726
  positionId: string,
619
727
  owner: string,
620
728
  collateralToken: string,
621
729
  indexToken: string,
622
- long: boolean
623
- ): Promise<Transaction> {
730
+ long: boolean,
731
+ ): Transaction {
624
732
  const tx = new Transaction()
625
733
 
626
734
  tx.moveCall({
@@ -645,7 +753,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
645
753
  return tx
646
754
  }
647
755
 
648
- public async adminDecreasePosition(
756
+ public adminDecreasePosition(
649
757
  positionId: string,
650
758
  owner: string,
651
759
  collateralToken: string,
@@ -653,10 +761,7 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
653
761
  positionAmount: number,
654
762
  amount: bigint,
655
763
  long: boolean,
656
- collateralPrice?: number,
657
- collateralSlippage?: number,
658
- relayerFee?: bigint
659
- ): Promise<Transaction> {
764
+ ): Transaction {
660
765
  const tx = new Transaction()
661
766
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
662
767
 
@@ -688,14 +793,14 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
688
793
  return tx
689
794
  }
690
795
 
691
- public async adminClearClosedPosition(
796
+ public adminClearClosedPosition(
692
797
  positionId: string,
693
798
  owner: string,
694
799
  collateralToken: string,
695
800
  indexToken: string,
696
801
  long: boolean,
697
- tx: Transaction
698
- ): Promise<void> {
802
+ tx: Transaction,
803
+ ): void {
699
804
  tx.moveCall({
700
805
  target: `${this.consts.zoCore.package}::market::force_clear_closed_position`,
701
806
  typeArguments: [
@@ -712,4 +817,4 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
712
817
  ],
713
818
  })
714
819
  }
715
- }
820
+ }