@qubic.org/contracts 0.2.6 → 1.0.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.
Files changed (163) hide show
  1. package/LICENSE +41 -0
  2. package/README.md +15 -18
  3. package/dist/__generated__/computorcontrolledfund.d.ts +1 -1
  4. package/dist/__generated__/computorcontrolledfund.d.ts.map +1 -1
  5. package/dist/__generated__/computorcontrolledfund.js +8 -8
  6. package/dist/__generated__/computorcontrolledfund.js.map +1 -1
  7. package/dist/__generated__/escrow.d.ts +1 -1
  8. package/dist/__generated__/escrow.d.ts.map +1 -1
  9. package/dist/__generated__/escrow.js +3 -3
  10. package/dist/__generated__/escrow.js.map +1 -1
  11. package/dist/__generated__/generalquorumproposal.d.ts +1 -1
  12. package/dist/__generated__/generalquorumproposal.d.ts.map +1 -1
  13. package/dist/__generated__/generalquorumproposal.js +6 -6
  14. package/dist/__generated__/generalquorumproposal.js.map +1 -1
  15. package/dist/__generated__/ggwp.d.ts +265 -0
  16. package/dist/__generated__/ggwp.d.ts.map +1 -0
  17. package/dist/__generated__/ggwp.js +825 -0
  18. package/dist/__generated__/ggwp.js.map +1 -0
  19. package/dist/__generated__/index.d.ts +1 -0
  20. package/dist/__generated__/index.d.ts.map +1 -1
  21. package/dist/__generated__/index.js +1 -0
  22. package/dist/__generated__/index.js.map +1 -1
  23. package/dist/__generated__/msvault.d.ts +1 -1
  24. package/dist/__generated__/msvault.d.ts.map +1 -1
  25. package/dist/__generated__/msvault.js +19 -19
  26. package/dist/__generated__/msvault.js.map +1 -1
  27. package/dist/__generated__/multisignvault.d.ts +25 -25
  28. package/dist/__generated__/multisignvault.d.ts.map +1 -1
  29. package/dist/__generated__/multisignvault.js +25 -25
  30. package/dist/__generated__/multisignvault.js.map +1 -1
  31. package/dist/__generated__/nostromo.d.ts +1 -1
  32. package/dist/__generated__/nostromo.d.ts.map +1 -1
  33. package/dist/__generated__/nostromo.js +15 -15
  34. package/dist/__generated__/nostromo.js.map +1 -1
  35. package/dist/__generated__/pulse.d.ts +1 -1
  36. package/dist/__generated__/pulse.d.ts.map +1 -1
  37. package/dist/__generated__/pulse.js +26 -26
  38. package/dist/__generated__/pulse.js.map +1 -1
  39. package/dist/__generated__/qbay.d.ts +1 -1
  40. package/dist/__generated__/qbay.d.ts.map +1 -1
  41. package/dist/__generated__/qbay.js +23 -23
  42. package/dist/__generated__/qbay.js.map +1 -1
  43. package/dist/__generated__/qbond.d.ts +1 -1
  44. package/dist/__generated__/qbond.d.ts.map +1 -1
  45. package/dist/__generated__/qbond.js +14 -14
  46. package/dist/__generated__/qbond.js.map +1 -1
  47. package/dist/__generated__/qdraw.d.ts +1 -1
  48. package/dist/__generated__/qdraw.d.ts.map +1 -1
  49. package/dist/__generated__/qdraw.js.map +1 -1
  50. package/dist/__generated__/qduel.d.ts +1 -1
  51. package/dist/__generated__/qduel.d.ts.map +1 -1
  52. package/dist/__generated__/qduel.js +11 -11
  53. package/dist/__generated__/qduel.js.map +1 -1
  54. package/dist/__generated__/qearn.d.ts +1 -1
  55. package/dist/__generated__/qearn.d.ts.map +1 -1
  56. package/dist/__generated__/qearn.js +10 -10
  57. package/dist/__generated__/qearn.js.map +1 -1
  58. package/dist/__generated__/qip.d.ts +18 -1
  59. package/dist/__generated__/qip.d.ts.map +1 -1
  60. package/dist/__generated__/qip.js +64 -3
  61. package/dist/__generated__/qip.js.map +1 -1
  62. package/dist/__generated__/qraffle.d.ts +1 -1
  63. package/dist/__generated__/qraffle.d.ts.map +1 -1
  64. package/dist/__generated__/qraffle.js +12 -12
  65. package/dist/__generated__/qraffle.js.map +1 -1
  66. package/dist/__generated__/qreservepool.d.ts +1 -1
  67. package/dist/__generated__/qreservepool.d.ts.map +1 -1
  68. package/dist/__generated__/qreservepool.js +5 -5
  69. package/dist/__generated__/qreservepool.js.map +1 -1
  70. package/dist/__generated__/qrwa.d.ts +1 -1
  71. package/dist/__generated__/qrwa.d.ts.map +1 -1
  72. package/dist/__generated__/qrwa.js +18 -18
  73. package/dist/__generated__/qrwa.js.map +1 -1
  74. package/dist/__generated__/qswap.d.ts +3 -1
  75. package/dist/__generated__/qswap.d.ts.map +1 -1
  76. package/dist/__generated__/qswap.js +30 -18
  77. package/dist/__generated__/qswap.js.map +1 -1
  78. package/dist/__generated__/qthirtyfour.d.ts +1 -1
  79. package/dist/__generated__/qthirtyfour.d.ts.map +1 -1
  80. package/dist/__generated__/qthirtyfour.js +19 -19
  81. package/dist/__generated__/qthirtyfour.js.map +1 -1
  82. package/dist/__generated__/qubicicoportal.d.ts +4 -4
  83. package/dist/__generated__/qubicicoportal.d.ts.map +1 -1
  84. package/dist/__generated__/qubicicoportal.js +4 -4
  85. package/dist/__generated__/qubicicoportal.js.map +1 -1
  86. package/dist/__generated__/quottery.d.ts +1 -1
  87. package/dist/__generated__/quottery.d.ts.map +1 -1
  88. package/dist/__generated__/quottery.js +14 -14
  89. package/dist/__generated__/quottery.js.map +1 -1
  90. package/dist/__generated__/qusino.d.ts +1 -1
  91. package/dist/__generated__/qusino.d.ts.map +1 -1
  92. package/dist/__generated__/qusino.js +13 -13
  93. package/dist/__generated__/qusino.js.map +1 -1
  94. package/dist/__generated__/qutil.d.ts +1 -1
  95. package/dist/__generated__/qutil.d.ts.map +1 -1
  96. package/dist/__generated__/qutil.js +22 -22
  97. package/dist/__generated__/qutil.js.map +1 -1
  98. package/dist/__generated__/qvault.d.ts +14 -2
  99. package/dist/__generated__/qvault.d.ts.map +1 -1
  100. package/dist/__generated__/qvault.js +70 -32
  101. package/dist/__generated__/qvault.js.map +1 -1
  102. package/dist/__generated__/qx.d.ts +1 -1
  103. package/dist/__generated__/qx.d.ts.map +1 -1
  104. package/dist/__generated__/qx.js +12 -12
  105. package/dist/__generated__/qx.js.map +1 -1
  106. package/dist/__generated__/random.d.ts +24 -1
  107. package/dist/__generated__/random.d.ts.map +1 -1
  108. package/dist/__generated__/random.js +68 -0
  109. package/dist/__generated__/random.js.map +1 -1
  110. package/dist/__generated__/randomlottery.d.ts +1 -1
  111. package/dist/__generated__/randomlottery.d.ts.map +1 -1
  112. package/dist/__generated__/randomlottery.js +12 -12
  113. package/dist/__generated__/randomlottery.js.map +1 -1
  114. package/dist/__generated__/vottunbridge.d.ts +1 -1
  115. package/dist/__generated__/vottunbridge.d.ts.map +1 -1
  116. package/dist/__generated__/vottunbridge.js +13 -13
  117. package/dist/__generated__/vottunbridge.js.map +1 -1
  118. package/dist/call-contract.d.ts.map +1 -1
  119. package/dist/call-contract.js +6 -1
  120. package/dist/call-contract.js.map +1 -1
  121. package/dist/index.d.ts +2 -2
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +1 -1
  124. package/dist/index.js.map +1 -1
  125. package/package.json +7 -6
  126. package/src/__generated__/computorcontrolledfund.ts +1066 -0
  127. package/src/__generated__/escrow.ts +529 -0
  128. package/src/__generated__/generalquorumproposal.ts +691 -0
  129. package/src/__generated__/ggwp.ts +1241 -0
  130. package/src/__generated__/index.ts +28 -0
  131. package/src/__generated__/msvault.ts +1716 -0
  132. package/src/__generated__/multisignvault.ts +1511 -0
  133. package/src/__generated__/mylastmatch.ts +12 -0
  134. package/src/__generated__/nostromo.ts +1551 -0
  135. package/src/__generated__/pulse.ts +1512 -0
  136. package/src/__generated__/qbay.ts +2097 -0
  137. package/src/__generated__/qbond.ts +1016 -0
  138. package/src/__generated__/qdraw.ts +188 -0
  139. package/src/__generated__/qduel.ts +827 -0
  140. package/src/__generated__/qearn.ts +696 -0
  141. package/src/__generated__/qip.ts +501 -0
  142. package/src/__generated__/qraffle.ts +1162 -0
  143. package/src/__generated__/qreservepool.ts +281 -0
  144. package/src/__generated__/qrwa.ts +1491 -0
  145. package/src/__generated__/qswap.ts +1336 -0
  146. package/src/__generated__/qthirtyfour.ts +1131 -0
  147. package/src/__generated__/qubicicoportal.ts +386 -0
  148. package/src/__generated__/quottery.ts +1519 -0
  149. package/src/__generated__/qusino.ts +799 -0
  150. package/src/__generated__/qutil.ts +1506 -0
  151. package/src/__generated__/qvault.ts +2911 -0
  152. package/src/__generated__/qx.ts +861 -0
  153. package/src/__generated__/random.ts +145 -0
  154. package/src/__generated__/randomlottery.ts +653 -0
  155. package/src/__generated__/supplywatcher.ts +12 -0
  156. package/src/__generated__/vottunbridge.ts +1162 -0
  157. package/src/__tests__/contracts.test.ts +933 -0
  158. package/src/call-contract.ts +87 -0
  159. package/src/index.ts +9 -0
  160. package/dist/result.d.ts +0 -12
  161. package/dist/result.d.ts.map +0 -1
  162. package/dist/result.js +0 -7
  163. package/dist/result.js.map +0 -1
