{
const {address, array, uint} = world.env.bindings()
const Compound = await world.env.library(CompoundLib)
const CompGov = await world.env.library(CompGovLib)
const $$proposeUpgrade = () => [
{...CompGov.$delegate(address('CompHolder')), from: 'CompHolder'},
{...CompGov.$propose(
"Borrow Caps Comptroller Patch",
[
{Unitroller: '_setPendingImplementation(address)', args: [address('StdComptrollerG5')]},
{StdComptrollerG5: '_become(address)', args: [address('Unitroller')]},
{Unitroller: '_setBorrowCapGuardian(address)', args: [address('Guardian')]}
]
), from: 'CompHolder'}
]
await world.exec([
$$proposeUpgrade(),
(w) => CompGov.whipLastProposal(address('CompHolder'), w),
{send: '_setMarketBorrowCaps', to: 'Comptroller', args: [array(address)([address('cUSDT')]), array(uint)([exp(100e6, 6)])], from: 'Guardian'},
Compound.$$basicLiquidate(address('ETHWhale'), 'cETH', exp(1), 'cUSDT', exp(240, 6), exp(100, 6), address('USDTWhale')),
{send: '_setMarketBorrowCaps', to: 'Comptroller', args: [array(address)([address('cUSDT')]), array(uint)([exp(1e6, 6)])], from: 'Guardian'}
])
await world.reverts(
Compound.$$basicBorrow('cETH', exp(1), 'cUSDT', exp(240, 6), address('ETHWhale')),
'market borrow cap reached'
)
await world.exec([
{send: '_setMarketBorrowCaps', to: 'Comptroller', args: [array(address)([address('cUSDT')]), array(uint)([exp(100e6, 6)])], from: 'Guardian'},
Compound.$$basicBorrow('cETH', exp(1), 'cUSDT', exp(240, 6), address('ETHWhale'))
])
return world;
}