Skip to content

Commit

Permalink
Use the 'bridged' raw vault field
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Oct 24, 2023
1 parent a9a98ae commit fa0f45c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"abstract-cache-redis": "^2.0.0",
"async-lock": "^1.4.0",
"axios": "^1.3.4",
"blockchain-addressbook": "^0.44.23",
"blockchain-addressbook": "^0.44.29",
"decimal.js": "^10.4.3",
"dotenv": "^16.0.3",
"ethereum-multicall": "^2.16.1",
Expand Down
23 changes: 12 additions & 11 deletions src/protocol/beefy/connector/vault-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cloneDeep } from "lodash";
import * as path from "path";
import prettier from "prettier";
import * as Rx from "rxjs";
import { Chain, allChainIds } from "../../../types/chain";
import { getBridgedMooBifiTokenAddress, getChainWNativeTokenAddress } from "../../../utils/addressbook";
import { Chain } from "../../../types/chain";
import { getChainWNativeTokenAddress } from "../../../utils/addressbook";
import { GITHUB_RO_AUTH_TOKEN, GIT_WORK_DIRECTORY } from "../../../utils/config";
import { normalizeAddressOrThrow } from "../../../utils/ethers";
import { rootLogger } from "../../../utils/logger";
Expand All @@ -24,6 +24,7 @@ interface RawBeefyVault {
oracleId: string;
status?: string;
assets?: string[];
bridged?: Record<Chain, string>; // { "optimism": "0xc55E93C62874D8100dBd2DfE307EDc1036ad5434" },
}

interface BeefyBaseVaultConfig {
Expand Down Expand Up @@ -224,14 +225,12 @@ export function beefyVaultsFromGitHistory$(chain: Chain): Rx.Observable<BeefyVau
}),

// just emit the vault
Rx.map(({ vault, eolDate }) => rawVaultToBeefyVault(chain, vault, eolDate)),
Rx.map(({ vault, eolDate }) => ({ vault: rawVaultToBeefyVault(chain, vault, eolDate), rawVault: vault })),
),

// add the bridged moo bifi vault
Rx.map((vault) => {
// our only bridged vault is mooBifi on eth
// TODO: update this when we go live
if (vault.id !== "ethereum-bifi-maxi") {
// add a virtual product of the bridged version of the vault
Rx.map(({ vault, rawVault }) => {
if (!rawVault.bridged) {
return [vault];
}

Expand All @@ -246,8 +245,10 @@ export function beefyVaultsFromGitHistory$(chain: Chain): Rx.Observable<BeefyVau
vault.eol = false;
vault.eol_date = null;

const bridgedVaults = allChainIds
.map((chain) => ({ chain, address: getBridgedMooBifiTokenAddress(chain) }))
type K = keyof Required<RawBeefyVault>["bridged"];
type V = Required<RawBeefyVault>["bridged"][K];
const bridgedVaults = (Object.entries(rawVault.bridged) as [K, V][])
.map(([chain, address]) => ({ chain, address }))
.filter((p): p is { chain: Chain; address: string } => p.address !== null)
.map(({ chain, address }): BeefyBridgedVersionOfStdVault => {
const bridgedMooBifiVault: BeefyBridgedVersionOfStdVault = {
Expand Down Expand Up @@ -287,7 +288,7 @@ function rawVaultToBeefyVault(chain: Chain, rawVault: RawBeefyVault, eolDate: Da
} else if (rawVault.oracleId.startsWith("be")) {
protocol = "beefy";
protocol_product = rawVault.oracleId;
} else if (rawVault.oracleId === "BIFI") {
} else if (rawVault.oracleId === "BIFI" || rawVault.oracleId === "oldBIFI") {
protocol = "beefy";
protocol_product = rawVault.oracleId;
} else {
Expand Down
8 changes: 0 additions & 8 deletions src/utils/addressbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ import * as addressbook from "blockchain-addressbook";
import { Chain } from "../types/chain";
import { normalizeAddressOrThrow } from "./ethers";

export function getBridgedMooBifiTokenAddress(chain: Chain): string | null {
// @todo: pull from the addressbook when live
if (chain === "optimism") {
return "0xc55E93C62874D8100dBd2DfE307EDc1036ad5434";
} else {
return null;
}
}
export function getBridgedVaultTargetChains(): Chain[] {
return ["optimism"];
}
Expand Down

0 comments on commit fa0f45c

Please sign in to comment.