Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4456ea6
ARM can be deployed to withdraw from the lending market on swaps
naddison36 Apr 10, 2026
9643e34
Cleanup of earlier changes
naddison36 Apr 10, 2026
6719069
getReserves now handles the new withdrawFromMarketOnSwap option
naddison36 Apr 10, 2026
6ce3c8b
format
naddison36 Apr 10, 2026
421110f
Removed withdrawFromMarketOnSwap config option. All ARMs will now wit…
naddison36 Apr 28, 2026
0b37eef
Fixed ambiguous asset params
naddison36 Apr 29, 2026
cdaa8d0
Natspec updates
naddison36 Apr 29, 2026
c3f27f7
Removed a layer of abstraction by flattening _transferAssetFrom into …
naddison36 Apr 29, 2026
71a1f4e
Removed the internal _transferAsset abstraction
naddison36 Apr 29, 2026
6153745
Refactor getReserves
naddison36 Apr 29, 2026
1063fba
Merge remote-tracking branch 'origin/main' into nicka/withdraw-on-swap
naddison36 Apr 29, 2026
d12c272
Replace the old performance fee on asset growth to fee on buying base…
naddison36 Apr 29, 2026
08dd860
Limit the liquidity a price can use
naddison36 Apr 29, 2026
7f361c7
Fixed _consumeSwapLiquidityLimit
naddison36 Apr 29, 2026
2117a42
Removed unchecked from Lido ARM
naddison36 Apr 29, 2026
4e176ef
Moved _migrateFeesAccrued up to under _initARM
naddison36 Apr 29, 2026
2b53b88
Updated setPrices Hardhat task
naddison36 Apr 29, 2026
79bf85a
Using swap multiplier to calculate accrued fee (#217)
naddison36 May 5, 2026
2c60ddb
fmt
clement-ux May 5, 2026
2973e53
Merge remote-tracking branch 'origin/main' into nicka/withdraw-on-swap
naddison36 May 8, 2026
abd11a5
Added new Ethena upgrade script
naddison36 May 8, 2026
7f87b65
Multiple base assets (#221)
naddison36 May 14, 2026
518cacc
Value base assets in the base withdrawal queue at the cross price (#225)
naddison36 May 14, 2026
28d4fb6
Added buyLiquidityRemaining and sellLiquidityRemaining to the Tradera…
naddison36 May 15, 2026
135f1c6
Now we value base assets in the withdrawal queue at the cross price, …
naddison36 May 15, 2026
1988a98
The operator can now claim a redeem on behalf of a redeemer
naddison36 May 15, 2026
6ef36ee
Protect against overriding unstaker contracts
naddison36 May 15, 2026
e5a4c4c
Cleanup of deprecated variables to reduce contract size
naddison36 May 15, 2026
6916fee
Formatting
naddison36 May 15, 2026
75f5756
Simplified collectFees
naddison36 May 15, 2026
873b46b
add comment
sparrowDom May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AGENTS.md

This file provides guidance to Codex when working with code in this repository.

## Documentation Conventions

- When writing NatSpec for scaled or non-obvious numeric parameters, include concrete examples.
For example: `10,000 = 100% fee`, `500 = 5% fee`, `1e18 = 100% buffer`, `0.1e18 = 10% buffer`.

2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ make simulate-sonic-deploys # Dry run Sonic
- Test base class: `test/Base.sol` with standard accounts (alice, bob, charlie) and shared setup
- Dependencies managed by Soldeer (not npm) for Solidity libs
- Prefer flat structure with early returns over deeply nested if/else blocks
- When writing NatSpec for scaled or non-obvious numeric parameters, include concrete examples.
For example: `10,000 = 100% fee`, `500 = 5% fee`, `1e18 = 100% buffer`, `0.1e18 = 10% buffer`.
Binary file modified docs/plantuml/EthenaContracts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions docs/plantuml/EthenaContracts.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,34 @@
!$changedColor = Orange
!$thirdPartyColor = WhiteSmoke

legend
blue - Origin
' legend
' blue - Origin
' green - new
' orange - changed
white - 3rd Party
end legend
' white - 3rd Party
' end legend

title "Ethena\nAutomated Redemption Manager (ARM)\nContract Dependencies"

object "EthenaARM" as arm <<Origin>><<Proxy>> #$originColor {
shares: ARM-sUSDe-USDe
assets: sUSDe, USDe
liquidity asset: USDe
base asset: sUSDe
}

object "CapManager" as capMan <<Origin>><<Proxy>> #$originColor {
}

object "EthenaAssetAdapter" as adapter <<Origin>><<Proxy>> #$originColor {
base asset: sUSDe
asset: USDe
}

