Pseudo-code and permission tables for the Commons Upgrade

@paulo and me have been working on how should look like a Gardens changed with the Commons Upgrade.

Gardens permission table

These are the gardens default permissions that will be changed by the Commons Upgrade:

App Permission Grantee Manager
ACL Create permissions DV (GDN) DV (GDN)
Agent 1 Execute actions DV (GDN) DV (GDN)
Agent 1 Run EVM Script DV (GDN) DV (GDN)
Agent 2 Transfer Agent’s tokens CV (GDN) DV (GDN)
Agent 2 Execute actions DV (GDN) DV (GDN)
Agent 2 Run EVM Script DV (GDN) DV (GDN)
Agreement Change Agreement configuration DV (GDN) DV (GDN)
Agreement Manage Agreement disputable apps Collateral Requirement Updater DV (GDN)
CV (GDN) Update settings DV (GDN) DV (GDN)
CV (GDN) Create proposals Any account DV (GDN)
CV (GDN) Cancel proposals DV (GDN) DV (GDN)
CV (GDN) Challenge votes Any account DV (GDN)
DV (GDN) Create new votes Any account DV (GDN)
DV (GDN) Challenge votes Any account DV (GDN)
EVM Script Registry Add executors DV (GDN) DV (GDN)
EVM Script Registry Enable and disable executors DV (GDN) DV (GDN)
Kernel Manage apps DV (GDN) DV (GDN)
Issuance Update the settings DV (GDN) DV (GDN)
Tokens Mint tokens Issuance DV (GDN)
Tokens Burn tokens Issuance DV (GDN)

*GDN: Gardens’ token minted by the Tokens app

Commons Upgrade script pseudo-code

We are working on a script that will be able to transform a Garden into a Common with the following set of actions:

  1. Install and initialize a new agent (our ABC reserve)
  2. Install and initialize bonding curve
  3. Install and initialize migration tools
  4. Add bonding curve permissions
  5. Add migration tools permissions
  6. Disable issuance (remove permissions)
  7. Execute marketMaker.addCollateralToken(wxDAI, 1, 0, reserveRatio)

Commons permission table

The resulting permission should be as follows:

App Permission Grantee Manager
ACL Create permissions DV (TEC) DV (TEC)
Agent 1 Execute actions DV (GDN) DV (GDN)
Agent 1 Run EVM Script DV (GDN) DV (GDN)
Agent 2 Transfer Agent’s tokens CV (GDN) DV (GDN)
Agent 2 Execute actions DV (GDN) DV (GDN)
Agent 2 Run EVM Script DV (GDN) DV (GDN)
Agreement Change Agreement configuration DV (TEC) DV (TEC)
Agreement Manage Agreement disputable apps Collateral Requirement Updater DV (TEC)
Bonding Curve Update fees Voting (TEC) DV (TEC)
Bonding Curve Add tokens as whitelisted collaterals DV (TEC) DV (TEC)
Bonding Curve Open trading DV (TEC) DV (TEC)
Bonding Curve Make buy orders Any account DV (TEC)
Bonding Curve Make sell orders Any account DV (TEC)
CV (TEC) Update settings Voting (TEC) DV (TEC)
CV (TEC) Create proposals Any account DV (TEC)
CV (TEC) Cancel proposals DV (TEC) DV (TEC)
CV (TEC) Challenge votes Any account DV (TEC)
DV (TEC) Create new votes Any account DV (TEC)
DV (TEC) Challenge votes Any account DV (TEC)
EVM Script Registry Add executors DV (TEC) DV (TEC)
EVM Script Registry Enable and disable executors DV (TEC) DV (TEC)
Kernel Manage apps DV (TEC) DV (TEC)
Migration Tools Prepare claims Migration Tools (Old Dao) DV (TEC)
Tokens Mint tokens Bonding Curve DV (TEC)
Tokens Burn tokens Bonding Curve DV (TEC)
Tokens Issue tokens Migration Tools DV (TEC)
Tokens Assign tokens Migration Tools DV (TEC)
Agent 3 (Reserve) Transfer Vault’s tokens Bonding Curve DV (TEC)

Edit (June 22, 2021): We simplified the scope to only have one disputable voting, and to install a third agent instead of a vault.

5 Likes

We are ready to show some more advances on the library Commons Swarm is writing for making EVMScripts much more manageable. This is a sneak peak of how this library will be used to create the Commons Upgrade vote:

import EVMScripter from '@commonsswarm/evmscripter'

// Commons Upgrade Garden Parameters
const formulaAddress = '0x9ac140f489df1481c20feb318f09b29a4f744915' // Bancor Formula
const collateral = '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d' // wxDAI
const hatchMigrationTools = '0xa1b4da2a85bce4733d50e392b5aaecc74223a926' // Hatch DAO app
const entryTribute = 0
const exitTribute = 0.2
const reserveRatio = 0.1

const PPM = 1000000
const evm = new EVMScripter()
await evm.connect(daoAddr)

const context = 'Commons Upgrade'
const path = ['disputable-voting']

evm.forward([
  evm.installApp('agent'),
  evm.installApp('commons-market-maker.open', [
    evm.app('wrappable-hooked-token-manager'),
    evm.app('agent:1'),
    evm.app('agent:2'),
    formulaAddress,
    parseInt(entryTribute * PPM),
    parseInt(exitTribute * PPM)
  ]),
  evm.installApp('migration-tools-beta.open', [
    evm.app('wrappable-hooked-token-manager'),
    evm.app('agent:1'),
    evm.app('agent:2')
  ]),
  evm.addPermissions([
    ['disputable-voting', 'commons-market-maker', 'OPEN_TRADING_ROLE'],
    [evm.ANY_ENTITY, 'commons-market-maker', 'MAKE_BUY_ORDER_ROLE'], 
    [evm.ANY_ENTITY, 'commons-market-maker', 'MAKE_SELL_ORDER_ROLE'],
    ['disputable-voting', 'commons-market-maker', 'ADD_COLLATERAL_TOKEN_ROLE'],
    ['commons-market-maker', 'wrappable-hooked-token-manager', 'MINT_ROLE'],
    ['commons-market-maker', 'wrappable-hooked-token-manager', 'BURN_ROLE'],
    ['commons-market-maker', 'agent:2', 'TRANSFER_ROLE'],
    [hatchMigrationTools, 'migration-tools-beta', 'PREPARE_CLAIMS_ROLE']
    ['migration-tools-beta', 'wrappable-hooked-token-manager', 'ISSUE_ROLE'],
    ['migration-tools-beta', 'wrappable-hooked-token-manager', 'ASSIGN_ROLE'],
  ], 'disputable-voting')
  evm.revokePermissions([
    ['dynamic-issuance', 'wrappable-hooked-token-manager', 'MINT_ROLE'],
    ['dynamic-issuance', 'wrappable-hooked-token-manager', 'BURN_ROLE'],
    ['disputable-voting', 'dynamic-issuance', 'UPDATE_SETTINGS_ROLE']
  ]),
  evm.call['commons-market-maker'].addCollateralToken(collateral, 1, 0, parseInt(reserveRatio * PPM))
], { context, path })
8 Likes

Love it! The API is :fire_engine::fire:

3 Likes

Love seeing these technical posts to learn from. Keep it up!

1 Like

Note that an updated version of this script can be found in: