@zuhaibnoor/zigchain-sdk 1.1.0 → 1.1.1

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 (42) hide show
  1. package/README.md +1 -1
  2. package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
  3. package/dist/circuit/ChainCircuitApi.js.map +1 -1
  4. package/dist/dex/ChainDexApi.d.ts.map +1 -1
  5. package/dist/dex/ChainDexApi.js.map +1 -1
  6. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
  7. package/dist/distribution/ChainDistributionApi.js +0 -1
  8. package/dist/distribution/ChainDistributionApi.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/staking/ChainStakingApi.d.ts +1 -5
  14. package/dist/staking/ChainStakingApi.d.ts.map +1 -1
  15. package/dist/staking/ChainStakingApi.js +9 -7
  16. package/dist/staking/ChainStakingApi.js.map +1 -1
  17. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
  18. package/dist/validator-set/ChainValidator.d.ts +8 -0
  19. package/dist/validator-set/ChainValidator.d.ts.map +1 -0
  20. package/dist/validator-set/ChainValidator.js +15 -0
  21. package/dist/validator-set/ChainValidator.js.map +1 -0
  22. package/docs/block.md +325 -38
  23. package/docs/circuit.md +164 -35
  24. package/docs/dex.md +313 -63
  25. package/docs/distribution.md +664 -93
  26. package/docs/evidence.md +117 -122
  27. package/docs/factory.md +308 -62
  28. package/docs/gov.md +268 -70
  29. package/docs/ibc/ibcChannel.md +736 -249
  30. package/docs/ibc/ibcClient.md +608 -139
  31. package/docs/ibc-transfer.md +349 -90
  32. package/docs/interchain-accounts.md +151 -48
  33. package/docs/mint.md +173 -36
  34. package/docs/runtime.md +81 -42
  35. package/docs/slashing.md +209 -61
  36. package/docs/staking.md +534 -411
  37. package/docs/tokenwrapper.md +221 -64
  38. package/docs/txs.md +447 -0
  39. package/docs/upgrade.md +281 -58
  40. package/docs/validator-set.md +177 -0
  41. package/package.json +1 -1
  42. package/docs/comet-validator-set.md +0 -70
package/docs/dex.md CHANGED
@@ -1,7 +1,85 @@
1
- # Decentralized Exchange (DEX) Module
1
+ # DEX Module
2
2
 