object "Ethena\nUnstaker" as unstaker <<Origin>> #$originColor {
}

object "Ethena\nMinting" as em <<Ethena>><<Proxy>> #$thirdPartyColor {
object "StakedUSDe" as susde <<Ethena>><<Proxy>> #$thirdPartyColor {
asset: USDe
}

' object "Aave Market" as aMarket <<Origin>><<Proxy>> #$originColor {
Expand All @@ -43,14 +49,15 @@ object "aUSDe" as aUSDe <<Aave>> #$thirdPartyColor {
}

arm <.> capMan
arm ..> unstaker
arm ...> em
unstaker ..> em
arm ..> adapter
adapter ..> unstaker
adapter ..> susde
unstaker ..> susde
' arm ..> aMarket
' aMarket ..> aVault
' aVault ..> aUSDe
' aMarket ...> aUSDe
arm ..> aVault
aVault ..> aUSDe

@enduml
@enduml
Binary file modified docs/plantuml/etherFiContracts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 26 additions & 6 deletions docs/plantuml/etherFiContracts.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

' legend
' blue - Origin
' ' green - new
' ' orange - changed
' green - new
' orange - changed
' white - 3rd Party
' end legend

Expand All @@ -21,7 +21,22 @@ object "ZapperARM" as zap <<Origin>> #$originColor {

object "EtherFiARM" as arm <<Origin>><<Proxy>> #$originColor {
shares: ARM-eETH-WETH
assets: eETH, WETH
liquidity asset: WETH
base assets: eETH, weETH
}

object "EtherFiAssetAdapter" as eethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: eETH
pegged: true
}

object "WeETHAssetAdapter" as weethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: weETH
wrapped asset: eETH
}

object "weETH" as weeth <<EtherFi>> #$thirdPartyColor {
asset: eETH
}

object "CapManager" as capMan <<Origin>><<Proxy>> #$originColor {
Expand All @@ -43,9 +58,14 @@ object "Yearn WETH ARM Vault" as morpho <<Morpho>> #$thirdPartyColor {

zap ..> arm
arm <.> capMan
arm ...> rm
arm ...> wq
arm ..> eethAdapter
arm ..> weethAdapter
eethAdapter ...> rm
eethAdapter ...> wq
weethAdapter ..> weeth
weethAdapter ...> rm
weethAdapter ...> wq
arm ..> morphoMarket
morphoMarket ..> morpho

@enduml
@enduml
Binary file modified docs/plantuml/lidoContracts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions docs/plantuml/lidoContracts.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

' legend
' blue - Origin
' ' green - new
' ' orange - changed
' green - new
' orange - changed
' white - 3rd Party
' end legend

Expand All @@ -21,7 +21,22 @@ object "ZapperLidoARM" as zap <<Origin>> #$originColor {

object "LidoARM" as arm <<Origin>><<Proxy>> #$originColor {
shares: ARM-stETH-WETH
assets: stETH, WETH
liquidity asset: WETH
base assets: stETH, wstETH
}

object "StETHAssetAdapter" as stethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: stETH
pegged: true
}

object "WstETHAssetAdapter" as wstethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: wstETH
wrapped asset: stETH
}

object "wstETH" as wsteth <<Lido>> #$thirdPartyColor {
asset: stETH
}

