Skip to content

Commit 4e117b6

Browse files
authored
Flash Mint contract for Set tokens with wrapped components (#116)
1 parent fc6df5c commit 4e117b6

19 files changed

+3649
-215
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,18 @@
33
"parser": "typescript",
44
"tabWidth": 2,
55
"trailingComma": "all",
6-
"arrowParens": "always"
6+
"arrowParens": "always",
7+
"overrides": [
8+
{
9+
"files": "*.sol",
10+
"options": {
11+
"printWidth": 100,
12+
"tabWidth": 2,
13+
"useTabs": false,
14+
"singleQuote": false,
15+
"bracketSpacing": true,
16+
"explicitTypes": "always"
17+
}
18+
}
19+
]
720
}

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ yarn
2828

2929
### Run Contract Tests
3030

31-
`yarn test` to run compiled contracts
31+
`yarn test` to run compiled contracts (executes on network localhost, you need to have `yarn chain` running)
3232

33-
OR `yarn test:clean` if contracts have been typings need to be updated
33+
OR `yarn test:clean` if contract typings need to be updated
34+
35+
### Run Integration Tests
36+
37+
`yarn chain:fork:ethereum` in one terminal to run chain fork. replace ethereum with polygon or optimism if needed, see package.json
38+
39+
`yarn test:integration:ethereum` in another terminal, replace chain again as needed
40+
41+
To run an individual test on e.g. a later block, use (replace path):
42+
`LATESTBLOCK=15508111 INTEGRATIONTEST=true VERBOSE=true npx hardhat test ./test/integration/ethereum/flashMintWrappedIntegration.spec.ts --network localhost`
3443

3544
### Run Coverage Report for Tests
3645

contracts/exchangeIssuance/DEXAdapter.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,13 @@ library DEXAdapter {
682682
returns (uint256)
683683
{
684684
_safeApprove(IERC20(_path[0]), address(_router), _amountIn);
685-
return _router.swapExactTokensForTokens(_amountIn, _minAmountOut, _path, address(this), block.timestamp)[1];
685+
// NOTE: The following was changed from always returning result at position [1] to returning the last element of the result array
686+
// With this change, the actual output is correctly returned also for multi-hop swaps
687+
// See https://github.com/IndexCoop/index-coop-smart-contracts/pull/116
688+
uint256[] memory result = _router.swapExactTokensForTokens(_amountIn, _minAmountOut, _path, address(this), block.timestamp);
689+
// result = uint[] memory The input token amount and all subsequent output token amounts.
690+
// we are usually only interested in the actual amount of the output token (so result element at the last place)
691+
return result[result.length-1];
686692
}
687693

688694
/**

0 commit comments

Comments
 (0)