Skip to content

Commit ab3579a

Browse files
author
jar-o
committed
Removes GNO, plus cleanup
1 parent b9881a8 commit ab3579a

File tree

3 files changed

+39
-49
lines changed

3 files changed

+39
-49
lines changed

scripts/test-forge.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export DAPP_BUILD_OPTIMIZE=1
2020
export FOUNDRY_OPTIMIZER_RUNS=1000
2121

2222
if [[ -z "$MATCH" && -z "$BLOCK" ]]; then
23-
forge test --fork-url "$ETH_RPC_URL" --force
23+
forge test --fork-url "$ETH_RPC_URL" --force -vvv
2424
elif [[ -n "$MATCH" ]]; then
2525
forge test --fork-url "$ETH_RPC_URL" --match "$MATCH" -vvv --force
2626
elif [[ -n "$MATCH_TEST" ]]; then

src/MegaPoker.sol

+22-23
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
pragma solidity ^0.6.12;
2020

2121
contract PokingAddresses {
22-
// OSMs and Spotter addresses
23-
address constant eth = 0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763;
22+
// OSMs
2423
address constant btc = 0xf185d0682d50819263941e5f4EacC763CC5C6C42;
25-
address constant univ2daiusdc = 0x25D03C2C928ADE19ff9f4FFECc07d991d0df054B;
24+
address constant eth = 0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763;
25+
address constant reth = 0xeE7F0b350aA119b3d05DC733a4621a81972f7D47;
2626
address constant wsteth = 0xFe7a2aC0B945f12089aEEB6eCebf4F384D9f043F;
27+
2728
address constant crvv1ethsteth = 0xEa508F82728927454bd3ce853171b0e2705880D4;
2829
address constant guniv3daiusdc1 = 0x7F6d78CC0040c87943a0e0c140De3F77a273bd58;
2930
address constant guniv3daiusdc2 = 0xcCBa43231aC6eceBd1278B90c3a44711a00F4e93;
31+
address constant univ2daiusdc = 0x25D03C2C928ADE19ff9f4FFECc07d991d0df054B;
32+
33+
// Spotter
3034
address constant spotter = 0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3;
31-
address constant reth = 0xeE7F0b350aA119b3d05DC733a4621a81972f7D47;
32-
address constant gno = 0xd800ca44fFABecd159c7889c3bf64a217361AEc8;
3335
}
3436

3537
contract MegaPoker is PokingAddresses {
@@ -40,40 +42,37 @@ contract MegaPoker is PokingAddresses {
4042
bool ok;
4143

4244
// poke() = 0x18178358
43-
(ok,) = eth.call(abi.encodeWithSelector(0x18178358));
4445
(ok,) = btc.call(abi.encodeWithSelector(0x18178358));
45-
(ok,) = wsteth.call(abi.encodeWithSelector(0x18178358));
46-
(ok,) = crvv1ethsteth.call(abi.encodeWithSelector(0x18178358));
46+
(ok,) = eth.call(abi.encodeWithSelector(0x18178358));
4747
(ok,) = reth.call(abi.encodeWithSelector(0x18178358));
48-
(ok,) = gno.call(abi.encodeWithSelector(0x18178358));
49-
48+
(ok,) = wsteth.call(abi.encodeWithSelector(0x18178358));
5049

5150
// poke(bytes32) = 0x1504460f
5251
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-A")));
53-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-A")));
5452
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-B")));
5553
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("ETH-C")));
56-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-A")));
57-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-B")));
58-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("CRVV1ETHSTETH-A")));
54+
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("RETH-A")));
55+
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-A")));
5956
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-B")));
6057
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WBTC-C")));
61-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("RETH-A")));
62-
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GNO-A")));
63-
58+
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-A")));
59+
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("WSTETH-B")));
6460

65-
// Daily pokes
66-
// Reduced cost pokes
61+
// Daily pokes, i.e. reduced cost pokes
6762
if (last <= block.timestamp - 1 days) {
68-
// poke
69-
// The GUINIV3DAIUSDCX Oracles are very expensive to poke, and the price should not
70-
// change frequently, so they are getting poked only once a day.
63+
// Poke
64+
(ok,) = crvv1ethsteth.call(abi.encodeWithSelector(0x18178358));
65+
66+
// The GUINIV3DAIUSDCX Oracles are very expensive to poke, and the
67+
// price should not change frequently, so they are getting poked
68+
// only once a day.
7169
(ok,) = guniv3daiusdc1.call(abi.encodeWithSelector(0x18178358));
7270
(ok,) = guniv3daiusdc2.call(abi.encodeWithSelector(0x18178358));
7371

7472
(ok,) = univ2daiusdc.call(abi.encodeWithSelector(0x18178358));
7573

76-
// spotter.poke
74+
// Spotter pokes
75+
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("CRVV1ETHSTETH-A")));
7776
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC1-A")));
7877
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("GUNIV3DAIUSDC2-A")));
7978
(ok,) = spotter.call(abi.encodeWithSelector(0x1504460f, bytes32("UNIV2DAIUSDC-A")));

src/MegaPoker.t.sol

+16-25
Original file line numberDiff line numberDiff line change
@@ -162,56 +162,51 @@ contract MegaPokerTest is DSTest, PokingAddresses {
162162
hevm.warp(block.timestamp + 1 hours);
163163
megaPoker.poke();
164164
assertEq(megaPoker.last(), block.timestamp - 1 hours);
165-
//
166165

167166
// Hacking nxt price to 0x123 (and making it valid)
168167
bytes32 hackedValue = 0x0000000000000000000000000000000100000000000000000000000000000123;
169-
hevm.store(eth, bytes32(uint256(4)), hackedValue);
170168
hevm.store(btc, bytes32(uint256(4)), hackedValue);
171-
hevm.store(univ2daiusdc, bytes32(uint256(4)), hackedValue);
172-
hevm.store(wsteth, bytes32(uint256(4)), hackedValue);
173169
hevm.store(crvv1ethsteth, bytes32(uint256(4)), hackedValue);
170+
hevm.store(eth, bytes32(uint256(4)), hackedValue);
174171
hevm.store(guniv3daiusdc1, bytes32(uint256(4)), hackedValue);
175172
hevm.store(guniv3daiusdc2, bytes32(uint256(4)), hackedValue);
176173
hevm.store(reth, bytes32(uint256(4)), hackedValue);
177-
hevm.store(gno, bytes32(uint256(4)), hackedValue);
174+
hevm.store(univ2daiusdc, bytes32(uint256(4)), hackedValue);
175+
hevm.store(wsteth, bytes32(uint256(4)), hackedValue);
178176

179177
// Whitelisting tester address
180-
hevm.store(eth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
181178
hevm.store(btc, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
182-
hevm.store(univ2daiusdc, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1)));
183-
hevm.store(wsteth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
184-
hevm.store(reth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
185-
hevm.store(gno, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
186179
hevm.store(crvv1ethsteth, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1)));
180+
hevm.store(eth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
187181
hevm.store(guniv3daiusdc1, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1)));
188182
hevm.store(guniv3daiusdc2, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1)));
183+
hevm.store(reth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
184+
hevm.store(univ2daiusdc, keccak256(abi.encode(address(this), uint256(2))), bytes32(uint256(1)));
185+
hevm.store(wsteth, keccak256(abi.encode(address(this), uint256(5))), bytes32(uint256(1)));
189186

190187
// 0x123
191188
hackedValue = 0x0000000000000000000000000000000000000000000000000000000000000123;
192189

193-
assertTrue(OsmLike(eth).read() != hackedValue);
194190
assertTrue(OsmLike(btc).read() != hackedValue);
195-
assertTrue(OsmLike(wsteth).read() != hackedValue);
196-
assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue);
191+
assertTrue(OsmLike(eth).read() != hackedValue);
197192
assertTrue(OsmLike(reth).read() != hackedValue);
198-
assertTrue(OsmLike(gno).read() != hackedValue);
193+
assertTrue(OsmLike(wsteth).read() != hackedValue);
199194

