Created
December 16, 2021 13:24
-
-
Save sunnyRK/2f6bbf010b4dc43eb6d9647e8127ab83 to your computer and use it in GitHub Desktop.
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
// import { MockContract, smockit } from "@eth-optimism/smock" | |
import { ethers, waffle } from "hardhat" | |
import { MockProvider } from 'ethereum-waffle'; | |
import hre from "hardhat"; | |
import { parseEther, parseUnits } from "ethers/lib/utils" | |
import { | |
AccountBalance, | |
BaseToken, | |
// ChainlinkPriceFeed, | |
ClearingHouse, | |
ClearingHouseConfig, | |
Exchange, | |
InsuranceFund, | |
MarketRegistry, | |
MockTestAggregatorV3, | |
OrderBook, | |
TestClearingHouse, | |
TestERC20, | |
TestExchange, | |
TestUniswapV3Broker, | |
UniswapV3Factory, | |
UniswapV3Pool, | |
Vault, | |
} from "../typechain" | |
import { QuoteToken } from "../typechain/QuoteToken" | |
import { TestAccountBalance } from "../typechain/TestAccountBalance" | |
import { createQuoteTokenFixture, token0Fixture, tokensFixture, uniswapV3FactoryFixture } from "../test/localDeployFixture/sharedFixtures" | |
import { createClearingHouseFixture } from "../test/localDeployFixture/fixtures" | |
import fs from 'fs'; | |
import { BigNumber } from "ethers"; | |
const SAVE_PREFIX = "./deployments/"; | |
const SAVE_POSTFIX = "local.deployment.js"; | |
let deployedContracts = {}; | |
const bn = require("bignumber.js"); | |
bn.config({ EXPONENTIAL_AT: 999999, DECIMAL_PLACES: 40 }) | |
function encodePriceSqrt(reserve1, reserve0) { | |
return BigNumber.from( | |
new bn(reserve1.toString()) | |
.div(reserve0.toString()) | |
.sqrt() | |
.multipliedBy(new bn(2).pow(96)) | |
.integerValue(3) | |
.toString(), | |
) | |
} | |
async function main() { | |
let clearingHouse: TestClearingHouse | |
let marketRegistry: MarketRegistry | |
let clearingHouseConfig: ClearingHouseConfig | |
let exchange: Exchange | |
let orderBook: OrderBook | |
let accountBalance: AccountBalance | |
let vault: Vault | |
let collateral: TestERC20 | |
let baseToken: BaseToken | |
let baseToken2: BaseToken | |
let quoteToken: QuoteToken | |
let pool: UniswapV3Pool | |
let pool2: UniswapV3Pool | |
let mockedBaseAggregator: MockTestAggregatorV3 | |
let mockedBaseAggregator2: MockTestAggregatorV3 | |
let univ3factory: UniswapV3Factory | |
let collateralDecimals: number | |
const lowerTick: number = 0 | |
const upperTick: number = 100000 | |
const provider = new MockProvider(); | |
const [admin, admin2] = provider.getWallets(); | |
console.log('admin: ', admin.address) | |
const loadFixture: ReturnType<typeof waffle.createFixtureLoader> = waffle.createFixtureLoader([admin]) | |
const _clearingHouseFixture = await loadFixture(createClearingHouseFixture()) | |
clearingHouse = _clearingHouseFixture.clearingHouse as TestClearingHouse | |
orderBook = _clearingHouseFixture.orderBook | |
accountBalance = _clearingHouseFixture.accountBalance | |
clearingHouseConfig = _clearingHouseFixture.clearingHouseConfig | |
vault = _clearingHouseFixture.vault | |
exchange = _clearingHouseFixture.exchange | |
marketRegistry = _clearingHouseFixture.marketRegistry | |
collateral = _clearingHouseFixture.USDC | |
baseToken = _clearingHouseFixture.baseToken | |
baseToken2 = _clearingHouseFixture.baseToken2 | |
quoteToken = _clearingHouseFixture.quoteToken | |
mockedBaseAggregator = _clearingHouseFixture.mockedBaseAggregator | |
mockedBaseAggregator2 = _clearingHouseFixture.mockedBaseAggregator2 | |
pool = _clearingHouseFixture.pool | |
pool2 = _clearingHouseFixture.pool2 | |
univ3factory = _clearingHouseFixture.uniV3Factory | |
deployedContracts['clearingHouse'] = { | |
name: 'clearingHouse', | |
address: clearingHouse.address | |
}; | |
deployedContracts['orderBook'] = { | |
name: 'orderBook', | |
address: orderBook.address | |
}; | |
deployedContracts['clearingHouseConfig'] = { | |
name: 'clearingHouseConfig', | |
address: clearingHouseConfig.address | |
}; | |
deployedContracts['vault'] = { | |
name: 'vault', | |
address: vault.address | |
}; | |
deployedContracts['exchange'] = { | |
name: 'exchange', | |
address: exchange.address | |
}; | |
deployedContracts['marketRegistry'] = { | |
name: 'marketRegistry', | |
address: marketRegistry.address | |
}; | |
deployedContracts['collateral'] = { | |
name: 'collateral', | |
address: collateral.address | |
}; | |
deployedContracts['baseToken'] = { | |
name: 'baseToken', | |
address: baseToken.address | |
}; | |
deployedContracts['baseToken2'] = { | |
name: 'baseToken2', | |
address: baseToken2.address | |
}; | |
deployedContracts['quoteToken'] = { | |
name: 'quoteToken', | |
address: quoteToken.address | |
}; | |
deployedContracts['mockedBaseAggregator'] = { | |
name: 'mockedBaseAggregator', | |
address: mockedBaseAggregator.address | |
}; | |
deployedContracts['mockedBaseAggregator2'] = { | |
name: 'mockedBaseAggregator2', | |
address: mockedBaseAggregator2.address | |
}; | |
deployedContracts['pool'] = { | |
name: 'pool', | |
address: pool.address | |
}; | |
deployedContracts['pool2'] = { | |
name: 'pool2', | |
address: pool2.address | |
}; | |
deployedContracts['accountBalance'] = { | |
name: 'accountBalance', | |
address: accountBalance.address | |
}; | |
deployedContracts['accountBalance'] = { | |
name: 'accountBalance', | |
address: accountBalance.address | |
}; | |
deployedContracts['univ3factory'] = { | |
name: 'univ3factory', | |
address: univ3factory.address | |
} | |
console.log('deployedContracts: ', deployedContracts) | |
await fs.writeFileSync(SAVE_PREFIX + SAVE_POSTFIX, JSON.stringify(deployedContracts, null, 2)); | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch(error => { | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment