oceanprotocol-archive / oceandao

🐡 OceanDAO wiki
28 stars 9 forks source link

Update snapshot strategies for v4 subgraphs #516

Closed idiom-bytes closed 2 years ago

idiom-bytes commented 2 years ago

Please expand below of there are any other dependencies WRT v4 & voting:

DoD:

idiom-bytes commented 2 years ago
idiom-bytes commented 2 years ago

From Alex. We should consider building an H2O vault strategy. Robin brought this up a little while ago but we did not have a ticket for this.

query{
  safes(orderBy: collateral, orderDirection: desc) {
    collateralType {
      id
    }
    safeId
    owner {
      address
    }
    collateral
    debt
  }
}
idiom-bytes commented 2 years ago

There was a good amount of things in here: DONE - updating the code so that it uses network as a parameter DONE - adding the remaining subgraphs to the list of available networks DONE - adjusting the subgraph query to use the v4 schema + updating the code base wherever needed DONE - registering the oceanTokenAddress foreach Chain so we can filter the subgraph query IN PROGRESS - creating multiple tests for different networks, configuring users, test each network (if possible). DONE - Design the snapshot spaces configuration to include the v4 marketplace across all chains.

Am focusing on completing the strategies first, and configuring all of this inside of test environemnt. I have also added moonbase + mumbai to facilitate testing inside of grants-staging.

V4 gql query

I'm using the following on the polygon subgraph to retrieve & map data to equivalent parameters. The query inside of the strategy is slightly different.

query {
  pools (
    where: {baseToken: "0x282d8efce846a88b159800bd4130ad77443fa1a1"},
    first: 1000,
    orderBy: baseTokenLiquidity,
    orderDirection: desc
  ){
    id,
    baseTokenLiquidity
    totalShares
    shares {
      id
      shares
    }
    baseToken {
      id
      symbol
    },
    datatoken {
      id,
      symbol,
      nft {
        id
      }
      holderCount
    }
  }
}
idiom-bytes commented 2 years ago

I have updated our fork from snapshot-strategies and all of the code for this PR can be found in this branch. https://github.com/oceanprotocol/snapshot-strategies/tree/feature/v4-strategy

@trizin maybe you can take a look at this stuff and keep moving it forward so we can push it to snapshot ASAP

Cheers!

idiom-bytes commented 2 years ago

[Testing against multiple networks + validating scores]

You need to modify the array index in order to cycle through each entry inside of examples.json (which is what I did)

[Testing against latest blockHeight] The testing suite... npm run test --strategy=ocean-marketplace Also tries to validate the example addresses + scores agains the latest blockHeight

This will always fail as the expectedValues that we pass in are for a specific blockHeight

[Next steps]

idiom-bytes commented 2 years ago

[Strategy deployment approach] I have split the strategy into ocean-marketplace-v4 and am proposing to snapshot this is accepted, in order to run v3 and v4 alongside each other. I'm not sure if snapshot will accept this update, but will propose this as the PR to move forward. This should enable us to simply expand on the vote count.

Strategy configuration update:

  1. Made sure that tests are passing using Snapshot's extended coverage yarn test --strategy=ocean-marketplace-v4 --more=500
  2. Updated tests to use the same param names as erc20-balance-of strategy
  3. I expanded the production strategy to also include erc20-balance-of strategy + ocean-marketplace-v4 for all 5 production chains
idiom-bytes commented 2 years ago

I updated the ocean-dao-brightid strategy to include the configuration for all chains, including erc20 balance of.

Ocean ERC20 Addresses

I utilized the erc20 ocean addresses from the contracts/blob/addresses.json

OCEAN_ADDRESS = {
  '1': '0x967da4048cD07aB37855c090aAF366e4ce1b9F48',
  '3': '0x5e8DCB2AfA23844bcc311B00Ad1A0C30025aADE9',
  '42': '0x8967bcf84170c91b0d24d4302c2376283b0b3a07',
  '56': '0xDCe07662CA8EbC241316a15B611c89711414Dd1a',
  '137': '0x282d8efCe846A88B159800bd4130ad77443Fa1A1',
  '246': '0x593122AAE80A6Fc3183b2AC0c4ab3336dEbeE528',
  '1285': '0x99C409E5f62E4bd2AC142f17caFb6810B8F0BAAE',
  '1287': '0xF6410bf5d773C7a41ebFf972f38e7463FA242477',
  '80001': '0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8'
};

Snapshot Spaces Configuration

{
  "symbol": "OCEAN",
  "registry": "0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0",
  "strategies": {
    "1": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cd07ab37855c090aaf366e4ce1b9f48",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace-v4",
        "params": {
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48"
        }
      },
      {
        "name": "sushiswap",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "uniswap",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "contract-call",
        "params": {
          "args": [
            "%{address}",
            "0xCDfF066eDf8a770E9b6A7aE12F7CFD3DbA0011B5",
            "0x967da4048cD07aB37855c090aAF366e4ce1b9F48"
          ],
          "symbol": "OCEAN",
          "address": "0x9712Bb50DC6Efb8a3d7D12cEA500a50967d2d471",
          "decimals": 18,
          "methodABI": {
            "name": "totalProviderAmount",
            "type": "function",
            "inputs": [
              {
                "name": "provider",
                "type": "address",
                "internalType": "address"
              },
              {
                "name": "poolToken",
                "type": "address",
                "internalType": "address"
              },
              {
                "name": "reserveToken",
                "type": "address",
                "internalType": "address"
              }
            ],
            "outputs": [
              {
                "name": "",
                "type": "uint256",
                "internalType": "uint256"
              }
            ],
            "stateMutability": "view"
          }
        }
      }
    ],
    "56": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0xDCe07662CA8EbC241316a15B611c89711414Dd1a",
          "decimals": 18
        }
      }
    ],
    "137": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace-v4",
        "params": {
          "address": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1"
        }
      }
    ],
    "246": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x593122AAE80A6Fc3183b2AC0c4ab3336dEbeE528",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace-v4",
        "params": {
          "address": "0x593122AAE80A6Fc3183b2AC0c4ab3336dEbeE528"
        }
      }
    ],
    "1285": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x99C409E5f62E4bd2AC142f17caFb6810B8F0BAAE",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace-v4",
        "params": {
          "address": "0x99C409E5f62E4bd2AC142f17caFb6810B8F0BAAE"
        }
      }
    ]
  },
  "brightIdNetwork": "1",
  "delegationSpace": "officialoceandao.eth",
  "brightIdMultiplier": 4,
  "notVerifiedMultiplier": 1
}
idiom-bytes commented 2 years ago

PR has been submitted for review https://github.com/snapshot-labs/snapshot-strategies/pull/695

idiom-bytes commented 2 years ago

Pushed commit to provide test coverage for EWT + MOVR. Configuring demo space + updating DAOBot to setup new strategy + deploy test vote.

idiom-bytes commented 2 years ago

We are awaiting for the snapshot strategy to be merged so we can deploy the test ballot + prod ballot.

Final Steps

  1. Update the demo snapshot space
  2. Configure staging Airtable
  3. Deploy the test ballot "via DAOBot on staging vm"
  4. Let community know + validate vote count
  5. Test results and validate the votes / strategy is working.
  6. Merge DAOBot changes into main
  7. Update prod VM
  8. Deploy R19 ballot via "DAOBot on prod vm"
idiom-bytes commented 2 years ago

To test delegation spaces:

idiom-bytes commented 2 years ago

Demo snapshot spaces is a bit broken atm.

Since I can't modify the strategy there, I'm going to modify the production strategy, and deploy a test in the production environment using DAOBot in my local environment, while using the data from staging....

Frankentesting!

This should be give me a little bit more confidence than I have at the moment, that this will be ok too.

Saving the current strategy from the prod configuration

{
  "symbol": "OCEAN",
  "registry": "0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0",
  "strategies": {
    "1": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cd07ab37855c090aaf366e4ce1b9f48",
          "decimals": 18
        }
      },
      {
        "name": "ocean-marketplace",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "sushiswap",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "uniswap",
        "params": {
          "symbol": "OCEAN",
          "address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
          "decimals": 18
        }
      },
      {
        "name": "contract-call",
        "params": {
          "args": [
            "%{address}",
            "0xCDfF066eDf8a770E9b6A7aE12F7CFD3DbA0011B5",
            "0x967da4048cD07aB37855c090aAF366e4ce1b9F48"
          ],
          "symbol": "OCEAN",
          "address": "0x9712Bb50DC6Efb8a3d7D12cEA500a50967d2d471",
          "decimals": 18,
          "methodABI": {
            "name": "totalProviderAmount",
            "type": "function",
            "inputs": [
              {
                "name": "provider",
                "type": "address",
                "internalType": "address"
              },
              {
                "name": "poolToken",
                "type": "address",
                "internalType": "address"
              },
              {
                "name": "reserveToken",
                "type": "address",
                "internalType": "address"
              }
            ],
            "outputs": [
              {
                "name": "",
                "type": "uint256",
                "internalType": "uint256"
              }
            ],
            "stateMutability": "view"
          }
        }
      }
    ],
    "56": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0xDCe07662CA8EbC241316a15B611c89711414Dd1a",
          "decimals": 18
        }
      }
    ],
    "137": [
      {
        "name": "erc20-balance-of",
        "params": {
          "symbol": "OCEAN",
          "address": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1",
          "decimals": 18
        }
      }
    ]
  },
  "brightIdNetwork": "1",
  "delegationSpace": "officialoceandao.eth",
  "brightIdMultiplier": 4,
  "notVerifiedMultiplier": 1
}
idiom-bytes commented 2 years ago

I have deployed a test proposal in our production environment. https://discord.com/channels/612953348487905282/776848812534398986/994329175362121779

As of now, demo.snaphsot/settings is not working. Laurent is asking us to update our ENS configuration, but it already has everything required for it to work.