Skip to content

Commit dda2330

Browse files
committed
first commit
0 parents  commit dda2330

File tree

1,650 files changed

+260942
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,650 files changed

+260942
-0
lines changed

README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# WrapMe
2+
3+
A simple ERC20 wrapper interface to fungiblize liquidity mining incentives and autocompound rewards.
4+
5+
## Overview
6+
7+
Yield bearing tokens (i.e., Uni LP, 3crv, aTokens, etc.) are (obviously) fungible but as DeFi building blocks have increased in complexity, additional incentives provided to holders and stakers of yield bearing tokens often lose it's fungibility characteristics. This simple wrapper provides 3 primary features:
8+
9+
1) Static accounting of monotonically increasing rebasing tokens. (e.g., aTokens). This allows protocols to abstract out the additional accounting overhead of rebasing tokens into this wrapper contract.
10+
2) Receiving external liquidity mining rewards beyond the base yield. This wrapper natively accepts rewards denominated in ERC20 tokens and native assets like ETH or WAVAX. This wrapper also provides a base implementation that allows arbitrary function calls to staking contracts to withdraw rewards into the wrapper.
11+
3) Built in autocompounding of Reward Token -> Underlying Token. This wrapper inherits a naive router implementation that not only swaps base level ERC-20 assets across DEXs but also integrates the final step of converting a base ERC20 into the underlying yield bearing asset. It currently supports swaps into UniV2-like LP tokens, aTokens, Compound-like tokens and will support Curve LP tokens and more.
12+
13+
## Blueprint
14+
15+
```ml
16+
17+
contracts
18+
└─ src
19+
├─ Vault.sol — "Base implementation of the wrapper. Inherit this contract to implement custom integrations for calling rewards"
20+
├─ Router.sol — "Naive router implementation. Routes for each Reward Token -> Underlying need to be hardcoded upon deployment"
21+
├─ Lever.sol — "Simple router inheritor to expose swapping functionality"
22+
└─ integrations
23+
├─ aaveVault.sol - "Adds additional functionality to claim rewards from AAVE Incentive controller. Also takes a cut from underlying yield"
24+
├─ compVault.sol - "Adds additional functionality to claim rewards from Comptroller. Also takes a cut from underlying yield"
25+
├─ CRVVault.sol - "Handles depositing and withdrawing from a liquidity gauge for CRV LP tokens"
26+
├─ JLPVault.sol - "Handles depositing and withdrawal into Trader Joe MasterChef strategies"
27+
└─ sJOEVault.sol - "Handles depositing and withdrawal into Trader Joe sJOE staking"
28+
29+
```
30+
31+
## Development
32+
33+
**Install Foundry**
34+
```https://github.com/gakonst/foundry```
35+
36+
37+
**Building**
38+
```
39+
cd contracts
40+
forge update
41+
forge build
42+
```
43+
44+
**Testing**
45+
```
46+
cd contracts
47+
forge test --fork-url="https://api.avax.network/ext/bc/C/rpc" --fork-block-number=12435550
48+
```
49+
50+
## License
51+
52+
[AGPL-3.0-only]
53+
54+
## Disclaimer
55+
56+
_These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk._

contracts/.DS_Store

6 KB
Binary file not shown.

contracts/foundry.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[default]
2+
src = 'src'
3+
out = 'out'
4+
libs = ['lib']
5+
remappings = ['solmate/=lib/solmate/src/','ds-test/=lib/ds-test/src/', 'openzeppelin/=lib/openzeppelin-contracts/','openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts']
6+
optimizer = true # enable or disable the solc optimizer
7+
optimizer_runs = 4000
8+
verbosity = 3
9+
10+
# See more config options https://github.com/gakonst/foundry/tree/master/config

contracts/lib/.DS_Store

6 KB
Binary file not shown.

contracts/lib/ds-test/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.dapple
2+
/build
3+
/out

contracts/lib/ds-test/LICENSE

+674
Large diffs are not rendered by default.

contracts/lib/ds-test/Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all:; dapp build
2+
3+
test:
4+
-dapp --use solc:0.4.23 build
5+
-dapp --use solc:0.4.26 build
6+
-dapp --use solc:0.5.17 build
7+
-dapp --use solc:0.6.12 build
8+
-dapp --use solc:0.7.5 build
9+
10+
demo:
11+
DAPP_SRC=demo dapp --use solc:0.7.5 build
12+
-hevm dapp-test --verbose 3
13+
14+
.PHONY: test demo

