Skip to content
14 changes: 12 additions & 2 deletions contracts/scripts/defender-actions/ousdRebalancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ const buildDiscordMessage = ({
a.withdrawableLiquidity != null
? formatUSDC(a.withdrawableLiquidity)
: " n/a ";
const apyStr = a.graphqlApy
? `${(a.apy * 100).toFixed(2)}% APY (API: ${(a.graphqlApy * 100).toFixed(
2
)}%)`
: `${(a.apy * 100).toFixed(2)}% APY`;
return ` ${a.name.padEnd(20)} ${formatUSDC(a.balance).padStart(
9
)} ${avail.padStart(9)} ${(a.apy * 100).toFixed(2)}% APY`;
)} ${avail.padStart(9)} ${apyStr}`;
});
currentLines.push(
` ${"Vault idle".padEnd(20)} ${formatUSDC(state.vaultBalance).padStart(9)}`
Expand Down Expand Up @@ -137,7 +142,12 @@ const handler = async (event) => {

const webhookUrl = event.secrets?.DISCORD_WEBHOOK_URL;

// Build chain providers for cross-chain APY reads
// Configure subsquid endpoint for APY reads
process.env.ORIGIN_SUBSQUID_SERVER =
event.secrets?.ORIGIN_SUBSQUID_SERVER ||
"https://origin.squids.live/origin-squid:prod/api/graphql";

// Build chain providers for on-chain reads (balances, max withdrawals)
const providers = { 1: provider };
if (event.secrets.BASE_PROVIDER_URL) {
providers[8453] = new ethers.providers.JsonRpcProvider(
Expand Down
17 changes: 17 additions & 0 deletions contracts/test/rebalancer/rebalancer.base.fork-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { expect } = require("chai");

const { fetchMorphoApys } = require("../../utils/morpho-apy");
const addresses = require("../../utils/addresses");

describe("ForkTest: Rebalancer APY — Base", function () {
it("should return non-zero APY for Base MetaMorpho V1 vault", async () => {
const { apys } = await fetchMorphoApys([
{
metaMorphoVaultAddress: addresses.base.MorphoOusdV1Vault,
morphoChainId: 8453,
},
]);
const apy = apys[addresses.base.MorphoOusdV1Vault];
expect(apy).to.be.gt(0, `Expected APY > 0, got ${(apy * 100).toFixed(4)}%`);
});
});
17 changes: 17 additions & 0 deletions contracts/test/rebalancer/rebalancer.hyperevm.fork-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { expect } = require("chai");

const { fetchMorphoApys } = require("../../utils/morpho-apy");
const addresses = require("../../utils/addresses");

describe("ForkTest: Rebalancer APY — HyperEVM", function () {
it("should return non-zero APY for HyperEVM MetaMorpho V1 vault", async () => {
const { apys } = await fetchMorphoApys([
{
metaMorphoVaultAddress: addresses.hyperevm.MorphoOusdV1Vault,
morphoChainId: 999,
},
]);
const apy = apys[addresses.hyperevm.MorphoOusdV1Vault];
expect(apy).to.be.gt(0, `Expected APY > 0, got ${(apy * 100).toFixed(4)}%`);
});
});
Loading
Loading