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

Feat/zap #344

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8bae565
feat(type): added zap type
Aug 18, 2022
31d963f
feat(hardhat): added compiler version
Aug 18, 2022
9598798
feat(zap): added datatypes
Aug 18, 2022
28122fb
feat(zap): added modified eip712
Aug 18, 2022
a322d11
feat(zap): added zapper contract
Aug 18, 2022
5325ee4
feat(test): added zapper test
Aug 18, 2022
eda7291
fix(eip712): added modified eip712 to incentivized erc20
Aug 19, 2022
9f16819
fix(eip712): added explanation to eip712 change
Aug 19, 2022
77fab5b
fix(eip712): change contract folder
Aug 19, 2022
f85501a
fix(datatypes): fixed param description
Aug 19, 2022
2a91684
fix(zapper): import iweth, add errors lib, add comments
Aug 19, 2022
ad91d71
feat(errors): added errors library
Aug 19, 2022
5214f27
feat(package): update prettier for revertstatement
Aug 19, 2022
9f90257
feat(zap): implemented diamond pattern
Aug 20, 2022
ceaacd0
feat(test): implemented diamond zap
Aug 20, 2022
2d40fef
feat(package): added solidstate contracts
Aug 20, 2022
32e7dfc
feat(swapper): added optyfiswapper submodule
Aug 24, 2022
079c899
fix(lib): libraries folder
Sep 16, 2022
810eaa8
fix(vault-interface): vault interface
Sep 16, 2022
80299e3
fix(zap): contracts imports
Sep 16, 2022
8be0f88
fix(zap): import ownable internal
Sep 19, 2022
d998a93
Update contracts/utils/EIP712.sol
0xhafa Sep 19, 2022
1a4733e
fix(zap-test): minor changes
Sep 19, 2022
039c986
fix(zap-test): refactored tests
Sep 19, 2022
f415df7
Merge branch 'feat/zap' of https://github.com/Opty-Fi/earn-protocol i…
Sep 19, 2022
26b14ea
feat(type): added zap type
Aug 18, 2022
3b4f2f0
feat(hardhat): added compiler version
Aug 18, 2022
f62deb6
feat(zap): added datatypes
Aug 18, 2022
540b782
feat(zap): added modified eip712
Aug 18, 2022
ca20242
feat(zap): added zapper contract
Aug 18, 2022
a055983
feat(test): added zapper test
Aug 18, 2022
0306760
fix(eip712): added modified eip712 to incentivized erc20
Aug 19, 2022
cc8bfbb
fix(eip712): added explanation to eip712 change
Aug 19, 2022
e582cd3
fix(eip712): change contract folder
Aug 19, 2022
7b15274
fix(datatypes): fixed param description
Aug 19, 2022
3e1a449
fix(zapper): import iweth, add errors lib, add comments
Aug 19, 2022
a6ae777
feat(errors): added errors library
Aug 19, 2022
5a3583e
feat(package): update prettier for revertstatement
Aug 19, 2022
cb9b392
feat(zap): implemented diamond pattern
Aug 20, 2022
76b4f47
feat(test): implemented diamond zap
Aug 20, 2022
a9738ba
feat(package): added solidstate contracts
Aug 20, 2022
c275565
feat(swapper): added optyfiswapper submodule
Aug 24, 2022
79302dd
fix(lib): libraries folder
Sep 16, 2022
48d532d
fix(vault-interface): vault interface
Sep 16, 2022
aa3e221
fix(zap): contracts imports
Sep 16, 2022
7af1a29
fix(zap): import ownable internal
Sep 19, 2022
7f4c2b7
fix(zap-test): minor changes
Sep 19, 2022
09c6823
fix(zap-test): refactored tests
Sep 19, 2022
d3aac97
feat(rebase): rebase
Sep 19, 2022
e54463b
fix(submodule): submodule import
Sep 19, 2022
199b7ca
fix(submodule): submodule import
Sep 19, 2022
4409b7e
fix(submodule): submodule import
Sep 19, 2022
b49929e
fix(submodule): submodule import
Sep 19, 2022
317e635
Merge branch 'feat/harvest' into feat/zap
Sep 19, 2022
c2c700e
fix(zap-test): refactor permit
Sep 19, 2022
9e7167d
Merge branch 'feat/harvest' into feat/zap
Sep 21, 2022
8914f34
fix(vault): remove whitelist codes
Sep 21, 2022
3ffae50
feat(zap): add proof to storage and remove whitelist code param
Sep 21, 2022
c66e76a
fix(test): fixed tests removing whitelist code and new vault risk pro…
Sep 21, 2022
894638e
Merge branch 'feat/harvest' into feat/zap
Sep 21, 2022
3bfdafa
fix(zap test): fix permit
Sep 21, 2022
7ecbf76
Merge branch 'feat/harvest' into feat/zap
Sep 22, 2022
a4dc1f6
fix(yarn): update yarn lock
Sep 22, 2022
e765e76
fix(lint): ignore swapper
Sep 22, 2022
b90db76
fix(yarn lock): fix prettier version
Sep 22, 2022
ab034ac
fix(test): rename
Sep 22, 2022
80b5497
fix(prettier): ignore zap
Sep 22, 2022
0c606c5
fix(yarn lock): yarn lock
Sep 22, 2022
a2e4973
fix(zap params): remove accounts proof
Sep 22, 2022
12dcdd0
feat(test): test set merkle proof
Sep 22, 2022
26d0b26
fix(deploy): aave v1 deployment
Sep 22, 2022
6ff329a
Merge branch 'feat/harvest' into feat/zap
Sep 23, 2022
e5ebd26
fix(submodule): update team-defi-adapters commit
Sep 23, 2022
a573a48
fix(deploy): aave v1 deployment
Sep 23, 2022
ce6e222
fix(submodules): update submodules commit
Sep 23, 2022
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ specification_docs/
deployments/
contracts/protocol/earn-protocol-configuration
contracts/protocol/adapters
contracts/protocol/optyfi-swapper
# files
.solcover.js
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
[submodule "contracts/protocol/adapters/ethereum/sushiswap-pool-adapter-ethereum"]
path = contracts/protocol/adapters/ethereum/sushiswap-pool-adapter-ethereum
url = git@github.com:Opty-Fi/sushiswap-pool-adapter-ethereum.git
[submodule "contracts/protocol/optyfi-swapper"]
path = contracts/protocol/optyfi-swapper
url = git@github.com:Opty-Fi/optyfi-swapper.git
branch = swap
[submodule "contracts/protocol/adapters/ethereum/team-defi-adapters"]
path = contracts/protocol/adapters/ethereum/team-defi-adapters
url = git@github.com:Opty-Fi/team-defi-adapters.git
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
**/specification_docs
contracts/protocol/earn-protocol-configuration
contracts/protocol/adapters
contracts/protocol/optyfi-swapper
contracts/protocol/zap