3
- The **ChainDexApi** allows you to interact with the chain’s decentralized exchange (DEX).
4
- It is used to fetch information about liquidity pools, pool balances, pool IDs for token pairs, and DEX parameters.
3
+ ## What is the DEX Module?
4
+
5
+ The **DEX module** is a ZigChain-native decentralized exchange built directly into the chain.
6
+
7
+ ---
8
+
9
+ ## Important Terminology
10
+
11
+ ### Pool
12
+
13
+ A **pool** is a liquidity pair that holds two tokens in reserve. Users can swap between those two tokens, with the exchange rate determined by the pool's pricing formula.
14
+
15
+ Each pool is identified by a unique **pool ID** in the format `zp<number>`.
16
+
17
+ Example:
18
+ ```
19
+ zp23
20
+ ```
21
+
22
+ ---
23
+
24
+ ### Pool ID
25
+
26
+ A unique identifier assigned to each pool when it is created.
27
+
28
+ ```
29
+ pool_id = 'zp23'
30
+ ```
31
+
32
+ ---
33
+
34
+ ### LP Token
35
+
36
+ A **Liquidity Provider token** is minted and given to users when they deposit tokens into a pool. It represents their proportional ownership of the pool's reserves.
37
+
38
+ LP tokens use the pool ID as their denom:
39
+ ```
40
+ denom = 'zp23'
41
+ amount = '1414213'
42
+ ```
43
+
44
+ When a user withdraws liquidity, their LP tokens are burned and the underlying tokens are returned.
45
+
46
+ ---
47
+
48
+ ### Fee
49
+
50
+ The swap fee charged on each trade.
51
+
52
+ ```
53
+ fee = 100 → 1% swap fee (100 basis points)
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Pool UID
59
+
60
+ A human-readable string that uniquely identifies a token pair, regardless of which pool holds them.
61
+
62
+ ```
63
+ pool_uid = 'coin.zig12jzwc0a3pyv4dze0t252qkwf77t4vs5rqfn3zc.panda-uzig'
64
+ ```
65
+
66
+ This is constructed by joining the two token denoms with a `-` separator.
67
+
68
+ ---
69
+
70
+ ### Pool Address
71
+
72
+ Every pool has its own on-chain address that holds the actual token reserves.
73
+
74
+ ```
75
+ address = 'zig1zhltn0ffu30waa5vlagwrsue30xflfem2k0753'
76
+ ```
77
+
78
+ ---
79
+
80
+ ### Slippage
81
+
82
+ The difference between the expected and actual price of a swap due to pool reserve changes. `max_slippage` in the DEX params defines the maximum tolerated slippage (in basis points) before a swap is rejected.
5
83
 
6
84
  ---
7
85
 
@@ -20,140 +98,312 @@ const dexApi = new ChainDexApi(endpoints)
20
98
 
21
99
  ---
22
100
 
23
- ## `fetchPool`
101
+ # 1️⃣ fetchPool
102
+
103
+ ## Method
24
104
 
25
- Fetch **details of a specific liquidity pool** by its pool ID.
105
+ ```ts
106
+ async fetchPool(poolId: string)
107
+ ```
26
108
 
27
- **CLI equivalent**
109
+ ## CLI Equivalent
28
110
 
29
111
  ```bash
30
112
  zigchaind query dex get-pool <pool-id>
31
113
  ```
32
114
 
33
- **Method**
115
+ ## Description
34
116
 
35
- ```ts
36
- fetchPool(poolId: string)
37
- ```
117
+ Fetches the **full details of a specific liquidity pool** by its pool ID.
118
+
119
+ Returns the pool's configuration including its token pair, current reserve amounts, LP token supply, swap fee, pricing formula, creator, and on-chain address.
38
120
 
39
- **Parameters**
121
+ ---
40
122
 
41
- * `poolId: string` – The ID of the pool you want to query.
123
+ ## Parameters
42
124
 
43
- **Returns**
125
+ | Name | Type | Description |
126
+ | ------ | ------ | ---------------------------------------- |
127
+ | poolId | string | Pool identifier in the format `zp<number>` (e.g. `'zp23'`) |
44
128
 
45
- * `DexPoolResponse` – Includes pool tokens, liquidity, swap fees, and other pool data.
129
+ ---
46
130
 
47
- **Example**
131
+ ## Usage Example
48
132
 
49
133
  ```ts
50
- const pool = await dexApi.fetchPool('1')
51
- console.log('Pool info:')
134
+ const pool = await dexApi.fetchPool('zp23')
52
135
  console.dir(pool, { depth: null })
