Skip to content

Commit 905e8b8

Browse files
SnakePoisonNaoki Murano
andauthored
feat: FlashMintLeveragedForCompound
* Flash Mint Leveraged Compound Integration * compound integration * compound leverage module * fix compile version * fix lint error * test * Change test script * use const instead of let for ethAddress * use const for ethAddress * fix issues * Change test script * remove unused variables * Fixed coverage issue * Rmove CEther * remove comment * Fix smart contract issues * Complete Test Interation Script * Fixed lint error in compIntegration script * Improve Coverage Score * Update lint issue * Test ERC20 * Fixed Lint Errors * Fixed Lint Error * add AaveLendingPoolMock * add ExchangeIssuanceLeveragedCompMock.sol * Completed Coverage 100% * Remove console.log * Final update * Final update (remove comment) * refactor: ExhangeIssuance to FlashMint. Refactors Natspec and File names only. Formatted flashMintLeveragedForCompound with prettier. * Ref: ExchangeIssuance to FlashMint migration in unit test. * ref(compound): pass cEther in through constructor. * ref: reduce number of arguements to constructor. fixes coverage failure, stack too deep compilation error. * ref: remove unused variables. Co-authored-by: Naoki Murano <[email protected]>
1 parent 19d09e9 commit 905e8b8

19 files changed

+5995
-4
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Apache License
1+
Apache License
22
Version 2.0, January 2004
33
http://www.apache.org/licenses/
44

contracts/exchangeIssuance/FlashMintLeveragedForCompound.sol

Lines changed: 1299 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2022 Index Cooperative
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
14+
SPDX-License-Identifier: Apache License, Version 2.0
15+
*/
16+
pragma solidity 0.6.10;
17+
pragma experimental ABIEncoderV2;
18+
19+
contract CErc20Storage {
20+
/**
21+
* @notice Underlying asset for this CToken
22+
*/
23+
address public underlying;
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2022 Index Cooperative
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
14+
SPDX-License-Identifier: Apache License, Version 2.0
15+
*/
16+
pragma solidity 0.6.10;
17+
pragma experimental ABIEncoderV2;
18+
19+
contract CompoundLeverageModuleStorage {
20+
// Mapping of underlying to CToken. If ETH, then map WETH to cETH
21+
mapping(address => address) public underlyingToCToken;
22+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity 0.6.10;
3+
pragma experimental ABIEncoderV2;
4+
5+
interface ICErc20Delegator {
6+
function _acceptAdmin() external returns(uint256);
7+
function _addReserves(uint256 addAmount) external returns(uint256);
8+
function _reduceReserves(uint256 reduceAmount) external returns(uint256);
9+
function _renounceAdminRights() external returns(uint256);
10+
function _renounceFuseAdminRights() external returns(uint256);
11+
function _resignImplementation() external;
12+
function _setAdminFee(uint256 newAdminFeeMantissa) external returns(uint256);
13+
function _setComptroller(address newComptroller) external returns(uint256);
14+
function _setFuseFee() external returns(uint256);
15+
function _setInterestRateModel(address newInterestRateModel) external returns(uint256);
16+
function _setPendingAdmin(address newPendingAdmin) external returns(uint256);
17+
function _setReserveFactor(uint256 newReserveFactorMantissa) external returns(uint256);
18+
function _withdrawAdminFees(uint256 withdrawAmount) external returns(uint256);
19+
function _withdrawFuseFees(uint256 withdrawAmount) external returns(uint256);
20+
function accrualBlockNumber() external view returns(uint256);
21+
function accrueInterest() external returns(uint256);
22+
function admin() external view returns(address);
23+
function adminFeeMantissa() external view returns(uint256);
24+
function adminHasRights() external view returns(bool);
25+
function allowance(address owner, address spender) external view returns(uint256);
26+
function approve(address spender, uint256 amount) external returns(bool);
27+
function balanceOf(address owner) external view returns(uint256);
28+
function balanceOfUnderlying(address owner) external returns(uint256);
29+
function borrow(uint256 borrowAmount) external returns(uint256);
30+
function borrowBalanceCurrent(address account) external returns(uint256);
31+
function borrowBalanceStored(address account) external view returns(uint256);
32+
function borrowIndex() external view returns(uint256);
33+
function borrowRatePerBlock() external view returns(uint256);
34+
function comptroller() external view returns(address);
35+
function decimals() external view returns(uint8);
36+
function exchangeRateCurrent() external returns(uint256);
37+
function exchangeRateStored() external view returns(uint256);
38+
function fuseAdminHasRights() external view returns(bool);
39+
function fuseFeeMantissa() external view returns(uint256);
40+
function getAccountSnapshot(address account) external view returns(uint256, uint256, uint256, uint256);
41+
function getCash() external view returns(uint256);
42+
function implementation() external view returns(address);
43+
function initialize(address comptroller_, address interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, uint256 reserveFactorMantissa_, uint256 adminFeeMantissa_) external;
44+
function initialize(address underlying_, address comptroller_, address interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, uint256 reserveFactorMantissa_, uint256 adminFeeMantissa_) external;
45+
function interestRateModel() external view returns(address);
46+
function isCEther() external view returns(bool);
47+
function isCToken() external view returns(bool);
48+
function liquidateBorrow(address borrower, uint256 repayAmount, address cTokenCollateral) external returns(uint256);
49+
function mint(uint256 mintAmount) external returns(uint256);
50+
function name() external view returns(string memory);
51+
function pendingAdmin() external view returns(address);
52+
function redeem(uint256 redeemTokens) external returns(uint256);
53+
function redeemUnderlying(uint256 redeemAmount) external returns(uint256);
54+
function repayBorrow(uint256 repayAmount) external returns(uint256);
55+
function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns(uint256);
56+
function reserveFactorMantissa() external view returns(uint256);
57+
function seize(address liquidator, address borrower, uint256 seizeTokens) external returns(uint256);
58+
function supplyRatePerBlock() external view returns(uint256);
59+
function symbol() external view returns(string memory);
60+
function totalAdminFees() external view returns(uint256);
61+
function totalBorrows() external view returns(uint256);
62+
function totalBorrowsCurrent() external returns(uint256);
63+
function totalFuseFees() external view returns(uint256);
64+
function totalReserves() external view returns(uint256);
65+
function totalSupply() external view returns(uint256);
66+
function transfer(address dst, uint256 amount) external returns(bool);
67+
function transferFrom(address src, address dst, uint256 amount) external returns(bool);
68+
function underlying() external view returns(address);
69+
}

contracts/interfaces/ICEther.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity 0.6.10;
3+
pragma experimental ABIEncoderV2;
4+
5+
interface ICEther {
6+
function mint() external payable;
7+
function redeem(uint redeemTokens) external returns (uint);
8+
function redeemUnderlying(uint redeemAmount) external returns (uint);
9+
function borrow(uint borrowAmount) external returns (uint);
10+
function getCash() external view returns (uint);
11+
function exchangeRateStored() external view returns (uint);
12+
function exchangeRateCurrent() external returns (uint);
13+
function allowance(address owner, address spender) external view returns (uint256);
14+
function approve(address spender, uint256 amount) external returns (bool);
15+
receive() external payable;
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2021 Set Labs Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache License, Version 2.0
17+
*/
18+
pragma solidity 0.6.10;
19+
import { ISetToken } from "./ISetToken.sol";
20+
21+
interface ICompoundLeverageModule {
22+
function sync(ISetToken _setToken, bool _shouldAccrueInterest) external virtual;
23+
}

0 commit comments

Comments
 (0)