@sherwoodagent/cli 0.18.2 → 0.18.3
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/index.js +64 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -720,7 +720,10 @@ function registerStrategyTemplateCommands(strategy2) {
|
|
|
720
720
|
functionName: "initialize",
|
|
721
721
|
args: [vault, account.address, initData]
|
|
722
722
|
});
|
|
723
|
-
await getPublicClient().waitForTransactionReceipt({ hash: initHash });
|
|
723
|
+
const receipt = await getPublicClient().waitForTransactionReceipt({ hash: initHash });
|
|
724
|
+
if (receipt.status === "reverted") {
|
|
725
|
+
throw new Error("Initialize transaction reverted on-chain");
|
|
726
|
+
}
|
|
724
727
|
initSpinner.succeed("Initialized");
|
|
725
728
|
} catch (err) {
|
|
726
729
|
initSpinner.fail("Initialize failed");
|
|
@@ -732,6 +735,62 @@ function registerStrategyTemplateCommands(strategy2) {
|
|
|
732
735
|
console.log(chalk.dim("Use this address in your proposal batch calls."));
|
|
733
736
|
console.log();
|
|
734
737
|
});
|
|
738
|
+
strategy2.command("init").description("Initialize an already-deployed but uninitialized strategy clone").argument("<template>", "Template: moonwell-supply, aerodrome-lp, venice-inference, wsteth-moonwell").requiredOption("--clone <address>", "Clone address to initialize").requiredOption("--vault <address>", "Vault address").option("--amount <n>", "Asset amount to deploy").option("--min-redeem <n>", "Min asset on settlement (Moonwell)").option("--token <symbol>", "Asset token symbol (default: USDC)").option("--asset <symbol>", "Asset token (USDC, VVV, or address)").option("--agent <address>", "Agent wallet (Venice, default: your wallet)").option("--min-vvv <n>", "Min VVV from swap (Venice)").option("--single-hop", "Single-hop Aerodrome swap (Venice)").option("--token-a <address>", "Token A (Aerodrome)").option("--token-b <address>", "Token B (Aerodrome)").option("--amount-a <n>", "Token A amount (Aerodrome)").option("--amount-b <n>", "Token B amount (Aerodrome)").option("--stable", "Stable pool (Aerodrome)").option("--gauge <address>", "Gauge address (Aerodrome)").option("--lp-token <address>", "LP token address (Aerodrome)").option("--min-a-out <n>", "Min token A on settle (Aerodrome)").option("--min-b-out <n>", "Min token B on settle (Aerodrome)").option("--slippage <bps>", "Slippage tolerance in bps (wstETH, default: 500 = 5%)").action(async (templateKey, opts) => {
|
|
739
|
+
const clone = opts.clone;
|
|
740
|
+
const vault = opts.vault;
|
|
741
|
+
if (!isAddress(clone)) {
|
|
742
|
+
console.error(chalk.red("Invalid clone address"));
|
|
743
|
+
process.exit(1);
|
|
744
|
+
}
|
|
745
|
+
if (!isAddress(vault)) {
|
|
746
|
+
console.error(chalk.red("Invalid vault address"));
|
|
747
|
+
process.exit(1);
|
|
748
|
+
}
|
|
749
|
+
resolveTemplate(templateKey);
|
|
750
|
+
const publicClient = getPublicClient();
|
|
751
|
+
const currentVault = await publicClient.readContract({
|
|
752
|
+
address: clone,
|
|
753
|
+
abi: BASE_STRATEGY_ABI,
|
|
754
|
+
functionName: "vault"
|
|
755
|
+
});
|
|
756
|
+
if (currentVault !== "0x0000000000000000000000000000000000000000") {
|
|
757
|
+
console.error(chalk.red(`Clone already initialized (vault: ${currentVault})`));
|
|
758
|
+
process.exit(1);
|
|
759
|
+
}
|
|
760
|
+
const initSpinner = ora("Initializing strategy clone...").start();
|
|
761
|
+
try {
|
|
762
|
+
const { initData } = await buildInitDataForTemplate(templateKey, opts, vault);
|
|
763
|
+
const account = getAccount();
|
|
764
|
+
const initHash = await writeContractWithRetry({
|
|
765
|
+
account,
|
|
766
|
+
chain: getChain(),
|
|
767
|
+
address: clone,
|
|
768
|
+
abi: BASE_STRATEGY_ABI,
|
|
769
|
+
functionName: "initialize",
|
|
770
|
+
args: [vault, account.address, initData]
|
|
771
|
+
});
|
|
772
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: initHash });
|
|
773
|
+
if (receipt.status === "reverted") {
|
|
774
|
+
throw new Error("Initialize transaction reverted on-chain");
|
|
775
|
+
}
|
|
776
|
+
initSpinner.succeed("Initialized");
|
|
777
|
+
console.log(chalk.dim(` Tx: ${getExplorerUrl(initHash)}`));
|
|
778
|
+
} catch (err) {
|
|
779
|
+
initSpinner.fail("Initialize failed");
|
|
780
|
+
console.error(chalk.red(err instanceof Error ? err.message : String(err)));
|
|
781
|
+
process.exit(1);
|
|
782
|
+
}
|
|
783
|
+
const verifiedVault = await publicClient.readContract({
|
|
784
|
+
address: clone,
|
|
785
|
+
abi: BASE_STRATEGY_ABI,
|
|
786
|
+
functionName: "vault"
|
|
787
|
+
});
|
|
788
|
+
console.log();
|
|
789
|
+
console.log(chalk.bold("Clone initialized:"), chalk.green(clone));
|
|
790
|
+
console.log(` Vault: ${chalk.green(verifiedVault)}`);
|
|
791
|
+
console.log(` Proposer: ${chalk.green(getAccount().address)}`);
|
|
792
|
+
console.log();
|
|
793
|
+
});
|
|
735
794
|
strategy2.command("propose").description("Clone + init + build calls + submit governance proposal (all-in-one)").argument("<template>", "Template: moonwell-supply, aerodrome-lp, venice-inference, wsteth-moonwell").requiredOption("--vault <address>", "Vault address").option("--write-calls <dir>", "Write execute/settle JSON to directory (skip proposal submission)").option("--name <name>", "Proposal name").option("--description <text>", "Proposal description").option("--performance-fee <bps>", "Agent fee in bps").option("--duration <duration>", "Strategy duration (7d, 24h, etc.)").option("--amount <n>", "Asset amount to deploy").option("--min-redeem <n>", "Min asset on settlement (Moonwell)").option("--token <symbol>", "Asset token symbol (default: USDC)").option("--asset <symbol>", "Asset token (USDC, VVV, or address)").option("--agent <address>", "Agent wallet (Venice, default: your wallet)").option("--min-vvv <n>", "Min VVV from swap (Venice)").option("--single-hop", "Single-hop Aerodrome swap (Venice)").option("--token-a <address>", "Token A (Aerodrome)").option("--token-b <address>", "Token B (Aerodrome)").option("--amount-a <n>", "Token A amount (Aerodrome)").option("--amount-b <n>", "Token B amount (Aerodrome)").option("--stable", "Stable pool (Aerodrome)").option("--gauge <address>", "Gauge address (Aerodrome)").option("--lp-token <address>", "LP token address (Aerodrome)").option("--min-a-out <n>", "Min token A on settle (Aerodrome)").option("--min-b-out <n>", "Min token B on settle (Aerodrome)").option("--slippage <bps>", "Slippage tolerance in bps (wstETH, default: 500 = 5%)").action(async (templateKey, opts) => {
|
|
736
795
|
const vault = opts.vault;
|
|
737
796
|
if (!isAddress(vault)) {
|
|
@@ -769,7 +828,10 @@ function registerStrategyTemplateCommands(strategy2) {
|
|
|
769
828
|
functionName: "initialize",
|
|
770
829
|
args: [vault, account2.address, built.initData]
|
|
771
830
|
});
|
|
772
|
-
await getPublicClient().waitForTransactionReceipt({ hash: initHash });
|
|
831
|
+
const initReceipt = await getPublicClient().waitForTransactionReceipt({ hash: initHash });
|
|
832
|
+
if (initReceipt.status === "reverted") {
|
|
833
|
+
throw new Error("Initialize transaction reverted on-chain");
|
|
834
|
+
}
|
|
773
835
|
initSpinner.succeed("Initialized");
|
|
774
836
|
} catch (err) {
|
|
775
837
|
initSpinner.fail("Initialize failed");
|