quantumswap 0.0.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 (77) hide show
  1. package/.github/workflows/publish-npmjs.yaml +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +287 -0
  4. package/examples/_test-wallet.js +17 -0
  5. package/examples/deploy-IERC20.js +23 -0
  6. package/examples/deploy-QuantumSwapV2ERC20.js +23 -0
  7. package/examples/deploy-QuantumSwapV2Factory.js +23 -0
  8. package/examples/deploy-QuantumSwapV2Pair.js +23 -0
  9. package/examples/deploy-QuantumSwapV2Router02.js +23 -0
  10. package/examples/deploy-WQ.js +23 -0
  11. package/examples/events-IERC20.js +20 -0
  12. package/examples/events-QuantumSwapV2ERC20.js +20 -0
  13. package/examples/events-QuantumSwapV2Factory.js +20 -0
  14. package/examples/events-QuantumSwapV2Pair.js +20 -0
  15. package/examples/events-QuantumSwapV2Router02.js +20 -0
  16. package/examples/events-WQ.js +20 -0
  17. package/examples/offline-signing-IERC20.js +29 -0
  18. package/examples/offline-signing-QuantumSwapV2ERC20.js +29 -0
  19. package/examples/offline-signing-QuantumSwapV2Factory.js +29 -0
  20. package/examples/offline-signing-QuantumSwapV2Pair.js +29 -0
  21. package/examples/offline-signing-QuantumSwapV2Router02.js +29 -0
  22. package/examples/offline-signing-WQ.js +29 -0
  23. package/examples/read-operations-IERC20.js +19 -0
  24. package/examples/read-operations-QuantumSwapV2ERC20.js +19 -0
  25. package/examples/read-operations-QuantumSwapV2Factory.js +19 -0
  26. package/examples/read-operations-QuantumSwapV2Pair.js +19 -0
  27. package/examples/read-operations-QuantumSwapV2Router02.js +19 -0
  28. package/examples/read-operations-WQ.js +19 -0
  29. package/examples/walkthrough-dex-full-flow.js +226 -0
  30. package/examples/walkthrough-dex-full-flow.ts +231 -0
  31. package/examples/write-operations-IERC20.js +22 -0
  32. package/examples/write-operations-QuantumSwapV2ERC20.js +22 -0
  33. package/examples/write-operations-QuantumSwapV2Factory.js +22 -0
  34. package/examples/write-operations-QuantumSwapV2Pair.js +22 -0
  35. package/examples/write-operations-QuantumSwapV2Router02.js +22 -0
  36. package/examples/write-operations-WQ.js +22 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +45 -0
  39. package/package.json +35 -0
  40. package/src/IERC20.d.ts +24 -0
  41. package/src/IERC20.js +348 -0
  42. package/src/IERC20__factory.d.ts +10 -0
  43. package/src/IERC20__factory.js +29 -0
  44. package/src/QuantumSwapV2ERC20.d.ts +24 -0
  45. package/src/QuantumSwapV2ERC20.js +353 -0
  46. package/src/QuantumSwapV2ERC20__factory.d.ts +10 -0
  47. package/src/QuantumSwapV2ERC20__factory.js +29 -0
  48. package/src/QuantumSwapV2Factory.d.ts +24 -0
  49. package/src/QuantumSwapV2Factory.js +310 -0
  50. package/src/QuantumSwapV2Factory__factory.d.ts +10 -0
  51. package/src/QuantumSwapV2Factory__factory.js +29 -0
  52. package/src/QuantumSwapV2Pair.d.ts +44 -0
  53. package/src/QuantumSwapV2Pair.js +847 -0
  54. package/src/QuantumSwapV2Pair__factory.d.ts +10 -0
  55. package/src/QuantumSwapV2Pair__factory.js +29 -0
  56. package/src/QuantumSwapV2Router02.d.ts +47 -0
  57. package/src/QuantumSwapV2Router02.js +1109 -0
  58. package/src/QuantumSwapV2Router02__factory.d.ts +10 -0
  59. package/src/QuantumSwapV2Router02__factory.js +29 -0
  60. package/src/WQ.d.ts +28 -0
  61. package/src/WQ.js +435 -0
  62. package/src/WQ__factory.d.ts +10 -0
  63. package/src/WQ__factory.js +29 -0
  64. package/src/index.d.ts +14 -0
  65. package/src/index.js +15 -0
  66. package/src/quantumcoin-shims.d.ts +25 -0
  67. package/src/types.d.ts +3 -0
  68. package/src/types.js +3 -0
  69. package/test/e2e/IERC20.e2e.test.js +79 -0
  70. package/test/e2e/QuantumSwapV2ERC20.e2e.test.js +79 -0
  71. package/test/e2e/QuantumSwapV2Factory.e2e.test.js +79 -0
  72. package/test/e2e/QuantumSwapV2Pair.e2e.test.js +79 -0
  73. package/test/e2e/QuantumSwapV2Router02.e2e.test.js +79 -0
  74. package/test/e2e/WQ.e2e.test.js +79 -0
  75. package/test/e2e/all-contracts.e2e.test.js +103 -0
  76. package/test/e2e/dex-full-flow.e2e.test.js +353 -0
  77. package/tsconfig.json +14 -0
