Skip to content

Commit 4d99a86

Browse files
authored
Hydrex AMO deployment (#2887)
* add deploy resilience * deploy Hydrex AMO * move a proxy to a more appropriate location
1 parent 960eda7 commit 4d99a86

12 files changed

Lines changed: 2306 additions & 7 deletions

contracts/contracts/proxies/BaseProxies.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ contract OETHBaseHarvesterProxy is InitializeGovernedUpgradeabilityProxy {
6565
contract OETHBaseCurveAMOProxy is InitializeGovernedUpgradeabilityProxy {
6666

6767
}
68+
69+
/**
70+
* @notice OETHbHydrexAMOProxy delegates calls to an OETHbHydrexAMOStrategy implementation
71+
*/
72+
contract OETHbHydrexAMOProxy is InitializeGovernedUpgradeabilityProxy {
73+
74+
}

contracts/contracts/proxies/Proxies.sol

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,3 @@ contract OUSDMorphoV2StrategyProxy is InitializeGovernedUpgradeabilityProxy {
249249
contract OETHSupernovaAMOProxy is InitializeGovernedUpgradeabilityProxy {
250250

251251
}
252-
253-
/**
254-
* @notice OETHbHydrexAMOProxy delegates calls to an OETHbHydrexAMOStrategy implementation
255-
*/
256-
contract OETHbHydrexAMOProxy is InitializeGovernedUpgradeabilityProxy {
257-
258-
}

contracts/deploy/deployActions.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const { replaceContractAt } = require("../utils/hardhat");
2424
const { resolveContract } = require("../utils/resolvers");
2525
const { impersonateAccount, getSigner } = require("../utils/signers");
2626
const { getDefenderSigner } = require("../utils/signersNoHardhat");
27+
const { sleep } = require("../utils/time");
2728
const { getTxOpts } = require("../utils/tx");
2829
const createxAbi = require("../abi/createx.json");
2930

@@ -899,6 +900,24 @@ const deployOETHSupernovaAMOStrategyImplementation = async () => {
899900
return cOETHSupernovaAMOStrategy;
900901
};
901902

903+
// Poll eth_getCode until bytecode appears at `addr`. Base's read replicas can
904+
// lag the sequencer by several seconds, so a fresh deploy receipt does not
905+
// guarantee that the next call's RPC node sees the contract yet.
906+
const waitForBytecode = async (
907+
addr,
908+
{ timeoutMs = 60000, pollMs = 2000 } = {}
909+
) => {
910+
const start = Date.now();
911+
while (Date.now() - start < timeoutMs) {
912+
const code = await ethers.provider.getCode(addr);
913+
if (code && code !== "0x") return;
914+
await sleep(pollMs);
915+
}
916+
throw new Error(
917+
`waitForBytecode: no code at ${addr} after ${timeoutMs}ms; RPC may still be lagging`
918+
);
919+
};
920+
902921
const deployOETHbHydrexAMOStrategyImplementation = async (gaugeAddress) => {
903922
const { deployerAddr } = await getNamedAccounts();
904923
const sDeployer = await ethers.provider.getSigner(deployerAddr);
@@ -927,6 +946,12 @@ const deployOETHbHydrexAMOStrategyImplementation = async (gaugeAddress) => {
927946
cOETHbHydrexAMOStrategyProxy.address
928947
);
929948

949+
// Wait for the Base RPC read replicas to surface the freshly deployed
950+
// implementation bytecode before the proxy initialize() runs. Without this,
951+
// estimateGas on the proxy can hit a stale node and revert with
952+
// "Cannot set a proxy implementation to a non-contract address".
953+
await waitForBytecode(dHydrexAMOStrategy.address);
954+
930955
// Initialize OETHb Hydrex AMO Strategy via the proxy.
931956
// Reward token is oHYDX (call option on HYDX). The Hydrex gauge emits oHYDX
932957
// from getReward(); off-chain plumbing exercises/sells it.

contracts/deployments/base/.migrations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
"045_deploy_pool_booster_merkl_factory": 1772622327,
4646
"046_crosschain_upgrade_remote": 1772750064,
4747
"047_merkl_pb_bribes_module": 1773930124,
48+
"048_oethb_hydrex_amo": 1778063838,
4849
"049_permissioned_rebase_module": 1778095983
4950
}

contracts/deployments/base/OETHbHydrexAMOProxy.json

Lines changed: 297 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)