@sherwoodagent/cli 0.86.1 → 0.87.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{abis-WVW2EBI3.js → abis-WJQ6IVYV.js} +2 -2
- package/dist/{agent-TBLC3WNJ.js → agent-FCGZL4GF.js} +7 -7
- package/dist/{chat-ETZSKQDI.js → chat-AKLYUJZV.js} +8 -8
- package/dist/{chunk-ZN2MHIB7.js → chunk-4ITTHKRX.js} +5 -5
- package/dist/{chunk-EVUKJ7CJ.js → chunk-6D3FNU75.js} +5 -5
- package/dist/{chunk-45FELUWY.js → chunk-6SAE2VDK.js} +2 -2
- package/dist/{chunk-EA65CDQH.js → chunk-BH3VTJ4F.js} +14 -23
- package/dist/chunk-BH3VTJ4F.js.map +1 -0
- package/dist/{chunk-QRMZRAMG.js → chunk-D4BSBW3Q.js} +221 -10
- package/dist/chunk-D4BSBW3Q.js.map +1 -0
- package/dist/{chunk-KVB5P2OE.js → chunk-EEI6FRTE.js} +2 -2
- package/dist/{chunk-IAM4VIU2.js → chunk-FWQESFFM.js} +18 -41
- package/dist/chunk-FWQESFFM.js.map +1 -0
- package/dist/{chunk-PVTZMRC6.js → chunk-G3FUEM5N.js} +2 -2
- package/dist/chunk-G3FUEM5N.js.map +1 -0
- package/dist/{chunk-YAS52NEF.js → chunk-G5MXVAFC.js} +18 -5
- package/dist/chunk-G5MXVAFC.js.map +1 -0
- package/dist/{chunk-F3MDCUGO.js → chunk-J2IZWAEW.js} +75 -227
- package/dist/chunk-J2IZWAEW.js.map +1 -0
- package/dist/{chunk-XPVXNG2K.js → chunk-N2E2Q5GL.js} +6 -6
- package/dist/{chunk-3IAZQMAW.js → chunk-QFGZQYZA.js} +29 -82
- package/dist/chunk-QFGZQYZA.js.map +1 -0
- package/dist/{chunk-OUYMZ5ZC.js → chunk-SI65QHTY.js} +5 -5
- package/dist/{chunk-6QBGTX2Q.js → chunk-VYCLG5DE.js} +264 -487
- package/dist/chunk-VYCLG5DE.js.map +1 -0
- package/dist/{client-3SE632Q2.js → client-PYFE6YQR.js} +3 -3
- package/dist/{eas-KMDAMLXW.js → eas-DV3Z7AT3.js} +6 -6
- package/dist/{governor-JNSWPJVQ.js → governor-QFBN6RYS.js} +8 -6
- package/dist/identity-M4TXM7EX.js +18 -0
- package/dist/index.js +352 -355
- package/dist/index.js.map +1 -1
- package/dist/{network-FEHRFDPJ.js → network-7445KSCF.js} +2 -2
- package/dist/{price-YNPYE2EO.js → price-EXZDYVDD.js} +6 -6
- package/dist/{providers-BMOHHVUN.js → providers-6UZKDFQD.js} +4 -4
- package/dist/{research-W74PNYPO.js → research-44GHYE4H.js} +7 -7
- package/dist/{session-HVRZ6AJM.js → session-45NQAHFI.js} +14 -12
- package/dist/session-45NQAHFI.js.map +1 -0
- package/dist/{trade-EOQY72L7.js → trade-FO52SP62.js} +15 -15
- package/dist/{vault-HWJQJW5U.js → vault-WWGSRNRP.js} +8 -8
- package/dist/{xmtp-KW73BGVO.js → xmtp-72IRK7JL.js} +6 -6
- package/package.json +1 -1
- package/dist/chunk-3IAZQMAW.js.map +0 -1
- package/dist/chunk-6QBGTX2Q.js.map +0 -1
- package/dist/chunk-EA65CDQH.js.map +0 -1
- package/dist/chunk-F3MDCUGO.js.map +0 -1
- package/dist/chunk-IAM4VIU2.js.map +0 -1
- package/dist/chunk-PVTZMRC6.js.map +0 -1
- package/dist/chunk-QRMZRAMG.js.map +0 -1
- package/dist/chunk-YAS52NEF.js.map +0 -1
- package/dist/identity-ATWV2O7Y.js +0 -15
- package/dist/session-HVRZ6AJM.js.map +0 -1
- /package/dist/{abis-WVW2EBI3.js.map → abis-WJQ6IVYV.js.map} +0 -0
- /package/dist/{agent-TBLC3WNJ.js.map → agent-FCGZL4GF.js.map} +0 -0
- /package/dist/{chat-ETZSKQDI.js.map → chat-AKLYUJZV.js.map} +0 -0
- /package/dist/{chunk-ZN2MHIB7.js.map → chunk-4ITTHKRX.js.map} +0 -0
- /package/dist/{chunk-EVUKJ7CJ.js.map → chunk-6D3FNU75.js.map} +0 -0
- /package/dist/{chunk-45FELUWY.js.map → chunk-6SAE2VDK.js.map} +0 -0
- /package/dist/{chunk-KVB5P2OE.js.map → chunk-EEI6FRTE.js.map} +0 -0
- /package/dist/{chunk-XPVXNG2K.js.map → chunk-N2E2Q5GL.js.map} +0 -0
- /package/dist/{chunk-OUYMZ5ZC.js.map → chunk-SI65QHTY.js.map} +0 -0
- /package/dist/{client-3SE632Q2.js.map → client-PYFE6YQR.js.map} +0 -0
- /package/dist/{eas-KMDAMLXW.js.map → eas-DV3Z7AT3.js.map} +0 -0
- /package/dist/{governor-JNSWPJVQ.js.map → governor-QFBN6RYS.js.map} +0 -0
- /package/dist/{identity-ATWV2O7Y.js.map → identity-M4TXM7EX.js.map} +0 -0
- /package/dist/{network-FEHRFDPJ.js.map → network-7445KSCF.js.map} +0 -0
- /package/dist/{price-YNPYE2EO.js.map → price-EXZDYVDD.js.map} +0 -0
- /package/dist/{providers-BMOHHVUN.js.map → providers-6UZKDFQD.js.map} +0 -0
- /package/dist/{research-W74PNYPO.js.map → research-44GHYE4H.js.map} +0 -0
- /package/dist/{trade-EOQY72L7.js.map → trade-FO52SP62.js.map} +0 -0
- /package/dist/{vault-HWJQJW5U.js.map → vault-WWGSRNRP.js.map} +0 -0
- /package/dist/{xmtp-KW73BGVO.js.map → xmtp-72IRK7JL.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLogsChunked
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BH3VTJ4F.js";
|
|
4
4
|
import {
|
|
5
5
|
TOKENS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FWQESFFM.js";
|
|
7
7
|
import {
|
|
8
8
|
GAS_UNITS,
|
|
9
9
|
estimateGasCushion,
|
|
@@ -12,17 +12,17 @@ import {
|
|
|
12
12
|
getWalletClient,
|
|
13
13
|
waitForReceipt,
|
|
14
14
|
writeContractWithRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-D4BSBW3Q.js";
|
|
16
16
|
import {
|
|
17
17
|
getChain
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-G3FUEM5N.js";
|
|
19
19
|
import {
|
|
20
20
|
getChainContracts
|
|
21
21
|
} from "./chunk-3TZIOAPH.js";
|
|
22
22
|
import {
|
|
23
23
|
ERC20_ABI,
|
|
24
24
|
SYNDICATE_VAULT_ABI
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-J2IZWAEW.js";
|
|
26
26
|
|
|
27
27
|
// src/lib/vault.ts
|
|
28
28
|
import { formatUnits, parseAbiItem } from "viem";
|
|
@@ -557,4 +557,4 @@ export {
|
|
|
557
557
|
registerAgent,
|
|
558
558
|
getVaultInfo
|
|
559
559
|
};
|
|
560
|
-
//# sourceMappingURL=chunk-
|
|
560
|
+
//# sourceMappingURL=chunk-N2E2Q5GL.js.map
|
|
@@ -6,20 +6,19 @@ import {
|
|
|
6
6
|
SYNTHRA,
|
|
7
7
|
TOKENS,
|
|
8
8
|
UNISWAP,
|
|
9
|
-
VENICE
|
|
10
|
-
|
|
11
|
-
} from "./chunk-IAM4VIU2.js";
|
|
9
|
+
VENICE
|
|
10
|
+
} from "./chunk-FWQESFFM.js";
|
|
12
11
|
import {
|
|
13
12
|
getPublicClient
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-D4BSBW3Q.js";
|
|
15
14
|
import {
|
|
16
15
|
getNetwork
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-G3FUEM5N.js";
|
|
18
17
|
import {
|
|
19
18
|
BASE_STRATEGY_ABI,
|
|
20
19
|
ERC20_ABI,
|
|
21
20
|
UNISWAP_QUOTER_V2_ABI
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-J2IZWAEW.js";
|
|
23
22
|
|
|
24
23
|
// src/lib/swap-router.ts
|
|
25
24
|
import { encodeFunctionData as encodeFunctionData9, decodeFunctionResult } from "viem";
|
|
@@ -30,7 +29,7 @@ import {
|
|
|
30
29
|
isAddress,
|
|
31
30
|
encodeAbiParameters as encodeAbiParameters9,
|
|
32
31
|
concat as concat2,
|
|
33
|
-
numberToHex
|
|
32
|
+
numberToHex
|
|
34
33
|
} from "viem";
|
|
35
34
|
import chalk from "chalk";
|
|
36
35
|
|
|
@@ -320,7 +319,7 @@ function buildSettleCalls5(clone) {
|
|
|
320
319
|
}
|
|
321
320
|
|
|
322
321
|
// src/strategies/portfolio-template.ts
|
|
323
|
-
import { concat, encodeAbiParameters as encodeAbiParameters6, encodeFunctionData as encodeFunctionData6
|
|
322
|
+
import { concat, encodeAbiParameters as encodeAbiParameters6, encodeFunctionData as encodeFunctionData6 } from "viem";
|
|
324
323
|
function withMode(mode, routeData) {
|
|
325
324
|
const modeByte = `0x${mode.toString(16).padStart(2, "0")}`;
|
|
326
325
|
return concat([modeByte, routeData]);
|
|
@@ -356,30 +355,14 @@ function v4PathExtraData(hops) {
|
|
|
356
355
|
)
|
|
357
356
|
);
|
|
358
357
|
}
|
|
359
|
-
|
|
360
|
-
var MIN_MAX_PRICE_AGE = 3600;
|
|
361
|
-
var MAX_MAX_PRICE_AGE = 2592e3;
|
|
362
|
-
function pushFeedId(feed, maxAgeSeconds) {
|
|
363
|
-
if (maxAgeSeconds === void 0 || maxAgeSeconds === 0) {
|
|
364
|
-
return pad(feed, { size: 32 });
|
|
365
|
-
}
|
|
366
|
-
if (!Number.isInteger(maxAgeSeconds) || maxAgeSeconds < MIN_MAX_PRICE_AGE || maxAgeSeconds > MAX_MAX_PRICE_AGE) {
|
|
367
|
-
throw new Error(
|
|
368
|
-
`pushFeedId: maxAgeSeconds must be an integer in [${MIN_MAX_PRICE_AGE}, ${MAX_MAX_PRICE_AGE}] (or 0 for the contract default), got ${maxAgeSeconds}`
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
const packed = BigInt(maxAgeSeconds) << 160n | BigInt(feed);
|
|
372
|
-
return numberToHex(packed, { size: 32 });
|
|
373
|
-
}
|
|
374
|
-
function buildInitData6(asset, swapAdapter, chainlinkVerifier, allocations, totalAmount, maxSlippageBps) {
|
|
358
|
+
function buildInitData6(asset, swapAdapter, allocations, totalAmount, maxSlippageBps) {
|
|
375
359
|
const tokens = allocations.map((a) => a.token);
|
|
376
360
|
const weightsBps = allocations.map((a) => BigInt(a.weightBps));
|
|
377
361
|
const swapExtraData = allocations.map((a) => a.swapExtraData);
|
|
378
362
|
const priceDecimals = allocations.map((a) => a.priceDecimals);
|
|
379
|
-
const
|
|
363
|
+
const feeds = allocations.map((a) => a.feed);
|
|
380
364
|
return encodeAbiParameters6(
|
|
381
365
|
[
|
|
382
|
-
{ type: "address" },
|
|
383
366
|
{ type: "address" },
|
|
384
367
|
{ type: "address" },
|
|
385
368
|
{ type: "address[]" },
|
|
@@ -388,19 +371,18 @@ function buildInitData6(asset, swapAdapter, chainlinkVerifier, allocations, tota
|
|
|
388
371
|
{ type: "uint256" },
|
|
389
372
|
{ type: "bytes[]" },
|
|
390
373
|
{ type: "uint8[]" },
|
|
391
|
-
{ type: "
|
|
374
|
+
{ type: "address[]" }
|
|
392
375
|
],
|
|
393
376
|
[
|
|
394
377
|
asset,
|
|
395
378
|
swapAdapter,
|
|
396
|
-
chainlinkVerifier,
|
|
397
379
|
tokens,
|
|
398
380
|
weightsBps,
|
|
399
381
|
totalAmount,
|
|
400
382
|
BigInt(maxSlippageBps),
|
|
401
383
|
swapExtraData,
|
|
402
384
|
priceDecimals,
|
|
403
|
-
|
|
385
|
+
feeds
|
|
404
386
|
]
|
|
405
387
|
);
|
|
406
388
|
}
|
|
@@ -937,14 +919,13 @@ function buildSettleCalls8(clone) {
|
|
|
937
919
|
|
|
938
920
|
// src/lib/template-encoder.ts
|
|
939
921
|
var ZERO = "0x0000000000000000000000000000000000000000";
|
|
940
|
-
var ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
941
922
|
function encodeV3Path(tokens, fees) {
|
|
942
923
|
if (tokens.length !== fees.length + 1) throw new Error("tokens.length must be fees.length + 1");
|
|
943
924
|
const parts = [];
|
|
944
925
|
for (let i = 0; i < tokens.length; i++) {
|
|
945
926
|
parts.push(tokens[i].toLowerCase());
|
|
946
927
|
if (i < fees.length) {
|
|
947
|
-
parts.push(
|
|
928
|
+
parts.push(numberToHex(fees[i], { size: 3 }));
|
|
948
929
|
}
|
|
949
930
|
}
|
|
950
931
|
return concat2(parts);
|
|
@@ -1267,13 +1248,11 @@ async function buildInitDataForTemplate(templateKey, opts, vault, resolved) {
|
|
|
1267
1248
|
process.exit(1);
|
|
1268
1249
|
}
|
|
1269
1250
|
const swapAdapter = opts.swapAdapter || resolveSwapAdapter();
|
|
1270
|
-
const chainlinkVerifier = CHAINLINK().VERIFIER_PROXY;
|
|
1271
|
-
const pushMode = chainlinkVerifier === ZERO;
|
|
1272
1251
|
const chainlink = CHAINLINK();
|
|
1273
|
-
const
|
|
1274
|
-
const
|
|
1275
|
-
if (
|
|
1276
|
-
console.error(chalk.red("--
|
|
1252
|
+
const feeds = parseAlignedOverrides(opts.feeds, tokenAddrs.length);
|
|
1253
|
+
const feedOverrides = feeds.values;
|
|
1254
|
+
if (feeds.mismatch) {
|
|
1255
|
+
console.error(chalk.red("--feeds must have the same length as --tokens"));
|
|
1277
1256
|
process.exit(1);
|
|
1278
1257
|
}
|
|
1279
1258
|
const priceDecimals = parseAlignedOverrides(opts.priceDecimals, tokenAddrs.length);
|
|
@@ -1288,12 +1267,6 @@ async function buildInitDataForTemplate(templateKey, opts, vault, resolved) {
|
|
|
1288
1267
|
console.error(chalk.red("--swap-routes must have the same length as --tokens"));
|
|
1289
1268
|
process.exit(1);
|
|
1290
1269
|
}
|
|
1291
|
-
const maxPriceAges = parseAlignedOverrides(opts.maxPriceAges, tokenAddrs.length);
|
|
1292
|
-
const maxPriceAgeOverrides = maxPriceAges.values;
|
|
1293
|
-
if (maxPriceAges.mismatch) {
|
|
1294
|
-
console.error(chalk.red("--max-price-ages must have the same length as --tokens"));
|
|
1295
|
-
process.exit(1);
|
|
1296
|
-
}
|
|
1297
1270
|
const wethAddr = TOKENS().WETH;
|
|
1298
1271
|
console.log(chalk.dim(" Detecting swap routes..."));
|
|
1299
1272
|
const allocations = [];
|
|
@@ -1339,45 +1312,19 @@ async function buildInitDataForTemplate(templateKey, opts, vault, resolved) {
|
|
|
1339
1312
|
process.exit(1);
|
|
1340
1313
|
}
|
|
1341
1314
|
console.log(chalk.dim(` ${token.slice(0, 10)}... \u2192 ${route.routeDesc}`));
|
|
1342
|
-
|
|
1343
|
-
let
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
maxPriceAge = Number(maxPriceAgeOverrides[i]);
|
|
1348
|
-
if (!Number.isInteger(maxPriceAge) || maxPriceAge < 0) {
|
|
1349
|
-
console.error(chalk.red(`Bad --max-price-ages entry for ${tokenSpecs[i]}: '${maxPriceAgeOverrides[i]}' (expected a non-negative integer count of seconds)`));
|
|
1350
|
-
process.exit(1);
|
|
1351
|
-
}
|
|
1352
|
-
} else if (pushMode && network === "robinhood") {
|
|
1353
|
-
const { maxPriceAge: age, unknownAddress } = robinhoodEquityMaxAge(
|
|
1354
|
-
tokenSpecs[i],
|
|
1355
|
-
tokens,
|
|
1356
|
-
EQUITY_MAX_PRICE_AGE_SECONDS
|
|
1357
|
-
);
|
|
1358
|
-
maxPriceAge = age;
|
|
1359
|
-
if (unknownAddress && feedIdOverrides[i]) {
|
|
1360
|
-
console.warn(
|
|
1361
|
-
chalk.yellow(
|
|
1362
|
-
` Warning: token ${tokenSpecs[i]} is not in the ${network} registry, so its push feed uses the contract's 26h default max-price-age.
|
|
1363
|
-
If this is a tokenized-equity feed, pass --max-price-ages (e.g. ${EQUITY_MAX_PRICE_AGE_SECONDS}) for this slot or it will trip StalePrice over long weekends.`
|
|
1364
|
-
)
|
|
1365
|
-
);
|
|
1366
|
-
}
|
|
1315
|
+
const priceDecimals2 = priceDecimalOverrides[i] ? Number(priceDecimalOverrides[i]) : 8;
|
|
1316
|
+
let feed = feedOverrides[i];
|
|
1317
|
+
if (feed && !isAddress(feed)) {
|
|
1318
|
+
console.error(chalk.red(`Bad --feeds entry for ${tokenSpecs[i]}: '${feed}' is not a 0x-prefixed AggregatorV3 address.`));
|
|
1319
|
+
process.exit(1);
|
|
1367
1320
|
}
|
|
1368
|
-
if (
|
|
1321
|
+
if (!feed) {
|
|
1322
|
+
const sym = tokenSpecs[i].toUpperCase();
|
|
1369
1323
|
const feedKey = sym === "WETH" || sym === "ETH" ? "ETH_USD_FEED" : `${sym}_USD_FEED`;
|
|
1370
|
-
|
|
1371
|
-
if (!feed || feed === ZERO) {
|
|
1372
|
-
console.error(chalk.red(`No Chainlink push feed for ${tokenSpecs[i]} on ${network}. Pass --feed-ids <feedAddr,...> to supply AggregatorV3 addresses.`));
|
|
1373
|
-
process.exit(1);
|
|
1374
|
-
}
|
|
1375
|
-
feedId = pushFeedId(feed, maxPriceAge);
|
|
1376
|
-
} else if (pushMode && feedId && isAddress(feedId)) {
|
|
1377
|
-
feedId = pushFeedId(feedId, maxPriceAge);
|
|
1324
|
+
feed = isAddress(tokenSpecs[i]) ? void 0 : chainlink[feedKey];
|
|
1378
1325
|
}
|
|
1379
|
-
if (!
|
|
1380
|
-
console.error(chalk.red(`
|
|
1326
|
+
if (!feed || feed === ZERO) {
|
|
1327
|
+
console.error(chalk.red(`No Chainlink push feed for ${tokenSpecs[i]} on ${network}. Pass --feeds <feedAddr,...> to supply AggregatorV3 addresses (every slot must be non-zero).`));
|
|
1381
1328
|
process.exit(1);
|
|
1382
1329
|
}
|
|
1383
1330
|
allocations.push({
|
|
@@ -1385,11 +1332,11 @@ async function buildInitDataForTemplate(templateKey, opts, vault, resolved) {
|
|
|
1385
1332
|
weightBps: weightsBps[i],
|
|
1386
1333
|
swapExtraData: route.extraData,
|
|
1387
1334
|
priceDecimals: priceDecimals2,
|
|
1388
|
-
|
|
1335
|
+
feed
|
|
1389
1336
|
});
|
|
1390
1337
|
}
|
|
1391
1338
|
return {
|
|
1392
|
-
initData: buildInitData6(asset, swapAdapter,
|
|
1339
|
+
initData: buildInitData6(asset, swapAdapter, allocations, totalAmount, maxSlippageBps),
|
|
1393
1340
|
asset,
|
|
1394
1341
|
assetAmount: totalAmount
|
|
1395
1342
|
};
|
|
@@ -1667,4 +1614,4 @@ export {
|
|
|
1667
1614
|
applySlippage,
|
|
1668
1615
|
encodeSwapPath
|
|
1669
1616
|
};
|
|
1670
|
-
//# sourceMappingURL=chunk-
|
|
1617
|
+
//# sourceMappingURL=chunk-QFGZQYZA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/swap-router.ts","../src/lib/template-encoder.ts","../src/strategies/moonwell-supply-template.ts","../src/strategies/venice-inference-template.ts","../src/strategies/aerodrome-lp-template.ts","../src/strategies/wsteth-moonwell-template.ts","../src/strategies/mamo-yield-template.ts","../src/strategies/portfolio-template.ts","../src/strategies/hyperliquid-perp-template.ts","../src/lib/abis-legacy.ts","../src/strategies/hyperliquid-grid-template.ts"],"sourcesContent":["/**\n * SwapRouter — the single owner of \"swap tokenIn→tokenOut on the current chain\".\n *\n * Surface (small, deep):\n * - detectRoute(tokenIn, tokenOut, feeTier?) → Route (wraps template-encoder's\n * detectSwapRoute; pure on the current deployment target)\n * - buildSwapCalldata(route, opts?) → adapter swapExtraData (delegates\n * byte encoding to template-encoder's tested buildSwapExtraData)\n * - quote({tokenIn, tokenOut, amountIn}) → Route + amountOut via the active\n * network's QuoterV2 (Synthra shim on robinhood-testnet)\n *\n * Quoting primitives (getQuote / getMultiHopQuote) moved here from lib/quote.ts,\n * which is now a back-compat re-export shim. QuoterV2's quote functions are NOT\n * view — they revert internally after computing — so we use eth_call and decode\n * the return data. The client is injectable (`deps.client`) so tests never need\n * a live RPC.\n *\n * Path/extraData byte layouts are owned by template-encoder.ts (golden-vector\n * tested) and strategies/portfolio-template.ts (v4 modes) — this module only\n * composes them; it never re-implements an encoding.\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeFunctionData, decodeFunctionResult } from \"viem\";\nimport { getPublicClient } from \"./client.js\";\nimport { getNetwork } from \"./network.js\";\nimport { UNISWAP } from \"./addresses.js\";\nimport { UNISWAP_QUOTER_V2_ABI } from \"./abis.js\";\nimport { buildSwapExtraData, detectSwapRoute, encodeV3Path } from \"./template-encoder.js\";\n\nexport const DEFAULT_FEE_TIER = 3000;\n\n/**\n * Standard v3 fee tiers probed by best-execution tier selection (SHE-20 /\n * #436). Matches the candidate set the old per-chain auto-detect enumerated\n * (preferred + 10000/3000/500) — no new venues, just an output comparison.\n */\nexport const CANDIDATE_FEE_TIERS: readonly number[] = [500, 3000, 10000];\n\nconst ZERO: Address = \"0x0000000000000000000000000000000000000000\";\n\n/**\n * Minimal client surface needed for quoting (eth_call). getPublicClient()\n * satisfies it; tests inject a mock.\n */\nexport interface QuoterClient {\n call(args: { to: Address; data: Hex }): Promise<{ data?: Hex }>;\n}\n\nexport interface QuoteDeps {\n client?: QuoterClient;\n}\n\nexport type Route =\n | {\n kind: \"v3-direct\";\n tokenIn: Address;\n tokenOut: Address;\n feeTier: number;\n routeDesc: string;\n }\n | {\n kind: \"v3-hop\";\n tokenIn: Address;\n tokenOut: Address;\n via: Address;\n feeIn: number;\n feeOut: number;\n routeDesc: string;\n };\n\nexport interface QuoteResult {\n amountOut: bigint;\n sqrtPriceX96After: bigint;\n gasEstimate: bigint;\n}\n\nexport interface Quote extends QuoteResult {\n route: Route;\n}\n\n// ── Route detection ──\n\n/**\n * Detect the swap route for a token pair on the current chain.\n * Wraps template-encoder's detectSwapRoute (which owns the per-chain routing\n * decision); on the current deployment target this is pure — always a direct\n * v3-style route through the Synthra-backed adapter.\n */\nexport async function detectRoute(\n tokenIn: Address,\n tokenOut: Address,\n preferredFeeTier: number = DEFAULT_FEE_TIER,\n): Promise<Route> {\n const detected = await detectSwapRoute(tokenIn, tokenOut, preferredFeeTier);\n if (!detected) {\n throw new Error(`No swap route found for ${tokenIn}→${tokenOut} (fee ${preferredFeeTier})`);\n }\n return {\n kind: \"v3-direct\",\n tokenIn,\n tokenOut,\n feeTier: preferredFeeTier,\n routeDesc: detected.routeDesc,\n };\n}\n\n// ── Calldata building ──\n\n/**\n * Build adapter swapExtraData for a route. Byte encoding is delegated to\n * template-encoder's tested buildSwapExtraData (mode 0 single-hop / mode 1\n * multi-hop with a per-hop slippage budget).\n */\nexport function buildSwapCalldata(\n route: Route,\n opts: { perHopSlippageBps?: number } = {},\n): Hex {\n const network = getNetwork();\n if (route.kind === \"v3-hop\") {\n return buildSwapExtraData(\n network,\n route.tokenIn,\n route.tokenOut,\n route.feeIn,\n { via: route.via, feeIn: route.feeIn, feeOut: route.feeOut },\n opts.perHopSlippageBps ?? 100,\n );\n }\n return buildSwapExtraData(network, route.tokenIn, route.tokenOut, route.feeTier);\n}\n\n// ── Quoting ──\n\nfunction quoterAddress(): Address {\n const quoter = UNISWAP().QUOTER_V2;\n if (quoter === ZERO) {\n throw new Error(\"QuoterV2 not deployed on this network\");\n }\n return quoter;\n}\n\n/**\n * Quote a swap on the current chain: detect the route, then price it through\n * the network's QuoterV2 (Synthra shim on robinhood-testnet).\n */\nexport async function quote(\n params: { tokenIn: Address; tokenOut: Address; amountIn: bigint; feeTier?: number },\n deps: QuoteDeps = {},\n): Promise<Quote> {\n const route = await detectRoute(params.tokenIn, params.tokenOut, params.feeTier);\n if (route.kind === \"v3-hop\") {\n const path = encodeSwapPath(\n [route.tokenIn, route.via, route.tokenOut],\n [route.feeIn, route.feeOut],\n );\n const result = await getMultiHopQuote({ path, amountIn: params.amountIn }, deps);\n return { route, ...result };\n }\n const result = await getQuote(\n {\n tokenIn: route.tokenIn,\n tokenOut: route.tokenOut,\n amountIn: params.amountIn,\n fee: route.feeTier,\n },\n deps,\n );\n return { route, ...result };\n}\n\n/**\n * Best-execution fee-tier selection (SHE-20 / #436).\n *\n * Quotes `amountIn` (exact-in) through EVERY candidate fee tier and returns\n * the tier with the highest `amountOut` — never the first tier that merely\n * quotes. A tier whose quote reverts, returns no data, or returns a zero\n * output is skipped (no pool, or a pool too shallow to price the amount).\n *\n * Determinism: tiers are probed in a fixed order — the preferred tier first,\n * then the remaining candidates ascending as listed in CANDIDATE_FEE_TIERS —\n * and a strictly-greater comparison picks the winner, so on an exact\n * output tie the earlier tier (i.e. the preferred one) wins.\n *\n * Returns null when NO candidate quotes at all (no route, or the quoter is\n * unreachable). Callers decide the fallback: the portfolio propose flow\n * falls back to the preferred tier — the pre-SHE-20 behavior — rather than\n * failing, so a dead RPC cannot brick a propose that works today.\n */\nexport async function selectBestFeeTier(\n params: {\n tokenIn: Address;\n tokenOut: Address;\n amountIn: bigint;\n preferredFeeTier?: number;\n candidateFeeTiers?: readonly number[];\n },\n deps: QuoteDeps = {},\n): Promise<{\n feeTier: number;\n amountOut: bigint;\n quoted: { feeTier: number; amountOut: bigint }[];\n} | null> {\n const preferred = params.preferredFeeTier ?? DEFAULT_FEE_TIER;\n const candidates = params.candidateFeeTiers ?? CANDIDATE_FEE_TIERS;\n const tiers = [preferred, ...candidates.filter((t) => t !== preferred)];\n\n const quoted: { feeTier: number; amountOut: bigint }[] = [];\n for (const fee of tiers) {\n try {\n const { amountOut } = await getQuote(\n { tokenIn: params.tokenIn, tokenOut: params.tokenOut, amountIn: params.amountIn, fee },\n deps,\n );\n if (amountOut > 0n) quoted.push({ feeTier: fee, amountOut });\n } catch {\n // No pool at this tier (quoter revert / no data) — skip it.\n }\n }\n\n if (quoted.length === 0) return null;\n let best = quoted[0];\n for (const q of quoted) {\n if (q.amountOut > best.amountOut) best = q;\n }\n return { feeTier: best.feeTier, amountOut: best.amountOut, quoted };\n}\n\n/**\n * Get a single-hop swap quote from QuoterV2 (moved from lib/quote.ts).\n */\nexport async function getQuote(\n params: { tokenIn: Address; tokenOut: Address; amountIn: bigint; fee: number },\n deps: QuoteDeps = {},\n): Promise<QuoteResult> {\n const client = deps.client ?? getPublicClient();\n\n const calldata = encodeFunctionData({\n abi: UNISWAP_QUOTER_V2_ABI,\n functionName: \"quoteExactInputSingle\",\n args: [\n {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amountIn: params.amountIn,\n fee: params.fee,\n sqrtPriceLimitX96: 0n,\n },\n ],\n });\n\n const { data } = await client.call({ to: quoterAddress(), data: calldata });\n\n if (!data) {\n throw new Error(\"Quoter returned no data — pool may not exist for this pair/fee\");\n }\n\n const [amountOut, sqrtPriceX96After, , gasEstimate] = decodeFunctionResult({\n abi: UNISWAP_QUOTER_V2_ABI,\n functionName: \"quoteExactInputSingle\",\n data,\n }) as [bigint, bigint, number, bigint];\n\n return { amountOut, sqrtPriceX96After, gasEstimate };\n}\n\n/**\n * Get a multi-hop swap quote from QuoterV2 (moved from lib/quote.ts).\n */\nexport async function getMultiHopQuote(\n params: { path: Hex; amountIn: bigint },\n deps: QuoteDeps = {},\n): Promise<QuoteResult> {\n const client = deps.client ?? getPublicClient();\n\n const calldata = encodeFunctionData({\n abi: UNISWAP_QUOTER_V2_ABI,\n functionName: \"quoteExactInput\",\n args: [params.path, params.amountIn],\n });\n\n const { data } = await client.call({ to: quoterAddress(), data: calldata });\n\n if (!data) {\n throw new Error(\"Quoter returned no data — pool may not exist for this path\");\n }\n\n const [amountOut, , , gasEstimate] = decodeFunctionResult({\n abi: UNISWAP_QUOTER_V2_ABI,\n functionName: \"quoteExactInput\",\n data,\n }) as [bigint, bigint[], number[], bigint];\n\n return { amountOut, sqrtPriceX96After: 0n, gasEstimate };\n}\n\n// ── Pure helpers (moved from lib/quote.ts) ──\n\n/**\n * Apply slippage tolerance to a quote amount.\n * Returns the minimum acceptable output amount.\n */\nexport function applySlippage(amountOut: bigint, slippageBps: number): bigint {\n return (amountOut * BigInt(10000 - slippageBps)) / 10000n;\n}\n\n/**\n * Encode a Uniswap V3 multi-hop swap path (address + uint24 fee + address ...).\n * Validates the shape here (>= 2 tokens), then delegates the byte layout to\n * template-encoder's tested encodeV3Path.\n */\nexport function encodeSwapPath(tokens: Address[], fees: number[]): Hex {\n if (tokens.length < 2 || fees.length !== tokens.length - 1) {\n throw new Error(\"Invalid path: need at least 2 tokens and (tokens-1) fees\");\n }\n return encodeV3Path(tokens, fees);\n}\n\n/** Token decimals for display purposes (moved from lib/quote.ts). */\nexport const TOKEN_DECIMALS: Record<string, number> = {\n USDC: 6,\n WETH: 18,\n cbETH: 18,\n wstETH: 18,\n cbBTC: 8,\n DAI: 18,\n AERO: 18,\n};\n","/**\n * Template encoder — pure params → bytes encoding for strategy templates.\n *\n * Extracted from commands/strategy-template.ts so the calldata-producing logic\n * is testable without a chain. The interface is deliberately small:\n *\n * - buildInitDataForTemplate(templateKey, opts, vault, resolved?) — per-template\n * initialize() payload + the asset/amount the vault must fund.\n * - buildCallsForTemplate(templateKey, clone, asset, amount, extraApprovals?) —\n * the execute/settle BatchCall arrays for a proposal.\n *\n * Secondary exports (parseSwapRouteSpec, buildSwapExtraData, encodeV3Path,\n * parseAlignedOverrides, computeProposalAssetChecks, resolve* helpers) exist for\n * the command layer and for tests.\n *\n * PURITY RULE: nothing in this module performs chain I/O or touches the signer.\n * The two inputs that historically needed RPC (the Venice minVVV auto-quote and\n * the Aerodrome tokenA/tokenB decimals) are supplied by the caller via\n * `ResolvedChainInputs` — see resolveChainInputsForTemplate in\n * commands/strategy-template.ts. Registry lookups (TOKENS(), CHAINLINK(), …) are\n * config reads keyed off the network singleton, not RPC.\n */\n\nimport type { Address, Hex } from \"viem\";\nimport {\n parseUnits,\n isAddress,\n encodeAbiParameters,\n concat,\n numberToHex,\n} from \"viem\";\nimport chalk from \"chalk\";\n\nimport { getNetwork } from \"./network.js\";\nimport {\n TOKENS,\n MOONWELL,\n VENICE,\n AERODROME,\n UNISWAP,\n SYNTHRA,\n CHAINLINK,\n ROBINHOOD_STOCK_ROUTES,\n} from \"./addresses.js\";\nimport type { BatchCall } from \"./batch.js\";\n\nimport * as moonwellBuilder from \"../strategies/moonwell-supply-template.js\";\nimport * as veniceBuilder from \"../strategies/venice-inference-template.js\";\nimport * as aerodromeBuilder from \"../strategies/aerodrome-lp-template.js\";\nimport * as wstethBuilder from \"../strategies/wsteth-moonwell-template.js\";\nimport * as mamoBuilder from \"../strategies/mamo-yield-template.js\";\nimport * as portfolioBuilder from \"../strategies/portfolio-template.js\";\nimport * as hyperliquidPerpBuilder from \"../strategies/hyperliquid-perp-template.js\";\nimport * as hyperliquidGridBuilder from \"../strategies/hyperliquid-grid-template.js\";\n\nconst ZERO: Address = \"0x0000000000000000000000000000000000000000\";\n\n/**\n * Chain-derived inputs the encoder cannot (and must not) fetch itself.\n * Resolved by the command layer BEFORE encoding (see\n * resolveChainInputsForTemplate in commands/strategy-template.ts).\n */\nexport interface ResolvedChainInputs {\n /** venice-inference: agent wallet — the caller defaults it to the signer. */\n veniceAgent?: Address;\n /**\n * venice-inference: auto-quoted minVVV (18-dec) for a non-direct path when\n * --min-vvv was not passed. Quoted via the Aerodrome router off-module.\n */\n veniceMinVVV?: bigint;\n /** aerodrome-lp: on-chain decimals() of tokenA / tokenB. */\n aerodromeDecimals?: { decimalsA: number; decimalsB: number };\n /**\n * portfolio: per-allocation best-execution v3 fee tier, index-aligned with\n * --tokens (SHE-20 / #436). Quoted by the command layer (see\n * resolveChainInputsForTemplate in commands/strategy-template-lib.ts) at\n * each leg's ACTUAL allocation amount (weight × totalAmount) across all\n * candidate tiers, picking the highest output. A null/undefined slot falls\n * through to detectSwapRoute's preferred-tier default — an explicit\n * --swap-routes override for the slot still wins over both.\n */\n portfolioFeeTiers?: ({ feeTier: number; routeDesc: string } | null)[];\n}\n\n// ── Uniswap V3 swap routing helpers ──\n\n/**\n * Encode Uniswap V3 packed path: token (20 bytes) + fee (3 bytes) + token (20 bytes) [+ fee + token ...]\n */\nexport function encodeV3Path(tokens: Address[], fees: number[]): Hex {\n if (tokens.length !== fees.length + 1) throw new Error(\"tokens.length must be fees.length + 1\");\n const parts: Hex[] = [];\n for (let i = 0; i < tokens.length; i++) {\n parts.push(tokens[i].toLowerCase() as Hex);\n if (i < fees.length) {\n // fee as 3 bytes (uint24)\n parts.push(numberToHex(fees[i], { size: 3 }));\n }\n }\n return concat(parts);\n}\n\n/**\n * Build swapExtraData for the UniswapSwapAdapter.\n *\n * Mode 0 — single-hop: 0x00 + abi.encode(uint24 fee)\n * Mode 1 — multi-hop: 0x01 + abi.encode(bytes path, uint16 perHopSlippageBps)\n *\n * Sherlock run #2 #11: mode-1 extraData now carries a per-hop slippage\n * budget so the adapter's `_chainedSingleHops` can enforce a per-hop\n * `amountOutMinimum` derived from a quoter pre-call at swap time. This\n * closes the cascading-sandwich attack on intermediate hops. Default\n * to 100 bps (1%) per hop unless the caller overrides — conservative\n * for typical V3 routes; mainnet templates with deeper pools can\n * tighten this. The adapter still enforces the top-level `amountOutMin`\n * on the final hop, so cumulative slippage is doubly capped.\n *\n * robinhood-testnet uses the registry UniswapSwapAdapter (Synthra-router-backed,\n * QuoterV2-shim), which consumes the SAME mode-prefixed encoding as the other\n * chains — mode 0 single-hop / mode 1 multi-hop — so no special-case here.\n */\nexport function buildSwapExtraData(\n network: string,\n tokenIn: Address,\n tokenOut: Address,\n feeTier: number,\n hop?: { via: Address; feeIn: number; feeOut: number },\n perHopSlippageBps: number = 100,\n): Hex {\n if (hop) {\n // Multi-hop: tokenIn → hop.via → tokenOut\n const path = encodeV3Path([tokenIn, hop.via, tokenOut], [hop.feeIn, hop.feeOut]);\n const encoded = encodeAbiParameters(\n [{ type: \"bytes\" }, { type: \"uint16\" }],\n [path, perHopSlippageBps],\n );\n return `0x01${encoded.slice(2)}` as Hex;\n }\n\n // Single-hop: mode 0\n const encoded = encodeAbiParameters([{ type: \"uint24\" }], [feeTier]);\n return `0x00${encoded.slice(2)}` as Hex;\n}\n\n// ── Explicit per-token swap-route spec parsing (--swap-routes) ──\n//\n// One entry per allocation, comma-separated at the flag level. Each entry:\n// 'v3:<fee>' → mode 0 (v3 single-hop)\n// 'v4:<fee>:<tickSpacing>' → mode 2 (v4 single-hop hookless)\n// 'v4path:<hop>+<hop>+...' → mode 3 (v4 multi-hop hookless)\n// where hop = '<currency>@<fee>:<tickSpacing>' and\n// currency ∈ { 'eth'|'native' → address(0), 'self' → this allocation's\n// token, or a literal 0x-address }. The last hop's currency MUST resolve\n// to the allocation token (contract-enforced); 'self' is the ergonomic form.\n\nexport function parseSwapRouteSpec(spec: string, token: Address): Hex {\n const s = spec.trim();\n const [kind, ...restParts] = s.split(\":\");\n const rest = restParts.join(\":\");\n switch (kind) {\n case \"v3\": {\n const fee = Number(rest);\n if (!Number.isInteger(fee) || fee <= 0) throw new Error(`bad v3 fee in '${spec}'`);\n return portfolioBuilder.v3SingleHopExtraData(fee);\n }\n case \"v4\": {\n const [feeStr, tsStr] = rest.split(\":\");\n const fee = Number(feeStr);\n const tickSpacing = Number(tsStr);\n if (!Number.isInteger(fee) || fee <= 0) throw new Error(`bad v4 fee in '${spec}'`);\n if (!Number.isInteger(tickSpacing) || tickSpacing <= 0) throw new Error(`bad v4 tickSpacing in '${spec}'`);\n return portfolioBuilder.v4SingleHopExtraData(fee, tickSpacing);\n }\n case \"v4path\": {\n const hops = rest.split(\"+\").map((hopStr) => {\n const [currencyRaw, feeTs] = hopStr.split(\"@\");\n if (!feeTs) throw new Error(`bad v4path hop '${hopStr}' in '${spec}' (expected currency@fee:tickSpacing)`);\n const [feeStr, tsStr] = feeTs.split(\":\");\n const fee = Number(feeStr);\n const tickSpacing = Number(tsStr);\n if (!Number.isInteger(fee) || fee <= 0) throw new Error(`bad v4path fee in '${spec}'`);\n if (!Number.isInteger(tickSpacing) || tickSpacing <= 0) throw new Error(`bad v4path tickSpacing in '${spec}'`);\n const c = currencyRaw.trim().toLowerCase();\n let currency: Address;\n if (c === \"eth\" || c === \"native\") currency = ZERO;\n else if (c === \"self\") currency = token;\n else if (isAddress(currencyRaw.trim())) currency = currencyRaw.trim() as Address;\n else throw new Error(`bad v4path currency '${currencyRaw}' in '${spec}' (use eth/native/self/0x-address)`);\n return { currency, fee, tickSpacing };\n });\n return portfolioBuilder.v4PathExtraData(hops);\n }\n default:\n throw new Error(`unknown swap-route kind '${kind}' in '${spec}' (use v3/v4/v4path)`);\n }\n}\n\n/**\n * Auto-detect swap route for a token pair on Uniswap V3.\n * Returns { direct: true, feeTier } or { direct: false, hop } or null if no route found.\n *\n * NOTE (encoder purity): on the current deployment target this performs NO\n * chain I/O — the multi-chain v3 pool probing was removed with Base/HyperEVM.\n * If per-chain detection comes back, the pool probing belongs in the command\n * layer (resolveChainInputsForTemplate), NOT here.\n */\nexport async function detectSwapRoute(\n asset: Address,\n token: Address,\n preferredFeeTier: number,\n): Promise<{ extraData: Hex; routeDesc: string } | null> {\n const network = getNetwork();\n // Both Robinhood chains use a direct v3-style route (Synthra-backed adapter\n // on 46630, official Uniswap v3 on the fork). Multi-chain v3 auto-detect (Base/HyperEVM)\n // was removed with those chains; re-add per-chain detection here when a chain\n // with distinct routing comes back.\n return {\n extraData: buildSwapExtraData(network, asset, token, preferredFeeTier),\n routeDesc: `direct (fee ${preferredFeeTier})`,\n };\n}\n\n// ── Helpers for building init data per template ──\n\n/**\n * Pure (no-RPC) derivation of the assets a propose call will pull from the\n * vault. Mirrors the asset/amount slice of `buildInitDataForTemplate` so the\n * propose preflight can balance-check the vault BEFORE clone + init burns\n * any gas. Returns one entry per token the vault has to fund — single\n * entry for most templates, two for aerodrome-lp (tokenA + tokenB).\n *\n * Templates whose amount is `0n` (hyperliquid-perp / -grid in dynamic-all\n * mode, wsteth-moonwell without --amount) intentionally return entries\n * with `amount === 0n`; the caller short-circuits on those.\n *\n * Kept in sync with `buildInitDataForTemplate` per-branch logic. The\n * sync-invariant suite in template-encoder.test.ts enforces the mirror for\n * venice-inference, wsteth-moonwell, mamo-yield, portfolio, hyperliquid-perp\n * and hyperliquid-grid. NOT enforced there: moonwell-supply (no Moonwell\n * market on the Robinhood-testnet token registry, so the branch is\n * unreachable in tests) and aerodrome-lp (returns [] — per-leg decimals\n * need RPC). Diverging here only weakens the preflight guard — the real\n * values still come from `buildInitDataForTemplate`, so we'd just miss a\n * warning, never produce an inconsistent on-chain call.\n */\nexport function computeProposalAssetChecks(\n templateKey: string,\n opts: Record<string, string | boolean | undefined>,\n): { asset: Address; amount: bigint; label: string }[] {\n if (templateKey === \"moonwell-supply\" || templateKey === \"mamo-yield\") {\n if (!opts.amount) return [];\n const token = (opts.token as string) || \"USDC\";\n const asset = resolveToken(token);\n const decimals = assetDecimalsForSymbol(token);\n return [{ asset, amount: parseUnits(opts.amount as string, decimals), label: token.toUpperCase() }];\n }\n\n if (templateKey === \"venice-inference\") {\n if (!opts.amount) return [];\n const assetSymbol = (opts.asset as string) || \"USDC\";\n const asset = resolveToken(assetSymbol);\n const decimals = assetDecimalsForSymbol(assetSymbol);\n return [{ asset, amount: parseUnits(opts.amount as string, decimals), label: assetSymbol.toUpperCase() }];\n }\n\n if (templateKey === \"aerodrome-lp\") {\n // Aerodrome needs both legs of the pair funded. We can't compute the\n // per-leg parseUnits without a decimals() RPC, so we fall back to a\n // raw-units balance check (vault must hold at least `amountA` raw of\n // tokenA AND `amountB` raw of tokenB). Worst case: a stricter check\n // than needed, never permissive.\n if (!opts.tokenA || !opts.tokenB || !opts.amountA || !opts.amountB) return [];\n // amountA/amountB are human strings — without decimals we can't normalize.\n // Skip the precise check for aerodrome and let buildInitDataForTemplate\n // handle errors. (Other templates cover the common --amount footgun.)\n return [];\n }\n\n if (templateKey === \"wsteth-moonwell\") {\n if (!opts.amount) return []; // dynamic-all mode\n return [{\n asset: TOKENS().WETH,\n amount: parseUnits(opts.amount as string, 18),\n label: \"WETH\",\n }];\n }\n\n if (templateKey === \"portfolio\") {\n if (!opts.amount) return [];\n // Keep this in lock-step with buildInitDataForTemplate's portfolio branch:\n // default asset is USDG on robinhood mainnet (6 dec, no USDC there), WETH on\n // robinhood-testnet, USDC elsewhere; decimals resolved from token metadata.\n const assetSymbol = (opts.asset as string) || defaultPortfolioAsset();\n const asset = resolveToken(assetSymbol);\n const decimals = assetDecimalsForSymbol(assetSymbol);\n return [{ asset, amount: parseUnits(opts.amount as string, decimals), label: assetSymbol.toUpperCase() }];\n }\n\n if (templateKey === \"hyperliquid-perp\" || templateKey === \"hyperliquid-grid\") {\n if (!opts.amount) return []; // dynamic-all mode — skip check\n const token = (opts.token as string) || \"USDC\";\n const asset = resolveToken(token);\n const decimals = assetDecimalsForSymbol(token);\n return [{ asset, amount: parseUnits(opts.amount as string, decimals), label: token.toUpperCase() }];\n }\n\n return [];\n}\n\n/**\n * Parse a comma-separated per-allocation override flag (--feeds,\n * --price-decimals, --swap-routes) into a slot-aligned array.\n *\n * Empty entries are PRESERVED (trimmed to \"\"), NOT filtered — so partial\n * overrides work: an empty slot falls through to that flag's per-slot\n * auto-resolve default (e.g. `--price-decimals \"8,,8\"` overrides slots 0 and 2\n * and auto-resolves slot 1). Filtering empties would collapse the length and\n * either misalign the remaining entries or trip the length check.\n *\n * Alignment is validated only when the flag is PRESENT (`raw !== undefined`):\n * an unset flag yields `[]` and `mismatch: false`. A present flag whose entry\n * count ≠ `expectedLen` returns `mismatch: true` for the caller to hard-exit.\n * (An unset flag is `undefined` here; `\"\"` — an explicitly empty flag — is\n * \"present\" and splits to `[\"\"]`, i.e. one empty slot.)\n */\nexport function parseAlignedOverrides(\n raw: string | undefined,\n expectedLen: number,\n): { values: string[]; mismatch: boolean } {\n if (raw === undefined) return { values: [], mismatch: false };\n const values = raw.split(\",\").map((s) => s.trim());\n return { values, mismatch: values.length !== expectedLen };\n}\n\nexport async function buildInitDataForTemplate(\n templateKey: string,\n opts: Record<string, string | boolean | undefined>,\n vault: Address,\n resolved?: ResolvedChainInputs,\n): Promise<{ initData: Hex; asset: Address; assetAmount: bigint; extraApprovals?: { token: Address; amount: bigint }[] }> {\n if (templateKey === \"moonwell-supply\") {\n if (!opts.amount) {\n console.error(chalk.red(\"--amount is required for moonwell-supply template\"));\n process.exit(1);\n }\n const token = (opts.token as string) || \"USDC\";\n const underlying = resolveToken(token);\n const mToken = resolveMToken(token);\n const decimals = assetDecimalsForSymbol(token);\n const supplyAmount = parseUnits(opts.amount as string, decimals);\n const minRedeem = parseUnits((opts.minRedeem as string) || opts.amount as string, decimals);\n // V2: Moonwell's native-ETH (mWETH) market redeems raw ETH the strategy\n // wraps back to WETH — every non-USDC token here is the WETH market.\n const isNativeEthMarket = token.toUpperCase() !== \"USDC\";\n\n return {\n initData: moonwellBuilder.buildInitData(underlying, mToken, supplyAmount, minRedeem, isNativeEthMarket),\n asset: underlying,\n assetAmount: supplyAmount,\n };\n }\n\n if (templateKey === \"venice-inference\") {\n if (!opts.amount) {\n console.error(chalk.red(\"--amount is required for venice-inference template\"));\n process.exit(1);\n }\n const assetSymbol = (opts.asset as string) || \"USDC\";\n const asset = resolveToken(assetSymbol);\n const vvv = VENICE().VVV;\n const isDirect = asset.toLowerCase() === vvv.toLowerCase();\n const decimals = assetDecimalsForSymbol(assetSymbol);\n const assetAmount = parseUnits(opts.amount as string, decimals);\n // The signer-default agent and the Aerodrome getAmountsOut auto-quote are\n // chain/signer concerns — the command layer resolves both (see\n // resolveChainInputsForTemplate) and passes them in.\n const agent = (opts.agent as Address) || resolved?.veniceAgent;\n if (!agent) {\n throw new Error(\n \"venice-inference: missing agent — pass --agent or resolve chain inputs (signer default) before encoding\",\n );\n }\n const isSingleHop = !!opts.singleHop;\n\n // minVVV: explicit flag wins; non-direct paths without it need the\n // caller-resolved auto-quote (5% slippage applied at quote time).\n let minVVV = 0n;\n if (!isDirect) {\n if (opts.minVvv) {\n minVVV = parseUnits(opts.minVvv as string, 18);\n } else if (resolved?.veniceMinVVV !== undefined) {\n minVVV = resolved.veniceMinVVV;\n } else {\n throw new Error(\n \"venice-inference: missing resolved minVVV quote — pass --min-vvv or resolve chain inputs before encoding\",\n );\n }\n }\n\n const params: veniceBuilder.VeniceInferenceInitParams = {\n asset,\n weth: isDirect ? ZERO : TOKENS().WETH,\n vvv,\n sVVV: VENICE().STAKING,\n aeroRouter: isDirect ? ZERO : AERODROME().ROUTER,\n aeroFactory: isDirect ? ZERO : AERODROME().FACTORY,\n agent,\n assetAmount,\n minVVV,\n deadlineOffset: 300n,\n singleHop: isSingleHop,\n };\n\n return {\n initData: veniceBuilder.buildInitData(params),\n asset,\n assetAmount,\n };\n }\n\n if (templateKey === \"aerodrome-lp\") {\n for (const flag of [\"tokenA\", \"tokenB\", \"amountA\", \"amountB\", \"lpToken\"]) {\n if (!opts[flag]) {\n console.error(chalk.red(`--${flag.replace(/([A-Z])/g, \"-$1\").toLowerCase()} is required for aerodrome-lp template`));\n process.exit(1);\n }\n }\n const tokenA = opts.tokenA as Address;\n const tokenB = opts.tokenB as Address;\n // decimals() is a chain read — the command layer resolves it (see\n // resolveChainInputsForTemplate) and passes it in.\n if (!resolved?.aerodromeDecimals) {\n throw new Error(\n \"aerodrome-lp: missing resolved tokenA/tokenB decimals — resolve chain inputs before encoding\",\n );\n }\n const { decimalsA, decimalsB } = resolved.aerodromeDecimals;\n const amountA = parseUnits(opts.amountA as string, decimalsA);\n const amountB = parseUnits(opts.amountB as string, decimalsB);\n const minAOut = parseUnits((opts.minAOut as string) || \"0\", decimalsA);\n const minBOut = parseUnits((opts.minBOut as string) || \"0\", decimalsB);\n\n const params: aerodromeBuilder.AerodromeLPInitParams = {\n tokenA,\n tokenB,\n stable: !!opts.stable,\n factory: AERODROME().FACTORY,\n router: AERODROME().ROUTER,\n gauge: (opts.gauge as Address) || ZERO,\n lpToken: opts.lpToken as Address,\n amountADesired: amountA,\n amountBDesired: amountB,\n amountAMin: amountA, // use desired as min for now\n amountBMin: amountB,\n minAmountAOut: minAOut,\n minAmountBOut: minBOut,\n };\n\n return {\n initData: aerodromeBuilder.buildInitData(params),\n asset: tokenA,\n assetAmount: amountA,\n extraApprovals: [{ token: tokenB, amount: amountB }],\n };\n }\n\n if (templateKey === \"wsteth-moonwell\") {\n const supplyAmount = opts.amount ? parseUnits(opts.amount as string, 18) : 0n; // WETH = 18 decimals; 0 => use full vault balance at execute time\n const slippageBps = BigInt((opts.slippage as string) || \"500\"); // default 5% slippage\n // Per-unit rates (1e18-scaled) — Aerodrome wstETH/WETH stable pool trades\n // near 1:1, so default the expected rate to 1e18. Slippage cuts from that.\n // Rates scale with amountIn at execute time → dynamic-all mode is safe.\n const ONE = 10n ** 18n;\n const minWstethOutPerWeth = (ONE * (10000n - slippageBps)) / 10000n;\n const minWethOutPerWsteth = (ONE * (10000n - slippageBps)) / 10000n;\n\n const params: wstethBuilder.WstETHMoonwellInitParams = {\n weth: TOKENS().WETH,\n wsteth: TOKENS().wstETH,\n mwsteth: MOONWELL().mWstETH,\n aeroRouter: AERODROME().ROUTER,\n aeroFactory: AERODROME().FACTORY,\n chainlinkWstethEthFeed: CHAINLINK().WSTETH_ETH_FEED,\n supplyAmount,\n minWstethOutPerWeth,\n minWethOutPerWsteth,\n deadlineOffset: 300n,\n };\n\n return {\n initData: wstethBuilder.buildInitData(params),\n asset: TOKENS().WETH,\n assetAmount: supplyAmount,\n };\n }\n\n if (templateKey === \"mamo-yield\") {\n if (!opts.amount) {\n console.error(chalk.red(\"--amount is required for mamo-yield template\"));\n process.exit(1);\n }\n if (!opts.mamoFactory) {\n console.error(chalk.red(\"--mamo-factory is required for mamo-yield template\"));\n process.exit(1);\n }\n const token = (opts.token as string) || \"USDC\";\n const underlying = resolveToken(token);\n const decimals = assetDecimalsForSymbol(token);\n const amount = parseUnits(opts.amount as string, decimals);\n const minRedeemAmount = parseUnits((opts.minRedeem as string) || opts.amount as string, decimals);\n\n return {\n initData: mamoBuilder.buildInitData(underlying, opts.mamoFactory as Address, minRedeemAmount),\n asset: underlying,\n assetAmount: amount,\n };\n }\n\n if (templateKey === \"portfolio\") {\n if (!opts.amount) { console.error(chalk.red(\"--amount is required for portfolio template\")); process.exit(1); }\n if (!opts.tokens || !opts.weights) {\n console.error(chalk.red(\"--tokens and --weights are required for portfolio template\"));\n console.error(chalk.dim(\" --tokens: comma-separated token addresses or symbols\"));\n console.error(chalk.dim(\" --weights: comma-separated bps (must sum to 10000)\"));\n process.exit(1);\n }\n const network = getNetwork();\n const tokens = TOKENS();\n const assetSymbol = (opts.asset as string) || defaultPortfolioAsset();\n const asset = resolveToken(assetSymbol);\n const decimals = assetDecimalsForSymbol(assetSymbol);\n const totalAmount = parseUnits(opts.amount as string, decimals);\n const maxSlippageBps = Number((opts.maxSlippage as string) || \"500\");\n const feeTier = (opts.feeTier as string) || \"3000\";\n\n // Parse token specs, keeping the original symbol/spec so we can resolve a\n // Chainlink push feed on chains that use AggregatorV3 push feeds.\n const tokenSpecs = (opts.tokens as string).split(\",\").map((t) => t.trim());\n const tokenAddrs = tokenSpecs.map((trimmed) => {\n if (isAddress(trimmed)) return trimmed as Address;\n const allTokens = tokens as Record<string, Address>;\n const resolvedAddr = allTokens[trimmed.toUpperCase()];\n if (resolvedAddr && resolvedAddr !== ZERO) return resolvedAddr;\n console.error(chalk.red(`Unknown token: ${trimmed}`)); process.exit(1);\n });\n const weightsBps = (opts.weights as string).split(\",\").map((w) => Number(w.trim()));\n if (tokenAddrs.length !== weightsBps.length) { console.error(chalk.red(\"--tokens and --weights must have same length\")); process.exit(1); }\n if (weightsBps.reduce((a, b) => a + b, 0) !== 10000) { console.error(chalk.red(`Weights must sum to 10000`)); process.exit(1); }\n\n const swapAdapter = (opts.swapAdapter as Address) || resolveSwapAdapter();\n // v1 is push-feed only: each allocation carries an AggregatorV3 proxy\n // ADDRESS, and priceDecimals must equal that feed's live decimals() (8 for\n // the tokenized-equity feeds, 18 for crypto pairs).\n const chainlink = CHAINLINK() as Record<string, Address>;\n\n // Optional explicit per-allocation overrides (comma-separated, aligned to\n // --tokens). All three flags parse identically via parseAlignedOverrides:\n // empty entries are preserved so a partial override (e.g. \"8,,8\") falls\n // through to that slot's auto-resolve default; a PRESENT flag must align\n // 1:1 with --tokens (an unset flag → [] and skips the check).\n // --feeds: AggregatorV3 proxy address per allocation. Empty slot\n // → auto-resolve SYMBOL_USD_FEED below.\n // --price-decimals: raw feed scale per allocation. Empty slot → 8.\n const feeds = parseAlignedOverrides(opts.feeds as string | undefined, tokenAddrs.length);\n const feedOverrides = feeds.values;\n if (feeds.mismatch) { console.error(chalk.red(\"--feeds must have the same length as --tokens\")); process.exit(1); }\n const priceDecimals = parseAlignedOverrides(opts.priceDecimals as string | undefined, tokenAddrs.length);\n const priceDecimalOverrides = priceDecimals.values;\n if (priceDecimals.mismatch) { console.error(chalk.red(\"--price-decimals must have the same length as --tokens\")); process.exit(1); }\n\n // Explicit per-token swap-route overrides (aligned to --tokens). An empty\n // entry falls through to the robinhood default / auto-detect below.\n const swapRoutes = parseAlignedOverrides(opts.swapRoutes as string | undefined, tokenAddrs.length);\n const swapRouteOverrides = swapRoutes.values;\n if (swapRoutes.mismatch) { console.error(chalk.red(\"--swap-routes must have the same length as --tokens\")); process.exit(1); }\n\n // Robinhood mainnet default swap routes come from the data-driven\n // ROBINHOOD_STOCK_ROUTES registry (verified on-chain liquidity) plus a WETH\n // v3 fee-500 leg. A robinhood basket token with a feed but NO verified route\n // and NO --swap-routes override fails fast (see below) rather than falling\n // through to a v3 auto-detect that is guaranteed dead on 4663.\n const wethAddr = TOKENS().WETH;\n function robinhoodDefaultRoute(token: Address, symbol: string): { extraData: Hex; routeDesc: string } | null {\n // Robinhood-mainnet-only default route (verified ROBINHOOD_STOCK_ROUTES).\n // Mainnet is not in the current deployment target, so this is inert today;\n // string-compare keeps it forward-compatible for when 4663 is added back.\n if ((network as string) !== \"robinhood\") return null;\n if (wethAddr !== ZERO && token.toLowerCase() === wethAddr.toLowerCase()) {\n return { extraData: portfolioBuilder.v3SingleHopExtraData(500), routeDesc: \"v3 direct (fee 500)\" };\n }\n const r = ROBINHOOD_STOCK_ROUTES[symbol.toUpperCase()];\n if (r) {\n return {\n extraData: portfolioBuilder.v4PathExtraData([\n { currency: ZERO, fee: r.nativeFee, tickSpacing: r.nativeTickSpacing },\n { currency: token, fee: r.stockFee, tickSpacing: r.stockTickSpacing },\n ]),\n routeDesc: `v4 multi-hop (USDG→ETH fee ${r.nativeFee} / ts ${r.nativeTickSpacing} → ${symbol.toUpperCase()} fee ${r.stockFee} / ts ${r.stockTickSpacing})`,\n };\n }\n return null;\n }\n\n // Auto-detect swap routes for each token\n console.log(chalk.dim(\" Detecting swap routes...\"));\n const allocations: portfolioBuilder.BasketAllocation[] = [];\n for (let i = 0; i < tokenAddrs.length; i++) {\n const token = tokenAddrs[i];\n let route: { extraData: Hex; routeDesc: string } | null = null;\n const override = swapRouteOverrides[i];\n if (override) {\n try {\n route = { extraData: parseSwapRouteSpec(override, token), routeDesc: `explicit '${override}'` };\n } catch (e) {\n console.error(chalk.red(`Bad --swap-routes entry for ${tokenSpecs[i]}: ${(e as Error).message}`));\n process.exit(1);\n }\n }\n if (!route) route = robinhoodDefaultRoute(token, tokenSpecs[i]);\n if (!route && (network as string) === \"robinhood\") {\n // No verified default route and no override. v3 auto-detect is dead on\n // 4663 (no v3 stock pools) — fail fast with an actionable message rather\n // than emitting a doomed proposal.\n console.error(\n chalk.red(\n `No verified default swap route for ${tokenSpecs[i]} on robinhood mainnet.`,\n ),\n );\n console.error(\n chalk.yellow(\n ` Pass --swap-routes to set it explicitly for this token, e.g.\\n` +\n ` --swap-routes 'v4path:eth@500:10+self@50000:1000' (USDG→ETH→${tokenSpecs[i].toUpperCase()})`,\n ),\n );\n process.exit(1);\n }\n if (!route) {\n // Best-execution tier resolved by the command layer (SHE-20 / #436):\n // every candidate tier quoted at the leg's actual amount, highest\n // output wins. Slot is null when quoting was unavailable (or the\n // caller skipped it, e.g. explicit --fee-tier) — then fall through to\n // the preferred-tier default below, the pre-SHE-20 behavior.\n const best = resolved?.portfolioFeeTiers?.[i];\n if (best) {\n route = {\n extraData: buildSwapExtraData(network, asset, token, best.feeTier),\n routeDesc: best.routeDesc,\n };\n }\n }\n if (!route) route = await detectSwapRoute(asset, token, Number(feeTier));\n if (!route) {\n console.error(chalk.red(`No swap route found for ${token}. No Uniswap V3 pool (direct or via WETH). Pass --swap-routes to set it explicitly.`));\n process.exit(1);\n }\n console.log(chalk.dim(` ${token.slice(0, 10)}... → ${route.routeDesc}`));\n\n // Resolve the per-allocation Chainlink push feed + priceDecimals.\n // Default priceDecimals 8 (the tokenized-equity feed scale); override wins.\n const priceDecimals = priceDecimalOverrides[i]\n ? Number(priceDecimalOverrides[i])\n : 8;\n\n let feed = feedOverrides[i] as Address | undefined;\n if (feed && !isAddress(feed)) {\n console.error(chalk.red(`Bad --feeds entry for ${tokenSpecs[i]}: '${feed}' is not a 0x-prefixed AggregatorV3 address.`));\n process.exit(1);\n }\n if (!feed) {\n // Auto-resolve SYMBOL_USD_FEED from the CHAINLINK() registry by symbol.\n // WETH/ETH share the ETH_USD_FEED key (there is no WETH_USD_FEED).\n const sym = tokenSpecs[i].toUpperCase();\n const feedKey = sym === \"WETH\" || sym === \"ETH\" ? \"ETH_USD_FEED\" : `${sym}_USD_FEED`;\n feed = isAddress(tokenSpecs[i]) ? undefined : chainlink[feedKey];\n }\n if (!feed || feed === ZERO) {\n console.error(chalk.red(`No Chainlink push feed for ${tokenSpecs[i]} on ${network}. Pass --feeds <feedAddr,...> to supply AggregatorV3 addresses (every slot must be non-zero).`));\n process.exit(1);\n }\n\n allocations.push({\n token, weightBps: weightsBps[i],\n swapExtraData: route.extraData,\n priceDecimals,\n feed,\n });\n }\n return {\n initData: portfolioBuilder.buildInitData(asset, swapAdapter, allocations, totalAmount, maxSlippageBps),\n asset, assetAmount: totalAmount,\n };\n }\n\n if (templateKey === \"hyperliquid-perp\") {\n const token = (opts.token as string) || \"USDC\";\n const asset = resolveToken(token);\n const decimals = assetDecimalsForSymbol(token);\n // Omit --amount to use the vault's full asset balance at execute time (dynamic-all mode).\n const depositAmount = opts.amount ? parseUnits(opts.amount as string, decimals) : 0n;\n const leverage = Number((opts.leverage as string) || \"10\");\n const assetIndex = Number((opts.assetIndex as string) || \"0\");\n const maxPosition = parseUnits((opts.maxPosition as string) || \"100000\", decimals);\n const maxTradesDay = Number((opts.maxTradesPerDay as string) || \"50\");\n return {\n initData: hyperliquidPerpBuilder.buildInitData(asset, depositAmount, assetIndex, leverage, maxPosition, maxTradesDay),\n asset, assetAmount: depositAmount,\n };\n }\n\n if (templateKey === \"hyperliquid-grid\") {\n const token = (opts.token as string) || \"USDC\";\n const asset = resolveToken(token);\n const decimals = assetDecimalsForSymbol(token);\n const depositAmount = opts.amount ? parseUnits(opts.amount as string, decimals) : 0n;\n const leverage = Number((opts.leverage as string) || \"5\");\n const maxOrderSize = parseUnits((opts.maxOrderSize as string) || \"10000\", decimals);\n const maxOrdersPerTick = Number((opts.maxOrdersPerTick as string) || \"20\");\n const assetIndices = ((opts.assetIndices as string) || \"0\")\n .split(\",\")\n .map((s) => Number(s.trim()))\n .filter((n) => !Number.isNaN(n));\n return {\n initData: hyperliquidGridBuilder.buildInitData(asset, depositAmount, leverage, maxOrderSize, maxOrdersPerTick, assetIndices),\n asset, assetAmount: depositAmount,\n };\n }\n\n throw new Error(`No init builder for template: ${templateKey}`);\n}\n\nexport function buildCallsForTemplate(\n templateKey: string,\n clone: Address,\n asset: Address,\n assetAmount: bigint,\n extraApprovals?: { token: Address; amount: bigint }[],\n): { executeCalls: BatchCall[]; settleCalls: BatchCall[] } {\n if (templateKey === \"moonwell-supply\") {\n return {\n executeCalls: moonwellBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: moonwellBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"venice-inference\") {\n return {\n executeCalls: veniceBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: veniceBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"aerodrome-lp\") {\n const tokenB = extraApprovals?.[0]?.token ?? ZERO;\n const amountB = extraApprovals?.[0]?.amount ?? 0n;\n return {\n executeCalls: aerodromeBuilder.buildExecuteCalls(clone, asset, assetAmount, tokenB, amountB),\n settleCalls: aerodromeBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"wsteth-moonwell\") {\n return {\n executeCalls: wstethBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: wstethBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"mamo-yield\") {\n return {\n executeCalls: mamoBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: mamoBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"portfolio\") {\n return {\n executeCalls: portfolioBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: portfolioBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"hyperliquid-perp\") {\n return {\n executeCalls: hyperliquidPerpBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: hyperliquidPerpBuilder.buildSettleCalls(clone),\n };\n }\n\n if (templateKey === \"hyperliquid-grid\") {\n return {\n executeCalls: hyperliquidGridBuilder.buildExecuteCalls(clone, asset, assetAmount),\n settleCalls: hyperliquidGridBuilder.buildSettleCalls(clone),\n };\n }\n\n throw new Error(`No call builder for template: ${templateKey}`);\n}\n\n// ── Token resolution (registry lookups — config reads, not RPC) ──\n\nexport function resolveSwapAdapter(): Address {\n const network = getNetwork();\n if (network === \"robinhood-testnet\" && SYNTHRA().ROUTER === ZERO) {\n console.error(chalk.red(\"Synthra DEX not available\"));\n process.exit(1);\n }\n // The deployed adapter on robinhood-testnet is the registry's UniswapSwapAdapter\n // (UNISWAP_SWAP_ADAPTER), backed by Synthra's router + a QuoterV2 shim\n // (SYNTHRA_QUOTER_V2_SHIM). It consumes MODE-PREFIXED extraData (0x00 single-hop\n // / 0x01 multi-hop — see buildSwapExtraData). An earlier build hardcoded a bare\n // SynthraDirectAdapter address here paired with un-prefixed extraData; that\n // adapter's on-chain `quote()` returns 0 (bricking PortfolioStrategy execute\n // with QuoteUnavailable), so always resolve the registry adapter instead.\n const adapterAddr = UNISWAP().SWAP_ADAPTER;\n if (adapterAddr !== ZERO) return adapterAddr;\n console.error(chalk.red(\"UniswapSwapAdapter not deployed yet. Use --swap-adapter to specify manually.\"));\n process.exit(1);\n}\n\nexport function resolveToken(symbolOrAddress: string): Address {\n if (isAddress(symbolOrAddress)) return symbolOrAddress as Address;\n const upper = symbolOrAddress.toUpperCase();\n // Spread the per-network TOKENS() registry (so USDG / stock tokens on robinhood\n // resolve without a second hand-rolled map — mirrors the basket-token path),\n // then overlay VVV which lives in the Venice registry rather than TOKENS().\n const tokenMap: Record<string, Address> = {\n ...(TOKENS() as Record<string, Address>),\n VVV: VENICE().VVV,\n };\n const addr = tokenMap[upper];\n if (!addr || addr === ZERO) {\n console.error(chalk.red(`Unknown token: ${symbolOrAddress}`));\n process.exit(1);\n }\n return addr;\n}\n\n/**\n * Default vault asset for the portfolio template on the current network:\n * WETH on Robinhood testnet (an ETH-only chain), USDG on the Robinhood mainnet\n * fork, USDC as the forward-compatible default for any other chain added back.\n * Single source of truth shared by buildInitDataForTemplate +\n * computeProposalAssetChecks.\n *\n * THE FORK BRANCH IS NOT COSMETIC. Robinhood mainnet has no USDC — the token\n * resolves to address(0) — so falling through to the USDC default made every\n * portfolio proposal on the fork die in preflight with a bare\n * \"Unknown token: USDC\", naming a token the operator never asked for. The rest\n * of this file already assumed otherwise (\"default asset is USDG on robinhood\n * mainnet (6 dec, no USDC there)\"); this is the line that was left behind.\n */\nexport function defaultPortfolioAsset(): string {\n const network = getNetwork();\n if (network === \"robinhood-testnet\") return \"WETH\";\n if (network === \"robinhood-fork\") return \"USDG\";\n return \"USDC\";\n}\n\n/**\n * Decimals for a vault-asset symbol. USDC and USDG are 6-decimal stables; every\n * other supported vault asset (WETH, stock tokens, …) is 18-decimal. Kept as one\n * helper so the funding math can't drift between the preflight check and the\n * on-chain init data.\n */\nexport function assetDecimalsForSymbol(symbol: string): number {\n const upper = symbol.toUpperCase();\n return upper === \"USDC\" || upper === \"USDG\" ? 6 : 18;\n}\n\nexport function resolveMToken(tokenSymbol: string): Address {\n const upper = tokenSymbol.toUpperCase();\n const moonwell = MOONWELL();\n const mTokenMap: Record<string, Address> = {\n USDC: moonwell.mUSDC,\n WETH: moonwell.mWETH,\n };\n const addr = mTokenMap[upper];\n if (!addr || addr === ZERO) {\n console.error(chalk.red(`No Moonwell market for: ${tokenSymbol}`));\n process.exit(1);\n }\n return addr;\n}\n","/**\n * MoonwellSupplyStrategy call builder.\n *\n * InitParams (Solidity, V2): (address underlying, address mToken, uint256 supplyAmount,\n * uint256 minRedeemAmount, bool isNativeEthMarket)\n *\n * `isNativeEthMarket` — true when the mToken is Moonwell's native-ETH (mWETH)\n * market, whose redeem returns raw ETH the strategy must wrap back to WETH.\n * false for ERC-20 markets (USDC). V2 beta added this field; encoding the old\n * 4-field payload makes the clone's `initialize` abi.decode revert with empty\n * data (vnet e2e finding, issues #411-#414).\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport function buildInitData(\n underlying: Address,\n mToken: Address,\n supplyAmount: bigint,\n minRedeemAmount: bigint,\n isNativeEthMarket: boolean,\n): Hex {\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bool\" },\n ],\n [underlying, mToken, supplyAmount, minRedeemAmount, isNativeEthMarket],\n );\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n underlying: Address,\n supplyAmount: bigint,\n): BatchCall[] {\n return [\n {\n target: underlying,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, supplyAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n","/**\n * VeniceInferenceStrategy call builder.\n *\n * InitParams (Solidity struct):\n * address asset, address weth, address vvv, address sVVV,\n * address aeroRouter, address aeroFactory, address agent,\n * uint256 assetAmount, uint256 minVVV, uint256 deadlineOffset, bool singleHop\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport interface VeniceInferenceInitParams {\n asset: Address;\n weth: Address;\n vvv: Address;\n sVVV: Address;\n aeroRouter: Address;\n aeroFactory: Address;\n agent: Address;\n assetAmount: bigint;\n minVVV: bigint;\n deadlineOffset: bigint;\n singleHop: boolean;\n}\n\nconst INIT_PARAMS_TYPES = [\n {\n type: \"tuple\" as const,\n components: [\n { name: \"asset\", type: \"address\" as const },\n { name: \"weth\", type: \"address\" as const },\n { name: \"vvv\", type: \"address\" as const },\n { name: \"sVVV\", type: \"address\" as const },\n { name: \"aeroRouter\", type: \"address\" as const },\n { name: \"aeroFactory\", type: \"address\" as const },\n { name: \"agent\", type: \"address\" as const },\n { name: \"assetAmount\", type: \"uint256\" as const },\n { name: \"minVVV\", type: \"uint256\" as const },\n { name: \"deadlineOffset\", type: \"uint256\" as const },\n { name: \"singleHop\", type: \"bool\" as const },\n ],\n },\n] as const;\n\nexport function buildInitData(params: VeniceInferenceInitParams): Hex {\n return encodeAbiParameters(INIT_PARAMS_TYPES, [params]);\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n asset: Address,\n assetAmount: bigint,\n): BatchCall[] {\n return [\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, assetAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n","/**\n * AerodromeLPStrategy call builder.\n *\n * InitParams (Solidity struct):\n * address tokenA, address tokenB, bool stable,\n * address factory, address router, address gauge, address lpToken,\n * uint256 amountADesired, uint256 amountBDesired,\n * uint256 amountAMin, uint256 amountBMin,\n * uint256 minAmountAOut, uint256 minAmountBOut\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport interface AerodromeLPInitParams {\n tokenA: Address;\n tokenB: Address;\n stable: boolean;\n factory: Address;\n router: Address;\n gauge: Address;\n lpToken: Address;\n amountADesired: bigint;\n amountBDesired: bigint;\n amountAMin: bigint;\n amountBMin: bigint;\n minAmountAOut: bigint;\n minAmountBOut: bigint;\n}\n\nconst INIT_PARAMS_TYPES = [\n {\n type: \"tuple\" as const,\n components: [\n { name: \"tokenA\", type: \"address\" as const },\n { name: \"tokenB\", type: \"address\" as const },\n { name: \"stable\", type: \"bool\" as const },\n { name: \"factory\", type: \"address\" as const },\n { name: \"router\", type: \"address\" as const },\n { name: \"gauge\", type: \"address\" as const },\n { name: \"lpToken\", type: \"address\" as const },\n { name: \"amountADesired\", type: \"uint256\" as const },\n { name: \"amountBDesired\", type: \"uint256\" as const },\n { name: \"amountAMin\", type: \"uint256\" as const },\n { name: \"amountBMin\", type: \"uint256\" as const },\n { name: \"minAmountAOut\", type: \"uint256\" as const },\n { name: \"minAmountBOut\", type: \"uint256\" as const },\n ],\n },\n] as const;\n\nexport function buildInitData(params: AerodromeLPInitParams): Hex {\n return encodeAbiParameters(INIT_PARAMS_TYPES, [params]);\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n tokenA: Address,\n amountA: bigint,\n tokenB: Address,\n amountB: bigint,\n): BatchCall[] {\n return [\n {\n target: tokenA,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, amountA],\n }),\n value: 0n,\n },\n {\n target: tokenB,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, amountB],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n","/**\n * WstETHMoonwellStrategy call builder.\n *\n * InitParams (Solidity struct):\n * address weth, address wsteth, address mwsteth,\n * address aeroRouter, address aeroFactory, address chainlinkWstethEthFeed,\n * uint256 supplyAmount, uint256 minWstethOutPerWeth, uint256 minWethOutPerWsteth, uint256 deadlineOffset\n * supplyAmount = 0 means use the vault's full WETH balance at execute time\n * min*PerX are 1e18-scaled per-unit rates so slippage protection scales with amountIn.\n * chainlinkWstethEthFeed is the Chainlink WSTETH/ETH price feed used by the\n * strategy's `_positionValue` for live NAV during an active proposal. Base\n * mainnet: 0x43a5C292A453A3bF3606fa856197f09D7B74251a (heartbeat 24h, 18 decimals).\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData, maxUint256 } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport interface WstETHMoonwellInitParams {\n weth: Address;\n wsteth: Address;\n mwsteth: Address;\n aeroRouter: Address;\n aeroFactory: Address;\n chainlinkWstethEthFeed: Address;\n supplyAmount: bigint;\n minWstethOutPerWeth: bigint;\n minWethOutPerWsteth: bigint;\n deadlineOffset: bigint;\n}\n\nconst INIT_PARAMS_TYPES = [\n {\n type: \"tuple\" as const,\n components: [\n { name: \"weth\", type: \"address\" as const },\n { name: \"wsteth\", type: \"address\" as const },\n { name: \"mwsteth\", type: \"address\" as const },\n { name: \"aeroRouter\", type: \"address\" as const },\n { name: \"aeroFactory\", type: \"address\" as const },\n { name: \"chainlinkWstethEthFeed\", type: \"address\" as const },\n { name: \"supplyAmount\", type: \"uint256\" as const },\n { name: \"minWstethOutPerWeth\", type: \"uint256\" as const },\n { name: \"minWethOutPerWsteth\", type: \"uint256\" as const },\n { name: \"deadlineOffset\", type: \"uint256\" as const },\n ],\n },\n] as const;\n\nexport function buildInitData(params: WstETHMoonwellInitParams): Hex {\n return encodeAbiParameters(INIT_PARAMS_TYPES, [params]);\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n weth: Address,\n supplyAmount: bigint,\n): BatchCall[] {\n // In dynamic-all mode (supplyAmount == 0) we can't know the exact amount\n // at proposal-build time, so approve maxUint256 then revoke to 0 after\n // execute() in the same batch. This bounds the residual allowance to a\n // single atomic tx — any leftover approval is cleared before control\n // returns to the governor.\n const approveAmount = supplyAmount === 0n ? maxUint256 : supplyAmount;\n\n return [\n {\n target: weth,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, approveAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n {\n target: weth,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, 0n],\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n","/**\n * MamoYieldStrategy call builder.\n *\n * InitParams (Solidity): (address underlying, address mamoFactory, uint256 minRedeemAmount)\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport function buildInitData(\n underlying: Address,\n mamoFactory: Address,\n minRedeemAmount: bigint,\n): Hex {\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"address\" },\n { type: \"uint256\" },\n ],\n [underlying, mamoFactory, minRedeemAmount],\n );\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n underlying: Address,\n amount: bigint,\n): BatchCall[] {\n return [\n {\n target: underlying,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, amount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}","/**\n * PortfolioStrategy call builder.\n *\n * InitParams (Solidity): (address asset, address swapAdapter, address[] tokens,\n * uint256[] weightsBps, uint256 totalAmount, uint256 maxSlippageBps,\n * bytes[] swapExtraData, uint8[] priceDecimals, address[] feeds)\n *\n * `priceDecimals[i]` declares the raw Chainlink feed scale for allocation `i`\n * (typically 8 for tokenized stocks, 18 for crypto pairs). It normalizes the\n * position value into the vault asset's decimals.\n *\n * `feeds[i]` is the AggregatorV3 push-feed proxy bound to allocation `i`\n * (Sherlock #56). Chainlink Data Streams is gone at v1 — there is no verifier\n * and no bytes32 feed id; the contract asserts the feed's live `decimals()`\n * equals `priceDecimals[i]` and rejects a zero address. Staleness is a flat\n * contract-wide `MAX_PUSH_PRICE_AGE` (26h), not a per-slot declaration.\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { concat, encodeAbiParameters, encodeFunctionData } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\n// ── UniswapSwapAdapter swapExtraData builders ──\n//\n// Wire format for every mode: one raw mode byte, then abi-encoded route data\n// (see UniswapSwapAdapter.sol header):\n// Mode 0 — v3 single-hop: 0x00 + abi.encode(uint24 fee)\n// Mode 1 — v3 multi-hop: 0x01 + abi.encode(bytes path, uint16 perHopSlippageBps)\n// Mode 2 — v4 single-hop: 0x02 + abi.encode(uint24 fee, int24 tickSpacing)\n// Mode 3 — v4 multi-hop: 0x03 + abi.encode(PathHop[]) where\n// PathHop = { address currency; uint24 fee; int24 tickSpacing }\n// hop i swaps prev currency → hops[i].currency; native ETH = address(0)\n// allowed as an intermediate; last hop currency MUST equal the token.\n\nconst ZERO_ADDRESS: Address = \"0x0000000000000000000000000000000000000000\";\n\n/** Concatenate a raw 1-byte mode prefix with abi-encoded route data. */\nfunction withMode(mode: number, routeData: Hex): Hex {\n const modeByte = (`0x${mode.toString(16).padStart(2, \"0\")}`) as Hex;\n return concat([modeByte, routeData]);\n}\n\n/** Mode 0 — Uniswap v3 single-hop. */\nexport function v3SingleHopExtraData(fee: number): Hex {\n return withMode(0, encodeAbiParameters([{ type: \"uint24\" }], [fee]));\n}\n\n/** Mode 2 — Uniswap v4 single-hop (hookless). */\nexport function v4SingleHopExtraData(fee: number, tickSpacing: number): Hex {\n return withMode(\n 2,\n encodeAbiParameters(\n [{ type: \"uint24\" }, { type: \"int24\" }],\n [fee, tickSpacing],\n ),\n );\n}\n\nexport interface V4PathHop {\n currency: Address; // address(0) = native ETH; last hop MUST equal the allocation token\n fee: number;\n tickSpacing: number;\n}\n\n/** Mode 3 — Uniswap v4 multi-hop (hookless; native ETH allowed as intermediate). */\nexport function v4PathExtraData(hops: V4PathHop[]): Hex {\n // The adapter's _orientHops reverts InvalidPath for n < 2 (a single hop is\n // mode 2) — reject at build time instead of at first execution.\n if (hops.length < 2) throw new Error(\"v4PathExtraData: mode 3 needs >= 2 hops (use v4SingleHopExtraData for one)\");\n return withMode(\n 3,\n encodeAbiParameters(\n [\n {\n type: \"tuple[]\",\n components: [\n { type: \"address\", name: \"currency\" },\n { type: \"uint24\", name: \"fee\" },\n { type: \"int24\", name: \"tickSpacing\" },\n ],\n },\n ],\n [hops.map((h) => ({ currency: h.currency, fee: h.fee, tickSpacing: h.tickSpacing }))],\n ),\n );\n}\n\nexport { ZERO_ADDRESS as NATIVE_ETH };\n\nexport interface BasketAllocation {\n token: Address;\n weightBps: number; // e.g. 4000 = 40%\n swapExtraData: Hex; // adapter-specific (fee tier, path, etc.)\n priceDecimals: number; // Chainlink feed report decimals (8 or 18)\n feed: Address; // AggregatorV3 push-feed proxy; must be non-zero\n}\n\nexport function buildInitData(\n asset: Address,\n swapAdapter: Address,\n allocations: BasketAllocation[],\n totalAmount: bigint,\n maxSlippageBps: number,\n): Hex {\n const tokens = allocations.map((a) => a.token);\n const weightsBps = allocations.map((a) => BigInt(a.weightBps));\n const swapExtraData = allocations.map((a) => a.swapExtraData);\n const priceDecimals = allocations.map((a) => a.priceDecimals);\n const feeds = allocations.map((a) => a.feed);\n\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"address\" },\n { type: \"address[]\" },\n { type: \"uint256[]\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bytes[]\" },\n { type: \"uint8[]\" },\n { type: \"address[]\" },\n ],\n [\n asset,\n swapAdapter,\n tokens,\n weightsBps,\n totalAmount,\n BigInt(maxSlippageBps),\n swapExtraData,\n priceDecimals,\n feeds,\n ],\n );\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n asset: Address,\n totalAmount: bigint,\n): BatchCall[] {\n return [\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, totalAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n\n// ── Rebalancing ──\n\nimport { PORTFOLIO_STRATEGY_ABI } from \"../lib/abis.js\";\n\n/**\n * Encode calldata for `rebalanceDelta()`.\n *\n * Takes no arguments at v1: the strategy reads every price from its bound\n * AggregatorV3 push feeds. The old `bytes[] priceReports` parameter went with\n * Chainlink Data Streams. Called directly by the proposer (not via vault batch).\n */\nexport function encodeRebalanceDeltaCalldata(): Hex {\n return encodeFunctionData({\n abi: PORTFOLIO_STRATEGY_ABI,\n functionName: \"rebalanceDelta\",\n });\n}\n\n/**\n * Encode calldata for `updateParams()`.\n *\n * At v1 weights and routes are FROZEN — a non-empty array for either reverts\n * (`WeightsFrozen` / `RoutesFrozen`). The tolerance is the only tunable, and\n * only downward: `newMaxSlippageBps` must sit in\n * [MIN_SLIPPAGE_BPS, current maxSlippageBps].\n */\nexport function encodeTightenSlippageCalldata(newMaxSlippageBps: number): Hex {\n const data = encodeAbiParameters(\n [{ type: \"uint256[]\" }, { type: \"uint256\" }, { type: \"bytes[]\" }],\n [[], BigInt(newMaxSlippageBps), []],\n );\n\n return encodeFunctionData({\n abi: PORTFOLIO_STRATEGY_ABI,\n functionName: \"updateParams\",\n args: [data],\n });\n}\n","/**\n * HyperliquidPerpStrategy call builder.\n *\n * InitParams (Solidity): (address asset, uint256 depositAmount, uint32 perpAssetIndex, uint32 leverage, uint256 maxPositionSize, uint32 maxTradesPerDay)\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData, maxUint256 } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\n// Frozen: the contract no longer ships in the protocol. See abis-legacy.ts.\nimport { HYPERLIQUID_PERP_STRATEGY_ABI } from \"../lib/abis-legacy.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport function buildInitData(\n asset: Address,\n depositAmount: bigint,\n perpAssetIndex: number,\n leverage: number,\n maxPositionSize: bigint,\n maxTradesPerDay: number,\n): Hex {\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"uint32\" },\n { type: \"uint32\" },\n { type: \"uint256\" },\n { type: \"uint32\" },\n ],\n [asset, depositAmount, perpAssetIndex, leverage, maxPositionSize, maxTradesPerDay],\n );\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n asset: Address,\n amount: bigint,\n): BatchCall[] {\n // In dynamic-all mode (amount == 0) we approve maxUint256 up front and\n // revoke to 0 after execute() in the same atomic batch — the residual\n // allowance never persists beyond the tx.\n const approveAmount = amount === 0n ? maxUint256 : amount;\n\n return [\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, approveAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, 0n],\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n\n/** Phase 2: sweep USDC back to vault after async HyperCore transfer completes. */\nexport function buildSweepToVaultCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: HYPERLIQUID_PERP_STRATEGY_ABI,\n functionName: \"sweepToVault\",\n }),\n value: 0n,\n },\n ];\n}\n","/**\n * FROZEN ABIs for contracts that NO LONGER SHIP IN THE PROTOCOL.\n *\n * `HyperliquidPerpStrategy` was removed from sherwood-protocol — `src/strategies/`\n * now holds only BaseStrategy, ConcentratedLiquidity, MorphoSupply and Portfolio.\n * It therefore has no build artifact, and `cli/src/lib/abis.ts` (which IS\n * generated) cannot carry it: requiring it made `npm run codegen` fail outright\n * against the post-audit protocol, which in turn blocked every ABI update.\n *\n * KEPT RATHER THAN DELETED, deliberately. Strategies already deployed from the\n * old template are still live on chain and still addressable; ripping the ABI\n * out would break the CLI's ability to talk to them, which is a product\n * decision separate from the contract's removal from the repo.\n *\n * FROZEN means frozen: nothing regenerates this file, so it can only be correct\n * for the bytecode that was deployed when the contract still existed. Do not\n * extend it, and do not add new contracts here — a contract that ships belongs\n * in the generated module, pinned to a real artifact.\n *\n * See sherwoodagent/sherwood#535 for the surrounding cleanup: the `grid`\n * commands, `hyperliquid-executor`, and the perp paths in `agent.ts` all still\n * target this contract and need their own decision.\n */\n\nexport const HYPERLIQUID_PERP_STRATEGY_ABI = [\n {\n name: \"asset\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\" }],\n },\n {\n name: \"assetTraded\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [{ name: \"\", type: \"uint32\" }],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"cumulativeSwept\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"depositAmount\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n { name: \"execute\", type: \"function\", stateMutability: \"nonpayable\", inputs: [], outputs: [] },\n {\n name: \"executed\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"finalizeForHyperCore\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"token\", type: \"uint64\" },\n { name: \"variant\", type: \"uint8\" },\n { name: \"createNonce\", type: \"uint64\" },\n ],\n outputs: [],\n },\n {\n name: \"getMarginSummary\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [\n {\n name: \"summary\",\n type: \"tuple\",\n components: [\n { name: \"accountValue\", type: \"int64\" },\n { name: \"marginUsed\", type: \"uint64\" },\n { name: \"ntlPos\", type: \"uint64\" },\n { name: \"rawUsd\", type: \"int64\" },\n ],\n },\n ],\n },\n {\n name: \"getPosition\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [\n {\n name: \"pos\",\n type: \"tuple\",\n components: [\n { name: \"szi\", type: \"int64\" },\n { name: \"entryNtl\", type: \"uint64\" },\n { name: \"isolatedRawUsd\", type: \"int64\" },\n { name: \"leverage\", type: \"uint32\" },\n { name: \"isIsolated\", type: \"bool\" },\n ],\n },\n ],\n },\n {\n name: \"getSpotBalance\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [\n {\n name: \"balance\",\n type: \"tuple\",\n components: [\n { name: \"total\", type: \"uint64\" },\n { name: \"hold\", type: \"uint64\" },\n { name: \"entryNtl\", type: \"uint64\" },\n ],\n },\n ],\n },\n {\n name: \"hasActiveStopLoss\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"hyperCoreFinalized\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"inFlightToHc\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"initialize\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"vault_\", type: \"address\" },\n { name: \"proposer_\", type: \"address\" },\n { name: \"data\", type: \"bytes\" },\n ],\n outputs: [],\n },\n {\n name: \"initiateReturn\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [],\n outputs: [],\n },\n {\n name: \"lastRecoverBlock\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"lastTradeReset\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"leverage\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\" }],\n },\n {\n name: \"maxPositionSize\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"maxTradesPerDay\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\" }],\n },\n {\n name: \"moveSpotToPerp\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [],\n outputs: [],\n },\n {\n name: \"name\",\n type: \"function\",\n stateMutability: \"pure\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\" }],\n },\n {\n name: \"perpAssetIndex\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\" }],\n },\n {\n name: \"positions\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [\n {\n name: \"ps\",\n type: \"tuple[]\",\n components: [\n { name: \"venue\", type: \"address\" },\n { name: \"kind\", type: \"bytes32\" },\n { name: \"ref\", type: \"bytes\" },\n ],\n },\n ],\n },\n {\n name: \"proposer\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\" }],\n },\n {\n name: \"recoverHcResiduals\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [],\n outputs: [],\n },\n {\n name: \"returnsInitiated\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"returnsInitiatedBlock\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n {\n name: \"selfManagesFees\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n { name: \"settle\", type: \"function\", stateMutability: \"nonpayable\", inputs: [], outputs: [] },\n {\n name: \"settled\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n {\n name: \"state\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint8\" }],\n },\n {\n name: \"sweepToVault\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [],\n outputs: [],\n },\n {\n name: \"tradedAssets\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [{ name: \"\", type: \"uint256\" }],\n outputs: [{ name: \"\", type: \"uint32\" }],\n },\n {\n name: \"tradesToday\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\" }],\n },\n {\n name: \"updateParams\",\n type: \"function\",\n stateMutability: \"nonpayable\",\n inputs: [{ name: \"data\", type: \"bytes\" }],\n outputs: [],\n },\n {\n name: \"vault\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\" }],\n },\n {\n name: \"FundsParked\",\n type: \"event\",\n inputs: [{ name: \"amount\", type: \"uint256\", indexed: false }],\n },\n {\n name: \"FundsSwept\",\n type: \"event\",\n inputs: [{ name: \"amount\", type: \"uint256\", indexed: false }],\n },\n {\n name: \"HyperCoreFinalized\",\n type: \"event\",\n inputs: [\n { name: \"token\", type: \"uint64\", indexed: false },\n { name: \"variant\", type: \"uint8\", indexed: false },\n { name: \"createNonce\", type: \"uint64\", indexed: false },\n ],\n },\n {\n name: \"PositionClosed\",\n type: \"event\",\n inputs: [\n { name: \"asset\", type: \"uint32\", indexed: false },\n { name: \"limitPx\", type: \"uint64\", indexed: false },\n { name: \"sz\", type: \"uint64\", indexed: false },\n ],\n },\n {\n name: \"PositionOpened\",\n type: \"event\",\n inputs: [\n { name: \"asset\", type: \"uint32\", indexed: false },\n { name: \"isBuy\", type: \"bool\", indexed: false },\n { name: \"limitPx\", type: \"uint64\", indexed: false },\n { name: \"sz\", type: \"uint64\", indexed: false },\n { name: \"leverage\", type: \"uint32\", indexed: false },\n ],\n },\n { name: \"ReturnsInitiated\", type: \"event\", inputs: [] },\n { name: \"Settled\", type: \"event\", inputs: [] },\n {\n name: \"StopLossUpdated\",\n type: \"event\",\n inputs: [{ name: \"triggerPx\", type: \"uint64\", indexed: false }],\n },\n { name: \"AccountMarginSummaryPrecompileCallFailed\", type: \"error\", inputs: [] },\n { name: \"AlreadyExecuted\", type: \"error\", inputs: [] },\n { name: \"AlreadyFinalized\", type: \"error\", inputs: [] },\n { name: \"AlreadyInitialized\", type: \"error\", inputs: [] },\n { name: \"AlreadySettled\", type: \"error\", inputs: [] },\n { name: \"DepositAmountTooLarge\", type: \"error\", inputs: [] },\n { name: \"InvalidAction\", type: \"error\", inputs: [] },\n { name: \"InvalidAmount\", type: \"error\", inputs: [] },\n { name: \"MaxTradesExceeded\", type: \"error\", inputs: [] },\n { name: \"NotAuthorized\", type: \"error\", inputs: [] },\n { name: \"NotExecuted\", type: \"error\", inputs: [] },\n { name: \"NotProposer\", type: \"error\", inputs: [] },\n { name: \"NotSweepable\", type: \"error\", inputs: [] },\n { name: \"NotVault\", type: \"error\", inputs: [] },\n { name: \"Position2PrecompileCallFailed\", type: \"error\", inputs: [] },\n {\n name: \"PositionTooLarge\",\n type: \"error\",\n inputs: [{ name: \"actual\", type: \"uint256\" }, { name: \"max\", type: \"uint256\" }],\n },\n { name: \"ReturnsNotInitiated\", type: \"error\", inputs: [] },\n {\n name: \"SafeERC20FailedOperation\",\n type: \"error\",\n inputs: [{ name: \"token\", type: \"address\" }],\n },\n { name: \"SettleTooSoon\", type: \"error\", inputs: [] },\n { name: \"SpotBalancePrecompileCallFailed\", type: \"error\", inputs: [] },\n { name: \"ZeroAddress\", type: \"error\", inputs: [] },\n] as const;\n","/**\n * HyperliquidGridStrategy call builder.\n *\n * InitParams (Solidity): (address asset, uint256 depositAmount, uint32 leverage, uint256 maxOrderSize, uint32 maxOrdersPerTick, uint32[] assetIndices)\n */\n\nimport type { Address, Hex } from \"viem\";\nimport { encodeAbiParameters, encodeFunctionData, maxUint256 } from \"viem\";\nimport { ERC20_ABI, BASE_STRATEGY_ABI } from \"../lib/abis.js\";\nimport type { BatchCall } from \"../lib/batch.js\";\n\nexport function buildInitData(\n asset: Address,\n depositAmount: bigint,\n leverage: number,\n maxOrderSize: bigint,\n maxOrdersPerTick: number,\n assetIndices: number[],\n): Hex {\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"uint32\" },\n { type: \"uint256\" },\n { type: \"uint32\" },\n { type: \"uint32[]\" },\n ],\n [asset, depositAmount, leverage, maxOrderSize, maxOrdersPerTick, assetIndices],\n );\n}\n\nexport function buildExecuteCalls(\n clone: Address,\n asset: Address,\n amount: bigint,\n): BatchCall[] {\n const approveAmount = amount === 0n ? maxUint256 : amount;\n\n return [\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, approveAmount],\n }),\n value: 0n,\n },\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"execute\",\n }),\n value: 0n,\n },\n {\n target: asset,\n data: encodeFunctionData({\n abi: ERC20_ABI,\n functionName: \"approve\",\n args: [clone, 0n],\n }),\n value: 0n,\n },\n ];\n}\n\nexport function buildSettleCalls(clone: Address): BatchCall[] {\n return [\n {\n target: clone,\n data: encodeFunctionData({\n abi: BASE_STRATEGY_ABI,\n functionName: \"settle\",\n }),\n value: 0n,\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,sBAAAA,qBAAoB,4BAA4B;;;ACCzD;AAAA,EACE;AAAA,EACA;AAAA,EACA,uBAAAC;AAAA,EACA,UAAAC;AAAA,EACA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Ac;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO,EAAE,WAAW,mBAAmB,IAAI,YAAY;AACzD;AAQO,SAAS,cAAc,WAAmB,aAA6B;AAC5E,SAAQ,YAAY,OAAO,MAAQ,WAAW,IAAK;AACrD;AAOO,SAAS,eAAe,QAAmB,MAAqB;AACrE,MAAI,OAAO,SAAS,KAAK,KAAK,WAAW,OAAO,SAAS,GAAG;AAC1D,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,SAAO,aAAa,QAAQ,IAAI;AAClC;","names":["encodeFunctionData","encodeAbiParameters","concat","encodeAbiParameters","encodeFunctionData","buildInitData","encodeAbiParameters","buildExecuteCalls","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","INIT_PARAMS_TYPES","buildInitData","encodeAbiParameters","buildExecuteCalls","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","INIT_PARAMS_TYPES","buildInitData","encodeAbiParameters","buildExecuteCalls","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","buildInitData","encodeAbiParameters","buildExecuteCalls","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","encodeAbiParameters","buildInitData","encodeAbiParameters","buildExecuteCalls","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","maxUint256","buildInitData","encodeAbiParameters","buildExecuteCalls","maxUint256","encodeFunctionData","buildSettleCalls","encodeAbiParameters","encodeFunctionData","maxUint256","buildInitData","encodeAbiParameters","buildExecuteCalls","maxUint256","encodeFunctionData","buildSettleCalls","concat","encoded","encodeAbiParameters","buildInitData","robinhoodDefaultRoute","priceDecimals","buildExecuteCalls","buildSettleCalls","ZERO","ZERO","result","encodeFunctionData"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EAS_CONTRACTS,
|
|
3
3
|
EAS_SCHEMAS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FWQESFFM.js";
|
|
5
5
|
import {
|
|
6
6
|
getAccount,
|
|
7
7
|
getPublicClient,
|
|
8
8
|
waitForReceipt,
|
|
9
9
|
writeContractWithRetry
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-D4BSBW3Q.js";
|
|
11
11
|
import {
|
|
12
12
|
CHAIN_REGISTRY,
|
|
13
13
|
getChain,
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
getNetwork,
|
|
16
16
|
isTestnet,
|
|
17
17
|
withNetwork
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-G3FUEM5N.js";
|
|
19
19
|
import {
|
|
20
20
|
EAS_ABI
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-J2IZWAEW.js";
|
|
22
22
|
|
|
23
23
|
// src/lib/eas.ts
|
|
24
24
|
import { encodeAbiParameters, parseAbiParameters, decodeAbiParameters } from "viem";
|
|
@@ -488,4 +488,4 @@ export {
|
|
|
488
488
|
queryApprovals,
|
|
489
489
|
queryJoinRequests
|
|
490
490
|
};
|
|
491
|
-
//# sourceMappingURL=chunk-
|
|
491
|
+
//# sourceMappingURL=chunk-SI65QHTY.js.map
|