quantumswap 0.0.5 → 0.0.7
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 +307 -307
- package/examples/README.md +46 -46
- package/examples/package-lock.json +12 -14
- package/examples/package.json +1 -1
- package/index.d.ts +1 -1
- package/index.js +45 -45
- package/package.json +32 -34
- package/src/IERC20.d.ts +24 -24
- package/src/IERC20.js +348 -348
- package/src/IERC20__factory.d.ts +10 -10
- package/src/IERC20__factory.js +29 -29
- package/src/QuantumSwapV2ERC20.d.ts +24 -24
- package/src/QuantumSwapV2ERC20.js +353 -353
- package/src/QuantumSwapV2ERC20__factory.d.ts +10 -10
- package/src/QuantumSwapV2ERC20__factory.js +29 -29
- package/src/QuantumSwapV2Factory.d.ts +24 -24
- package/src/QuantumSwapV2Factory.js +310 -310
- package/src/QuantumSwapV2Factory__factory.d.ts +10 -10
- package/src/QuantumSwapV2Factory__factory.js +29 -29
- package/src/QuantumSwapV2Pair.d.ts +44 -44
- package/src/QuantumSwapV2Pair.js +847 -847
- package/src/QuantumSwapV2Pair__factory.d.ts +10 -10
- package/src/QuantumSwapV2Pair__factory.js +29 -29
- package/src/QuantumSwapV2Router02.d.ts +47 -47
- package/src/QuantumSwapV2Router02.js +1109 -1109
- package/src/QuantumSwapV2Router02__factory.d.ts +10 -10
- package/src/QuantumSwapV2Router02__factory.js +29 -29
- package/src/WQ.d.ts +28 -28
- package/src/WQ.js +435 -435
- package/src/WQ__factory.d.ts +10 -10
- package/src/WQ__factory.js +29 -29
- package/src/index.d.ts +14 -14
- package/src/index.js +15 -15
- package/src/quantumcoin-shims.d.ts +25 -25
- package/src/types.d.ts +3 -3
- package/src/types.js +3 -3
package/README.md
CHANGED
|
@@ -1,307 +1,307 @@
|
|
|
1
|
-
# QuantumSwap
|
|
2
|
-
|
|
3
|
-
QuantumSwap.js SDK for DEX functionality in QuantumCoin blockchain
|
|
4
|
-
|
|
5
|
-
> **Note:** This is an experimental SDK. Use at your own risk.
|
|
6
|
-
|
|
7
|
-
## Interacting with QuantumCoin blockchain
|
|
8
|
-
|
|
9
|
-
For general programmatic interaction with the QuantumCoin blockchain (wallets, providers, contracts, encoding, etc.), use **quantumcoin.js**:
|
|
10
|
-
|
|
11
|
-
- **npm:** [quantumcoin](https://www.npmjs.com/package/quantumcoin)
|
|
12
|
-
- **Git:** [quantumcoin.js repository](https://github.com/quantumcoinproject/quantumcoin.js) (see the npm package page for the canonical repo link)
|
|
13
|
-
|
|
14
|
-
QuantumSwap.js depends on `quantumcoin` and uses it for `Initialize`, `JsonRpcProvider`, `Wallet`, `Contract`, and related utilities. Use quantumcoin.js for all non–QuantumSwap-specific blockchain interaction.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## What’s in this package
|
|
18
|
-
|
|
19
|
-
- JavaScript contract wrappers and factories in [src/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/src) (TypeScript types via `.d.ts`)
|
|
20
|
-
- Transactional tests in [test/e2e/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/test/e2e)
|
|
21
|
-
- Example scripts in [examples/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/examples)
|
|
22
|
-
|
|
23
|
-
## Install
|
|
24
|
-
|
|
25
|
-
- `npm install`
|
|
26
|
-
|
|
27
|
-
## Build
|
|
28
|
-
|
|
29
|
-
- (no build step required)
|
|
30
|
-
|
|
31
|
-
## Run tests
|
|
32
|
-
|
|
33
|
-
- `npm test`
|
|
34
|
-
|
|
35
|
-
Transactional tests require:
|
|
36
|
-
- `QC_RPC_URL` (required for transactional tests)
|
|
37
|
-
- `QC_CHAIN_ID` (optional; defaults are used if omitted)
|
|
38
|
-
|
|
39
|
-
## Examples
|
|
40
|
-
|
|
41
|
-
- **JavaScript:** [examples/run-dex-flow-custom.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.js)
|
|
42
|
-
- **TypeScript:** [examples/run-dex-flow-custom.ts](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.ts)
|
|
43
|
-
|
|
44
|
-
cd examples
|
|
45
|
-
npm install
|
|
46
|
-
$env:QC_RPC_URL="https://public.rpc.quantumcoiapi.com:8545" (export for Linux)
|
|
47
|
-
node run-dex-flow-custom.js
|
|
48
|
-
|
|
49
|
-
### Step by step walkthrough
|
|
50
|
-
|
|
51
|
-
This walkthrough uses **pre-deployed** WQ, V2 Factory, and Swap Router. Do **not** deploy these contracts; use the Test Release (Dec 2025) addresses below.
|
|
52
|
-
|
|
53
|
-
**Test Release (Dec 2025) Contracts**
|
|
54
|
-
|
|
55
|
-
| Variable | Address |
|
|
56
|
-
|----------|---------|
|
|
57
|
-
| `WQ_CONTRACT_ADDRESS` | `0x0E49c26cd1ca19bF8ddA2C8985B96783288458754757F4C9E00a5439A7291628` |
|
|
58
|
-
| `V2_CORE_FACTORY_CONTRACT_ADDRESS` | `0xbbF45a1B60044669793B444eD01Eb33e03Bb8cf3c5b6ae7887B218D05C5Cbf1d` |
|
|
59
|
-
| `SWAP_ROUTER_V2_CONTRACT_ADDRESS` | `0x41323EF72662185f44a03ea0ad8094a0C9e925aB1102679D8e957e838054aac5` |
|
|
60
|
-
|
|
61
|
-
**Steps**
|
|
62
|
-
|
|
63
|
-
1. **Connect** — Initialize the SDK, create a `JsonRpcProvider` with your RPC URL and chain ID, load a `Wallet` (e.g. from encrypted JSON or private key). Attach the SDK contract wrappers to the deployed addresses:
|
|
64
|
-
- `WQ.connect(WQ_CONTRACT_ADDRESS, provider)` (or with signer for writes)
|
|
65
|
-
- `QuantumSwapV2Factory.connect(V2_CORE_FACTORY_CONTRACT_ADDRESS, provider)`
|
|
66
|
-
- `QuantumSwapV2Router02.connect(SWAP_ROUTER_V2_CONTRACT_ADDRESS, signer)` for router calls
|
|
67
|
-
|
|
68
|
-
2. **Deploy two ERC20 tokens** — Deploy two tokens that have initial supply and mint to the deployer (e.g. a SimpleERC20-style contract: `constructor(name, symbol, initialSupply)`). Use `ContractFactory` with the token ABI and bytecode, then `getDeployTransaction(...)` and `sendTransaction({ ...tx, gasLimit })` so deployment has enough gas. Record `tokenA` and `tokenB` contract addresses.
|
|
69
|
-
|
|
70
|
-
3. **Create a pair** — Call `factory.createPair(tokenAAddress, tokenBAddress)` (with a signer). Wait for the tx. Get the pair address with `factory.getPair(tokenAAddress, tokenBAddress)`.
|
|
71
|
-
|
|
72
|
-
4. **Add liquidity** — Approve the router to spend tokenA and tokenB (e.g. `tokenA.approve(routerAddress, amountADesired)` and same for tokenB). Call `router.addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline)` with a signer. Optionally verify pair reserves with `pair.getReserves()`.
|
|
73
|
-
|
|
74
|
-
5. **Swap token for token** — Approve the router to spend the input token. Call `router.swapExactTokensForTokens(amountIn, amountOutMin, [tokenIn, tokenOut], to, deadline)`. Check the recipient token balance before and after to confirm the swap.
|
|
75
|
-
|
|
76
|
-
6. **Swap ETH for token (optional)** — Wrap native currency: `wq.deposit({ value: amount })`. If there is no WQ–token pair yet, create it with `factory.createPair(wqAddress, tokenAddress)` and add liquidity via `router.addLiquidityETH(token, amountTokenDesired, amountTokenMin, amountETHMin, to, deadline, { value: ethAmount })`. Then call `router.swapExactETHForTokens(amountOutMin, [wqAddress, tokenAddress], to, deadline, { value: ethValue })` to swap native ETH for the token.
|
|
77
|
-
|
|
78
|
-
Runnable scripts that perform all steps above:
|
|
79
|
-
|
|
80
|
-
- **JavaScript:** [examples/run-dex-flow-custom.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.js)
|
|
81
|
-
- **TypeScript:** [examples/run-dex-flow-custom.ts](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.ts)
|
|
82
|
-
|
|
83
|
-
Run with `QC_RPC_URL` set (and optionally `QC_CHAIN_ID`, or `QC_WALLET_JSON` + `QC_WALLET_PASSPHRASE` for your own wallet):
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# Use https://public.rpc.quantumcoinapi.com for mainnet
|
|
87
|
-
|
|
88
|
-
# JavaScript
|
|
89
|
-
QC_RPC_URL=http://your-rpc:8545 node examples/run-dex-flow-custom.js
|
|
90
|
-
|
|
91
|
-
# TypeScript (requires typescript and ts-node: npm install -D typescript ts-node)
|
|
92
|
-
QC_RPC_URL=http://your-rpc:8545 npx ts-node examples/run-dex-flow-custom.ts
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The same flow is covered as an E2E test in [test/e2e/dex-full-flow.e2e.test.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/dex-full-flow.e2e.test.js) (the test can optionally deploy WQ/Factory/Router when not using Test Release addresses).
|
|
96
|
-
|
|
97
|
-
Examples are generated per contract (e.g. [examples/deploy-<Contract>.js](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/examples)).
|
|
98
|
-
|
|
99
|
-
## Contracts
|
|
100
|
-
|
|
101
|
-
- [`IERC20`](#ierc20)
|
|
102
|
-
- [`QuantumSwapV2ERC20`](#quantumswapv2erc20)
|
|
103
|
-
- [`QuantumSwapV2Factory`](#quantumswapv2factory)
|
|
104
|
-
- [`QuantumSwapV2Pair`](#quantumswapv2pair)
|
|
105
|
-
- [`QuantumSwapV2Router02`](#quantumswapv2router02)
|
|
106
|
-
- [`WQ`](#wq)
|
|
107
|
-
|
|
108
|
-
## IERC20
|
|
109
|
-
- **Exports**: `IERC20`, `IERC20__factory`
|
|
110
|
-
- **Constructor**: `constructor()`
|
|
111
|
-
### Files
|
|
112
|
-
- [`src/IERC20.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/IERC20.js)
|
|
113
|
-
- [`src/IERC20__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/IERC20__factory.js)
|
|
114
|
-
### Examples
|
|
115
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-IERC20.js)
|
|
116
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-IERC20.js)
|
|
117
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-IERC20.js)
|
|
118
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-IERC20.js)
|
|
119
|
-
### Tests
|
|
120
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/IERC20.e2e.test.js)
|
|
121
|
-
### Functions
|
|
122
|
-
- `allowance(address owner, address spender) view returns (uint256)`
|
|
123
|
-
- `approve(address spender, uint256 value) returns (bool)`
|
|
124
|
-
- `balanceOf(address owner) view returns (uint256)`
|
|
125
|
-
- `decimals() view returns (uint8)`
|
|
126
|
-
- `name() view returns (string)`
|
|
127
|
-
- `symbol() view returns (string)`
|
|
128
|
-
- `totalSupply() view returns (uint256)`
|
|
129
|
-
- `transfer(address to, uint256 value) returns (bool)`
|
|
130
|
-
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
131
|
-
### Events
|
|
132
|
-
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
133
|
-
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
134
|
-
### Errors
|
|
135
|
-
- (none)
|
|
136
|
-
## QuantumSwapV2ERC20
|
|
137
|
-
- **Exports**: `QuantumSwapV2ERC20`, `QuantumSwapV2ERC20__factory`
|
|
138
|
-
- **Constructor**: `constructor()`
|
|
139
|
-
### Files
|
|
140
|
-
- [`src/QuantumSwapV2ERC20.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2ERC20.js)
|
|
141
|
-
- [`src/QuantumSwapV2ERC20__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2ERC20__factory.js)
|
|
142
|
-
### Examples
|
|
143
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2ERC20.js)
|
|
144
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2ERC20.js)
|
|
145
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2ERC20.js)
|
|
146
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2ERC20.js)
|
|
147
|
-
### Tests
|
|
148
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2ERC20.e2e.test.js)
|
|
149
|
-
### Functions
|
|
150
|
-
- `allowance(address, address) view returns (uint256)`
|
|
151
|
-
- `approve(address spender, uint256 value) returns (bool)`
|
|
152
|
-
- `balanceOf(address) view returns (uint256)`
|
|
153
|
-
- `decimals() view returns (uint8)`
|
|
154
|
-
- `name() view returns (string)`
|
|
155
|
-
- `symbol() view returns (string)`
|
|
156
|
-
- `totalSupply() view returns (uint256)`
|
|
157
|
-
- `transfer(address to, uint256 value) returns (bool)`
|
|
158
|
-
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
159
|
-
### Events
|
|
160
|
-
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
161
|
-
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
162
|
-
### Errors
|
|
163
|
-
- (none)
|
|
164
|
-
## QuantumSwapV2Factory
|
|
165
|
-
- **Exports**: `QuantumSwapV2Factory`, `QuantumSwapV2Factory__factory`
|
|
166
|
-
- **Constructor**: `constructor(address _feeToSetter)`
|
|
167
|
-
### Files
|
|
168
|
-
- [`src/QuantumSwapV2Factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Factory.js)
|
|
169
|
-
- [`src/QuantumSwapV2Factory__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Factory__factory.js)
|
|
170
|
-
### Examples
|
|
171
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Factory.js)
|
|
172
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Factory.js)
|
|
173
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Factory.js)
|
|
174
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Factory.js)
|
|
175
|
-
### Tests
|
|
176
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Factory.e2e.test.js)
|
|
177
|
-
### Functions
|
|
178
|
-
- `allPairs(uint256) view returns (address)`
|
|
179
|
-
- `allPairsLength() view returns (uint256)`
|
|
180
|
-
- `createPair(address tokenA, address tokenB) returns (address)`
|
|
181
|
-
- `feeTo() view returns (address)`
|
|
182
|
-
- `feeToSetter() view returns (address)`
|
|
183
|
-
- `getPair(address, address) view returns (address)`
|
|
184
|
-
- `INIT_CODE_HASH() view returns (bytes32)`
|
|
185
|
-
- `setFeeTo(address _feeTo)`
|
|
186
|
-
- `setFeeToSetter(address _feeToSetter)`
|
|
187
|
-
### Events
|
|
188
|
-
- `PairCreated(address indexed token0, address indexed token1, address pair, uint256)`
|
|
189
|
-
### Errors
|
|
190
|
-
- (none)
|
|
191
|
-
## QuantumSwapV2Pair
|
|
192
|
-
- **Exports**: `QuantumSwapV2Pair`, `QuantumSwapV2Pair__factory`
|
|
193
|
-
- **Constructor**: `constructor()`
|
|
194
|
-
### Files
|
|
195
|
-
- [`src/QuantumSwapV2Pair.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Pair.js)
|
|
196
|
-
- [`src/QuantumSwapV2Pair__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Pair__factory.js)
|
|
197
|
-
### Examples
|
|
198
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Pair.js)
|
|
199
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Pair.js)
|
|
200
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Pair.js)
|
|
201
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Pair.js)
|
|
202
|
-
### Tests
|
|
203
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Pair.e2e.test.js)
|
|
204
|
-
### Functions
|
|
205
|
-
- `allowance(address, address) view returns (uint256)`
|
|
206
|
-
- `approve(address spender, uint256 value) returns (bool)`
|
|
207
|
-
- `balanceOf(address) view returns (uint256)`
|
|
208
|
-
- `burn(address to) returns (uint256, uint256)`
|
|
209
|
-
- `decimals() view returns (uint8)`
|
|
210
|
-
- `factory() view returns (address)`
|
|
211
|
-
- `getReserves() view returns (uint112, uint112, uint32)`
|
|
212
|
-
- `initialize(address _token0, address _token1)`
|
|
213
|
-
- `kLast() view returns (uint256)`
|
|
214
|
-
- `MINIMUM_LIQUIDITY() view returns (uint256)`
|
|
215
|
-
- `mint(address to) returns (uint256)`
|
|
216
|
-
- `name() view returns (string)`
|
|
217
|
-
- `price0CumulativeLast() view returns (uint256)`
|
|
218
|
-
- `price1CumulativeLast() view returns (uint256)`
|
|
219
|
-
- `skim(address to)`
|
|
220
|
-
- `swap(uint256 amount0Out, uint256 amount1Out, address to, bytes data)`
|
|
221
|
-
- `symbol() view returns (string)`
|
|
222
|
-
- `sync()`
|
|
223
|
-
- `token0() view returns (address)`
|
|
224
|
-
- `token1() view returns (address)`
|
|
225
|
-
- `totalSupply() view returns (uint256)`
|
|
226
|
-
- `transfer(address to, uint256 value) returns (bool)`
|
|
227
|
-
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
228
|
-
### Events
|
|
229
|
-
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
230
|
-
- `Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to)`
|
|
231
|
-
- `Mint(address indexed sender, uint256 amount0, uint256 amount1)`
|
|
232
|
-
- `Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to)`
|
|
233
|
-
- `Sync(uint112 reserve0, uint112 reserve1)`
|
|
234
|
-
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
235
|
-
### Errors
|
|
236
|
-
- (none)
|
|
237
|
-
## QuantumSwapV2Router02
|
|
238
|
-
- **Exports**: `QuantumSwapV2Router02`, `QuantumSwapV2Router02__factory`
|
|
239
|
-
- **Constructor**: `constructor(address _factory, address _WETH)`
|
|
240
|
-
### Files
|
|
241
|
-
- [`src/QuantumSwapV2Router02.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Router02.js)
|
|
242
|
-
- [`src/QuantumSwapV2Router02__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Router02__factory.js)
|
|
243
|
-
### Examples
|
|
244
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Router02.js)
|
|
245
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Router02.js)
|
|
246
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Router02.js)
|
|
247
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Router02.js)
|
|
248
|
-
### Tests
|
|
249
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Router02.e2e.test.js)
|
|
250
|
-
### Functions
|
|
251
|
-
- `addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256, uint256, uint256)`
|
|
252
|
-
- `addLiquidityETH(address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) payable returns (uint256, uint256, uint256)`
|
|
253
|
-
- `factory() view returns (address)`
|
|
254
|
-
- `getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut) pure returns (uint256)`
|
|
255
|
-
- `getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) pure returns (uint256)`
|
|
256
|
-
- `getAmountsIn(uint256 amountOut, address[] path) view returns (uint256[])`
|
|
257
|
-
- `getAmountsOut(uint256 amountIn, address[] path) view returns (uint256[])`
|
|
258
|
-
- `quote(uint256 amountA, uint256 reserveA, uint256 reserveB) pure returns (uint256)`
|
|
259
|
-
- `removeLiquidity(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256, uint256)`
|
|
260
|
-
- `removeLiquidityETH(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) returns (uint256, uint256)`
|
|
261
|
-
- `removeLiquidityETHSupportingFeeOnTransferTokens(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) returns (uint256)`
|
|
262
|
-
- `swapETHForExactTokens(uint256 amountOut, address[] path, address to, uint256 deadline) payable returns (uint256[])`
|
|
263
|
-
- `swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable returns (uint256[])`
|
|
264
|
-
- `swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable`
|
|
265
|
-
- `swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
266
|
-
- `swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)`
|
|
267
|
-
- `swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
268
|
-
- `swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)`
|
|
269
|
-
- `swapTokensForExactETH(uint256 amountOut, uint256 amountInMax, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
270
|
-
- `swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
271
|
-
- `WETH() view returns (address)`
|
|
272
|
-
### Events
|
|
273
|
-
- (none)
|
|
274
|
-
### Errors
|
|
275
|
-
- (none)
|
|
276
|
-
## WQ
|
|
277
|
-
- **Exports**: `WQ`, `WQ__factory`
|
|
278
|
-
- **Constructor**: `constructor()`
|
|
279
|
-
### Files
|
|
280
|
-
- [`src/WQ.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/WQ.js)
|
|
281
|
-
- [`src/WQ__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/WQ__factory.js)
|
|
282
|
-
### Examples
|
|
283
|
-
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-WQ.js)
|
|
284
|
-
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-WQ.js)
|
|
285
|
-
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-WQ.js)
|
|
286
|
-
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-WQ.js)
|
|
287
|
-
### Tests
|
|
288
|
-
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/WQ.e2e.test.js)
|
|
289
|
-
### Functions
|
|
290
|
-
- `allowance(address, address) view returns (uint256)`
|
|
291
|
-
- `approve(address guy, uint256 wad) returns (bool)`
|
|
292
|
-
- `balanceOf(address) view returns (uint256)`
|
|
293
|
-
- `decimals() view returns (uint8)`
|
|
294
|
-
- `deposit() payable`
|
|
295
|
-
- `name() view returns (string)`
|
|
296
|
-
- `symbol() view returns (string)`
|
|
297
|
-
- `totalSupply() view returns (uint256)`
|
|
298
|
-
- `transfer(address dst, uint256 wad) returns (bool)`
|
|
299
|
-
- `transferFrom(address src, address dst, uint256 wad) returns (bool)`
|
|
300
|
-
- `withdraw(uint256 wad)`
|
|
301
|
-
### Events
|
|
302
|
-
- `Approval(address indexed src, address indexed guy, uint256 wad)`
|
|
303
|
-
- `Deposit(address indexed dst, uint256 wad)`
|
|
304
|
-
- `Transfer(address indexed src, address indexed dst, uint256 wad)`
|
|
305
|
-
- `Withdrawal(address indexed src, uint256 wad)`
|
|
306
|
-
### Errors
|
|
307
|
-
- (none)
|
|
1
|
+
# QuantumSwap
|
|
2
|
+
|
|
3
|
+
QuantumSwap.js SDK for DEX functionality in QuantumCoin blockchain
|
|
4
|
+
|
|
5
|
+
> **Note:** This is an experimental SDK. Use at your own risk.
|
|
6
|
+
|
|
7
|
+
## Interacting with QuantumCoin blockchain
|
|
8
|
+
|
|
9
|
+
For general programmatic interaction with the QuantumCoin blockchain (wallets, providers, contracts, encoding, etc.), use **quantumcoin.js**:
|
|
10
|
+
|
|
11
|
+
- **npm:** [quantumcoin](https://www.npmjs.com/package/quantumcoin)
|
|
12
|
+
- **Git:** [quantumcoin.js repository](https://github.com/quantumcoinproject/quantumcoin.js) (see the npm package page for the canonical repo link)
|
|
13
|
+
|
|
14
|
+
QuantumSwap.js depends on `quantumcoin` and uses it for `Initialize`, `JsonRpcProvider`, `Wallet`, `Contract`, and related utilities. Use quantumcoin.js for all non–QuantumSwap-specific blockchain interaction.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## What’s in this package
|
|
18
|
+
|
|
19
|
+
- JavaScript contract wrappers and factories in [src/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/src) (TypeScript types via `.d.ts`)
|
|
20
|
+
- Transactional tests in [test/e2e/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/test/e2e)
|
|
21
|
+
- Example scripts in [examples/](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/examples)
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
- `npm install`
|
|
26
|
+
|
|
27
|
+
## Build
|
|
28
|
+
|
|
29
|
+
- (no build step required)
|
|
30
|
+
|
|
31
|
+
## Run tests
|
|
32
|
+
|
|
33
|
+
- `npm test`
|
|
34
|
+
|
|
35
|
+
Transactional tests require:
|
|
36
|
+
- `QC_RPC_URL` (required for transactional tests)
|
|
37
|
+
- `QC_CHAIN_ID` (optional; defaults are used if omitted)
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
- **JavaScript:** [examples/run-dex-flow-custom.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.js)
|
|
42
|
+
- **TypeScript:** [examples/run-dex-flow-custom.ts](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.ts)
|
|
43
|
+
|
|
44
|
+
cd examples
|
|
45
|
+
npm install
|
|
46
|
+
$env:QC_RPC_URL="https://public.rpc.quantumcoiapi.com:8545" (export for Linux)
|
|
47
|
+
node run-dex-flow-custom.js
|
|
48
|
+
|
|
49
|
+
### Step by step walkthrough
|
|
50
|
+
|
|
51
|
+
This walkthrough uses **pre-deployed** WQ, V2 Factory, and Swap Router. Do **not** deploy these contracts; use the Test Release (Dec 2025) addresses below.
|
|
52
|
+
|
|
53
|
+
**Test Release (Dec 2025) Contracts**
|
|
54
|
+
|
|
55
|
+
| Variable | Address |
|
|
56
|
+
|----------|---------|
|
|
57
|
+
| `WQ_CONTRACT_ADDRESS` | `0x0E49c26cd1ca19bF8ddA2C8985B96783288458754757F4C9E00a5439A7291628` |
|
|
58
|
+
| `V2_CORE_FACTORY_CONTRACT_ADDRESS` | `0xbbF45a1B60044669793B444eD01Eb33e03Bb8cf3c5b6ae7887B218D05C5Cbf1d` |
|
|
59
|
+
| `SWAP_ROUTER_V2_CONTRACT_ADDRESS` | `0x41323EF72662185f44a03ea0ad8094a0C9e925aB1102679D8e957e838054aac5` |
|
|
60
|
+
|
|
61
|
+
**Steps**
|
|
62
|
+
|
|
63
|
+
1. **Connect** — Initialize the SDK, create a `JsonRpcProvider` with your RPC URL and chain ID, load a `Wallet` (e.g. from encrypted JSON or private key). Attach the SDK contract wrappers to the deployed addresses:
|
|
64
|
+
- `WQ.connect(WQ_CONTRACT_ADDRESS, provider)` (or with signer for writes)
|
|
65
|
+
- `QuantumSwapV2Factory.connect(V2_CORE_FACTORY_CONTRACT_ADDRESS, provider)`
|
|
66
|
+
- `QuantumSwapV2Router02.connect(SWAP_ROUTER_V2_CONTRACT_ADDRESS, signer)` for router calls
|
|
67
|
+
|
|
68
|
+
2. **Deploy two ERC20 tokens** — Deploy two tokens that have initial supply and mint to the deployer (e.g. a SimpleERC20-style contract: `constructor(name, symbol, initialSupply)`). Use `ContractFactory` with the token ABI and bytecode, then `getDeployTransaction(...)` and `sendTransaction({ ...tx, gasLimit })` so deployment has enough gas. Record `tokenA` and `tokenB` contract addresses.
|
|
69
|
+
|
|
70
|
+
3. **Create a pair** — Call `factory.createPair(tokenAAddress, tokenBAddress)` (with a signer). Wait for the tx. Get the pair address with `factory.getPair(tokenAAddress, tokenBAddress)`.
|
|
71
|
+
|
|
72
|
+
4. **Add liquidity** — Approve the router to spend tokenA and tokenB (e.g. `tokenA.approve(routerAddress, amountADesired)` and same for tokenB). Call `router.addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline)` with a signer. Optionally verify pair reserves with `pair.getReserves()`.
|
|
73
|
+
|
|
74
|
+
5. **Swap token for token** — Approve the router to spend the input token. Call `router.swapExactTokensForTokens(amountIn, amountOutMin, [tokenIn, tokenOut], to, deadline)`. Check the recipient token balance before and after to confirm the swap.
|
|
75
|
+
|
|
76
|
+
6. **Swap ETH for token (optional)** — Wrap native currency: `wq.deposit({ value: amount })`. If there is no WQ–token pair yet, create it with `factory.createPair(wqAddress, tokenAddress)` and add liquidity via `router.addLiquidityETH(token, amountTokenDesired, amountTokenMin, amountETHMin, to, deadline, { value: ethAmount })`. Then call `router.swapExactETHForTokens(amountOutMin, [wqAddress, tokenAddress], to, deadline, { value: ethValue })` to swap native ETH for the token.
|
|
77
|
+
|
|
78
|
+
Runnable scripts that perform all steps above:
|
|
79
|
+
|
|
80
|
+
- **JavaScript:** [examples/run-dex-flow-custom.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.js)
|
|
81
|
+
- **TypeScript:** [examples/run-dex-flow-custom.ts](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/run-dex-flow-custom.ts)
|
|
82
|
+
|
|
83
|
+
Run with `QC_RPC_URL` set (and optionally `QC_CHAIN_ID`, or `QC_WALLET_JSON` + `QC_WALLET_PASSPHRASE` for your own wallet):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Use https://public.rpc.quantumcoinapi.com for mainnet
|
|
87
|
+
|
|
88
|
+
# JavaScript
|
|
89
|
+
QC_RPC_URL=http://your-rpc:8545 node examples/run-dex-flow-custom.js
|
|
90
|
+
|
|
91
|
+
# TypeScript (requires typescript and ts-node: npm install -D typescript ts-node)
|
|
92
|
+
QC_RPC_URL=http://your-rpc:8545 npx ts-node examples/run-dex-flow-custom.ts
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The same flow is covered as an E2E test in [test/e2e/dex-full-flow.e2e.test.js](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/dex-full-flow.e2e.test.js) (the test can optionally deploy WQ/Factory/Router when not using Test Release addresses).
|
|
96
|
+
|
|
97
|
+
Examples are generated per contract (e.g. [examples/deploy-<Contract>.js](https://github.com/quantumswapdex/QuantumSwap.js/tree/main/examples)).
|
|
98
|
+
|
|
99
|
+
## Contracts
|
|
100
|
+
|
|
101
|
+
- [`IERC20`](#ierc20)
|
|
102
|
+
- [`QuantumSwapV2ERC20`](#quantumswapv2erc20)
|
|
103
|
+
- [`QuantumSwapV2Factory`](#quantumswapv2factory)
|
|
104
|
+
- [`QuantumSwapV2Pair`](#quantumswapv2pair)
|
|
105
|
+
- [`QuantumSwapV2Router02`](#quantumswapv2router02)
|
|
106
|
+
- [`WQ`](#wq)
|
|
107
|
+
|
|
108
|
+
## IERC20
|
|
109
|
+
- **Exports**: `IERC20`, `IERC20__factory`
|
|
110
|
+
- **Constructor**: `constructor()`
|
|
111
|
+
### Files
|
|
112
|
+
- [`src/IERC20.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/IERC20.js)
|
|
113
|
+
- [`src/IERC20__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/IERC20__factory.js)
|
|
114
|
+
### Examples
|
|
115
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-IERC20.js)
|
|
116
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-IERC20.js)
|
|
117
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-IERC20.js)
|
|
118
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-IERC20.js)
|
|
119
|
+
### Tests
|
|
120
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/IERC20.e2e.test.js)
|
|
121
|
+
### Functions
|
|
122
|
+
- `allowance(address owner, address spender) view returns (uint256)`
|
|
123
|
+
- `approve(address spender, uint256 value) returns (bool)`
|
|
124
|
+
- `balanceOf(address owner) view returns (uint256)`
|
|
125
|
+
- `decimals() view returns (uint8)`
|
|
126
|
+
- `name() view returns (string)`
|
|
127
|
+
- `symbol() view returns (string)`
|
|
128
|
+
- `totalSupply() view returns (uint256)`
|
|
129
|
+
- `transfer(address to, uint256 value) returns (bool)`
|
|
130
|
+
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
131
|
+
### Events
|
|
132
|
+
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
133
|
+
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
134
|
+
### Errors
|
|
135
|
+
- (none)
|
|
136
|
+
## QuantumSwapV2ERC20
|
|
137
|
+
- **Exports**: `QuantumSwapV2ERC20`, `QuantumSwapV2ERC20__factory`
|
|
138
|
+
- **Constructor**: `constructor()`
|
|
139
|
+
### Files
|
|
140
|
+
- [`src/QuantumSwapV2ERC20.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2ERC20.js)
|
|
141
|
+
- [`src/QuantumSwapV2ERC20__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2ERC20__factory.js)
|
|
142
|
+
### Examples
|
|
143
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2ERC20.js)
|
|
144
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2ERC20.js)
|
|
145
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2ERC20.js)
|
|
146
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2ERC20.js)
|
|
147
|
+
### Tests
|
|
148
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2ERC20.e2e.test.js)
|
|
149
|
+
### Functions
|
|
150
|
+
- `allowance(address, address) view returns (uint256)`
|
|
151
|
+
- `approve(address spender, uint256 value) returns (bool)`
|
|
152
|
+
- `balanceOf(address) view returns (uint256)`
|
|
153
|
+
- `decimals() view returns (uint8)`
|
|
154
|
+
- `name() view returns (string)`
|
|
155
|
+
- `symbol() view returns (string)`
|
|
156
|
+
- `totalSupply() view returns (uint256)`
|
|
157
|
+
- `transfer(address to, uint256 value) returns (bool)`
|
|
158
|
+
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
159
|
+
### Events
|
|
160
|
+
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
161
|
+
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
162
|
+
### Errors
|
|
163
|
+
- (none)
|
|
164
|
+
## QuantumSwapV2Factory
|
|
165
|
+
- **Exports**: `QuantumSwapV2Factory`, `QuantumSwapV2Factory__factory`
|
|
166
|
+
- **Constructor**: `constructor(address _feeToSetter)`
|
|
167
|
+
### Files
|
|
168
|
+
- [`src/QuantumSwapV2Factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Factory.js)
|
|
169
|
+
- [`src/QuantumSwapV2Factory__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Factory__factory.js)
|
|
170
|
+
### Examples
|
|
171
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Factory.js)
|
|
172
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Factory.js)
|
|
173
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Factory.js)
|
|
174
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Factory.js)
|
|
175
|
+
### Tests
|
|
176
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Factory.e2e.test.js)
|
|
177
|
+
### Functions
|
|
178
|
+
- `allPairs(uint256) view returns (address)`
|
|
179
|
+
- `allPairsLength() view returns (uint256)`
|
|
180
|
+
- `createPair(address tokenA, address tokenB) returns (address)`
|
|
181
|
+
- `feeTo() view returns (address)`
|
|
182
|
+
- `feeToSetter() view returns (address)`
|
|
183
|
+
- `getPair(address, address) view returns (address)`
|
|
184
|
+
- `INIT_CODE_HASH() view returns (bytes32)`
|
|
185
|
+
- `setFeeTo(address _feeTo)`
|
|
186
|
+
- `setFeeToSetter(address _feeToSetter)`
|
|
187
|
+
### Events
|
|
188
|
+
- `PairCreated(address indexed token0, address indexed token1, address pair, uint256)`
|
|
189
|
+
### Errors
|
|
190
|
+
- (none)
|
|
191
|
+
## QuantumSwapV2Pair
|
|
192
|
+
- **Exports**: `QuantumSwapV2Pair`, `QuantumSwapV2Pair__factory`
|
|
193
|
+
- **Constructor**: `constructor()`
|
|
194
|
+
### Files
|
|
195
|
+
- [`src/QuantumSwapV2Pair.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Pair.js)
|
|
196
|
+
- [`src/QuantumSwapV2Pair__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Pair__factory.js)
|
|
197
|
+
### Examples
|
|
198
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Pair.js)
|
|
199
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Pair.js)
|
|
200
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Pair.js)
|
|
201
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Pair.js)
|
|
202
|
+
### Tests
|
|
203
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Pair.e2e.test.js)
|
|
204
|
+
### Functions
|
|
205
|
+
- `allowance(address, address) view returns (uint256)`
|
|
206
|
+
- `approve(address spender, uint256 value) returns (bool)`
|
|
207
|
+
- `balanceOf(address) view returns (uint256)`
|
|
208
|
+
- `burn(address to) returns (uint256, uint256)`
|
|
209
|
+
- `decimals() view returns (uint8)`
|
|
210
|
+
- `factory() view returns (address)`
|
|
211
|
+
- `getReserves() view returns (uint112, uint112, uint32)`
|
|
212
|
+
- `initialize(address _token0, address _token1)`
|
|
213
|
+
- `kLast() view returns (uint256)`
|
|
214
|
+
- `MINIMUM_LIQUIDITY() view returns (uint256)`
|
|
215
|
+
- `mint(address to) returns (uint256)`
|
|
216
|
+
- `name() view returns (string)`
|
|
217
|
+
- `price0CumulativeLast() view returns (uint256)`
|
|
218
|
+
- `price1CumulativeLast() view returns (uint256)`
|
|
219
|
+
- `skim(address to)`
|
|
220
|
+
- `swap(uint256 amount0Out, uint256 amount1Out, address to, bytes data)`
|
|
221
|
+
- `symbol() view returns (string)`
|
|
222
|
+
- `sync()`
|
|
223
|
+
- `token0() view returns (address)`
|
|
224
|
+
- `token1() view returns (address)`
|
|
225
|
+
- `totalSupply() view returns (uint256)`
|
|
226
|
+
- `transfer(address to, uint256 value) returns (bool)`
|
|
227
|
+
- `transferFrom(address from, address to, uint256 value) returns (bool)`
|
|
228
|
+
### Events
|
|
229
|
+
- `Approval(address indexed owner, address indexed spender, uint256 value)`
|
|
230
|
+
- `Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to)`
|
|
231
|
+
- `Mint(address indexed sender, uint256 amount0, uint256 amount1)`
|
|
232
|
+
- `Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to)`
|
|
233
|
+
- `Sync(uint112 reserve0, uint112 reserve1)`
|
|
234
|
+
- `Transfer(address indexed from, address indexed to, uint256 value)`
|
|
235
|
+
### Errors
|
|
236
|
+
- (none)
|
|
237
|
+
## QuantumSwapV2Router02
|
|
238
|
+
- **Exports**: `QuantumSwapV2Router02`, `QuantumSwapV2Router02__factory`
|
|
239
|
+
- **Constructor**: `constructor(address _factory, address _WETH)`
|
|
240
|
+
### Files
|
|
241
|
+
- [`src/QuantumSwapV2Router02.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Router02.js)
|
|
242
|
+
- [`src/QuantumSwapV2Router02__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/QuantumSwapV2Router02__factory.js)
|
|
243
|
+
### Examples
|
|
244
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-QuantumSwapV2Router02.js)
|
|
245
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-QuantumSwapV2Router02.js)
|
|
246
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-QuantumSwapV2Router02.js)
|
|
247
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-QuantumSwapV2Router02.js)
|
|
248
|
+
### Tests
|
|
249
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/QuantumSwapV2Router02.e2e.test.js)
|
|
250
|
+
### Functions
|
|
251
|
+
- `addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256, uint256, uint256)`
|
|
252
|
+
- `addLiquidityETH(address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) payable returns (uint256, uint256, uint256)`
|
|
253
|
+
- `factory() view returns (address)`
|
|
254
|
+
- `getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut) pure returns (uint256)`
|
|
255
|
+
- `getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) pure returns (uint256)`
|
|
256
|
+
- `getAmountsIn(uint256 amountOut, address[] path) view returns (uint256[])`
|
|
257
|
+
- `getAmountsOut(uint256 amountIn, address[] path) view returns (uint256[])`
|
|
258
|
+
- `quote(uint256 amountA, uint256 reserveA, uint256 reserveB) pure returns (uint256)`
|
|
259
|
+
- `removeLiquidity(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256, uint256)`
|
|
260
|
+
- `removeLiquidityETH(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) returns (uint256, uint256)`
|
|
261
|
+
- `removeLiquidityETHSupportingFeeOnTransferTokens(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) returns (uint256)`
|
|
262
|
+
- `swapETHForExactTokens(uint256 amountOut, address[] path, address to, uint256 deadline) payable returns (uint256[])`
|
|
263
|
+
- `swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable returns (uint256[])`
|
|
264
|
+
- `swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable`
|
|
265
|
+
- `swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
266
|
+
- `swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)`
|
|
267
|
+
- `swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
268
|
+
- `swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)`
|
|
269
|
+
- `swapTokensForExactETH(uint256 amountOut, uint256 amountInMax, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
270
|
+
- `swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] path, address to, uint256 deadline) returns (uint256[])`
|
|
271
|
+
- `WETH() view returns (address)`
|
|
272
|
+
### Events
|
|
273
|
+
- (none)
|
|
274
|
+
### Errors
|
|
275
|
+
- (none)
|
|
276
|
+
## WQ
|
|
277
|
+
- **Exports**: `WQ`, `WQ__factory`
|
|
278
|
+
- **Constructor**: `constructor()`
|
|
279
|
+
### Files
|
|
280
|
+
- [`src/WQ.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/WQ.js)
|
|
281
|
+
- [`src/WQ__factory.js`](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/src/WQ__factory.js)
|
|
282
|
+
### Examples
|
|
283
|
+
- [deploy](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/deploy-WQ.js)
|
|
284
|
+
- [read operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/read-operations-WQ.js)
|
|
285
|
+
- [write operations](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/write-operations-WQ.js)
|
|
286
|
+
- [events](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/examples/events-WQ.js)
|
|
287
|
+
### Tests
|
|
288
|
+
- [transactional test](https://github.com/quantumswapdex/QuantumSwap.js/blob/main/test/e2e/WQ.e2e.test.js)
|
|
289
|
+
### Functions
|
|
290
|
+
- `allowance(address, address) view returns (uint256)`
|
|
291
|
+
- `approve(address guy, uint256 wad) returns (bool)`
|
|
292
|
+
- `balanceOf(address) view returns (uint256)`
|
|
293
|
+
- `decimals() view returns (uint8)`
|
|
294
|
+
- `deposit() payable`
|
|
295
|
+
- `name() view returns (string)`
|
|
296
|
+
- `symbol() view returns (string)`
|
|
297
|
+
- `totalSupply() view returns (uint256)`
|
|
298
|
+
- `transfer(address dst, uint256 wad) returns (bool)`
|
|
299
|
+
- `transferFrom(address src, address dst, uint256 wad) returns (bool)`
|
|
300
|
+
- `withdraw(uint256 wad)`
|
|
301
|
+
### Events
|
|
302
|
+
- `Approval(address indexed src, address indexed guy, uint256 wad)`
|
|
303
|
+
- `Deposit(address indexed dst, uint256 wad)`
|
|
304
|
+
- `Transfer(address indexed src, address indexed dst, uint256 wad)`
|
|
305
|
+
- `Withdrawal(address indexed src, uint256 wad)`
|
|
306
|
+
### Errors
|
|
307
|
+
- (none)
|