@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.
- package/README.md +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.js.map +1 -1
- package/dist/dex/ChainDexApi.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
- package/dist/distribution/ChainDistributionApi.js +0 -1
- package/dist/distribution/ChainDistributionApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/staking/ChainStakingApi.d.ts +1 -5
- package/dist/staking/ChainStakingApi.d.ts.map +1 -1
- package/dist/staking/ChainStakingApi.js +9 -7
- package/dist/staking/ChainStakingApi.js.map +1 -1
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
- package/dist/validator-set/ChainValidator.d.ts +8 -0
- package/dist/validator-set/ChainValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainValidator.js +15 -0
- package/dist/validator-set/ChainValidator.js.map +1 -0
- package/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/dex.md +313 -63
- package/docs/distribution.md +664 -93
- package/docs/evidence.md +117 -122
- package/docs/factory.md +308 -62
- package/docs/gov.md +268 -70
- package/docs/ibc/ibcChannel.md +736 -249
- package/docs/ibc/ibcClient.md +608 -139
- package/docs/ibc-transfer.md +349 -90
- package/docs/interchain-accounts.md +151 -48
- package/docs/mint.md +173 -36
- package/docs/runtime.md +81 -42
- package/docs/slashing.md +209 -61
- package/docs/staking.md +534 -411
- package/docs/tokenwrapper.md +221 -64
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +281 -58
- package/docs/validator-set.md +177 -0
- package/package.json +1 -1
- package/docs/comet-validator-set.md +0 -70
package/docs/dex.md
CHANGED
|
@@ -1,7 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DEX Module
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
101
|
+
# 1️⃣ fetchPool
|
|
102
|
+
|
|
103
|
+
## Method
|
|
24
104
|
|
|
25
|
-
|
|
105
|
+
```ts
|
|
106
|
+
async fetchPool(poolId: string)
|
|
107
|
+
```
|
|
26
108
|
|
|
27
|
-
|
|
109
|
+
## CLI Equivalent
|
|
28
110
|
|
|
29
111
|
```bash
|
|
30
112
|
zigchaind query dex get-pool <pool-id>
|
|
31
113
|
```
|
|
32
114
|
|
|
33
|
-
|
|
115
|
+
## Description
|
|
34
116
|
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
121
|
+
---
|
|
40
122
|
|
|
41
|
-
|
|
123
|
+
## Parameters
|
|
42
124
|
|
|
43
|
-
|
|
125
|
+
| Name | Type | Description |
|
|
126
|
+
| ------ | ------ | ---------------------------------------- |
|
|
127
|
+
| poolId | string | Pool identifier in the format `zp<number>` (e.g. `'zp23'`) |
|
|
44
128
|
|
|
45
|
-
|
|
129
|
+
---
|
|
46
130
|
|
|
47
|
-
|
|
131
|
+
## Usage Example
|
|
48
132
|
|
|
49
133
|
```ts
|
|
50
|
-
const pool = await dexApi.fetchPool('
|
|
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
|
-
|
|
191
|
+
# 2️⃣ fetchPoolBalances
|
|
192
|
+
|
|
193
|
+
## Method
|
|
58
194
|
|
|
59
|
-
|
|
195
|
+
```ts
|
|
196
|
+
async fetchPoolBalances(poolId: string)
|
|
197
|
+
```
|
|
60
198
|
|
|
61
|
-
|
|
199
|
+
## CLI Equivalent
|
|
62
200
|
|
|
63
201
|
```bash
|
|
64
202
|
zigchaind query dex get-pool-balances <pool-id>
|
|
65
203
|
```
|
|
66
204
|
|
|
67
|
-
|
|
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(
|
|
220
|
+
const poolBalances = await dexApi.fetchPoolBalances('zp23')
|
|
221
|
+
console.dir(poolBalances, { depth: null })
|
|
71
222
|
```
|
|
72
223
|
|
|
73
|
-
|
|
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
|
-
|
|
247
|
+
## Response Field Explanation
|
|
76
248
|
|
|
77
|
-
|
|
249
|
+
### `pool`
|
|
78
250
|
|
|
79
|
-
|
|
251
|
+
Full pool metadata — identical structure to `fetchPool`. See that section for field descriptions.
|
|
80
252
|
|
|
81
|
-
|
|
253
|
+
### `balances`
|
|
82
254
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
278
|
+
# 3️⃣ fetchPoolUids
|
|
279
|
+
|
|
280
|
+
## Method
|
|
92
281
|
|
|
93
|
-
|
|
282
|
+
```ts
|
|
283
|
+
async fetchPoolUids(tokenA: string, tokenB: string)
|
|
284
|
+
```
|
|
94
285
|
|
|
95
|
-
|
|
286
|
+
## CLI Equivalent
|
|
96
287
|
|
|
97
288
|
```bash
|
|
98
289
|
zigchaind query dex pool-uids <tokenA> <tokenB>
|
|
99
290
|
```
|
|
100
291
|
|
|
101
|
-
|
|
292
|
+
## Description
|
|
102
293
|
|
|
103
|
-
|
|
104
|
-
fetchPoolUids(tokenA: string, tokenB: string)
|
|
105
|
-
```
|
|
294
|
+
Resolves the **pool UID and pool ID** for a given token pair.
|
|
106
295
|
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
* `tokenB: string` – Symbol or denom of the second token.
|
|
298
|
+
## Parameters
|
|
111
299
|
|
|
112
|
-
|
|
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
|
-
|
|
305
|
+
> Pass the full token denom, not a short symbol — e.g. `'coin.zig12jzwc0a3pyv4dze0t252qkwf77t4vs5rqfn3zc.panda'` not `'panda'`.
|
|
115
306
|
|
|
116
|
-
|
|
307
|
+
## Usage Example
|
|
117
308
|
|
|
118
309
|
```ts
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
347
|
+
# 4️⃣ fetchParams
|
|
348
|
+
|
|
349
|
+
## Method
|
|
127
350
|
|
|
128
|
-
|
|
351
|
+
```ts
|
|
352
|
+
async fetchParams()
|
|
353
|
+
```
|
|
129
354
|
|
|
130
|
-
|
|
355
|
+
## CLI Equivalent
|
|
131
356
|
|
|
132
357
|
```bash
|
|
133
358
|
zigchaind query dex params
|
|
134
359
|
```
|
|
135
360
|
|
|
136
|
-
|
|
361
|
+
## Description
|
|
137
362
|
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
367
|
+
## Parameters
|
|
143
368
|
|
|
144
|
-
|
|
369
|
+
None.
|
|
145
370
|
|
|
146
|
-
|
|
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
|
-
|
|
394
|
+
### `params`
|
|
157
395
|
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
---
|