object "CapManager" as capMan <<Origin>><<Proxy>> #$originColor {
Expand All @@ -41,8 +56,12 @@ object "Yearn WETH ARM Vault" as morpho <<Morpho>> #$thirdPartyColor {

zap <..> arm
arm <.> capMan
arm ..> lidoQ
arm ..> stethAdapter
arm ..> wstethAdapter
stethAdapter ..> lidoQ
wstethAdapter ..> wsteth
wstethAdapter ..> lidoQ
arm ..> morphoMarket
morphoMarket ..> morpho

@enduml
@enduml
Binary file modified docs/plantuml/originContracts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions docs/plantuml/originContracts.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

' legend
' blue - Origin
' ' green - new
' ' orange - changed
' green - new
' orange - changed
' white - 3rd Party
' end legend

Expand All @@ -21,7 +21,22 @@ object "ZapperARM" as zap <<Origin>> #$originColor {

object "OriginARM" as arm <<Origin>><<Proxy>> #$originColor {
shares: ARM-oETH-WETH
assets: oETH, WETH
liquidity asset: WETH
base assets: OETH, wOETH
}

object "OriginAssetAdapter" as oethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: OETH
pegged: true
}

object "WrappedOriginAssetAdapter" as woethAdapter <<Origin>><<Proxy>> #$originColor {
base asset: wOETH
wrapped asset: OETH
}

object "wOETH" as woeth <<Origin>><<ERC4626>> #$thirdPartyColor {
asset: OETH
}

object "OETHVault" as oethVault <<Origin>><<Proxy>> #$thirdPartyColor {
Expand All @@ -37,8 +52,12 @@ object "Yearn WETH ARM Vault" as morpho <<Morpho>> #$thirdPartyColor {
}

zap ..> arm
arm ..> oethVault
arm ..> oethAdapter
arm ..> woethAdapter
oethAdapter ..> oethVault
woethAdapter ..> woeth
woethAdapter ..> oethVault
arm ..> morphoMarket
morphoMarket ..> morpho