@@ -0,0 +1,1336 @@
1
+ // @generated — do not edit by hand. Run `bun run generate` to regenerate.
2
+ import type { BinaryField, FieldValue, NamedStruct } from '@qubic.org/registry'
3
+ import { buildPayload, decodePayload } from '@qubic.org/registry'
4
+ import type { QubicRpcError } from '@qubic.org/rpc'
5
+ import type { Result } from '@qubic.org/types'
6
+ import { type ContractCall, type ContractCallOptions, type SmartContractCaller, callContractFunction } from '../call-contract.js'
7
+
8
+ export const QSWAP_CONTRACT_INDEX = 13
9
+
10
+ export interface QswapAssetStruct {
11
+ issuer: string
12
+ assetName: bigint
13
+ }
14
+
15
+ const STRUCTS: Record<string, NamedStruct> = {
16
+ 'Asset': {
17
+ name: 'Asset',
18
+ byteLength: 40,
19
+ fields: [
20
+ {
21
+ name: 'issuer',
22
+ type: 'id',
23
+ offset: 0,
24
+ byteLength: 32,
25
+ },
26
+ {
27
+ name: 'assetName',
28
+ type: 'uint64',
29
+ offset: 32,
30
+ byteLength: 8,
31
+ },
32
+ ],
33
+ },
34
+ }
35
+
36
+ export const QSWAP_ISSUE_ASSET_INPUT_TYPE = 1
37
+
38
+ export interface QswapIssueAssetInput {
39
+ assetName: bigint
40
+ numberOfShares: bigint
41
+ unitOfMeasurement: bigint
42
+ numberOfDecimalPlaces: number
43
+ }
44
+
45
+ const QSWAP_ISSUE_ASSET_INPUT_FIELDS: BinaryField[] = [
46
+ {
47
+ name: 'assetName',
48
+ type: 'uint64',
49
+ offset: 0,
50
+ byteLength: 8,
51
+ },
52
+ {
53
+ name: 'numberOfShares',
54
+ type: 'sint64',
55
+ offset: 8,
56
+ byteLength: 8,
57
+ },
58
+ {
59
+ name: 'unitOfMeasurement',
60
+ type: 'uint64',
61
+ offset: 16,
62
+ byteLength: 8,
63
+ },
64
+ {
65
+ name: 'numberOfDecimalPlaces',
66
+ type: 'sint8',
67
+ offset: 24,
68
+ byteLength: 1,
69
+ },
70
+ ]
71
+
72
+ export function buildQswapIssueAssetInput(
73
+ input: QswapIssueAssetInput,
74
+ ): ContractCall {
75
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_ISSUE_ASSET_INPUT_TYPE, payload: buildPayload(QSWAP_ISSUE_ASSET_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, (_: string) => new Uint8Array(32)) }
76
+ }
77
+
78
+ export interface QswapIssueAssetOutput {
79
+ issuedNumberOfShares: bigint
80
+ }
81
+
82
+ const QSWAP_ISSUE_ASSET_OUTPUT_FIELDS: BinaryField[] = [
83
+ {
84
+ name: 'issuedNumberOfShares',
85
+ type: 'sint64',
86
+ offset: 0,
87
+ byteLength: 8,
88
+ },
89
+ ]
90
+
91
+ export function decodeQswapIssueAssetOutput(
92
+ data: Uint8Array,
93
+ ): QswapIssueAssetOutput {
94
+ return decodePayload(data, QSWAP_ISSUE_ASSET_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapIssueAssetOutput
95
+ }
96
+
97
+ export const QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_INPUT_TYPE = 2
98
+
99
+ export interface QswapTransferShareOwnershipAndPossessionInput {
100
+ assetIssuer: string
101
+ assetName: bigint
102
+ newOwnerAndPossessor: string
103
+ amount: bigint
104
+ }
105
+
106
+ const QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_INPUT_FIELDS: BinaryField[] = [
107
+ {
108
+ name: 'assetIssuer',
109
+ type: 'id',
110
+ offset: 0,
111
+ byteLength: 32,
112
+ },
113
+ {
114
+ name: 'assetName',
115
+ type: 'uint64',
116
+ offset: 32,
117
+ byteLength: 8,
118
+ },
119
+ {
120
+ name: 'newOwnerAndPossessor',
121
+ type: 'id',
122
+ offset: 40,
123
+ byteLength: 32,
124
+ },
125
+ {
126
+ name: 'amount',
127
+ type: 'sint64',
128
+ offset: 72,
129
+ byteLength: 8,
130
+ },
131
+ ]
132
+
133
+ export function buildQswapTransferShareOwnershipAndPossessionInput(
134
+ input: QswapTransferShareOwnershipAndPossessionInput,
135
+ identityToPublicKey: (identity: string) => Uint8Array,
136
+ ): ContractCall {
137
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_INPUT_TYPE, payload: buildPayload(QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
138
+ }
139
+
140
+ export interface QswapTransferShareOwnershipAndPossessionOutput {
141
+ transferredAmount: bigint
142
+ }
143
+
144
+ const QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_OUTPUT_FIELDS: BinaryField[] = [
145
+ {
146
+ name: 'transferredAmount',
147
+ type: 'sint64',
148
+ offset: 0,
149
+ byteLength: 8,
150
+ },
151
+ ]
152
+
153
+ export function decodeQswapTransferShareOwnershipAndPossessionOutput(
154
+ data: Uint8Array,
155
+ ): QswapTransferShareOwnershipAndPossessionOutput {
156
+ return decodePayload(data, QSWAP_TRANSFER_SHARE_OWNERSHIP_AND_POSSESSION_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapTransferShareOwnershipAndPossessionOutput
157
+ }
158
+
159
+ export const QSWAP_CREATE_POOL_INPUT_TYPE = 3
160
+
161
+ export interface QswapCreatePoolInput {
162
+ assetIssuer: string
163
+ assetName: bigint
164
+ }
165
+
166
+ const QSWAP_CREATE_POOL_INPUT_FIELDS: BinaryField[] = [
167
+ {
168
+ name: 'assetIssuer',
169
+ type: 'id',
170
+ offset: 0,
171
+ byteLength: 32,
172
+ },
173
+ {
174
+ name: 'assetName',
175
+ type: 'uint64',
176
+ offset: 32,
177
+ byteLength: 8,
178
+ },
179
+ ]
180
+
181
+ export function buildQswapCreatePoolInput(
182
+ input: QswapCreatePoolInput,
183
+ identityToPublicKey: (identity: string) => Uint8Array,
184
+ ): ContractCall {
185
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_CREATE_POOL_INPUT_TYPE, payload: buildPayload(QSWAP_CREATE_POOL_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
186
+ }
187
+
188
+ export interface QswapCreatePoolOutput {
189
+ success: number
190
+ }
191
+
192
+ const QSWAP_CREATE_POOL_OUTPUT_FIELDS: BinaryField[] = [
193
+ {
194
+ name: 'success',
195
+ type: 'uint8',
196
+ offset: 0,
197
+ byteLength: 1,
198
+ },
199
+ ]
200
+
201
+ export function decodeQswapCreatePoolOutput(
202
+ data: Uint8Array,
203
+ ): QswapCreatePoolOutput {
204
+ return decodePayload(data, QSWAP_CREATE_POOL_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapCreatePoolOutput
205
+ }
206
+
207
+ export const QSWAP_ADD_LIQUIDITY_INPUT_TYPE = 4
208
+
209
+ export interface QswapAddLiquidityInput {
210
+ assetIssuer: string
211
+ assetName: bigint
212
+ assetAmountDesired: bigint
213
+ quAmountMin: bigint
214
+ assetAmountMin: bigint
215
+ }
216
+
217
+ const QSWAP_ADD_LIQUIDITY_INPUT_FIELDS: BinaryField[] = [
218
+ {
219
+ name: 'assetIssuer',
220
+ type: 'id',
221
+ offset: 0,
222
+ byteLength: 32,
223
+ },
224
+ {
225
+ name: 'assetName',
226
+ type: 'uint64',
227
+ offset: 32,
228
+ byteLength: 8,
229
+ },
230
+ {
231
+ name: 'assetAmountDesired',
232
+ type: 'sint64',
233
+ offset: 40,
234
+ byteLength: 8,
235
+ },
236
+ {
237
+ name: 'quAmountMin',
238
+ type: 'sint64',
239
+ offset: 48,
240
+ byteLength: 8,
241
+ },
242
+ {
243
+ name: 'assetAmountMin',
244
+ type: 'sint64',
245
+ offset: 56,
246
+ byteLength: 8,
247
+ },
248
+ ]
249
+
250
+ export function buildQswapAddLiquidityInput(
251
+ input: QswapAddLiquidityInput,
252
+ identityToPublicKey: (identity: string) => Uint8Array,
253
+ ): ContractCall {
254
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_ADD_LIQUIDITY_INPUT_TYPE, payload: buildPayload(QSWAP_ADD_LIQUIDITY_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
255
+ }
256
+
257
+ export interface QswapAddLiquidityOutput {
258
+ userIncreaseLiquidity: bigint
259
+ quAmount: bigint
260
+ assetAmount: bigint
261
+ }
262
+
263
+ const QSWAP_ADD_LIQUIDITY_OUTPUT_FIELDS: BinaryField[] = [
264
+ {
265
+ name: 'userIncreaseLiquidity',
266
+ type: 'sint64',
267
+ offset: 0,
268
+ byteLength: 8,
269
+ },
270
+ {
271
+ name: 'quAmount',
272
+ type: 'sint64',
273
+ offset: 8,
274
+ byteLength: 8,
275
+ },
276
+ {
277
+ name: 'assetAmount',
278
+ type: 'sint64',
279
+ offset: 16,
280
+ byteLength: 8,
281
+ },
282
+ ]
283
+
284
+ export function decodeQswapAddLiquidityOutput(
285
+ data: Uint8Array,
286
+ ): QswapAddLiquidityOutput {
287
+ return decodePayload(data, QSWAP_ADD_LIQUIDITY_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapAddLiquidityOutput
288
+ }
289
+
290
+ export const QSWAP_REMOVE_LIQUIDITY_INPUT_TYPE = 5
291
+
292
+ export interface QswapRemoveLiquidityInput {
293
+ assetIssuer: string
294
+ assetName: bigint
295
+ burnLiquidity: bigint
296
+ quAmountMin: bigint
297
+ assetAmountMin: bigint
298
+ }
299
+
300
+ const QSWAP_REMOVE_LIQUIDITY_INPUT_FIELDS: BinaryField[] = [
301
+ {
302
+ name: 'assetIssuer',
303
+ type: 'id',
304
+ offset: 0,
305
+ byteLength: 32,
306
+ },
307
+ {
308
+ name: 'assetName',
309
+ type: 'uint64',
310
+ offset: 32,
311
+ byteLength: 8,
312
+ },
313
+ {
314
+ name: 'burnLiquidity',
315
+ type: 'sint64',
316
+ offset: 40,
317
+ byteLength: 8,
318
+ },
319
+ {
320
+ name: 'quAmountMin',
321
+ type: 'sint64',
322
+ offset: 48,
323
+ byteLength: 8,
324
+ },
325
+ {
326
+ name: 'assetAmountMin',
327
+ type: 'sint64',
328
+ offset: 56,
329
+ byteLength: 8,
330
+ },
331
+ ]
332
+
333
+ export function buildQswapRemoveLiquidityInput(
334
+ input: QswapRemoveLiquidityInput,
335
+ identityToPublicKey: (identity: string) => Uint8Array,
336
+ ): ContractCall {
337
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_REMOVE_LIQUIDITY_INPUT_TYPE, payload: buildPayload(QSWAP_REMOVE_LIQUIDITY_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
338
+ }
339
+
340
+ export interface QswapRemoveLiquidityOutput {
341
+ quAmount: bigint
342
+ assetAmount: bigint
343
+ }
344
+
345
+ const QSWAP_REMOVE_LIQUIDITY_OUTPUT_FIELDS: BinaryField[] = [
346
+ {
347
+ name: 'quAmount',
348
+ type: 'sint64',
349
+ offset: 0,
350
+ byteLength: 8,
351
+ },
352
+ {
353
+ name: 'assetAmount',
354
+ type: 'sint64',
355
+ offset: 8,
356
+ byteLength: 8,
357
+ },
358
+ ]
359
+
360
+ export function decodeQswapRemoveLiquidityOutput(
361
+ data: Uint8Array,
362
+ ): QswapRemoveLiquidityOutput {
363
+ return decodePayload(data, QSWAP_REMOVE_LIQUIDITY_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapRemoveLiquidityOutput
364
+ }
365
+
366
+ export const QSWAP_SWAP_EXACT_QU_FOR_ASSET_INPUT_TYPE = 6
367
+
368
+ export interface QswapSwapExactQuForAssetInput {
369
+ assetIssuer: string
370
+ assetName: bigint
371
+ assetAmountOutMin: bigint
372
+ }
373
+
374
+ const QSWAP_SWAP_EXACT_QU_FOR_ASSET_INPUT_FIELDS: BinaryField[] = [
375
+ {
376
+ name: 'assetIssuer',
377
+ type: 'id',
378
+ offset: 0,
379
+ byteLength: 32,
380
+ },
381
+ {
382
+ name: 'assetName',
383
+ type: 'uint64',
384
+ offset: 32,
385
+ byteLength: 8,
386
+ },
387
+ {
388
+ name: 'assetAmountOutMin',
389
+ type: 'sint64',
390
+ offset: 40,
391
+ byteLength: 8,
392
+ },
393
+ ]
394
+
395
+ export function buildQswapSwapExactQuForAssetInput(
396
+ input: QswapSwapExactQuForAssetInput,
397
+ identityToPublicKey: (identity: string) => Uint8Array,
398
+ ): ContractCall {
399
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_SWAP_EXACT_QU_FOR_ASSET_INPUT_TYPE, payload: buildPayload(QSWAP_SWAP_EXACT_QU_FOR_ASSET_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
400
+ }
401
+
402
+ export interface QswapSwapExactQuForAssetOutput {
403
+ assetAmountOut: bigint
404
+ }
405
+
406
+ const QSWAP_SWAP_EXACT_QU_FOR_ASSET_OUTPUT_FIELDS: BinaryField[] = [
407
+ {
408
+ name: 'assetAmountOut',
409
+ type: 'sint64',
410
+ offset: 0,
411
+ byteLength: 8,
412
+ },
413
+ ]
414
+
415
+ export function decodeQswapSwapExactQuForAssetOutput(
416
+ data: Uint8Array,
417
+ ): QswapSwapExactQuForAssetOutput {
418
+ return decodePayload(data, QSWAP_SWAP_EXACT_QU_FOR_ASSET_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapSwapExactQuForAssetOutput
419
+ }
420
+
421
+ export const QSWAP_SWAP_QU_FOR_EXACT_ASSET_INPUT_TYPE = 7
422
+
423
+ export interface QswapSwapQuForExactAssetInput {
424
+ assetIssuer: string
425
+ assetName: bigint
426
+ assetAmountOut: bigint
427
+ }
428
+
429
+ const QSWAP_SWAP_QU_FOR_EXACT_ASSET_INPUT_FIELDS: BinaryField[] = [
430
+ {
431
+ name: 'assetIssuer',
432
+ type: 'id',
433
+ offset: 0,
434
+ byteLength: 32,
435
+ },
436
+ {
437
+ name: 'assetName',
438
+ type: 'uint64',
439
+ offset: 32,
440
+ byteLength: 8,
441
+ },
442
+ {
443
+ name: 'assetAmountOut',
444
+ type: 'sint64',
445
+ offset: 40,
446
+ byteLength: 8,
447
+ },
448
+ ]
449
+
450
+ export function buildQswapSwapQuForExactAssetInput(
451
+ input: QswapSwapQuForExactAssetInput,
452
+ identityToPublicKey: (identity: string) => Uint8Array,
453
+ ): ContractCall {
454
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_SWAP_QU_FOR_EXACT_ASSET_INPUT_TYPE, payload: buildPayload(QSWAP_SWAP_QU_FOR_EXACT_ASSET_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
455
+ }
456
+
457
+ export interface QswapSwapQuForExactAssetOutput {
458
+ quAmountIn: bigint
459
+ }
460
+
461
+ const QSWAP_SWAP_QU_FOR_EXACT_ASSET_OUTPUT_FIELDS: BinaryField[] = [
462
+ {
463
+ name: 'quAmountIn',
464
+ type: 'sint64',
465
+ offset: 0,
466
+ byteLength: 8,
467
+ },
468
+ ]
469
+
470
+ export function decodeQswapSwapQuForExactAssetOutput(
471
+ data: Uint8Array,
472
+ ): QswapSwapQuForExactAssetOutput {
473
+ return decodePayload(data, QSWAP_SWAP_QU_FOR_EXACT_ASSET_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapSwapQuForExactAssetOutput
474
+ }
475
+
476
+ export const QSWAP_SWAP_EXACT_ASSET_FOR_QU_INPUT_TYPE = 8
477
+
478
+ export interface QswapSwapExactAssetForQuInput {
479
+ assetIssuer: string
480
+ assetName: bigint
481
+ assetAmountIn: bigint
482
+ quAmountOutMin: bigint
483
+ }
484
+
485
+ const QSWAP_SWAP_EXACT_ASSET_FOR_QU_INPUT_FIELDS: BinaryField[] = [
486
+ {
487
+ name: 'assetIssuer',
488
+ type: 'id',
489
+ offset: 0,
490
+ byteLength: 32,
491
+ },
492
+ {
493
+ name: 'assetName',
494
+ type: 'uint64',
495
+ offset: 32,
496
+ byteLength: 8,
497
+ },
498
+ {
499
+ name: 'assetAmountIn',
500
+ type: 'sint64',
501
+ offset: 40,
502
+ byteLength: 8,
503
+ },
504
+ {
505
+ name: 'quAmountOutMin',
506
+ type: 'sint64',
507
+ offset: 48,
508
+ byteLength: 8,
509
+ },
510
+ ]
511
+
512
+ export function buildQswapSwapExactAssetForQuInput(
513
+ input: QswapSwapExactAssetForQuInput,
514
+ identityToPublicKey: (identity: string) => Uint8Array,
515
+ ): ContractCall {
516
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_SWAP_EXACT_ASSET_FOR_QU_INPUT_TYPE, payload: buildPayload(QSWAP_SWAP_EXACT_ASSET_FOR_QU_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
517
+ }
518
+
519
+ export interface QswapSwapExactAssetForQuOutput {
520
+ quAmountOut: bigint
521
+ }
522
+
523
+ const QSWAP_SWAP_EXACT_ASSET_FOR_QU_OUTPUT_FIELDS: BinaryField[] = [
524
+ {
525
+ name: 'quAmountOut',
526
+ type: 'sint64',
527
+ offset: 0,
528
+ byteLength: 8,
529
+ },
530
+ ]
531
+
532
+ export function decodeQswapSwapExactAssetForQuOutput(
533
+ data: Uint8Array,
534
+ ): QswapSwapExactAssetForQuOutput {
535
+ return decodePayload(data, QSWAP_SWAP_EXACT_ASSET_FOR_QU_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapSwapExactAssetForQuOutput
536
+ }
537
+
538
+ export const QSWAP_SWAP_ASSET_FOR_EXACT_QU_INPUT_TYPE = 9
539
+
540
+ export interface QswapSwapAssetForExactQuInput {
541
+ assetIssuer: string
542
+ assetName: bigint
543
+ assetAmountInMax: bigint
544
+ quAmountOut: bigint
545
+ }
546
+
547
+ const QSWAP_SWAP_ASSET_FOR_EXACT_QU_INPUT_FIELDS: BinaryField[] = [
548
+ {
549
+ name: 'assetIssuer',
550
+ type: 'id',
551
+ offset: 0,
552
+ byteLength: 32,
553
+ },
554
+ {
555
+ name: 'assetName',
556
+ type: 'uint64',
557
+ offset: 32,
558
+ byteLength: 8,
559
+ },
560
+ {
561
+ name: 'assetAmountInMax',
562
+ type: 'sint64',
563
+ offset: 40,
564
+ byteLength: 8,
565
+ },
566
+ {
567
+ name: 'quAmountOut',
568
+ type: 'sint64',
569
+ offset: 48,
570
+ byteLength: 8,
571
+ },
572
+ ]
573
+
574
+ export function buildQswapSwapAssetForExactQuInput(
575
+ input: QswapSwapAssetForExactQuInput,
576
+ identityToPublicKey: (identity: string) => Uint8Array,
577
+ ): ContractCall {
578
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_SWAP_ASSET_FOR_EXACT_QU_INPUT_TYPE, payload: buildPayload(QSWAP_SWAP_ASSET_FOR_EXACT_QU_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
579
+ }
580
+
581
+ export interface QswapSwapAssetForExactQuOutput {
582
+ assetAmountIn: bigint
583
+ }
584
+
585
+ const QSWAP_SWAP_ASSET_FOR_EXACT_QU_OUTPUT_FIELDS: BinaryField[] = [
586
+ {
587
+ name: 'assetAmountIn',
588
+ type: 'sint64',
589
+ offset: 0,
590
+ byteLength: 8,
591
+ },
592
+ ]
593
+
594
+ export function decodeQswapSwapAssetForExactQuOutput(
595
+ data: Uint8Array,
596
+ ): QswapSwapAssetForExactQuOutput {
597
+ return decodePayload(data, QSWAP_SWAP_ASSET_FOR_EXACT_QU_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapSwapAssetForExactQuOutput
598
+ }
599
+
600
+ export const QSWAP_SET_INVEST_REWARDS_INFO_INPUT_TYPE = 10
601
+
602
+ export interface QswapSetInvestRewardsInfoInput {
603
+ newInvestRewardsId: string
604
+ }
605
+
606
+ const QSWAP_SET_INVEST_REWARDS_INFO_INPUT_FIELDS: BinaryField[] = [
607
+ {
608
+ name: 'newInvestRewardsId',
609
+ type: 'id',
610
+ offset: 0,
611
+ byteLength: 32,
612
+ },
613
+ ]
614
+
615
+ export function buildQswapSetInvestRewardsInfoInput(
616
+ input: QswapSetInvestRewardsInfoInput,
617
+ identityToPublicKey: (identity: string) => Uint8Array,
618
+ ): ContractCall {
619
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_SET_INVEST_REWARDS_INFO_INPUT_TYPE, payload: buildPayload(QSWAP_SET_INVEST_REWARDS_INFO_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey) }
620
+ }
621
+
622
+ export interface QswapSetInvestRewardsInfoOutput {
623
+ success: number
624
+ }
625
+
626
+ const QSWAP_SET_INVEST_REWARDS_INFO_OUTPUT_FIELDS: BinaryField[] = [
627
+ {
628
+ name: 'success',
629
+ type: 'uint8',
630
+ offset: 0,
631
+ byteLength: 1,
632
+ },
633
+ ]
634
+
635
+ export function decodeQswapSetInvestRewardsInfoOutput(
636
+ data: Uint8Array,
637
+ ): QswapSetInvestRewardsInfoOutput {
638
+ return decodePayload(data, QSWAP_SET_INVEST_REWARDS_INFO_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapSetInvestRewardsInfoOutput
639
+ }
640
+
641
+ export const QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_INPUT_TYPE = 11
642
+
643
+ export interface QswapTransferShareManagementRightsInput {
644
+ asset: QswapAssetStruct
645
+ numberOfShares: bigint
646
+ newManagingContractIndex: number
647
+ }
648
+
649
+ const QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_INPUT_FIELDS: BinaryField[] = [
650
+ {
651
+ name: 'asset',
652
+ type: 'struct',
653
+ offset: 0,
654
+ byteLength: 40,
655
+ structRef: 'Asset',
656
+ },
657
+ {
658
+ name: 'numberOfShares',
659
+ type: 'sint64',
660
+ offset: 40,
661
+ byteLength: 8,
662
+ },
663
+ {
664
+ name: 'newManagingContractIndex',
665
+ type: 'uint32',
666
+ offset: 48,
667
+ byteLength: 4,
668
+ },
669
+ ]
670
+
671
+ export function buildQswapTransferShareManagementRightsInput(
672
+ input: QswapTransferShareManagementRightsInput,
673
+ ): ContractCall {
674
+ return { contractIndex: QSWAP_CONTRACT_INDEX, inputType: QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_INPUT_TYPE, payload: buildPayload(QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, (_: string) => new Uint8Array(32)) }
675
+ }
676
+
677
+ export interface QswapTransferShareManagementRightsOutput {
678
+ transferredNumberOfShares: bigint
679
+ }
680
+
681
+ const QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_OUTPUT_FIELDS: BinaryField[] = [
682
+ {
683
+ name: 'transferredNumberOfShares',
684
+ type: 'sint64',
685
+ offset: 0,
686
+ byteLength: 8,
687
+ },
688
+ ]
689
+
690
+ export function decodeQswapTransferShareManagementRightsOutput(
691
+ data: Uint8Array,
692
+ ): QswapTransferShareManagementRightsOutput {
693
+ return decodePayload(data, QSWAP_TRANSFER_SHARE_MANAGEMENT_RIGHTS_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapTransferShareManagementRightsOutput
694
+ }
695
+
696
+ export const QSWAP_FEES_INPUT_TYPE = 1
697
+ export const QSWAP_FEES_INPUT_SIZE = 0
698
+
699
+ export interface QswapFeesOutput {
700
+ assetIssuanceFee: number
701
+ poolCreationFee: number
702
+ transferFee: number
703
+ swapFee: number
704
+ shareholderFee: number
705
+ investRewardsFee: number
706
+ qxFee: number
707
+ burnFee: number
708
+ }
709
+
710
+ const QSWAP_FEES_OUTPUT_FIELDS: BinaryField[] = [
711
+ {
712
+ name: 'assetIssuanceFee',
713
+ type: 'uint32',
714
+ offset: 0,
715
+ byteLength: 4,
716
+ },
717
+ {
718
+ name: 'poolCreationFee',
719
+ type: 'uint32',
720
+ offset: 4,
721
+ byteLength: 4,
722
+ },
723
+ {
724
+ name: 'transferFee',
725
+ type: 'uint32',
726
+ offset: 8,
727
+ byteLength: 4,
728
+ },
729
+ {
730
+ name: 'swapFee',
731
+ type: 'uint32',
732
+ offset: 12,
733
+ byteLength: 4,
734
+ },
735
+ {
736
+ name: 'shareholderFee',
737
+ type: 'uint32',
738
+ offset: 16,
739
+ byteLength: 4,
740
+ },
741
+ {
742
+ name: 'investRewardsFee',
743
+ type: 'uint32',
744
+ offset: 20,
745
+ byteLength: 4,
746
+ },
747
+ {
748
+ name: 'qxFee',
749
+ type: 'uint32',
750
+ offset: 24,
751
+ byteLength: 4,
752
+ },
753
+ {
754
+ name: 'burnFee',
755
+ type: 'uint32',
756
+ offset: 28,
757
+ byteLength: 4,
758
+ },
759
+ ]
760
+
761
+ export function decodeQswapFeesOutput(
762
+ data: Uint8Array,
763
+ ): QswapFeesOutput {
764
+ return decodePayload(data, QSWAP_FEES_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapFeesOutput
765
+ }
766
+
767
+ export async function qswapFees(
768
+ live: SmartContractCaller,
769
+ options?: ContractCallOptions,
770
+ ): Promise<Result<QswapFeesOutput, QubicRpcError>> {
771
+ return callContractFunction({
772
+ live,
773
+ contractIndex: QSWAP_CONTRACT_INDEX,
774
+ inputType: QSWAP_FEES_INPUT_TYPE,
775
+ inputSize: QSWAP_FEES_INPUT_SIZE,
776
+ inputFields: [],
777
+ outputFields: QSWAP_FEES_OUTPUT_FIELDS,
778
+ structs: STRUCTS,
779
+ input: {},
780
+ ...options,
781
+ })
782
+ }
783
+
784
+ export const QSWAP_GET_POOL_BASIC_STATE_INPUT_TYPE = 2
785
+ export const QSWAP_GET_POOL_BASIC_STATE_INPUT_SIZE = 40
786
+
787
+ export interface QswapGetPoolBasicStateInput {
788
+ assetIssuer: string
789
+ assetName: bigint
790
+ }
791
+
792
+ const QSWAP_GET_POOL_BASIC_STATE_INPUT_FIELDS: BinaryField[] = [
793
+ {
794
+ name: 'assetIssuer',
795
+ type: 'id',
796
+ offset: 0,
797
+ byteLength: 32,
798
+ },
799
+ {
800
+ name: 'assetName',
801
+ type: 'uint64',
802
+ offset: 32,
803
+ byteLength: 8,
804
+ },
805
+ ]
806
+
807
+ export function buildQswapGetPoolBasicStateInput(
808
+ input: QswapGetPoolBasicStateInput,
809
+ identityToPublicKey: (identity: string) => Uint8Array,
810
+ ): Uint8Array {
811
+ return buildPayload(QSWAP_GET_POOL_BASIC_STATE_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
812
+ }
813
+
814
+ export interface QswapGetPoolBasicStateOutput {
815
+ poolExists: bigint
816
+ reservedQuAmount: bigint
817
+ reservedAssetAmount: bigint
818
+ totalLiquidity: bigint
819
+ accFeePerLP: bigint
820
+ }
821
+
822
+ const QSWAP_GET_POOL_BASIC_STATE_OUTPUT_FIELDS: BinaryField[] = [
823
+ {
824
+ name: 'poolExists',
825
+ type: 'sint64',
826
+ offset: 0,
827
+ byteLength: 8,
828
+ },
829
+ {
830
+ name: 'reservedQuAmount',
831
+ type: 'sint64',
832
+ offset: 8,
833
+ byteLength: 8,
834
+ },
835
+ {
836
+ name: 'reservedAssetAmount',
837
+ type: 'sint64',
838
+ offset: 16,
839
+ byteLength: 8,
840
+ },
841
+ {
842
+ name: 'totalLiquidity',
843
+ type: 'sint64',
844
+ offset: 24,
845
+ byteLength: 8,
846
+ },
847
+ {
848
+ name: 'accFeePerLP',
849
+ type: 'uint64',
850
+ offset: 32,
851
+ byteLength: 8,
852
+ },
853
+ ]
854
+
855
+ export function decodeQswapGetPoolBasicStateOutput(
856
+ data: Uint8Array,
857
+ ): QswapGetPoolBasicStateOutput {
858
+ return decodePayload(data, QSWAP_GET_POOL_BASIC_STATE_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapGetPoolBasicStateOutput
859
+ }
860
+
861
+ export async function qswapGetPoolBasicState(
862
+ live: SmartContractCaller,
863
+ input: QswapGetPoolBasicStateInput,
864
+ options?: ContractCallOptions,
865
+ ): Promise<Result<QswapGetPoolBasicStateOutput, QubicRpcError>> {
866
+ return callContractFunction({
867
+ live,
868
+ contractIndex: QSWAP_CONTRACT_INDEX,
869
+ inputType: QSWAP_GET_POOL_BASIC_STATE_INPUT_TYPE,
870
+ inputSize: QSWAP_GET_POOL_BASIC_STATE_INPUT_SIZE,
871
+ inputFields: QSWAP_GET_POOL_BASIC_STATE_INPUT_FIELDS,
872
+ outputFields: QSWAP_GET_POOL_BASIC_STATE_OUTPUT_FIELDS,
873
+ structs: STRUCTS,
874
+ input: (input as unknown as Record<string, unknown>),
875
+ ...options,
876
+ })
877
+ }
878
+
879
+ export const QSWAP_GET_LIQUIDITY_OF_INPUT_TYPE = 3
880
+ export const QSWAP_GET_LIQUIDITY_OF_INPUT_SIZE = 72
881
+
882
+ export interface QswapGetLiquidityOfInput {
883
+ assetIssuer: string
884
+ assetName: bigint
885
+ account: string
886
+ }
887
+
888
+ const QSWAP_GET_LIQUIDITY_OF_INPUT_FIELDS: BinaryField[] = [
889
+ {
890
+ name: 'assetIssuer',
891
+ type: 'id',
892
+ offset: 0,
893
+ byteLength: 32,
894
+ },
895
+ {
896
+ name: 'assetName',
897
+ type: 'uint64',
898
+ offset: 32,
899
+ byteLength: 8,
900
+ },
901
+ {
902
+ name: 'account',
903
+ type: 'id',
904
+ offset: 40,
905
+ byteLength: 32,
906
+ },
907
+ ]
908
+
909
+ export function buildQswapGetLiquidityOfInput(
910
+ input: QswapGetLiquidityOfInput,
911
+ identityToPublicKey: (identity: string) => Uint8Array,
912
+ ): Uint8Array {
913
+ return buildPayload(QSWAP_GET_LIQUIDITY_OF_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
914
+ }
915
+
916
+ export interface QswapGetLiquidityOfOutput {
917
+ liquidity: bigint
918
+ earnedFees: bigint
919
+ }
920
+
921
+ const QSWAP_GET_LIQUIDITY_OF_OUTPUT_FIELDS: BinaryField[] = [
922
+ {
923
+ name: 'liquidity',
924
+ type: 'sint64',
925
+ offset: 0,
926
+ byteLength: 8,
927
+ },
928
+ {
929
+ name: 'earnedFees',
930
+ type: 'uint64',
931
+ offset: 8,
932
+ byteLength: 8,
933
+ },
934
+ ]
935
+
936
+ export function decodeQswapGetLiquidityOfOutput(
937
+ data: Uint8Array,
938
+ ): QswapGetLiquidityOfOutput {
939
+ return decodePayload(data, QSWAP_GET_LIQUIDITY_OF_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapGetLiquidityOfOutput
940
+ }
941
+
942
+ export async function qswapGetLiquidityOf(
943
+ live: SmartContractCaller,
944
+ input: QswapGetLiquidityOfInput,
945
+ options?: ContractCallOptions,
946
+ ): Promise<Result<QswapGetLiquidityOfOutput, QubicRpcError>> {
947
+ return callContractFunction({
948
+ live,
949
+ contractIndex: QSWAP_CONTRACT_INDEX,
950
+ inputType: QSWAP_GET_LIQUIDITY_OF_INPUT_TYPE,
951
+ inputSize: QSWAP_GET_LIQUIDITY_OF_INPUT_SIZE,
952
+ inputFields: QSWAP_GET_LIQUIDITY_OF_INPUT_FIELDS,
953
+ outputFields: QSWAP_GET_LIQUIDITY_OF_OUTPUT_FIELDS,
954
+ structs: STRUCTS,
955
+ input: (input as unknown as Record<string, unknown>),
956
+ ...options,
957
+ })
958
+ }
959
+
960
+ export const QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_TYPE = 4
961
+ export const QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_SIZE = 48
962
+
963
+ export interface QswapQuoteExactQuInputInput {
964
+ assetIssuer: string
965
+ assetName: bigint
966
+ quAmountIn: bigint
967
+ }
968
+
969
+ const QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_FIELDS: BinaryField[] = [
970
+ {
971
+ name: 'assetIssuer',
972
+ type: 'id',
973
+ offset: 0,
974
+ byteLength: 32,
975
+ },
976
+ {
977
+ name: 'assetName',
978
+ type: 'uint64',
979
+ offset: 32,
980
+ byteLength: 8,
981
+ },
982
+ {
983
+ name: 'quAmountIn',
984
+ type: 'sint64',
985
+ offset: 40,
986
+ byteLength: 8,
987
+ },
988
+ ]
989
+
990
+ export function buildQswapQuoteExactQuInputInput(
991
+ input: QswapQuoteExactQuInputInput,
992
+ identityToPublicKey: (identity: string) => Uint8Array,
993
+ ): Uint8Array {
994
+ return buildPayload(QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
995
+ }
996
+
997
+ export interface QswapQuoteExactQuInputOutput {
998
+ assetAmountOut: bigint
999
+ }
1000
+
1001
+ const QSWAP_QUOTE_EXACT_QU_INPUT_OUTPUT_FIELDS: BinaryField[] = [
1002
+ {
1003
+ name: 'assetAmountOut',
1004
+ type: 'sint64',
1005
+ offset: 0,
1006
+ byteLength: 8,
1007
+ },
1008
+ ]
1009
+
1010
+ export function decodeQswapQuoteExactQuInputOutput(
1011
+ data: Uint8Array,
1012
+ ): QswapQuoteExactQuInputOutput {
1013
+ return decodePayload(data, QSWAP_QUOTE_EXACT_QU_INPUT_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapQuoteExactQuInputOutput
1014
+ }
1015
+
1016
+ export async function qswapQuoteExactQuInput(
1017
+ live: SmartContractCaller,
1018
+ input: QswapQuoteExactQuInputInput,
1019
+ options?: ContractCallOptions,
1020
+ ): Promise<Result<QswapQuoteExactQuInputOutput, QubicRpcError>> {
1021
+ return callContractFunction({
1022
+ live,
1023
+ contractIndex: QSWAP_CONTRACT_INDEX,
1024
+ inputType: QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_TYPE,
1025
+ inputSize: QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_SIZE,
1026
+ inputFields: QSWAP_QUOTE_EXACT_QU_INPUT_INPUT_FIELDS,
1027
+ outputFields: QSWAP_QUOTE_EXACT_QU_INPUT_OUTPUT_FIELDS,
1028
+ structs: STRUCTS,
1029
+ input: (input as unknown as Record<string, unknown>),
1030
+ ...options,
1031
+ })
1032
+ }
1033
+
1034
+ export const QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_TYPE = 5
1035
+ export const QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_SIZE = 48
1036
+
1037
+ export interface QswapQuoteExactQuOutputInput {
1038
+ assetIssuer: string
1039
+ assetName: bigint
1040
+ quAmountOut: bigint
1041
+ }
1042
+
1043
+ const QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_FIELDS: BinaryField[] = [
1044
+ {
1045
+ name: 'assetIssuer',
1046
+ type: 'id',
1047
+ offset: 0,
1048
+ byteLength: 32,
1049
+ },
1050
+ {
1051
+ name: 'assetName',
1052
+ type: 'uint64',
1053
+ offset: 32,
1054
+ byteLength: 8,
1055
+ },
1056
+ {
1057
+ name: 'quAmountOut',
1058
+ type: 'sint64',
1059
+ offset: 40,
1060
+ byteLength: 8,
1061
+ },
1062
+ ]
1063
+
1064
+ export function buildQswapQuoteExactQuOutputInput(
1065
+ input: QswapQuoteExactQuOutputInput,
1066
+ identityToPublicKey: (identity: string) => Uint8Array,
1067
+ ): Uint8Array {
1068
+ return buildPayload(QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
1069
+ }
1070
+
1071
+ export interface QswapQuoteExactQuOutputOutput {
1072
+ assetAmountIn: bigint
1073
+ }
1074
+
1075
+ const QSWAP_QUOTE_EXACT_QU_OUTPUT_OUTPUT_FIELDS: BinaryField[] = [
1076
+ {
1077
+ name: 'assetAmountIn',
1078
+ type: 'sint64',
1079
+ offset: 0,
1080
+ byteLength: 8,
1081
+ },
1082
+ ]
1083
+
1084
+ export function decodeQswapQuoteExactQuOutputOutput(
1085
+ data: Uint8Array,
1086
+ ): QswapQuoteExactQuOutputOutput {
1087
+ return decodePayload(data, QSWAP_QUOTE_EXACT_QU_OUTPUT_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapQuoteExactQuOutputOutput
1088
+ }
1089
+
1090
+ export async function qswapQuoteExactQuOutput(
1091
+ live: SmartContractCaller,
1092
+ input: QswapQuoteExactQuOutputInput,
1093
+ options?: ContractCallOptions,
1094
+ ): Promise<Result<QswapQuoteExactQuOutputOutput, QubicRpcError>> {
1095
+ return callContractFunction({
1096
+ live,
1097
+ contractIndex: QSWAP_CONTRACT_INDEX,
1098
+ inputType: QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_TYPE,
1099
+ inputSize: QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_SIZE,
1100
+ inputFields: QSWAP_QUOTE_EXACT_QU_OUTPUT_INPUT_FIELDS,
1101
+ outputFields: QSWAP_QUOTE_EXACT_QU_OUTPUT_OUTPUT_FIELDS,
1102
+ structs: STRUCTS,
1103
+ input: (input as unknown as Record<string, unknown>),
1104
+ ...options,
1105
+ })
1106
+ }
1107
+
1108
+ export const QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_TYPE = 6
1109
+ export const QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_SIZE = 48
1110
+
1111
+ export interface QswapQuoteExactAssetInputInput {
1112
+ assetIssuer: string
1113
+ assetName: bigint
1114
+ assetAmountIn: bigint
1115
+ }
1116
+
1117
+ const QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_FIELDS: BinaryField[] = [
1118
+ {
1119
+ name: 'assetIssuer',
1120
+ type: 'id',
1121
+ offset: 0,
1122
+ byteLength: 32,
1123
+ },
1124
+ {
1125
+ name: 'assetName',
1126
+ type: 'uint64',
1127
+ offset: 32,
1128
+ byteLength: 8,
1129
+ },
1130
+ {
1131
+ name: 'assetAmountIn',
1132
+ type: 'sint64',
1133
+ offset: 40,
1134
+ byteLength: 8,
1135
+ },
1136
+ ]
1137
+
1138
+ export function buildQswapQuoteExactAssetInputInput(
1139
+ input: QswapQuoteExactAssetInputInput,
1140
+ identityToPublicKey: (identity: string) => Uint8Array,
1141
+ ): Uint8Array {
1142
+ return buildPayload(QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
1143
+ }
1144
+
1145
+ export interface QswapQuoteExactAssetInputOutput {
1146
+ quAmountOut: bigint
1147
+ }
1148
+
1149
+ const QSWAP_QUOTE_EXACT_ASSET_INPUT_OUTPUT_FIELDS: BinaryField[] = [
1150
+ {
1151
+ name: 'quAmountOut',
1152
+ type: 'sint64',
1153
+ offset: 0,
1154
+ byteLength: 8,
1155
+ },
1156
+ ]
1157
+
1158
+ export function decodeQswapQuoteExactAssetInputOutput(
1159
+ data: Uint8Array,
1160
+ ): QswapQuoteExactAssetInputOutput {
1161
+ return decodePayload(data, QSWAP_QUOTE_EXACT_ASSET_INPUT_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapQuoteExactAssetInputOutput
1162
+ }
1163
+
1164
+ export async function qswapQuoteExactAssetInput(
1165
+ live: SmartContractCaller,
1166
+ input: QswapQuoteExactAssetInputInput,
1167
+ options?: ContractCallOptions,
1168
+ ): Promise<Result<QswapQuoteExactAssetInputOutput, QubicRpcError>> {
1169
+ return callContractFunction({
1170
+ live,
1171
+ contractIndex: QSWAP_CONTRACT_INDEX,
1172
+ inputType: QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_TYPE,
1173
+ inputSize: QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_SIZE,
1174
+ inputFields: QSWAP_QUOTE_EXACT_ASSET_INPUT_INPUT_FIELDS,
1175
+ outputFields: QSWAP_QUOTE_EXACT_ASSET_INPUT_OUTPUT_FIELDS,
1176
+ structs: STRUCTS,
1177
+ input: (input as unknown as Record<string, unknown>),
1178
+ ...options,
1179
+ })
1180
+ }
1181
+
1182
+ export const QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_TYPE = 7
1183
+ export const QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_SIZE = 48
1184
+
1185
+ export interface QswapQuoteExactAssetOutputInput {
1186
+ assetIssuer: string
1187
+ assetName: bigint
1188
+ assetAmountOut: bigint
1189
+ }
1190
+
1191
+ const QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_FIELDS: BinaryField[] = [
1192
+ {
1193
+ name: 'assetIssuer',
1194
+ type: 'id',
1195
+ offset: 0,
1196
+ byteLength: 32,
1197
+ },
1198
+ {
1199
+ name: 'assetName',
1200
+ type: 'uint64',
1201
+ offset: 32,
1202
+ byteLength: 8,
1203
+ },
1204
+ {
1205
+ name: 'assetAmountOut',
1206
+ type: 'sint64',
1207
+ offset: 40,
1208
+ byteLength: 8,
1209
+ },
1210
+ ]
1211
+
1212
+ export function buildQswapQuoteExactAssetOutputInput(
1213
+ input: QswapQuoteExactAssetOutputInput,
1214
+ identityToPublicKey: (identity: string) => Uint8Array,
1215
+ ): Uint8Array {
1216
+ return buildPayload(QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_FIELDS, STRUCTS, input as unknown as Record<string, FieldValue | Uint8Array>, identityToPublicKey)
1217
+ }
1218
+
1219
+ export interface QswapQuoteExactAssetOutputOutput {
1220
+ quAmountIn: bigint
1221
+ }
1222
+
1223
+ const QSWAP_QUOTE_EXACT_ASSET_OUTPUT_OUTPUT_FIELDS: BinaryField[] = [
1224
+ {
1225
+ name: 'quAmountIn',
1226
+ type: 'sint64',
1227
+ offset: 0,
1228
+ byteLength: 8,
1229
+ },
1230
+ ]
1231
+
1232
+ export function decodeQswapQuoteExactAssetOutputOutput(
1233
+ data: Uint8Array,
1234
+ ): QswapQuoteExactAssetOutputOutput {
1235
+ return decodePayload(data, QSWAP_QUOTE_EXACT_ASSET_OUTPUT_OUTPUT_FIELDS, STRUCTS, (_: Uint8Array) => { throw new Error('unreachable') }) as unknown as QswapQuoteExactAssetOutputOutput
1236
+ }
1237
+
1238
+ export async function qswapQuoteExactAssetOutput(
1239
+ live: SmartContractCaller,
1240
+ input: QswapQuoteExactAssetOutputInput,
1241
+ options?: ContractCallOptions,
1242
+ ): Promise<Result<QswapQuoteExactAssetOutputOutput, QubicRpcError>> {
1243
+ return callContractFunction({
1244
+ live,
1245
+ contractIndex: QSWAP_CONTRACT_INDEX,
1246
+ inputType: QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_TYPE,
1247
+ inputSize: QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_SIZE,
1248
+ inputFields: QSWAP_QUOTE_EXACT_ASSET_OUTPUT_INPUT_FIELDS,
1249
+ outputFields: QSWAP_QUOTE_EXACT_ASSET_OUTPUT_OUTPUT_FIELDS,
1250
+ structs: STRUCTS,
1251
+ input: (input as unknown as Record<string, unknown>),
1252
+ ...options,
1253
+ })
1254
+ }
1255
+
1256
+ export const QSWAP_INVEST_REWARDS_INFO_INPUT_TYPE = 8
1257
+ export const QSWAP_INVEST_REWARDS_INFO_INPUT_SIZE = 0
1258
+
1259
+ export interface QswapInvestRewardsInfoOutput {
1260
+ investRewardsFee: number
1261
+ investRewardsId: string
1262
+ }
1263
+
1264
+ const QSWAP_INVEST_REWARDS_INFO_OUTPUT_FIELDS: BinaryField[] = [
1265
+ {
1266
+ name: 'investRewardsFee',
1267
+ type: 'uint32',
1268
+ offset: 0,
1269
+ byteLength: 4,
1270
+ },
1271
+ {
1272
+ name: 'investRewardsId',
1273
+ type: 'id',
1274
+ offset: 4,
1275
+ byteLength: 32,
1276
+ },
1277
+ ]
1278
+
1279
+ export function decodeQswapInvestRewardsInfoOutput(
1280
+ data: Uint8Array,
1281
+ publicKeyToIdentity: (pk: Uint8Array) => string,
1282
+ ): QswapInvestRewardsInfoOutput {
1283
+ return decodePayload(data, QSWAP_INVEST_REWARDS_INFO_OUTPUT_FIELDS, STRUCTS, publicKeyToIdentity) as unknown as QswapInvestRewardsInfoOutput
1284
+ }
1285
+
1286
+ export async function qswapInvestRewardsInfo(
1287
+ live: SmartContractCaller,
1288
+ options?: ContractCallOptions,
1289
+ ): Promise<Result<QswapInvestRewardsInfoOutput, QubicRpcError>> {
1290
+ return callContractFunction({
1291
+ live,
1292
+ contractIndex: QSWAP_CONTRACT_INDEX,
1293
+ inputType: QSWAP_INVEST_REWARDS_INFO_INPUT_TYPE,
1294
+ inputSize: QSWAP_INVEST_REWARDS_INFO_INPUT_SIZE,
1295
+ inputFields: [],
1296
+ outputFields: QSWAP_INVEST_REWARDS_INFO_OUTPUT_FIELDS,
1297
+ structs: STRUCTS,
1298
+ input: {},
1299
+ ...options,
1300
+ })
1301
+ }
1302
+
1303
+ export const qswap = {
1304
+ contractIndex: QSWAP_CONTRACT_INDEX,
1305
+ Fees: qswapFees,
1306
+ GetPoolBasicState: qswapGetPoolBasicState,
1307
+ GetLiquidityOf: qswapGetLiquidityOf,
1308
+ QuoteExactQuInput: qswapQuoteExactQuInput,
1309
+ QuoteExactQuOutput: qswapQuoteExactQuOutput,
1310
+ QuoteExactAssetInput: qswapQuoteExactAssetInput,
1311
+ QuoteExactAssetOutput: qswapQuoteExactAssetOutput,
1312
+ InvestRewardsInfo: qswapInvestRewardsInfo,
1313
+ buildIssueAssetInput: buildQswapIssueAssetInput,
1314
+ decodeIssueAssetOutput: decodeQswapIssueAssetOutput,
1315
+ buildTransferShareOwnershipAndPossessionInput: buildQswapTransferShareOwnershipAndPossessionInput,
1316
+ decodeTransferShareOwnershipAndPossessionOutput: decodeQswapTransferShareOwnershipAndPossessionOutput,
1317
+ buildCreatePoolInput: buildQswapCreatePoolInput,
1318
+ decodeCreatePoolOutput: decodeQswapCreatePoolOutput,
1319
+ buildAddLiquidityInput: buildQswapAddLiquidityInput,
1320
+ decodeAddLiquidityOutput: decodeQswapAddLiquidityOutput,
1321
+ buildRemoveLiquidityInput: buildQswapRemoveLiquidityInput,
1322
+ decodeRemoveLiquidityOutput: decodeQswapRemoveLiquidityOutput,
1323
+ buildSwapExactQuForAssetInput: buildQswapSwapExactQuForAssetInput,
1324
+ decodeSwapExactQuForAssetOutput: decodeQswapSwapExactQuForAssetOutput,
1325
+ buildSwapQuForExactAssetInput: buildQswapSwapQuForExactAssetInput,
1326
+ decodeSwapQuForExactAssetOutput: decodeQswapSwapQuForExactAssetOutput,
1327
+ buildSwapExactAssetForQuInput: buildQswapSwapExactAssetForQuInput,
1328
+ decodeSwapExactAssetForQuOutput: decodeQswapSwapExactAssetForQuOutput,
1329
+ buildSwapAssetForExactQuInput: buildQswapSwapAssetForExactQuInput,
1330
+ decodeSwapAssetForExactQuOutput: decodeQswapSwapAssetForExactQuOutput,
1331
+ buildSetInvestRewardsInfoInput: buildQswapSetInvestRewardsInfoInput,
1332
+ decodeSetInvestRewardsInfoOutput: decodeQswapSetInvestRewardsInfoOutput,
1333
+ buildTransferShareManagementRightsInput: buildQswapTransferShareManagementRightsInput,
1334
+ decodeTransferShareManagementRightsOutput: decodeQswapTransferShareManagementRightsOutput,
1335
+ }
1336
+