@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/index.js
CHANGED
|
@@ -7712,9 +7712,7 @@ function resolveAsset(registry, chain, asset) {
|
|
|
7712
7712
|
return registry.resolveToken(chain, asset).address;
|
|
7713
7713
|
}
|
|
7714
7714
|
async function collectLendingRates(registry, chainName, rpc, assetAddr) {
|
|
7715
|
-
const protos = registry.getProtocolsForChain(chainName).filter(
|
|
7716
|
-
(p) => p.category === ProtocolCategory.Lending && (p.interface === "aave_v3" || p.interface === "aave_v3_isolated")
|
|
7717
|
-
);
|
|
7715
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7718
7716
|
const results = [];
|
|
7719
7717
|
let first = true;
|
|
7720
7718
|
for (const proto of protos) {
|
|
@@ -7802,7 +7800,7 @@ async function runYieldScan(registry, asset, output) {
|
|
|
7802
7800
|
} catch {
|
|
7803
7801
|
return [];
|
|
7804
7802
|
}
|
|
7805
|
-
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
7803
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7806
7804
|
if (protos.length === 0) return [];
|
|
7807
7805
|
const rpc = chain.effectiveRpcUrl();
|
|
7808
7806
|
const rates = [];
|
|
@@ -7885,7 +7883,7 @@ async function scanRatesForExecute(registry, asset) {
|
|
|
7885
7883
|
} catch {
|
|
7886
7884
|
return [];
|
|
7887
7885
|
}
|
|
7888
|
-
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
7886
|
+
const protos = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
7889
7887
|
if (protos.length === 0) return [];
|
|
7890
7888
|
const rpc = chain.effectiveRpcUrl();
|
|
7891
7889
|
const rates = [];
|
|
@@ -7917,7 +7915,26 @@ async function scanRatesForExecute(registry, asset) {
|
|
|
7917
7915
|
}
|
|
7918
7916
|
function registerYield(parent, getOpts, makeExecutor2) {
|
|
7919
7917
|
const yieldCmd = parent.command("yield").description("Yield operations: compare, scan, optimize, execute");
|
|
7920
|
-
yieldCmd.
|
|
7918
|
+
yieldCmd.option("--asset <token>", "Token symbol or address", "USDC").action(async (opts) => {
|
|
7919
|
+
try {
|
|
7920
|
+
const registry = Registry.loadEmbedded();
|
|
7921
|
+
const chainName = (parent.opts().chain ?? "hyperevm").toLowerCase();
|
|
7922
|
+
const chain = registry.getChain(chainName);
|
|
7923
|
+
const rpc = chain.effectiveRpcUrl();
|
|
7924
|
+
const assetAddr = resolveAsset(registry, chainName, opts.asset);
|
|
7925
|
+
const results = await collectLendingRates(registry, chainName, rpc, assetAddr);
|
|
7926
|
+
results.sort((a, b) => b.supply_apy - a.supply_apy);
|
|
7927
|
+
const bestSupply = results[0]?.protocol ?? null;
|
|
7928
|
+
const bestBorrow = results.reduce((best, r) => {
|
|
7929
|
+
if (!best || r.borrow_variable_apy < best.borrow_variable_apy) return r;
|
|
7930
|
+
return best;
|
|
7931
|
+
}, null)?.protocol ?? null;
|
|
7932
|
+
printOutput({ asset: opts.asset, chain: chainName, rates: results, best_supply: bestSupply, best_borrow: bestBorrow }, getOpts());
|
|
7933
|
+
} catch (err) {
|
|
7934
|
+
printOutput({ error: String(err) }, getOpts());
|
|
7935
|
+
}
|
|
7936
|
+
});
|
|
7937
|
+
yieldCmd.command("compare").description("Compare lending rates across protocols for an asset").option("--asset <token>", "Token symbol or address", "USDC").action(async (opts) => {
|
|
7921
7938
|
try {
|
|
7922
7939
|
const registry = Registry.loadEmbedded();
|
|
7923
7940
|
const chainName = (parent.opts().chain ?? "hyperevm").toLowerCase();
|
|
@@ -8093,7 +8110,7 @@ function registerYield(parent, getOpts, makeExecutor2) {
|
|
|
8093
8110
|
return;
|
|
8094
8111
|
}
|
|
8095
8112
|
} else {
|
|
8096
|
-
const candidates = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending
|
|
8113
|
+
const candidates = registry.getProtocolsForChain(chainName).filter((p) => p.category === ProtocolCategory.Lending);
|
|
8097
8114
|
if (candidates.length === 0) {
|
|
8098
8115
|
printOutput({ error: `No aave_v3 lending protocol found on ${chainName}` }, getOpts());
|
|
8099
8116
|
process.exit(1);
|