@enduml
@enduml
2 changes: 1 addition & 1 deletion script/deploy/mainnet/000_Example.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract $000_Example is AbstractDeployScript("000_Example") {
// vm.broadcast (real) or vm.prank (fork).

// Example: Deploy a new implementation contract
newImplementation = new LidoARM(steth, weth, Mainnet.LIDO_WITHDRAWAL, 10 minutes, 0, 0);
newImplementation = new LidoARM(weth, 10 minutes, 0, 0);

// Example: Deploy a proxy with implementation
// Proxy proxy = new Proxy();
Expand Down
44 changes: 36 additions & 8 deletions script/deploy/mainnet/003_UpgradeLidoARMScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {LidoARM} from "contracts/LidoARM.sol";
import {Mainnet} from "contracts/utils/Addresses.sol";
import {CapManager} from "contracts/CapManager.sol";
import {ZapperLidoARM} from "contracts/ZapperLidoARM.sol";
import {StETHAssetAdapter} from "contracts/adapters/StETHAssetAdapter.sol";
import {WstETHAssetAdapter} from "contracts/adapters/WstETHAssetAdapter.sol";
import {IERC20, LegacyAMM} from "contracts/Interfaces.sol";

// Deployment
Expand All @@ -19,6 +21,8 @@ contract $003_UpgradeLidoARMMainnetScript is AbstractDeployScript("003_UpgradeLi
LidoARM lidoARM;
CapManager capManager;
ZapperLidoARM zapper;
StETHAssetAdapter stethAdapter;
WstETHAssetAdapter wstethAdapter;

function _execute() internal override {
// 1. Record the proxy address used for AMM v1
Expand Down Expand Up @@ -46,10 +50,25 @@ contract $003_UpgradeLidoARMMainnetScript is AbstractDeployScript("003_UpgradeLi

// 7. Deploy Lido implementation
uint256 claimDelay = 10 minutes;
lidoARMImpl = new LidoARM(Mainnet.STETH, Mainnet.WETH, Mainnet.LIDO_WITHDRAWAL, claimDelay, 0, 0);
lidoARMImpl = new LidoARM(Mainnet.WETH, claimDelay, 0, 0);
_recordDeployment("LIDO_ARM_IMPL", address(lidoARMImpl));

// 8. Deploy the Zapper
// 8. Deploy asset adapter implementations and proxies
stethAdapter = new StETHAssetAdapter(Mainnet.LIDO_ARM, Mainnet.WETH, Mainnet.STETH, Mainnet.LIDO_WITHDRAWAL);
_recordDeployment("LIDO_ARM_STETH_ADAPTER_IMPL", address(stethAdapter));
Proxy stethAdapterProxy = new Proxy();
stethAdapterProxy.initialize(address(stethAdapter), Mainnet.TIMELOCK, abi.encodeWithSignature("initialize()"));
_recordDeployment("LIDO_ARM_STETH_ADAPTER", address(stethAdapterProxy));

wstethAdapter = new WstETHAssetAdapter(
Mainnet.LIDO_ARM, Mainnet.WETH, Mainnet.STETH, Mainnet.WSTETH, Mainnet.LIDO_WITHDRAWAL
);
_recordDeployment("LIDO_ARM_WSTETH_ADAPTER_IMPL", address(wstethAdapter));
Proxy wstethAdapterProxy = new Proxy();
wstethAdapterProxy.initialize(address(wstethAdapter), Mainnet.TIMELOCK, abi.encodeWithSignature("initialize()"));
_recordDeployment("LIDO_ARM_WSTETH_ADAPTER", address(wstethAdapterProxy));

// 9. Deploy the Zapper
zapper = new ZapperLidoARM(Mainnet.WETH, Mainnet.LIDO_ARM);
zapper.setOwner(Mainnet.STRATEGIST);
_recordDeployment("LIDO_ARM_ZAPPER", address(zapper));
Expand All @@ -59,6 +78,8 @@ contract $003_UpgradeLidoARMMainnetScript is AbstractDeployScript("003_UpgradeLi
Proxy lidoARMProxy_ = Proxy(payable(resolver.resolve("LIDO_ARM")));
address lidoARMImpl_ = resolver.resolve("LIDO_ARM_IMPL");
address capManProxy_ = resolver.resolve("LIDO_ARM_CAP_MAN");
address stethAdapter_ = resolver.resolve("LIDO_ARM_STETH_ADAPTER");
address wstethAdapter_ = resolver.resolve("LIDO_ARM_WSTETH_ADAPTER");

// Skip if already upgraded on-chain
if (lidoARMProxy_.implementation() == lidoARMImpl_) return;
Expand Down Expand Up @@ -94,12 +115,19 @@ contract $003_UpgradeLidoARMMainnetScript is AbstractDeployScript("003_UpgradeLi
lidoARMProxy_.upgradeToAndCall(lidoARMImpl_, data);
LidoARM lidoARM_ = LidoARM(payable(Mainnet.LIDO_ARM));

// Set the price that buy and sell prices can not cross
LidoARM(payable(Mainnet.LIDO_ARM)).setCrossPrice(0.9998e36);

// Set the buy price with a 2.5 basis point discount.
// The sell price has a 1 basis point discount.
LidoARM(payable(Mainnet.LIDO_ARM)).setPrices(0.99975e36, 0.9999e36);
lidoARM_.addBaseAsset(
Mainnet.STETH, stethAdapter_, 0.99975e36, 0.9999e36, type(uint128).max, type(uint128).max, 0.9998e36, true
);
lidoARM_.addBaseAsset(
Mainnet.WSTETH,
wstethAdapter_,
0.99975e36,
0.9999e36,
type(uint128).max,
type(uint128).max,
0.9998e36,
false
);

// transfer ownership of the Lido ARM proxy to the mainnet 5/8 multisig
lidoARMProxy_.setOwner(Mainnet.GOV_MULTISIG);
Expand Down
5 changes: 4 additions & 1 deletion script/deploy/mainnet/004_UpdateCrossPriceScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.23;
// Deployment
import {AbstractDeployScript} from "script/deploy/helpers/AbstractDeployScript.s.sol";
import {GovHelper, GovProposal} from "script/deploy/helpers/GovHelper.sol";
import {Mainnet} from "contracts/utils/Addresses.sol";

contract $004_UpdateCrossPriceMainnetScript is AbstractDeployScript("004_UpdateCrossPriceScript") {
using GovHelper for GovProposal;
Expand All @@ -13,6 +14,8 @@ contract $004_UpdateCrossPriceMainnetScript is AbstractDeployScript("004_UpdateC

uint256 newCrossPrice = 0.9999 * 1e36;

govProposal.action(resolver.resolve("LIDO_ARM"), "setCrossPrice(uint256)", abi.encode(newCrossPrice));
govProposal.action(
resolver.resolve("LIDO_ARM"), "setCrossPrice(address,uint256)", abi.encode(Mainnet.STETH, newCrossPrice)
);
}
}
31 changes: 26 additions & 5 deletions script/deploy/mainnet/005_RegisterLidoWithdrawalsScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity 0.8.23;

// Contract
import {LidoARM} from "contracts/LidoARM.sol";
import {Proxy} from "contracts/Proxy.sol";
import {StETHAssetAdapter} from "contracts/adapters/StETHAssetAdapter.sol";
import {Mainnet} from "contracts/utils/Addresses.sol";

// Deployment
Expand All @@ -15,17 +17,36 @@ contract $005_RegisterLidoWithdrawalsScript is AbstractDeployScript("005_Registe
function _execute() internal override {
// 1. Deploy new Lido ARM implementation
uint256 claimDelay = 10 minutes;
LidoARM lidoARMImpl = new LidoARM(Mainnet.STETH, Mainnet.WETH, Mainnet.LIDO_WITHDRAWAL, claimDelay, 0, 0);
LidoARM lidoARMImpl = new LidoARM(Mainnet.WETH, claimDelay, 0, 0);
_recordDeployment("LIDO_ARM_IMPL", address(lidoARMImpl));

StETHAssetAdapter stethAdapter =
new StETHAssetAdapter(Mainnet.LIDO_ARM, Mainnet.WETH, Mainnet.STETH, Mainnet.LIDO_WITHDRAWAL);
_recordDeployment("LIDO_ARM_STETH_ADAPTER_IMPL", address(stethAdapter));
Proxy stethAdapterProxy = new Proxy();
stethAdapterProxy.initialize(address(stethAdapter), Mainnet.TIMELOCK, abi.encodeWithSignature("initialize()"));
_recordDeployment("LIDO_ARM_STETH_ADAPTER", address(stethAdapterProxy));
}

function _buildGovernanceProposal() internal override {
govProposal.setDescription("Upgrade Lido ARM and register Lido withdrawal requests");

bytes memory callData = abi.encodeWithSignature("registerLidoWithdrawalRequests()");
govProposal.setDescription("Upgrade Lido ARM and add stETH asset adapter");

bytes memory proxyData = abi.encode(resolver.resolve("LIDO_ARM_IMPL"), callData);
bytes memory proxyData = abi.encode(resolver.resolve("LIDO_ARM_IMPL"), "");

govProposal.action(resolver.resolve("LIDO_ARM"), "upgradeToAndCall(address,bytes)", proxyData);
govProposal.action(
resolver.resolve("LIDO_ARM"),
"addBaseAsset(address,address,uint256,uint256,uint256,uint256,uint256,bool)",
abi.encode(
Mainnet.STETH,
resolver.resolve("LIDO_ARM_STETH_ADAPTER"),
0.99975e36,
0.9999e36,
type(uint128).max,
type(uint128).max,
0.9998e36,
true
)
);
}
}
Loading
Loading