# files
*.env
Expand Down
4 changes: 3 additions & 1 deletion .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ contracts/utils/
contracts/dependencies/
contracts/mocks/
contracts/protocol/earn-protocol-configuration
contracts/protocol/adapters
contracts/protocol/adapters
contracts/protocol/optyfi-swapper
contracts/protocol/zap
1 change: 1 addition & 0 deletions contracts/protocol/optyfi-swapper
Submodule optyfi-swapper added at 4c9fab
55 changes: 55 additions & 0 deletions contracts/protocol/zap/IZap.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//SPDX-license-identifier: MIT
pragma solidity ^0.8.15;

import { DataTypes } from "./lib/DataTypes.sol";
import { ZapStorage } from "./ZapStorage.sol";

/**
* @title OptyFiZapper interface
* @author OptyFi
*/
interface IZap {
/**
* @notice performs an arbitrary swap of a given token or ETH to deposit in a OptyFi Vault
* @param _token the address of the input token
* @param _amount input token amount to deposit
* @param _permitParams ERC2612 permit params
* @param _zapParams the zapParams for the zap to be performed
* @return the shares received from the vault deposit
*/
function zapIn(
address _token,
uint256 _amount,
bytes memory _permitParams,
DataTypes.ZapData memory _zapParams
) external payable returns (uint256);

/**
* @notice redeems the vault shares and performs an arbitrary swap
* from the OptyFi Vault underlying token to any given token
* @param _token the address of the input token
* @param _amount input token amount to deposit
* @param _permitParams ERC2612 permit params
* @param _zapParams the zapParams for the zap to be performed
* @return the amount of output tokens received
*/
function zapOut(
address _token,
uint256 _amount,
bytes memory _permitParams,
DataTypes.ZapData memory _zapParams
) external returns (uint256);

/**
* @notice set swapper address
* @param _swapper swapper address
*/
function setSwapper(address _swapper) external;

/**
* @notice set the zap contract merkle proof to deposit and withdraw on vault
* @param _vault address of the target vault
* @param _merkleProof zapper contract merkle proof
*/
function setMerkleProof(address _vault, bytes32[] memory _merkleProof) external;
}
20 changes: 20 additions & 0 deletions contracts/protocol/zap/IZapView.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//SPDX-license-identifier: MIT
pragma solidity ^0.8.15;

import { ISwapper } from "../optyfi-swapper/contracts/swap/ISwapper.sol";

/**
* @title ZapperView interface
* @author OptyFi
*/
interface IZapView {
/**
* @notice get swapper address
*/
function getSwapper() external view returns (ISwapper);

/**
* @notice get merkle proof on a given vault
*/
function getMerkleProof(address _vault) external view returns (bytes32[] memory);
}
16 changes: 16 additions & 0 deletions contracts/protocol/zap/OptyFiZapper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//SPDX-license-identifier: MIT
pragma solidity ^0.8.15;

import { SolidStateDiamond } from "@solidstate/contracts/proxy/diamond/SolidStateDiamond.sol";
import { ISwapper } from "../optyfi-swapper/contracts/swap/ISwapper.sol";
import { ZapStorage } from "./ZapStorage.sol";

/**
* @title Diamond proxy for OptyFiZapper
* @author OptyFi
*/
contract OptyFiZapper is SolidStateDiamond {
constructor(address _swapper) {
ZapStorage.layout().swapper = ISwapper(_swapper);
}
}
67 changes: 67 additions & 0 deletions contracts/protocol/zap/Zap.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//SPDX-license-identifier: MIT
pragma solidity ^0.8.15;

// helper contracts
import { ZapInternal } from "./ZapInternal.sol";
import { OwnableInternal } from "@solidstate/contracts/access/ownable/OwnableInternal.sol";

// libraries
import { DataTypes } from "./lib/DataTypes.sol";
import { ZapStorage } from "./ZapStorage.sol";

// interfaces
import { IZap } from "./IZap.sol";

/**
* @title Zap
* @author OptyFi
*/
contract Zap is IZap, ZapInternal, OwnableInternal {
using ZapStorage for ZapStorage.Layout;

/**
* @inheritdoc IZap
*/
function zapIn(
address _token,
uint256 _amount,
bytes memory _permitParams,
DataTypes.ZapData memory _zapParams
) external payable override returns (uint256 sharesReceived) {
ZapStorage.Layout storage _l = ZapStorage.layout();

sharesReceived = _zapIn(_l, _token, _amount, _permitParams, _zapParams);
}

/**
* @inheritdoc IZap
*/
function zapOut(
address _token,
uint256 _amount,
bytes memory _permitParams,
DataTypes.ZapData memory _zapParams
) external override returns (uint256 receivedAmount) {
ZapStorage.Layout storage _l = ZapStorage.layout();

receivedAmount = _zapOut(_l, _token, _amount, _permitParams, _zapParams);
}

/**
* @inheritdoc IZap
*/
function setSwapper(address _swapper) external override onlyOwner {
ZapStorage.Layout storage _l = ZapStorage.layout();

_setSwapper(_l, _swapper);
}

/**
* @inheritdoc IZap
*/
function setMerkleProof(address _vault, bytes32[] memory _merkleProof) external override onlyOwner {
ZapStorage.Layout storage _l = ZapStorage.layout();

_setMerkleProof(_l, _vault, _merkleProof);
}
}
Loading