Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlashMintLeveraged: Support for fixed input Issuance #169

Merged
merged 49 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
967db96
Copy paste FlashMintLeveraged as starting point
ckoopmann Apr 11, 2024
00b09b8
Fix tests
ckoopmann Apr 11, 2024
28d49af
Remove debug logs
ckoopmann Apr 11, 2024
9f57430
Correct wrong eth logic, still failing because eth is sent back prema…
ckoopmann Apr 11, 2024
893b1b7
Fix lint failure
ckoopmann Apr 11, 2024
196f409
Fix eth issuance by adjusting handling of input token, only paying ba…
ckoopmann Apr 12, 2024
93de35d
Fix fixedSetAmount issuance method and add related tests
ckoopmann Apr 12, 2024
032ce1e
Add redemExactSet tests back in
ckoopmann Apr 12, 2024
7f948fa
Adjust redemption methods
ckoopmann Apr 12, 2024
e9794b8
First version of exact output redemption
ckoopmann Apr 12, 2024
2daa061
Add redemSetForExactETH method
ckoopmann Apr 12, 2024
4f53857
Fix fixedOutputRedeem methods
ckoopmann Apr 12, 2024
bbcf683
copy paste ethereum integration test to new arbitrum integration test…
ckoopmann Apr 17, 2024
4c9358c
Adjust arbitrum integration test addresses
ckoopmann Apr 17, 2024
156649c
Fix arbitrum integration test setup
ckoopmann Apr 18, 2024
015d966
More test fixes
ckoopmann Apr 18, 2024
f39b49a
Arbitrum tests green
ckoopmann Apr 18, 2024
80b32a3
Add arbitrum integration tests to ci
ckoopmann Apr 18, 2024
a5a1bbd
Set Arbitrum rpc url in env variables
ckoopmann Apr 18, 2024
55b0ba3
update solidity-coverage
ckoopmann Apr 18, 2024
11bc4ed
Remove ethereum integration tests for flashmintextended
ckoopmann Apr 18, 2024
6b6c145
Return excess eth in issueSetFromExactETH
ckoopmann Apr 18, 2024
31d9d30
Swap Input Token to ETH
ckoopmann Apr 19, 2024
e97db32
Add swap data to ETH for redeem method
ckoopmann Apr 19, 2024
d56efca
Temporarily comment out non-integration tests
ckoopmann Apr 19, 2024
2ceea63
Contract fixes
ckoopmann Apr 19, 2024
4af01df
Fix test
ckoopmann Apr 19, 2024
e7eefaa
More contract changes
ckoopmann Apr 19, 2024
e27eb1d
Return amount of set token obtained from fixed input / output methods
ckoopmann Apr 19, 2024
e4c6aa9
Add maxIterations check
ckoopmann Apr 19, 2024
ae2cae1
Add docstring comments and fix maxIterations check
ckoopmann Apr 19, 2024
8a051bc
more docstrings
ckoopmann Apr 19, 2024
83577c6
Test issuance / redemption from / to usdc
ckoopmann Apr 21, 2024
1209e57
Temporarily comment out polygon tests
ckoopmann Apr 21, 2024
856d410
Add maxGasRebate to protect against misconfiguration
ckoopmann Apr 22, 2024
5c9c370
Fix contract bug regarding eth rebate opt out
ckoopmann Apr 22, 2024
b9dd6b6
Extend tests
ckoopmann Apr 22, 2024
ecbf733
Re-Trigger CI
ckoopmann Apr 22, 2024
c21607c
Use node 20 in github actions
ckoopmann Apr 22, 2024
32344ca
Bump hardhat version
ckoopmann Apr 22, 2024
8dafecd
Update circleci node version
ckoopmann Apr 22, 2024
79c0a62
fix tests
ckoopmann Apr 22, 2024
1e49c97
fix tests
ckoopmann Apr 22, 2024
7ba9c79
Deactivate optimism tests
ckoopmann Apr 22, 2024
7bab9d8
only run optimistic auction rebalance tests in eth integration pipeline
ckoopmann Apr 22, 2024
6564839
fix tests
ckoopmann Apr 22, 2024
3dbaa24
Inline doc comment
ckoopmann Apr 22, 2024
53061f9
Remove test step from publish workflow
ckoopmann Apr 22, 2024
9fdae37
Fix tests
ckoopmann Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 57 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
checkout_and_compile:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- checkout
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
- ~/index-coop-smart-contracts
test:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
parallelism: 2
steps:
Expand All @@ -60,7 +60,7 @@ jobs:

test_integration_polygon:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- setup_remote_docker:
Expand All @@ -83,7 +83,7 @@ jobs:

test_integration_optimism:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- setup_remote_docker:
Expand All @@ -106,7 +106,7 @@ jobs:

test_integration_ethereum:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- setup_remote_docker:
Expand All @@ -129,7 +129,7 @@ jobs:

coverage:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
parallelism: 2
steps:
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:

report_coverage:
docker:
- image: cimg/node:16.18
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- attach_workspace:
Expand All @@ -184,26 +184,63 @@ jobs:
command: |
cat coverage/lcov.info | ./node_modules/.bin/coveralls

test_integration_arbitrum:
docker:
- image: cimg/node:20.12.2
working_directory: ~/index-coop-smart-contracts
steps:
- setup_remote_docker:
docker_layer_caching: false
- run:
name: Fetch solc version
command: docker pull ethereum/solc:0.6.10
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- run:
name: Test RPC
command: yarn chain:fork:arbitrum
environment:
ARBITRUM_RPC_URL: https://arb-mainnet.g.alchemy.com/v2/NpgutFt2TfCFgUsHixNBsyoIkdgfg6tH
NETWORK: arbitrum
FORK: TRUE
background: true
- run:
name: Hardhat Test
environment:
ARBITRUM_RPC_URL: https://arb-mainnet.g.alchemy.com/v2/NpgutFt2TfCFgUsHixNBsyoIkdgfg6tH
NETWORK: arbitrum
FORK: TRUE
command: yarn run test:integration:arbitrum

workflows:
version: 2
build-and-test:
jobs:
- checkout_and_compile
- test:
requires:
- checkout_and_compile
# TODO: Comment back in when adding a new non-integration test (and use .only() to avoid rerunning all the old tests)
# - test:
# requires:
# - checkout_and_compile
- test_integration_ethereum:
requires:
- checkout_and_compile
- test_integration_polygon:
requires:
- checkout_and_compile
- test_integration_optimism:
# TODO: Reactivate when developing new contract on polygon (and use .only() to avoid rerunning all the old tests)
# - test_integration_polygon:
# requires:
# - checkout_and_compile
# TODO: Reactivate when developing new contract on optimism (and use .only() to avoid rerunning all the old tests)
# - test_integration_optimism:
# requires:
# - checkout_and_compile
- test_integration_arbitrum:
requires:
- checkout_and_compile
- coverage:
requires:
- checkout_and_compile
- report_coverage:
requires:
- coverage
# - coverage:
# requires:
# - checkout_and_compile
# - report_coverage:
# requires:
# - coverage
8 changes: 2 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: copy env
run: cp .env.default .env
- name: install
run: yarn
- name: build
run: yarn build
- name: test
run: |
yarn chain &
yarn test

publish:
runs-on: ubuntu-latest
Expand All @@ -34,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: copy env
run: cp .env.default .env
- name: install
Expand Down
4 changes: 2 additions & 2 deletions contracts/exchangeIssuance/DEXAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ library DEXAdapter {
external
returns (uint256)
{
if (_swapData.path[0] == _swapData.path[_swapData.path.length -1]) {
if (_swapData.path.length == 0 || _swapData.path[0] == _swapData.path[_swapData.path.length -1]) {
return _amountIn;
}

Expand Down Expand Up @@ -151,7 +151,7 @@ library DEXAdapter {
external
returns (uint256 amountIn)
{
if (_swapData.path[0] == _swapData.path[_swapData.path.length -1]) {
if (_swapData.path.length == 0 || _swapData.path[0] == _swapData.path[_swapData.path.length -1]) {
return _amountOut;
}

Expand Down
9 changes: 9 additions & 0 deletions contracts/exchangeIssuance/FlashMintLeveraged.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { DEXAdapter } from "./DEXAdapter.sol";
import {IVault, IFlashLoanRecipient} from "../interfaces/external/balancer-v2/IVault.sol";
import {IPool} from "../interfaces/IPool.sol";


/**
* @title FlashMintLeveraged
* @author Index Coop
Expand Down Expand Up @@ -284,6 +285,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapDataOutputToken
)
external
virtual
nonReentrant
{
_initiateRedemption(
Expand Down Expand Up @@ -315,6 +317,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapDataOutputToken
)
external
virtual
nonReentrant
{
_initiateRedemption(
Expand Down Expand Up @@ -346,6 +349,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapDataInputToken
)
external
virtual
nonReentrant
{
_initiateIssuance(
Expand Down Expand Up @@ -373,6 +377,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapDataInputToken
)
external
virtual
payable
nonReentrant
{
Expand Down Expand Up @@ -784,6 +789,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapData
)
internal
virtual
returns (uint256)
{
if(address(_outputToken) == _collateralToken){
Expand Down Expand Up @@ -820,6 +826,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapData
)
internal
virtual
isValidPath(_swapData.path, _collateralToken, addresses.weth)
returns(uint256)
{
Expand Down Expand Up @@ -958,6 +965,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
DEXAdapter.SwapData memory _swapData
)
internal
virtual
returns (uint256)
{
if(address(_inputToken) == _collateralToken){
Expand Down Expand Up @@ -998,6 +1006,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{

)
internal
virtual
returns(uint256)
{
IWETH(addresses.weth).deposit{value: _maxAmountEth}();
Expand Down
Loading
Loading