#55208 [SC-Low] executors receive a greater reward than the assigned value
Previous#55242 [SC-Low] selfcloseexitto vulnerable to frontrunning griefing via exit NextFolks Smart Contract Library | Aud Comp
Was this helpful?
Was this helpful?
Was this helpful?
it.only("reserve-collateral", async() => {
const fAssetImpl = await FAsset.new();
const fAssetProxy = await FAssetProxy.new(fAssetImpl.address, "fEthereum", "fETH", "Ethereum", "ETH", 18, { from: governance });
fAsset = await FAsset.at(fAssetProxy.address);
let wNat = await ERC20Mock.new("wNative", "wNat");
assetManager = await AssetManager.new(wNat.address);
await fAsset.setAssetManager(assetManager.address, { from: governance });
// 1- agent is created and agent become available
const agent = await Agent.createTest(context, agentOwner1, underlyingAgent1);
const minter = await Minter.createTest(context, minterAddress1, underlyingMinter1, context.underlyingAmount(1e8));
const redeemer = await Redeemer.create(context, redeemerAddress1, underlyingRedeemer1);
// make agent available one lot worth of pool collateral
const requiredCollateral = await agent.requiredCollateralForLots(100);
await agent.depositCollateralsAndMakeAvailable(requiredCollateral.vault, requiredCollateral.pool);
const poolTokenSupplyBefore = await agent.collateralPoolToken.totalSupply();
// minter mints
const lots = 1;
let agentInfo = await agent.getAgentInfo();
let snapshotId = await network.provider.send("evm_snapshot", []);
await context.priceStore.setCurrentPrice("NAT", 110000, 0);
let res = await context.assetManager.reserveCollateral(agent.vaultAddress, lots, agentInfo.feeBIPS, redeemer.address, {from: minter.address, value : toBNExp(150, 18)});
let reserveColl = requiredEventArgs(res, 'CollateralReserved');
console.log("executor paying out when NAT price raises to $1.1 upon execution of the minter's transaction-----------------------------------");
console.log("executorFeeNat:", reserveColl.executorFeeNatWei.toString() / 1e18);
console.log("reservationFeeNat:", Number(toBNExp(150, 18).sub(reserveColl.executorFeeNatWei)) / 1e18);
console.log("executor paying out when NAT price is $1-----------------------------------");
await network.provider.send("evm_revert", [snapshotId]);
res = await context.assetManager.reserveCollateral(agent.vaultAddress, lots, agentInfo.feeBIPS, redeemer.address, {from: minter.address, value : toBNExp(150, 18)});
reserveColl = requiredEventArgs(res, 'CollateralReserved');
console.log("executorFeeNat:", reserveColl.executorFeeNatWei.toString() / 1e18);
console.log("reservationFeeNat:", Number(toBNExp(150, 18).sub(reserveColl.executorFeeNatWei)) / 1e18);
}); Contract: AssetManager.sol; test/integration/assetManager/AttackScenarios.ts; Asset manager integration tests
challenger's reward:300 deprecated collateral
✔ challenger receives deprecated collateral (105ms)
executor paying out when NAT price raises to $1.1 upon execution of the minter's transaction-----------------------------------
executorFeeNat: 59.090909090000004
reservationFeeNat: 90.90909091
executor paying out when NAT price is $1-----------------------------------
executorFeeNat: 50
reservationFeeNat: 100
✔ reserve-collateral (78ms)
2 passing (3s)