contracts/lib/ds-test/default.nix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{ solidityPackage, dappsys }: solidityPackage {
2+
name = "ds-test";
3+
src = ./src;
4+
}

contracts/lib/ds-test/demo/demo.sol

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity >=0.4.23;
3+
4+
import "../src/test.sol";
5+
6+
contract DemoTest is DSTest {
7+
function test_this() public pure {
8+
require(true);
9+
}
10+
function test_logs() public {
11+
emit log("-- log(string)");
12+
emit log("a string");
13+
14+
emit log("-- log_named_uint(string, uint)");
15+
log_named_uint("uint", 512);
16+
17+
emit log("-- log_named_int(string, int)");
18+
log_named_int("int", -512);
19+
20+
emit log("-- log_named_address(string, address)");
21+
log_named_address("address", address(this));
22+
23+
emit log("-- log_named_bytes32(string, bytes32)");
24+
log_named_bytes32("bytes32", "a string");
25+
26+
emit log("-- log_named_bytes(string, bytes)");
27+
log_named_bytes("bytes", hex"cafefe");
28+
29+
emit log("-- log_named_string(string, string)");
30+
log_named_string("string", "a string");
31+
32+
emit log("-- log_named_decimal_uint(string, uint, uint)");
33+
log_named_decimal_uint("decimal uint", 1.0e18, 18);
34+
35+
emit log("-- log_named_decimal_int(string, int, uint)");
36+
log_named_decimal_int("decimal int", -1.0e18, 18);
37+
}
38+
event log_old_named_uint(bytes32,uint);
39+
function test_old_logs() public {
40+
log_old_named_uint("key", 500);
41+
log_named_bytes32("bkey", "val");
42+
}
43+
function test_trace() public view {
44+
this.echo("string 1", "string 2");
45+
}
46+
function test_multiline() public {
47+
emit log("a multiline\\n" "string");
48+
emit log("a multiline " "string");
49+
log_bytes("a string");
50+
log_bytes("a multiline\n" "string");
51+
log_bytes("a multiline\\n" "string");
52+
emit log(unicode"Ώ");
53+
logs(hex"0000");
54+
log_named_bytes("0x0000", hex"0000");
55+
logs(hex"ff");
56+
}
57+
function echo(string memory s1, string memory s2) public pure
58+
returns (string memory, string memory)
59+
{
60+
return (s1, s2);
61+
}
62+
63+
function prove_this(uint x) public {
64+
log_named_uint("sym x", x);
65+
assertGt(x + 1, 0);
66+
}
67+
68+
function test_logn() public {
69+
assembly {
70+
log0(0x01, 0x02)
71+
log1(0x01, 0x02, 0x03)
72+
log2(0x01, 0x02, 0x03, 0x04)
73+
log3(0x01, 0x02, 0x03, 0x04, 0x05)
74+
}
75+
}
76+
77+
event MyEvent(uint, uint indexed, uint, uint indexed);
78+
function test_events() public {
79+
emit MyEvent(1, 2, 3, 4);
80+
}
81+
82+
function test_asserts() public {
83+
string memory err = "this test has failed!";
84+
emit log("## assertTrue(bool)\n");
85+
assertTrue(false);
86+
emit log("\n");
87+
assertTrue(false, err);
88+
89+
emit log("\n## assertEq(address,address)\n");
90+
assertEq(address(this), msg.sender);
91+
emit log("\n");
92+
assertEq(address(this), msg.sender, err);
93+
94+
emit log("\n## assertEq32(bytes32,bytes32)\n");
95+
assertEq32("bytes 1", "bytes 2");
96+
emit log("\n");
97+
assertEq32("bytes 1", "bytes 2", err);
98+
99+
emit log("\n## assertEq(bytes32,bytes32)\n");
100+
assertEq32("bytes 1", "bytes 2");
101+
emit log("\n");
102+
assertEq32("bytes 1", "bytes 2", err);
103+
104+
emit log("\n## assertEq(uint,uint)\n");
105+
assertEq(uint(0), 1);
106+
emit log("\n");
107+
assertEq(uint(0), 1, err);
108+
109+
emit log("\n## assertEq(int,int)\n");
110+
assertEq(-1, -2);
111+
emit log("\n");
112+
assertEq(-1, -2, err);
113+
114+
emit log("\n## assertEqDecimal(int,int,uint)\n");
115+
assertEqDecimal(-1.0e18, -1.1e18, 18);
116+
emit log("\n");
117+
assertEqDecimal(-1.0e18, -1.1e18, 18, err);
118+
119+
emit log("\n## assertEqDecimal(uint,uint,uint)\n");
120+
assertEqDecimal(uint(1.0e18), 1.1e18, 18);
121+
emit log("\n");
122+
assertEqDecimal(uint(1.0e18), 1.1e18, 18, err);
123+
124+
emit log("\n## assertGt(uint,uint)\n");
125+
assertGt(uint(0), 0);
126+
emit log("\n");
127+
assertGt(uint(0), 0, err);
128+
129+
emit log("\n## assertGt(int,int)\n");
130+
assertGt(-1, -1);
131+
emit log("\n");
132+
assertGt(-1, -1, err);
133+
134+
emit log("\n## assertGtDecimal(int,int,uint)\n");
135+
assertGtDecimal(-2.0e18, -1.1e18, 18);
136+
emit log("\n");
137+
assertGtDecimal(-2.0e18, -1.1e18, 18, err);
138+
139+
emit log("\n## assertGtDecimal(uint,uint,uint)\n");
140+
assertGtDecimal(uint(1.0e18), 1.1e18, 18);
141+
emit log("\n");
142+
assertGtDecimal(uint(1.0e18), 1.1e18, 18, err);
143+
144+
emit log("\n## assertGe(uint,uint)\n");
145+
assertGe(uint(0), 1);
146+
emit log("\n");
147+
assertGe(uint(0), 1, err);
148+
149+
emit log("\n## assertGe(int,int)\n");
150+
assertGe(-1, 0);
151+
emit log("\n");
152+
assertGe(-1, 0, err);
153+
154+
emit log("\n## assertGeDecimal(int,int,uint)\n");
155+
assertGeDecimal(-2.0e18, -1.1e18, 18);
156+
emit log("\n");
157+
assertGeDecimal(-2.0e18, -1.1e18, 18, err);
158+
159+
emit log("\n## assertGeDecimal(uint,uint,uint)\n");
160+
assertGeDecimal(uint(1.0e18), 1.1e18, 18);
161+
emit log("\n");
162+
assertGeDecimal(uint(1.0e18), 1.1e18, 18, err);
163+
164+
emit log("\n## assertLt(uint,uint)\n");
165+
assertLt(uint(0), 0);
166+
emit log("\n");
167+
assertLt(uint(0), 0, err);
168+
169+
emit log("\n## assertLt(int,int)\n");
170+
assertLt(-1, -1);
171+
emit log("\n");
172+
assertLt(-1, -1, err);
173+
174+
emit log("\n## assertLtDecimal(int,int,uint)\n");
175+
assertLtDecimal(-1.0e18, -1.1e18, 18);
176+
emit log("\n");
177+
assertLtDecimal(-1.0e18, -1.1e18, 18, err);
178+
179+
emit log("\n## assertLtDecimal(uint,uint,uint)\n");
180+
assertLtDecimal(uint(2.0e18), 1.1e18, 18);
181+
emit log("\n");
182+
assertLtDecimal(uint(2.0e18), 1.1e18, 18, err);
183+
184+
emit log("\n## assertLe(uint,uint)\n");
185+
assertLe(uint(1), 0);
186+
emit log("\n");
187+
assertLe(uint(1), 0, err);
188+
189+
emit log("\n## assertLe(int,int)\n");
190+
assertLe(0, -1);
191+
emit log("\n");
192+
assertLe(0, -1, err);
193+
194+
emit log("\n## assertLeDecimal(int,int,uint)\n");
195+
assertLeDecimal(-1.0e18, -1.1e18, 18);
196+
emit log("\n");
197+
assertLeDecimal(-1.0e18, -1.1e18, 18, err);
198+
199+
emit log("\n## assertLeDecimal(uint,uint,uint)\n");
200+
assertLeDecimal(uint(2.0e18), 1.1e18, 18);
201+
emit log("\n");
202+
assertLeDecimal(uint(2.0e18), 1.1e18, 18, err);
203+
204+
emit log("\n## assertEq(string,string)\n");
205+
string memory s1 = "string 1";
206+
string memory s2 = "string 2";
207+
assertEq(s1, s2);
208+
emit log("\n");
209+
assertEq(s1, s2, err);
210+
211+
emit log("\n## assertEq0(bytes,bytes)\n");
212+
assertEq0(hex"abcdef01", hex"abcdef02");
213+
log("\n");
214+
assertEq0(hex"abcdef01", hex"abcdef02", err);
215+
}
216+
}
217+
218+
contract DemoTestWithSetUp {
219+
function setUp() public {
220+
}
221+
function test_pass() public pure {
222+
}
223+
}

0 commit comments

Comments
 (0)