function UniswapAnchoredViewLib({abi, address, uint, array, Enum, Struct}, env) {
const {
$mineBlock,
$increaseTime,
$$advanceBlocks
} = env.library(EVMLib)
return {
PriceSource: new Enum('PriceSource', ['FIXED_ETH', 'FIXED_USD', 'REPORTER']),
TokenConfig: new Struct('TokenConfig', {
cToken: 'address',
underlying: 'address',
symbolHash: 'bytes32',
baseUnit: 'uint256',
priceSource: 'PriceSource',
fixedPrice: 'uint256',
uniswapMarket: 'address',
isUniswapReversed: 'bool'
}),
deployUniswapAnchoredView: async (world) => world.exec([
{deploy: 'OpenOraclePriceData', as: 'priceData', force: true},
{deploy: 'UniswapAnchoredView', as: 'priceFeed', force: true, args: [
() => address('priceData'),
address('reporter'),
uint('anchorToleranceMantissa'),
uint('anchorPeriod'),
array('TokenConfig')('tokenConfigs')
]}
]),
checkUniswapAnchoredView: async (world) => world.exec([
{call: 'price', on: address('priceFeed'), args: ['BTC'], expect: uint('btcUsdPrice')},
{call: 'price', on: address('priceFeed'), args: ['ETH'], expect: uint('ethUsdPrice')},
]),
proposePriceFeed: async (world) => world.exec([
{send: 'delegate', to: 'Comp', args: [address('CompHolder')], from: 'CompHolder'},
{send: 'propose', to: 'GovernorAlpha', args: [
[address('Comptroller')],
[0],
['_setPriceOracle(address)'],
[abi.encode(address('priceFeed'))],
"Migrate to Compound Price Feed"
], from: 'CompHolder'}
]),
voteForQueueAndExecuteProposal: async (proposalId, world) => world.exec([
$mineBlock(),
{send: 'castVote', to: 'GovernorAlpha', args: [proposalId, true], from: 'CompHolder'},
$$advanceBlocks(uint('votingPeriodWait')),
{send: 'queue', to: 'GovernorAlpha', args: [proposalId]},
$increaseTime(uint('timelockDelayWait')),
{send: 'execute', to: 'GovernorAlpha', args: [proposalId]}
]),
lastProposal: async (world) => world.call('proposalCount', {on: 'GovernorAlpha'})
}
}