zo-sdk 0.1.2 → 0.1.4

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 +56 -15
  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 +56 -15
  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 +61 -16
  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,16 @@
3
3
  * Implements ZLP-specific trading and transaction methods
4
4
  */
5
5
 
6
+ import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
7
+ import { KioskTransaction } from '@mysten/kiosk'
6
8
  import type { SuiClient } from '@mysten/sui/client'
7
9
  import { Transaction } from '@mysten/sui/transactions'
8
10
  import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
11
+
12
+ import { BaseAPI } from '../abstract'
9
13
  import type { Network } from '../consts'
10
14
  import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE, LPToken } from '../consts'
11
- import {
12
- IZLPAPI,
15
+ import type {
13
16
  IBaseCredential,
14
17
  IBaseHistoryResponse,
15
18
  IBaseMarketInfo,
@@ -19,16 +22,15 @@ import {
19
22
  IBasePositionCapInfo,
20
23
  IBasePositionConfig,
21
24
  IBasePositionInfo,
25
+ IBaseRebaseFeeModel,
22
26
  IBaseStaked,
27
+ IBaseStakePool,
23
28
  IBaseSymbolInfo,
24
29
  IBaseVaultInfo,
25
- IBaseRebaseFeeModel,
26
- IBaseStakePool
30
+ IZLPAPI,
27
31
  } from '../interfaces'
28
- import { BaseAPI } from '../abstract'
29
- import { ZLPDataAPI } from './ZLPDataAPI'
30
32
  import { joinSymbol } from '../utils'
31
- import { KioskClient, KioskOwnerCap, KioskTransaction } from '@mysten/kiosk'
33
+ import { ZLPDataAPI } from './ZLPDataAPI'
32
34
 
33
35
  export class ZLPAPI extends BaseAPI implements IZLPAPI {
34
36
  public dataAPI: ZLPDataAPI
@@ -37,92 +39,118 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
37
39
  network: Network,
38
40
  provider: SuiClient,
39
41
  apiEndpoint: string,
40
- connectionURL: string
42
+ connectionURL: string,
41
43
  ) {
42
44
  super(network, provider, apiEndpoint, connectionURL, LPToken.ZLP)
43
45
  this.dataAPI = new ZLPDataAPI(network, provider, apiEndpoint, connectionURL)
44
46
  }
45
47
 
46
- public stake(lpCoinObjects: string[], amount: bigint, pool: string, tx?: Transaction): Promise<Transaction> {
47
- throw new Error('Method not implemented.')
48
+ public stake(_lpCoinObjects: string[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
49
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
48
50
  }
49
- public unstake(credentials: IBaseCredential[], amount: bigint, pool: string, tx?: Transaction): Promise<Transaction> {
50
- throw new Error('Method not implemented.')
51
+
52
+ public unstake(_credentials: IBaseCredential[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
53
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
51
54
  }
52
- public claimTokenFromSCard(token: string, coinObjects: string[], kioskClient: KioskClient, kioskCap: KioskOwnerCap, scard: string): Promise<Transaction> {
53
- throw new Error('Method not implemented.')
55
+
56
+ public claimTokenFromSCard(_token: string, _coinObjects: string[], _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string): Transaction {
57
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
54
58
  }
55
- public valuateVaults(tx: Transaction) {
56
- throw new Error('Method not implemented.')
59
+
60
+ public valuateVaults(_tx: Transaction) {
61
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
57
62
  }
58
- public valuateSymbols(tx: Transaction) {
59
- throw new Error('Method not implemented.')
63
+
64
+ public valuateSymbols(_tx: Transaction) {
65
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
60
66
  }
61
- public valuate(tx: Transaction): { vaultsValuation: any; symbolsValuation: any } {
62
- throw new Error('Method not implemented.')
67
+
68
+ public valuate(_tx: Transaction): { vaultsValuation: any, symbolsValuation: any } {
69
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
63
70
  }
71
+
64
72
  public valuateMarket(): Promise<IBaseMarketValuationInfo> {
65
- throw new Error('Method not implemented.')
73
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
66
74
  }
67
- public fundingFeeRate(indexToken: string, long: boolean): Promise<number> {
68
- throw new Error('Method not implemented.')
75
+
76
+ public fundingFeeRate(_indexToken: string, _long: boolean): Promise<number> {
77
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
69
78
  }
70
- public rebaseFeeRate(collateralToken: string, increase: boolean, amount: number): Promise<number> {
71
- throw new Error('Method not implemented.')
79
+
80
+ public rebaseFeeRate(_collateralToken: string, _increase: boolean, _amount: number): Promise<number> {
81
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
72
82
  }
73
- public reservingFeeRate(collateralToken: string, amount: number): Promise<number> {
74
- throw new Error('Method not implemented.')
83
+
84
+ public reservingFeeRate(_collateralToken: string, _amount: number): Promise<number> {
85
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
75
86
  }
76
- public calcPositionReserveFeeAmount(position: IBasePositionInfo): Promise<number> {
77
- throw new Error('Method not implemented.')
87
+
88
+ public calcPositionReserveFeeAmount(_position: IBasePositionInfo): Promise<number> {
89
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
78
90
  }
79
- public calcPositionFundingFeeValue(position: IBasePositionInfo): Promise<number> {
80
- throw new Error('Method not implemented.')
91
+
92
+ public calcPositionFundingFeeValue(_position: IBasePositionInfo): Promise<number> {
93
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
81
94
  }
95
+
82
96
  public getMarketInfo(): Promise<IBaseMarketInfo> {
83
- throw new Error('Method not implemented.')
97
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
84
98
  }
85
- public getVaultInfo(vault: string): Promise<IBaseVaultInfo> {
86
- throw new Error('Method not implemented.')
99
+
100
+ public getVaultInfo(_vault: string): Promise<IBaseVaultInfo> {
101
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
87
102
  }
88
- public getSymbolInfo(tokenId: string, long: boolean): Promise<IBaseSymbolInfo> {
89
- throw new Error('Method not implemented.')
103
+
104
+ public getSymbolInfo(_tokenId: string, _long: boolean): Promise<IBaseSymbolInfo> {
105
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
90
106
  }
91
- public getPositionConfig(indexToken: string, long: boolean): Promise<IBasePositionConfig> {
92
- throw new Error('Method not implemented.')
107
+
108
+ public getPositionConfig(_indexToken: string, _long: boolean): Promise<IBasePositionConfig> {
109
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
93
110
  }
111
+
94
112
  public getRebaseFeeModel(): Promise<IBaseRebaseFeeModel> {
95
- throw new Error('Method not implemented.')
113
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
96
114
  }
115
+
97
116
  public getOpenPositions(): Promise<IBasePositionInfo[]> {
98
- throw new Error('Method not implemented.')
117
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
99
118
  }
100
- public getPositionCapInfoList(owner: string): Promise<IBasePositionCapInfo[]> {
101
- throw new Error('Method not implemented.')
119
+
120
+ public getPositionCapInfoList(_owner: string): Promise<IBasePositionCapInfo[]> {
121
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
102
122
  }
103
- public getPositionInfoList(positionCapInfoList: IBasePositionCapInfo[], owner: string): Promise<IBasePositionInfo[]> {
104
- throw new Error('Method not implemented.')
123
+
124
+ public getPositionInfoList(_positionCapInfoList: IBasePositionCapInfo[], _owner: string): Promise<IBasePositionInfo[]> {
125
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
105
126
  }
106
- public getOrderCapInfoList(owner: string): Promise<IBaseOrderCapInfo[]> {
107
- throw new Error('Method not implemented.')
127
+
128
+ public getOrderCapInfoList(_owner: string): Promise<IBaseOrderCapInfo[]> {
129
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
108
130
  }
109
- public getOrderInfoList(orderCapInfoList: IBaseOrderCapInfo[], owner: string): Promise<IBaseOrderInfo[]> {
110
- throw new Error('Method not implemented.')
131
+
132
+ public getOrderInfoList(_orderCapInfoList: IBaseOrderCapInfo[], _owner: string): Promise<IBaseOrderInfo[]> {
133
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
111
134
  }
112
- public getHistory(trader: string, page: number, limit: number, orderType?: string, symbol?: string): Promise<IBaseHistoryResponse> {
113
- throw new Error('Method not implemented.')
135
+
136
+ public getHistory(_trader: string, _page: number, _limit: number, _orderType?: string, _symbol?: string): Promise<IBaseHistoryResponse> {
137
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
114
138
  }
115
- public getStaked(owner: string): Promise<IBaseStaked> {
116
- throw new Error('Method not implemented.')
139
+
140
+ public getStaked(_owner: string): Promise<IBaseStaked> {
141
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
117
142
  }
143
+
118
144
  public getStakePool(): Promise<IBaseStakePool> {
119
- throw new Error('Method not implemented.')
145
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
120
146
  }
121
- public hasReferral(referree: string): Promise<boolean> {
122
- throw new Error('Method not implemented.')
147
+
148
+ public hasReferral(_referree: string): Promise<boolean> {
149
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
123
150
  }
124
- public getReferralData(referree: string): Promise<any> {
125
- throw new Error('Method not implemented.')
151
+
152
+ public getReferralData(_referree: string): Promise<any> {
153
+ throw new Error(`Method not implemented in ${this.constructor.name}.`)
126
154
  }
127
155
 
128
156
  /**
@@ -132,27 +160,70 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
132
160
  coin: string,
133
161
  coinObjects: string[],
134
162
  amount: number,
135
- minAmountOut?: number,
163
+ minAmountOut = 0,
136
164
  referralAddress?: string,
137
- sender?: string
165
+ sender?: string,
166
+ sponsoredTx?: boolean,
167
+ suiCoinObjectsForPythUpdate?: string[],
168
+ isDepositingSui?: boolean,
138
169
  ): Promise<Transaction> {
139
- let tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder))
170
+ let tx = new Transaction()
171
+
172
+ // Add referral if needed
140
173
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
141
174
  tx = await this.addReferral(referralAddress, tx)
142
175
  }
143
- const coinObject = this.processCoins(tx, coin, coinObjects)
144
- const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
176
+
177
+ // Initialize oracle transaction
178
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
179
+
180
+ // Handle sponsored transaction case
181
+ if (sponsoredTx) {
182
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
183
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
184
+
185
+ // Process deposit coins
186
+ const depositObject = isDepositingSui
187
+ ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
188
+ : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
189
+
190
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
191
+
192
+ tx.moveCall({
193
+ target: `${this.consts.zoCore.package}::market::deposit`,
194
+ typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
195
+ arguments: [
196
+ tx.object(this.consts.zoCore.market),
197
+ tx.object(this.consts.zoCore.rebaseFeeModel),
198
+ depositObject,
199
+ tx.pure.u64(minAmountOut),
200
+ vaultsValuation,
201
+ symbolsValuation,
202
+ ],
203
+ })
204
+ return tx
205
+ }
206
+
207
+ // Handle non-sponsored transaction case
208
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
209
+ const depositObject = tx.splitCoins(
210
+ this.processCoins(tx, coin, coinObjects, false),
211
+ [tx.pure.u64(amount)],
212
+ )[0]
145
213
 
146
214
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
147
215
 
148
216
  tx.moveCall({
149
217
  target: `${this.consts.zoCore.package}::market::deposit`,
150
- typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
218
+ typeArguments: [
219
+ `${this.consts.zoCore.package}::zlp::ZLP`,
220
+ this.consts.coins[coin].module,
221
+ ],
151
222
  arguments: [
152
223
  tx.object(this.consts.zoCore.market),
153
224
  tx.object(this.consts.zoCore.rebaseFeeModel),
154
225
  depositObject,
155
- tx.pure.u64(minAmountOut || 0),
226
+ tx.pure.u64(minAmountOut),
156
227
  vaultsValuation,
157
228
  symbolsValuation,
158
229
  ],
@@ -167,22 +238,37 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
167
238
  coin: string,
168
239
  lpCoinObjects: string[],
169
240
  amount: number,
170
- minAmountOut?: number
241
+ minAmountOut = 0,
242
+ sponsoredTx?: boolean,
243
+ suiCoinObjectsForPythUpdate?: string[],
171
244
  ): Promise<Transaction> {
172
- const tx = await this.initOracleTxb(Object.keys(this.consts.pythFeeder.feeder))
173
- const zlpCoinObject = this.processCoins(tx, 'zlp', lpCoinObjects)
174
- const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)])
245
+ let tx = new Transaction()
246
+
247
+ // Initialize oracle transaction
248
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
175
249
 
250
+ if (sponsoredTx) {
251
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
252
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
253
+ }
254
+ else {
255
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
256
+ }
257
+ const zlpCoinObject = this.processCoins(tx, 'zlp', lpCoinObjects, false)
258
+ const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)])
176
259
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
177
260
 
178
261
  tx.moveCall({
179
262
  target: `${this.consts.zoCore.package}::market::withdraw`,
180
- typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
263
+ typeArguments: [
264
+ `${this.consts.zoCore.package}::zlp::ZLP`,
265
+ this.consts.coins[coin].module,
266
+ ],
181
267
  arguments: [
182
268
  tx.object(this.consts.zoCore.market),
183
269
  tx.object(this.consts.zoCore.rebaseFeeModel),
184
270
  withdrawObject,
185
- tx.pure.u64(minAmountOut || 0),
271
+ tx.pure.u64(minAmountOut),
186
272
  vaultsValuation,
187
273
  symbolsValuation,
188
274
  ],
@@ -190,13 +276,12 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
190
276
  return tx
191
277
  }
192
278
 
193
-
194
279
  public async swap(
195
280
  fromToken: string,
196
281
  toToken: string,
197
282
  fromAmount: bigint,
198
283
  fromCoinObjects: string[],
199
- minAmountOut?: number
284
+ minAmountOut?: number,
200
285
  ): Promise<Transaction> {
201
286
  const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
202
287
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
@@ -236,11 +321,11 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
236
321
  collateralPrice: number,
237
322
  isLimitOrder?: boolean,
238
323
  isIocOrder?: boolean,
239
- pricesSlippage: number = 0.003,
240
- collateralSlippage: number = 0.5,
324
+ pricesSlippage = 0.003,
325
+ collateralSlippage = 0.5,
241
326
  relayerFee = BigInt(0.5),
242
327
  referralAddress?: string,
243
- sender?: string
328
+ sender?: string,
244
329
  ): Promise<Transaction> {
245
330
  let tx = new Transaction()
246
331
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -305,11 +390,14 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
305
390
  isTriggerOrder = false,
306
391
  isTakeProfitOrder = true,
307
392
  isIocOrder = false,
308
- pricesSlippage: number = 0.003,
309
- collateralSlippage: number = 0.5,
393
+ pricesSlippage = 0.003,
394
+ collateralSlippage = 0.5,
310
395
  relayerFee = BigInt(0.5),
311
- coinObjects?: string[]
396
+ coinObjects?: string[],
312
397
  ): Promise<Transaction> {
398
+ if (!coinObjects) {
399
+ throw new Error(`${this.constructor.name}: coinObjects is required`)
400
+ }
313
401
  const tx = await this.initOracleTxb([collateralToken, indexToken])
314
402
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
315
403
  const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
@@ -321,7 +409,8 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
321
409
  let allowTrade = ALLOW_TRADE_MUST_TRADE
322
410
  if (isTriggerOrder) {
323
411
  allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
324
- } else {
412
+ }
413
+ else {
325
414
  isTakeProfitOrder = true
326
415
  }
327
416
 
@@ -355,43 +444,56 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
355
444
  }
356
445
 
357
446
  public async decreaseMultiPositions(positions: Array<{
358
- pcpId: string,
359
- collateralToken: string,
360
- coinObjects: string[],
361
- indexToken: string,
362
- amount: bigint,
363
- long: boolean,
364
- indexPrice: number,
365
- collateralPrice: number,
366
- isTriggerOrder: boolean,
367
- isTakeProfitOrder: boolean,
368
- isIocOrder: boolean,
369
- slippage: number,
370
- relayerFee: bigint,
447
+ pcpId: string
448
+ collateralToken: string
449
+ indexToken: string
450
+ amount: bigint
451
+ long: boolean
452
+ indexPrice: number
453
+ collateralPrice: number
454
+ isTriggerOrder?: boolean
455
+ isTakeProfitOrder?: boolean
456
+ isIocOrder?: boolean
457
+ pricesSlippage?: number
458
+ collateralSlippage?: number
459
+ relayerFee?: bigint
460
+ coinObjects?: string[]
371
461
  }>, tx?: Transaction): Promise<Transaction> {
372
462
  if (!tx) {
373
463
  tx = new Transaction()
374
464
  }
375
- tx = await this.initOracleTxb(positions.map(position => [position.collateralToken, position.indexToken]).flat(), tx)
465
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
376
466
 
377
467
  for (const position of positions) {
378
468
  const {
379
469
  pcpId,
380
470
  collateralToken,
381
- coinObjects, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder, isTakeProfitOrder, isIocOrder, slippage, relayerFee
471
+ coinObjects = [],
472
+ indexToken,
473
+ amount,
474
+ long,
475
+ indexPrice,
476
+ collateralPrice,
477
+ isTriggerOrder = false,
478
+ isTakeProfitOrder = true,
479
+ isIocOrder = false,
480
+ pricesSlippage = 0.003,
481
+ collateralSlippage = 0.5,
482
+ relayerFee = BigInt(0.5),
382
483
  } = position
383
484
  let innerIsTakeProfitOrder = isTakeProfitOrder
384
485
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
385
486
  const coinObject = this.processCoins(tx, collateralToken, coinObjects)
386
487
  const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
387
488
 
388
- const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : slippage)
389
- const adjustCollateralPrice = this.processSlippage(collateralPrice, false, 0.5)
489
+ const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
490
+ const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
390
491
 
391
492
  let allowTrade = ALLOW_TRADE_MUST_TRADE
392
493
  if (isTriggerOrder) {
393
494
  allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
394
- } else {
495
+ }
496
+ else {
395
497
  innerIsTakeProfitOrder = true
396
498
  }
397
499
 
@@ -439,11 +541,12 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
439
541
  scard: string,
440
542
  isLimitOrder?: boolean,
441
543
  isIocOrder?: boolean,
442
- pricesSlippage: number = 0.003,
443
- collateralSlippage: number = 0.5,
544
+ pricesSlippage = 0.003,
545
+ collateralSlippage = 0.5,
444
546
  relayerFee = BigInt(0.5),
445
547
  referralAddress?: string,
446
- sender?: string): Promise<Transaction> {
548
+ sender?: string,
549
+ ): Promise<Transaction> {
447
550
  let tx = new Transaction()
448
551
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
449
552
  tx = await this.addReferral(referralAddress, tx)
@@ -468,7 +571,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
468
571
  transaction: tx,
469
572
  kioskClient,
470
573
  cap: kioskCap,
471
- });
574
+ })
472
575
 
473
576
  const [sudoCard, promise] = kioskTx.borrow({
474
577
  itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
@@ -507,7 +610,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
507
610
  .return({
508
611
  itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
509
612
  item: sudoCard,
510
- promise: promise,
613
+ promise,
511
614
  })
512
615
  .finalize()
513
616
  return tx
@@ -527,10 +630,14 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
527
630
  isTriggerOrder = false,
528
631
  isTakeProfitOrder = true,
529
632
  isIocOrder = false,
530
- pricesSlippage: number = 0.003,
531
- collateralSlippage: number = 0.5,
633
+ pricesSlippage = 0.003,
634
+ collateralSlippage = 0.5,
532
635
  relayerFee = BigInt(0.5),
533
- coinObjects?: string[]): Promise<Transaction> {
636
+ coinObjects?: string[],
637
+ ): Promise<Transaction> {
638
+ if (!coinObjects) {
639
+ throw new Error(`${this.constructor.name}: coinObjects is required`)
640
+ }
534
641
  const tx = await this.initOracleTxb([collateralToken, indexToken])
535
642
 
536
643
  const kioskTx = new KioskTransaction({
@@ -554,7 +661,8 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
554
661
  let allowTrade = ALLOW_TRADE_MUST_TRADE
555
662
  if (isTriggerOrder) {
556
663
  allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
557
- } else {
664
+ }
665
+ else {
558
666
  isTakeProfitOrder = true
559
667
  }
560
668
 
@@ -589,7 +697,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
589
697
  .return({
590
698
  itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
591
699
  item: sudoCard,
592
- promise: promise,
700
+ promise,
593
701
  })
594
702
  .finalize()
595
703
  return tx
@@ -597,28 +705,30 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
597
705
 
598
706
  public async decreaseMultiPositionsWithSCard(
599
707
  positions: Array<{
600
- pcpId: string;
601
- collateralToken: string;
602
- indexToken: string;
603
- amount: bigint;
604
- long: boolean;
605
- indexPrice: number;
606
- collateralPrice: number;
607
- isTriggerOrder: boolean;
608
- isTakeProfitOrder: boolean;
609
- isIocOrder: boolean;
610
- slippage: number;
611
- relayerFee: bigint;
612
- coinObjects: string[];
708
+ pcpId: string
709
+ collateralToken: string
710
+ indexToken: string
711
+ amount: bigint
712
+ long: boolean
713
+ indexPrice: number
714
+ collateralPrice: number
715
+ isTriggerOrder?: boolean
716
+ isTakeProfitOrder?: boolean
717
+ isIocOrder?: boolean
718
+ pricesSlippage?: number
719
+ collateralSlippage?: number
720
+ relayerFee?: bigint
721
+ coinObjects?: string[]
613
722
  }>,
614
723
  kioskClient: KioskClient,
615
724
  kioskCap: KioskOwnerCap,
616
725
  scard: string,
617
- tx?: Transaction): Promise<Transaction> {
726
+ tx?: Transaction,
727
+ ): Promise<Transaction> {
618
728
  if (!tx) {
619
- tx = new Transaction();
729
+ tx = new Transaction()
620
730
  }
621
- tx = await this.initOracleTxb(positions.map(position => [position.collateralToken, position.indexToken]).flat(), tx);
731
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
622
732
 
623
733
  const kioskTx = new KioskTransaction({
624
734
  transaction: tx,
@@ -635,20 +745,32 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
635
745
  const {
636
746
  pcpId,
637
747
  collateralToken,
638
- indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder, isTakeProfitOrder, isIocOrder, slippage, relayerFee, coinObjects
748
+ indexToken,
749
+ amount,
750
+ long,
751
+ indexPrice,
752
+ collateralPrice,
753
+ isTriggerOrder = false,
754
+ isTakeProfitOrder = true,
755
+ isIocOrder = false,
756
+ pricesSlippage = 0.003,
757
+ collateralSlippage = 0.5,
758
+ relayerFee = BigInt(0.5),
759
+ coinObjects = [],
639
760
  } = position
640
761
  let innerIsTakeProfitOrder = isTakeProfitOrder
641
762
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
642
763
  const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
643
764
  const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee || BigInt(0.5))])
644
765
 
645
- const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : slippage)
646
- const adjustCollateralPrice = this.processSlippage(collateralPrice, false, 0.5)
766
+ const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
767
+ const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
647
768
 
648
769
  let allowTrade = ALLOW_TRADE_MUST_TRADE
649
770
  if (isTriggerOrder) {
650
771
  allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
651
- } else {
772
+ }
773
+ else {
652
774
  innerIsTakeProfitOrder = true
653
775
  }
654
776
 
@@ -684,7 +806,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
684
806
  .return({
685
807
  itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
686
808
  item: sudoCard,
687
- promise: promise,
809
+ promise,
688
810
  })
689
811
  .finalize()
690
812
  return tx
@@ -699,7 +821,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
699
821
  indexToken: string,
700
822
  amount: number,
701
823
  coinObjects: string[],
702
- long: boolean
824
+ long: boolean,
703
825
  ): Promise<Transaction> {
704
826
  const tx = await this.initOracleTxb([collateralToken, indexToken])
705
827
  const coinObject = this.processCoins(tx, collateralToken, coinObjects)
@@ -751,14 +873,14 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
751
873
  return tx
752
874
  }
753
875
 
754
- public async cancelOrder(
876
+ public cancelOrder(
755
877
  orderCapId: string,
756
878
  collateralToken: string,
757
879
  indexToken: string,
758
880
  long: boolean,
759
881
  type: string,
760
- isV11Order?: boolean
761
- ): Promise<Transaction> {
882
+ isV11Order?: boolean,
883
+ ): Transaction {
762
884
  const tx = new Transaction()
763
885
  let functionName = ''
764
886
  switch (type) {
@@ -790,16 +912,17 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
790
912
  return tx
791
913
  }
792
914
 
793
- public async cancelMultiOrders(
915
+ public cancelMultiOrders(
794
916
  orders: Array<{
795
- orderCapId: string,
796
- collateralToken: string,
797
- indexToken: string,
798
- long: boolean,
799
- type: string,
917
+ orderCapId: string
918
+ collateralToken: string
919
+ indexToken: string
920
+ long: boolean
921
+ type: string
800
922
  isV11Order?: boolean
801
- }>, tx?: Transaction
802
- ): Promise<Transaction> {
923
+ }>,
924
+ tx?: Transaction,
925
+ ): Transaction {
803
926
  if (!tx) {
804
927
  tx = new Transaction()
805
928
  }
@@ -838,13 +961,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
838
961
  return tx
839
962
  }
840
963
 
841
-
842
964
  public clearClosedPosition(
843
965
  pcpId: string,
844
966
  collateralToken: string,
845
967
  indexToken: string,
846
968
  long: boolean,
847
- tx: Transaction): void {
969
+ tx: Transaction,
970
+ ): void {
848
971
  tx.moveCall({
849
972
  target: `${this.consts.zoCore.package}::market::clear_closed_position`,
850
973
  typeArguments: [
@@ -863,7 +986,8 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
863
986
  indexToken: string,
864
987
  long: boolean,
865
988
  tx: Transaction,
866
- isV11Order?: boolean): void {
989
+ isV11Order?: boolean,
990
+ ): void {
867
991
  const funcName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order'
868
992
  tx.moveCall({
869
993
  target: `${this.consts.zoCore.package}::market::${funcName}`,
@@ -884,7 +1008,8 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
884
1008
  indexToken: string,
885
1009
  long: boolean,
886
1010
  tx: Transaction,
887
- isV11Order?: boolean): void {
1011
+ isV11Order?: boolean,
1012
+ ): void {
888
1013
  const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order'
889
1014
  tx.moveCall({
890
1015
  target: `${this.consts.zoCore.package}::market::${funcName}`,
@@ -901,7 +1026,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
901
1026
 
902
1027
  public addReferral(
903
1028
  referralAddress: string,
904
- tx?: Transaction
1029
+ tx?: Transaction,
905
1030
  ): Transaction {
906
1031
  if (!tx) {
907
1032
  tx = new Transaction()
@@ -917,19 +1042,19 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
917
1042
 
918
1043
  public async adminUpdatePriceFeed(
919
1044
  collateralToken: string,
920
- indexToken: string
1045
+ indexToken: string,
921
1046
  ): Promise<Transaction> {
922
1047
  const tx = await this.initOracleTxb([collateralToken, indexToken])
923
1048
  return tx
924
1049
  }
925
1050
 
926
- public async adminSettlePosition(
1051
+ public adminSettlePosition(
927
1052
  positionId: string,
928
1053
  owner: string,
929
1054
  collateralToken: string,
930
1055
  indexToken: string,
931
- long: boolean
932
- ): Promise<Transaction> {
1056
+ long: boolean,
1057
+ ): Transaction {
933
1058
  const tx = new Transaction()
934
1059
 
935
1060
  tx.moveCall({
@@ -954,7 +1079,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
954
1079
  return tx
955
1080
  }
956
1081
 
957
- public async adminDecreasePosition(
1082
+ public adminDecreasePosition(
958
1083
  positionId: string,
959
1084
  owner: string,
960
1085
  collateralToken: string,
@@ -962,10 +1087,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
962
1087
  positionAmount: number,
963
1088
  amount: bigint,
964
1089
  long: boolean,
965
- collateralPrice?: number,
966
- collateralSlippage?: number,
967
- relayerFee?: bigint
968
- ): Promise<Transaction> {
1090
+ ): Transaction {
969
1091
  const tx = new Transaction()
970
1092
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
971
1093
 
@@ -997,14 +1119,14 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
997
1119
  return tx
998
1120
  }
999
1121
 
1000
- public async adminClearClosedPosition(
1122
+ public adminClearClosedPosition(
1001
1123
  positionId: string,
1002
1124
  owner: string,
1003
1125
  collateralToken: string,
1004
1126
  indexToken: string,
1005
1127
  long: boolean,
1006
- tx: Transaction
1007
- ): Promise<void> {
1128
+ tx: Transaction,
1129
+ ): void {
1008
1130
  tx.moveCall({
1009
1131
  target: `${this.consts.zoCore.package}::market::force_clear_closed_position`,
1010
1132
  typeArguments: [
@@ -1022,25 +1144,25 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
1022
1144
  })
1023
1145
  }
1024
1146
 
1025
- public async adminIssueLootbox(
1147
+ public adminIssueLootbox(
1026
1148
  coin: string,
1027
1149
  tiers: number[],
1028
1150
  beneficiaries: string[],
1029
1151
  amounts: number[],
1030
1152
  tx: Transaction,
1031
- ): Promise<void> {
1032
- let module = this.consts.zoCore.package + '::zlp::ZLP'
1153
+ ): void {
1154
+ let module = `${this.consts.zoCore.package}::zlp::ZLP`
1033
1155
  if (coin !== 'zlp') {
1034
1156
  module = this.consts.coins[coin].module
1035
1157
  }
1036
- for (let i = 0; i < beneficiaries.length; i++) {
1158
+ for (const [i, beneficiary] of beneficiaries.entries()) {
1037
1159
  tx.moveCall({
1038
1160
  target: `${this.consts.zoLootbox.package}::lootbox::admin_issue_lootbox`,
1039
1161
  typeArguments: [module],
1040
1162
  arguments: [
1041
1163
  tx.object(this.consts.zoLootbox.adminCap),
1042
1164
  tx.pure.u8(tiers[i]),
1043
- tx.pure.address(beneficiaries[i]),
1165
+ tx.pure.address(beneficiary),
1044
1166
  tx.pure.u64(amounts[i]),
1045
1167
  tx.pure.bool(amounts[i] > 0),
1046
1168
  tx.object(`${this.consts.zoLootbox.lootboxSettings}`),
@@ -1049,16 +1171,16 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
1049
1171
  }
1050
1172
  }
1051
1173
 
1052
- public async depositToPrizePool(
1174
+ public depositToPrizePool(
1053
1175
  coin: string,
1054
1176
  coinObjects: string[],
1055
1177
  amount: number,
1056
- ): Promise<Transaction> {
1178
+ ): Transaction {
1057
1179
  const tx = new Transaction()
1058
1180
  const coinObject = this.processCoins(tx, coin, coinObjects)
1059
1181
  const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
1060
1182
 
1061
- let module = this.consts.zoCore.package + '::zlp::ZLP'
1183
+ let module = `${this.consts.zoCore.package}::zlp::ZLP`
1062
1184
  if (coin !== 'zlp') {
1063
1185
  module = this.consts.coins[coin].module
1064
1186
  }
@@ -1075,13 +1197,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
1075
1197
  return tx
1076
1198
  }
1077
1199
 
1078
- public async withdrawFromPricePool(
1200
+ public withdrawFromPricePool(
1079
1201
  coin: string,
1080
- amount: number
1081
- ): Promise<Transaction> {
1202
+ amount: number,
1203
+ ): Transaction {
1082
1204
  const tx = new Transaction()
1083
1205
 
1084
- let module = this.consts.zoCore.package + '::zlp::ZLP'
1206
+ let module = `${this.consts.zoCore.package}::zlp::ZLP`
1085
1207
  let metadata = this.consts.zoCore.zlpMetadata
1086
1208
  if (coin !== 'zlp') {
1087
1209
  module = this.consts.coins[coin].module
@@ -1101,13 +1223,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
1101
1223
  return tx
1102
1224
  }
1103
1225
 
1104
- public async openLootbox(
1226
+ public openLootbox(
1105
1227
  coin: string,
1106
- lootbox: string
1107
- ): Promise<Transaction> {
1228
+ lootbox: string,
1229
+ ): Transaction {
1108
1230
  const tx = new Transaction()
1109
1231
 
1110
- let module = this.consts.zoCore.package + '::zlp::ZLP'
1232
+ let module = `${this.consts.zoCore.package}::zlp::ZLP`
1111
1233
  let metadata = this.consts.zoCore.zlpMetadata
1112
1234
  if (coin !== 'zlp') {
1113
1235
  module = this.consts.coins[coin].module
@@ -1127,4 +1249,4 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
1127
1249
 
1128
1250
  return tx
1129
1251
  }
1130
- }
1252
+ }