Skip to content

Commit

Permalink
Merge pull request #144 from gildlab/10-22-2024-zero-shares-amount-er…
Browse files Browse the repository at this point in the history
…ror-reproduction

Add testDepositBasicReproduction
  • Loading branch information
thedavidmeister authored Oct 28, 2024
2 parents 95605cc + 1d70832 commit 6af12a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 0 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ solc = "0.8.25"
optimizer = true
optimizer_runs = 100000

fuzz.runs = 2056

remappings = [
"rain.factory/=lib/rain.factory/src/",
"rain.intorastring/=lib/rain.interpreter/lib/rain.intorastring/src/",
Expand Down
35 changes: 35 additions & 0 deletions test/src/concrete/vault/ERC20PriceOracleReceiptVault.deposit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {Receipt as ReceiptContract} from "src/concrete/receipt/Receipt.sol";
import {IReceiptVaultV1} from "src/interface/IReceiptVaultV1.sol";
import {LibUniqueAddressesGenerator} from "../../../lib/LibUniqueAddressesGenerator.sol";
import {SFLR_CONTRACT} from "rain.flare/lib/sflr/LibSceptreStakedFlare.sol";
import "forge-std/StdCheats.sol";
import {LibFork} from "rain.flare/../test/fork/LibFork.sol";
import {LibSceptreStakedFlare} from "rain.flare/lib/sflr/LibSceptreStakedFlare.sol";
import {LibFtsoV2LTS, FLR_USD_FEED_ID} from "rain.flare/lib/lts/LibFtsoV2LTS.sol";

contract ERC20PriceOracleReceiptVaultDepositTest is ERC20PriceOracleReceiptVaultTest {
using LibFixedPointDecimalArithmeticOpenZeppelin for uint256;
Expand Down Expand Up @@ -200,5 +205,35 @@ contract ERC20PriceOracleReceiptVaultDepositTest is ERC20PriceOracleReceiptVault
vm.stopPrank();
}

/// forge-config: default.fuzz.runs = 1
function testDepositFlareFork(uint256 deposit) public {
deposit = bound(deposit, 1, type(uint128).max);
// Contract address on Flare
ERC20PriceOracleReceiptVault vault =
ERC20PriceOracleReceiptVault(payable(0xf0363b922299EA467d1E9c0F9c37d89830d9a4C4));

// Sender address
address alice = address(uint160(uint256(keccak256("ALICE"))));

uint256 BLOCK_NUMBER = 31725348;
vm.createSelectFork(LibFork.rpcUrlFlare(vm), BLOCK_NUMBER);

deal(address(SFLR_CONTRACT), alice, deposit);

vm.startPrank(alice);

// Make the deposit
IERC20(address(SFLR_CONTRACT)).approve(payable(vault), deposit);
vault.deposit(deposit, alice, 0, hex"00");
vm.stopPrank();

uint256 shareBalance = vault.balanceOf(alice);
uint256 usdPerFlr = LibFtsoV2LTS.ftsoV2LTSGetFeed(FLR_USD_FEED_ID, 60);
uint256 sflrPerFlr = LibSceptreStakedFlare.getSFLRPerFLR18();
uint256 rate = usdPerFlr.fixedPointDiv(sflrPerFlr, Math.Rounding.Up);

assertEqUint(deposit.fixedPointMul(rate, Math.Rounding.Down), shareBalance);
}

fallback() external {}
}

0 comments on commit 6af12a2

Please sign in to comment.