-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86e8959
commit 23104a4
Showing
8 changed files
with
224 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Wallet, ethers } from "ethers"; | ||
import CloneFactory from '../artifacts/contracts/mellowpricefeed/CloneFactory.sol/CloneFactory.json'; | ||
import testnet_chains from '../testnet_chains.json'; | ||
import mainnet_chains from '../mainnet_chains.json'; | ||
|
||
async function main() { | ||
const evmChains = JSON.parse(process.env.EVM_CHAINS!); | ||
const mellowPriceFeedDecimals = process.env.PRICE_FEED_DECIMALS as any; | ||
const mellowPriceFeeds = JSON.parse(process.env.MELLOW_PRICE_FEEDS!); | ||
const mellowVaults = JSON.parse(process.env.MELLOW_VAULTS!); | ||
|
||
if (mellowPriceFeeds.length !== mellowVaults.length) { | ||
throw new Error('unequal amount of mellowVaults associated with mellowPriceFeeds'); | ||
} | ||
|
||
const privateKey = process.env.PRIVATE_KEY; | ||
|
||
if (!privateKey) { | ||
throw new Error('Invalid private key. Make sure the PRIVATE_KEY environment variable is set.'); | ||
} | ||
|
||
const mainnet = process.env.MAINNET as string | ||
let chains = testnet_chains.map((chain) => ({ ...chain })); | ||
if (mainnet === "TRUE") { | ||
chains = mainnet_chains.map((chain) => ({ ...chain })); | ||
} | ||
|
||
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 cloneFactoryMellowContract = new ethers.Contract(chain.cloneFactoryMellow, CloneFactory.abi, wallet) | ||
let i = 0 | ||
for (const mellowPriceFeed of mellowPriceFeeds) { | ||
console.log(`Deploying ${mellowPriceFeed} price feed on ${chain.name}`); | ||
try { | ||
const [baseAsset, quoteAsset] = mellowPriceFeed.split('/'); | ||
|
||
console.log("baseAsset", baseAsset) | ||
console.log("quoteAsset", quoteAsset) | ||
const tx = await cloneFactoryMellowContract.createMellowPriceFeed(mellowPriceFeedDecimals, mellowVaults[i], baseAsset, quoteAsset); | ||
console.log(`Transaction sent: ${tx.hash}`); | ||
|
||
const receipt = await tx.wait(); | ||
console.log(`Transaction mined: ${receipt.transactionHash}`); | ||
} catch (error) { | ||
console.error(`Failed to deploy ${mellowPriceFeed} on ${chain.name}:`, error); | ||
} | ||
i += 1 | ||
} | ||
} | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Wallet, ethers } from "ethers"; | ||
import CloneFactoryQuoted from '../artifacts/contracts/mellowpricefeed/CloneFactory.sol/CloneFactory.json'; | ||
import testnet_chains from '../testnet_chains.json'; | ||
import mainnet_chains from '../mainnet_chains.json'; | ||
|
||
async function main () { | ||
const evmChains = JSON.parse(process.env.EVM_CHAINS!); | ||
|
||
const privateKey = process.env.PRIVATE_KEY; | ||
|
||
if (!privateKey) { | ||
throw new Error('Invalid private key. Make sure the PRIVATE_KEY environment variable is set.'); | ||
} | ||
|
||
const mainnet = process.env.MAINNET as string | ||
let chains = testnet_chains.map((chain) => ({ ...chain })); | ||
if (mainnet === "TRUE") { | ||
chains = mainnet_chains.map((chain) => ({ ...chain })); | ||
} | ||
|
||
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 cloneFactoryQuotedFactory = new ethers.ContractFactory(CloneFactoryQuoted.abi, CloneFactoryQuoted.bytecode, wallet) | ||
const cloneFactoryQuoted = await cloneFactoryQuotedFactory.deploy(chain.mellowPriceFeedImplementation) | ||
console.log(`${chain.name}, address: ${await cloneFactoryQuoted.getAddress()}`); | ||
} | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Wallet, ethers } from "ethers"; | ||
import MellowPriceFeed from '../artifacts/contracts/mellowpricefeed/MellowPriceFeed.sol/MellowPriceFeed.json'; | ||
import testnet_chains from '../testnet_chains.json'; | ||
import mainnet_chains from '../mainnet_chains.json'; | ||
|
||
async function main() { | ||
const evmChains = JSON.parse(process.env.EVM_CHAINS!); | ||
|
||
const privateKey = process.env.PRIVATE_KEY; | ||
|
||
if (!privateKey) { | ||
throw new Error('Invalid private key. Make sure the PRIVATE_KEY environment variable is set.'); | ||
} | ||
|
||
const mainnet = process.env.MAINNET as string | ||
let chains = testnet_chains.map((chain) => ({ ...chain })); | ||
if (mainnet === "TRUE") { | ||
chains = mainnet_chains.map((chain) => ({ ...chain })); | ||
} | ||
|
||
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 mellowPriceFeedFactory = new ethers.ContractFactory(MellowPriceFeed.abi, MellowPriceFeed.bytecode, wallet) | ||
const mellowPriceFeed = await mellowPriceFeedFactory.deploy() | ||
console.log(`${chain.name}, address: ${await mellowPriceFeed.getAddress()}`); | ||
} | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
Oops, something went wrong.