53
136
  ```
54
137
 
138
+ ## Example Response
139
+
140
+ ```json
141
+ {
142
+ "pool": {
143
+ "pool_id": "zp23",
144
+ "lp_token": { "denom": "zp23", "amount": "1414213" },
145
+ "creator": "zig1648nalqktvkes73hxn4spayp3p5my0hq0hl9pe",
146
+ "fee": 100,
147
+ "formula": "constant_product",
148
+ "coins": [
149
+ {
150
+ "denom": "coin.zig1648nalqktvkes73hxn4spayp3p5my0hq0hl9pe.apl",
151
+ "amount": "1000"
152
+ },
153
+ { "denom": "uzig", "amount": "2000000000" }
154
+ ],
155
+ "address": "zig1zhltn0ffu30waa5vlagwrsue30xflfem2k0753"
156
+ }
157
+ }
158
+ ```
159
+
160
+ ## Response Field Explanation
161
+
162
+ ### `pool`
163
+
164
+ | Field | Description |
165
+ | -------------- | ----------------------------------------------------------------------- |
166
+ | pool_id | Unique pool identifier (e.g. `zp23`) |
167
+ | lp_token.denom | LP token denom — same as the pool ID |
168
+ | lp_token.amount | Total LP tokens currently in circulation |
169
+ | creator | Address that created this pool |
170
+ | fee | Swap fee in basis points (100 = 1%) |
171
+ | formula | Pricing model used (`constant_product`) |
172
+ | coins | Array of the two token reserves held in this pool |
173
+ | address | On-chain address of the pool's reserve account |
174
+
175
+ ### `coins[]`
176
+
177
+ | Field | Description |
178
+ | ------ | ---------------------------------------- |
179
+ | denom | Token denomination |
180
+ | amount | Current reserve amount in the pool |
181
+
182
+ ## When to Use
183
+
184
+ * Displaying pool details in a DEX interface
185
+ * Calculating current exchange rates from reserve ratios
186
+ * Checking pool fee and formula before executing a swap
187
+ * Verifying a pool's creator and configuration
188
+
55
189
  ---
56
190
 
57
- ## `fetchPoolBalances`
191
+ # 2️⃣ fetchPoolBalances
192
+
193
+ ## Method
58
194
 
59
- Fetch **balances of tokens in a specific pool**.
195
+ ```ts
196
+ async fetchPoolBalances(poolId: string)
197
+ ```
60
198
 
61
- **CLI equivalent**
199
+ ## CLI Equivalent
62
200
 
63
201
  ```bash
64
202
  zigchaind query dex get-pool-balances <pool-id>
65
203
  ```
66
204
 
67
- **Method**
205
+ ## Description
206
+
207
+ Fetches the **current token balances** held in a specific pool, alongside the full pool metadata.
208
+
209
+ While `fetchPool` already includes reserve amounts inside `coins`, this endpoint provides a dedicated `balances` array that is more convenient for balance-focused queries — for example when building swap calculators or liquidity displays.
210
+
211
+ ## Parameters
212
+
213
+ | Name | Type | Description |
214
+ | ------ | ------ | -------------------------------------------------------- |
215
+ | poolId | string | Pool identifier in the format `zp<number>` (e.g. `'zp23'`) |
216
+
217
+ ## Usage Example
68
218
 
69
219
  ```ts
