Skip to content

Commit bf74be4

Browse files
authored
WETH Actions (#325)
* Split mainnet_set_prices_weth action into Lid and EtherFi actions * Send setArmPrices tx if the buy or sell amounts are changed * Removed autoRequestEtherFiWithdraw action
1 parent 3d4367d commit bf74be4

5 files changed

Lines changed: 90 additions & 21 deletions

File tree

docs/ACTIONS.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ range, tolerance, and quote-amount flags apply to every selected base.
4343

4444
## EtherFi ARM — mainnet
4545

46-
| Action | Cron | Description |
47-
| ---------------------------- | --------------- | -------------------------------------------- |
48-
| `autoRequestEtherFiWithdraw` | `10,40 * * * *` | Request EtherFi withdrawals from EtherFi ARM |
49-
| `autoClaimEtherFiWithdraw` | `40 * * * *` | Claim EtherFi withdrawals from EtherFi ARM |
50-
| `collectEtherFiFees` | `45 23 * * *` | Collect fees from EtherFi ARM |
51-
| `allocateEtherFi` | `52 * * * *` | Allocate liquidity for EtherFi ARM |
52-
| `setPricesEtherFi` | `2,32 * * * *` | Set prices for EtherFi ARM |
46+
| Action | Cron | Description |
47+
| -------------------------- | -------------- | ------------------------------------------ |
48+
| `autoClaimEtherFiWithdraw` | `40 * * * *` | Claim EtherFi withdrawals from EtherFi ARM |
49+
| `collectEtherFiFees` | `45 23 * * *` | Collect fees from EtherFi ARM |
50+
| `allocateEtherFi` | `52 * * * *` | Allocate liquidity for EtherFi ARM |
51+
| `setPricesEtherFi` | `2,32 * * * *` | Set prices for EtherFi ARM |
5352

5453
## Ethena ARM — mainnet
5554

@@ -73,15 +72,16 @@ range, tolerance, and quote-amount flags apply to every selected base.
7372

7473
## WETH ARM — mainnet
7574

76-
| Action | Cron | Description |
77-
| -------------------------------- | ----------------------- | ---------------------------------------------- |
78-
| `autoRequestWETHLidoWithdraw` | `29,58 12-23,0-8 * * *` | Request stETH/wstETH withdrawals from WETH ARM |
79-
| `autoClaimWETHLidoWithdraw` | `32 0,12 * * *` | Claim stETH/wstETH withdrawals for WETH ARM |
80-
| `autoRequestWETHEtherFiWithdraw` | `10,40 * * * *` | Request eETH/weETH withdrawals from WETH ARM |
81-
| `autoClaimWETHEtherFiWithdraw` | `40 * * * *` | Claim eETH/weETH withdrawals for WETH ARM |
82-
| `collectWETHFees` | `30 12 * * *` | Collect fees from WETH ARM |
83-
| `allocateWETH` | `38,08 * * * *` | Allocate liquidity for WETH ARM |
84-
| `setPricesWETH` | `*/30 * * * *` | Set prices for all four WETH ARM base assets |
75+
| Action | Cron | Description |
76+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- | ---------------------------------------------- |
77+
| `autoRequestWETHLidoWithdraw` | `29,58 12-23,0-8 * * *` | Request stETH/wstETH withdrawals from WETH ARM |
78+
| `autoClaimWETHLidoWithdraw` | `32 0,12 * * *` | Claim stETH/wstETH withdrawals for WETH ARM |
79+
| `autoRequestWETHEtherFiWithdraw` | `10,40 * * * *` | Request eETH/weETH withdrawals from WETH ARM |
80+
| `autoClaimWETHEtherFiWithdraw` | `40 * * * *` | Claim eETH/weETH withdrawals for WETH ARM |
81+
| `collectWETHFees` | `30 12 * * *` | Collect fees from WETH ARM |
82+
| `allocateWETH` | `38,08 * * * *` | Allocate liquidity for WETH ARM |
83+
| `setPricesWETH --bases STETH,WSTETH --fee 0.6 --inch false --kyber true --tolerance 0.1 --amount 30 --offset 0.3 --max-buy-price 0.99996 --min-sell-price 0.99998` | `*/10 * * * *` | Set WETH ARM prices for Lido base assets |
84+
| `setPricesWETH --bases EETH,WEETH --fee 0.6 --inch false --kyber true --tolerance 0.1 --amount 30 --offset 0.3 --max-buy-price 0.99996 --min-sell-price 0.99998` | `2-59/10 * * * *` | Set WETH ARM prices for Ether.fi base assets |
8585

8686
## Origin ARM — Sonic
8787

migrations/seed_schedules.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ WHERE product = 'arm-oeth'
1313
'mainnet_collect_usd_fees',
1414
'mainnet_allocate_usd',
1515
'mainnet_set_prices_usd',
16+
'mainnet_set_prices_weth',
17+
'mainnet_auto_request_etherfi_withdraw',
1618
'mainnet_pause_usd',
1719
'mainnet_pause_lido',
1820
'mainnet_pause_etherfi',
@@ -24,7 +26,6 @@ INSERT INTO schedules (product, name, command, cron_expr, timezone, enabled, not
2426
('arm-oeth', 'healthcheck', 'cd /app && pnpm hardhat healthcheck', '*/5 * * * *', 'UTC', false, NULL),
2527
('arm-oeth', 'mainnet_auto_request_lido_withdraw', 'cd /app && pnpm hardhat autoRequestLidoWithdraw --network mainnet', '29,58 12-23,0-8 * * *', 'UTC', false, NULL),
2628
('arm-oeth', 'mainnet_auto_claim_lido_withdraw', 'cd /app && pnpm hardhat autoClaimLidoWithdraw --network mainnet', '32 0,12 * * *', 'UTC', false, NULL),
27-
('arm-oeth', 'mainnet_auto_request_etherfi_withdraw','cd /app && pnpm hardhat autoRequestEtherFiWithdraw --network mainnet', '10,40 * * * *', 'UTC', false, NULL),
2829
('arm-oeth', 'mainnet_auto_claim_etherfi_withdraw', 'cd /app && pnpm hardhat autoClaimEtherFiWithdraw --network mainnet', '40 * * * *', 'UTC', false, NULL),
2930
('arm-oeth', 'mainnet_auto_request_ethena_withdraw', 'cd /app && pnpm hardhat autoRequestEthenaWithdraw --network mainnet', '12 * * * *', 'UTC', false, NULL),
3031
('arm-oeth', 'mainnet_auto_claim_ethena_withdraw', 'cd /app && pnpm hardhat autoClaimEthenaWithdraw --network mainnet', '40 * * * *', 'UTC', false, NULL),
@@ -48,7 +49,8 @@ INSERT INTO schedules (product, name, command, cron_expr, timezone, enabled, not
4849
('arm-oeth', 'mainnet_auto_claim_weth_etherfi_withdraw', 'cd /app && pnpm hardhat autoClaimWETHEtherFiWithdraw --network mainnet', '40 * * * *', 'UTC', false, NULL),
4950
('arm-oeth', 'mainnet_collect_weth_fees', 'cd /app && pnpm hardhat collectWETHFees --network mainnet', '30 12 * * *', 'UTC', false, NULL),
5051
('arm-oeth', 'mainnet_allocate_weth', 'cd /app && pnpm hardhat allocateWETH --network mainnet', '38,08 * * * *', 'UTC', false, NULL),
51-
('arm-oeth', 'mainnet_set_prices_weth', 'cd /app && pnpm hardhat setPricesWETH --network mainnet', '*/30 * * * *', 'UTC', false, NULL),
52+
('arm-oeth', 'mainnet_set_prices_weth_lido', 'cd /app && pnpm hardhat setPricesWETH --bases STETH,WSTETH --network mainnet --fee 0.6 --inch false --kyber true --tolerance 0.1 --amount 30 --offset 0.3 --max-buy-price 0.99996 --min-sell-price 0.99998', '*/10 * * * *', 'UTC', false, NULL),
53+
('arm-oeth', 'mainnet_set_prices_weth_etherfi', 'cd /app && pnpm hardhat setPricesWETH --bases EETH,WEETH --network mainnet --fee 0.6 --inch false --kyber true --tolerance 0.1 --amount 30 --offset 0.3 --max-buy-price 0.99996 --min-sell-price 0.99998', '2-59/10 * * * *', 'UTC', false, NULL),
5254
-- Emergency pause action: manual-only (enabled=false). Edit `--arm` before
5355
-- using "Run now". The supported Ethereum ARMs are lido, etherfi, ethena,
5456
-- oeth, usdc, and weth. cron_expr is a placeholder and never fires while disabled.

src/js/tasks/armPrices.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
rangeSellPrice,
1919
rangeBuyPrice,
2020
} = require("../utils/pricing");
21+
const { haveSwapCapsChanged } = require("../utils/priceUpdate");
2122

2223
const log = require("../utils/logger")("task:prices");
2324

@@ -360,11 +361,32 @@ const setPrices = async (options) => {
360361
const toleranceScaled = parseUnits(tolerance.toString(), 36 - 4);
361362
log(`tolerance : ${formatUnits(toleranceScaled, 32)} basis points`);
362363

364+
const targetBuyAmount = parseSwapCap(buyAmount);
365+
const targetSellAmount = parseSwapCap(sellAmount);
366+
const swapCapsChanged = haveSwapCapsChanged(
367+
baseContext,
368+
targetBuyAmount,
369+
targetSellAmount,
370+
);
371+
if (baseContext.version === "multiBase") {
372+
log(`current buy amount : ${config.buyLiquidityRemaining}`);
373+
log(`target buy amount : ${targetBuyAmount}`);
374+
log(`current sell amount: ${config.sellLiquidityRemaining}`);
375+
log(`target sell amount : ${targetSellAmount}`);
376+
}
377+
363378
// decide if rates need to be updated
364-
if (diffSellPrice > toleranceScaled || diffBuyPrice > toleranceScaled) {
379+
if (
380+
diffSellPrice > toleranceScaled ||
381+
diffBuyPrice > toleranceScaled ||
382+
swapCapsChanged
383+
) {
365384
console.log(`About to update ARM prices`);
366385
console.log(`sell: ${formatUnits(targetSellPrice, 36)}`);
367386
console.log(`buy : ${formatUnits(targetBuyPrice, 36)}`);
387+
if (swapCapsChanged) {
388+
console.log(`Buy or sell amount has changed`);
389+
}
368390

369391
if (dryrun) {
370392
console.log(`Dry run mode - not calling setPrices`);
@@ -376,8 +398,8 @@ const setPrices = async (options) => {
376398
signer,
377399
buyPrice: targetBuyPrice,
378400
sellPrice: targetSellPrice,
379-
buyAmount: parseSwapCap(buyAmount),
380-
sellAmount: parseSwapCap(sellAmount),
401+
buyAmount: targetBuyAmount,
402+
sellAmount: targetSellAmount,
381403
});
382404

383405
await logTxDetails(tx, "setPrices", options.confirm);

src/js/utils/priceUpdate.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const haveSwapCapsChanged = (baseContext, buyAmount, sellAmount) =>
2+
baseContext.version === "multiBase" &&
3+
(buyAmount !== baseContext.config.buyLiquidityRemaining ||
4+
sellAmount !== baseContext.config.sellLiquidityRemaining);
5+
6+
module.exports = {
7+
haveSwapCapsChanged,
8+
};

test/js/armPrices.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const assert = require("assert");
2+
3+
const { haveSwapCapsChanged } = require("../../src/js/utils/priceUpdate");
4+
5+
const multiBaseContext = (buyLiquidityRemaining, sellLiquidityRemaining) => ({
6+
version: "multiBase",
7+
config: {
8+
buyLiquidityRemaining,
9+
sellLiquidityRemaining,
10+
},
11+
});
12+
13+
assert.strictEqual(
14+
haveSwapCapsChanged(multiBaseContext(10n, 20n), 10n, 20n),
15+
false,
16+
"unchanged buy and sell amounts should not trigger an update",
17+
);
18+
19+
assert.strictEqual(
20+
haveSwapCapsChanged(multiBaseContext(9n, 20n), 10n, 20n),
21+
true,
22+
"a changed buy amount should trigger an update",
23+
);
24+
25+
assert.strictEqual(
26+
haveSwapCapsChanged(multiBaseContext(10n, 19n), 10n, 20n),
27+
true,
28+
"a changed sell amount should trigger an update",
29+
);
30+
31+
assert.strictEqual(
32+
haveSwapCapsChanged({ version: "legacy" }, 10n, 20n),
33+
false,
34+
"legacy ARMs do not support buy and sell amounts",
35+
);
36+
37+
console.log("ARM price tests passed");

0 commit comments

Comments
 (0)