Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 81c20a8

Browse files
committed
feat: full viem
1 parent fa81658 commit 81c20a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4551
-479
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ deployments/kovan/
1313
contracts.iml
1414
node_modules/
1515
ionic-contracts.iml
16+
cache_hardhat

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"arcanis.vscode-zipfs",
4+
"esbenp.prettier-vscode"
5+
]
6+
}

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
33
"editor.formatOnSave": true,
44
"editor.tabSize": 2,
5-
"typescript.tsdk": "node_modules/typescript/lib",
5+
"typescript.tsdk": ".yarn/sdks/typescript/lib",
66
"[typescript]": {
77
"editor.defaultFormatter": "esbenp.prettier-vscode"
88
},
99
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
10-
"solidity.packageDefaultDependenciesDirectory": "lib"
10+
"solidity.packageDefaultDependenciesDirectory": "lib",
11+
"search.exclude": {
12+
"**/.yarn": true,
13+
"**/.pnp.*": true
14+
},
15+
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
16+
"typescript.enablePromptUseWorkspaceTsdk": true
1117
}

chainDeploy/helpers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export { deployIRMs } from "./irms";
33
export { deployChainlinkOracle } from "./oracles/chainlink";
44
export { deployFlywheelWithDynamicRewards } from "./dynamicFlywheels";
55
export { deployErc4626PriceOracle } from "./oracles/erc4626";
6-
export { configureBalancerSwap } from "./liquidators/ionicLiquidator";
6+
export { deployPythPriceOracle } from "./oracles/pyth";

chainDeploy/helpers/liquidators/ionicLiquidator.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const deployIonicLiquidator = async ({
1818
const { deployer, multisig } = await getNamedAccounts();
1919
const publicClient = await viem.getPublicClient();
2020

21-
const initializeArgs = [
21+
const initializeArgs: [Address, Address, number] = [
2222
deployConfig.wtoken,
2323
deployConfig.uniswap.uniswapV2RouterAddress,
2424
deployConfig.uniswap.flashSwapFee
@@ -107,11 +107,9 @@ export const deployIonicUniV3Liquidator = async ({
107107
export const configureIonicLiquidator = async ({
108108
contractName,
109109
viem,
110-
getNamedAccounts,
111110
chainId,
112111
deployments
113112
}: LiquidatorConfigFnParams): Promise<void> => {
114-
const { deployer } = await getNamedAccounts();
115113
const publicClient = await viem.getPublicClient();
116114

117115
const strategies: string[] = [];
@@ -124,7 +122,7 @@ export const configureIonicLiquidator = async ({
124122
for (const redemptionStrategyConfig of chainIdToConfig[chainId].redemptionStrategies) {
125123
const { strategy } = redemptionStrategyConfig;
126124
const redemptionStrategyContract = await viem.getContractAt(
127-
strategy,
125+
strategy as string,
128126
(await deployments.get(strategy)).address as Address
129127
);
130128

chainDeploy/helpers/oracles/chainlink.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const deployChainlinkOracle = async ({
162162
"MasterPriceOracle",
163163
(await deployments.get("MasterPriceOracle")).address as Address
164164
);
165-
await addUnderlyingsToMpo(mpo, underlyings, chainLinkv2.address, deployer);
165+
await addUnderlyingsToMpo(mpo as any, underlyings, chainLinkv2.address, deployer, publicClient, walletClient);
166166

167167
const addressesProvider = await viem.getContractAt(
168168
"AddressesProvider",
@@ -181,7 +181,7 @@ export const deployChainlinkOracle = async ({
181181
data: encodeFunctionData({
182182
abi: addressesProvider.abi,
183183
functionName: "setAddress",
184-
args: [chainLinkv2.address]
184+
args: ["ChainlinkPriceOracleV2", chainLinkv2.address]
185185
})
186186
});
187187
addTransaction({

chainDeploy/helpers/oracles/redstoneWeETHFallbacks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Address } from "viem";
33
import { addUnderlyingsToMpoFallback } from "./utils";
44
import { RedStoneDeployFnParams } from "../../../chains/types";
55

6-
export const addRedstoneFallbacks = async ({
6+
export const addRedstoneWeETHFallbacks = async ({
77
viem,
88
getNamedAccounts,
99
deployments,

chainDeploy/helpers/oracles/redstoneWrsETH.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RedStoneDeployFnParams } from "../../../chains/types";
33
import { addUnderlyingsToMpo } from "./utils";
44
import { Address } from "viem";
55

6-
export const deployRedStonePriceOracle = async ({
6+
export const deployRedStoneWrsETHPriceOracle = async ({
77
viem,
88
getNamedAccounts,
99
deployments,

chainDeploy/helpers/oracles/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Address, encodeFunctionData, GetContractReturnType, PublicClient, WalletClient, zeroAddress } from "viem";
1+
import { Address, encodeFunctionData, PublicClient, WalletClient, zeroAddress } from "viem";
22
import { addTransaction } from "../logging";
33
import { masterPriceOracleAbi } from "../../../generated";
4+
import type { GetContractReturnType } from "@nomicfoundation/hardhat-viem/types.js";
45

56
export async function addUnderlyingsToMpo(
6-
mpo: GetContractReturnType<typeof masterPriceOracleAbi, WalletClient>,
7+
mpo: GetContractReturnType<typeof masterPriceOracleAbi>,
78
underlyingsToCheck: Address[],
89
oracleAddress: Address,
910
deployer: string,
@@ -23,6 +24,7 @@ export async function addUnderlyingsToMpo(
2324
if (underlyings.length) {
2425
if ((await mpo.read.admin()).toLowerCase() === deployer.toLowerCase()) {
2526
const tx = await mpo.write.add([underlyings, oracles]);
27+
console.log("tx: ", tx);
2628
await publicClient.waitForTransactionReceipt({ hash: tx });
2729
console.log(`Master Price Oracle updated oracles for tokens ${underlyings.join(",")} at ${tx}`);
2830
} else {
@@ -60,7 +62,7 @@ export async function addUnderlyingsToMpo(
6062
}
6163

6264
export async function addUnderlyingsToMpoFallback(
63-
mpo: GetContractReturnType<typeof masterPriceOracleAbi, WalletClient>,
65+
mpo: GetContractReturnType<typeof masterPriceOracleAbi>,
6466
underlyingsToCheck: Address[],
6567
oracleAddress: Address,
6668
deployer: Address,

chainDeploy/helpers/utils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import { Address } from "viem";
12
import { SupportedAsset } from "../../chains/types";
23

3-
export const underlying = (assets: SupportedAsset[], symbol: string): string => {
4+
export const underlying = (assets: SupportedAsset[], symbol: string): Address => {
45
return assetFilter(assets, symbol).underlying;
56
};
67

78
export const assetArrayToMap = (assets: SupportedAsset[]): { [key: string]: SupportedAsset } =>
8-
assets.reduce((acc, curr) => {
9-
acc[curr.underlying] = curr;
10-
return acc;
11-
}, {} as Record<string, SupportedAsset>);
9+
assets.reduce(
10+
(acc, curr) => {
11+
acc[curr.underlying] = curr;
12+
return acc;
13+
},
14+
{} as Record<string, SupportedAsset>
15+
);
1216

1317
export const assetFilter = (assets: SupportedAsset[], symbol: string): SupportedAsset => {
1418
const asset = assets.find((a: SupportedAsset) => a.symbol === symbol);

0 commit comments

Comments
 (0)