Skip to content

Commit

Permalink
Don't hardcode address
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasdenH committed Apr 19, 2022
1 parent 8418320 commit 59c2167
Show file tree
Hide file tree
Showing 11 changed files with 12,930 additions and 11,127 deletions.
5 changes: 5 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@ npx truffle exec .\scripts\prepare.js
# Start server
cd ./frontend
# Move new contract ABI, including deployed contract address, and generate typings.
npm run prepare
# Start the app
npm start
```
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"prepare": "cp ../build/contracts/YieldLever.json ./src/abi/ && npx abi-types-generator ./src/abi/YieldLever.json --provider=ethers_v5",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"format": "npx prettier . --write"
},
"eslintConfig": {
"extends": [
Expand Down
21 changes: 14 additions & 7 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BigNumber, ethers } from "ethers";
import { ConnectWallet } from "./components/ConnectWallet";
import erc20Abi from "./abi/ERC20.json";
import Invest from "./components/Invest";
import yieldLever from "./abi/YieldLever.json";
import poolAbi from "./abi/Pool.json";
import cauldronAbi from "./abi/Cauldron.json";
import ladleAbi from "./abi/Ladle.json";
Expand All @@ -16,16 +15,16 @@ import { ContractContext as YieldLever } from "./abi/YieldLever";
import { ContractContext as Pool } from "./abi/Pool";
import { ContractContext as Cauldron } from "./abi/Cauldron";
import { ContractContext as Ladle } from "./abi/Ladle";
import yieldLeverAbi from "./abi/YieldLever.json";

const YIELD_LEVER_CONTRACT_ADDRESS: string =
"0xe4e6A1CE0B36CcF0b920b6b57Df0f922915450Ee";
const YIELD_LEVER_CONTRACT_ADDRESS: string = yieldLeverAbi.networks[1].address;
const USDC_ADDRESS: string = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const POOL_CONTRACT: string = "0xEf82611C6120185D3BF6e020D1993B49471E7da0";
const CAULDRON_CONTRACT: string = "0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867";
const LADLE_CONTRACT: string = "0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A";

export const SERIES_ID: string = "0x303230360000";
export const ILK_ID: string = '0x303900000000';
export const ILK_ID: string = "0x303900000000";

interface State {
selectedAddress?: string;
Expand Down Expand Up @@ -187,7 +186,7 @@ export class App extends React.Component<{}, State> {
) as any,
yieldLeverContract: new ethers.Contract(
YIELD_LEVER_CONTRACT_ADDRESS,
yieldLever.abi,
yieldLeverAbi.abi,
this._provider.getSigner(0)
) as any,
poolContract: new ethers.Contract(
Expand All @@ -200,7 +199,11 @@ export class App extends React.Component<{}, State> {
cauldronAbi,
this._provider
) as any,
ladleContract: new ethers.Contract(LADLE_CONTRACT, ladleAbi, this._provider) as any,
ladleContract: new ethers.Contract(
LADLE_CONTRACT,
ladleAbi,
this._provider
) as any,
};

// if (this.state.selectedAddress !== undefined)
Expand Down Expand Up @@ -255,7 +258,11 @@ export class App extends React.Component<{}, State> {
}

private async pollData() {
if (this.contracts !== undefined && this._provider !== undefined && this.state.selectedAddress !== undefined) {
if (
this.contracts !== undefined &&
this._provider !== undefined &&
this.state.selectedAddress !== undefined
) {
const { cauldronContract } = this.contracts;
const [usdcBalance, ...vaultAndBalances] = await Promise.all([
this.contracts.usdcContract.balanceOf(this.state.selectedAddress),
Expand Down
120 changes: 60 additions & 60 deletions frontend/src/abi/Cauldron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
BytesLike as Arrayish,
BigNumber,
BigNumberish,
} from 'ethers';
import { EthersContractContextV5 } from 'ethereum-abi-types-generator';
} from "ethers";
import { EthersContractContextV5 } from "ethereum-abi-types-generator";

export type ContractContext = EthersContractContextV5<
Cauldron,
Expand Down Expand Up @@ -55,23 +55,23 @@ export interface ContractCallOverrides {
gasLimit?: number;
}
export type CauldronEvents =
| 'AssetAdded'
| 'DebtLimitsSet'
| 'IlkAdded'
| 'RateOracleAdded'
| 'RoleAdminChanged'
| 'RoleGranted'
| 'RoleRevoked'
| 'SeriesAdded'
| 'SeriesMatured'
| 'SpotOracleAdded'
| 'VaultBuilt'
| 'VaultDestroyed'
| 'VaultGiven'
| 'VaultPoured'
| 'VaultRolled'
| 'VaultStirred'
| 'VaultTweaked';
| "AssetAdded"
| "DebtLimitsSet"
| "IlkAdded"
| "RateOracleAdded"
| "RoleAdminChanged"
| "RoleGranted"
| "RoleRevoked"
| "SeriesAdded"
| "SeriesMatured"
| "SpotOracleAdded"
| "VaultBuilt"
| "VaultDestroyed"
| "VaultGiven"
| "VaultPoured"
| "VaultRolled"
| "VaultStirred"
| "VaultTweaked";
export interface CauldronEventsContext {
AssetAdded(...parameters: any): EventFilter;
DebtLimitsSet(...parameters: any): EventFilter;
Expand All @@ -92,47 +92,47 @@ export interface CauldronEventsContext {
VaultTweaked(...parameters: any): EventFilter;
}
export type CauldronMethodNames =
| 'LOCK'
| 'LOCK8605463013'
| 'ROOT'
| 'ROOT4146650865'
| 'accrual'
| 'addAsset'
| 'addIlks'
| 'addSeries'
| 'assets'
| 'balances'
| 'build'
| 'debt'
| 'debtFromBase'
| 'debtToBase'
| 'destroy'
| 'getRoleAdmin'
| 'give'
| 'grantRole'
| 'grantRoles'
| 'hasRole'
| 'ilks'
| 'lendingOracles'
| 'level'
| 'lockRole'
| 'mature'
| 'pour'
| 'ratesAtMaturity'
| 'renounceRole'
| 'revokeRole'
| 'revokeRoles'
| 'roll'
| 'series'
| 'setDebtLimits'
| 'setLendingOracle'
| 'setRoleAdmin'
| 'setSpotOracle'
| 'slurp'
| 'spotOracles'
| 'stir'
| 'tweak'
| 'vaults';
| "LOCK"
| "LOCK8605463013"
| "ROOT"
| "ROOT4146650865"
| "accrual"
| "addAsset"
| "addIlks"
| "addSeries"
| "assets"
| "balances"
| "build"
| "debt"
| "debtFromBase"
| "debtToBase"
| "destroy"
| "getRoleAdmin"
| "give"
| "grantRole"
| "grantRoles"
| "hasRole"
| "ilks"
| "lendingOracles"
| "level"
| "lockRole"
| "mature"
| "pour"
| "ratesAtMaturity"
| "renounceRole"
| "revokeRole"
| "revokeRoles"
| "roll"
| "series"
| "setDebtLimits"
| "setLendingOracle"
| "setRoleAdmin"
| "setSpotOracle"
| "slurp"
| "spotOracles"
| "stir"
| "tweak"
| "vaults";
export interface AssetAddedEventEmittedResponse {
assetId: Arrayish;
asset: string;
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/abi/ERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
BytesLike as Arrayish,
BigNumber,
BigNumberish,
} from 'ethers';
import { EthersContractContextV5 } from 'ethereum-abi-types-generator';
} from "ethers";
import { EthersContractContextV5 } from "ethereum-abi-types-generator";

export type ContractContext = EthersContractContextV5<
ERC20,
Expand Down Expand Up @@ -54,21 +54,21 @@ export interface ContractCallOverrides {
*/
gasLimit?: number;
}
export type ERC20Events = 'Approval' | 'Transfer';
export type ERC20Events = "Approval" | "Transfer";
export interface ERC20EventsContext {
Approval(...parameters: any): EventFilter;
Transfer(...parameters: any): EventFilter;
}
export type ERC20MethodNames =
| 'name'
| 'approve'
| 'totalSupply'
| 'transferFrom'
| 'decimals'
| 'balanceOf'
| 'symbol'
| 'transfer'
| 'allowance';
| "name"
| "approve"
| "totalSupply"
| "transferFrom"
| "decimals"
| "balanceOf"
| "symbol"
| "transfer"
| "allowance";
export interface ApprovalEventEmittedResponse {
owner: string;
spender: string;
Expand Down
Loading

0 comments on commit 59c2167

Please sign in to comment.