195+
assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue);
200196
assertTrue(OsmLike(guniv3daiusdc1).read() != hackedValue);
201197
assertTrue(OsmLike(guniv3daiusdc2).read() != hackedValue);
202198
assertTrue(OsmLike(univ2daiusdc).read() != hackedValue);
203199

204200
hevm.warp(block.timestamp + 1 hours);
205201
megaPoker.poke();
206202

207-
assertEq(OsmLike(eth).read(), hackedValue);
208203
assertEq(OsmLike(btc).read(), hackedValue);
209-
assertEq(OsmLike(wsteth).read(), hackedValue);
210-
assertEq(OsmLike(crvv1ethsteth).read(), hackedValue);
204+
assertEq(OsmLike(eth).read(), hackedValue);
211205
assertEq(OsmLike(reth).read(), hackedValue);
212-
assertEq(OsmLike(gno).read(), hackedValue);
206+
assertEq(OsmLike(wsteth).read(), hackedValue);
213207

214208
// Daily OSM's are not updated after one hour
209+
assertTrue(OsmLike(crvv1ethsteth).read() != hackedValue);
215210
assertTrue(OsmLike(guniv3daiusdc1).read() != hackedValue);
216211
assertTrue(OsmLike(guniv3daiusdc2).read() != hackedValue);
217212
assertTrue(OsmLike(univ2daiusdc).read() != hackedValue);
@@ -239,9 +234,6 @@ contract MegaPokerTest is DSTest, PokingAddresses {
239234
(, mat) = SpotLike(spotter).ilks("WSTETH-B");
240235
(,, spot,,) = VatLike(vat).ilks("WSTETH-B");
241236
assertEq(spot, _rdiv(value, mat));
242-
(, mat) = SpotLike(spotter).ilks("CRVV1ETHSTETH-A");
243-
(,, spot,,) = VatLike(vat).ilks("CRVV1ETHSTETH-A");
244-
assertEq(spot, _rdiv(value, mat));
245237
(, mat) = SpotLike(spotter).ilks("WBTC-B");
246238
(,, spot,,) = VatLike(vat).ilks("WBTC-B");
247239
assertEq(spot, _rdiv(value, mat));
@@ -251,11 +243,11 @@ contract MegaPokerTest is DSTest, PokingAddresses {
251243
(, mat) = SpotLike(spotter).ilks("RETH-A");
252244
(,, spot,,) = VatLike(vat).ilks("RETH-A");
253245
assertEq(spot, _rdiv(value, mat));
254-
(, mat) = SpotLike(spotter).ilks("GNO-A");
255-
(,, spot,,) = VatLike(vat).ilks("GNO-A");
256-
assertEq(spot, _rdiv(value, mat));
257246

258247
// These collateral types should not be updated after 1 hour
248+
(, mat) = SpotLike(spotter).ilks("CRVV1ETHSTETH-A");
249+
(,, spot,,) = VatLike(vat).ilks("CRVV1ETHSTETH-A");
250+
assertTrue(spot != _rdiv(value, mat));
259251
(, mat) = SpotLike(spotter).ilks("GUNIV3DAIUSDC1-A");
260252
(,, spot,,) = VatLike(vat).ilks("GUNIV3DAIUSDC1-A");
261253
assertTrue(spot != _rdiv(value, mat));
@@ -274,7 +266,6 @@ contract MegaPokerTest is DSTest, PokingAddresses {
274266
assertEq(OsmLike(guniv3daiusdc1).read(), hackedValue);
275267
assertEq(OsmLike(guniv3daiusdc2).read(), hackedValue);
276268

277-
278269
(, mat) = SpotLike(spotter).ilks("GUNIV3DAIUSDC1-A");
279270
(,, spot,,) = VatLike(vat).ilks("GUNIV3DAIUSDC1-A");
280271
assertEq(spot, _rdiv(value, mat));

0 commit comments

Comments
 (0)