Skip to content

Commit 9e47a3c

Browse files
authored
Off-chain cleanup (#302)
* Added optional --id param to the auto claim withdrawal actions * Updated ARMs in the README * README update * Added new getReserves interface * Removed Defender from the repo
1 parent b1e1530 commit 9e47a3c

19 files changed

Lines changed: 104 additions & 2545 deletions

.claude/CLAUDE.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ All ARMs are deployed behind `Proxy.sol` (EIP-1967) for upgradeability.
7272

7373
### Off-Chain Automation (`src/js/`)
7474

75-
- **`src/js/actions/`** - OpenZeppelin Defender Actions (auto-withdraw, auto-claim, price setting, fee collection, allocation). Bundled with rollup.
76-
- **`src/js/tasks/`** - Hardhat tasks for admin operations.
75+
- **`src/js/tasks/actions/`** - Talos scheduled actions.
76+
- **`src/js/tasks/`** - Hardhat tasks for admin and operational jobs.
7777
- **`src/js/utils/`** - Shared utilities (1Inch/Kyber integration, address parsing, pricing helpers).
7878

79-
Actions are bundled via: `pnpm rollup -c src/js/actions/rollup.config.cjs`
80-
8179
**Scheduled actions (Talos):** the runner's cron/manual actions live in `src/js/tasks/actions/*.ts`, are scheduled in `migrations/seed_schedules.sql`, and are catalogued in `docs/ACTIONS.md`. When you add, remove, or change the behaviour of a scheduled action, update `docs/ACTIONS.md` in the same change.
8280

8381
## Deployment

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ test/invariants/.foundry-failures
3333
lcov.info*
3434
crytic-export
3535

36-
# Defender Actions
3736
dist
3837
cache_hardhat
3938

@@ -43,4 +42,4 @@ build/deployments-fork*.json
4342
*.html
4443

4544
# Other
46-
.DS_Store
45+
.DS_Store

CLAUDE.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ All ARMs are deployed behind `Proxy.sol` (EIP-1967) for upgradeability.
6262

6363
### Off-Chain Automation (`src/js/`)
6464

65-
- **`src/js/actions/`** - OpenZeppelin Defender Actions (auto-withdraw, auto-claim, price setting, fee collection, allocation). Bundled with rollup.
66-
- **`src/js/tasks/`** - Hardhat tasks for admin operations.
67-
68-
Actions are bundled via: `pnpm rollup -c src/js/actions/rollup.config.cjs`
65+
- **`src/js/tasks/actions/`** - Talos scheduled actions.
66+
- **`src/js/tasks/`** - Hardhat tasks for admin and operational jobs.
6967

7068
**Scheduled actions (Talos):** the runner's cron/manual actions live in `src/js/tasks/actions/*.ts`, are scheduled in `migrations/seed_schedules.sql`, and are catalogued in `docs/ACTIONS.md`. When you add, remove, or change the behaviour of a scheduled action, update `docs/ACTIONS.md` in the same change.
7169

Hardhat.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,19 @@ anvil --fork-url="$MAINNET_URL"
1212
2. In a separate terminal, run the `requestWithdraw` task against the local fork.
1313

1414
```
15-
unset DEFENDER_API_KEY
16-
unset DEFENDER_API_SECRET
1715
export IMPERSONATE=0x39878253374355DBcc15C86458F084fb6f2d6DE7
1816
export DEBUG=origin*
1917
yarn hardhat requestWithdraw --amount 300 --network local
2018
```
2119

22-
3. Create a Relayer API key
23-
24-
See [Generate Relayer API key](./README.md#generate-relayer-api-key) instructions in the README.
25-
26-
4. Run the real thing after generating an API key for the Relay account
20+
3. Run the real task from an environment with AWS KMS credentials configured.
2721

2822
```
2923
unset IMPERSONATE
30-
export DEFENDER_API_KEY=
31-
export DEFENDER_API_SECRET=
3224
export DEBUG=origin*
3325
yarn hardhat requestWithdraw --amount 300 --network mainnet
3426
```
3527

36-
5. Delete the Relayer API key
37-
3828
For more information, see the `requestWithdraw` help
3929

4030
```
@@ -52,29 +42,19 @@ anvil --fork-url="$MAINNET_URL"
5242
2. In a separate terminal, run the `autoClaimWithdraw` task against the local fork.
5343

5444
```
55-
unset DEFENDER_API_KEY
56-
unset DEFENDER_API_SECRET
5745
export IMPERSONATE=0x39878253374355DBcc15C86458F084fb6f2d6DE7
5846
export DEBUG=origin*
5947
yarn hardhat autoClaimWithdraw --network local
6048
```
6149

62-
3. Create a Relayer API key
63-
64-
See [Generate Relayer API key](./README.md#generate-relayer-api-key) instructions in the README.
65-
66-
4. Run the real thing after generating an API key for the Relay account
50+
3. Run the real task from an environment with AWS KMS credentials configured.
6751

6852
```
6953
unset IMPERSONATE
70-
export DEFENDER_API_KEY=
71-
export DEFENDER_API_SECRET=
7254
export DEBUG=origin*
7355
yarn hardhat autoClaimWithdraw --network mainnet
7456
```
7557

76-
5. Delete the Relayer API key
77-
7858
For more information, see the `autoClaimWithdraw` help
7959

8060
```

README.md

Lines changed: 25 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Automated Redemption Manager (ARM)
22

3-
There are currently three ARM contracts:
3+
There are currently five ARM contracts:
44

55
1. [Lido ARM](https://docs.originprotocol.com/automated-redemption-manager-arm/steth-arm) on Ethereum with stETH as the base asset and WETH as the liquidity asset.
66
2. [EtherFi ARM](https://docs.originprotocol.com/automated-redemption-manager-arm/eeth-arm) on Ethereum with eETH as the base asset and WETH as the liquidity asset.
7-
3. Ethena ARM on Ethereum with sUSDe as the base asset and USDe as the liquidity asset.
8-
2. [OS ARM](https://docs.originprotocol.com/os-arm) on Sonic with OS as the base asset and wS as the liquidity asset.
9-
3. OETH ARM on Ethereum with OETH as the base asset and WETH as the liquidity asset.
7+
3. [Ethena ARM](https://docs.originprotocol.com/automated-redemption-manager-arm/susde-arm) on Ethereum with sUSDe as the base asset and USDe as the liquidity asset.
8+
4. USD ARM on Ethereum with PYUSD and USDG as base assets and USDC as the liquidity asset.
9+
5. [OS ARM](https://docs.originprotocol.com/os-arm) on Sonic with OS as the base asset and wS as the liquidity asset.
1010

1111
## Deployed Contracts
1212

@@ -100,11 +100,27 @@ function swapTokensForExactTokens(
100100
) external returns (uint256[] memory amounts);
101101
102102
/**
103-
* @notice Get the available liquidity for a each token in the ARM.
104-
* @return reserve0 The available liquidity for token0
105-
* @return reserve1 The available liquidity for token1
103+
* @notice Get the available reserves for each token in the ARM.
104+
* @dev Applies to the Lido, EtherFi, OETH and OS ARMs.
105+
* @return reserve0 The available liquidity for token0.
106+
* @return reserve1 The available liquidity for token1.
106107
*/
107108
function getReserves() external view returns (uint256 reserve0, uint256 reserve1);
109+
110+
/**
111+
* @notice Get available liquidity and base asset reserves for a supported base asset.
112+
* @dev Applies to the Ethena and USD ARMs.
113+
* For the Ethena ARM, reserveBaseAsset is sUSDe and liquidityAssets are USDe.
114+
* For the USD ARM, reserveBaseAsset is PYUSD or USDG and liquidityAssets are USDC.
115+
* Liquidity assets are net of outstanding LP withdrawal claims.
116+
* @param reserveBaseAsset Supported base asset whose reserve should be returned.
117+
* @return liquidityAssets Available liquidity assets.
118+
* @return baseAssetReserve Base assets held directly by the ARM.
119+
*/
120+
function getReserves(address reserveBaseAsset)
121+
external
122+
view
123+
returns (uint256 liquidityAssets, uint256 baseAssetReserve);
108124
```
109125

110126
## Liquidity Provider Interface
@@ -293,7 +309,7 @@ yarn hardhat tenderlySync --network sonic
293309
yarn hardhat tenderlyUpload --network sonic --name ORIGIN_ARM
294310
```
295311

296-
## Automated Actions (Talos)
312+
## Automated Actions (Talos)
297313

298314
The `src/js/tasks/actions/*.ts` files are hardhat tasks that handle operational jobs (allocations, fee collection, withdrawal requests, etc.). In production they're driven by a container that imports [`@talos/client`](https://github.com/oplabs/talos):
299315

@@ -316,86 +332,4 @@ pnpm hardhat healthcheck
316332

317333
If you opt in by setting `DATABASE_URL` (e.g., via `docker compose up`), the nonce queue engages and will try to connect to whatever that URL points at. `unset DATABASE_URL` to go back to the unwrapped path.
318334

319-
Signer selection (`DEPLOYER_PRIVATE_KEY` → KMS via `KMS_RELAYER_ID``IMPERSONATE` → Defender → hardhat first signer) lives entirely in `src/js/utils/signers.ts` and is unchanged.
320-
321-
## Open Zeppelin Defender
322-
323-
[Open Zeppelin Defender v2](https://docs.openzeppelin.com/defender/v2/) is used to manage the Operations account and automate AMM operational jobs like managing liquidity.
324-
325-
### Deploying Defender Actions
326-
327-
Defender Actions are used to run operational jobs are specific times or intervals.
328-
329-
[rollup](https://rollupjs.org/) is used to bundle the Actions source code in [/src/js/actions](./src/js/actions) into a single file that can be uploaded to Defender. The implementation was based off [Defender Action example using Rollup](https://github.com/OpenZeppelin/defender-autotask-examples/tree/master/rollup). The rollup config is in [/src/js/actions/rollup.config.cjs](./src/js/actions/rollup.config.cjs). The outputs are written to task-specific folders under [/src/js/actions/dist](./src/js/actions/dist/).
330-
331-
The [defender-autotask CLI](https://www.npmjs.com/package/@openzeppelin/defender-autotask-client) is used to upload the Action code to Defender.
332-
For this to work, a Defender Team API key with `Manage Actions` capabilities is needed. This can be generated by a Defender team admin under the `Manage` tab on the top right of the UI and then `API Keys` on the left menu.
333-
334-
The following will set the Defender Team API key and bundle the Actions code ready for upload.
335-
336-
```bash
337-
# Set the DEFENDER_TEAM_KEY and DEFENDER_TEAM_SECRET env vars in the .env file
338-
339-
yarn rollup -c src/js/actions/rollup.config.cjs
340-
```
341-
342-
The following will upload the different Action bundles to Defender.
343-
344-
```bash
345-
346-
# Set the DEBUG environment variable to oeth* for the Defender Action
347-
yarn hardhat setActionVars --id 93c010f9-05b5-460f-bd10-1205dd80a7c9
348-
yarn hardhat setActionVars --id 563d8d0c-17dc-46d3-8955-e4824864869f
349-
yarn hardhat setActionVars --id c010fb76-ea63-409d-9981-69322d27993a
350-
yarn hardhat setActionVars --id 127171fd-7b85-497e-8335-fd7907c08386
351-
yarn hardhat setActionVars --id 84b5f134-8351-4402-8f6a-fb4376034bc4
352-
yarn hardhat setActionVars --id ffcfc580-7b0a-42ed-a4f2-3f0a3add9779 --name ONEINCH_API_KEY # Don't forget to run `export ONEINCH_API_KEY=...` first!
353-
yarn hardhat setActionVars --id 89658c5f-3857-4972-bef8-a5e914e13c56 # setPricesEtherFi
354-
yarn hardhat setActionVars --id 641e73f8-6792-41c8-bda9-930681d94ada # setPricesEthena
355-
yarn hardhat setActionVars --id 32dbc67b-89f3-4856-8f3d-ad4dc5a09322
356-
yarn hardhat setActionVars --id 7a0cb2c9-11c2-41dd-bcd0-d7c2dbda6af6
357-
yarn hardhat setActionVars --id a9fc4c86-0506-4809-afbc-93b5e558cb68
358-
yarn hardhat setActionVars --id 12977d51-d107-45eb-ac20-45942009ab01
359-
yarn hardhat setActionVars --id 6ec46510-0b8e-48b4-a4c8-de759aad0ba4
360-
yarn hardhat setActionVars --id 6d148f26-54a6-4377-92f2-3148d572eea3 --name ONEINCH_API_KEY # Don't forget to run `export ONEINCH_API_KEY=...` first!
361-
yarn hardhat setActionVars --id acfbb7d6-5ea6-4ffc-a758-fa4b4f584dd1 # allocateLido
362-
yarn hardhat setActionVars --id 6e26641e-4132-4824-bb80-7c891fd31455 # collectEtherFiFees
363-
yarn hardhat setActionVars --id 002c2b0d-9522-4d5f-a340-9713ee43a1c3 # allocateEtherFi
364-
yarn hardhat setActionVars --id 062cfee1-c34e-43ae-beb0-de62bc668bbd # autoRequestEtherFiWithdraw
365-
yarn hardhat setActionVars --id 6c52f3a9-85d8-4c7f-8aee-90a95b13965c # autoClaimEtherFiWithdraw
366-
yarn hardhat setActionVars --id 82ead29e-88f1-43bc-a5ed-503fadb3e491 # collectEthenaFees
367-
yarn hardhat setActionVars --id 80565995-9bb2-42a0-bbd5-e15297b67050 # allocateEthena
368-
yarn hardhat setActionVars --id 3a49c165-62d9-43a2-bef0-901ce1d59bef # autoRequestEthenaWithdraw
369-
yarn hardhat setActionVars --id b362885c-a023-4fb5-8c04-1c33147465eb # autoClaimEthenaWithdraw
370-
371-
# Mainnet
372-
yarn hardhat updateAction --id 93c010f9-05b5-460f-bd10-1205dd80a7c9 --file autoRequestWithdraw
373-
yarn hardhat updateAction --id 563d8d0c-17dc-46d3-8955-e4824864869f --file autoClaimWithdraw
374-
yarn hardhat updateAction --id c010fb76-ea63-409d-9981-69322d27993a --file autoRequestLidoWithdraw
375-
yarn hardhat updateAction --id 127171fd-7b85-497e-8335-fd7907c08386 --file autoClaimLidoWithdraw
376-
yarn hardhat updateAction --id 84b5f134-8351-4402-8f6a-fb4376034bc4 --file collectLidoFees
377-
yarn hardhat updateAction --id ffcfc580-7b0a-42ed-a4f2-3f0a3add9779 --file setPricesLido
378-
yarn hardhat updateAction --id 89658c5f-3857-4972-bef8-a5e914e13c56 --file setPricesEtherFi
379-
yarn hardhat updateAction --id 641e73f8-6792-41c8-bda9-930681d94ada --file setPricesEthena
380-
yarn hardhat updateAction --id 32dbc67b-89f3-4856-8f3d-ad4dc5a09322 --file collectFeesSonic
381-
yarn hardhat updateAction --id 7a0cb2c9-11c2-41dd-bcd0-d7c2dbda6af6 --file allocateSonic
382-
yarn hardhat updateAction --id a9fc4c86-0506-4809-afbc-93b5e558cb68 --file collectRewardsSonic
383-
yarn hardhat updateAction --id 12977d51-d107-45eb-ac20-45942009ab01 --file autoRequestWithdrawSonic
384-
yarn hardhat updateAction --id 6ec46510-0b8e-48b4-a4c8-de759aad0ba4 --file autoClaimWithdrawSonic
385-
yarn hardhat updateAction --id 6d148f26-54a6-4377-92f2-3148d572eea3 --file setOSSiloPriceAction
386-
yarn hardhat updateAction --id acfbb7d6-5ea6-4ffc-a758-fa4b4f584dd1 --file allocateLido
387-
yarn hardhat updateAction --id 6e26641e-4132-4824-bb80-7c891fd31455 --file collectEtherFiFees
388-
yarn hardhat updateAction --id 002c2b0d-9522-4d5f-a340-9713ee43a1c3 --file allocateEtherFi
389-
yarn hardhat updateAction --id 062cfee1-c34e-43ae-beb0-de62bc668bbd --file autoRequestEtherFiWithdraw
390-
yarn hardhat updateAction --id 6c52f3a9-85d8-4c7f-8aee-90a95b13965c --file autoClaimEtherFiWithdraw
391-
yarn hardhat updateAction --id 82ead29e-88f1-43bc-a5ed-503fadb3e491 --file collectEthenaFees
392-
yarn hardhat updateAction --id 80565995-9bb2-42a0-bbd5-e15297b67050 --file allocateEthena
393-
yarn hardhat updateAction --id 3a49c165-62d9-43a2-bef0-901ce1d59bef --file autoRequestEthenaWithdraw
394-
yarn hardhat updateAction --id b362885c-a023-4fb5-8c04-1c33147465eb --file autoClaimEthenaWithdraw
395-
```
396-
397-
`rollup` can be installed globally to avoid the `yarn` prefix.
398-
399-
The Defender Actions need to be under 5MB in size. The [rollup-plugin-visualizer](https://www.npmjs.com/package/rollup-plugin-visualizer) can be used to visualize the size of an Action's dependencies.
400-
A `stats.html` file is generated in the`src/js/actions` folder that can be opened in a browser to see the size of the Action's dependencies.
401-
This will be for the last Action in the rollup config `src/js/actions/rollup.config.cjs`.
335+
Signer selection (`DEPLOYER_PRIVATE_KEY` → KMS via `KMS_RELAYER_ID``IMPERSONATE` → hardhat first signer) lives in `src/js/utils/signers.ts`.

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
"@nomicfoundation/hardhat-ethers": "3.0.7",
2424
"@nomicfoundation/hardhat-foundry": "^1.1.1",
2525
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
26-
"@openzeppelin/defender-sdk": "2.7.0",
27-
"@rollup/plugin-commonjs": "^25.0.7",
28-
"@rollup/plugin-json": "^6.1.0",
29-
"@rollup/plugin-node-resolve": "^15.2.3",
3026
"@solidity-parser/parser": "^0.18.0",
3127
"axios": "^1.9.0",
3228
"builtin-modules": "^3.3.0",
@@ -39,8 +35,6 @@
3935
"hardhat": "^2.22.9",
4036
"node-fetch": "^2.6.7",
4137
"prettier": "^3.6.2",
42-
"rollup": "^4.9.1",
43-
"rollup-plugin-visualizer": "^5.12.0",
4438
"ts-node": "^10.9.2",
4539
"typescript": "^5.7.0"
4640
},

0 commit comments

Comments
 (0)