@@ -0,0 +1,353 @@
1
+ // Auto-generated by sdkgen
2
+ const { Contract } = require("quantumcoin");
3
+
4
+ /**
5
+ * QuantumSwapV2ERC20 - A typed contract interface for QuantumSwapV2ERC20
6
+ */
7
+ class QuantumSwapV2ERC20 extends Contract {
8
+ static abi = [
9
+ {
10
+ "inputs": [],
11
+ "stateMutability": "nonpayable",
12
+ "type": "constructor"
13
+ },
14
+ {
15
+ "anonymous": false,
16
+ "inputs": [
17
+ {
18
+ "indexed": true,
19
+ "internalType": "address",
20
+ "name": "owner",
21
+ "type": "address"
22
+ },
23
+ {
24
+ "indexed": true,
25
+ "internalType": "address",
26
+ "name": "spender",
27
+ "type": "address"
28
+ },
29
+ {
30
+ "indexed": false,
31
+ "internalType": "uint256",
32
+ "name": "value",
33
+ "type": "uint256"
34
+ }
35
+ ],
36
+ "name": "Approval",
37
+ "type": "event"
38
+ },
39
+ {
40
+ "anonymous": false,
41
+ "inputs": [
42
+ {
43
+ "indexed": true,
44
+ "internalType": "address",
45
+ "name": "from",
46
+ "type": "address"
47
+ },
48
+ {
49
+ "indexed": true,
50
+ "internalType": "address",
51
+ "name": "to",
52
+ "type": "address"
53
+ },
54
+ {
55
+ "indexed": false,
56
+ "internalType": "uint256",
57
+ "name": "value",
58
+ "type": "uint256"
59
+ }
60
+ ],
61
+ "name": "Transfer",
62
+ "type": "event"
63
+ },
64
+ {
65
+ "inputs": [
66
+ {
67
+ "internalType": "address",
68
+ "name": "",
69
+ "type": "address"
70
+ },
71
+ {
72
+ "internalType": "address",
73
+ "name": "",
74
+ "type": "address"
75
+ }
76
+ ],
77
+ "name": "allowance",
78
+ "outputs": [
79
+ {
80
+ "internalType": "uint256",
81
+ "name": "",
82
+ "type": "uint256"
83
+ }
84
+ ],
85
+ "stateMutability": "view",
86
+ "type": "function"
87
+ },
88
+ {
89
+ "inputs": [
90
+ {
91
+ "internalType": "address",
92
+ "name": "spender",
93
+ "type": "address"
94
+ },
95
+ {
96
+ "internalType": "uint256",
97
+ "name": "value",
98
+ "type": "uint256"
99
+ }
100
+ ],
101
+ "name": "approve",
102
+ "outputs": [
103
+ {
104
+ "internalType": "bool",
105
+ "name": "",
106
+ "type": "bool"
107
+ }
108
+ ],
109
+ "stateMutability": "nonpayable",
110
+ "type": "function"
111
+ },
112
+ {
113
+ "inputs": [
114
+ {
115
+ "internalType": "address",
116
+ "name": "",
117
+ "type": "address"
118
+ }
119
+ ],
120
+ "name": "balanceOf",
121
+ "outputs": [
122
+ {
123
+ "internalType": "uint256",
124
+ "name": "",
125
+ "type": "uint256"
126
+ }
127
+ ],
128
+ "stateMutability": "view",
129
+ "type": "function"
130
+ },
131
+ {
132
+ "inputs": [],
133
+ "name": "decimals",
134
+ "outputs": [
135
+ {
136
+ "internalType": "uint8",
137
+ "name": "",
138
+ "type": "uint8"
139
+ }
140
+ ],
141
+ "stateMutability": "view",
142
+ "type": "function"
143
+ },
144
+ {
145
+ "inputs": [],
146
+ "name": "name",
147
+ "outputs": [
148
+ {
149
+ "internalType": "string",
150
+ "name": "",
151
+ "type": "string"
152
+ }
153
+ ],
154
+ "stateMutability": "view",
155
+ "type": "function"
156
+ },
157
+ {
158
+ "inputs": [],
159
+ "name": "symbol",
160
+ "outputs": [
161
+ {
162
+ "internalType": "string",
163
+ "name": "",
164
+ "type": "string"
165
+ }
166
+ ],
167
+ "stateMutability": "view",
168
+ "type": "function"
169
+ },
170
+ {
171
+ "inputs": [],
172
+ "name": "totalSupply",
173
+ "outputs": [
174
+ {
175
+ "internalType": "uint256",
176
+ "name": "",
177
+ "type": "uint256"
178
+ }
179
+ ],
180
+ "stateMutability": "view",
181
+ "type": "function"
182
+ },
183
+ {
184
+ "inputs": [
185
+ {
186
+ "internalType": "address",
187
+ "name": "to",
188
+ "type": "address"
189
+ },
190
+ {
191
+ "internalType": "uint256",
192
+ "name": "value",
193
+ "type": "uint256"
194
+ }
195
+ ],
196
+ "name": "transfer",
197
+ "outputs": [
198
+ {
199
+ "internalType": "bool",
200
+ "name": "",
201
+ "type": "bool"
202
+ }
203
+ ],
204
+ "stateMutability": "nonpayable",
205
+ "type": "function"
206
+ },
207
+ {
208
+ "inputs": [
209
+ {
210
+ "internalType": "address",
211
+ "name": "from",
212
+ "type": "address"
213
+ },
214
+ {
215
+ "internalType": "address",
216
+ "name": "to",
217
+ "type": "address"
218
+ },
219
+ {
220
+ "internalType": "uint256",
221
+ "name": "value",
222
+ "type": "uint256"
223
+ }
224
+ ],
225
+ "name": "transferFrom",
226
+ "outputs": [
227
+ {
228
+ "internalType": "bool",
229
+ "name": "",
230
+ "type": "bool"
231
+ }
232
+ ],
233
+ "stateMutability": "nonpayable",
234
+ "type": "function"
235
+ }
236
+ ];
237
+ static bytecode = "0x608060405234801561001057600080fd5b50600046905050610765806100266000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce567146101df57806370a082311461020057806395d89b4114610242578063a9059cbb146102c5578063dd62ed3e1461031357610093565b806306fdde0314610098578063095ea7b31461011b57806318160ddd1461016957806323b872dd14610187575b600080fd5b6100a061035f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101516004803603604081101561013157600080fd5b810190808035906020019092919080359060200190929190505050610398565b60405180821515815260200191505060405180910390f35b6101716103af565b6040518082815260200191505060405180910390f35b6101c76004803603606081101561019d57600080fd5b810190808035906020019092919080359060200190929190803590602001909291905050506103b5565b60405180821515815260200191505060405180910390f35b6101e7610478565b604051808260ff16815260200191505060405180910390f35b61022c6004803603602081101561021657600080fd5b810190808035906020019092919050505061047d565b6040518082815260200191505060405180910390f35b61024a610495565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561028a57808201518184015260208101905061026f565b50505050905090810190601f1680156102b75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102fb600480360360408110156102db57600080fd5b8101908080359060200190929190803590602001909291905050506104ce565b60405180821515815260200191505060405180910390f35b6103496004803603604081101561032957600080fd5b8101908080359060200190929190803590602001909291905050506104e5565b6040518082815260200191505060405180910390f35b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b60006103a533848461050a565b6001905092915050565b60005481565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600260008681526020019081526020016000206000338152602001908152602001600020541461046257610439826002600087815260200190815260200160002060003381526020019081526020016000205461057190919063ffffffff16565b600260008681526020019081526020016000206000338152602001908152602001600020819055505b61046d8484846105f4565b600190509392505050565b601281565b60016020528060005260406000206000915090505481565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b60006104db3384846105f4565b6001905092915050565b6002602052816000526040600020602052806000526040600020600091509150505481565b806002600085815260200190815260200160002060008481526020019081526020016000208190555081837f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b60008282840391508111156105ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f64732d6d6174682d7375622d756e646572666c6f77000000000000000000000081525060200191505060405180910390fd5b92915050565b61061a81600160008681526020019081526020016000205461057190919063ffffffff16565b60016000858152602001908152602001600020819055506106578160016000858152602001908152602001600020546106ac90919063ffffffff16565b600160008481526020019081526020016000208190555081837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000828284019150811015610729576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f64732d6d6174682d6164642d6f766572666c6f7700000000000000000000000081525060200191505060405180910390fd5b9291505056fea2646970667358221220e48a2d0a171f8442d84eea3ddb68d815456dae50840418568f564b3e96ede40d64736f6c63430007060033";
238
+
239
+ static connect(address, runner) {
240
+ return new QuantumSwapV2ERC20(address, runner);
241
+ }
242
+
243
+ constructor(address, runner, _deployTx) {
244
+ super(address, QuantumSwapV2ERC20.abi, runner, QuantumSwapV2ERC20.bytecode);
245
+ this._deployTx = _deployTx;
246
+
247
+ // Typed populateTransaction helpers (offline signing / sendRawTransaction flows)
248
+ this.populateTransaction = {
249
+ approve: async (spender, value, overrides) => {
250
+ const data = this.interface.encodeFunctionData("approve", [spender, value]);
251
+ return { to: this.address, data, ...(overrides || {}) };
252
+ },
253
+ transfer: async (to, value, overrides) => {
254
+ const data = this.interface.encodeFunctionData("transfer", [to, value]);
255
+ return { to: this.address, data, ...(overrides || {}) };
256
+ },
257
+ transferFrom: async (from, to, value, overrides) => {
258
+ const data = this.interface.encodeFunctionData("transferFrom", [from, to, value]);
259
+ return { to: this.address, data, ...(overrides || {}) };
260
+ },
261
+ };
262
+ }
263
+
264
+ /**
265
+ * allowance
266
+ * @param {import("quantumcoin/types").AddressLike} arg
267
+ * @param {import("quantumcoin/types").AddressLike} arg
268
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
269
+ */
270
+ async allowance(arg0, arg1) {
271
+ const res = await this.call("allowance", [arg0, arg1]);
272
+ return Array.isArray(res) ? res[0] : res;
273
+ }
274
+
275
+ /**
276
+ * approve
277
+ * @param {import("quantumcoin/types").AddressLike} spender
278
+ * @param {import("quantumcoin/types").Uint256Like} value
279
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
280
+ */
281
+ async approve(spender, value, overrides) {
282
+ return this.send("approve", [spender, value], overrides);
283
+ }
284
+
285
+ /**
286
+ * balanceOf
287
+ * @param {import("quantumcoin/types").AddressLike} arg
288
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
289
+ */
290
+ async balanceOf(arg0) {
291
+ const res = await this.call("balanceOf", [arg0]);
292
+ return Array.isArray(res) ? res[0] : res;
293
+ }
294
+
295
+ /**
296
+ * decimals
297
+ * @returns {Promise<import("quantumcoin/types").Uint8>}
298
+ */
299
+ async decimals() {
300
+ const res = await this.call("decimals", []);
301
+ return Array.isArray(res) ? res[0] : res;
302
+ }
303
+
304
+ /**
305
+ * name
306
+ * @returns {Promise<string>}
307
+ */
308
+ async name() {
309
+ const res = await this.call("name", []);
310
+ return Array.isArray(res) ? res[0] : res;
311
+ }
312
+
313
+ /**
314
+ * symbol
315
+ * @returns {Promise<string>}
316
+ */
317
+ async symbol() {
318
+ const res = await this.call("symbol", []);
319
+ return Array.isArray(res) ? res[0] : res;
320
+ }
321
+
322
+ /**
323
+ * totalSupply
324
+ * @returns {Promise<import("quantumcoin/types").Uint256>}
325
+ */
326
+ async totalSupply() {
327
+ const res = await this.call("totalSupply", []);
328
+ return Array.isArray(res) ? res[0] : res;
329
+ }
330
+
331
+ /**
332
+ * transfer
333
+ * @param {import("quantumcoin/types").AddressLike} to
334
+ * @param {import("quantumcoin/types").Uint256Like} value
335
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
336
+ */
337
+ async transfer(to, value, overrides) {
338
+ return this.send("transfer", [to, value], overrides);
339
+ }
340
+
341
+ /**
342
+ * transferFrom
343
+ * @param {import("quantumcoin/types").AddressLike} from
344
+ * @param {import("quantumcoin/types").AddressLike} to
345
+ * @param {import("quantumcoin/types").Uint256Like} value
346
+ * @returns {Promise<import("quantumcoin").ContractTransactionResponse>}
347
+ */
348
+ async transferFrom(from, to, value, overrides) {
349
+ return this.send("transferFrom", [from, to, value], overrides);
350
+ }
351
+ }
352
+
353
+ module.exports = { QuantumSwapV2ERC20 };
@@ -0,0 +1,10 @@
1
+ // Auto-generated by sdkgen
2
+ import { ContractFactory, ContractRunner } from "quantumcoin";
3
+ import { QuantumSwapV2ERC20 } from "./QuantumSwapV2ERC20";
4
+ import type * as Types from "./types";
5
+
6
+ export declare class QuantumSwapV2ERC20__factory extends ContractFactory {
7
+ constructor(runner: ContractRunner);
8
+ deploy(overrides?: any): Promise<QuantumSwapV2ERC20>;
9
+ static connect(address: string, runner?: ContractRunner): QuantumSwapV2ERC20;
10
+ }
@@ -0,0 +1,29 @@
1
+ // Auto-generated by sdkgen
2
+ const { ContractFactory, getCreateAddress } = require("quantumcoin");
3
+ const { QuantumSwapV2ERC20 } = require("./QuantumSwapV2ERC20");
4
+
5
+ class QuantumSwapV2ERC20__factory extends ContractFactory {
6
+ constructor(runner) {
7
+ super(QuantumSwapV2ERC20.abi, QuantumSwapV2ERC20.bytecode, runner);
8
+ }
9
+
10
+ async deploy(overrides) {
11
+ const signer = this.signer;
12
+ if (!signer) { throw new Error("missing signer"); }
13
+ const from = signer.getAddress ? await signer.getAddress() : signer.address;
14
+ const provider = signer.provider;
15
+ if (!provider || !provider.getTransactionCount) { throw new Error("missing provider"); }
16
+ let nonce;
17
+ try { nonce = await provider.getTransactionCount(from, "pending"); } catch { nonce = await provider.getTransactionCount(from, "latest"); }
18
+ const address = getCreateAddress({ from, nonce });
19
+ const txReq = this.getDeployTransaction();
20
+ const tx = await signer.sendTransaction({ ...txReq, ...(overrides || {}), nonce });
21
+ return new QuantumSwapV2ERC20(address, signer, tx);
22
+ }
23
+
24
+ static connect(address, runner) {
25
+ return QuantumSwapV2ERC20.connect(address, runner);
26
+ }
27
+ }
28
+
29
+ module.exports = { QuantumSwapV2ERC20__factory };
@@ -0,0 +1,24 @@
1
+ // Auto-generated by sdkgen
2
+ import { Contract, ContractRunner, ContractTransactionResponse, TransactionResponse } from "quantumcoin";
3
+ import type * as Types from "./types";
4
+
5
+ export declare class QuantumSwapV2Factory extends Contract {
6
+ static readonly abi: readonly any[];
7
+ static readonly bytecode: string;
8
+ static connect(address: string, runner?: ContractRunner): QuantumSwapV2Factory;
9
+ constructor(address: string, runner?: ContractRunner, _deployTx?: TransactionResponse);
10
+ readonly populateTransaction: {
11
+ createPair(tokenA: Types.AddressLike, tokenB: Types.AddressLike, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
12
+ setFeeTo(_feeTo: Types.AddressLike, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
13
+ setFeeToSetter(_feeToSetter: Types.AddressLike, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
14
+ };
15
+ INIT_CODE_HASH(): Promise<Types.Bytes32>;
16
+ allPairs(arg0: Types.Uint256Like): Promise<Types.SolAddress>;
17
+ allPairsLength(): Promise<Types.Uint256>;
18
+ createPair(tokenA: Types.AddressLike, tokenB: Types.AddressLike, overrides?: any): Promise<ContractTransactionResponse>;
19
+ feeTo(): Promise<Types.SolAddress>;
20
+ feeToSetter(): Promise<Types.SolAddress>;
21
+ getPair(arg0: Types.AddressLike, arg1: Types.AddressLike): Promise<Types.SolAddress>;
22
+ setFeeTo(_feeTo: Types.AddressLike, overrides?: any): Promise<ContractTransactionResponse>;
23
+ setFeeToSetter(_feeToSetter: Types.AddressLike, overrides?: any): Promise<ContractTransactionResponse>;
24
+ }