Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions test/escrowForkTests/BaseEscrowLPConvexTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ abstract contract BaseEscrowLPConvexTest is Test {
struct ConvexInfo {
uint256 pid;
address rewardPool;
address depositToken;
address stash;
}

Expand All @@ -62,7 +61,6 @@ abstract contract BaseEscrowLPConvexTest is Test {
gauge = _gauge;
pid = _convexInfo.pid;
rewardPool = IRewardPool(_convexInfo.rewardPool);
depositToken = IERC20(_convexInfo.depositToken);
stash = _convexInfo.stash;

if (_addExtraDolaReward) {
Expand Down
64 changes: 41 additions & 23 deletions test/escrowForkTests/ConvexEscrowFork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import "forge-std/Test.sol";
import "src/escrows/ConvexEscrow.sol";

contract MockRewards {

IERC20 token;
constructor(address _token){
constructor(address _token) {
token = IERC20(_token);
}

Expand All @@ -16,25 +15,23 @@ contract MockRewards {
}
}

contract ConvexEscrowForkTest is Test{

contract ConvexEscrowForkTest is Test {
address market = address(0xA);
address beneficiary = address(0xB);
address friend = address(0xC);
address holder = address(0x50BE13b54f3EeBBe415d20250598D81280e56772);
address holder = address(0x272b065A43EF59EA470fbfD9be76AD1b43aAB651);
IERC20 dola = IERC20(0x865377367054516e17014CcdED1e7d814EDC9ce4);
IERC20 cvx = IERC20(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
IERC20 cvxCrv = IERC20(0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7);
ICvxRewardPool rewardPool = ICvxRewardPool(0xCF50b810E57Ac33B91dCF525C6ddd9881B139332);

ConvexEscrow escrow;
ICvxRewardPool rewardPool =
ICvxRewardPool(0xCF50b810E57Ac33B91dCF525C6ddd9881B139332);

ConvexEscrow escrow;

function setUp() public {
//This will fail if there's no mainnet variable in foundry.toml
string memory url = vm.rpcUrl("mainnet");
vm.createSelectFork(url, 22114296);

escrow = new ConvexEscrow();
vm.startPrank(market, market);
escrow.initialize(address(cvx), beneficiary);
Expand All @@ -46,13 +43,16 @@ contract ConvexEscrowForkTest is Test{
function testOnDeposit_successful_whenContractHoldsCvxCrv() public {
uint balanceBefore = escrow.balance();
uint stakedBalanceBefore = rewardPool.balanceOf(address(escrow));

vm.prank(holder, holder);
cvx.transfer(address(escrow), 1 ether);
escrow.onDeposit();

assertEq(escrow.balance(), balanceBefore + 1 ether);
assertEq(rewardPool.balanceOf(address(escrow)), stakedBalanceBefore + 1 ether);
assertEq(
rewardPool.balanceOf(address(escrow)),
stakedBalanceBefore + 1 ether
);
}

function testPay_successful_whenContractHasStakedCvxCrv() public {
Expand All @@ -66,10 +66,15 @@ contract ConvexEscrowForkTest is Test{
vm.prank(market, market);
escrow.pay(beneficiary, 1 ether);


assertEq(escrow.balance(), balanceBefore - 1 ether);
assertEq(rewardPool.balanceOf(address(escrow)), stakedBalanceBefore - 1 ether);
assertEq(cvx.balanceOf(beneficiary), beneficiaryBalanceBefore + 1 ether);
assertEq(
rewardPool.balanceOf(address(escrow)),
stakedBalanceBefore - 1 ether
);
assertEq(
cvx.balanceOf(beneficiary),
beneficiaryBalanceBefore + 1 ether
);
}

function testPay_failWithONLYMARKET_whenCalledByNonMarket() public {
Expand Down Expand Up @@ -100,13 +105,17 @@ contract ConvexEscrowForkTest is Test{
vm.prank(holder, holder);
cvx.transfer(address(escrow), 1 ether);
escrow.onDeposit();

vm.startPrank(beneficiary);
vm.warp(block.timestamp + 14 days);
escrow.claim();
vm.stopPrank();

assertGt(cvxCrv.balanceOf(beneficiary), cvxCrvBalanceBefore, "cvxCrv balance did not increase");
assertGt(
cvxCrv.balanceOf(beneficiary),
cvxCrvBalanceBefore,
"cvxCrv balance did not increase"
);
}

function testClaimTo_successful_whenExtraRewardsAdded() public {
Expand All @@ -120,16 +129,24 @@ contract ConvexEscrowForkTest is Test{
deal(address(dola), address(reward), 10 ether);
vm.prank(rewardPool.rewardManager());
rewardPool.addExtraReward(address(reward));

vm.startPrank(beneficiary);
vm.warp(block.timestamp + 14 days);
address[] memory rewards = new address[](1);
rewards[0] = address(dola);
escrow.claimTo(beneficiary, rewards);
vm.stopPrank();

assertGt(cvxCrv.balanceOf(beneficiary), cvxCrvBalanceBefore, "cvxCrv balance did not increase");
assertGt(dola.balanceOf(beneficiary), dolaBalanceBefore, "Dola extra reward balance did not increase");
assertGt(
cvxCrv.balanceOf(beneficiary),
cvxCrvBalanceBefore,
"cvxCrv balance did not increase"
);
assertGt(
dola.balanceOf(beneficiary),
dolaBalanceBefore,
"Dola extra reward balance did not increase"
);
}

function testClaimTo_fails_whenTryingToClaimCollateral() public {
Expand All @@ -141,7 +158,7 @@ contract ConvexEscrowForkTest is Test{
deal(address(cvx), address(reward), 10 ether);
vm.prank(rewardPool.rewardManager());
rewardPool.addExtraReward(address(reward));

vm.startPrank(beneficiary);
vm.warp(block.timestamp + 14 days);
address[] memory rewards = new address[](1);
Expand All @@ -160,7 +177,7 @@ contract ConvexEscrowForkTest is Test{
deal(address(cvx), address(reward), 10 ether);
vm.prank(rewardPool.rewardManager());
rewardPool.addExtraReward(address(reward));

vm.startPrank(beneficiary);
vm.warp(block.timestamp + 14 days);
address[] memory rewards = new address[](2);
Expand Down Expand Up @@ -237,10 +254,11 @@ contract ConvexEscrowForkTest is Test{
escrow.allowClaimOnBehalf(friend);
}

function testDisallowClaimOnBehalf_fails_whenCalledByNonBeneficiary() public {
function testDisallowClaimOnBehalf_fails_whenCalledByNonBeneficiary()
public
{
vm.prank(friend);
vm.expectRevert("ONLY BENEFICIARY");
escrow.disallowClaimOnBehalf(friend);
}

}
2 changes: 0 additions & 2 deletions test/escrowForkTests/CrvUSDDolaEscrowConvexFork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ contract DolaCrvUSDEscrowConvexForkTest is BaseEscrowLPConvexTest {
// Convex
uint256 _pid = 215;
address _rewardPool = 0xC94208D230EEdC4cDC4F80141E21aA485A515660;
address _depositToken = 0x408abF1a02388A5EF19E3dB1e08db5eFdC510DFF;
address _stash = 0x25F5Ccd892985Bf878327B15815bd90066EEf28d;

function setUp() public {
Expand All @@ -22,7 +21,6 @@ contract DolaCrvUSDEscrowConvexForkTest is BaseEscrowLPConvexTest {
BaseEscrowLPConvexTest.ConvexInfo memory convexParams = ConvexInfo(
_pid,
_rewardPool,
_depositToken,
_stash
);

Expand Down
29 changes: 29 additions & 0 deletions test/escrowForkTests/DolaDeUSDEscrowConvexFork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {BaseEscrowLPConvexTest} from "test/escrowForkTests/BaseEscrowLPConvexTest.t.sol";

contract DolaDeUSDEscrowConvexForkTest is BaseEscrowLPConvexTest {
// Curve
address _dolaDeUSD = 0x6691DBb44154A9f23f8357C56FC9ff5548A8bdc4;
address _lpHolder = address(0xcb4a7b790eDB7Fa3e2731Efd7ED85275f92Fc74A);
address _gauge = 0xa48A3c91b062ca06Fd0d0569695432EB066f8c7E;

// Convex
uint256 _pid = 419;
address _rewardPool = 0xD30E66cBc869Aa808eB9c81f8Aad8408767E3a3E;
address _stash = 0x074297Bf0dEA6925c27526E6E3E3151D8cE4edc7;

function setUp() public {
//This will fail if there's no mainnet variable in foundry.toml
string memory url = vm.rpcUrl("mainnet");
vm.createSelectFork(url, 21826229);
BaseEscrowLPConvexTest.ConvexInfo memory convexParams = ConvexInfo(
_pid,
_rewardPool,
_stash
);

init(_dolaDeUSD, _lpHolder, _gauge, convexParams, true);
}
}
2 changes: 0 additions & 2 deletions test/escrowForkTests/DolaFraxBPEscrowConvexFork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ contract DolaFraxBPEscrowConvexForkTest is BaseEscrowLPConvexTest {
// Convex
uint256 _pid = 115;
address _rewardPool = 0x0404d05F3992347d2f0dC3a97bdd147D77C85c1c;
address _depositToken = 0xf7eCC27CC9DB5d28110AF2d89b176A6623c7E351;
address _stash = 0xe5A980F96c791c8Ea56c2585840Cab571441510e;

function setUp() public {
Expand All @@ -22,7 +21,6 @@ contract DolaFraxBPEscrowConvexForkTest is BaseEscrowLPConvexTest {
BaseEscrowLPConvexTest.ConvexInfo memory convexParams = ConvexInfo(
_pid,
_rewardPool,
_depositToken,
_stash
);

Expand Down
2 changes: 0 additions & 2 deletions test/escrowForkTests/DolaFraxPyUSDEscrowConvexFork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ contract DolaFraxPyUSDEscrowForkTest is BaseEscrowLPConvexTest {
// Convex
uint256 _pid = 317;
address _rewardPool = 0xE8cBdBFD4A1D776AB1146B63ABD1718b2F92a823;
address _depositToken = 0x430bE19e180fd8c2199eC5FAEabE2F5CDba68C94;
address _stash = 0x6bCc4b00F2Cc9CdFF935E1A5D939f26A233Dd381;

function setUp() public {
Expand All @@ -22,7 +21,6 @@ contract DolaFraxPyUSDEscrowForkTest is BaseEscrowLPConvexTest {
BaseEscrowLPConvexTest.ConvexInfo memory convexParams = ConvexInfo(
_pid,
_rewardPool,
_depositToken,
_stash
);

Expand Down
29 changes: 29 additions & 0 deletions test/escrowForkTests/DolaUSREscrowConvexFork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {BaseEscrowLPConvexTest} from "test/escrowForkTests/BaseEscrowLPConvexTest.t.sol";

contract DolaUSREscrowConvexForkTest is BaseEscrowLPConvexTest {
// Curve
address _dolaUSR = 0x38De22a3175708D45E7c7c64CD78479C8B56f76E;
address _lpHolder = address(0x89836bB3a0471adBa7DEf2677292c07004308Feb);
address _gauge = 0xd303994a0Db9b74f3E8fF629ba3097fC7060C331;

// Convex
uint256 _pid = 421;
address _rewardPool = 0xE694a5e9272ea7ed2DC25f0c6D21640fb8a83166;
address _stash = 0x63A8AE4C4fE19B8816dEa970544F8a446051cB89;

function setUp() public {
//This will fail if there's no mainnet variable in foundry.toml
string memory url = vm.rpcUrl("mainnet");
vm.createSelectFork(url, 21969468);
BaseEscrowLPConvexTest.ConvexInfo memory convexParams = ConvexInfo(
_pid,
_rewardPool,
_stash
);

init(_dolaUSR, _lpHolder, _gauge, convexParams, true);
}
}
31 changes: 31 additions & 0 deletions test/feedForkTests/DolaDeUSDFeedFork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import "src/feeds/ChainlinkBasePriceFeed.sol";
import {ChainlinkCurveFeed} from "src/feeds/ChainlinkCurveFeed.sol";
import {ChainlinkCurve2CoinsFeed} from "src/feeds/ChainlinkCurve2CoinsFeed.sol";
import "src/feeds/CurveLPPessimisticFeed.sol";
import {DolaCurveLPPessimsticFeedBaseTest} from "test/feedForkTests/DolaCurveLPPessimsticFeedBaseTest.t.sol";
import {ConfigAddr} from "test/ConfigAddr.sol";

contract DolaDeUSDFeedFork is DolaCurveLPPessimsticFeedBaseTest, ConfigAddr {
address clDeUSDFeed = address(0x471a6299C027Bd81ed4D66069dc510Bd0569f4F8);
uint256 deUSDHeartbeat = 86400;

ICurvePool public constant dolaDeUSD =
ICurvePool(0x6691DBb44154A9f23f8357C56FC9ff5548A8bdc4);

function setUp() public {
string memory url = vm.rpcUrl("mainnet");
vm.createSelectFork(url, 21826229);

ChainlinkBasePriceFeed deUSDFeed = new ChainlinkBasePriceFeed(
gov,
clDeUSDFeed,
address(0),
deUSDHeartbeat
);
init(address(0), address(deUSDFeed), address(dolaDeUSD));
}
}
31 changes: 31 additions & 0 deletions test/feedForkTests/DolaUSRFeedFork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import "src/feeds/ChainlinkBasePriceFeed.sol";
import {ChainlinkCurveFeed} from "src/feeds/ChainlinkCurveFeed.sol";
import {ChainlinkCurve2CoinsFeed} from "src/feeds/ChainlinkCurve2CoinsFeed.sol";
import "src/feeds/CurveLPPessimisticFeed.sol";
import {DolaCurveLPPessimsticFeedBaseTest} from "test/feedForkTests/DolaCurveLPPessimsticFeedBaseTest.t.sol";
import {ConfigAddr} from "test/ConfigAddr.sol";

contract DolaUSRFeedFork is DolaCurveLPPessimsticFeedBaseTest, ConfigAddr {
address clUSRFeed = address(0x34ad75691e25A8E9b681AAA85dbeB7ef6561B42c);
uint256 usrHeartbeat = 86400;

ICurvePool public constant dolaUSR =
ICurvePool(0x38De22a3175708D45E7c7c64CD78479C8B56f76E);

function setUp() public {
string memory url = vm.rpcUrl("mainnet");
vm.createSelectFork(url, 21969468);

ChainlinkBasePriceFeed usrFeed = new ChainlinkBasePriceFeed(
gov,
clUSRFeed,
address(0),
usrHeartbeat
);
init(address(0), address(usrFeed), address(dolaUSR));
}
}
Loading
Loading