Skip to content

Commit

Permalink
price feeds script
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Jun 19, 2024
1 parent a644a53 commit cdb0425
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions mainnet_chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"gasReceiver": "0x2d5d7d31F671F86C782533cc367F14109a082712",
"ojoContract": "0x5BB3E85f91D08fe92a3D123EE35050b763D6E6A7",
"create2Deployer": "0x98b2920d53612483f91f12ed7754e51b4a77919e",
"priceFeedImplementation": "",
"cloneFactory": ""
"priceFeedImplementation": "0xde471274F1B684476d341eB131224F389AD4A270",
"cloneFactory": "0x710C8a3c8CB393cA24748849de3585b5C48D4D0c"
}
]
26 changes: 17 additions & 9 deletions scripts/createPriceFeed.ts → scripts/createPriceFeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import testnet_chains from '../testnet_chains.json';
import mainnet_chains from '../mainnet_chains.json';

async function main() {
const cloneFactoryAddress = process.env.CLONE_FACTORY_CONTRACT_ADDRESS as string;
const priceFeedChain = process.env.PRICE_FEED_EVM_CHAIN as string;
const evmChains = JSON.parse(process.env.EVM_CHAINS!);
const priceFeedDecimals = process.env.PRICE_FEED_DECIMALS as any;
const priceFeedDescriptions = process.env.PRICE_FEED_DESCRIPTIONS as any;
const priceFeedDescriptions = JSON.parse(process.env.PRICE_FEED_DESCRIPTIONS!);

const privateKey = process.env.PRIVATE_KEY;

Expand All @@ -16,21 +15,30 @@ async function main() {
}

const mainnet = process.env.MAINNET as string
let evmChains = testnet_chains.map((chain) => ({ ...chain }));
let chains = testnet_chains.map((chain) => ({ ...chain }));
if (mainnet === "TRUE") {
evmChains = mainnet_chains.map((chain) => ({ ...chain }));
chains = mainnet_chains.map((chain) => ({ ...chain }));
}

for (const chain of evmChains) {
if (chain.name === priceFeedChain) {
for (const chain of chains) {
if (evmChains.includes(chain.name)) {
const provider = new ethers.JsonRpcProvider(chain.rpc)
const wallet = new Wallet(privateKey, provider);
const balance = await provider.getBalance(wallet.address)
console.log(`${chain.name} wallet balance: ${ethers.formatEther(balance.toString())} ${chain.tokenSymbol}`);

const cloneFactoryContract = new ethers.Contract(cloneFactoryAddress, CloneFactory.abi, wallet)
const cloneFactoryContract = new ethers.Contract(chain.cloneFactory, CloneFactory.abi, wallet)
for (const priceFeedDescription of priceFeedDescriptions) {
await cloneFactoryContract.createPriceFeed(priceFeedDecimals, priceFeedDescription)
console.log(`Deploying ${priceFeedDescription} price feed on ${chain.name}`);
try {
const tx = await cloneFactoryContract.createPriceFeed(priceFeedDecimals, priceFeedDescription);
console.log(`Transaction sent: ${tx.hash}`);

const receipt = await tx.wait();
console.log(`Transaction mined: ${receipt.transactionHash}`);
} catch (error) {
console.error(`Failed to deploy ${priceFeedDescription} on ${chain.name}:`, error);
}
}
}
}
Expand Down

0 comments on commit cdb0425

Please sign in to comment.