fix: make Lend supply and collateral atomic#225
Merged
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
shivam-ef
reviewed
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
forge fmt --checkon all changed Solidity filesOPENOCEAN_API_KEYand transient Optimism RPC errors), with affected RPC suites passing on rerunforge lintcompiled successfully, then hit the repository's existing Solar import-resolution issue in vendored Aave V4 sourcesNote
Medium Risk
Changes core Aave supply semantics and several production paths (migration, sweeps, top-ups, module sandwiches); behavior is safer against supplied-but-not-collateral states, but any gateway supply failure handling now depends on full-call revert atomicity.
Overview
Lend gateway
supplyis now one atomic step: after pulling from the safe and calling the Spoke, the gateway also enables the reserve as collateral and emitsCollateralUsageSet.ILendGatewaydocuments that supply and collateral enablement succeed or revert together.Call sites no longer double-enable collateral: migration (
DebtManagerCore), credit resupply (CashLendLib), top-up auto-lend (TopUpDest), and sandwich resupply (ModuleLendGatewaySandwich) only callsupply. The mock gateway setsusingAsCollateralinsidesupplyto match.Observability on best-effort paths: auto-sweep, sandwich resupply, and top-up catch supply failures and emit
LendSupplyFailed(token, amount, raw revert bytes) viaCashEventEmitter/ module events, replacingLendSupplied. Batches can continue after a failed asset.Tests expect gateway
Suppliedevents for successful sweeps/borrows and cover collateral-enable failures rolling back that token while other tokens still sweep.Reviewed by Cursor Bugbot for commit b6363a1. Bugbot is set up for automated code reviews on this repo. Configure here.