70
- fetchPoolBalances(poolId: string)
220
+ const poolBalances = await dexApi.fetchPoolBalances('zp23')
221
+ console.dir(poolBalances, { depth: null })
71
222
  ```
72
223
 
73
- **Parameters**
224
+ ## Example Response
225
+
226
+ ```json
227
+ {
228
+ "pool": {
229
+ "pool_id": "zp23",
230
+ "lp_token": { "denom": "zp23", "amount": "1414213" },
231
+ "creator": "zig1648nalqktvkes73hxn4spayp3p5my0hq0hl9pe",
232
+ "fee": 100,
233
+ "formula": "constant_product",
234
+ "coins": [
235
+ { "denom": "coin.zig1648nalqktvkes73hxn4spayp3p5my0hq0hl9pe.apl", "amount": "1000" },
236
+ { "denom": "uzig", "amount": "2000000000" }
237
+ ],
238
+ "address": "zig1zhltn0ffu30waa5vlagwrsue30xflfem2k0753"
239
+ },
240
+ "balances": [
241
+ { "denom": "coin.zig1648nalqktvkes73hxn4spayp3p5my0hq0hl9pe.apl", "amount": "1000" },
242
+ { "denom": "uzig", "amount": "2000000000" }
243
+ ]
244
+ }
245
+ ```
74
246
 
75
- * `poolId: string` – The pool ID to query balances for.
247
+ ## Response Field Explanation
76
248
 
77
- **Returns**
249
+ ### `pool`
78
250
 
79
- * `DexPoolBalancesResponse` Contains the amounts of each token in the pool.
251
+ Full pool metadata identical structure to `fetchPool`. See that section for field descriptions.
80
252
 
81
- **Example**
253
+ ### `balances`
82
254
 
83
- ```ts
84
- const balances = await dexApi.fetchPoolBalances('1')
85
- console.log('Pool balances:')
86
- console.dir(balances, { depth: null })
87
- ```
255
+ A dedicated array of the current token reserves held in the pool.
256
+
257
+ | Field | Description |
258
+ | ------ | --------------------------------------- |
259
+ | denom | Token denomination |
260
+ | amount | Current reserve amount in the pool |
261
+
262
+ ### `fetchPool` vs `fetchPoolBalances`
263
+
264
+ | Feature | fetchPool | fetchPoolBalances |
265
+ | -------------------------- | ------------ | ------------------------- |
266
+ | Full pool metadata | ✅ Yes | ✅ Yes (same pool object) |
267
+ | Dedicated balances array | ❌ No | ✅ Yes |
268
+ | Use case | Pool info | Balance-focused queries |
269
+
270
+ ## When to Use
271
+
272
+ * Building swap calculators that need clean reserve amounts
273
+ * Displaying current pool liquidity depth
274
+ * Monitoring pool reserve changes over time
88
275
 
89
276
  ---
90
277
 
91
- ## `fetchPoolUids`
278
+ # 3️⃣ fetchPoolUids
279
+
280
+ ## Method
92
281
 
93
- Fetch the **pool IDs for a given token pair**.
282
+ ```ts
283
+ async fetchPoolUids(tokenA: string, tokenB: string)
284
+ ```
94
285
 
95
- **CLI equivalent**
286
+ ## CLI Equivalent
96
287
 
97
288
  ```bash
98
289
  zigchaind query dex pool-uids <tokenA> <tokenB>
99
290
  ```
100
291
 
101
- **Method**
292
+ ## Description
102
293
 
103
- ```ts
104
- fetchPoolUids(tokenA: string, tokenB: string)
105
- ```
294
+ Resolves the **pool UID and pool ID** for a given token pair.
106
295
 
107
- **Parameters**
296
+ Use this when you know the two tokens you want to swap or provide liquidity for, but don't know which pool serves that pair. This is the lookup function that maps a token pair to its corresponding pool.
108
297
 
109
- * `tokenA: string` – Symbol or denom of the first token.
110
- * `tokenB: string` – Symbol or denom of the second token.
298
+ ## Parameters
111
299
 
112
- **Returns**
300
+ | Name | Type | Description |
301
+ | ------ | ------ | ---------------------------------------------- |
302
+ | tokenA | string | Full denom of the first token in the pair |
303
+ | tokenB | string | Full denom of the second token in the pair |
113
304
 
114
- * `poolUidResponse` Pool IDs that match the token pair.
305
+ > Pass the full token denom, not a short symbol — e.g. `'coin.zig12jzwc0a3pyv4dze0t252qkwf77t4vs5rqfn3zc.panda'` not `'panda'`.
115
306
 
116
- **Example**
307
+ ## Usage Example
117
308
 
118
309
  ```ts
119
- const uids = await dexApi.fetchPoolUids('uzig', 'uatom')
120
- console.log('Pool IDs for token pair:')
121
- console.dir(uids, { depth: null })
310
+ const poolUids = await dexApi.fetchPoolUids(
311
+ 'coin.zig12jzwc0a3pyv4dze0t252qkwf77t4vs5rqfn3zc.panda',
312
+ 'uzig'
313
+ )
314
+ console.dir(poolUids, { depth: null })
315
+ ```
316
+
317
+ ## Example Response
318
+
319
+ ```json
320
+ {
321
+ "pool_uids": {
322
+ "pool_uid": "coin.zig12jzwc0a3pyv4dze0t252qkwf77t4vs5rqfn3zc.panda-uzig",
323
+ "pool_id": "zp72"
324
+ }
325
+ }
122
326
  ```
123
327
 
328
+ ## Response Field Explanation
329
+
330
+ ### `pool_uids`
331
+
332
+ | Field | Description |
333
+ | -------- | ------------------------------------------------------------------------- |
334
+ | pool_uid | Human-readable string identifying this token pair (`tokenA-tokenB`) |
335
+ | pool_id | The pool ID for this pair — use this with `fetchPool` or `fetchPoolBalances` |
336
+
337
+ > Once you have the `pool_id`, you can pass it to `fetchPool('zp72')` or `fetchPoolBalances('zp72')` to get full pool details.
338
+
339
+ ## When to Use
340
+
341
+ * Finding which pool to use for a given token pair
342
+ * Resolving a pool ID before executing a swap
343
+ * Checking if a pool exists for a specific pair
344
+
124
345
  ---
125
346
 
126
- ## `fetchParams`
347
+ # 4️⃣ fetchParams
348
+
349
+ ## Method
127
350
 
128
- Fetch the **DEX module parameters**.
351
+ ```ts
352
+ async fetchParams()
353
+ ```
129
354
 
130
- **CLI equivalent**
355
+ ## CLI Equivalent
131
356
 
132
357
  ```bash
133
358
  zigchaind query dex params
134
359
  ```
135
360
 
136
- **Method**
361
+ ## Description
137
362
 
138
- ```ts
139
- fetchParams()
140
- ```
363
+ Fetches the **DEX module parameters** configured at chain level.
364
+
365
+ These are governance-controlled settings that define pool creation costs, fee structures, slippage limits, and the beneficiary address that receives protocol fees.
141
366
 
142
- **Returns**
367
+ ## Parameters
143
368
 
144
- * `DexParamsResponse` – Includes swap fees, allowed pools, and other DEX settings.
369
+ None.
145
370
 
146
- **Example**
371
+ ## Usage Example
147
372
 
148
373
  ```ts
149
374
  const params = await dexApi.fetchParams()
150
- console.log('DEX params:')
151
375
  console.dir(params, { depth: null })
152
376
  ```
153
377
 
154
- ---
378
+ ## Example Response
379
+
380
+ ```json
381
+ {
382
+ "params": {
383
+ "new_pool_fee_pct": 100,
384
+ "creation_fee": 10000000,
385
+ "beneficiary": "zig1s3mhkcycpgjj5tdv09ux6qg7hgzcyu6shzsfu0",
386
+ "minimal_liquidity_lock": 1000,
387
+ "max_slippage": 100
388
+ }
389
+ }
390
+ ```
391
+
392
+ ## Response Field Explanation
155
393
 
156
- ## Notes
394
+ ### `params`
157
395
 
158
- * All queries are **read-only** and do not require a wallet.
159
- * Pool-related queries are useful for **tracking liquidity, swaps, and token balances**.
396
+ | Field | Description |
397
+ | ---------------------- | ------------------------------------------------------------------------------- |
398
+ | new_pool_fee_pct | Fee percentage charged on new pool creation, in basis points (100 = 1%) |
399
+ | creation_fee | Flat fee in `uzig` required to create a new pool (`10000000` = 10 ZIG) |
400
+ | beneficiary | Address that receives protocol-level fees from pool creation |
401
+ | minimal_liquidity_lock | Minimum LP token amount that must remain locked in a pool at all times |
402
+ | max_slippage | Maximum allowed slippage per swap in basis points (100 = 1%) |
403
+
404
+ ## When to Use
405
+
406
+ * Displaying pool creation costs to users before they create a pool
407
+ * Verifying current slippage limits for swap transactions
408
+ * Governance monitoring for DEX parameter changes
409
+ ---