Skip to content

Commit c02b8d7

Browse files
author
Augusto Lemble
authored
Merge pull request #24 from levelkdev/develop
v0.3.2
2 parents 63ddd04 + 4fa1f7c commit c02b8d7

12 files changed

+582
-582
lines changed

.contracts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"rinkeby": {
3-
"router": "0xe304a7d1fe202bc092621ac95dd203bcb56c42ce"
3+
"router": "0x0ee602c11858f99aa48c7c0093a2d5f68316f05a"
44
}
55
}

build/Combined-Json.json

+520-520
Large diffs are not rendered by default.

build/DXswapLibrary.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"evm": {
44
"bytecode": {
55
"linkReferences": {},
6-
"object": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207c02a5364239f5435c4ed94ecc2bb039518c775d5c326e98b0916798cf1143a764736f6c63430006060033",
7-
"opcodes": "PUSH1 0x56 PUSH1 0x23 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH1 0x0 BYTE PUSH1 0x73 EQ PUSH1 0x16 JUMPI INVALID JUMPDEST ADDRESS PUSH1 0x0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH29 0x2A5364239F5435C4ED94ECC2BB039518C775D5C326E98B0916798CF11 NUMBER 0xA7 PUSH5 0x736F6C6343 STOP MOD MOD STOP CALLER ",
8-
"sourceMap": "112:4758:12:-:0;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24"
6+
"object": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122003aaa5d5a5b0fa41b8f0667c0b87713605a6d3fde5fe86e664d3270297134c5a64736f6c63430006060033",
7+
"opcodes": "PUSH1 0x56 PUSH1 0x23 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH1 0x0 BYTE PUSH1 0x73 EQ PUSH1 0x16 JUMPI INVALID JUMPDEST ADDRESS PUSH1 0x0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 SUB 0xAA 0xA5 0xD5 0xA5 0xB0 STATICCALL COINBASE 0xB8 CREATE PUSH7 0x7C0B87713605A6 0xD3 REVERT 0xE5 INVALID DUP7 0xE6 PUSH5 0xD327029713 0x4C GAS PUSH5 0x736F6C6343 STOP MOD MOD STOP CALLER ",
8+
"sourceMap": "112:4738:12:-:0;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24"
99
},
1010
"deployedBytecode": {
1111
"immutableReferences": {},
1212
"linkReferences": {},
13-
"object": "73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207c02a5364239f5435c4ed94ecc2bb039518c775d5c326e98b0916798cf1143a764736f6c63430006060033",
14-
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH29 0x2A5364239F5435C4ED94ECC2BB039518C775D5C326E98B0916798CF11 NUMBER 0xA7 PUSH5 0x736F6C6343 STOP MOD MOD STOP CALLER ",
15-
"sourceMap": "112:4758:12:-:0;;;;;;12:1:-1;9;2:12"
13+
"object": "73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122003aaa5d5a5b0fa41b8f0667c0b87713605a6d3fde5fe86e664d3270297134c5a64736f6c63430006060033",
14+
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 SUB 0xAA 0xA5 0xD5 0xA5 0xB0 STATICCALL COINBASE 0xB8 CREATE PUSH7 0x7C0B87713605A6 0xD3 REVERT 0xE5 INVALID DUP7 0xE6 PUSH5 0xD327029713 0x4C GAS PUSH5 0x736F6C6343 STOP MOD MOD STOP CALLER ",
15+
"sourceMap": "112:4738:12:-:0;;;;;;12:1:-1;9;2:12"
1616
}
1717
},
1818
"interface": [],
19-
"bytecode": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207c02a5364239f5435c4ed94ecc2bb039518c775d5c326e98b0916798cf1143a764736f6c63430006060033"
19+
"bytecode": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122003aaa5d5a5b0fa41b8f0667c0b87713605a6d3fde5fe86e664d3270297134c5a64736f6c63430006060033"
2020
}

build/DXswapRouter.json

+6-6
Large diffs are not rendered by default.

build/ExampleOracleSimple.json

+7-7
Large diffs are not rendered by default.

build/ExampleSlidingWindowOracle.json

+6-6
Large diffs are not rendered by default.

build/ExampleSwapToPrice.json

+6-6
Large diffs are not rendered by default.

