@hypurrquant/defi-cli 0.3.1 → 0.3.2
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 +24 -7
- package/dist/index.js.map +1 -1
- package/dist/main.js +24 -7
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -7716,9 +7716,7 @@ function resolveAsset(registry, chain, asset) {
|
|
|
7716
7716
|
return registry.resolveToken(chain, asset).address;
|
|
7717
7717
|
}
|
|
7718
7718
|
async function collectLendingRates(registry, chainName, rpc, assetAddr) {
|
|
7719
|
-
const protos = registry.getProtocolsForChain(chainName).filter(
|
|
7720
|
-
(p) => p.category === ProtocolCategory.Lending && (p.interface === "aave_v3" || p.interface === "aave_v3_isolated")
|
|
7721
|
-
);
|
|
7719
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7722
7720
|
const results = [];
|
|
7723
7721
|
let first = true;
|
|
7724
7722
|
for (const proto of protos) {
|
|
@@ -7806,7 +7804,7 @@ async function runYieldScan(registry, asset, output) {
|
|
|
7806
7804
|
} catch {
|
|
7807
7805
|
return [];
|
|
7808
7806
|
}
|
|
7809
|
-
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
7807
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7810
7808
|
if (protos.length === 0) return [];
|
|
7811
7809
|
const rpc = chain.effectiveRpcUrl();
|
|
7812
7810
|
const rates = [];
|
|
@@ -7889,7 +7887,7 @@ async function scanRatesForExecute(registry, asset) {
|
|
|
7889
7887
|
} catch {
|
|
7890
7888
|
return [];
|
|
7891
7889
|
}
|
|
7892
|
-
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
7890
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7893
7891
|
if (protos.length === 0) return [];
|
|
7894
7892
|
const rpc = chain.effectiveRpcUrl();
|
|
7895
7893
|
const rates = [];
|
|
@@ -7921,7 +7919,26 @@ async function scanRatesForExecute(registry, asset) {
|
|
|
7921
7919
|
}
|
|
7922
7920
|
function registerYield(parent, getOpts, makeExecutor2) {
|
|
7923
7921
|
const yieldCmd = parent.command("yield").description("Yield operations: compare, scan, optimize, execute");
|
|
7924
|
-
yieldCmd.
|
|
7922
|
+
yieldCmd.option("--asset <token>", "Token symbol or address", "USDC").action(async (opts) => {
|
|
7923
|
+
try {
|
|
7924
|
+
const registry = Registry.loadEmbedded();
|
|
7925
|
+
const chainName = (parent.opts().chain ?? "hyperevm").toLowerCase();
|
|
7926
|
+
const chain = registry.getChain(chainName);
|
|
7927
|
+
const rpc = chain.effectiveRpcUrl();
|
|
7928
|
+
const assetAddr = resolveAsset(registry, chainName, opts.asset);
|
|
7929
|
+
const results = await collectLendingRates(registry, chainName, rpc, assetAddr);
|
|
7930
|
+
results.sort((a, b) => b.supply_apy - a.supply_apy);
|
|
7931
|
+
const bestSupply = results[0]?.protocol ?? null;
|
|
7932
|
+
const bestBorrow = results.reduce((best, r) => {
|
|
7933
|
+
if (!best || r.borrow_variable_apy < best.borrow_variable_apy) return r;
|
|
7934
|
+
return best;
|
|
7935
|
+
}, null)?.protocol ?? null;
|
|
7936
|
+
printOutput({ asset: opts.asset, chain: chainName, rates: results, best_supply: bestSupply, best_borrow: bestBorrow }, getOpts());
|
|
7937
|
+
} catch (err) {
|
|
7938
|
+
printOutput({ error: String(err) }, getOpts());
|
|
7939
|
+
}
|
|
7940
|
+
});
|
|
7941
|
+
yieldCmd.command("compare").description("Compare lending rates across protocols for an asset").option("--asset <token>", "Token symbol or address", "USDC").action(async (opts) => {
|
|
7925
7942
|
try {
|
|
7926
7943
|
const registry = Registry.loadEmbedded();
|
|
7927
7944
|
const chainName = (parent.opts().chain ?? "hyperevm").toLowerCase();
|
|
@@ -8097,7 +8114,7 @@ function registerYield(parent, getOpts, makeExecutor2) {
|
|
|
8097
8114
|
return;
|
|
8098
8115
|
}
|
|
8099
8116
|
} else {
|
|
8100
|
-
const candidates = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
8117
|
+
const candidates = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
8101
8118
|
if (candidates.length === 0) {
|
|
8102
8119
|
printOutput({ error: `No aave_v3 lending protocol found on ${chainName}` }, getOpts());
|
|
8103
8120
|
process.exit(1);
|