diff --git a/examples/common.mjs b/examples/common.mjs new file mode 100644 index 00000000..dcbe71bd --- /dev/null +++ b/examples/common.mjs @@ -0,0 +1,9 @@ +export const YearnGovernance = "0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52"; +export const Addresses = !process.env.WEB3_PROVIDER && { + adapters: { + registryV2: "0xFbD588c72B438faD4Cf7cD879c8F730Faa213Da0", + ironBank: "0xed00238F9A0F7b4d93842033cdF56cCB32C781c2" + }, + helper: "0x420b1099B9eF5baba6D92029594eF45E19A04A4A", + oracle: "0xE7eD6747FaC5360f88a2EFC03E00d25789F69291" +}; diff --git a/examples/ironbank.mjs b/examples/ironbank.mjs new file mode 100644 index 00000000..f1529c01 --- /dev/null +++ b/examples/ironbank.mjs @@ -0,0 +1,40 @@ +import Table from "cli-table3"; + +import { JsonRpcProvider } from "@ethersproject/providers"; +import { YearnGovernance, Addresses } from "./common.mjs"; + +import { Yearn } from "../dist/index.js"; + +const url = process.env.WEB3_PROVIDER || "http://localhost:8545"; +const provider = new JsonRpcProvider(url); + +const yearn = new Yearn(1, { + provider, + addresses: Addresses +}); + +async function main() { + const ironBank = await yearn.ironBank.get(); + + const ironBankTable = new Table(); + ironBankTable.push(...ironBank.map(market => [market.name, market.address, market.typeId])); + + console.log("IronBank markets:"); + console.log(ironBankTable.toString()); + + const ironBankGeneralPositionTable = new Table(); + const ironBankGeneralPosition = await yearn.ironBank.generalPositionOf(YearnGovernance); + + ironBankGeneralPositionTable.push(...Object.entries(ironBankGeneralPosition)); + console.log("Yearn Multisig general IronBank position:"); + console.log(ironBankGeneralPositionTable.toString()); + + const ironBankUserMetadataTable = new Table(); + const ironBankUserMetadata = await yearn.ironBank.userMetadata(YearnGovernance); + + ironBankUserMetadataTable.push(...ironBankUserMetadata.map(market => Object.values(market))); + console.log("Yearn Multisig IronBank user metadata:"); + console.log(ironBankUserMetadataTable.toString()); +} + +main(); diff --git a/examples/mvp.js b/examples/mvp.js deleted file mode 100644 index 82b7ce20..00000000 --- a/examples/mvp.js +++ /dev/null @@ -1,95 +0,0 @@ -const Table = require("cli-table3"); - -const { JsonRpcProvider } = require("@ethersproject/providers"); - -const { Yearn } = require("../dist"); - -const url = process.env.WEB3_PROVIDER || "http://localhost:8545"; -const provider = new JsonRpcProvider(url); - -const yearn = new Yearn(1, { - provider, - addresses: { - adapters: { - registryV2: "0xFbD588c72B438faD4Cf7cD879c8F730Faa213Da0", - ironBank: "0xed00238F9A0F7b4d93842033cdF56cCB32C781c2" - }, - helper: "0x420b1099B9eF5baba6D92029594eF45E19A04A4A", - oracle: "0xE7eD6747FaC5360f88a2EFC03E00d25789F69291" - } -}); - -async function main() { - const gov = "0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52"; - - // VAULTS V1 & V2 - const vaults = await yearn.vaults.get(); - - const vaultsTable = new Table(); - vaultsTable.push(...vaults.map(vault => [vault.name, vault.address, vault.typeId])); - - console.log("V1 & V2 vaults:"); - console.log(vaultsTable.toString()); - - const positions = await yearn.vaults.positionsOf(gov); - - const positionsTable = new Table(); - positionsTable.push( - ...positions.map(position => { - const vault = vaults.find(vault => (vault.address = position.assetAddress)); - return [vault.name, position.balance]; - }) - ); - - console.log("Yearn Multisig vault positions:"); - console.log(positionsTable.toString()); - - // Get token balances for common coins in ETH mainnet - const vaultBalances = await yearn.vaults.balances(gov); - - const vaultBalancesTable = new Table(); - vaultBalancesTable.push(...vaultBalances.map(balance => [balance.token.name, balance.balance, balance.balanceUsdc])); - - console.log("Yearn Multisig underlying vault tokens balances:"); - console.log(vaultBalancesTable.toString()); - - // IRON BANK - const ironBank = await yearn.ironBank.get(); - - const ironBankTable = new Table(); - ironBankTable.push(...ironBank.map(market => [market.name, market.address, market.typeId])); - - console.log("IronBank markets:"); - console.log(ironBankTable.toString()); - - const ironBankGeneralPositionTable = new Table(); - const ironBankGeneralPosition = await yearn.ironBank.generalPositionOf(gov); - - ironBankGeneralPositionTable.push(...Object.entries(ironBankGeneralPosition)); - console.log("Yearn Multisig general IronBank position:"); - console.log(ironBankGeneralPositionTable.toString()); - - const ironBankUserMetadataTable = new Table(); - const ironBankUserMetadata = await yearn.ironBank.userMetadata(gov); - - ironBankUserMetadataTable.push(...ironBankUserMetadata.map(market => Object.values(market))); - console.log("Yearn Multisig IronBank user metadata:"); - console.log(ironBankUserMetadataTable.toString()); - - // ONLY ETH - - // Get all tokens supported by zapper - const supported = await yearn.tokens.supported(); - console.log("SDK supported tokens:", supported.length); - - // Get token balances for common coins in ETH mainnet - const balances = await yearn.tokens.balances(gov); - - const balancesTable = new Table(); - balancesTable.push(...balances.map(balance => [balance.token.name, balance.balance, balance.balanceUsdc])); - - console.log("Yearn Multisig token balances:"); - console.log(balancesTable.toString()); -} - -main(); diff --git a/examples/token.mjs b/examples/token.mjs new file mode 100644 index 00000000..aaed5a64 --- /dev/null +++ b/examples/token.mjs @@ -0,0 +1,31 @@ +import Table from "cli-table3"; + +import { JsonRpcProvider } from "@ethersproject/providers"; +import { YearnGovernance, Addresses } from "./common.mjs"; + +import { Yearn } from "../dist/index.js"; + +const url = process.env.WEB3_PROVIDER || "http://localhost:8545"; +const provider = new JsonRpcProvider(url); + +const yearn = new Yearn(1, { + provider, + addresses: Addresses +}); + +async function main() { + // Get all tokens supported by zapper + const supported = await yearn.tokens.supported(); + console.log("Zapper supported tokens:", supported.length); + + // Get token balances for common coins in ETH mainnet + const balances = await yearn.tokens.balances(YearnGovernance); + + const balancesTable = new Table(); + balancesTable.push(...balances.map(balance => [balance.token.name, balance.balance, balance.balanceUsdc])); + + console.log("Yearn Multisig token balances:"); + console.log(balancesTable.toString()); +} + +main(); diff --git a/examples/vault.mjs b/examples/vault.mjs new file mode 100644 index 00000000..7692dd47 --- /dev/null +++ b/examples/vault.mjs @@ -0,0 +1,39 @@ +import Table from "cli-table3"; + +import { JsonRpcProvider } from "@ethersproject/providers"; +import { YearnGovernance, Addresses } from "./common.mjs"; + +import { Yearn } from "../dist/index.js"; + +const url = process.env.WEB3_PROVIDER || "http://localhost:8545"; +const provider = new JsonRpcProvider(url); + +const yearn = new Yearn(1, { + provider, + addresses: Addresses +}); + +async function main() { + const vaults = await yearn.vaults.get(); + + const vaultsTable = new Table(); + vaultsTable.push(...vaults.map(vault => [vault.name, vault.address, vault.typeId])); + + console.log("V1 & V2 vaults:"); + console.log(vaultsTable.toString()); + + const positions = await yearn.vaults.positionsOf(YearnGovernance); + + const positionsTable = new Table(); + positionsTable.push( + ...positions.map(position => { + const vault = vaults.find(vault => (vault.address = position.assetAddress)); + return [vault.name, position.balance]; + }) + ); + + console.log("Yearn Multisig vault positions:"); + console.log(positionsTable.toString()); +} + +main(); diff --git a/src/services/adapters/ironbank.ts b/src/services/adapters/ironbank.ts index 18e9ee1b..626b538c 100644 --- a/src/services/adapters/ironbank.ts +++ b/src/services/adapters/ironbank.ts @@ -57,9 +57,9 @@ export class IronBankAdapter extends ContractService { switch (chainId) { case 1: case 1337: - return "0x21670dDB429B6D80B5bE4e65532576bB14b7cC62"; + return "0xFF0bd2d0C7E9424ccB149ED3757155eEf41a793D"; case 250: // FIXME: doesn't actually exist - return "0x21670dDB429B6D80B5bE4e65532576bB14b7cC62"; + return "0xFF0bd2d0C7E9424ccB149ED3757155eEf41a793D"; } } diff --git a/src/services/adapters/registry.ts b/src/services/adapters/registry.ts index 5702a9be..fd12b2ad 100644 --- a/src/services/adapters/registry.ts +++ b/src/services/adapters/registry.ts @@ -32,9 +32,9 @@ export class RegistryV2Adapter extends ContractService implem switch (chainId) { case 1: case 1337: - return "0xE75E51566C5761896528B4698a88C92A54B3C954"; + return "0x240315db938d44bb124ae619f5fd0269a02d1271"; case 250: // FIXME: doesn't actually exist - return "0xE75E51566C5761896528B4698a88C92A54B3C954"; + return "0x240315db938d44bb124ae619f5fd0269a02d1271"; } } diff --git a/src/services/helper.ts b/src/services/helper.ts index 1b65e7d5..6f107bbe 100644 --- a/src/services/helper.ts +++ b/src/services/helper.ts @@ -22,10 +22,10 @@ export class HelperService extends ContractService { static addressByChain(chainId: ChainId): string { switch (chainId) { - case 1: // FIXME: doesn't actually exist - case 250: // ditto - case 1337: // ditto - return "0x420b1099B9eF5baba6D92029594eF45E19A04A4A"; + case 1: + case 1337: + case 250: // FIXME: doesn't actually exist + return "0x5AACD0D03096039aC4381CD814637e9FB7C34a6f"; } }