contracts/libraries/DXswapLibrary.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ library DXswapLibrary {
1818
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
1919
(address token0, address token1) = sortTokens(tokenA, tokenB);
2020
pair = address(uint(keccak256(abi.encodePacked(
21-
hex'ff',
22-
factory,
23-
keccak256(abi.encodePacked(token0, token1)),
24-
hex'2db943b381c6ef706828ea5e89f480bd449d4d3a2b98e6da97b30d0eb41fb6d6' // init code hash
25-
))));
21+
hex'ff',
22+
factory,
23+
keccak256(abi.encodePacked(token0, token1)),
24+
hex'd306a548755b9295ee49cc729e13ca4a45e00199bbd890fa146da43a50571776' // init code hash
25+
))));
2626
}
2727

2828
// fetches and sorts the reserves for a pair

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"contracts"
1515
],
1616
"dependencies": {
17-
"dxswap-core": "git://github.com/levelkdev/dxswap-core.git#v0.3.0"
17+
"dxswap-core": "git://github.com/levelkdev/dxswap-core.git#v0.3.1"
1818
},
1919
"devDependencies": {
2020
"@types/chai": "^4.2.6",

test/DXswapRouter.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ describe('DXswapRouter', () => {
298298
const token0Amount = expandTo18Decimals(5)
299299
const token1Amount = expandTo18Decimals(10)
300300
const swapAmount = expandTo18Decimals(1)
301-
const expectedOutputAmount = bigNumberify('1664582812369759106')
301+
const expectedOutputAmount = bigNumberify('1663192997082117548')
302302

303303
beforeEach(async () => {
304304
await addLiquidity(token0Amount, token1Amount)
@@ -366,7 +366,7 @@ describe('DXswapRouter', () => {
366366
describe('swapTokensForExactTokens', () => {
367367
const token0Amount = expandTo18Decimals(5)
368368
const token1Amount = expandTo18Decimals(10)
369-
const expectedSwapAmount = bigNumberify('556390140766705614')
369+
const expectedSwapAmount = bigNumberify('556947925368978001')
370370
const outputAmount = expandTo18Decimals(1)
371371

372372
beforeEach(async () => {
@@ -417,7 +417,7 @@ describe('DXswapRouter', () => {
417417
const WETHPartnerAmount = expandTo18Decimals(10)
418418
const ETHAmount = expandTo18Decimals(5)
419419
const swapAmount = expandTo18Decimals(1)
420-
const expectedOutputAmount = bigNumberify('1664582812369759106')
420+
const expectedOutputAmount = bigNumberify('1663192997082117548')
421421

422422
beforeEach(async () => {
423423
await WETHPartner.transfer(WETHPair.address, WETHPartnerAmount)
@@ -510,7 +510,7 @@ describe('DXswapRouter', () => {
510510
describe('swapTokensForExactETH', () => {
511511
const WETHPartnerAmount = expandTo18Decimals(5)
512512
const ETHAmount = expandTo18Decimals(10)
513-
const expectedSwapAmount = bigNumberify('556390140766705614')
513+
const expectedSwapAmount = bigNumberify('556947925368978001')
514514
const outputAmount = expandTo18Decimals(1)
515515

516516
beforeEach(async () => {
@@ -579,7 +579,7 @@ describe('DXswapRouter', () => {
579579
const WETHPartnerAmount = expandTo18Decimals(5)
580580
const ETHAmount = expandTo18Decimals(10)
581581
const swapAmount = expandTo18Decimals(1)
582-
const expectedOutputAmount = bigNumberify('1664582812369759106')
582+
const expectedOutputAmount = bigNumberify('1663192997082117548')
583583

584584
beforeEach(async () => {
585585
await WETHPartner.transfer(WETHPair.address, WETHPartnerAmount)
@@ -646,7 +646,7 @@ describe('DXswapRouter', () => {
646646
describe('swapETHForExactTokens', () => {
647647
const WETHPartnerAmount = expandTo18Decimals(10)
648648
const ETHAmount = expandTo18Decimals(5)
649-
const expectedSwapAmount = bigNumberify('556390140766705614')
649+
const expectedSwapAmount = bigNumberify('556947925368978001')
650650
const outputAmount = expandTo18Decimals(1)
651651

652652
beforeEach(async () => {

test/ExampleSwapToPrice.spec.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ describe('ExampleSwapToPrice', () => {
118118
overrides
119119
)
120120
)
121-
// (1e19 + 533817599282230583) : (1e21 - 50604388022536152921) ~= 1:90
121+
// (1e19 + 529063791046788173) : (1e21 - 50128619708044703422) ~= 1:90
122122
.to.emit(token0, 'Transfer')
123-
.withArgs(wallet.address, swapToPriceExample.address, '533817599282230583')
123+
.withArgs(wallet.address, swapToPriceExample.address, '529063791046788173')
124124
.to.emit(token0, 'Approval')
125-
.withArgs(swapToPriceExample.address, router.address, '533817599282230583')
125+
.withArgs(swapToPriceExample.address, router.address, '529063791046788173')
126126
.to.emit(token0, 'Transfer')
127-
.withArgs(swapToPriceExample.address, pair.address, '533817599282230583')
127+
.withArgs(swapToPriceExample.address, pair.address, '529063791046788173')
128128
.to.emit(token1, 'Transfer')
129-
.withArgs(pair.address, wallet.address, '50604388022536152921')
129+
.withArgs(pair.address, wallet.address, '50128619708044703422')
130130
})
131131

132132
it('moves the price to 1:110', async () => {
@@ -143,15 +143,15 @@ describe('ExampleSwapToPrice', () => {
143143
overrides
144144
)
145145
)
146-
// (1e21 + 48094087466294086126) : (1e19 - 458215083214870988) ~= 1:110
146+
// (1e21 + 47616056844306438751) : (1e19 - 453433431741210547) ~= 1:110
147147
.to.emit(token1, 'Transfer')
148-
.withArgs(wallet.address, swapToPriceExample.address, '48094087466294086126')
148+
.withArgs(wallet.address, swapToPriceExample.address, '47616056844306438751')
149149
.to.emit(token1, 'Approval')
150-
.withArgs(swapToPriceExample.address, router.address, '48094087466294086126')
150+
.withArgs(swapToPriceExample.address, router.address, '47616056844306438751')
151151
.to.emit(token1, 'Transfer')
152-
.withArgs(swapToPriceExample.address, pair.address, '48094087466294086126')
152+
.withArgs(swapToPriceExample.address, pair.address, '47616056844306438751')
153153
.to.emit(token0, 'Transfer')
154-
.withArgs(pair.address, wallet.address, '458215083214870988')
154+
.withArgs(pair.address, wallet.address, '453433431741210547')
155155
})
156156

157157
it('reverse token order', async () => {
@@ -168,15 +168,15 @@ describe('ExampleSwapToPrice', () => {
168168
overrides
169169
)
170170
)
171-
// (1e21 + 48094087466294086126) : (1e19 - 458215083214870988) ~= 1:110
171+
// (1e21 + 47616056844306438751) : (1e19 - 453433431741210547) ~= 1:110
172172
.to.emit(token1, 'Transfer')
173-
.withArgs(wallet.address, swapToPriceExample.address, '48094087466294086126')
173+
.withArgs(wallet.address, swapToPriceExample.address, '47616056844306438751')
174174
.to.emit(token1, 'Approval')
175-
.withArgs(swapToPriceExample.address, router.address, '48094087466294086126')
175+
.withArgs(swapToPriceExample.address, router.address, '47616056844306438751')
176176
.to.emit(token1, 'Transfer')
177-
.withArgs(swapToPriceExample.address, pair.address, '48094087466294086126')
177+
.withArgs(swapToPriceExample.address, pair.address, '47616056844306438751')
178178
.to.emit(token0, 'Transfer')
179-
.withArgs(pair.address, wallet.address, '458215083214870988')
179+
.withArgs(pair.address, wallet.address, '453433431741210547')
180180
})
181181

182182
it('swap gas cost', async () => {

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1706,9 +1706,9 @@ duplexer3@^0.1.4:
17061706
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
17071707
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
17081708

1709-
"dxswap-core@git://github.com/levelkdev/dxswap-core.git#v0.3.0":
1709+
"dxswap-core@git://github.com/levelkdev/dxswap-core.git#v0.3.1":
17101710
version "0.3.0"
1711-
resolved "git://github.com/levelkdev/dxswap-core.git#eeefa874239307ca59c96341793560a0f3fa39d4"
1711+
resolved "git://github.com/levelkdev/dxswap-core.git#ea38ac67256e514eaf3acd0cfc84d7135e59e64e"
17121712
dependencies:
17131713
typescript "^3.9.5"
17141714

0 commit comments

Comments
 (0)