Skip to content

Commit

Permalink
Add comptroller upgrade process to readme (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 authored Nov 16, 2021
1 parent ecc4ab8 commit 4a8648e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ We detail a few of the core contracts in the Compound protocol.
<dl>
<dt>Comptroller</dt>
<dd>The risk model contract, which validates permissible user actions and disallows actions if they do not fit certain risk parameters. For instance, the Comptroller enforces that each borrowing user must maintain a sufficient collateral balance across all cTokens.</dd>
<ul>
<em>Updating the Comptroller</em>
<li>Follow the existing naming schema (ControllerGX)</li>
<li>Update the scenario runner in scenario/src/Builder/ComptrollerImplBuilder.ts</li>
<li>Create unit tests and fork simulations as necessary</li>
<li>Call <code>npx saddle deploy Comptroller -n mainnet</code> to deploy to mainnet and generate new ABI</li>
<ul>
<li>The ABI can also be generated by deploying to mainnet in a fork simulation</li>
</ul>
<li>Call <code>node script/comptroller-abi</code> to merge the new Comptroller ABI with the Unitroller ABI</li>
<li>Ensure that commit contains new generated Comptroller ABI</li>
</ul>
</dl>

<dl>
Expand Down
10 changes: 5 additions & 5 deletions script/comptroller-abi
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ function mergeInterface(into, from) {
return into.concat(from)
}

function mergeComptroller(abi, G) {
abi.Comptroller = mergeInterface(abi.Unitroller, abi[`StdComptrollerG${G}`])
function mergeComptroller(abi) {
abi.Comptroller = mergeInterface(abi.Unitroller, abi[`Comptroller`])
return abi;
}

function format(abi) {
return JSON.stringify(abi, null, 4).replace(/^( {4}".*?)$/mg, '\n$1')
}

function main(path, G) {
function main(path) {
const abi = JSON.parse(fs.readFileSync(path))
fs.writeFileSync(path, format(mergeComptroller(abi, G)))
fs.writeFileSync(path, format(mergeComptroller(abi)))
}

main('networks/mainnet-abi.json', 5)
main('networks/mainnet-abi.json')

0 comments on commit 4a8648e

Please sign in to comment.