diff --git a/scripts/test-forge.sh b/scripts/test-forge.sh index 9039784..f978a6c 100755 --- a/scripts/test-forge.sh +++ b/scripts/test-forge.sh @@ -20,7 +20,7 @@ export DAPP_BUILD_OPTIMIZE=1 export FOUNDRY_OPTIMIZER_RUNS=1000 if [[ -z "$MATCH" && -z "$BLOCK" ]]; then - forge test --fork-url "$ETH_RPC_URL" --force + forge test --fork-url "$ETH_RPC_URL" --force -vvv elif [[ -n "$MATCH" ]]; then forge test --fork-url "$ETH_RPC_URL" --match "$MATCH" -vvv --force elif [[ -n "$MATCH_TEST" ]]; then diff --git a/src/MegaPoker.sol b/src/MegaPoker.sol index eaa9768..369ab13 100644 --- a/src/MegaPoker.sol +++ b/src/MegaPoker.sol @@ -19,17 +19,19 @@ pragma solidity ^0.6.12; contract PokingAddresses { - // OSMs and Spotter addresses - address constant eth = 0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763; + // OSMs address constant btc = 0xf185d0682d50819263941e5f4EacC763CC5C6C42; - address constant univ2daiusdc = 0x25D03C2C928ADE19ff9f4FFECc07d991d0df054B; + address constant eth = 0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763; + address constant reth = 0xeE7F0b350aA119b3d05DC733a4621a81972f7D47; address constant wsteth = 0xFe7a2aC0B945f12089aEEB6eCebf4F384D9f043F; + address constant crvv1ethsteth = 0xEa508F82728927454bd3ce853171b0e2705880D4; address constant guniv3daiusdc1 = 0x7F6d78CC0040c87943a0e0c140De3F77a273bd58; address constant guniv3daiusdc2 = 0xcCBa43231aC6eceBd1278B90c3a44711a00F4e93; + address constant univ2daiusdc = 0x25D03C2C928ADE19ff9f4FFECc07d991d0df054B; + + // Spotter address constant spotter = 0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3; - address constant reth = 0xeE7F0b350aA119b3d05DC733a4621a81972f7D47; - address constant gno = 0xd800ca44fFABecd159c7889c3bf64a217361AEc8; } contract MegaPoker is PokingAddresses { @@ -40,40 +42,37 @@ contract MegaPoker is PokingAddresses { bool ok; // poke() = 0x18178358 - (ok,) = eth.call(abi.encodeWithSelector(0x18178358)); (ok,) = btc.call(abi.encodeWithSelector(0x18178358)); - (ok,) = wsteth.call(abi.encodeWithSelector(0x18178358)); - (ok,) = crvv1ethsteth.call(abi.encodeWithSelector(0x18178358)); + (ok,) = eth.call(abi.encodeWithSelector(0x18178358)); (ok,) = reth.call(abi.encodeWithSelector(0x18178358)); - (ok,) = gno.call(abi.encodeWithSelector(0x18178358)); - + (ok,) = wsteth.call(abi.encodeWithSelector(0x18178358)); // poke(bytes32) = 0x1504460f (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-A"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-B"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-C"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-A"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-B"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("CRVV1ETHSTETH-A"))); + (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("RETH-A"))); + (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-B"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-C"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("RETH-A"))); - (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GNO-A"))); - + (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-A"))); + (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-B"))); - // Daily pokes - // Reduced cost pokes + // Daily pokes, i.e. reduced cost pokes if (last <= block.timestamp - 1 days) { - // poke - // The GUINIV3DAIUSDCX Oracles are very expensive to poke, and the price should not - // change frequently, so they are getting poked only once a day. + // Poke + (ok,) = crvv1ethsteth.call(abi.encodeWithSelector(0x18178358)); + + // The GUINIV3DAIUSDCX Oracles are very expensive to poke, and the + // price should not change frequently, so they are getting poked + // only once a day. (ok,) = guniv3daiusdc1.call(abi.encodeWithSelector(0x18178358)); (ok,) = guniv3daiusdc2.call(abi.encodeWithSelector(0x18178358)); (ok,) = univ2daiusdc.call(abi.encodeWithSelector(0x18178358)); - // spotter.poke + // Spotter pokes + (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("CRVV1ETHSTETH-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC1-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC2-A"))); (ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("UNIV2DAIUSDC-A"))); diff --git a/src/MegaPoker.t.sol b/src/MegaPoker.t.sol index 71eb565..3aac469 100644 --- a/src/MegaPoker.t.sol +++ b/src/MegaPoker.t.sol @@ -162,41 +162,37 @@ contract MegaPokerTest is DSTest, PokingAddresses { hevm.warp(block.timestamp + 1 hours); megaPoker.poke(); assertEq(megaPoker.last(), block.timestamp - 1 hours); - // // Hacking nxt price to 0x123 (and making it valid) bytes32 hackedValue = 0x0000000000000000000000000000000100000000000000000000000000000123; - hevm.store(eth, bytes32(uint256(4)), hackedValue); hevm.store(btc, bytes32(uint256(4)), hackedValue); - hevm.store(univ2daiusdc, bytes32(uint256(4)), hackedValue); - hevm.store(wsteth, bytes32(uint256(4)), hackedValue); hevm.store(crvv1ethsteth, bytes32(uint256(4)), hackedValue); + hevm.store(eth, bytes32(uint256(4)), hackedValue); hevm.store(guniv3daiusdc1, bytes32(uint256(4)), hackedValue); hevm.store(guniv3daiusdc2, bytes32(uint256(4)), hackedValue); hevm.store(reth, bytes32(uint256(4)), hackedValue); - hevm.store(gno, bytes32(uint256(4)), hackedValue); + hevm.store(univ2daiusdc, bytes32(uint256(4)), hackedValue); + hevm.store(wsteth, bytes32(uint256(4)), hackedValue); // Whitelisting tester address - hevm.store(eth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); hevm.store(btc, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); - hevm.store(univ2daiusdc, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1))); - hevm.store(wsteth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); - hevm.store(reth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); - hevm.store(gno, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); hevm.store(crvv1ethsteth, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1))); + hevm.store(eth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); hevm.store(guniv3daiusdc1, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1))); hevm.store(guniv3daiusdc2, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1))); + hevm.store(reth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); + hevm.store(univ2daiusdc, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1))); + hevm.store(wsteth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1))); // 0x123 hackedValue = 0x0000000000000000000000000000000000000000000000000000000000000123; - assertTrue(OsmLike(eth).read() != hackedValue); assertTrue(OsmLike(btc).read() != hackedValue); - assertTrue(OsmLike(wsteth).read() != hackedValue); - assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue); + assertTrue(OsmLike(eth).read() != hackedValue); assertTrue(OsmLike(reth).read() != hackedValue); - assertTrue(OsmLike(gno).read() != hackedValue); + assertTrue(OsmLike(wsteth).read() != hackedValue); + assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue); assertTrue(OsmLike(guniv3daiusdc1).read() != hackedValue); assertTrue(OsmLike(guniv3daiusdc2).read() != hackedValue); assertTrue(OsmLike(univ2daiusdc).read() != hackedValue); @@ -204,14 +200,13 @@ contract MegaPokerTest is DSTest, PokingAddresses { hevm.warp(block.timestamp + 1 hours); megaPoker.poke(); - assertEq(OsmLike(eth).read(), hackedValue); assertEq(OsmLike(btc).read(), hackedValue); - assertEq(OsmLike(wsteth).read(), hackedValue); - assertEq(OsmLike(crvv1ethsteth).read(), hackedValue); + assertEq(OsmLike(eth).read(), hackedValue); assertEq(OsmLike(reth).read(), hackedValue); - assertEq(OsmLike(gno).read(), hackedValue); + assertEq(OsmLike(wsteth).read(), hackedValue); // Daily OSM's are not updated after one hour + assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue); assertTrue(OsmLike(guniv3daiusdc1).read() != hackedValue); assertTrue(OsmLike(guniv3daiusdc2).read() != hackedValue); assertTrue(OsmLike(univ2daiusdc).read() != hackedValue); @@ -239,9 +234,6 @@ contract MegaPokerTest is DSTest, PokingAddresses { (, mat) = SpotLike(spotter).ilks("WSTETH-B"); (,, spot,,) = VatLike(vat).ilks("WSTETH-B"); assertEq(spot, _rdiv(value, mat)); - (, mat) = SpotLike(spotter).ilks("CRVV1ETHSTETH-A"); - (,, spot,,) = VatLike(vat).ilks("CRVV1ETHSTETH-A"); - assertEq(spot, _rdiv(value, mat)); (, mat) = SpotLike(spotter).ilks("WBTC-B"); (,, spot,,) = VatLike(vat).ilks("WBTC-B"); assertEq(spot, _rdiv(value, mat)); @@ -251,11 +243,11 @@ contract MegaPokerTest is DSTest, PokingAddresses { (, mat) = SpotLike(spotter).ilks("RETH-A"); (,, spot,,) = VatLike(vat).ilks("RETH-A"); assertEq(spot, _rdiv(value, mat)); - (, mat) = SpotLike(spotter).ilks("GNO-A"); - (,, spot,,) = VatLike(vat).ilks("GNO-A"); - assertEq(spot, _rdiv(value, mat)); // These collateral types should not be updated after 1 hour + (, mat) = SpotLike(spotter).ilks("CRVV1ETHSTETH-A"); + (,, spot,,) = VatLike(vat).ilks("CRVV1ETHSTETH-A"); + assertTrue(spot != _rdiv(value, mat)); (, mat) = SpotLike(spotter).ilks("GUNIV3DAIUSDC1-A"); (,, spot,,) = VatLike(vat).ilks("GUNIV3DAIUSDC1-A"); assertTrue(spot != _rdiv(value, mat)); @@ -274,7 +266,6 @@ contract MegaPokerTest is DSTest, PokingAddresses { assertEq(OsmLike(guniv3daiusdc1).read(), hackedValue); assertEq(OsmLike(guniv3daiusdc2).read(), hackedValue); - (, mat) = SpotLike(spotter).ilks("GUNIV3DAIUSDC1-A"); (,, spot,,) = VatLike(vat).ilks("GUNIV3DAIUSDC1-A"); assertEq(spot, _rdiv(value, mat));