Skip to content

Commit

Permalink
feat: FlashMintWrapped (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlattestWhite authored Sep 28, 2022
1 parent 905e8b8 commit bd70f3d
Show file tree
Hide file tree
Showing 19 changed files with 3,704 additions and 34 deletions.
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

15 changes: 14 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,18 @@
"parser": "typescript",
"tabWidth": 2,
"trailingComma": "all",
"arrowParens": "always"
"arrowParens": "always",
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
}
}
]
}
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ yarn

### Run Contract Tests

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

OR `yarn test:clean` if contracts have been typings need to be updated
OR `yarn test:clean` if contract typings need to be updated

### Run Integration Tests

`yarn chain:fork:ethereum` in one terminal to run chain fork. replace ethereum with polygon or optimism if needed, see package.json

`yarn test:integration:ethereum` in another terminal, replace chain again as needed

To run an individual test on e.g. a later block, use (replace path):
`LATESTBLOCK=15508111 INTEGRATIONTEST=true VERBOSE=true npx hardhat test ./test/integration/ethereum/flashMintWrappedIntegration.spec.ts --network localhost`

### Run Coverage Report for Tests

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

/**
Expand Down
Loading

0 comments on commit bd70f3d

Please sign in to comment.