Skip to content

feat: add dLEND recovery tooling#45

Open
Git-on-my-level wants to merge 10 commits intomainfrom
incident/dlend-recovery-kit
Open

feat: add dLEND recovery tooling#45
Git-on-my-level wants to merge 10 commits intomainfrom
incident/dlend-recovery-kit

Conversation

@Git-on-my-level
Copy link
Contributor

Summary

  • add repo-native dLEND recovery operator scripts for preflight checks, attacker debt repayment, and post-repay assertions
  • add Safe deploy tags for Ethereum mainnet recovery preflight and recovery batch generation
  • document the recovery sequence and the live reserve-scope nuance discovered during validation

Validation

  • yarn hardhat compile
  • npx tsc --noEmit --target ES2020 --module commonjs --moduleResolution node --esModuleInterop --skipLibCheck scripts/recovery/common.ts scripts/recovery/preflight-checks.ts scripts/recovery/repay-attacker-variable-debt.ts scripts/recovery/assert-post-repay.ts
  • yarn eslint deploy/32_dlend_recovery_mainnet/*.ts
  • yarn tsx scripts/recovery/preflight-checks.ts
  • RECOVERY_RESERVES_JSON='["0x07fFf99e1664d9B116fbC158c0E99785F81cA236","0xb419EcDd222981E7E54cEc316797eCb799c6AFdC","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0","0xae78736Cd615f374D3085123A210448E74Fc6393","0x9D39A5DE30e57443BfF2A8307A4256c8797A3497","0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD","0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b","0x356B8d89c1e1239Cbbb9dE4815c39A1474d5BA7D"]' PK_MAINNET_DEPLOYER='0x1111111111111111111111111111111111111111111111111111111111111111' USE_SAFE=true yarn hardhat deploy --network ethereum_mainnet --tags setup-ethereum-mainnet-dlend-recovery-preflight
  • RECOVERY_RESERVES_JSON='["0x07fFf99e1664d9B116fbC158c0E99785F81cA236","0xb419EcDd222981E7E54cEc316797eCb799c6AFdC","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0","0xae78736Cd615f374D3085123A210448E74Fc6393","0x9D39A5DE30e57443BfF2A8307A4256c8797A3497","0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD","0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b","0x356B8d89c1e1239Cbbb9dE4815c39A1474d5BA7D"]' yarn tsx scripts/recovery/assert-post-repay.ts (expected to fail against current live state until the admin batch and repay are executed)

Notes

  • during validation the live chain still showed dETH, WETH, wstETH, rETH, sUSDe, sUSDS, syrupUSDC, and syrupUSDT as unpaused low-supply reserves with flash loans enabled, so the recovery docs and batch inputs were widened to account for those markets rather than only the originally paused set

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eee50df8f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +75 to +76
const addressProvider = await ethers.getContractAt("PoolAddressesProvider", providerDeployment.address, signer);
const [poolAddress, poolConfiguratorAddress] = await Promise.all([addressProvider.getPool(), addressProvider.getPoolConfigurator()]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate the recovery rollout on Safe admin access

This preflight only verifies addresses, but the batch it green-lights queues PoolConfigurator calls such as setReservePause, setReserveBorrowing, setReserveFlashLoaning, setReserveFreeze, and configureReserveAsCollateral. In contracts/dlend/core/protocol/pool/PoolConfigurator.sol, those entrypoints are protected by onlyEmergencyOrPoolAdmin and onlyRiskOrPoolAdmins, and this repo’s other mainnet rollouts already have explicit ACL role checks/grant steps for the same reason. If the governance Safe can grant these roles but does not already hold them, recovery:safe:preflight still passes and the generated batch reverts when the Safe executes it.

Useful? React with 👍 / 👎.

```bash
export RPC_URL='https://ethereum-rpc.publicnode.com'
export ATTACKER='0xbA5E1E36b0305772D35509c694782fB9118D4ecc'
export RESERVES_JSON='["0x07fFf99e1664d9B116fbC158c0E99785F81cA236","0x8236a87084f8B84306f72007F36F2618A5634494","0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599","0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf","0x45804880De22913dAFE09f4980848ECE6EcbAf78","0xac3E018457B222d93114458476f3E3416Abbe38F","0xcf62F905562626CfcDD2261162a51fd02Fc9c5b6"]'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Snapshot the full reserve set in Phase 0

This recommended RESERVES_JSON narrows preflight-checks.ts to seven assets, but the rest of the playbook depends on Phase 0 discovering every unpaused low-supply flash-loan reserve before the operator derives RECOVERY_RESERVES_JSON. The addresses called out later in the same document (dETH, WETH, wstETH, rETH, sUSDe, sUSDS, syrupUSDC, syrupUSDT) are not in this list, so an operator who copies the snippet will never see them in the preflight output and can prepare an incomplete recovery batch.

Useful? React with 👍 / 👎.

- Add AtomicMarketListingHelper contract (stage/enable reserves with min supply)
- Deploy helper in pool configurator; wire preflight and new-listings deploy scripts
- Add viaIR override and stack-depth refactor for AtomicMarketListingHelper
- Skip setDebtCeiling when unchanged to avoid RESERVE_LIQUIDITY_NOT_ZERO on enable
- Add no-op default export to deploy/30_dlend_new_listings/common.ts for hardhat-deploy
- Update collateral rollout and recovery playbook docs; add AtomicMarketListingHelper tests

Made-with: Cursor
Patch flash-loan premium routing to remove the near-empty reserve index inflation path and add operator tooling to sanitize and permanently remove the quarantined cbBTC market safely.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant