Skip to content

Commit e478d5b

Browse files
authored
Feat: Dola-WstUSR Convex and Yearn Markets (#127)
* add Dola-WstUSR tests * add feed test for Yearn market, rm old empty test files
1 parent adffc53 commit e478d5b

9 files changed

+317
-0
lines changed

test/feedForkTests/CurveLPPessimsticFeedBaseTest.t.sol

Whitespace-only changes.

test/feedForkTests/CurveLPPessimsticYearnV2FeedBaseTest.t.sol

Whitespace-only changes.

test/feedForkTests/CurveLPSingleFeedBaseTest.t.sol

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.19;
3+
4+
import "forge-std/Test.sol";
5+
import "src/feeds/ChainlinkBasePriceFeed.sol";
6+
import {ChainlinkCurveFeed} from "src/feeds/ChainlinkCurveFeed.sol";
7+
import {ChainlinkCurve2CoinsFeed} from "src/feeds/ChainlinkCurve2CoinsFeed.sol";
8+
import "src/feeds/CurveLPPessimisticFeed.sol";
9+
import {DolaCurveLPPessimsticFeedBaseTest} from "test/feedForkTests/DolaCurveLPPessimsticFeedBaseTest.t.sol";
10+
import {ConfigAddr} from "test/ConfigAddr.sol";
11+
import {ERC4626Feed} from "src/feeds/ERC4626Feed.sol";
12+
13+
contract DolaWstUSRUSDFeedFork is DolaCurveLPPessimsticFeedBaseTest, ConfigAddr {
14+
ICurvePool public constant dolawstUSR =
15+
ICurvePool(0x64273624eb57c5cA961d366CBF3968e760Bf0452);
16+
address usrWrapper = address(0x182Af82E3619D2182b3669BbFA8C72bC57614aDf);
17+
function setUp() public {
18+
string memory url = vm.rpcUrl("mainnet");
19+
vm.createSelectFork(url);
20+
21+
init(address(0), address(usrWrapper), address(dolawstUSR));
22+
}
23+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.19;
3+
4+
import "forge-std/Test.sol";
5+
import "src/feeds/ChainlinkBasePriceFeed.sol";
6+
import {ChainlinkCurveFeed} from "src/feeds/ChainlinkCurveFeed.sol";
7+
import "src/feeds/CurveLPPessimisticFeed.sol";
8+
import {CurveLPYearnV2FeedBaseTest} from "test/feedForkTests/CurveLPYearnV2FeedBaseTest.t.sol";
9+
10+
contract DolawstUSRYearnV2FeedFork is CurveLPYearnV2FeedBaseTest {
11+
ICurvePool public constant dolawstUSR =
12+
ICurvePool(0x64273624eb57c5cA961d366CBF3968e760Bf0452);
13+
14+
address usrWrapper = address(0x182Af82E3619D2182b3669BbFA8C72bC57614aDf);
15+
16+
address public constant yearnVault =
17+
address(0x8A5f20dA6B393fE25aCF1522C828166D22eF8321);
18+
19+
CurveLPPessimisticFeed dolaWstUSRFeed;
20+
21+
function setUp() public {
22+
string memory url = vm.rpcUrl("mainnet");
23+
vm.createSelectFork(url);
24+
25+
dolaWstUSRFeed = new CurveLPPessimisticFeed(
26+
address(dolawstUSR),
27+
usrWrapper,
28+
dolaFixedFeedAddr,
29+
false
30+
);
31+
init(address(dolaWstUSRFeed), address(dolawstUSR), yearnVault);
32+
}
33+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {MarketBaseForkTest, IOracle, IDolaBorrowingRights, IERC20} from "./MarketBaseForkTest.sol";
5+
import {Market} from "src/Market.sol";
6+
7+
import {ConvexEscrowV2} from "src/escrows/ConvexEscrowV2.sol";
8+
import {CurveLPPessimisticFeed} from "src/feeds/CurveLPPessimisticFeed.sol";
9+
import {ChainlinkCurve2CoinsFeed, ICurvePool} from "src/feeds/ChainlinkCurve2CoinsFeed.sol";
10+
import {ChainlinkCurveFeed} from "src/feeds/ChainlinkCurveFeed.sol";
11+
import "src/feeds/ChainlinkBasePriceFeed.sol";
12+
import {console} from "forge-std/console.sol";
13+
import {YearnVaultV2Helper, IYearnVaultV2} from "src/util/YearnVaultV2Helper.sol";
14+
import {DolaFixedPriceFeed} from "src/feeds/DolaFixedPriceFeed.sol";
15+
import {ChainlinkBasePriceFeed} from "src/feeds/ChainlinkBasePriceFeed.sol";
16+
import {MockFeedDescription} from "test/mocks/MockFeedDescription.sol";
17+
18+
contract DolaWstUSRConvexMarketForkTest is MarketBaseForkTest {
19+
ConvexEscrowV2 escrow;
20+
21+
CurveLPPessimisticFeed feedDolaUSR;
22+
DolaFixedPriceFeed dolaFeed;
23+
24+
ICurvePool public constant dolaWstUSR =
25+
ICurvePool(0x64273624eb57c5cA961d366CBF3968e760Bf0452);
26+
27+
address usrWrapper = address(0x182Af82E3619D2182b3669BbFA8C72bC57614aDf);
28+
29+
address rewardPool = address(0x7F548ca54A86a326CE42772879338d429F14f048);
30+
31+
address booster = address(0xF403C135812408BFbE8713b5A23a04b3D48AAE31);
32+
33+
uint256 pid = 496;
34+
35+
IERC20 public cvx = IERC20(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
36+
IERC20 public crv = IERC20(0xD533a949740bb3306d119CC777fa900bA034cd52);
37+
38+
ConvexEscrowV2 userEscrow;
39+
40+
function setUp() public virtual {
41+
//This will fail if there's no mainnet variable in foundry.toml
42+
string memory url = vm.rpcUrl("mainnet");
43+
vm.createSelectFork(url);
44+
escrow = new ConvexEscrowV2(
45+
rewardPool,
46+
booster,
47+
address(cvx),
48+
address(crv),
49+
pid
50+
);
51+
feedDolaUSR = _deployDolaUSRFeed();
52+
market = new Market(
53+
gov,
54+
fedAddr,
55+
pauseGuardian,
56+
address(escrow),
57+
IDolaBorrowingRights(address(dbrAddr)),
58+
IERC20(address(dolaWstUSR)),
59+
IOracle(address(oracleAddr)),
60+
5000,
61+
5000,
62+
100,
63+
true
64+
);
65+
_advancedInit(address(market), address(feedDolaUSR), true);
66+
67+
userEscrow = ConvexEscrowV2(
68+
address(Market(address(market)).predictEscrow(user))
69+
);
70+
}
71+
72+
function test_escrow_immutables() public {
73+
testDeposit();
74+
assertEq(
75+
address(userEscrow.rewardPool()),
76+
address(rewardPool),
77+
"Reward pool not set"
78+
);
79+
assertEq(
80+
address(userEscrow.booster()),
81+
address(booster),
82+
"Booster not set"
83+
);
84+
85+
assertEq(address(userEscrow.cvx()), address(cvx), "CVX not set");
86+
assertEq(address(userEscrow.crv()), address(crv), "CRV not set");
87+
}
88+
89+
function _deployDolaUSRFeed()
90+
internal
91+
returns (CurveLPPessimisticFeed feed)
92+
{
93+
feed = new CurveLPPessimisticFeed(
94+
address(dolaWstUSR),
95+
address(usrWrapper),
96+
address(dolaFixedFeedAddr),
97+
false
98+
);
99+
}
100+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {MarketBaseForkTest, IOracle, IDolaBorrowingRights, IERC20} from "./MarketBaseForkTest.sol";
5+
import {Market} from "src/Market.sol";
6+
import {SimpleERC20Escrow} from "src/escrows/SimpleERC20Escrow.sol";
7+
import {CurveLPYearnV2Feed} from "src/feeds/CurveLPYearnV2Feed.sol";
8+
import {ChainlinkCurve2CoinsFeed} from "src/feeds/ChainlinkCurve2CoinsFeed.sol";
9+
import {ChainlinkCurveFeed, ICurvePool} from "src/feeds/ChainlinkCurveFeed.sol";
10+
import "src/feeds/ChainlinkBasePriceFeed.sol";
11+
import "src/feeds/CurveLPYearnV2Feed.sol";
12+
import {console} from "forge-std/console.sol";
13+
import {YearnVaultV2Helper, IYearnVaultV2} from "src/util/YearnVaultV2Helper.sol";
14+
import {CurveLPPessimisticFeed} from "src/feeds/CurveLPPessimisticFeed.sol";
15+
import {MockFeedDescription} from "test/mocks/MockFeedDescription.sol";
16+
import {ChainlinkBasePriceFeed} from "src/feeds/ChainlinkBasePriceFeed.sol";
17+
18+
contract DolaWstUSRYearnV2MarketForkTest is MarketBaseForkTest {
19+
CurveLPYearnV2Feed yearnFeed;
20+
CurveLPPessimisticFeed lpFeed;
21+
22+
address usrWrapper = address(0x182Af82E3619D2182b3669BbFA8C72bC57614aDf);
23+
24+
ICurvePool public constant dolaWstUSR =
25+
ICurvePool(0x64273624eb57c5cA961d366CBF3968e760Bf0452);
26+
27+
address public constant yearn =
28+
address(0x8A5f20dA6B393fE25aCF1522C828166D22eF8321);
29+
30+
function setUp() public virtual {
31+
//This will fail if there's no mainnet variable in foundry.toml
32+
string memory url = vm.rpcUrl("mainnet");
33+
vm.createSelectFork(url);
34+
35+
Market market = new Market(
36+
gov,
37+
lender,
38+
pauseGuardian,
39+
address(simpleERC20EscrowAddr),
40+
IDolaBorrowingRights(address(dbr)),
41+
IERC20(address(yearn)),
42+
IOracle(address(oracle)),
43+
5000,
44+
5000,
45+
1000,
46+
false
47+
);
48+
yearnFeed = _deployDolaUSRYearnV2Feed();
49+
_advancedInit(address(market), address(yearnFeed), true);
50+
}
51+
52+
function _deployDolaUSRYearnV2Feed()
53+
internal
54+
returns (CurveLPYearnV2Feed feed)
55+
{
56+
57+
lpFeed = new CurveLPPessimisticFeed(
58+
address(dolaWstUSR),
59+
address(usrWrapper),
60+
address(dolaFixedFeedAddr),
61+
false
62+
);
63+
64+
feed = new CurveLPYearnV2Feed(address(yearn), address(lpFeed));
65+
}
66+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
pragma solidity ^0.8.13;
2+
3+
import {ICurvePool} from "src/interfaces/ICurvePool.sol";
4+
import {CurveDolaLPHelperDynamic} from "src/util/CurveDolaLPHelperDynamic.sol";
5+
import "test/marketForkTests/DolaWstUSRConvexMarketForkTest.t.sol";
6+
import {console} from "forge-std/console.sol";
7+
import {IMultiMarketTransformHelper} from "src/interfaces/IMultiMarketTransformHelper.sol";
8+
import {ALEV2} from "src/util/ALEV2.sol";
9+
import {ALEBaseDolaLPDynTest, IFlashMinter} from "test/util/aleTests/ALEBaseDolaLPDyn.sol";
10+
11+
contract ALEDolaWstUSRTest is
12+
ALEBaseDolaLPDynTest,
13+
DolaWstUSRConvexMarketForkTest
14+
{
15+
address wstUSR = address(0x1202F5C7b4B9E47a1A484E8B270be34dbbC75055);
16+
17+
function setUp() public override {
18+
super.setUp();
19+
curvePool = dolaWstUSR;
20+
21+
helper = CurveDolaLPHelperDynamic(curveDolaLPHelperDynamicAddr);
22+
23+
vm.startPrank(gov);
24+
DOLA.mint(address(this), 100000 ether);
25+
helper.setMarket(address(market), address(curvePool), 0, 2, address(0));
26+
ale = ALEV2(payable(aleV2Addr));
27+
ale.setMarket(address(market), address(DOLA), address(helper), false);
28+
29+
borrowController.allow(address(ale));
30+
vm.stopPrank();
31+
userPkEscrow = address(market.predictEscrow(userPk));
32+
_seedPool();
33+
}
34+
35+
function _seedPool() internal{
36+
// Seed the pool with 902153 wstETH and 1000000 DOLA
37+
deal(wstUSR, address(this), 902153 ether, true);
38+
vm.prank(gov);
39+
DOLA.mint(address(this), 1000000 ether);
40+
IERC20(wstUSR).approve(address(curvePool), type(uint256).max);
41+
DOLA.approve(address(curvePool), type(uint256).max);
42+
uint256[] memory amounts = new uint256[](2);
43+
amounts[0] = 1000000 ether;
44+
amounts[1] = 902153 ether;
45+
curvePool.add_liquidity(amounts, 0, address(this));
46+
}
47+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
pragma solidity ^0.8.13;
2+
3+
import {ICurvePool} from "src/interfaces/ICurvePool.sol";
4+
import {CurveDolaLPHelperDynamic} from "src/util/CurveDolaLPHelperDynamic.sol";
5+
import "test/marketForkTests/DolaWstUSRYearnV2MarketForkTest.t.sol";
6+
import {console} from "forge-std/console.sol";
7+
import {IMultiMarketTransformHelper} from "src/interfaces/IMultiMarketTransformHelper.sol";
8+
import {ALEV2} from "src/util/ALEV2.sol";
9+
import {YearnVaultV2Helper, IYearnVaultV2} from "src/util/YearnVaultV2Helper.sol";
10+
import {ALEBaseDolaLPDynYearnV2Test, IFlashMinter} from "test/util/aleTests/ALEBaseDolaLPDynYearnV2.sol";
11+
12+
contract ALEDolaWstUSRYearnV2Test is
13+
ALEBaseDolaLPDynYearnV2Test,
14+
DolaWstUSRYearnV2MarketForkTest
15+
{
16+
address wstUSR = address(0x1202F5C7b4B9E47a1A484E8B270be34dbbC75055);
17+
18+
function setUp() public override {
19+
super.setUp();
20+
21+
helper = CurveDolaLPHelperDynamic(curveDolaLPHelperDynamicAddr);
22+
curvePool = dolaWstUSR;
23+
vault = IYearnVaultV2(yearn);
24+
vm.startPrank(gov);
25+
DOLA.mint(address(this), 100000 ether);
26+
helper.setMarket(address(market), address(curvePool), 0, 2, yearn);
27+
ale = ALEV2(payable(aleV2Addr));
28+
ale.setMarket(address(market), address(DOLA), address(helper), false);
29+
30+
borrowController.allow(address(ale));
31+
vm.stopPrank();
32+
userPkEscrow = address(market.predictEscrow(userPk));
33+
_seedPool();
34+
}
35+
36+
function _seedPool() internal{
37+
// Seed the pool with 902153 wstETH and 1000000 DOLA
38+
deal(wstUSR, address(this), 902153 ether, true);
39+
vm.prank(gov);
40+
DOLA.mint(address(this), 1000000 ether);
41+
IERC20(wstUSR).approve(address(curvePool), type(uint256).max);
42+
DOLA.approve(address(curvePool), type(uint256).max);
43+
uint256[] memory amounts = new uint256[](2);
44+
amounts[0] = 1000000 ether;
45+
amounts[1] = 902153 ether;
46+
curvePool.add_liquidity(amounts, 0, address(this));
47+
}
48+
}

0 commit comments

Comments
 (0)