Compare commits
333 Commits
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 2f322ee016 | |
dependabot[bot] | ecc9092f5b | |
dependabot[bot] | ae1a33755f | |
dependabot[bot] | 63bc3f8409 | |
dependabot[bot] | b9bfe07a92 | |
Alex Coseru | d80ba60637 | |
dependabot[bot] | 4e939c70c0 | |
Alex Coseru | ba5e514ddf | |
alexcos20 | 8930eef827 | |
Alex Coseru | 36ae877984 | |
alexcos20 | cf58c9aae4 | |
Alex Coseru | 8bc4dab920 | |
dependabot[bot] | fc07962311 | |
dependabot[bot] | 0077cfa69f | |
dependabot[bot] | 90ad128bc2 | |
dependabot[bot] | 0880f714b0 | |
dependabot[bot] | 7ee41bc29b | |
dependabot[bot] | 957db42e59 | |
dependabot[bot] | db6c3eeeea | |
alexcos20 | 329ea980b6 | |
Alex Coseru | c6004336ae | |
Alex Coseru | 87e42fd6ce | |
alexcos20 | f5b5400261 | |
Alex Coseru | aeef30129a | |
Alex Coseru | 299d196162 | |
Alex Coseru | fa58272978 | |
Alex Coseru | bc56752f3c | |
dependabot[bot] | ab62f18c3e | |
alexcos20 | a62a4c189d | |
Alex Coseru | 39a1210c82 | |
dependabot[bot] | ae9c371e8f | |
dependabot[bot] | 86cc7f0608 | |
dependabot[bot] | b412d2b0b6 | |
alexcos20 | 207a4ac806 | |
dependabot[bot] | 60b8728225 | |
dependabot[bot] | dcaf83775d | |
trizin | 2ca1280328 | |
Maria Carmina | e1df119197 | |
dependabot[bot] | c42cd1c283 | |
dependabot[bot] | e30047c430 | |
dependabot[bot] | 093b452441 | |
alexcos20 | 8691538078 | |
Alex Coseru | 5b2ccbc276 | |
alexcos20 | 9fd0553337 | |
Alex Coseru | c33868d841 | |
alexcos20 | 68944f02a5 | |
Alex Coseru | a77ea45d5f | |
dependabot[bot] | fa071a9cd2 | |
dependabot[bot] | 9164897f2c | |
trizin | 4794dec64e | |
alexcos20 | c8541a071e | |
Alex Coseru | b376cb3942 | |
dependabot[bot] | 81b43ecc20 | |
dependabot[bot] | c02b32b47e | |
dependabot[bot] | a6ded85a37 | |
dependabot[bot] | 4607c673b4 | |
alexcos20 | d888d7d256 | |
Jamie Hewitt | 420a229a61 | |
Jamie Hewitt | 0cf40d40ce | |
dependabot[bot] | b803f1eb6b | |
dependabot[bot] | 1a44345d05 | |
mihaisc | de5f1aab4b | |
Jamie Hewitt | 0a3d513262 | |
dependabot[bot] | 81eb7ea738 | |
dependabot[bot] | 40f09aa6fe | |
dependabot[bot] | 1a5b1a500c | |
dependabot[bot] | dd0512e793 | |
dependabot[bot] | 140bcc6341 | |
Maria Carmina | 6a9b342c52 | |
dependabot[bot] | ec9d7e733f | |
dependabot[bot] | 4c3fd95abc | |
dependabot[bot] | 46f88599b4 | |
dependabot[bot] | 86c6551f31 | |
dependabot[bot] | 1191594196 | |
md00ux | 88a2eecb9b | |
Maria Carmina | 15af2cd609 | |
dependabot[bot] | 1a5906b2b3 | |
dependabot[bot] | 6925cfdde3 | |
dependabot[bot] | 21618b89cf | |
dependabot[bot] | 8ad4f4852b | |
dependabot[bot] | 4cacee3f45 | |
alexcos20 | 3de53c5197 | |
alexcos20 | 7c35711f72 | |
Alex Coseru | 26a53431ea | |
dependabot[bot] | 25021ac9ea | |
dependabot[bot] | 38a7166041 | |
Jamie Hewitt | 9c56b00faa | |
dependabot[bot] | 957488077b | |
dependabot[bot] | 688166e2a0 | |
dependabot[bot] | 1e5e461286 | |
dependabot[bot] | e15d69ebf9 | |
dependabot[bot] | a48b376fa5 | |
dependabot[bot] | 1bb6c9da78 | |
dependabot[bot] | a923bd943f | |
dependabot[bot] | 574b20795b | |
dependabot[bot] | 65515d9d91 | |
dependabot[bot] | cb16d01926 | |
dependabot[bot] | 1293e6ebd7 | |
dependabot[bot] | 004930fd69 | |
dependabot[bot] | 2c7ccabe02 | |
dependabot[bot] | a36c2aecce | |
dependabot[bot] | f34e863623 | |
dependabot[bot] | 8ef553769a | |
dependabot[bot] | c8a4978bc8 | |
dependabot[bot] | c636ad2680 | |
dependabot[bot] | 941dfa28ed | |
dependabot[bot] | d9c5e71d9f | |
Jamie Hewitt | 20c27cd521 | |
mihaisc | 6c4fc1c346 | |
dependabot[bot] | 8eb80507c9 | |
dependabot[bot] | 5ef15e8845 | |
dependabot[bot] | 39ef388831 | |
dependabot[bot] | e6975c60cb | |
dependabot[bot] | 5be8f397af | |
dependabot[bot] | bb90457b91 | |
dependabot[bot] | 89db52ff41 | |
dependabot[bot] | 3a629c7d3e | |
dependabot[bot] | d7e0643c1d | |
dependabot[bot] | a0d3c365bb | |
dependabot[bot] | 52ab055c1a | |
dependabot[bot] | 0cf93fbc52 | |
dependabot[bot] | 5b787d72b5 | |
dependabot[bot] | e9fdbb96d8 | |
dependabot[bot] | c7668c4f1d | |
dependabot[bot] | 45ac3c3d96 | |
dependabot[bot] | 619571b0c2 | |
dependabot[bot] | 29b5efe472 | |
dependabot[bot] | 1e2a3b1814 | |
mihaisc | ae78cae608 | |
mihaisc | 95fcfe9ba7 | |
dependabot[bot] | 7be20246c0 | |
alexcos20 | 92094086f9 | |
Alex Coseru | 868f991f17 | |
dependabot[bot] | 93a05eb767 | |
dependabot[bot] | 12ac5cb523 | |
alexcos20 | 253dc63fa8 | |
Alex Coseru | 24df9f332e | |
alexcos20 | 6c4b270564 | |
Alex Coseru | fe68442fe2 | |
alexcos20 | 91122175dc | |
Alex Coseru | 8cb1d83a26 | |
Berkay Saglam | f61cce9722 | |
Alex Coseru | d2ddf2d156 | |
dependabot[bot] | f3815cdf4b | |
alexcos20 | 181a4f45d0 | |
Alex Coseru | 39b58ba8fe | |
Alex Coseru | 73089dacc3 | |
alexcos20 | a74e3edb3a | |
Alex Coseru | b1a58b7f13 | |
Alex Coseru | c5d86d10df | |
dependabot[bot] | c74d938c24 | |
alexcos20 | 7a627a3bfd | |
Alex Coseru | 0900c1fe88 | |
dependabot[bot] | 2c5459402e | |
dependabot[bot] | 947fe5b341 | |
Idiom | a10c6244b5 | |
Jamie Hewitt | dbb296063b | |
dependabot[bot] | 6af741e5e6 | |
dependabot[bot] | 8b1c3a6060 | |
dependabot[bot] | 3fbc29c145 | |
dependabot[bot] | 9fb268cde9 | |
dependabot[bot] | b340850015 | |
dependabot[bot] | c066d9e59b | |
Jamie Hewitt | 02e980fce2 | |
Jamie Hewitt | 82ce88c026 | |
dependabot[bot] | 6199c34c69 | |
dependabot[bot] | c84c299dbc | |
mihaisc | 06bbaa54c2 | |
mihaisc | 8416d773cc | |
Jamie Hewitt | fd40e490cc | |
Jamie Hewitt | bd03b28197 | |
dependabot[bot] | d9f83dc933 | |
Jamie Hewitt | cedd082749 | |
Jamie Hewitt | 1289a085bb | |
dependabot[bot] | 61cfdbaf23 | |
mihaisc | 4353b15391 | |
mihaisc | a8396aec19 | |
mihaisc | 6572762639 | |
mihaisc | 3ced2e4179 | |
Alex Coseru | e7cb995797 | |
dependabot[bot] | 13d7fb78c1 | |
dependabot[bot] | 5e581e8418 | |
dependabot[bot] | 838de4ba92 | |
dependabot[bot] | cee74ac14a | |
Jamie Hewitt | a733b27fa1 | |
Jamie Hewitt | 493a6d2546 | |
Jamie Hewitt | 07ce9398a6 | |
Jamie Hewitt | 0b8f6e1af5 | |
dependabot[bot] | 6f96246c04 | |
dependabot[bot] | c18d20141d | |
Jamie Hewitt | 3ebc29a74d | |
dependabot[bot] | db8cf22d16 | |
dependabot[bot] | 5da91c2282 | |
dependabot[bot] | f85bfef788 | |
dependabot[bot] | 7aa2be4a34 | |
Jamie Hewitt | cb9890122c | |
Jamie Hewitt | 011e256f5a | |
mihaisc | d864a5ade7 | |
mihaisc | a5d0c10855 | |
Jamie Hewitt | bc693e7797 | |
dependabot[bot] | 8b66fa992b | |
dependabot[bot] | 7b0163f220 | |
mihaisc | 09e79380c3 | |
Jamie Hewitt | 603a25f26a | |
mihaisc | 28979c8c79 | |
mihaisc | d87fbed5b5 | |
mihaisc | d1844f4853 | |
dependabot[bot] | 88cf1967c6 | |
dependabot[bot] | c9636756e2 | |
dependabot[bot] | a531fb347d | |
Jamie Hewitt | b6ce8bae1f | |
mihaisc | a8dd151a01 | |
mihaisc | 401df35f6a | |
mihaisc | 569eb98d8f | |
dependabot[bot] | aa4574994b | |
Alex Coseru | e48b39a80a | |
dependabot[bot] | 74ee630291 | |
mihaisc | 90f7e6482f | |
Alex Coseru | ebecf1f423 | |
Alex Coseru | 8f44e7808d | |
Jamie Hewitt | 4e5bcba661 | |
dependabot[bot] | ed462c4e10 | |
Jamie Hewitt | 796bff70e7 | |
Jamie Hewitt | cb7e36fc98 | |
Alex Coseru | 232c9387f4 | |
dependabot[bot] | 2ff87797ac | |
dependabot[bot] | e3bf0417b9 | |
dependabot[bot] | 898a99cfea | |
dependabot[bot] | f71fc093ed | |
dependabot[bot] | cd9963d5a7 | |
dependabot[bot] | db7ccf070e | |
dependabot[bot] | 8049e1ac1a | |
dependabot[bot] | 1e28dca65f | |
mihaisc | a13ff28062 | |
Ana | 04eddaaac0 | |
mihaisc | 23e87b558e | |
mihaisc | c531773136 | |
mihaisc | d8751fcb99 | |
dependabot[bot] | c5885359fe | |
Alex Coseru | 7073cd8743 | |
dependabot[bot] | c1a0df4eb8 | |
dependabot[bot] | 7d16be1993 | |
dependabot[bot] | 783581eeaa | |
mihaisc | 70fea016fc | |
dependabot[bot] | 1037666e47 | |
dependabot[bot] | 53ed695e3c | |
dependabot[bot] | 24805f662b | |
dependabot[bot] | 937e2fe58b | |
mihaisc | 17821115f9 | |
mihaisc | 9837a71a27 | |
dependabot[bot] | ac9e4832a7 | |
dependabot[bot] | 34cec4f406 | |
dependabot[bot] | e93bf3c48e | |
dependabot[bot] | 4c52664c71 | |
Alex Coseru | a7d8901084 | |
Alex Coseru | 03055e4460 | |
dependabot[bot] | 399c4ce5a9 | |
dependabot[bot] | d52522ff7a | |
Alex Coseru | ccded4c4b1 | |
mihaisc | 1cfe520dad | |
mihaisc | ab2d80429a | |
mihaisc | f127e2206f | |
mihaisc | f03dce6497 | |
Trent McConaghy | 648b1edd6f | |
mihaisc | 48ba47be52 | |
Alex Coseru | 5918c8b035 | |
Alex Coseru | 3aabf53da4 | |
Alex Coseru | f5c7eeae00 | |
dependabot[bot] | 992323baaa | |
dependabot[bot] | c5edbf1fb3 | |
dependabot[bot] | 8b968836a4 | |
dependabot[bot] | f6822dfa28 | |
dependabot[bot] | 748ac7008e | |
dependabot[bot] | de72fc4608 | |
alexcos20 | b6e2256826 | |
Alex Coseru | 68db058782 | |
Alex Coseru | cbdbc64a42 | |
Alex Coseru | cb16470c9a | |
Alex Coseru | 772b723d8a | |
alexcos20 | 59eff980f3 | |
Alex Coseru | dfb59ae6fd | |
Alex Coseru | cd27a2432d | |
Alex Coseru | f3b501b728 | |
Alex Coseru | 11b14081e9 | |
dependabot[bot] | 96f8ec0604 | |
dependabot[bot] | 19d752584b | |
dependabot[bot] | 22b6d11ab4 | |
dependabot[bot] | f8b506a1cf | |
dependabot[bot] | f2808dd5fa | |
Alex Coseru | a69ef020d4 | |
mihaisc | 849464135f | |
mihaisc | 5f67254d42 | |
mihaisc | 6a64fa8ea2 | |
mihaisc | eb29317e5b | |
Alex Coseru | 4df522b426 | |
Alex Coseru | f04fe156ac | |
mihaisc | 01e2a33021 | |
mihaisc | b3d229a543 | |
mihaisc | 4d4f5670ce | |
mihaisc | 49f46806f4 | |
mihaisc | 3e3a9d593d | |
mihaisc | f6ab8f8975 | |
mihaisc | 48d8b92527 | |
mihaisc | 22417b41ba | |
mihaisc | 7f945f02f4 | |
mihaisc | 2839649b28 | |
mihaisc | 6148fd260a | |
mihaisc | 271ea50672 | |
mihaisc | 736c5bb5db | |
mihaisc | f6a0a874a2 | |
mihaisc | 89b494c765 | |
mihaisc | 1868a6219c | |
mihaisc | b469174136 | |
mihaisc | 64cdaf8993 | |
mihaisc | 30c1be31e0 | |
mihaisc | 9fcdbf6ce3 | |
mihaisc | 0ceff45ef2 | |
mihaisc | 3eeba287fb | |
mihaisc | dd7710b2f1 | |
mihaisc | c708e8367b | |
mihaisc | 53e93861bc | |
mihaisc | bc1784edfe | |
mihaisc | b39ecb6e12 | |
mihaisc | dd238aa614 | |
mihaisc | c4633aa381 | |
mihaisc | 82fd689144 | |
mihaisc | 4ac408de51 | |
mihaisc | d8c0d1c9ae | |
mihaisc | 028e83cbe6 | |
mihaisc | bcc520f38d | |
mihaisc | 2e0f4b9e12 | |
mihaisc | 1b5ef439d8 | |
mihaisc | efba716ff5 |
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
contracts
|
||||
.env.local
|
||||
.env
|
||||
build
|
||||
coverage
|
||||
__mocks__
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
node_modules
|
||||
data
|
||||
src/@types
|
20
.eslintrc
20
.eslintrc
|
@ -1,14 +1,24 @@
|
|||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": ["./tsconfig.json"]
|
||||
"project": [
|
||||
"./tsconfig.json"
|
||||
]
|
||||
},
|
||||
"extends": ["oceanprotocol", "plugin:prettier/recommended"],
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"oceanprotocol",
|
||||
"plugin:prettier/recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"no-use-before-define": "off",
|
||||
"eqeqeq": "off",
|
||||
"@typescript-eslint/no-use-before-define": "error",
|
||||
"no-undef": ["warn"]
|
||||
"no-undef": "off",
|
||||
"prefer-destructuring": "off",
|
||||
"no-unneeded-ternary": "off",
|
||||
"no-undefined": "off"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,8 +30,3 @@ jobs:
|
|||
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
# TODO: activate once this issue is solved:
|
||||
# https://github.com/graphprotocol/graph-ts/issues/113
|
||||
# - run: npm run type-check
|
||||
- run: npm run codegen
|
||||
- run: npm run build
|
||||
|
|
|
@ -11,54 +11,65 @@ on:
|
|||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
strategy:
|
||||
max-parallel: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Cache node modules
|
||||
- name: Cache node_modules
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
|
||||
key: ${{ runner.os }}-test-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-test-integration-${{ env.cache-name }}-
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout Barge
|
||||
# Env var expansion workaround
|
||||
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
|
||||
- name: Set ADDRESS_FILE
|
||||
run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout Barge
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: 'oceanprotocol/barge'
|
||||
path: 'barge'
|
||||
- run: npm ci
|
||||
- name: Login to Docker Hub
|
||||
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}
|
||||
run: |
|
||||
echo "Login to Docker Hub";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Run Barge
|
||||
working-directory: ${{ github.workspace }}/barge
|
||||
env:
|
||||
ADDRESS_FILE: ${HOME}/.ocean/ocean-contracts/artifacts/address.json
|
||||
run: |
|
||||
bash -x start_ocean.sh --with-thegraph --no-dashboard 2>&1 > start_ocean.log &
|
||||
for i in $(seq 1 1500); do
|
||||
sleep 5
|
||||
bash -x start_ocean.sh --with-thegraph --skip-subgraph-deploy --no-dashboard 2>&1 > start_ocean.log &
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Wait for contracts deployment
|
||||
working-directory: ${{ github.workspace }}/barge
|
||||
run: |
|
||||
for i in $(seq 1 250); do
|
||||
sleep 10
|
||||
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] && break
|
||||
done
|
||||
cat "$HOME/.ocean/ocean-contracts/artifacts/address.json"
|
||||
- run: npm run bargesetup
|
||||
env:
|
||||
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
||||
- name: create and deploy subgraph
|
||||
run: |
|
||||
npm run codegen
|
||||
npm run build
|
||||
npm run create:local-barge
|
||||
npm run deploy:local-barge
|
||||
npm run quickstart:barge
|
||||
sleep 20
|
||||
env:
|
||||
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
||||
BARGE_FOLDER: /home/runner/.ocean/
|
||||
- run: npm run test-integration
|
||||
env:
|
||||
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
||||
BARGE_FOLDER: /home/runner/.ocean/
|
||||
- name: docker logs
|
||||
run: docker logs ocean_graph-node_1
|
||||
if: ${{ failure() }}
|
||||
|
|
|
@ -67,4 +67,5 @@ typings/
|
|||
.next
|
||||
|
||||
# auto generated barge yaml
|
||||
subgraph.barge.yaml
|
||||
subgraph.barge.yaml
|
||||
subgraph.yaml
|
|
@ -0,0 +1 @@
|
|||
*.graphql
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"wix.vscode-import-cost"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact"
|
||||
],
|
||||
"search.exclude": {
|
||||
"**/.next": true,
|
||||
"**/out": true
|
||||
}
|
||||
}
|
526
CHANGELOG.md
526
CHANGELOG.md
|
@ -4,8 +4,533 @@ All notable changes to this project will be documented in this file. Dates are d
|
|||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
#### [v4.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v4.0.1...v4.0.2)
|
||||
|
||||
- fix deps [`#744`](https://github.com/oceanprotocol/ocean-subgraph/pull/744)
|
||||
|
||||
#### [v4.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v4.0.0...v4.0.1)
|
||||
|
||||
> 22 November 2023
|
||||
|
||||
- Feature/add_optimism & use graph-node 0.33.0 [`#742`](https://github.com/oceanprotocol/ocean-subgraph/pull/742)
|
||||
- Bump chai and @types/chai [`#729`](https://github.com/oceanprotocol/ocean-subgraph/pull/729)
|
||||
- Bump @graphprotocol/graph-cli from 0.56.0 to 0.61.0 [`#738`](https://github.com/oceanprotocol/ocean-subgraph/pull/738)
|
||||
- Bump crypto-js from 4.1.1 to 4.2.0 [`#733`](https://github.com/oceanprotocol/ocean-subgraph/pull/733)
|
||||
- Bump release-it from 15.11.0 to 17.0.0 [`#737`](https://github.com/oceanprotocol/ocean-subgraph/pull/737)
|
||||
- Bump minimist from 1.2.5 to 1.2.6 [`#740`](https://github.com/oceanprotocol/ocean-subgraph/pull/740)
|
||||
- Bump tar from 4.4.13 to 4.4.19 [`#741`](https://github.com/oceanprotocol/ocean-subgraph/pull/741)
|
||||
- Bump @graphprotocol/graph-ts from 0.30.0 to 0.31.0 [`#730`](https://github.com/oceanprotocol/ocean-subgraph/pull/730)
|
||||
- Release 4.0.1 [`cf58c9a`](https://github.com/oceanprotocol/ocean-subgraph/commit/cf58c9aae4aa16f7a30b4c93de72786b1d4b3b3f)
|
||||
|
||||
### [v4.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.10...v4.0.0)
|
||||
|
||||
> 21 November 2023
|
||||
|
||||
- Predictoor support [`#678`](https://github.com/oceanprotocol/ocean-subgraph/pull/678)
|
||||
- bump deps [`#725`](https://github.com/oceanprotocol/ocean-subgraph/pull/725)
|
||||
- Release 4.0.0 [`329ea98`](https://github.com/oceanprotocol/ocean-subgraph/commit/329ea980b628417652de8a444808ba7f470515c8)
|
||||
|
||||
#### [v3.0.10](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.9...v3.0.10)
|
||||
|
||||
> 15 August 2023
|
||||
|
||||
- Bump to graphnode 0.28.2 [`#702`](https://github.com/oceanprotocol/ocean-subgraph/pull/702)
|
||||
- Template id detection [`#705`](https://github.com/oceanprotocol/ocean-subgraph/pull/705)
|
||||
- reduce docker siz [`#709`](https://github.com/oceanprotocol/ocean-subgraph/pull/709)
|
||||
- Create README.md [`#698`](https://github.com/oceanprotocol/ocean-subgraph/pull/698)
|
||||
- Bump word-wrap from 1.2.3 to 1.2.4 [`#701`](https://github.com/oceanprotocol/ocean-subgraph/pull/701)
|
||||
- Release 3.0.10 [`f5b5400`](https://github.com/oceanprotocol/ocean-subgraph/commit/f5b540026106cdaddfdfb1ba1edce0cc1eb333fc)
|
||||
|
||||
#### [v3.0.9](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.8...v3.0.9)
|
||||
|
||||
> 4 July 2023
|
||||
|
||||
- bump to latest contracts [`#695`](https://github.com/oceanprotocol/ocean-subgraph/pull/695)
|
||||
- Bump release-it from 15.10.3 to 15.11.0 [`#688`](https://github.com/oceanprotocol/ocean-subgraph/pull/688)
|
||||
- Bump mock-local-storage from 1.1.23 to 1.1.24 [`#683`](https://github.com/oceanprotocol/ocean-subgraph/pull/683)
|
||||
- Bump vm2 from 3.9.17 to 3.9.18 [`#681`](https://github.com/oceanprotocol/ocean-subgraph/pull/681)
|
||||
- Release 3.0.9 [`a62a4c1`](https://github.com/oceanprotocol/ocean-subgraph/commit/a62a4c189ddd5f712acb62a683dec1c9c8e067b9)
|
||||
|
||||
#### [v3.0.8](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.7...v3.0.8)
|
||||
|
||||
> 16 May 2023
|
||||
|
||||
- Bump @graphprotocol/graph-ts from 0.29.3 to 0.30.0 [`#680`](https://github.com/oceanprotocol/ocean-subgraph/pull/680)
|
||||
- Bump cross-fetch from 3.1.5 to 3.1.6 [`#679`](https://github.com/oceanprotocol/ocean-subgraph/pull/679)
|
||||
- Add lockedAmount to veDelegation [`#672`](https://github.com/oceanprotocol/ocean-subgraph/pull/672)
|
||||
- Fix #628 & #629 & #621: Store event log index for all records [`#630`](https://github.com/oceanprotocol/ocean-subgraph/pull/630)
|
||||
- Bump release-it from 15.10.2 to 15.10.3 [`#673`](https://github.com/oceanprotocol/ocean-subgraph/pull/673)
|
||||
- Bump @types/chai from 4.3.4 to 4.3.5 [`#669`](https://github.com/oceanprotocol/ocean-subgraph/pull/669)
|
||||
- Bump release-it from 15.10.1 to 15.10.2 [`#668`](https://github.com/oceanprotocol/ocean-subgraph/pull/668)
|
||||
- Fix #628 & #629 & #621: Store event log index for all records (#630) [`#628`](https://github.com/oceanprotocol/ocean-subgraph/issues/628)
|
||||
- Release 3.0.8 [`207a4ac`](https://github.com/oceanprotocol/ocean-subgraph/commit/207a4ac806d0f7817ac7f2f4ace5d3c2160ad64c)
|
||||
|
||||
#### [v3.0.7](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.6...v3.0.7)
|
||||
|
||||
> 28 April 2023
|
||||
|
||||
- switch amount from wei to numeric [`#666`](https://github.com/oceanprotocol/ocean-subgraph/pull/666)
|
||||
- Release 3.0.7 [`8691538`](https://github.com/oceanprotocol/ocean-subgraph/commit/8691538078f0d8aa81a0543de403a4e540adbfbd)
|
||||
|
||||
#### [v3.0.6](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.5...v3.0.6)
|
||||
|
||||
> 28 April 2023
|
||||
|
||||
- proper veDelegation [`#663`](https://github.com/oceanprotocol/ocean-subgraph/pull/663)
|
||||
- Release 3.0.6 [`9fd0553`](https://github.com/oceanprotocol/ocean-subgraph/commit/9fd055333705185b5f507fddcdf0f5502add1f1c)
|
||||
|
||||
#### [v3.0.5](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.4...v3.0.5)
|
||||
|
||||
> 26 April 2023
|
||||
|
||||
- add events handlers [`#662`](https://github.com/oceanprotocol/ocean-subgraph/pull/662)
|
||||
- Bump prettier from 2.8.7 to 2.8.8 [`#660`](https://github.com/oceanprotocol/ocean-subgraph/pull/660)
|
||||
- Bump vm2 from 3.9.16 to 3.9.17 [`#659`](https://github.com/oceanprotocol/ocean-subgraph/pull/659)
|
||||
- Add missing veDelegation.save() [`#658`](https://github.com/oceanprotocol/ocean-subgraph/pull/658)
|
||||
- Release 3.0.5 [`68944f0`](https://github.com/oceanprotocol/ocean-subgraph/commit/68944f02a545ea9c06881dcd8883f7dcecd72063)
|
||||
|
||||
#### [v3.0.4](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.3...v3.0.4)
|
||||
|
||||
> 14 April 2023
|
||||
|
||||
- add more veOcean stats [`#655`](https://github.com/oceanprotocol/ocean-subgraph/pull/655)
|
||||
- Bump vm2 from 3.9.15 to 3.9.16 [`#653`](https://github.com/oceanprotocol/ocean-subgraph/pull/653)
|
||||
- Bump typescript from 5.0.3 to 5.0.4 [`#652`](https://github.com/oceanprotocol/ocean-subgraph/pull/652)
|
||||
- Bump vm2 from 3.9.11 to 3.9.15 [`#649`](https://github.com/oceanprotocol/ocean-subgraph/pull/649)
|
||||
- Bump release-it from 15.10.0 to 15.10.1 [`#651`](https://github.com/oceanprotocol/ocean-subgraph/pull/651)
|
||||
- Release 3.0.4 [`c8541a0`](https://github.com/oceanprotocol/ocean-subgraph/commit/c8541a071ef13d51e2e62822a194710bef660729)
|
||||
|
||||
#### [v3.0.3](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.2...v3.0.3)
|
||||
|
||||
> 6 April 2023
|
||||
|
||||
- Removing amountFraction and adding timestamp [`#647`](https://github.com/oceanprotocol/ocean-subgraph/pull/647)
|
||||
- Fixing decimals issue [`#644`](https://github.com/oceanprotocol/ocean-subgraph/pull/644)
|
||||
- Bump typescript from 5.0.2 to 5.0.3 [`#641`](https://github.com/oceanprotocol/ocean-subgraph/pull/641)
|
||||
- Bump release-it from 15.9.3 to 15.10.0 [`#640`](https://github.com/oceanprotocol/ocean-subgraph/pull/640)
|
||||
- Release 3.0.3 [`d888d7d`](https://github.com/oceanprotocol/ocean-subgraph/commit/d888d7d2566c5fa0fe21903bd16d0b5329815526)
|
||||
|
||||
#### [v3.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.1...v3.0.2)
|
||||
|
||||
> 31 March 2023
|
||||
|
||||
- Storing the fraction of veOcean [`#623`](https://github.com/oceanprotocol/ocean-subgraph/pull/623)
|
||||
- Bump eslint-config-prettier from 8.7.0 to 8.8.0 [`#637`](https://github.com/oceanprotocol/ocean-subgraph/pull/637)
|
||||
- Bump prettier from 2.8.4 to 2.8.7 [`#636`](https://github.com/oceanprotocol/ocean-subgraph/pull/636)
|
||||
- Bump release-it from 15.9.1 to 15.9.3 [`#638`](https://github.com/oceanprotocol/ocean-subgraph/pull/638)
|
||||
- Bump typescript from 4.9.5 to 5.0.2 [`#632`](https://github.com/oceanprotocol/ocean-subgraph/pull/632)
|
||||
- Bump release-it from 15.8.0 to 15.9.1 [`#634`](https://github.com/oceanprotocol/ocean-subgraph/pull/634)
|
||||
- Update ocean-lib with 2.7.0 version. [`#633`](https://github.com/oceanprotocol/ocean-subgraph/pull/633)
|
||||
- Bump eslint-config-prettier from 8.6.0 to 8.7.0 [`#625`](https://github.com/oceanprotocol/ocean-subgraph/pull/625)
|
||||
- Bump @oceanprotocol/lib from 2.6.1 to 2.6.3 [`#614`](https://github.com/oceanprotocol/ocean-subgraph/pull/614)
|
||||
- Bump release-it from 15.7.0 to 15.8.0 [`#624`](https://github.com/oceanprotocol/ocean-subgraph/pull/624)
|
||||
- Bump @oceanprotocol/contracts from 1.1.8 to 1.1.12 [`#627`](https://github.com/oceanprotocol/ocean-subgraph/pull/627)
|
||||
- Bump release-it from 15.6.0 to 15.7.0 [`#618`](https://github.com/oceanprotocol/ocean-subgraph/pull/618)
|
||||
- Update README.md [`#617`](https://github.com/oceanprotocol/ocean-subgraph/pull/617)
|
||||
- Update copyright year. [`#615`](https://github.com/oceanprotocol/ocean-subgraph/pull/615)
|
||||
- Bump prettier from 2.8.3 to 2.8.4 [`#612`](https://github.com/oceanprotocol/ocean-subgraph/pull/612)
|
||||
- Bump http-cache-semantics from 4.1.0 to 4.1.1 [`#608`](https://github.com/oceanprotocol/ocean-subgraph/pull/608)
|
||||
- Bump @graphprotocol/graph-ts from 0.29.1 to 0.29.3 [`#611`](https://github.com/oceanprotocol/ocean-subgraph/pull/611)
|
||||
- Bump typescript from 4.9.4 to 4.9.5 [`#610`](https://github.com/oceanprotocol/ocean-subgraph/pull/610)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.7 to 0.38.0 [`#609`](https://github.com/oceanprotocol/ocean-subgraph/pull/609)
|
||||
- Release 3.0.2 [`de5f1aa`](https://github.com/oceanprotocol/ocean-subgraph/commit/de5f1aab4bc70d6ec831fa0f24099666ef3c46a1)
|
||||
|
||||
#### [v3.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.0...v3.0.1)
|
||||
|
||||
> 27 January 2023
|
||||
|
||||
- fix veDeposit id generation [`#606`](https://github.com/oceanprotocol/ocean-subgraph/pull/606)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.2 to 0.37.7 [`#603`](https://github.com/oceanprotocol/ocean-subgraph/pull/603)
|
||||
- Bump eslint-plugin-import from 2.27.4 to 2.27.5 [`#602`](https://github.com/oceanprotocol/ocean-subgraph/pull/602)
|
||||
- Tracking OPC fees [`#593`](https://github.com/oceanprotocol/ocean-subgraph/pull/593)
|
||||
- Bump prettier from 2.8.2 to 2.8.3 [`#600`](https://github.com/oceanprotocol/ocean-subgraph/pull/600)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.1 to 0.37.2 [`#599`](https://github.com/oceanprotocol/ocean-subgraph/pull/599)
|
||||
- Bump eslint-plugin-import from 2.26.0 to 2.27.4 [`#601`](https://github.com/oceanprotocol/ocean-subgraph/pull/601)
|
||||
- Bump eslint-config-prettier from 8.5.0 to 8.6.0 [`#596`](https://github.com/oceanprotocol/ocean-subgraph/pull/596)
|
||||
- Bump prettier from 2.8.1 to 2.8.2 [`#597`](https://github.com/oceanprotocol/ocean-subgraph/pull/597)
|
||||
- Bump @oceanprotocol/lib from 2.6.0 to 2.6.1 [`#598`](https://github.com/oceanprotocol/ocean-subgraph/pull/598)
|
||||
- Bump json5 from 1.0.1 to 1.0.2 [`#594`](https://github.com/oceanprotocol/ocean-subgraph/pull/594)
|
||||
- Bump @graphprotocol/graph-ts from 0.29.0 to 0.29.1 [`#590`](https://github.com/oceanprotocol/ocean-subgraph/pull/590)
|
||||
- Bump @oceanprotocol/lib from 2.5.2 to 2.6.0 [`#591`](https://github.com/oceanprotocol/ocean-subgraph/pull/591)
|
||||
- Bump release-it from 15.5.1 to 15.6.0 [`#592`](https://github.com/oceanprotocol/ocean-subgraph/pull/592)
|
||||
- Bump typescript from 4.9.3 to 4.9.4 [`#586`](https://github.com/oceanprotocol/ocean-subgraph/pull/586)
|
||||
- Bump mocha from 10.1.0 to 10.2.0 [`#583`](https://github.com/oceanprotocol/ocean-subgraph/pull/583)
|
||||
- Bump qs from 6.5.2 to 6.5.3 [`#587`](https://github.com/oceanprotocol/ocean-subgraph/pull/587)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.0 to 0.37.1 [`#585`](https://github.com/oceanprotocol/ocean-subgraph/pull/585)
|
||||
- Bump prettier from 2.8.0 to 2.8.1 [`#584`](https://github.com/oceanprotocol/ocean-subgraph/pull/584)
|
||||
- Bump @graphprotocol/graph-cli from 0.36.1 to 0.37.0 [`#578`](https://github.com/oceanprotocol/ocean-subgraph/pull/578)
|
||||
- Bump decode-uri-component from 0.2.0 to 0.2.2 [`#581`](https://github.com/oceanprotocol/ocean-subgraph/pull/581)
|
||||
- Bump release-it from 15.5.0 to 15.5.1 [`#579`](https://github.com/oceanprotocol/ocean-subgraph/pull/579)
|
||||
- Bump @types/mocha from 10.0.0 to 10.0.1 [`#580`](https://github.com/oceanprotocol/ocean-subgraph/pull/580)
|
||||
- Bump prettier from 2.7.1 to 2.8.0 [`#577`](https://github.com/oceanprotocol/ocean-subgraph/pull/577)
|
||||
- Release 2.1.4 [`7c35711`](https://github.com/oceanprotocol/ocean-subgraph/commit/7c35711f722b7ea487d8b8c9aa3e42d71f2beb56)
|
||||
- Release 3.0.1 [`3de53c5`](https://github.com/oceanprotocol/ocean-subgraph/commit/3de53c519750ca40ec269ed21f7c17773b53b139)
|
||||
|
||||
### [v3.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.4...v3.0.0)
|
||||
|
||||
> 24 November 2022
|
||||
|
||||
#### [v2.1.4](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.3...v2.1.4)
|
||||
|
||||
> 27 January 2023
|
||||
|
||||
- fix veDeposit id generation [`#606`](https://github.com/oceanprotocol/ocean-subgraph/pull/606)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.2 to 0.37.7 [`#603`](https://github.com/oceanprotocol/ocean-subgraph/pull/603)
|
||||
- Bump eslint-plugin-import from 2.27.4 to 2.27.5 [`#602`](https://github.com/oceanprotocol/ocean-subgraph/pull/602)
|
||||
- Tracking OPC fees [`#593`](https://github.com/oceanprotocol/ocean-subgraph/pull/593)
|
||||
- Bump prettier from 2.8.2 to 2.8.3 [`#600`](https://github.com/oceanprotocol/ocean-subgraph/pull/600)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.1 to 0.37.2 [`#599`](https://github.com/oceanprotocol/ocean-subgraph/pull/599)
|
||||
- Bump eslint-plugin-import from 2.26.0 to 2.27.4 [`#601`](https://github.com/oceanprotocol/ocean-subgraph/pull/601)
|
||||
- Bump eslint-config-prettier from 8.5.0 to 8.6.0 [`#596`](https://github.com/oceanprotocol/ocean-subgraph/pull/596)
|
||||
- Bump prettier from 2.8.1 to 2.8.2 [`#597`](https://github.com/oceanprotocol/ocean-subgraph/pull/597)
|
||||
- Bump @oceanprotocol/lib from 2.6.0 to 2.6.1 [`#598`](https://github.com/oceanprotocol/ocean-subgraph/pull/598)
|
||||
- Bump json5 from 1.0.1 to 1.0.2 [`#594`](https://github.com/oceanprotocol/ocean-subgraph/pull/594)
|
||||
- Bump @graphprotocol/graph-ts from 0.29.0 to 0.29.1 [`#590`](https://github.com/oceanprotocol/ocean-subgraph/pull/590)
|
||||
- Bump @oceanprotocol/lib from 2.5.2 to 2.6.0 [`#591`](https://github.com/oceanprotocol/ocean-subgraph/pull/591)
|
||||
- Bump release-it from 15.5.1 to 15.6.0 [`#592`](https://github.com/oceanprotocol/ocean-subgraph/pull/592)
|
||||
- Bump typescript from 4.9.3 to 4.9.4 [`#586`](https://github.com/oceanprotocol/ocean-subgraph/pull/586)
|
||||
- Bump mocha from 10.1.0 to 10.2.0 [`#583`](https://github.com/oceanprotocol/ocean-subgraph/pull/583)
|
||||
- Bump qs from 6.5.2 to 6.5.3 [`#587`](https://github.com/oceanprotocol/ocean-subgraph/pull/587)
|
||||
- Bump @graphprotocol/graph-cli from 0.37.0 to 0.37.1 [`#585`](https://github.com/oceanprotocol/ocean-subgraph/pull/585)
|
||||
- Bump prettier from 2.8.0 to 2.8.1 [`#584`](https://github.com/oceanprotocol/ocean-subgraph/pull/584)
|
||||
- Bump @graphprotocol/graph-cli from 0.36.1 to 0.37.0 [`#578`](https://github.com/oceanprotocol/ocean-subgraph/pull/578)
|
||||
- Bump decode-uri-component from 0.2.0 to 0.2.2 [`#581`](https://github.com/oceanprotocol/ocean-subgraph/pull/581)
|
||||
- Bump release-it from 15.5.0 to 15.5.1 [`#579`](https://github.com/oceanprotocol/ocean-subgraph/pull/579)
|
||||
- Bump @types/mocha from 10.0.0 to 10.0.1 [`#580`](https://github.com/oceanprotocol/ocean-subgraph/pull/580)
|
||||
- Bump prettier from 2.7.1 to 2.8.0 [`#577`](https://github.com/oceanprotocol/ocean-subgraph/pull/577)
|
||||
- nft transfer event [`#573`](https://github.com/oceanprotocol/ocean-subgraph/pull/573)
|
||||
- add lastPriceToken [`#567`](https://github.com/oceanprotocol/ocean-subgraph/pull/567)
|
||||
- Bump typescript from 4.8.4 to 4.9.3 [`#576`](https://github.com/oceanprotocol/ocean-subgraph/pull/576)
|
||||
- Bump @graphprotocol/graph-cli from 0.35.0 to 0.36.1 [`#575`](https://github.com/oceanprotocol/ocean-subgraph/pull/575)
|
||||
- Bump @oceanprotocol/lib from 2.5.1 to 2.5.2 [`#574`](https://github.com/oceanprotocol/ocean-subgraph/pull/574)
|
||||
- Bump @graphprotocol/graph-ts from 0.28.1 to 0.29.0 [`#571`](https://github.com/oceanprotocol/ocean-subgraph/pull/571)
|
||||
- Bump chai and @types/chai [`#572`](https://github.com/oceanprotocol/ocean-subgraph/pull/572)
|
||||
- Bump @oceanprotocol/lib from 2.4.0 to 2.5.1 [`#569`](https://github.com/oceanprotocol/ocean-subgraph/pull/569)
|
||||
- Bump @oceanprotocol/lib from 2.3.0 to 2.4.0 [`#568`](https://github.com/oceanprotocol/ocean-subgraph/pull/568)
|
||||
- Bump @oceanprotocol/contracts from 1.1.7 to 1.1.8 [`#566`](https://github.com/oceanprotocol/ocean-subgraph/pull/566)
|
||||
- Bump @oceanprotocol/lib from 2.2.2 to 2.3.0 [`#565`](https://github.com/oceanprotocol/ocean-subgraph/pull/565)
|
||||
- Bump @graphprotocol/graph-ts from 0.28.0 to 0.28.1 [`#559`](https://github.com/oceanprotocol/ocean-subgraph/pull/559)
|
||||
- Bump @graphprotocol/graph-cli from 0.34.0 to 0.35.0 [`#560`](https://github.com/oceanprotocol/ocean-subgraph/pull/560)
|
||||
- Bump mocha from 10.0.0 to 10.1.0 [`#561`](https://github.com/oceanprotocol/ocean-subgraph/pull/561)
|
||||
- Bump @oceanprotocol/lib from 2.2.1 to 2.2.2 [`#562`](https://github.com/oceanprotocol/ocean-subgraph/pull/562)
|
||||
- Bump @oceanprotocol/lib from 2.1.1 to 2.2.1 [`#557`](https://github.com/oceanprotocol/ocean-subgraph/pull/557)
|
||||
- Bump release-it from 15.4.2 to 15.5.0 [`#558`](https://github.com/oceanprotocol/ocean-subgraph/pull/558)
|
||||
- Bump @types/mocha from 9.1.1 to 10.0.0 [`#556`](https://github.com/oceanprotocol/ocean-subgraph/pull/556)
|
||||
- Bump @graphprotocol/graph-cli from 0.33.1 to 0.34.0 [`#555`](https://github.com/oceanprotocol/ocean-subgraph/pull/555)
|
||||
- Bump typescript from 4.8.3 to 4.8.4 [`#554`](https://github.com/oceanprotocol/ocean-subgraph/pull/554)
|
||||
- Bump @graphprotocol/graph-ts from 0.27.0 to 0.28.0 [`#553`](https://github.com/oceanprotocol/ocean-subgraph/pull/553)
|
||||
- Release 2.1.4 [`7c35711`](https://github.com/oceanprotocol/ocean-subgraph/commit/7c35711f722b7ea487d8b8c9aa3e42d71f2beb56)
|
||||
|
||||
#### [v2.1.3](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.2...v2.1.3)
|
||||
|
||||
> 30 September 2022
|
||||
|
||||
- add chainId and nftAddress [`#552`](https://github.com/oceanprotocol/ocean-subgraph/pull/552)
|
||||
- Bump vm2 from 3.9.9 to 3.9.11 [`#550`](https://github.com/oceanprotocol/ocean-subgraph/pull/550)
|
||||
- Release 2.1.3 [`ae78cae`](https://github.com/oceanprotocol/ocean-subgraph/commit/ae78cae6083514592756f2549f21a307361d96d8)
|
||||
|
||||
#### [v2.1.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.1...v2.1.2)
|
||||
|
||||
> 28 September 2022
|
||||
|
||||
- fix tokenRemoved [`#549`](https://github.com/oceanprotocol/ocean-subgraph/pull/549)
|
||||
- Bump @oceanprotocol/lib from 2.0.2 to 2.1.1 [`#545`](https://github.com/oceanprotocol/ocean-subgraph/pull/545)
|
||||
- Bump eslint-config-oceanprotocol from 2.0.3 to 2.0.4 [`#546`](https://github.com/oceanprotocol/ocean-subgraph/pull/546)
|
||||
- Release 2.1.2 [`9209408`](https://github.com/oceanprotocol/ocean-subgraph/commit/92094086f98ebe7470f1fcbeeb297fbb695a431e)
|
||||
|
||||
#### [v2.1.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.0...v2.1.1)
|
||||
|
||||
> 26 September 2022
|
||||
|
||||
- fix allocation [`#544`](https://github.com/oceanprotocol/ocean-subgraph/pull/544)
|
||||
- Release 2.1.1 [`253dc63`](https://github.com/oceanprotocol/ocean-subgraph/commit/253dc63fa853011ed95f3501cc4cf0eed6d22f73)
|
||||
|
||||
#### [v2.1.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.7...v2.1.0)
|
||||
|
||||
> 23 September 2022
|
||||
|
||||
- Feature/more ve [`#543`](https://github.com/oceanprotocol/ocean-subgraph/pull/543)
|
||||
- Release 2.1.0 [`6c4b270`](https://github.com/oceanprotocol/ocean-subgraph/commit/6c4b2705645632b23dc90809868f25550238f2e1)
|
||||
|
||||
#### [v2.0.7](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.6...v2.0.7)
|
||||
|
||||
> 21 September 2022
|
||||
|
||||
- Feature/graphnode 27 [`#541`](https://github.com/oceanprotocol/ocean-subgraph/pull/541)
|
||||
- Add gasUsed and gasPrice to order [`#540`](https://github.com/oceanprotocol/ocean-subgraph/pull/540)
|
||||
- add goerli npm command [`#538`](https://github.com/oceanprotocol/ocean-subgraph/pull/538)
|
||||
- Bump release-it from 15.4.1 to 15.4.2 [`#535`](https://github.com/oceanprotocol/ocean-subgraph/pull/535)
|
||||
- Release 2.0.7 [`9112217`](https://github.com/oceanprotocol/ocean-subgraph/commit/91122175dc17d5f670103e193631e176b710c160)
|
||||
|
||||
#### [v2.0.6](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.5...v2.0.6)
|
||||
|
||||
> 14 September 2022
|
||||
|
||||
- fix nftUpdate critical bug [`#534`](https://github.com/oceanprotocol/ocean-subgraph/pull/534)
|
||||
- add erc725 key/value store [`#533`](https://github.com/oceanprotocol/ocean-subgraph/pull/533)
|
||||
- Release 2.0.6 [`181a4f4`](https://github.com/oceanprotocol/ocean-subgraph/commit/181a4f45d0be93140677ba96470bb33a4936d88e)
|
||||
|
||||
#### [v2.0.5](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.4...v2.0.5)
|
||||
|
||||
> 13 September 2022
|
||||
|
||||
- Feature/df rewards [`#531`](https://github.com/oceanprotocol/ocean-subgraph/pull/531)
|
||||
- nft updates [`#530`](https://github.com/oceanprotocol/ocean-subgraph/pull/530)
|
||||
- Bump typescript from 4.8.2 to 4.8.3 [`#527`](https://github.com/oceanprotocol/ocean-subgraph/pull/527)
|
||||
- Release 2.0.5 [`a74e3ed`](https://github.com/oceanprotocol/ocean-subgraph/commit/a74e3edb3a12070cbfe3caf56fbabf4f57aa8e7f)
|
||||
|
||||
#### [v2.0.4](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.3...v2.0.4)
|
||||
|
||||
> 7 September 2022
|
||||
|
||||
- update tests for new ocean.js 2.0 [`#526`](https://github.com/oceanprotocol/ocean-subgraph/pull/526)
|
||||
- Bump @graphprotocol/graph-cli from 0.33.0 to 0.33.1 [`#525`](https://github.com/oceanprotocol/ocean-subgraph/pull/525)
|
||||
- Bump release-it from 15.4.0 to 15.4.1 [`#524`](https://github.com/oceanprotocol/ocean-subgraph/pull/524)
|
||||
- Implementing first pass of veAllocate schema, handlers, and test cove… [`#490`](https://github.com/oceanprotocol/ocean-subgraph/pull/490)
|
||||
- Testing user fields [`#516`](https://github.com/oceanprotocol/ocean-subgraph/pull/516)
|
||||
- Bump json-schema from 0.2.3 to 0.4.0 [`#523`](https://github.com/oceanprotocol/ocean-subgraph/pull/523)
|
||||
- Bump release-it from 15.3.0 to 15.4.0 [`#522`](https://github.com/oceanprotocol/ocean-subgraph/pull/522)
|
||||
- Bump typescript from 4.7.4 to 4.8.2 [`#521`](https://github.com/oceanprotocol/ocean-subgraph/pull/521)
|
||||
- Bump @oceanprotocol/lib from 1.1.7 to 1.1.8 [`#519`](https://github.com/oceanprotocol/ocean-subgraph/pull/519)
|
||||
- Bump @types/chai from 4.3.2 to 4.3.3 [`#517`](https://github.com/oceanprotocol/ocean-subgraph/pull/517)
|
||||
- Bump release-it from 15.2.0 to 15.3.0 [`#518`](https://github.com/oceanprotocol/ocean-subgraph/pull/518)
|
||||
- Dispenser tests [`#514`](https://github.com/oceanprotocol/ocean-subgraph/pull/514)
|
||||
- Fixed rate exchange tests [`#513`](https://github.com/oceanprotocol/ocean-subgraph/pull/513)
|
||||
- Bump @types/chai from 4.3.1 to 4.3.2 [`#511`](https://github.com/oceanprotocol/ocean-subgraph/pull/511)
|
||||
- Bump @oceanprotocol/lib from 1.1.6 to 1.1.7 [`#512`](https://github.com/oceanprotocol/ocean-subgraph/pull/512)
|
||||
- fixed swapper change issue [`#510`](https://github.com/oceanprotocol/ocean-subgraph/pull/510)
|
||||
- Release 2.0.4 [`7a627a3`](https://github.com/oceanprotocol/ocean-subgraph/commit/7a627a3bfde4d496c26a3c0a18e8b4992210a2b2)
|
||||
|
||||
#### [v2.0.3](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.2...v2.0.3)
|
||||
|
||||
> 2 August 2022
|
||||
|
||||
- Tracking templateId [`#508`](https://github.com/oceanprotocol/ocean-subgraph/pull/508)
|
||||
- Additional tests for NFT and Datatokens [`#498`](https://github.com/oceanprotocol/ocean-subgraph/pull/498)
|
||||
- Bump mock-local-storage from 1.1.21 to 1.1.23 [`#507`](https://github.com/oceanprotocol/ocean-subgraph/pull/507)
|
||||
- Removing Pool example queries and adding new examples [`#493`](https://github.com/oceanprotocol/ocean-subgraph/pull/493)
|
||||
- Remove tracking of pools [`#492`](https://github.com/oceanprotocol/ocean-subgraph/pull/492)
|
||||
- Bump release-it from 15.1.4 to 15.2.0 [`#503`](https://github.com/oceanprotocol/ocean-subgraph/pull/503)
|
||||
- minor change [`#501`](https://github.com/oceanprotocol/ocean-subgraph/pull/501)
|
||||
- Revert "roolback deps" [`4353b15`](https://github.com/oceanprotocol/ocean-subgraph/commit/4353b153910717182930735c7bd596301132eb92)
|
||||
- roolback deps [`a8396ae`](https://github.com/oceanprotocol/ocean-subgraph/commit/a8396aec1941769c69fd462d0b318464afdb2193)
|
||||
- Release 2.0.3 [`8416d77`](https://github.com/oceanprotocol/ocean-subgraph/commit/8416d773cc2f7cd9606872c0a61f7bf782c95006)
|
||||
|
||||
#### [v2.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.1...v2.0.2)
|
||||
|
||||
> 26 July 2022
|
||||
|
||||
- add event Index to pool transactions [`#497`](https://github.com/oceanprotocol/ocean-subgraph/pull/497)
|
||||
- Bump release-it from 15.1.3 to 15.1.4 [`#499`](https://github.com/oceanprotocol/ocean-subgraph/pull/499)
|
||||
- Bump @graphprotocol/graph-cli from 0.29.0 to 0.33.0 [`#495`](https://github.com/oceanprotocol/ocean-subgraph/pull/495)
|
||||
- Bump typescript from 4.6.4 to 4.7.4 [`#461`](https://github.com/oceanprotocol/ocean-subgraph/pull/461)
|
||||
- Bump release-it from 15.1.2 to 15.1.3 [`#496`](https://github.com/oceanprotocol/ocean-subgraph/pull/496)
|
||||
- Bump release-it from 15.1.1 to 15.1.2 [`#489`](https://github.com/oceanprotocol/ocean-subgraph/pull/489)
|
||||
- Bump @oceanprotocol/lib from 1.1.5 to 1.1.6 [`#488`](https://github.com/oceanprotocol/ocean-subgraph/pull/488)
|
||||
- Issue 471 provider fees [`#474`](https://github.com/oceanprotocol/ocean-subgraph/pull/474)
|
||||
- Bump parse-url from 6.0.0 to 6.0.2 [`#485`](https://github.com/oceanprotocol/ocean-subgraph/pull/485)
|
||||
- Bump @oceanprotocol/lib from 1.1.3 to 1.1.5 [`#481`](https://github.com/oceanprotocol/ocean-subgraph/pull/481)
|
||||
- Bump release-it from 15.1.0 to 15.1.1 [`#479`](https://github.com/oceanprotocol/ocean-subgraph/pull/479)
|
||||
- Bump eslint-plugin-prettier from 4.0.0 to 4.2.1 [`#478`](https://github.com/oceanprotocol/ocean-subgraph/pull/478)
|
||||
- Revert "Removing pools from schema" [`493a6d2`](https://github.com/oceanprotocol/ocean-subgraph/commit/493a6d25461b163c52b08358b62ba17a77cee41f)
|
||||
- Removing pools from schema [`0b8f6e1`](https://github.com/oceanprotocol/ocean-subgraph/commit/0b8f6e1af510c8164f56bd81687012c8a23665b6)
|
||||
- Revert "Removing pool events from subgraph.template.yaml" [`a733b27`](https://github.com/oceanprotocol/ocean-subgraph/commit/a733b27fa134073073390829d6c3e9ae939bb337)
|
||||
|
||||
#### [v2.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.0...v2.0.1)
|
||||
|
||||
> 30 June 2022
|
||||
|
||||
- changing lastPriceToken from token to string [`#477`](https://github.com/oceanprotocol/ocean-subgraph/pull/477)
|
||||
- Release 2.0.1 [`cb98901`](https://github.com/oceanprotocol/ocean-subgraph/commit/cb9890122c02cb42b4fc374892c010e6f7166b8e)
|
||||
|
||||
### [v2.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v1.2.1...v2.0.0)
|
||||
|
||||
> 29 June 2022
|
||||
|
||||
- Release 2.0.0 [`d864a5a`](https://github.com/oceanprotocol/ocean-subgraph/commit/d864a5ade7ebcf1067cd7a930b268d75833aa536)
|
||||
|
||||
#### [v1.2.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v1.2.0...v1.2.1)
|
||||
|
||||
> 29 June 2022
|
||||
|
||||
- changing the type of lastPriceToken from string to Token on Order [`#462`](https://github.com/oceanprotocol/ocean-subgraph/pull/462)
|
||||
- Bump @oceanprotocol/lib from 1.1.2 to 1.1.3 [`#470`](https://github.com/oceanprotocol/ocean-subgraph/pull/470)
|
||||
- Bump release-it from 15.0.0 to 15.1.0 [`#469`](https://github.com/oceanprotocol/ocean-subgraph/pull/469)
|
||||
- fix weight [`#468`](https://github.com/oceanprotocol/ocean-subgraph/pull/468)
|
||||
- Tracking transfer event & updating nft owner [`#436`](https://github.com/oceanprotocol/ocean-subgraph/pull/436)
|
||||
- add version [`#455`](https://github.com/oceanprotocol/ocean-subgraph/pull/455)
|
||||
- create token [`#467`](https://github.com/oceanprotocol/ocean-subgraph/pull/467)
|
||||
- update graph-node [`#457`](https://github.com/oceanprotocol/ocean-subgraph/pull/457)
|
||||
- Bump prettier from 2.6.2 to 2.7.1 [`#458`](https://github.com/oceanprotocol/ocean-subgraph/pull/458)
|
||||
- Bump @oceanprotocol/lib from 1.0.0 to 1.1.2 [`#460`](https://github.com/oceanprotocol/ocean-subgraph/pull/460)
|
||||
- Bump eslint-config-oceanprotocol from 2.0.1 to 2.0.3 [`#459`](https://github.com/oceanprotocol/ocean-subgraph/pull/459)
|
||||
- Using main branch of barge for tests [`#464`](https://github.com/oceanprotocol/ocean-subgraph/pull/464)
|
||||
- fix [`#456`](https://github.com/oceanprotocol/ocean-subgraph/pull/456)
|
||||
- fix [`#454`](https://github.com/oceanprotocol/ocean-subgraph/pull/454)
|
||||
- fix global stats pool count [`#453`](https://github.com/oceanprotocol/ocean-subgraph/pull/453)
|
||||
- Bump @oceanprotocol/lib from 1.0.0-next.45 to 1.0.0 [`#452`](https://github.com/oceanprotocol/ocean-subgraph/pull/452)
|
||||
- latest contracts&ocean.js [`#449`](https://github.com/oceanprotocol/ocean-subgraph/pull/449)
|
||||
- Bump @graphprotocol/graph-ts from 0.26.0 to 0.27.0 [`#442`](https://github.com/oceanprotocol/ocean-subgraph/pull/442)
|
||||
- add reuse order [`#444`](https://github.com/oceanprotocol/ocean-subgraph/pull/444)
|
||||
- bump to ocean.js 44 [`#439`](https://github.com/oceanprotocol/ocean-subgraph/pull/439)
|
||||
- bump ocean.js [`#438`](https://github.com/oceanprotocol/ocean-subgraph/pull/438)
|
||||
- Renaming consumeFee to orderFee [`#434`](https://github.com/oceanprotocol/ocean-subgraph/pull/434)
|
||||
- Bump eslint-config-oceanprotocol from 1.5.0 to 2.0.1 [`#435`](https://github.com/oceanprotocol/ocean-subgraph/pull/435)
|
||||
- removing Vesting and opcFee [`#432`](https://github.com/oceanprotocol/ocean-subgraph/pull/432)
|
||||
- Updating readme example queries [`#431`](https://github.com/oceanprotocol/ocean-subgraph/pull/431)
|
||||
- bump ocean.js & add polygon [`#429`](https://github.com/oceanprotocol/ocean-subgraph/pull/429)
|
||||
- Bump async from 2.6.3 to 2.6.4 [`#419`](https://github.com/oceanprotocol/ocean-subgraph/pull/419)
|
||||
- Bump release-it from 14.14.2 to 15.0.0 [`#420`](https://github.com/oceanprotocol/ocean-subgraph/pull/420)
|
||||
- Bump @types/mocha from 9.1.0 to 9.1.1 [`#424`](https://github.com/oceanprotocol/ocean-subgraph/pull/424)
|
||||
- Bump typescript from 4.6.3 to 4.6.4 [`#422`](https://github.com/oceanprotocol/ocean-subgraph/pull/422)
|
||||
- Bump mocha from 9.2.2 to 10.0.0 [`#423`](https://github.com/oceanprotocol/ocean-subgraph/pull/423)
|
||||
- Bump eslint-plugin-import from 2.24.2 to 2.26.0 [`#409`](https://github.com/oceanprotocol/ocean-subgraph/pull/409)
|
||||
- Bump @types/chai from 4.3.0 to 4.3.1 [`#412`](https://github.com/oceanprotocol/ocean-subgraph/pull/412)
|
||||
- Bump release-it from 14.14.0 to 14.14.2 [`#414`](https://github.com/oceanprotocol/ocean-subgraph/pull/414)
|
||||
- cleanup [`#417`](https://github.com/oceanprotocol/ocean-subgraph/pull/417)
|
||||
- Fix README subgraph links [`#407`](https://github.com/oceanprotocol/ocean-subgraph/pull/407)
|
||||
- fix [`#405`](https://github.com/oceanprotocol/ocean-subgraph/pull/405)
|
||||
- convert spot price from wei [`#403`](https://github.com/oceanprotocol/ocean-subgraph/pull/403)
|
||||
- Bump ansi-regex from 3.0.0 to 3.0.1 [`#402`](https://github.com/oceanprotocol/ocean-subgraph/pull/402)
|
||||
- bump contracts to alpha28 and ocean.js to alpha 33 [`#401`](https://github.com/oceanprotocol/ocean-subgraph/pull/401)
|
||||
- Bump mock-local-storage from 1.1.20 to 1.1.21 [`#398`](https://github.com/oceanprotocol/ocean-subgraph/pull/398)
|
||||
- Bump release-it from 14.13.1 to 14.14.0 [`#397`](https://github.com/oceanprotocol/ocean-subgraph/pull/397)
|
||||
- Bump prettier from 2.6.1 to 2.6.2 [`#399`](https://github.com/oceanprotocol/ocean-subgraph/pull/399)
|
||||
- fix setup [`#396`](https://github.com/oceanprotocol/ocean-subgraph/pull/396)
|
||||
- Bump prettier from 2.5.1 to 2.6.1 [`#387`](https://github.com/oceanprotocol/ocean-subgraph/pull/387)
|
||||
- Bump minimist from 1.2.5 to 1.2.6 [`#393`](https://github.com/oceanprotocol/ocean-subgraph/pull/393)
|
||||
- Bump typescript from 4.6.2 to 4.6.3 [`#388`](https://github.com/oceanprotocol/ocean-subgraph/pull/388)
|
||||
- Bump release-it from 14.12.5 to 14.13.1 [`#389`](https://github.com/oceanprotocol/ocean-subgraph/pull/389)
|
||||
- fix pool exit values [`#392`](https://github.com/oceanprotocol/ocean-subgraph/pull/392)
|
||||
- fix liquidity [`#383`](https://github.com/oceanprotocol/ocean-subgraph/pull/383)
|
||||
- Bump @graphprotocol/graph-cli from 0.26.0 to 0.29.0 [`#384`](https://github.com/oceanprotocol/ocean-subgraph/pull/384)
|
||||
- Bump mocha from 9.2.1 to 9.2.2 [`#378`](https://github.com/oceanprotocol/ocean-subgraph/pull/378)
|
||||
- Bump typescript from 4.5.5 to 4.6.2 [`#376`](https://github.com/oceanprotocol/ocean-subgraph/pull/376)
|
||||
- Bump @graphprotocol/graph-ts from 0.24.1 to 0.26.0 [`#379`](https://github.com/oceanprotocol/ocean-subgraph/pull/379)
|
||||
- bump ocean.js [`#382`](https://github.com/oceanprotocol/ocean-subgraph/pull/382)
|
||||
- Feature/bump oceanlib to next 27 [`#375`](https://github.com/oceanprotocol/ocean-subgraph/pull/375)
|
||||
- Bump release-it from 14.12.4 to 14.12.5 [`#364`](https://github.com/oceanprotocol/ocean-subgraph/pull/364)
|
||||
- Bump eslint-config-prettier from 8.4.0 to 8.5.0 [`#370`](https://github.com/oceanprotocol/ocean-subgraph/pull/370)
|
||||
- Feature/lastprices [`#369`](https://github.com/oceanprotocol/ocean-subgraph/pull/369)
|
||||
- fix lp fee and publish market fee [`#368`](https://github.com/oceanprotocol/ocean-subgraph/pull/368)
|
||||
- fix liquidity [`#363`](https://github.com/oceanprotocol/ocean-subgraph/pull/363)
|
||||
- fix poolSnapshot [`#361`](https://github.com/oceanprotocol/ocean-subgraph/pull/361)
|
||||
- fix nft on updates [`#359`](https://github.com/oceanprotocol/ocean-subgraph/pull/359)
|
||||
- Fix poolSnapshot and fixed rate balance [`#357`](https://github.com/oceanprotocol/ocean-subgraph/pull/357)
|
||||
- add vesting details [`#353`](https://github.com/oceanprotocol/ocean-subgraph/pull/353)
|
||||
- closes #351 [`#352`](https://github.com/oceanprotocol/ocean-subgraph/pull/352)
|
||||
- Feature/templates [`#349`](https://github.com/oceanprotocol/ocean-subgraph/pull/349)
|
||||
- Bump eslint-config-prettier from 8.3.0 to 8.4.0 [`#348`](https://github.com/oceanprotocol/ocean-subgraph/pull/348)
|
||||
- Bump prettier from 2.4.1 to 2.5.1 [`#342`](https://github.com/oceanprotocol/ocean-subgraph/pull/342)
|
||||
- Bump mocha from 9.1.3 to 9.2.1 [`#343`](https://github.com/oceanprotocol/ocean-subgraph/pull/343)
|
||||
- Bump @types/mocha from 9.0.0 to 9.1.0 [`#344`](https://github.com/oceanprotocol/ocean-subgraph/pull/344)
|
||||
- Bump auto-changelog from 2.3.0 to 2.4.0 [`#345`](https://github.com/oceanprotocol/ocean-subgraph/pull/345)
|
||||
- Bump release-it from 14.11.6 to 14.12.4 [`#346`](https://github.com/oceanprotocol/ocean-subgraph/pull/346)
|
||||
- dispenser updates [`#341`](https://github.com/oceanprotocol/ocean-subgraph/pull/341)
|
||||
- add fixedrate balances [`#339`](https://github.com/oceanprotocol/ocean-subgraph/pull/339)
|
||||
- OPC fees [`#337`](https://github.com/oceanprotocol/ocean-subgraph/pull/337)
|
||||
- roles [`#336`](https://github.com/oceanprotocol/ocean-subgraph/pull/336)
|
||||
- add user totalSales and totalOrders [`#333`](https://github.com/oceanprotocol/ocean-subgraph/pull/333)
|
||||
- add nft.orderCount [`#332`](https://github.com/oceanprotocol/ocean-subgraph/pull/332)
|
||||
- Feature/fix scripts [`#331`](https://github.com/oceanprotocol/ocean-subgraph/pull/331)
|
||||
- Feature/fees [`#330`](https://github.com/oceanprotocol/ocean-subgraph/pull/330)
|
||||
- Bump mocha from 9.1.2 to 9.2.0 (#306) [`#322`](https://github.com/oceanprotocol/ocean-subgraph/pull/322)
|
||||
- Bump @types/chai from 4.2.22 to 4.3.0 [`#328`](https://github.com/oceanprotocol/ocean-subgraph/pull/328)
|
||||
- Bump typescript from 4.4.3 to 4.5.5 [`#329`](https://github.com/oceanprotocol/ocean-subgraph/pull/329)
|
||||
- Bump keypair from 1.0.3 to 1.0.4 [`#325`](https://github.com/oceanprotocol/ocean-subgraph/pull/325)
|
||||
- Bump mocha from 9.1.2 to 9.2.0 (#306) [`#324`](https://github.com/oceanprotocol/ocean-subgraph/pull/324)
|
||||
- bump ocean.js [`#327`](https://github.com/oceanprotocol/ocean-subgraph/pull/327)
|
||||
- Global stats [`#319`](https://github.com/oceanprotocol/ocean-subgraph/pull/319)
|
||||
- fee update [`#321`](https://github.com/oceanprotocol/ocean-subgraph/pull/321)
|
||||
- update netwroks [`#318`](https://github.com/oceanprotocol/ocean-subgraph/pull/318)
|
||||
- bump ocean.js to next 18 [`#317`](https://github.com/oceanprotocol/ocean-subgraph/pull/317)
|
||||
- refactor [`#314`](https://github.com/oceanprotocol/ocean-subgraph/pull/314)
|
||||
- fix build [`#308`](https://github.com/oceanprotocol/ocean-subgraph/pull/308)
|
||||
- schema updates [`#307`](https://github.com/oceanprotocol/ocean-subgraph/pull/307)
|
||||
- Fix/nft update [`#304`](https://github.com/oceanprotocol/ocean-subgraph/pull/304)
|
||||
- up [`#302`](https://github.com/oceanprotocol/ocean-subgraph/pull/302)
|
||||
- Various fixes [`#294`](https://github.com/oceanprotocol/ocean-subgraph/pull/294)
|
||||
- Fix pools [`#287`](https://github.com/oceanprotocol/ocean-subgraph/pull/287)
|
||||
- Fix bugs [`#286`](https://github.com/oceanprotocol/ocean-subgraph/pull/286)
|
||||
- Feature/bump libs [`#255`](https://github.com/oceanprotocol/ocean-subgraph/pull/255)
|
||||
- closes #351 (#352) [`#351`](https://github.com/oceanprotocol/ocean-subgraph/issues/351)
|
||||
- basic events [`b39ecb6`](https://github.com/oceanprotocol/ocean-subgraph/commit/b39ecb6e12e508cf745529ffdeb1ed0e58ff83fe)
|
||||
- mostly pool stuff [`3eeba28`](https://github.com/oceanprotocol/ocean-subgraph/commit/3eeba287fb14b8079f11540e8dedbb98d8e0c21b)
|
||||
- updates [`64cdaf8`](https://github.com/oceanprotocol/ocean-subgraph/commit/64cdaf8993caf8de37594012e8056d7d2948dedc)
|
||||
|
||||
#### [v1.2.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v1.1.2...v1.2.0)
|
||||
|
||||
> 6 October 2021
|
||||
|
||||
- Bump @oceanprotocol/lib from 0.17.4 to 0.19.2 [`#246`](https://github.com/oceanprotocol/ocean-subgraph/pull/246)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.32.0 to 4.33.0 [`#248`](https://github.com/oceanprotocol/ocean-subgraph/pull/248)
|
||||
- Bump mocha from 9.1.1 to 9.1.2 [`#247`](https://github.com/oceanprotocol/ocean-subgraph/pull/247)
|
||||
- add EnergyWeb, Moonriver & Celo Alfajores [`#239`](https://github.com/oceanprotocol/ocean-subgraph/pull/239)
|
||||
- Bump @typescript-eslint/parser from 4.31.1 to 4.33.0 [`#245`](https://github.com/oceanprotocol/ocean-subgraph/pull/245)
|
||||
- Bump release-it from 14.11.5 to 14.11.6 [`#244`](https://github.com/oceanprotocol/ocean-subgraph/pull/244)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.31.1 to 4.32.0 [`#242`](https://github.com/oceanprotocol/ocean-subgraph/pull/242)
|
||||
- add nr of sales for user [`#231`](https://github.com/oceanprotocol/ocean-subgraph/pull/231)
|
||||
- add catenax & bump ocean.js [`#227`](https://github.com/oceanprotocol/ocean-subgraph/pull/227)
|
||||
- Bump typescript from 4.4.2 to 4.4.3 [`#223`](https://github.com/oceanprotocol/ocean-subgraph/pull/223)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.29.3 to 4.31.0 [`#222`](https://github.com/oceanprotocol/ocean-subgraph/pull/222)
|
||||
- Bump @oceanprotocol/lib from 0.17.1 to 0.17.3 [`#216`](https://github.com/oceanprotocol/ocean-subgraph/pull/216)
|
||||
- Bump @typescript-eslint/parser from 4.30.0 to 4.31.0 [`#221`](https://github.com/oceanprotocol/ocean-subgraph/pull/221)
|
||||
- Bump prettier from 2.3.2 to 2.4.0 [`#220`](https://github.com/oceanprotocol/ocean-subgraph/pull/220)
|
||||
- Bump eslint-plugin-prettier from 3.4.1 to 4.0.0 [`#217`](https://github.com/oceanprotocol/ocean-subgraph/pull/217)
|
||||
- Bump @typescript-eslint/parser from 4.29.0 to 4.30.0 [`#215`](https://github.com/oceanprotocol/ocean-subgraph/pull/215)
|
||||
- Bump mocha from 9.0.3 to 9.1.1 [`#210`](https://github.com/oceanprotocol/ocean-subgraph/pull/210)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.3 [`#209`](https://github.com/oceanprotocol/ocean-subgraph/pull/209)
|
||||
- Bump typescript from 4.3.5 to 4.4.2 [`#211`](https://github.com/oceanprotocol/ocean-subgraph/pull/211)
|
||||
- Bump eslint-plugin-prettier from 3.4.0 to 3.4.1 [`#206`](https://github.com/oceanprotocol/ocean-subgraph/pull/206)
|
||||
- fix id [`#214`](https://github.com/oceanprotocol/ocean-subgraph/pull/214)
|
||||
- Bump release-it from 14.11.0 to 14.11.5 [`#203`](https://github.com/oceanprotocol/ocean-subgraph/pull/203)
|
||||
- Added baseTokenSymbol to FixedRateExchange [`#201`](https://github.com/oceanprotocol/ocean-subgraph/pull/201)
|
||||
- Bump @oceanprotocol/lib from 0.17.0 to 0.17.1 [`#189`](https://github.com/oceanprotocol/ocean-subgraph/pull/189)
|
||||
- add nvmrc [`#199`](https://github.com/oceanprotocol/ocean-subgraph/pull/199)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.28.5 to 4.29.1 [`#198`](https://github.com/oceanprotocol/ocean-subgraph/pull/198)
|
||||
- Bump release-it from 14.10.1 to 14.11.0 [`#187`](https://github.com/oceanprotocol/ocean-subgraph/pull/187)
|
||||
- Bump @typescript-eslint/parser from 4.28.5 to 4.29.0 [`#188`](https://github.com/oceanprotocol/ocean-subgraph/pull/188)
|
||||
- Manual bump test [`#181`](https://github.com/oceanprotocol/ocean-subgraph/pull/181)
|
||||
- Bump @typescript-eslint/parser from 4.28.4 to 4.28.5 [`#183`](https://github.com/oceanprotocol/ocean-subgraph/pull/183)
|
||||
- Bump eslint from 7.31.0 to 7.32.0 [`#185`](https://github.com/oceanprotocol/ocean-subgraph/pull/185)
|
||||
- Add swap volume, consume volume to subgraph [`#64`](https://github.com/oceanprotocol/ocean-subgraph/pull/64)
|
||||
- add token name symbol to pools [`#61`](https://github.com/oceanprotocol/ocean-subgraph/pull/61)
|
||||
- Bump @types/mocha from 8.2.3 to 9.0.0 [`#176`](https://github.com/oceanprotocol/ocean-subgraph/pull/176)
|
||||
- Bump @typescript-eslint/parser from 4.28.3 to 4.28.4 [`#177`](https://github.com/oceanprotocol/ocean-subgraph/pull/177)
|
||||
- Bump mocha from 9.0.2 to 9.0.3 [`#171`](https://github.com/oceanprotocol/ocean-subgraph/pull/171)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.28.3 to 4.28.4 [`#173`](https://github.com/oceanprotocol/ocean-subgraph/pull/173)
|
||||
- Bump release-it from 14.10.0 to 14.10.1 [`#172`](https://github.com/oceanprotocol/ocean-subgraph/pull/172)
|
||||
- Bump eslint from 7.30.0 to 7.31.0 [`#170`](https://github.com/oceanprotocol/ocean-subgraph/pull/170)
|
||||
- Feature: add Ploygon and Bsc in supported networks [`#168`](https://github.com/oceanprotocol/ocean-subgraph/pull/168)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.28.2 to 4.28.3 [`#166`](https://github.com/oceanprotocol/ocean-subgraph/pull/166)
|
||||
- Bump @typescript-eslint/parser from 4.28.0 to 4.28.3 [`#165`](https://github.com/oceanprotocol/ocean-subgraph/pull/165)
|
||||
- Bump @types/chai from 4.2.19 to 4.2.21 [`#164`](https://github.com/oceanprotocol/ocean-subgraph/pull/164)
|
||||
- Bump mocha from 9.0.1 to 9.0.2 [`#161`](https://github.com/oceanprotocol/ocean-subgraph/pull/161)
|
||||
- Bump @types/mocha from 8.2.2 to 8.2.3 [`#160`](https://github.com/oceanprotocol/ocean-subgraph/pull/160)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.28.0 to 4.28.2 [`#162`](https://github.com/oceanprotocol/ocean-subgraph/pull/162)
|
||||
- Bump eslint from 7.29.0 to 7.30.0 [`#156`](https://github.com/oceanprotocol/ocean-subgraph/pull/156)
|
||||
- Bump prettier from 2.3.1 to 2.3.2 [`#152`](https://github.com/oceanprotocol/ocean-subgraph/pull/152)
|
||||
- Bump @graphprotocol/graph-ts from 0.20.0 to 0.20.1 [`#155`](https://github.com/oceanprotocol/ocean-subgraph/pull/155)
|
||||
- Bump typescript from 4.3.4 to 4.3.5 [`#154`](https://github.com/oceanprotocol/ocean-subgraph/pull/154)
|
||||
- new moonbeam alpha deployment [`#158`](https://github.com/oceanprotocol/ocean-subgraph/pull/158)
|
||||
- Bump @typescript-eslint/parser from 4.26.1 to 4.28.0 [`#151`](https://github.com/oceanprotocol/ocean-subgraph/pull/151)
|
||||
- Bump @typescript-eslint/eslint-plugin from 4.26.1 to 4.28.0 [`#150`](https://github.com/oceanprotocol/ocean-subgraph/pull/150)
|
||||
- Bump mocha from 9.0.0 to 9.0.1 [`#149`](https://github.com/oceanprotocol/ocean-subgraph/pull/149)
|
||||
- Bump @types/chai from 4.2.18 to 4.2.19 [`#148`](https://github.com/oceanprotocol/ocean-subgraph/pull/148)
|
||||
- Bump typescript from 4.3.2 to 4.3.4 [`#146`](https://github.com/oceanprotocol/ocean-subgraph/pull/146)
|
||||
- Bump release-it from 14.8.0 to 14.10.0 [`#145`](https://github.com/oceanprotocol/ocean-subgraph/pull/145)
|
||||
- Bump eslint from 7.28.0 to 7.29.0 [`#144`](https://github.com/oceanprotocol/ocean-subgraph/pull/144)
|
||||
- Bump @typescript-eslint/parser from 4.26.1 to 4.27.0 [`#143`](https://github.com/oceanprotocol/ocean-subgraph/pull/143)
|
||||
- Bump @graphprotocol/graph-cli from 0.20.0 to 0.20.1 [`#141`](https://github.com/oceanprotocol/ocean-subgraph/pull/141)
|
||||
- Use debug instead of info [`#147`](https://github.com/oceanprotocol/ocean-subgraph/pull/147)
|
||||
- Release 1.2.0 [`c5aae69`](https://github.com/oceanprotocol/ocean-subgraph/commit/c5aae693d2fbb97c9b3cdb09d0d88c93bfe8d998)
|
||||
- fix gaia-x abi [`931cbe0`](https://github.com/oceanprotocol/ocean-subgraph/commit/931cbe0ac016ac50abc24f2d73a76a44515d3e9f)
|
||||
- fix bsc yaml [`2a65774`](https://github.com/oceanprotocol/ocean-subgraph/commit/2a65774abb9950109e7a2b2f60c7f2be2bcd5398)
|
||||
|
||||
#### [v1.1.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v1.1.1...v1.1.2)
|
||||
|
||||
> 10 June 2021
|
||||
|
||||
- add Gaia-X testnet, BSC & Mumbai [`#140`](https://github.com/oceanprotocol/ocean-subgraph/pull/140)
|
||||
- Bump prettier from 2.3.0 to 2.3.1 [`#138`](https://github.com/oceanprotocol/ocean-subgraph/pull/138)
|
||||
- Bump @typescript-eslint/parser from 4.25.0 to 4.26.1 [`#135`](https://github.com/oceanprotocol/ocean-subgraph/pull/135)
|
||||
|
@ -38,6 +563,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|||
- Bump eslint from 7.24.0 to 7.25.0 [`#96`](https://github.com/oceanprotocol/ocean-subgraph/pull/96)
|
||||
- Issue 92 readme improvements [`#93`](https://github.com/oceanprotocol/ocean-subgraph/pull/93)
|
||||
- Bump eslint-plugin-prettier from 3.3.1 to 3.4.0 [`#88`](https://github.com/oceanprotocol/ocean-subgraph/pull/88)
|
||||
- Release 1.1.2 [`d073f2d`](https://github.com/oceanprotocol/ocean-subgraph/commit/d073f2dc33935abb3e7cc153616317870bac51bf)
|
||||
- Add ADDRESS_FILE env docs [`81c5ad7`](https://github.com/oceanprotocol/ocean-subgraph/commit/81c5ad782e2dc1eb0cf0d52bc62ab699f179427b)
|
||||
- Update README.md [`8aebc1f`](https://github.com/oceanprotocol/ocean-subgraph/commit/8aebc1f26f938f43ad1fe1487982cec3f992f998)
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
FROM ubuntu:20.04 as base
|
||||
RUN apt-get update && apt-get -y install bash curl
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
|
||||
RUN bash /tmp/nodesource_setup.sh
|
||||
RUN apt install nodejs
|
||||
|
||||
|
||||
|
||||
FROM base as builder
|
||||
RUN apt-get update && apt-get -y install wget
|
||||
COPY package*.json /usr/src/app/
|
||||
WORKDIR /usr/src/app/
|
||||
ENV NODE_ENV=production
|
||||
RUN npm ci
|
||||
|
||||
|
||||
FROM base as runner
|
||||
ENV NODE_ENV=production
|
||||
COPY . /usr/src/app
|
||||
WORKDIR /usr/src/app/
|
||||
COPY --from=builder /usr/src/app/node_modules/ /usr/src/app/node_modules/
|
||||
ENV DEPLOY_SUBGRAPH=true
|
||||
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
|
155
README.md
155
README.md
|
@ -18,8 +18,8 @@
|
|||
|
||||
- [🏄 Get Started](#-get-started)
|
||||
- [⛵ Example Queries](#-example-queries)
|
||||
- [🏊 Development](#-development)
|
||||
- [🏊 Development on barge](#-development-on-barge)
|
||||
- [🏊 Deploying graphs for live networks](#-Deploying-graphs-for-live-networks)
|
||||
- [🔍 Testing](#-testing)
|
||||
- [✨ Code Style](#-code-style)
|
||||
- [🛳 Releases](#️-releases)
|
||||
|
@ -30,95 +30,91 @@
|
|||
|
||||
This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/` namespace for all networks the Ocean Protocol contracts are deployed to:
|
||||
|
||||
- [subgraph.mainnet.oceanprotocol.com](https://subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [subgraph.ropsten.oceanprotocol.com](https://subgraph.ropsten.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [subgraph.rinkeby.oceanprotocol.com](https://subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [subgraph.polygon.oceanprotocol.com](https://subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [subgraph.bsc.oceanprotocol.com](https://subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.mainnet.oceanprotocol.com](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.polygon.oceanprotocol.com](https://v4.subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.bsc.oceanprotocol.com](https://v4.subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.moonriver.oceanprotocol.com](https://v4.subgraph.moonriver.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.energyweb.oceanprotocol.com](https://v4.subgraph.energyweb.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.mumbai.oceanprotocol.com](https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
|
||||
## ⛵ Example Queries
|
||||
|
||||
**All pools**
|
||||
**All Data NFTs**
|
||||
|
||||
```graphql
|
||||
{
|
||||
pools(orderBy: oceanReserve, orderDirection: desc) {
|
||||
consumePrice
|
||||
datatokenReserve
|
||||
oceanReserve
|
||||
spotPrice
|
||||
swapFee
|
||||
transactionCount
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**All datatokens**
|
||||
|
||||
```graphql
|
||||
{
|
||||
datatokens(orderBy: createTime, orderDirection: desc) {
|
||||
address
|
||||
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
cap
|
||||
supply
|
||||
publisher
|
||||
holderCount
|
||||
creator
|
||||
createdTimestamp
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**All pool transactions for a given user**
|
||||
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||
|
||||
**Total Orders for Each User**
|
||||
|
||||
```graphql
|
||||
{
|
||||
poolTransactions(
|
||||
where: { userAddressStr: $userAddress }
|
||||
orderBy: timestamp
|
||||
orderDirection: desc
|
||||
) {
|
||||
poolAddressStr
|
||||
users(first: 1000) {
|
||||
id
|
||||
totalOrders
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> Note: all ETH addresses like `$userAddress` in above example need to be passed in lowercase.
|
||||
**Total Orders for All Users**
|
||||
|
||||
## 🏊 Development
|
||||
|
||||
First, clone the repo and install dependencies:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/oceanprotocol/ocean-subgraph/
|
||||
cd ocean-subgraph
|
||||
npm i
|
||||
```graphql
|
||||
{
|
||||
users(first: 1000) {
|
||||
id
|
||||
totalOrders
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Developing and testing any change requires them to be deployed against a locally running graph-node and some other components running in Docker. Make sure you have Docker and Docker Compose installed on your machine, then prepare the Docker setup:
|
||||
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
./setup.sh
|
||||
**Total Orders for a Specific User**
|
||||
|
||||
```graphql
|
||||
{
|
||||
user(id: $user) {
|
||||
id
|
||||
totalOrders
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then add your Infura key as environment variable with a `.env` file, and start everything up with Docker Compose:
|
||||
> Note: all ETH addresses like `$user` in above example need to be passed as a lowercase string.
|
||||
|
||||
```bash
|
||||
# create .env and modify
|
||||
cp .env.example .env
|
||||
**All Orders**
|
||||
|
||||
docker-compose --env-file .env up
|
||||
```
|
||||
{
|
||||
orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
|
||||
amount
|
||||
datatoken {
|
||||
id
|
||||
}
|
||||
consumer {
|
||||
id
|
||||
}
|
||||
payer {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The default network for development is set to Rinkeby. If you want to switch to another network you have to modify the `docker/docker-compose.yml` file within `environment.ethereum`.
|
||||
|
||||
You now have a local graph-node running and can start deploying your changes to it. To do so, follow the [Deployment instructions](#️-deployment).
|
||||
|
||||
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||
|
||||
## 🏊 Development on Barge
|
||||
|
||||
|
||||
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
|
||||
|
||||
```bash
|
||||
|
@ -137,35 +133,54 @@ cd ocean-subgraph
|
|||
npm i
|
||||
```
|
||||
|
||||
3. Let the components know where to pickup the smart contract addresses:
|
||||
3. Let the components know where to pickup the smart contract addresses.
|
||||
|
||||
```
|
||||
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||
```
|
||||
|
||||
4. Generate the subgraph
|
||||
4. Generate the subgraphs
|
||||
|
||||
```bash
|
||||
node ./scripts/generatenetworkssubgraphs.js barge
|
||||
npm run codegen
|
||||
npm run bargesetup
|
||||
```
|
||||
|
||||
5. To deploy a subgraph connected to Barge, use:
|
||||
5. To deploy a subgraph use:
|
||||
|
||||
```bash
|
||||
npm run create:local-barge
|
||||
npm run deploy:local-barge
|
||||
|
||||
```bash
|
||||
npm run create:local
|
||||
npm run deploy:local
|
||||
```
|
||||
|
||||
- Alternatively, if you want to get the sub-graph quickly running on barge, you can run `npm run quickstart:barge` which combines steps 3-5 above.
|
||||
- Alternatively, if you want to get the sub-graph quickly running on barge, you can run `npm run quickstart:barge` which combines steps 4-5 above.
|
||||
|
||||
You now have a local graph-node running on http://localhost:9000
|
||||
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
||||
|
||||
## 🏊 Deploying graphs for live networks
|
||||
|
||||
1. Clone the repo and install dependencies:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/oceanprotocol/ocean-subgraph/
|
||||
cd ocean-subgraph
|
||||
npm i
|
||||
```
|
||||
|
||||
2. Generate & deploy on rinkeby
|
||||
|
||||
```bash
|
||||
npm run quickstart:rinkeby
|
||||
```
|
||||
|
||||
## 🔍 Testing
|
||||
|
||||
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).
|
||||
|
||||
To run the integration tests locally, first start up barge by following the instructions above, then run the following terminal commands from the ocean-subgraph folder:
|
||||
To run the integration tests locally, first start up barge by following the instructions above, then run the following terminal commands from the ocean-subgraph folder:
|
||||
|
||||
```Bash
|
||||
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||
|
@ -186,8 +201,8 @@ npm run format
|
|||
|
||||
## 🛳 Releases
|
||||
|
||||
Releases are managed semi-automatically. They are always manually triggered from a developer's
|
||||
machine with release scripts. From a clean `main` branch you can run the release task bumping
|
||||
Releases are managed semi-automatically. They are always manually triggered from a developer's
|
||||
machine with release scripts. From a clean `main` branch you can run the release task bumping
|
||||
the version accordingly based on semantic versioning:
|
||||
|
||||
```bash
|
||||
|
@ -234,7 +249,7 @@ You can edit the event handler code and then run `npm run deploy:local`, with so
|
|||
- Running deploy will fail if the code has no changes
|
||||
- Sometimes deploy will fail no matter what, in this case:
|
||||
- Stop the docker-compose run (`docker-compose down` or Ctrl+C)
|
||||
This should stop the graph-node, ipfs and postgres containers
|
||||
This should stop the graph-node, ipfs and postgres containers
|
||||
- Delete the `ipfs` and `postgres` folders in `/docker/data` (`rm -rf ./docker/data/*`)
|
||||
- Run `docker-compose up` to restart graph-node, ipfs and postgres
|
||||
- Run `npm run create:local` to create the ocean-subgraph
|
||||
|
@ -245,7 +260,7 @@ You can edit the event handler code and then run `npm run deploy:local`, with so
|
|||
## 🏛 License
|
||||
|
||||
```
|
||||
Copyright ((C)) 2021 Ocean Protocol Foundation
|
||||
Copyright ((C)) 2023 Ocean Protocol Foundation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
2986
abis/BFactory.json
2986
abis/BFactory.json
File diff suppressed because one or more lines are too long
1526
abis/BPool.json
1526
abis/BPool.json
File diff suppressed because it is too large
Load Diff
13920
abis/BToken.json
13920
abis/BToken.json
File diff suppressed because one or more lines are too long
4527
abis/DTFactory.json
4527
abis/DTFactory.json
File diff suppressed because one or more lines are too long
|
@ -1,679 +0,0 @@
|
|||
[
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "BASE_MARKET_FEE_PERCENTAGE",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "addedValue",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "increaseAllowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "subtractedValue",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "decreaseAllowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "BASE_COMMUNITY_FEE_PERCENTAGE",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "BASE",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "minterAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "cap",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "blob",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "feeCollector",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "consumer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "payer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "serviceId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "timestamp",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "mrktFeeCollector",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "marketFee",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "OrderStarted",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "orderTxId",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "consumer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "serviceId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "timestamp",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "OrderFinished",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "currentMinter",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newMinter",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "MinterProposed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "currentMinter",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newMinter",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "MinterApproved",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "minterAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "cap",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "blob",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "feeCollector",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "consumer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "serviceId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "mrktFeeCollector",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "startOrder",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderTxId",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "consumer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "serviceId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "finishOrder",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newMinter",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "proposeMinter",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [],
|
||||
"name": "approveMinter",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "blob",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "cap",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isMinter",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minter",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "feePercentage",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "calculateFee",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
17468
abis/Dispenser.json
17468
abis/Dispenser.json
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,6 @@
|
|||
[
|
||||
{
|
||||
"contractName": "ERC20",
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
|
@ -219,4 +221,5 @@
|
|||
"name": "Transfer",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
|
@ -1,17 +0,0 @@
|
|||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
File diff suppressed because one or more lines are too long
2392
abis/Metadata.json
2392
abis/Metadata.json
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,657 @@
|
|||
<!--
|
||||
Copyright 2023 Ocean Protocol Foundation
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
|
||||
- [Kubernetes deployment](#kubernetes-deployment)
|
||||
- [Postgresql](#postgresql)
|
||||
- [IPFS](#ipfs)
|
||||
- [Graph-node](#graph-node)
|
||||
- [Docker Compose deployment](#docker-compose-deployment)
|
||||
- [Single systemd service (Graph-node+Postgresql+IPFS)](#single-systemd-service-graph-nodepostgresqlipfs)
|
||||
- [Ocean-subgraph deployment](#ocean-subgraph-deployment)
|
||||
|
||||
#### Kubernetes deployment
|
||||
|
||||
[ocean-subgraph](https://github.com/oceanprotocol/ocean-subgraph) must be deployed on top of [graph-node](https://github.com/graphprotocol/graph-node) which has the following dependencies:
|
||||
|
||||
- PostgreSQL
|
||||
|
||||
- IPFS
|
||||
|
||||
Templates (yaml files) provided and could be customized based on the environment's specifics.
|
||||
|
||||
##### Postgresql
|
||||
|
||||
It is recommended to deploy PostgreSQL as helm chart
|
||||
|
||||
References: https://github.com/bitnami/charts/tree/main/bitnami/postgresql/#installing-the-chart
|
||||
|
||||
Once PostgreSQL pods are running, a database must be created: eg. `mumbai`
|
||||
|
||||
##### IPFS
|
||||
|
||||
The following template can be customized to deploy IPFS statefulset and service:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: ipfs
|
||||
name: ipfs
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ipfs
|
||||
serviceName: ipfs
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: ipfs
|
||||
spec:
|
||||
containers:
|
||||
- image: ipfs/go-ipfs:v0.4.22
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /debug/metrics/prometheus
|
||||
port: api
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 3
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
name: s1-ipfs
|
||||
ports:
|
||||
- containerPort: 5001
|
||||
name: api
|
||||
protocol: TCP
|
||||
- containerPort: 8080
|
||||
name: gateway
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /debug/metrics/prometheus
|
||||
port: api
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 3
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /data/ipfs
|
||||
name: ipfs-storage
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
runAsUser: 1000
|
||||
terminationGracePeriodSeconds: 30
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
volumeClaimTemplates:
|
||||
- apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: ipfs-storage
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1G
|
||||
volumeMode: Filesystem
|
||||
status:
|
||||
phase: Pending
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: ipfs
|
||||
name: ipfs
|
||||
spec:
|
||||
clusterIP:
|
||||
clusterIPs:
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
ports:
|
||||
- name: api
|
||||
port: 5001
|
||||
- name: gateway
|
||||
port: 8080
|
||||
selector:
|
||||
app: ipfs
|
||||
```
|
||||
|
||||
##### Graph-node
|
||||
|
||||
The following annotated templated can be customized to deploy graph-node deployment and service:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
name: mumbai-graph-node
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mumbai-graph-node
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: ipfs
|
||||
value: ipfs.<namespace>.svc.cluster.local:5001
|
||||
- name: postgres_host
|
||||
value: postgresql.<namespace>.svc.cluster.local
|
||||
- name: postgres_user
|
||||
value: < postgresql user >
|
||||
- name: postgres_pass
|
||||
value: < postgresql database password >
|
||||
- name: postgres_db
|
||||
value: < postgresql database >
|
||||
- name: ethereum
|
||||
value: mumbai:https://polygon-mumbai.infura.io/v3/< INFURA ID>
|
||||
- name: GRAPH_KILL_IF_UNRESPONSIVE
|
||||
value: 'true'
|
||||
image: graphprotocol/graph-node:v0.28.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
name: mumbai-graph-node
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
name: graphql
|
||||
protocol: TCP
|
||||
- containerPort: 8020
|
||||
name: jsonrpc
|
||||
protocol: TCP
|
||||
- containerPort: 8030
|
||||
name: indexnode
|
||||
protocol: TCP
|
||||
- containerPort: 8040
|
||||
name: metrics
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
limits:
|
||||
cpu: '2'
|
||||
memory: 1536Mi
|
||||
requests:
|
||||
cpu: 1500m
|
||||
memory: 1536Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
terminationGracePeriodSeconds: 30
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
name: mumbai-graph-node
|
||||
spec:
|
||||
clusterIP:
|
||||
clusterIPs:
|
||||
internalTrafficPolicy: Cluster
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
ports:
|
||||
- name: graphql
|
||||
port: 8000
|
||||
- name: jsonrpc
|
||||
port: 8020
|
||||
- name: indexnode
|
||||
port: 8030
|
||||
- name: metrics
|
||||
port: 8040
|
||||
selector:
|
||||
app: mumbai-graph-node
|
||||
```
|
||||
|
||||
#### Docker Compose deployment
|
||||
|
||||
##### Single systemd service (Graph-node+Postgresql+IPFS)
|
||||
|
||||
a) create _/etc/docker/compose/graph-node/docker-compose.yml_ file
|
||||
|
||||
_/etc/docker/compose/graph-node/docker-compose.yml_ (annotated - example for `mumbai` network)
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
services:
|
||||
graph-node:
|
||||
image: graphprotocol/graph-node:v0.28.2
|
||||
container_name: graph-node
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '8000:8000'
|
||||
- '8020:8020'
|
||||
- '8030:8030'
|
||||
- '8040:8040'
|
||||
depends_on:
|
||||
- ipfs
|
||||
- postgres-graph
|
||||
environment:
|
||||
postgres_host: postgres-graph
|
||||
postgres_user: graph-node
|
||||
postgres_pass: < password >
|
||||
postgres_db: mumbai
|
||||
ipfs: 'ipfs:5001'
|
||||
ethereum: 'mumbai:https://polygon-mumbai.infura.io/v3/< INFURA ID >'
|
||||
GRAPH_LOG: info
|
||||
ipfs:
|
||||
image: ipfs/go-ipfs:v0.4.23
|
||||
container_name: ipfs
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '5001:5001'
|
||||
volumes:
|
||||
- ipfs-graph-node:/data/ipfs
|
||||
postgres-graph:
|
||||
image: postgres:15.3
|
||||
container_name: postgres
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '5432:5432'
|
||||
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
|
||||
environment:
|
||||
POSTGRES_USER: graph-node
|
||||
POSTGRES_PASSWORD: < password >
|
||||
POSTGRES_DB: mumbai
|
||||
volumes:
|
||||
- pgdata-graph-node:/var/lib/postgresql/data
|
||||
volumes:
|
||||
pgdata-graph-node:
|
||||
driver: local
|
||||
ipfs-graph-node:
|
||||
driver: local
|
||||
```
|
||||
|
||||
b) create _/etc/systemd/system/docker-compose@graph-node.service_ file
|
||||
|
||||
```shell
|
||||
[Unit]
|
||||
Description=%i service with docker compose
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
Environment="PROJECT=ocean"
|
||||
WorkingDirectory=/etc/docker/compose/%i
|
||||
ExecStartPre=/usr/bin/env docker-compose -p $PROJECT pull
|
||||
ExecStart=/usr/bin/env docker-compose -p $PROJECT up -d
|
||||
ExecStop=/usr/bin/env docker-compose -p $PROJECT stop
|
||||
ExecStopPost=/usr/bin/env docker-compose -p $PROJECT down
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
c) run:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
optional - enable service to start at boot:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl enable docker-compose@graph-node.service
|
||||
```
|
||||
|
||||
d) start aquarius service:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl start docker-compose@graph-node.service
|
||||
```
|
||||
|
||||
check status:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl status docker-compose@graph-node.service
|
||||
● docker-compose@graph-node.service - graph-node service with docker compose
|
||||
Loaded: loaded (/etc/systemd/system/docker-compose@graph-node.service; disabled; vendor preset: enabled)
|
||||
Active: active (exited) since Sun 2023-06-25 17:05:25 UTC; 6s ago
|
||||
Process: 4878 ExecStartPre=/usr/bin/env docker-compose -p $PROJECT pull (code=exited, status=0/SUCCESS)
|
||||
Process: 4887 ExecStart=/usr/bin/env docker-compose -p $PROJECT up -d (code=exited, status=0/SUCCESS)
|
||||
Main PID: 4887 (code=exited, status=0/SUCCESS)
|
||||
CPU: 123ms
|
||||
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Created
|
||||
Jun 25 17:05:24 testvm env[4887]: Container graph-node Creating
|
||||
Jun 25 17:05:24 testvm env[4887]: Container graph-node Created
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Starting
|
||||
Jun 25 17:05:24 testvm env[4887]: Container postgres Starting
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Started
|
||||
Jun 25 17:05:25 testvm env[4887]: Container postgres Started
|
||||
Jun 25 17:05:25 testvm env[4887]: Container graph-node Starting
|
||||
Jun 25 17:05:25 testvm env[4887]: Container graph-node Started
|
||||
Jun 25 17:05:25 testvm systemd[1]: Finished graph-node service with docker compose.
|
||||
|
||||
```
|
||||
|
||||
- check containers status
|
||||
|
||||
```shell
|
||||
$ docker ps --format "table {{.Image}}\t{{.Ports}}\t{{.Names}}\t{{.Status}}"
|
||||
IMAGE PORTS NAMES STATUS
|
||||
graphprotocol/graph-node:v0.28.2 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:8020->8020/tcp, :::8020->8020/tcp, 0.0.0.0:8030->8030/tcp, :::8030->8030/tcp, 0.0.0.0:8040->8040/tcp, :::8040->8040/tcp, 8001/tcp graph-node Up 55 minutes
|
||||
ipfs/go-ipfs:v0.4.23 4001/tcp, 8080-8081/tcp, 0.0.0.0:5001->5001/tcp, :::5001->5001/tcp ipfs Up 55 minutes
|
||||
postgres:15.3 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres Up 55 minutes
|
||||
```
|
||||
|
||||
- check logs for graph-node container
|
||||
|
||||
```shell
|
||||
$ docker logs graph-node [--follow]
|
||||
```
|
||||
|
||||
#### Ocean-subgraph deployment
|
||||
|
||||
- install Node.js locally
|
||||
|
||||
- download and extract [Ocean-subgraph](https://github.com/oceanprotocol/ocean-subgraph) (check [here](https://github.com/oceanprotocol/ocean-subgraph/releases) the available releases)
|
||||
- run inside the extracted directory:
|
||||
|
||||
```shell
|
||||
$ npm i
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
(Note: in this example we are deploying on graph-node running for `mumbai` testnet )
|
||||
|
||||
Note: for `ocean-subgraph` deployment in kubernetes environment, both `graph-node` and `ipfs` services must be locally forwarded using `kubectl port-forward` command.
|
||||
|
||||
```shell
|
||||
$ npm run quickstart:mumbai
|
||||
|
||||
> ocean-subgraph@3.0.8 quickstart:mumbai
|
||||
> node ./scripts/generatenetworkssubgraphs.js mumbai && npm run codegen && npm run create:local && npm run deploy:local
|
||||
|
||||
Creating subgraph.yaml for mumbai
|
||||
Adding veOCEAN
|
||||
Skipping polygon
|
||||
Skipping bsc
|
||||
Skipping energyweb
|
||||
Skipping moonriver
|
||||
Skipping mainnet
|
||||
Skipping polygonedge
|
||||
Skipping gaiaxtestnet
|
||||
Skipping alfajores
|
||||
Skipping gen-x-testnet
|
||||
Skipping filecointestnet
|
||||
|
||||
> ocean-subgraph@3.0.8 codegen
|
||||
> graph codegen --output-dir src/@types
|
||||
|
||||
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
|
||||
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
|
||||
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
|
||||
Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
|
||||
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
|
||||
Apply migration: Bump manifest specVersion from 0.0.2 to 0.0.4
|
||||
✔ Apply migrations
|
||||
✔ Load subgraph from subgraph.yaml
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
Load contract ABI from abis/ERC20.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
Load contract ABI from abis/ERC20.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
✔ Load contract ABIs
|
||||
Generate types for contract ABI: ERC721Factory (node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json)
|
||||
Write types to src/@types/ERC721Factory/ERC721Factory.ts
|
||||
Generate types for contract ABI: ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/ERC721Factory/ERC20.ts
|
||||
Generate types for contract ABI: FactoryRouter (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json)
|
||||
Write types to src/@types/FactoryRouter/FactoryRouter.ts
|
||||
Generate types for contract ABI: ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/FactoryRouter/ERC20.ts
|
||||
Generate types for contract ABI: veAllocate (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json)
|
||||
Write types to src/@types/veAllocate/veAllocate.ts
|
||||
Generate types for contract ABI: veOCEAN (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json)
|
||||
Write types to src/@types/veOCEAN/veOCEAN.ts
|
||||
Generate types for contract ABI: veDelegation (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json)
|
||||
Write types to src/@types/veDelegation/veDelegation.ts
|
||||
Generate types for contract ABI: veFeeDistributor (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json)
|
||||
Write types to src/@types/veFeeDistributor/veFeeDistributor.ts
|
||||
Generate types for contract ABI: DFRewards (node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json)
|
||||
Write types to src/@types/DFRewards/DFRewards.ts
|
||||
✔ Generate types for contract ABIs
|
||||
Generate types for data source template ERC20Template
|
||||
Generate types for data source template ERC721Template
|
||||
Generate types for data source template Dispenser
|
||||
Generate types for data source template FixedRateExchange
|
||||
Write types for templates to src/@types/templates.ts
|
||||
✔ Generate types for data source templates
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
✔ Load data source template ABIs
|
||||
Generate types for data source template ABI: ERC20Template > ERC20Template (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20Template.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20TemplateEnterprise (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20TemplateEnterprise.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20Roles (node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20Roles.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC721Template (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC721Template.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC721RolesAddress (node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC721RolesAddress.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC20.ts
|
||||
Generate types for data source template ABI: Dispenser > Dispenser (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json)
|
||||
Write types to src/@types/templates/Dispenser/Dispenser.ts
|
||||
Generate types for data source template ABI: Dispenser > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/Dispenser/ERC20.ts
|
||||
Generate types for data source template ABI: FixedRateExchange > FixedRateExchange (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json)
|
||||
Write types to src/@types/templates/FixedRateExchange/FixedRateExchange.ts
|
||||
Generate types for data source template ABI: FixedRateExchange > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/FixedRateExchange/ERC20.ts
|
||||
✔ Generate types for data source template ABIs
|
||||
✔ Load GraphQL schema from schema.graphql
|
||||
Write types to src/@types/schema.ts
|
||||
✔ Generate types for GraphQL schema
|
||||
|
||||
Types generated successfully
|
||||
|
||||
|
||||
> ocean-subgraph@3.0.8 create:local
|
||||
> graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020
|
||||
|
||||
Created subgraph: oceanprotocol/ocean-subgraph
|
||||
|
||||
> ocean-subgraph@3.0.8 deploy:local
|
||||
> graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020
|
||||
|
||||
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
|
||||
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
|
||||
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
|
||||
Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
|
||||
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
|
||||
✔ Apply migrations
|
||||
✔ Load subgraph from subgraph.yaml
|
||||
Compile data source: ERC721Factory => build/ERC721Factory/ERC721Factory.wasm
|
||||
Compile data source: FactoryRouter => build/FactoryRouter/FactoryRouter.wasm
|
||||
Compile data source: veAllocate => build/veAllocate/veAllocate.wasm
|
||||
Compile data source: veOCEAN => build/veOCEAN/veOCEAN.wasm
|
||||
Compile data source: veDelegation => build/veDelegation/veDelegation.wasm
|
||||
Compile data source: veFeeDistributor => build/veFeeDistributor/veFeeDistributor.wasm
|
||||
Compile data source: DFRewards => build/DFRewards/DFRewards.wasm
|
||||
Compile data source template: ERC20Template => build/templates/ERC20Template/ERC20Template.wasm
|
||||
Compile data source template: ERC721Template => build/templates/ERC721Template/ERC721Template.wasm
|
||||
Compile data source template: Dispenser => build/templates/Dispenser/Dispenser.wasm
|
||||
Compile data source template: FixedRateExchange => build/templates/FixedRateExchange/FixedRateExchange.wasm
|
||||
✔ Compile subgraph
|
||||
Copy schema file build/schema.graphql
|
||||
Write subgraph file build/ERC721Factory/node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
Write subgraph file build/ERC721Factory/abis/ERC20.json
|
||||
Write subgraph file build/FactoryRouter/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
Write subgraph file build/FactoryRouter/abis/ERC20.json
|
||||
Write subgraph file build/veAllocate/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
Write subgraph file build/veOCEAN/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
Write subgraph file build/veDelegation/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
Write subgraph file build/veFeeDistributor/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
Write subgraph file build/DFRewards/node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
Write subgraph file build/ERC20Template/abis/ERC20.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
Write subgraph file build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
Write subgraph file build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
Write subgraph file build/ERC721Template/abis/ERC20.json
|
||||
Write subgraph file build/Dispenser/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
Write subgraph file build/Dispenser/abis/ERC20.json
|
||||
Write subgraph file build/FixedRateExchange/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
Write subgraph file build/FixedRateExchange/abis/ERC20.json
|
||||
Write subgraph manifest build/subgraph.yaml
|
||||
✔ Write compiled subgraph to build/
|
||||
Add file to IPFS build/schema.graphql
|
||||
.. QmQa3a9ypCLC84prHGQdhbcGG4DHJceqADGxmZMmAAXuTz
|
||||
Add file to IPFS build/ERC721Factory/node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
.. QmSoG3r5vyWXqjEfKAQYjwtQcQkZCsZEcJXVFWVq1tT1dD
|
||||
Add file to IPFS build/ERC721Factory/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2
|
||||
Add file to IPFS build/FactoryRouter/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
.. QmcBVA1R3yi2167UZMvV4LvG4cMHjL8ZZXmPMriCjn8DEe
|
||||
Add file to IPFS build/FactoryRouter/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/veAllocate/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
.. Qmc3iwQkQAhqe1PjzTt6KZLh9rsWQvyxkFt7doj2iXv8C3
|
||||
Add file to IPFS build/veOCEAN/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
.. QmahFjirJqiwKpytFZ9CdE92LdPGBUDZs6AWpsrH2wn1VP
|
||||
Add file to IPFS build/veDelegation/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
.. QmfU6kZ5sksLdj3q88n7SUP63C1cnhQjU8vuMmRYwf2v5r
|
||||
Add file to IPFS build/veFeeDistributor/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
.. QmVU51oBr62D4UFXTwnMcbzuBBAAeQssqmqM9jic7A6L3v
|
||||
Add file to IPFS build/DFRewards/node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
.. QmcckRMahzpL7foEFGpWfkDBsyoWbNRfLC32uFq8ceUV3a
|
||||
Add file to IPFS build/ERC721Factory/ERC721Factory.wasm
|
||||
.. QmVfDAgZdKWxMuNfT7kso1LbFre2xhYbEeHBGm3gH3R9oE
|
||||
Add file to IPFS build/FactoryRouter/FactoryRouter.wasm
|
||||
.. QmYCC9AcaYw3nGSqNXNFHVsuB67FQEyZ8twRjRXrprcgyp
|
||||
Add file to IPFS build/veAllocate/veAllocate.wasm
|
||||
.. QmUFaYDxChi5nKEJLvHQZP1cRoqqP5k3fYSwk2JjuSceiJ
|
||||
Add file to IPFS build/veOCEAN/veOCEAN.wasm
|
||||
.. QmRYCyYKwHdSeM55vuvL1mdCooDkFQm6d2TQ7iK2N1qgur
|
||||
Add file to IPFS build/veDelegation/veDelegation.wasm
|
||||
.. QmaTjRLirzfidtQTYgzxqVVD9AX9e69TN1Y8fEsNQ9AEZq
|
||||
Add file to IPFS build/veFeeDistributor/veFeeDistributor.wasm
|
||||
.. QmZCEp4yxiDyuksEjSaceogJwLMto2UGfV1KxVuJTJLTqg
|
||||
Add file to IPFS build/DFRewards/DFRewards.wasm
|
||||
.. QmRSxe52B836bdfoJbuDY4tUCawzqgkHRNxe9ucU1JdYm5
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
.. QmPkhFvnBbqA3You7NsK5Zsyh8kkizXUHF9pcC5V6qDJQu
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
.. QmZnogwnfr4TeBPykvmCL2oaX63AKQP1F1uBAbbfnyPAzB
|
||||
Add file to IPFS build/ERC20Template/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
.. QmTWTzg4jTx4GxGApVyxirNRTxB7QovS4bHGuWnnW8Ciz2
|
||||
Add file to IPFS build/templates/ERC20Template/ERC20Template.wasm
|
||||
.. QmUcxes5La7n9481Vf9AoQ2Mjt1CrbS7T6tDhpnfF77Uh5
|
||||
Add file to IPFS build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
.. QmPE82CiACicgu1WxEjeFrLmskiJADroQRnxH7owpK6jaP
|
||||
Add file to IPFS build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
.. Qmdhi7UK6Ww8vXH9YC3JxVUEFjTyx3XycF53rRZapVK5c3
|
||||
Add file to IPFS build/ERC721Template/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/ERC721Template/ERC721Template.wasm
|
||||
.. QmNhLws24szwpz8LM2sL6HHKc6KK4vtJwzfeZWkghuqn7Q
|
||||
Add file to IPFS build/Dispenser/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
.. QmdiN7Fhw9sjoVVJgHtTtzxv5fwtFMHLNH1x1yqbswsThW
|
||||
Add file to IPFS build/Dispenser/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/Dispenser/Dispenser.wasm
|
||||
.. QmTpn9wagpmH6byjjdCBZdgypFgcw2mva3bC52nC4z3eLW
|
||||
Add file to IPFS build/FixedRateExchange/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
.. Qmd2ToAptK74j8pGxe8mZXfAvY3AxstgmYH8JDMAfLtAGd
|
||||
Add file to IPFS build/FixedRateExchange/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/FixedRateExchange/FixedRateExchange.wasm
|
||||
.. QmRrwwoFF33LvPhnGCGgLBLyuLizrFgD44kW9io81tPZzX
|
||||
✔ Upload subgraph to IPFS
|
||||
|
||||
Build completed: QmVUKpgwuyDh9KgUxTzZvVNFJbdevc56YrZpZjQvu8Yp7q
|
||||
|
||||
Deployed to http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
||||
|
||||
Subgraph endpoints:
|
||||
Queries (HTTP): http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph
|
||||
```
|
||||
|
||||
- This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
||||
|
||||
http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# default to true in case it is not set
|
||||
DEPLOY_SUBGRAPH="${DEPLOY_SUBGRAPH:-true}"
|
||||
echo "deploy subgraph is ${DEPLOY_SUBGRAPH}"
|
||||
|
||||
if [ "${DEPLOY_SUBGRAPH}" = "true" ]
|
||||
then
|
||||
rm -f /ocean-subgraph/ready
|
||||
echo "Waiting for contracts to be deployed"
|
||||
while [ ! -f "/ocean-contracts/artifacts/ready" ]; do
|
||||
sleep 2
|
||||
done
|
||||
export ADDRESS_FILE="/ocean-contracts/artifacts/address.json"
|
||||
cd /usr/src/app/
|
||||
npm run quickstart:barge
|
||||
sleep 3
|
||||
touch /ocean-subgraph/ready
|
||||
fi
|
||||
tail -f /dev/null
|
|
@ -60,6 +60,11 @@ clone this repository and run
|
|||
```sh
|
||||
docker-compose up
|
||||
```
|
||||
OR
|
||||
|
||||
```sh
|
||||
docker-compose --env-file .env up | grep -a -E --color 'WARN.*|$'
|
||||
```
|
||||
|
||||
This will start IPFS, Postgres and Graph Node in Docker and create persistent
|
||||
data directories for IPFS and Postgres in `./data/ipfs` and `./data/postgres`. You
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
version: '3'
|
||||
services:
|
||||
graph-node:
|
||||
image: oceanprotocol/graph-node:latest
|
||||
image: graphprotocol/graph-node:v0.28.2
|
||||
ports:
|
||||
- '8000:8000'
|
||||
- '9000:8000'
|
||||
- '8001:8001'
|
||||
- '8020:8020'
|
||||
- '8030:8030'
|
||||
|
@ -17,8 +17,9 @@ services:
|
|||
postgres_pass: let-me-in
|
||||
postgres_db: graph-node
|
||||
ipfs: 'ipfs:5001'
|
||||
ethereum: 'rinkeby:https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}'
|
||||
RUST_LOG: info
|
||||
ethereum: 'oasis_saphire_testnet:http://192.168.136.129:8080'
|
||||
RUST_LOG: warning
|
||||
GRAPH_ETHEREUM_MAX_BLOCK_RANGE_SIZE: 100
|
||||
ipfs:
|
||||
image: ipfs/go-ipfs:v0.4.23
|
||||
ports:
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
# Add contract as dataSource and use local Subgraph + Ganache + Brownie
|
||||
To develop new features on top of `ocean-subgraph`, it pays to deploy a local Subgraph that consumes from Ganache, so you can deploy your Contracts, execute their functionality, and query the Subgraph to verify Events are being Handled correctly, w/ the right Schema being yielded.
|
||||
|
||||
The following doc takes you through:
|
||||
1. Configuring `docker-compose.yml` to run an internal Subgraph that consumes from a local Ganache.
|
||||
2. Configuring `df-py` + Brownie to connect to the `ocean-subgraph` Ganache so we can deploy our local contracts.
|
||||
3. Adding our smart contract as a dataSource for our internal Subgraph. We can then handle contract events, and transform that data into queryable entities using GQL.
|
||||
4. Finally, we can hook our contracts into Testing & verifying that your subgraph is working as intended.
|
||||
|
||||
Note 1: For this tutorial, you should be using multiple terminal windows. These will be referred to at the top of each section.
|
||||
|
||||
Note 2: For this example, we're going to use the `df-py` repository and integrate `veAllocate` contract into `ocean-subgraph`
|
||||
|
||||
Note 3: For the sake of versatility, the example below is being executed using `df-py` while verification is being done by hand by viewing & querying GQL on the browser.
|
||||
|
||||
### 1. ocean-subgraph - Add & Connect Ganache
|
||||
Section 1 takes place inside `ocean-subgraph` terminal window.
|
||||
|
||||
You should have this repository configured and working on your machine.
|
||||
|
||||
We now need to update `./docker/docker-compose.yml` to implement a local instance of Ganache. Our `graph-node` needs to listen to Ganache for events, so we update the ethereum url.
|
||||
```
|
||||
services:
|
||||
ganache:
|
||||
image: trufflesuite/ganache-cli:latest
|
||||
ports:
|
||||
- 8545:8545
|
||||
entrypoint: ["node", "/app/ganache-core.docker.cli.js", "--db", "./ganache_cache","--chainId","0x2324","--networkId","0x2324","--gasLimit","10000000000","--gasPrice","1","---hardfork","istanbul","--mnemonic","${GANACHE_MNEMONIC}", "-e", "100", "-a", "20"]
|
||||
graph-node:
|
||||
environment:
|
||||
ethereum: 'development:http://ganache:8545'
|
||||
```
|
||||
|
||||
Great, our docker environment is now setup. We can finally deploy it by typing `docker-compose up` inside of `./docker/`.
|
||||
|
||||
### 2a. df-py - Configure to connect to Subgraph
|
||||
Section 2 takes place inside `df-py` terminal window.
|
||||
|
||||
You should have this repository configured and working on your machine.
|
||||
|
||||
First, we make sure that we're inside our venv by typing `source venv/bin/activate/`. Again, we're assuming your requirements.txt, and other dependencies have been properly initialized.
|
||||
|
||||
We now `df-py` connect to Ganache via Brownie. To do this, we're going to add a network so Brownie can listen to our Ganache service.
|
||||
```
|
||||
brownie networks add Ethereum subgraph-ganache host=http://127.0.0.1:8545, chainid=8996
|
||||
```
|
||||
|
||||
We then update our `brownie-config.yaml` so that it uses the network above by default.
|
||||
```
|
||||
networks:
|
||||
default: subgraph-ganache
|
||||
```
|
||||
|
||||
You should now be able to verify that the accounts from `subgraph-ganache` are working from inside `df-py` brownie.
|
||||
```
|
||||
brownie console --network subgraph-ganache
|
||||
>>> accounts[0].balance()
|
||||
100000000000000000000
|
||||
```
|
||||
|
||||
### 2b. df-py - Configure dftools and deploy contracts
|
||||
This section continues from Section 2.
|
||||
|
||||
We can now, also configure dftools to use accounts from Ganache, and deploy contracts into `ocean-subgraph`.
|
||||
|
||||
Look inside the `ocean-subgraph` terminal for the private accounts that were generated for you inside of Ganache. Copy one of their private keys, and do the following inside of `df-py/(venv)/`
|
||||
```
|
||||
export DFTOOL_KEY=0xYourUserPrivateKeyFromGanache
|
||||
export WEB3_INFURA_PROJECT_ID=YourInfuraKey
|
||||
```
|
||||
|
||||
You should now be able to deploy a newToken + veOCEAN + veAllocate contracts.
|
||||
```
|
||||
// deploy a new token
|
||||
dftool newToken 8996
|
||||
|
||||
// use the token address from above to deploy veOcean
|
||||
dftool newVeOcean 8996 token_address
|
||||
|
||||
// deploy veAllocate
|
||||
dftool newVeAllocate 8996
|
||||
```
|
||||
|
||||
You will need the address from the new `veAllocate` contract you just deployed for the next section. This contract will be used in the future so our subgraph can listen for events.
|
||||
|
||||
### 3a. ocean-subgraph - Initialize the project
|
||||
Section 3 takes place inside `ocean-subgraph` terminal.
|
||||
|
||||
We're going to now generate `subgraph.yaml` so we can start connecting the veOCEAN contract into the logic of `ocean-subpgrah`.
|
||||
|
||||
We begin by running the following node script from the root folder.
|
||||
```
|
||||
node ./scripts/generatenetworkssubgraphs.js
|
||||
```
|
||||
|
||||
Here, we're going to configure our local `subgraph.yaml` file so we can serve our local ganache, contracts, and everything that `df-py` depends on.
|
||||
|
||||
Use this file for all of your development until you have things sorted out. If you make any mistakes, you can just recreate the file. You should make your final changes inside of `subgraph.template.yaml` before submitting a PR.
|
||||
|
||||
### 3b. ocean-subgraph - Configure dataSources
|
||||
|
||||
We now configure our `subgraph.yaml` to talk to ganache and add our veAllocate Contract as a dataSource.
|
||||
|
||||
Our first step is to reset our `subgraph.yaml` so that it can consume all the events. Do a search for `startBlock` and make sure all params are initialized to 0.
|
||||
```
|
||||
- kind: ethereum/contract
|
||||
source:
|
||||
startBlock: 0
|
||||
```
|
||||
|
||||
We then add our contract as a dataSource. We get our address from Section 2b `dftool newVeAllocate 8996` and enter it in the `dataSources` section of the `subgraph.yaml` file.
|
||||
```
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: veAllocate
|
||||
network: development
|
||||
source:
|
||||
address: 0x0000000000000000000000000000000
|
||||
abi: veAllocate
|
||||
startBlock: 0
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.6
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/veAllocate.ts
|
||||
entities:
|
||||
- veAllocate
|
||||
abis:
|
||||
- name: veAllocate
|
||||
file: ./abis/veAllocate.json
|
||||
eventHandlers:
|
||||
- event: AllocationSet(indexed address,indexed address,indexed uint256,uint256)
|
||||
handler: handleAllocationSet
|
||||
```
|
||||
|
||||
As you can see, we have also imported our `veAllocate.json ABI` file into the project, added the contract events we want to handle, and created a mapping script `./src/mappings/veAllocate.ts` so we can handle all the vents for the Subgraph.
|
||||
|
||||
Note: This tutorial will not go into details of how to do this work. Someone can create a separate guide on how to handle internal logic, define GraphQL entities, and save records into GraphQL.
|
||||
|
||||
_Please review the PR associated with this README for more intuition on this_
|
||||
|
||||
### 4a. ocean-subgraph - run: `npm run codegen`
|
||||
From the root folder run this command.
|
||||
|
||||
You'll have to do this again every time you change `schema.graphql`
|
||||
|
||||
### 4b. ocean-subgraph - run: `npm run create:local`
|
||||
From the root folder run this command.
|
||||
|
||||
You'll have to do this again every time you run step 5a.
|
||||
|
||||
### 4c. ocean-subgraph - run: `npm run deploy:local`
|
||||
From the root folder run this command.
|
||||
|
||||
You'll have to do this again when you write any new subgraph code (mappings, utils, etc...).
|
||||
|
||||
### 5. ocean-subgraph - restart docker
|
||||
Restart docker containers via `docker-compose up`
|
||||
|
||||
### 6. df-py - Execute onchain events + query subgraph
|
||||
You can now start performing your onchain + contract tests and see records inside of your local subgraph.
|
||||
|
||||
As an example, you may use the following command inside `dftools` to generate many onchain events for Ganache.
|
||||
```
|
||||
dftool manyrandom 8996
|
||||
```
|
File diff suppressed because it is too large
Load Diff
105
package.json
105
package.json
|
@ -1,66 +1,87 @@
|
|||
{
|
||||
"name": "ocean-subgraph",
|
||||
"version": "1.1.2",
|
||||
"version": "4.0.2",
|
||||
"scripts": {
|
||||
"start": "",
|
||||
"quickstart:barge": "export ADDRESS_FILE=\"${HOME}/.ocean/ocean-contracts/artifacts/address.json\" && npm run codegen && npm run bargesetup && npm run create:local-barge && npm run deploy:local-barge",
|
||||
"bargesetup": "node ./scripts/generatebargesubgraph.js",
|
||||
"create": "graph create oceanprotocol/ocean-subgraph --node https://api.thegraph.com/deploy/",
|
||||
"quickstart:development": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:barge": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local-barge && npm run deploy:local-barge",
|
||||
"quickstart:rinkeby": "node ./scripts/generatenetworkssubgraphs.js rinkeby && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:ropsten": "node ./scripts/generatenetworkssubgraphs.js ropsten && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:mumbai": "node ./scripts/generatenetworkssubgraphs.js mumbai && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:moonbase": "node ./scripts/generatenetworkssubgraphs.js moonbase && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:polygon": "node ./scripts/generatenetworkssubgraphs.js polygon && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:mainnet": "node ./scripts/generatenetworkssubgraphs.js mainnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:moonriver": "node ./scripts/generatenetworkssubgraphs.js moonriver && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:energyweb": "node ./scripts/generatenetworkssubgraphs.js energyweb && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:sepolia": "node ./scripts/generatenetworkssubgraphs.js sepolia && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:gen-x-testnet": "node ./scripts/generatenetworkssubgraphs.js gen-x-testnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:bsc": "node ./scripts/generatenetworkssubgraphs.js bsc && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:oasis_saphire_testnet": "node ./scripts/generatenetworkssubgraphs.js oasis_saphire_testnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:oasis_saphire": "node ./scripts/generatenetworkssubgraphs.js oasis_saphire && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:optimism": "node ./scripts/generatenetworkssubgraphs.js optimism && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:optimism_sepolia": "node ./scripts/generatenetworkssubgraphs.js optimism_sepolia && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"create:thegraph": "graph create oceanprotocol/ocean-subgraph --node https://api.thegraph.com/deploy/",
|
||||
"create:local": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-barge": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:9020",
|
||||
"create:local-rinkeby": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-ropsten": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-polygon": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-moonbeamalpha": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-gaiaxtestnet": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-mumbai": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-bsc": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
|
||||
"create:local-barge": "graph create oceanprotocol/ocean-subgraph --node http://172.15.0.15:8020",
|
||||
"codegen": "graph codegen --output-dir src/@types",
|
||||
"build": "graph build",
|
||||
"deploy": "graph deploy oceanprotocol/ocean-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
|
||||
"deploy:beta": "graph deploy oceanprotocol/ocean-subgraph-beta --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
|
||||
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-barge": "graph deploy oceanprotocol/ocean-subgraph subgraph.barge.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:9020",
|
||||
"deploy:local-rinkeby": "graph deploy oceanprotocol/ocean-subgraph subgraph.rinkeby.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-ropsten": "graph deploy oceanprotocol/ocean-subgraph subgraph.ropsten.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-polygon": "graph deploy oceanprotocol/ocean-subgraph subgraph.polygon.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-moonbeamalpha": "graph deploy oceanprotocol/ocean-subgraph subgraph.moonbeamalpha.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-gaiaxtestnet": "graph deploy oceanprotocol/ocean-subgraph subgraph.gaiaxtestnet.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-mumbai": "graph deploy oceanprotocol/ocean-subgraph subgraph.mumbai.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-bsc": "graph deploy oceanprotocol/ocean-subgraph subgraph.bsc.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:thegraph": "graph deploy oceanprotocol/ocean-subgraph -l $npm_package_version --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
|
||||
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-barge": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --ipfs http://172.15.0.16:5001 --node http://172.15.0.15:8020",
|
||||
"test": "npm run codegen && npm run lint && npm run type-check",
|
||||
"test-integration": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/**/*.test.ts'",
|
||||
"test-dispenser": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Dispenser.test.ts'",
|
||||
"test-simple": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/SimpleSubgraph.test.ts'",
|
||||
"test-fixed": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/FixedRateExchange.test.ts'",
|
||||
"test-users": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/users.test.ts'",
|
||||
"test-ve": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/VeOcean.test.ts'",
|
||||
"test-df": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/DFRewards.test.ts'",
|
||||
"test-dt": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Datatoken.test.ts'",
|
||||
"test-zend": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/ZEnding.test.ts'",
|
||||
"test-publish-consume": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/SimplePublishConsume.test.ts'",
|
||||
"test-nft": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Nft.test.ts'",
|
||||
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
|
||||
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
|
||||
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
|
||||
"type-check": "tsc --noEmit",
|
||||
"replaceVersion": "node ./scripts/replaceVersion.js",
|
||||
"release": "release-it --non-interactive",
|
||||
"changelog": "auto-changelog -p"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphprotocol/graph-cli": "^0.18.0",
|
||||
"@graphprotocol/graph-ts": "^0.20.1",
|
||||
"@types/chai": "^4.2.21",
|
||||
"@types/chai": "^4.3.11",
|
||||
"@types/chai-spies": "^1.0.3",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.1",
|
||||
"@typescript-eslint/parser": "^4.29.0",
|
||||
"auto-changelog": "^2.3.0",
|
||||
"chai": "^4.3.4",
|
||||
"@types/mocha": "^10.0.2",
|
||||
"@types/node": "^20.8.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
||||
"@typescript-eslint/parser": "^6.19.0",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"chai": "^4.3.10",
|
||||
"chai-spies": "^1.0.0",
|
||||
"cross-fetch": "^3.1.6",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-oceanprotocol": "^1.5.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"mocha": "^9.0.3",
|
||||
"mock-local-storage": "^1.1.17",
|
||||
"prettier": "^2.3.2",
|
||||
"release-it": "^14.11.5",
|
||||
"eslint-config-oceanprotocol": "^2.0.4",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"ethereumjs-util": "^7.1.5",
|
||||
"mocha": "^10.2.0",
|
||||
"mock-local-storage": "^1.1.24",
|
||||
"prettier": "^2.8.8",
|
||||
"release-it": "^17.0.0",
|
||||
"source-map-support": "^0.5.21",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"ts-node-register": "^1.0.0",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^5.4.5",
|
||||
"@oceanprotocol/lib": "^2.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/lib": "^0.17.1",
|
||||
"cross-fetch": "^3.1.4"
|
||||
"@oceanprotocol/contracts": "^2.0.3",
|
||||
"@graphprotocol/graph-cli": "^0.71.0",
|
||||
"@graphprotocol/graph-ts": "^0.31.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -69,7 +90,7 @@
|
|||
"license": "Apache-2.0",
|
||||
"release-it": {
|
||||
"hooks": {
|
||||
"after:bump": "npm run changelog"
|
||||
"after:bump": "npm run changelog && npm run replaceVersion"
|
||||
},
|
||||
"plugins": {},
|
||||
"git": {
|
||||
|
|
943
schema.graphql
943
schema.graphql
|
@ -1,249 +1,259 @@
|
|||
type PoolFactory @entity {
|
||||
id: ID!
|
||||
|
||||
totalValueLocked: BigDecimal # total value from all pools expressed in OCEAN
|
||||
|
||||
totalOceanLiquidity: BigDecimal! # Total of OCEAN liquidity from all pools
|
||||
totalSwapVolume: BigDecimal! # All the swap volume in Ocean
|
||||
totalSwapFee: BigDecimal! # All the swap fee in Ocean
|
||||
totalOrderVolume: BigDecimal
|
||||
|
||||
poolCount: Int! # Number of pools
|
||||
finalizedPoolCount: Int! # Number of finalized pools
|
||||
orderCount: BigInt # Number of total consumes
|
||||
pools: [Pool!] @derivedFrom(field: "factoryID")
|
||||
}
|
||||
|
||||
type Global @entity {
|
||||
id: ID!
|
||||
totalValueLocked: BigDecimal # total value from all pools expressed in OCEAN
|
||||
totalOceanLiquidity: BigDecimal! # Total of OCEAN liquidity from all pools
|
||||
totalSwapVolume: BigDecimal! # All the swap volume in Ocean
|
||||
totalOrderVolume: BigDecimal
|
||||
orderCount: BigInt
|
||||
poolCount: Int!
|
||||
}
|
||||
|
||||
type Pool @entity {
|
||||
id: ID! # Pool address
|
||||
factoryID: PoolFactory!
|
||||
controller: Bytes! # Controller address
|
||||
publicSwap: Boolean! # isPublicSwap
|
||||
finalized: Boolean! # isFinalized
|
||||
symbol: String # Pool token symbol
|
||||
name: String # Pool token name
|
||||
cap: BigInt # Maximum supply if any
|
||||
active: Boolean! # isActive
|
||||
swapFee: BigDecimal! # Swap Fees
|
||||
|
||||
totalWeight: BigDecimal!
|
||||
totalShares: BigDecimal! # Total pool token shares
|
||||
totalSwapVolume: BigDecimal! # Total swap volume in OCEAN
|
||||
totalSwapFee: BigDecimal! # Total swap fee in OCEAN
|
||||
|
||||
valueLocked: BigDecimal! # value locked in pool expressed in OCEAN (captures both Ocean and Datatoken)
|
||||
datatokenReserve: BigDecimal! # Total pool reserve of Datatoken
|
||||
oceanReserve: BigDecimal! # Total pool reserve of OCEAN
|
||||
spotPrice: BigDecimal!
|
||||
consumePrice: BigDecimal!
|
||||
|
||||
tokenCount: BigInt! # Number of tokens in the pool
|
||||
holderCount: BigInt! # Number of addresses holding a positive balance of pool shares
|
||||
joinCount: BigInt! # liquidity has been added
|
||||
exitCount: BigInt! # liquidity has been removed
|
||||
swapCount: BigInt!
|
||||
transactionCount: BigInt! # Number of transactions in this pool involving liquidity changes
|
||||
type Token @entity {
|
||||
id: ID!
|
||||
symbol: String
|
||||
name: String
|
||||
decimals: Int!
|
||||
address: String!
|
||||
cap: BigDecimal
|
||||
supply: BigDecimal
|
||||
isDatatoken: Boolean!
|
||||
|
||||
datatokenAddress: String!
|
||||
createTime: Int! # Block time pool was created
|
||||
tx: Bytes # Pool creation transaction id
|
||||
"address of ERC721 that owns the token, valid only for datatokens"
|
||||
nft: Nft
|
||||
|
||||
tokens: [PoolToken!] @derivedFrom(field: "poolId")
|
||||
shares: [PoolShare!] @derivedFrom(field: "poolId")
|
||||
transactions: [PoolTransaction!] @derivedFrom(field: "poolAddress")
|
||||
transactionsTokenValues: [PoolTransactionTokenValues!] @derivedFrom(field: "poolAddress")
|
||||
"array of addresses with minter role"
|
||||
minter: [String!]
|
||||
|
||||
"array of addresses with payment manager minter role"
|
||||
paymentManager: [String!]
|
||||
|
||||
"address that collects the payments (NOT fees)"
|
||||
paymentCollector: String
|
||||
|
||||
"address of the market where the datatoken was created. This address collects market fees."
|
||||
publishMarketFeeAddress: String
|
||||
|
||||
"adreess of fee token (can be Ocean, ETH, etc.)"
|
||||
publishMarketFeeToken: String
|
||||
|
||||
"fee amount. Fixed value."
|
||||
publishMarketFeeAmount: BigDecimal
|
||||
|
||||
"template ID of the datatoken"
|
||||
templateId: BigInt!
|
||||
|
||||
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
|
||||
holderCount: BigInt!
|
||||
|
||||
"number of orders executed for this datatoken"
|
||||
orderCount: BigInt!
|
||||
|
||||
"orders created with the datatoken, only available for datatokens"
|
||||
orders: [Order!] @derivedFrom(field:"datatoken")
|
||||
|
||||
"fixed rate exchanges, only available for datatokens"
|
||||
fixedRateExchanges: [FixedRateExchange!] @derivedFrom(field:"datatoken")
|
||||
|
||||
"dispensers using this token"
|
||||
dispensers: [Dispenser!] @derivedFrom(field:"token")
|
||||
|
||||
"block time datatoken was created"
|
||||
createdTimestamp: Int!
|
||||
|
||||
"datatoken creation transaction id"
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
"block number when it was created"
|
||||
block: Int!
|
||||
|
||||
lastPriceToken: Token
|
||||
lastPriceValue: BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
type PoolToken @entity {
|
||||
id: ID! # poolId + token address
|
||||
poolId: Pool!
|
||||
isDatatoken: Boolean!
|
||||
address: String
|
||||
tokenId: Datatoken
|
||||
tokenAddress: String
|
||||
balance: BigDecimal!
|
||||
denormWeight: BigDecimal!
|
||||
symbol: String
|
||||
name: String
|
||||
decimals: Int
|
||||
"utility type"
|
||||
type TokenValuePair @entity {
|
||||
"address of the token"
|
||||
id : ID!
|
||||
token : Token!
|
||||
value : BigDecimal!
|
||||
}
|
||||
|
||||
type Nft @entity{
|
||||
"nft address"
|
||||
id: ID!
|
||||
symbol: String!
|
||||
name: String!
|
||||
tokenUri: String
|
||||
|
||||
"address of the owner of the nft"
|
||||
owner: User!
|
||||
"address of the creator of the nft"
|
||||
creator: User!
|
||||
|
||||
"same as id, it's just for easy discoverability"
|
||||
address: String!
|
||||
|
||||
type PoolShare @entity {
|
||||
id: ID! # poolId + userAddress
|
||||
userAddress: User!
|
||||
poolId: Pool!
|
||||
balance: BigDecimal!
|
||||
"provider url that can decrypt the ddo"
|
||||
providerUrl: String
|
||||
|
||||
"state of the asset (described in docs)"
|
||||
assetState: Int!
|
||||
|
||||
managerRole: [String!]
|
||||
erc20DeployerRole: [String!]
|
||||
storeUpdateRole: [String!]
|
||||
"addresses that can update the metadata"
|
||||
metadataRole: [String!]
|
||||
|
||||
"template address"
|
||||
template: String!
|
||||
|
||||
"template ID of the datatoken"
|
||||
templateId: Int
|
||||
|
||||
"set if NFT is transferable"
|
||||
transferable: Boolean!
|
||||
|
||||
"block time nft was created"
|
||||
createdTimestamp: Int!
|
||||
"nft creation transaction id"
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
|
||||
"number of orders executed for all underlying datatokens"
|
||||
orderCount: BigInt!
|
||||
|
||||
"has metadata"
|
||||
hasMetadata: Boolean!
|
||||
|
||||
nftData: [NftData!] @derivedFrom(field: "nft")
|
||||
transferHistory: [NftTransferHistory!] @derivedFrom(field: "nft")
|
||||
}
|
||||
|
||||
type PoolTransactionTokenValues @entity {
|
||||
id: ID! # pool tx + tokenAddress
|
||||
txId: PoolTransaction!
|
||||
poolToken: PoolToken!
|
||||
poolAddress: Pool!
|
||||
userAddress: User!
|
||||
tokenAddress: String!
|
||||
type NftData @entity{
|
||||
"nft address+key"
|
||||
id: ID!
|
||||
nft: Nft!
|
||||
key: Bytes
|
||||
value: Bytes
|
||||
}
|
||||
|
||||
value: BigDecimal!
|
||||
tokenReserve: BigDecimal!
|
||||
feeValue: BigDecimal! # Swap fee value in OCEAN
|
||||
type: String!
|
||||
}
|
||||
|
||||
type PoolTransaction @entity {
|
||||
id: ID! # pool tx
|
||||
poolAddress: Pool
|
||||
userAddress: User # User address that initiates the swap
|
||||
poolAddressStr: String!
|
||||
userAddressStr: String!
|
||||
|
||||
sharesTransferAmount: BigDecimal! #
|
||||
sharesBalance: BigDecimal!
|
||||
|
||||
spotPrice: BigDecimal!
|
||||
consumePrice: BigDecimal!
|
||||
tx: Bytes!
|
||||
event: String
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
gasUsed: BigDecimal!
|
||||
gasPrice: BigDecimal!
|
||||
|
||||
oceanReserve: BigDecimal!
|
||||
datatokenReserve: BigDecimal!
|
||||
|
||||
tokens: [PoolTransactionTokenValues!] @derivedFrom(field: "txId")
|
||||
}
|
||||
|
||||
type DatatokenFactory @entity {
|
||||
type OrderReuse @entity {
|
||||
id: ID!
|
||||
|
||||
tokenCount: Int! # Number of datatokens
|
||||
datatokens: [Datatoken!] @derivedFrom(field: "factoryID")
|
||||
}
|
||||
|
||||
type Datatoken @entity {
|
||||
id: ID! # token address
|
||||
factoryID: DatatokenFactory!
|
||||
|
||||
symbol: String
|
||||
name: String
|
||||
decimals: Int!
|
||||
address: String!
|
||||
cap: BigDecimal!
|
||||
supply: BigDecimal!
|
||||
minter: User!
|
||||
publisher: String!
|
||||
|
||||
holderCount: BigInt! # Number of addresses holding a balance of datatoken
|
||||
orderCount: BigInt! # Number of orders executed for this dataset
|
||||
metadataUpdateCount: BigInt!
|
||||
|
||||
orderVolume: BigDecimal
|
||||
createTime: Int! # Block time datatoken was created
|
||||
tx: Bytes # Datatoken creation transaction id
|
||||
|
||||
balances: [TokenBalance!] @derivedFrom(field: "datatokenId")
|
||||
orders: [TokenOrder!] @derivedFrom(field: "datatokenId")
|
||||
updates: [MetadataUpdate!] @derivedFrom(field: "datatokenId") # list of MetadataUpdate objects
|
||||
}
|
||||
|
||||
type MetadataUpdate @entity {
|
||||
id: ID! # update tx + datatokenAddress
|
||||
datatokenId: Datatoken!
|
||||
|
||||
datatokenAddress: String!
|
||||
userAddress: String!
|
||||
|
||||
order: Order!
|
||||
caller: String!
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
}
|
||||
providerFee: String
|
||||
providerFeeValidUntil: BigInt
|
||||
"gas price in Wei"
|
||||
gasPrice: BigInt
|
||||
gasUsed: BigDecimal
|
||||
}
|
||||
|
||||
type TokenOrder @entity {
|
||||
id: ID! # datatokenId + userAddress + tx
|
||||
datatokenId: Datatoken!
|
||||
type Order @entity {
|
||||
"transaction hash - token address - from address - eventIndex"
|
||||
id: ID!
|
||||
datatoken: Token!
|
||||
|
||||
consumer: User!
|
||||
payer: User!
|
||||
amount: BigDecimal!
|
||||
serviceId: Int!
|
||||
marketFeeCollector: User
|
||||
marketFee: BigDecimal!
|
||||
serviceIndex: Int!
|
||||
nftOwner: User!
|
||||
|
||||
timestamp: Int!
|
||||
tx: Bytes
|
||||
|
||||
# the fees will be updated from an event that will be created after (todo)
|
||||
publishingMarket: User
|
||||
publishingMarketToken: Token #
|
||||
publishingMarketAmmount: BigDecimal #call contract to get fee amount
|
||||
providerFee: String
|
||||
providerFeeValidUntil: BigInt
|
||||
|
||||
consumerMarket: User
|
||||
consumerMarketToken: Token #
|
||||
consumerMarketAmmount: BigDecimal #call contract to get fee amount
|
||||
|
||||
reuses: [OrderReuse!] @derivedFrom(field: "order")
|
||||
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type TokenBalance @entity {
|
||||
id: ID! # datatokenId + userAddress
|
||||
userAddress: User!
|
||||
datatokenId: Datatoken!
|
||||
balance: BigDecimal!
|
||||
}
|
||||
|
||||
type TokenTransaction @entity {
|
||||
id: ID! # Log ID
|
||||
event: String
|
||||
datatokenAddress: Datatoken
|
||||
userAddress: User
|
||||
|
||||
block: Int!
|
||||
gasUsed: BigDecimal!
|
||||
gasPrice: BigDecimal!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
lastPriceToken: Token
|
||||
lastPriceValue: BigDecimal!
|
||||
estimatedUSDValue: BigDecimal!
|
||||
gasUsed: BigDecimal
|
||||
"gas price in Wei"
|
||||
gasPrice: BigInt
|
||||
}
|
||||
|
||||
type User @entity {
|
||||
id: ID!
|
||||
|
||||
sharesOwned: [PoolShare!] @derivedFrom(field: "userAddress")
|
||||
tokenBalancesOwned: [TokenBalance!] @derivedFrom(field: "userAddress")
|
||||
tokensOwned: [Datatoken!] @derivedFrom(field: "minter")
|
||||
poolTransactions: [PoolTransaction!] @derivedFrom(field: "userAddress")
|
||||
poolTransactionsTokenValues: [PoolTransactionTokenValues!]
|
||||
@derivedFrom(field: "userAddress")
|
||||
tokenTransactions: [TokenTransaction!] @derivedFrom(field: "userAddress")
|
||||
orders: [TokenOrder!] @derivedFrom(field: "payer")
|
||||
tokenBalancesOwned: [TokenValuePair!]
|
||||
orders: [Order!] @derivedFrom(field: "payer")
|
||||
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
|
||||
|
||||
"total number of orders made by this user"
|
||||
totalOrders: BigInt!
|
||||
|
||||
"total number of orders made on assets owned by this user"
|
||||
totalSales: BigInt!
|
||||
}
|
||||
|
||||
type FixedRateExchange @entity {
|
||||
id: ID! # fixed rate exchange id
|
||||
exchangeOwner: User!
|
||||
datatoken: Datatoken!
|
||||
baseToken: String!
|
||||
baseTokenSymbol: String!
|
||||
rate: BigDecimal!
|
||||
"fixed rate exchange id"
|
||||
id: ID!
|
||||
contract: String!
|
||||
exchangeId: String!
|
||||
owner: User!
|
||||
datatoken: Token!
|
||||
baseToken: Token!
|
||||
"amount of datatokens available to be sold, this is relevant if the exchange is not able to mint"
|
||||
datatokenSupply: BigDecimal!
|
||||
"amount of basetokens available to be collected by the owner"
|
||||
baseTokenSupply: BigDecimal!
|
||||
datatokenBalance: BigDecimal!
|
||||
baseTokenBalance: BigDecimal!
|
||||
price: BigDecimal!
|
||||
active: Boolean!
|
||||
"amount of total basetokens spent"
|
||||
totalSwapValue: BigDecimal!
|
||||
"address that is allowed to swap tokens"
|
||||
allowedSwapper: String
|
||||
"if the owner allowes the fre to mint"
|
||||
withMint: Boolean
|
||||
"if the fre has the minter role on the datatoken"
|
||||
isMinter: Boolean
|
||||
|
||||
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
|
||||
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
||||
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
block: Int!
|
||||
|
||||
"address of the market where the datatoken was created. This address collects market fees."
|
||||
publishMarketFeeAddress: String
|
||||
|
||||
"fee amount. Fixed value"
|
||||
publishMarketSwapFee: BigDecimal
|
||||
|
||||
}
|
||||
|
||||
type FixedRateExchangeUpdate @entity {
|
||||
id: ID!
|
||||
exchangeId: FixedRateExchange!
|
||||
oldRate: BigDecimal!
|
||||
newRate: BigDecimal!
|
||||
oldActive: Boolean!
|
||||
newActive: Boolean!
|
||||
|
||||
oldPrice: BigDecimal
|
||||
newPrice: BigDecimal
|
||||
|
||||
oldActive: Boolean
|
||||
newActive: Boolean
|
||||
|
||||
oldAllowedSwapper: String
|
||||
newAllowedSwapper: String
|
||||
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type FixedRateExchangeSwap @entity {
|
||||
|
@ -253,31 +263,514 @@ type FixedRateExchangeSwap @entity {
|
|||
baseTokenAmount: BigDecimal!
|
||||
dataTokenAmount: BigDecimal!
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
oceanFeeAmount: BigDecimal!
|
||||
marketFeeAmount: BigDecimal!
|
||||
consumeMarketFeeAmount: BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
type Dispenser @entity {
|
||||
id: ID! # dispenser datatoken
|
||||
active: Boolean!
|
||||
owner: User!
|
||||
minterApproved: Boolean!
|
||||
isTrueMinter: Boolean!
|
||||
maxTokens: BigDecimal!
|
||||
maxBalance: BigDecimal!
|
||||
balance: BigDecimal!
|
||||
datatoken: Datatoken!
|
||||
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenserId")
|
||||
"token address"
|
||||
id: ID!
|
||||
contract: String!
|
||||
active: Boolean!
|
||||
"if using the enterprise template the owner will always be the erc721 factory, for normal template it will a user"
|
||||
owner: String
|
||||
token: Token!
|
||||
|
||||
allowedSwapper: String
|
||||
isMinter: Boolean
|
||||
"max tokens that can be dispensed"
|
||||
maxTokens: BigDecimal!
|
||||
"max balance of requester. If the balance is higher, the dispense is rejected"
|
||||
maxBalance: BigDecimal!
|
||||
"how many tokens are left"
|
||||
balance: BigDecimal!
|
||||
|
||||
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
|
||||
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
|
||||
}
|
||||
|
||||
type DispenserTransaction @entity {
|
||||
id: ID!
|
||||
dispenserId: Dispenser!
|
||||
datatoken: Datatoken!
|
||||
id: ID!
|
||||
dispenser: Dispenser!
|
||||
user: User!
|
||||
amount: BigDecimal!
|
||||
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
"utility type"
|
||||
type GlobalTotalLiquidityPair @entity {
|
||||
"address of the token"
|
||||
id : ID!
|
||||
globalStatistic: GlobalStatistic!
|
||||
token : Token!
|
||||
value : BigDecimal!
|
||||
}
|
||||
|
||||
"utility type"
|
||||
type GlobalTotalFixedSwapPair @entity {
|
||||
"address of the token"
|
||||
id : ID!
|
||||
globalStatistic: GlobalStatistic!
|
||||
token : Token!
|
||||
value : BigDecimal!
|
||||
count: BigInt!
|
||||
}
|
||||
type GlobalStatistic @entity {
|
||||
id: ID!
|
||||
|
||||
"total swap volume for each base token in fixed rate exchanges"
|
||||
totalFixedSwapVolume: [GlobalTotalFixedSwapPair!] @derivedFrom(field: "globalStatistic")
|
||||
|
||||
"number of total orders. fixed rate exchange orders + dispenser orders"
|
||||
orderCount: Int!
|
||||
|
||||
"total nfts(erc721) created"
|
||||
nftCount: Int!
|
||||
"total datatokens (tokens with isDatatoken = true) created"
|
||||
datatokenCount:Int!
|
||||
|
||||
"number of fixed rate exchanges"
|
||||
fixedCount: Int!
|
||||
|
||||
"number of dispensers created"
|
||||
dispenserCount: Int!
|
||||
|
||||
"total ocean locked in veOcean"
|
||||
totalOceanLocked:BigDecimal!
|
||||
|
||||
"current version"
|
||||
version: String
|
||||
}
|
||||
|
||||
type OPC @entity {
|
||||
id: ID!
|
||||
"fee in percent for swaps involving OPC approved tokens"
|
||||
swapOceanFee: BigDecimal
|
||||
"fee in percent for swaps involving non OPC approved tokens"
|
||||
swapNonOceanFee: BigDecimal
|
||||
"fee in percent taken by OPC from orderFees"
|
||||
orderFee: BigDecimal
|
||||
"fee in percent taken by OPC from providerFees"
|
||||
providerFee: BigDecimal
|
||||
approvedTokens: [Token!]
|
||||
}
|
||||
|
||||
enum NftUpdateType {
|
||||
METADATA_CREATED,
|
||||
METADATA_UPDATED,
|
||||
STATE_UPDATED,
|
||||
TOKENURI_UPDATED
|
||||
}
|
||||
|
||||
type NftUpdate @entity {
|
||||
id: ID! # update tx + nft address
|
||||
tokenUri: String
|
||||
nft: Nft!
|
||||
|
||||
"provider url that can decrypt the ddo"
|
||||
providerUrl: String
|
||||
|
||||
"user that made the update"
|
||||
userAddress: String!
|
||||
|
||||
"state of the asset in this update"
|
||||
assetState: Int!
|
||||
|
||||
"type of the update: metadata created, metadata update, state update, token uri update"
|
||||
type: NftUpdateType!
|
||||
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
type: String!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type Template @entity{
|
||||
id: ID!
|
||||
fixedRateTemplates: [String!]
|
||||
dispenserTemplates: [String!]
|
||||
}
|
||||
|
||||
# Not tracking allocationToId or idToAllocation
|
||||
type VeAllocateUser @entity{
|
||||
"id = {user}"
|
||||
id: ID!
|
||||
|
||||
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationUser")
|
||||
allocatedTotal: BigDecimal!
|
||||
|
||||
block: Int!
|
||||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
}
|
||||
|
||||
type VeAllocateId @entity{
|
||||
"id = {DataNFT Address}-{chain id}"
|
||||
id: ID!
|
||||
nftAddress: String!
|
||||
chainId: BigInt!
|
||||
|
||||
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationId")
|
||||
allocatedTotal: BigDecimal!
|
||||
|
||||
block: Int!
|
||||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
# we need to track allocation of user to id
|
||||
type VeAllocation @entity {
|
||||
"id = {user}-{DataNFT Address}-{chain id}"
|
||||
id: ID!
|
||||
|
||||
allocationUser: VeAllocateUser!
|
||||
allocationId: VeAllocateId!
|
||||
|
||||
updates: [VeAllocationUpdate!] @derivedFrom(field: "veAllocation")
|
||||
allocated: BigDecimal!
|
||||
chainId: BigInt!
|
||||
nftAddress: String!
|
||||
|
||||
block: Int!
|
||||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
enum veAllocationUpdateType {
|
||||
SET,
|
||||
REMOVED
|
||||
}
|
||||
|
||||
type VeAllocationUpdate @entity {
|
||||
"{tx}-{VeAllocation id}-{eventIndex}"
|
||||
id: ID!
|
||||
|
||||
veAllocation: VeAllocation!
|
||||
type: veAllocationUpdateType!
|
||||
allocatedTotal: BigDecimal!
|
||||
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type VeDelegation @entity {
|
||||
"id = VeDelegation contract + tokenId"
|
||||
id: ID!
|
||||
delegator: VeOCEAN!
|
||||
receiver: VeOCEAN!
|
||||
tokenId: BigInt!
|
||||
amount: BigDecimal!
|
||||
lockedAmount: BigDecimal!
|
||||
timeLeftUnlock: Int!
|
||||
cancelTime: BigInt!
|
||||
expireTime: BigInt!
|
||||
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
|
||||
|
||||
}
|
||||
|
||||
type VeDelegationUpdate @entity {
|
||||
"id = {tx}-{eventIndex}"
|
||||
id: ID!
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
sender: String!
|
||||
amount: BigDecimal!
|
||||
cancelTime: BigInt!
|
||||
expireTime: BigInt!
|
||||
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
|
||||
type:Int!
|
||||
veDelegation:VeDelegation!
|
||||
}
|
||||
|
||||
|
||||
type VeOCEAN @entity {
|
||||
"id = {user address}"
|
||||
id: ID!
|
||||
"total amount of locked tokens"
|
||||
lockedAmount: BigDecimal!
|
||||
"unlock timestamp"
|
||||
unlockTime: BigInt!
|
||||
delegation: [VeDelegation!] @derivedFrom(field: "delegator")
|
||||
delegates: [VeDelegation!] @derivedFrom(field: "receiver")
|
||||
deposits: [VeDeposit!] @derivedFrom(field: "veOcean")
|
||||
claims: [VeClaim!] @derivedFrom(field: "veOcean")
|
||||
allocation: VeAllocateUser @derivedFrom(field: "veOcean")
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type VeDeposit @entity {
|
||||
"id = {user address}-{tx}-{eventIndex}"
|
||||
id: ID!
|
||||
"veOcean holder"
|
||||
provider:String!
|
||||
"who initiated the tx"
|
||||
sender: String!
|
||||
"amount of tokens locked"
|
||||
value: BigDecimal!
|
||||
"unlock timestamp"
|
||||
unlockTime: BigInt!
|
||||
"deposit type: DEPOSIT_FOR = 0, CREATE_LOCK_TYPE = 1,INCREASE_LOCK_AMOUNT = 2,INCREASE_UNLOCK_TIME = 3, WITHDRAW = 4"
|
||||
type:BigInt!
|
||||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
totalOceanLocked:BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
type VeFeeDistributor @entity {
|
||||
"id = contract address"
|
||||
id: ID!
|
||||
"token used by FeeDistributor"
|
||||
token: Token!
|
||||
claims: [VeClaim!] @derivedFrom(field: "VeFeeDistributor")
|
||||
checkpoints: [VeFeeDistributorCheckPoint!] @derivedFrom(field: "VeFeeDistributor")
|
||||
}
|
||||
|
||||
type VeFeeDistributorCheckPoint @entity {
|
||||
"id = {tx}-{eventno}"
|
||||
id: ID!
|
||||
"amount of tokens for rewards"
|
||||
tokens: BigDecimal!
|
||||
"who initiated the tx"
|
||||
sender: String!
|
||||
VeFeeDistributor: VeFeeDistributor!
|
||||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type VeClaim @entity {
|
||||
"id = {tx}-{eventno}"
|
||||
id: ID!
|
||||
"amount of tokens claimed"
|
||||
amount: BigDecimal!
|
||||
"claim epoch"
|
||||
claim_epoch: BigInt
|
||||
"max_epoch"
|
||||
max_epoch: BigInt
|
||||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
VeFeeDistributor: VeFeeDistributor!
|
||||
}
|
||||
|
||||
enum DFHistoryType {
|
||||
Allocated,
|
||||
Claimed
|
||||
}
|
||||
|
||||
type DFAvailableClaim @entity {
|
||||
"id = {userId}-{tokenId}"
|
||||
id: ID!
|
||||
receiver: DFReward!
|
||||
amount: BigDecimal!
|
||||
token: Token!
|
||||
}
|
||||
|
||||
|
||||
type DFHistory @entity {
|
||||
"id = {user-id}-{txId}-{eventId}"
|
||||
id: ID!
|
||||
receiver: DFReward!
|
||||
amount: BigDecimal!
|
||||
token: Token!
|
||||
type: DFHistoryType!
|
||||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
|
||||
type DFReward @entity {
|
||||
"id = {user address}"
|
||||
id: ID!
|
||||
receiver: User!
|
||||
availableClaims: [DFAvailableClaim!] @derivedFrom(field: "receiver")
|
||||
history: [DFHistory!] @derivedFrom(field: "receiver")
|
||||
}
|
||||
|
||||
type NftTransferHistory @entity {
|
||||
# ID = hash(nftAddress+txId+eventNumber)
|
||||
id: ID!
|
||||
nft: Nft!
|
||||
oldOwner: User!
|
||||
newOwner: User!
|
||||
txId: String
|
||||
eventIndex: Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type Erc721Template @entity {
|
||||
#ID = template address
|
||||
id: ID!
|
||||
templateId: BigInt!
|
||||
}
|
||||
|
||||
type Erc20Template @entity {
|
||||
#ID = template address
|
||||
id: ID!
|
||||
templateId: BigInt!
|
||||
}
|
||||
|
||||
|
||||
|
||||
type PredictSubscription @entity{
|
||||
"id = {contract address}-{txid}-{eventIndex}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
user: User!
|
||||
expireTime: BigInt!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
enum PredictSlotStatus {
|
||||
Pending,
|
||||
Paying,
|
||||
Canceled
|
||||
}
|
||||
|
||||
|
||||
type PredictPayout @entity{
|
||||
"id = {contract address}-{slot}-{user}"
|
||||
id: ID!
|
||||
prediction: PredictPrediction!
|
||||
payout: BigDecimal!
|
||||
predictedValue: Boolean!
|
||||
trueValue: Boolean!
|
||||
aggregatedPredictedValue: BigDecimal!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictPrediction @entity{
|
||||
"id = {contract address}-{slot}-{user}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
user: User!
|
||||
stake: BigDecimal!
|
||||
payout: PredictPayout
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
|
||||
type PredictTrueVal @entity{
|
||||
"id = {contract address}-{slot}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
trueValue: Boolean!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictionRevenue @entity{
|
||||
"id = {contract address}-{slot}-{txid}-{eventIndex}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
amount: BigDecimal!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictSlot @entity{
|
||||
"id = {contract address}-{slot}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
slot: Int!
|
||||
predictions:[PredictPrediction!] @derivedFrom(field: "slot")
|
||||
trueValues: [PredictTrueVal!] @derivedFrom(field: "slot")
|
||||
revenue: BigDecimal!
|
||||
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
|
||||
status: PredictSlotStatus!
|
||||
roundSumStakesUp: BigDecimal!
|
||||
roundSumStakes: BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
type PredictSettingUpdate @entity{
|
||||
"id = {contract address}-{txId}-{eventIndex}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
secondsPerEpoch: BigInt!
|
||||
secondsPerSubscription: BigInt!
|
||||
truevalSubmitTimeout: BigInt!
|
||||
stakeToken: Token
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
type PredictContract @entity{
|
||||
"id = {contract address}"
|
||||
id: ID!
|
||||
token: Token!
|
||||
paused: Boolean!
|
||||
slots: [PredictSlot!] @derivedFrom(field: "predictContract")
|
||||
settingUpdates: [PredictSettingUpdate!] @derivedFrom(field: "predictContract")
|
||||
subscriptions: [PredictSubscription!] @derivedFrom(field: "predictContract")
|
||||
secondsPerEpoch: BigInt!
|
||||
secondsPerSubscription: BigInt!
|
||||
truevalSubmitTimeout: BigInt!
|
||||
stakeToken: Token
|
||||
"creation txId"
|
||||
txId: String
|
||||
"timestamp of creation tx"
|
||||
timestamp: Int!
|
||||
"block of creation tx"
|
||||
block: Int!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
var fs = require('fs')
|
||||
|
||||
async function replaceContractAddresses() {
|
||||
// load barge addresses first
|
||||
try {
|
||||
const data = JSON.parse(fs.readFileSync(process.env.ADDRESS_FILE, 'utf8'))
|
||||
const {
|
||||
DTFactory,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
BFactory,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
FixedRateExchange,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
Metadata,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
Dispenser
|
||||
} = data.development
|
||||
let subgraph = fs.readFileSync('subgraph.yaml', 'utf8')
|
||||
if (!data) {
|
||||
return false
|
||||
}
|
||||
// BFactory
|
||||
subgraph = subgraph.replace(
|
||||
/0xbe0083053744ECb871510C88dC0f6b77Da162706/g,
|
||||
BFactory
|
||||
)
|
||||
// dt factory
|
||||
subgraph = subgraph.replace(
|
||||
/0x57317f97E9EA49eBd19f7c9bB7c180b8cDcbDeB9/g,
|
||||
DTFactory
|
||||
)
|
||||
// metadata
|
||||
subgraph = subgraph.replace(
|
||||
/0x1a4b70d8c9DcA47cD6D0Fb3c52BB8634CA1C0Fdf/g,
|
||||
Metadata
|
||||
)
|
||||
// fixed rate exchgage
|
||||
subgraph = subgraph.replace(
|
||||
/0x608d05214E42722B94a54cF6114d4840FCfF84e1/g,
|
||||
FixedRateExchange
|
||||
)
|
||||
// dispenser
|
||||
subgraph = subgraph.replace(
|
||||
/0xDEfD0018969cd2d4E648209F876ADe184815f038/g,
|
||||
Dispenser
|
||||
)
|
||||
// network
|
||||
subgraph = subgraph.replace(/network: mainnet/g, 'network: barge')
|
||||
|
||||
// startBlocks
|
||||
subgraph = subgraph.replace(/startBlock:[ 0-9].*/g, 'startBlock: 0')
|
||||
|
||||
fs.writeFileSync('subgraph.barge.yaml', subgraph, 'utf8')
|
||||
} catch (e) {
|
||||
console.error('Failed to load address.json')
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
replaceContractAddresses()
|
|
@ -0,0 +1,75 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
const fs = require('fs')
|
||||
let addresses = require('@oceanprotocol/contracts/addresses/address.json')
|
||||
|
||||
async function replaceContractAddresses() {
|
||||
// load addresses file first
|
||||
if (!process.argv[2]) {
|
||||
console.error('Missing network..')
|
||||
return
|
||||
}
|
||||
if (process.env.ADDRESS_FILE) {
|
||||
console.log('Using custom ADDRESS_FILE instead of ocean-contracts npm dep')
|
||||
addresses = JSON.parse(fs.readFileSync(process.env.ADDRESS_FILE, 'utf8'))
|
||||
}
|
||||
|
||||
for (const network in addresses) {
|
||||
if (process.argv[2] != network) {
|
||||
console.log('Skipping ' + network)
|
||||
continue
|
||||
}
|
||||
console.log('Creating subgraph.yaml for ' + network)
|
||||
let subgraph = fs.readFileSync('./subgraph.template.yaml', 'utf8')
|
||||
const subgraphVe = fs.readFileSync('./subgraph_ve.template.yaml', 'utf8')
|
||||
if (addresses[network].veOCEAN) {
|
||||
console.log('\t Adding veOCEAN')
|
||||
// fix identation , due to vs auto format (subgraph_ve.template is moved to left)
|
||||
const lines = subgraphVe.split('\n')
|
||||
for (let line = 0; line < lines.length; line++) {
|
||||
subgraph += ' ' + lines[line] + '\n'
|
||||
}
|
||||
}
|
||||
|
||||
subgraph = subgraph.replace(/__NETWORK__/g, network)
|
||||
subgraph = subgraph.replace(
|
||||
/__STARTBLOCK__/g,
|
||||
addresses[network].startBlock
|
||||
)
|
||||
subgraph = subgraph.replace(
|
||||
/__ERC721FACTORYADDRESS__/g,
|
||||
"'" + addresses[network].ERC721Factory + "'"
|
||||
)
|
||||
subgraph = subgraph.replace(
|
||||
/__FACTORYROUTERADDRESS__/g,
|
||||
"'" + addresses[network].Router + "'"
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/__VEALLOCATEADDRESS__/g,
|
||||
"'" + addresses[network].veAllocate + "'"
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/__VEOCEANADDRESS__/g,
|
||||
"'" + addresses[network].veOCEAN + "'"
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/__VEDELEGATIONADDRESS__/g,
|
||||
"'" + addresses[network].veDelegation + "'"
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/__VEFEEDISTRIBUTORNADDRESS__/g,
|
||||
"'" + addresses[network].veFeeDistributor + "'"
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/__DFREWARDSADDRESS__/g,
|
||||
"'" + addresses[network].DFRewards + "'"
|
||||
)
|
||||
fs.writeFileSync('subgraph.yaml', subgraph, 'utf8')
|
||||
}
|
||||
}
|
||||
|
||||
replaceContractAddresses()
|
|
@ -0,0 +1,17 @@
|
|||
const fs = require('fs')
|
||||
const packageJson = require('../package.json')
|
||||
|
||||
async function replaceVersion() {
|
||||
let globalUtils = fs.readFileSync(
|
||||
'./src/mappings/utils/globalUtils.ts',
|
||||
'utf8'
|
||||
)
|
||||
globalUtils = globalUtils.replace(
|
||||
/.*globalStats\.version.*\n/,
|
||||
" globalStats.version = '" + packageJson.version + "'\n"
|
||||
)
|
||||
|
||||
fs.writeFileSync('./src/mappings/utils/globalUtils.ts', globalUtils, 'utf8')
|
||||
}
|
||||
|
||||
replaceVersion()
|
606
src/helpers.ts
606
src/helpers.ts
|
@ -1,606 +0,0 @@
|
|||
import {
|
||||
BigDecimal,
|
||||
BigInt,
|
||||
Bytes,
|
||||
dataSource,
|
||||
Address,
|
||||
ethereum,
|
||||
log
|
||||
} from '@graphprotocol/graph-ts'
|
||||
|
||||
import {
|
||||
Pool as PoolEntity,
|
||||
User,
|
||||
PoolToken,
|
||||
PoolShare,
|
||||
PoolTransaction,
|
||||
PoolFactory,
|
||||
Datatoken,
|
||||
TokenBalance,
|
||||
TokenTransaction,
|
||||
PoolTransactionTokenValues,
|
||||
Global
|
||||
} from './@types/schema'
|
||||
|
||||
import { Pool } from './@types/templates/Pool/Pool'
|
||||
import { ERC20 } from './@types/templates/Pool/ERC20'
|
||||
import { ERC20SymbolBytes } from './@types/templates/Pool/ERC20SymbolBytes'
|
||||
import { ERC20NameBytes } from './@types/templates/Pool/ERC20NameBytes'
|
||||
|
||||
export const ZERO_BD = BigDecimal.fromString('0.0')
|
||||
export const MINUS_1_BD = BigDecimal.fromString('-1.0')
|
||||
export const ONE_BD = BigDecimal.fromString('1.0')
|
||||
|
||||
export const ONE_BASE_18 = BigInt.fromI32(10).pow(18 as u8)
|
||||
export const BONE = BigDecimal.fromString('1000000000000000000')
|
||||
|
||||
export const ENABLE_DEBUG = true
|
||||
|
||||
const network = dataSource.network()
|
||||
|
||||
export function getOceanAddress(): string {
|
||||
// switch is not working for some reason
|
||||
if (network == 'ropsten') return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
|
||||
if (network == 'rinkeby') return '0x8967bcf84170c91b0d24d4302c2376283b0b3a07'
|
||||
if (network == 'polygon') return '0x282d8efce846a88b159800bd4130ad77443fa1a1'
|
||||
if (network == 'moonbeamalpha')
|
||||
return '0xf6410bf5d773c7a41ebff972f38e7463fa242477'
|
||||
if (network == 'gaiaxtestnet')
|
||||
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
|
||||
if (network == 'mumbai') return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
|
||||
if (network == 'bsc') return '0xdce07662ca8ebc241316a15b611c89711414dd1a'
|
||||
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
|
||||
}
|
||||
|
||||
export const OCEAN: string = getOceanAddress()
|
||||
|
||||
export function getGlobalStats(): Global | null {
|
||||
let gStats: Global | null = Global.load('1')
|
||||
if (gStats == null) {
|
||||
gStats = new Global('1')
|
||||
gStats.totalOceanLiquidity = ZERO_BD
|
||||
gStats.totalSwapVolume = ZERO_BD
|
||||
gStats.totalValueLocked = ZERO_BD
|
||||
gStats.totalOrderVolume = ZERO_BD
|
||||
gStats.orderCount = BigInt.fromI32(0)
|
||||
gStats.poolCount = 0
|
||||
}
|
||||
|
||||
return gStats
|
||||
}
|
||||
|
||||
export function _debuglog(
|
||||
message: string,
|
||||
event: ethereum.Event,
|
||||
args: Array<string>
|
||||
): void {
|
||||
if (event != null) {
|
||||
args.push(event.transaction.hash.toHex())
|
||||
args.push(event.address.toHex())
|
||||
}
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
message = message.concat(' {}')
|
||||
}
|
||||
log.debug('@@@@@@ ' + message, args)
|
||||
}
|
||||
|
||||
export function debuglog(
|
||||
message: string,
|
||||
event: ethereum.Event,
|
||||
args: Array<string>
|
||||
): void {
|
||||
if (!ENABLE_DEBUG) return
|
||||
_debuglog(message, event, args)
|
||||
}
|
||||
|
||||
export function hexToDecimal(hexString: string, decimals: i32): BigDecimal {
|
||||
const bytes = Bytes.fromHexString(hexString.toString()).reverse() as Bytes
|
||||
const bi = BigInt.fromUnsignedBytes(bytes)
|
||||
const scale = BigInt.fromI32(10)
|
||||
.pow(decimals as u8)
|
||||
.toBigDecimal()
|
||||
return bi.divDecimal(scale)
|
||||
}
|
||||
|
||||
export function bigIntToDecimal(amount: BigInt, decimals: i32): BigDecimal {
|
||||
const scale = BigInt.fromI32(10)
|
||||
.pow(decimals as u8)
|
||||
.toBigDecimal()
|
||||
return amount.toBigDecimal().div(scale)
|
||||
}
|
||||
|
||||
export function tokenToDecimal(amount: BigDecimal, decimals: i32): BigDecimal {
|
||||
const scale = BigInt.fromI32(10)
|
||||
.pow(decimals as u8)
|
||||
.toBigDecimal()
|
||||
return amount.div(scale)
|
||||
}
|
||||
|
||||
export function decimalToBigInt(value: BigDecimal): BigInt {
|
||||
value.truncate(18)
|
||||
const scale = BigInt.fromI32(10).pow((value.exp.toI32() + 18) as u8)
|
||||
return value.digits.times(scale)
|
||||
}
|
||||
|
||||
export function isNullEthValue(value: string): boolean {
|
||||
return (
|
||||
value ==
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000001'
|
||||
)
|
||||
}
|
||||
|
||||
export function getTokenSymbol(tokenAddress: Address): string {
|
||||
const contract = ERC20.bind(tokenAddress)
|
||||
const contractSymbolBytes = ERC20SymbolBytes.bind(tokenAddress)
|
||||
|
||||
// try types string and bytes32 for symbol
|
||||
let symbolValue = 'unknown'
|
||||
const symbolResult = contract.try_symbol()
|
||||
if (symbolResult.reverted) {
|
||||
const symbolResultBytes = contractSymbolBytes.try_symbol()
|
||||
if (!symbolResultBytes.reverted) {
|
||||
// for broken pairs that have no symbol function exposed
|
||||
if (!isNullEthValue(symbolResultBytes.value.toHexString())) {
|
||||
symbolValue = symbolResultBytes.value.toString()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
symbolValue = symbolResult.value
|
||||
}
|
||||
|
||||
return symbolValue
|
||||
}
|
||||
|
||||
export function getTokenName(tokenAddress: Address): string {
|
||||
const contract = ERC20.bind(tokenAddress)
|
||||
const contractNameBytes = ERC20NameBytes.bind(tokenAddress)
|
||||
|
||||
// try types string and bytes32 for name
|
||||
let nameValue = 'unknown'
|
||||
const nameResult = contract.try_name()
|
||||
if (nameResult.reverted) {
|
||||
const nameResultBytes = contractNameBytes.try_name()
|
||||
if (!nameResultBytes.reverted) {
|
||||
// for broken exchanges that have no name function exposed
|
||||
if (!isNullEthValue(nameResultBytes.value.toHexString())) {
|
||||
nameValue = nameResultBytes.value.toString()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nameValue = nameResult.value
|
||||
}
|
||||
|
||||
return nameValue
|
||||
}
|
||||
|
||||
export function getTokenDecimals(tokenAddress: Address): i32 {
|
||||
const contract = ERC20.bind(tokenAddress)
|
||||
let decimals = 18
|
||||
const decimalCall = contract.try_decimals()
|
||||
if (!decimalCall.reverted) {
|
||||
decimals = decimalCall.value
|
||||
}
|
||||
return decimals
|
||||
}
|
||||
|
||||
export function updatePoolTokenBalance(
|
||||
poolToken: PoolToken,
|
||||
balance: BigDecimal,
|
||||
source: string
|
||||
): void {
|
||||
debuglog(
|
||||
'########## updating poolToken balance (source, oldBalance, newBalance, poolId) ',
|
||||
null,
|
||||
[source, poolToken.balance.toString(), balance.toString(), poolToken.poolId]
|
||||
)
|
||||
if (balance < ZERO_BD || poolToken.balance < ZERO_BD) {
|
||||
log.warning(
|
||||
'EEEEEEEEEEEEEEEEE poolToken.balance < Zero: pool={}, poolToken={}, oldBalance={}, newBalance={}',
|
||||
[
|
||||
poolToken.poolId,
|
||||
poolToken.address.toString(),
|
||||
poolToken.balance.toString(),
|
||||
balance.toString()
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
poolToken.balance = balance
|
||||
}
|
||||
|
||||
export function updatePoolSwapVolume(
|
||||
pool: Pool,
|
||||
swapAmount: BigDecimal
|
||||
// source: string
|
||||
): void {
|
||||
debuglog(
|
||||
'########## updating poolToken balance (source, oldBalance, newBalance, poolId) ',
|
||||
null,
|
||||
[source, pool.totalSwapVolume.toString(), swapAmount.toString(), pool.id]
|
||||
)
|
||||
if (swapAmount < ZERO_BD || pool.totalSwapVolume < ZERO_BD) {
|
||||
log.warning(
|
||||
'EEEEEEEEEEEEEEEEE poolToken.balance < Zero: pool={}, poolToken={}, oldBalance={}, newBalance={}',
|
||||
[
|
||||
pool.id,
|
||||
poolToken.tokenAddress.toString(),
|
||||
poolToken.balance.toString(),
|
||||
swapAmount.toString()
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
poolToken.swapBalanceOcean = poolToken.swapBalanceOcean.plus(swapAmount)
|
||||
}
|
||||
export function createUserEntity(address: string): void {
|
||||
if (User.load(address) == null) {
|
||||
const user = new User(address)
|
||||
user.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function createPoolShareEntity(
|
||||
id: string,
|
||||
pool: string,
|
||||
user: string
|
||||
): void {
|
||||
const poolShare = new PoolShare(id)
|
||||
|
||||
createUserEntity(user)
|
||||
|
||||
poolShare.userAddress = user
|
||||
poolShare.poolId = pool
|
||||
poolShare.balance = ZERO_BD
|
||||
poolShare.save()
|
||||
}
|
||||
|
||||
export function createPoolTokenEntity(
|
||||
id: string,
|
||||
pool: string,
|
||||
address: Address
|
||||
): void {
|
||||
const datatoken = Datatoken.load(address.toHexString())
|
||||
|
||||
const poolToken = new PoolToken(id)
|
||||
poolToken.poolId = pool
|
||||
poolToken.isDatatoken = !!datatoken
|
||||
poolToken.tokenId = datatoken ? datatoken.id : ''
|
||||
poolToken.address = address.toHexString()
|
||||
poolToken.balance = ZERO_BD
|
||||
poolToken.denormWeight = ZERO_BD
|
||||
poolToken.symbol = getTokenSymbol(address)
|
||||
poolToken.name = getTokenName(address)
|
||||
poolToken.decimals = getTokenDecimals(address)
|
||||
poolToken.save()
|
||||
}
|
||||
|
||||
export function updatePoolTransactionToken(
|
||||
poolTx: string,
|
||||
poolTokenId: string,
|
||||
amount: BigDecimal,
|
||||
balance: BigDecimal,
|
||||
feeValue: BigDecimal
|
||||
): void {
|
||||
log.warning('WWWWWWWWWW ---- started update ptx with id {}', [poolTx])
|
||||
log.warning('updatePoolTransactionToken({}, {} , {} , {} , {}}', [
|
||||
poolTx,
|
||||
poolTokenId,
|
||||
amount.toString(),
|
||||
balance.toString(),
|
||||
feeValue.toString()
|
||||
])
|
||||
const ptx = PoolTransaction.load(poolTx)
|
||||
const poolToken = PoolToken.load(poolTokenId)
|
||||
const pool = PoolEntity.load(poolToken.poolId)
|
||||
if (!ptx) {
|
||||
log.error('Cannot load PoolTransaction {}', [poolTx])
|
||||
return
|
||||
}
|
||||
if (!poolToken) {
|
||||
log.error('Cannot load PoolToken {}', [poolTokenId])
|
||||
return
|
||||
}
|
||||
if (!pool) {
|
||||
log.error('Cannot load PoolEntity {}', [poolToken.poolId])
|
||||
return
|
||||
}
|
||||
const ptxTokenValuesId = poolTx.concat('-').concat(poolToken.tokenAddress)
|
||||
let ptxTokenValues = PoolTransactionTokenValues.load(ptxTokenValuesId)
|
||||
if (ptxTokenValues == null) {
|
||||
ptxTokenValues = new PoolTransactionTokenValues(ptxTokenValuesId)
|
||||
log.warning('created PoolTransactionTokenValues for {}', [ptxTokenValuesId])
|
||||
}
|
||||
ptxTokenValues.txId = poolTx
|
||||
ptxTokenValues.poolToken = poolTokenId
|
||||
ptxTokenValues.poolAddress = poolToken.poolId
|
||||
ptxTokenValues.userAddress = ptx.userAddress
|
||||
ptxTokenValues.tokenAddress = PoolToken.load(poolTokenId).address
|
||||
|
||||
ptxTokenValues.value = amount
|
||||
ptxTokenValues.tokenReserve = balance
|
||||
ptxTokenValues.feeValue = feeValue
|
||||
if (amount.lt(ZERO_BD)) {
|
||||
ptxTokenValues.type = 'out'
|
||||
} else {
|
||||
ptxTokenValues.type = 'in'
|
||||
}
|
||||
|
||||
ptxTokenValues.save()
|
||||
log.warning('ptxTokenValues {} saved', [ptxTokenValues.id])
|
||||
if (ptxTokenValues.tokenAddress == OCEAN) {
|
||||
const factory = PoolFactory.load('1')
|
||||
|
||||
factory.totalOceanLiquidity = factory.totalOceanLiquidity
|
||||
.plus(ptxTokenValues.tokenReserve)
|
||||
.minus(pool.oceanReserve)
|
||||
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
gStats.totalOceanLiquidity = factory.totalOceanLiquidity
|
||||
|
||||
gStats.save()
|
||||
if (factory.totalOceanLiquidity < ZERO_BD || pool.oceanReserve < ZERO_BD) {
|
||||
log.warning(
|
||||
'EEEEEEEEEEEEEEEEE totalOceanLiquidity or oceanReserve < Zero: pool={}, totOcnLiq={}, ocnRes={}',
|
||||
[
|
||||
pool.id,
|
||||
factory.totalOceanLiquidity.toString(),
|
||||
pool.oceanReserve.toString()
|
||||
]
|
||||
)
|
||||
}
|
||||
ptx.oceanReserve = ptxTokenValues.tokenReserve
|
||||
pool.oceanReserve = ptxTokenValues.tokenReserve
|
||||
factory.save()
|
||||
} else {
|
||||
ptx.datatokenReserve = ptxTokenValues.tokenReserve
|
||||
pool.datatokenReserve = ptxTokenValues.tokenReserve
|
||||
}
|
||||
// debuglog('########## updatePoolTransactionToken: ', null, [
|
||||
// BigInt.fromI32(ptx.block).toString(),
|
||||
// BigInt.fromI32(ptx.timestamp).toString(),
|
||||
// ptxTokenValues.type,
|
||||
// ptxTokenValues.value.toString(),
|
||||
// ptxTokenValues.tokenReserve.toString(),
|
||||
// poolToken.poolId
|
||||
// ])
|
||||
log.warning('saving ptx {} ', [ptx.id.toString()])
|
||||
ptx.save()
|
||||
log.warning('saving pool {} ', [pool.id.toString()])
|
||||
pool.save()
|
||||
}
|
||||
|
||||
export function calcSpotPrice(
|
||||
balanceIn: BigDecimal,
|
||||
wIn: BigDecimal,
|
||||
balanceOut: BigDecimal,
|
||||
wOut: BigDecimal,
|
||||
swapFee: BigDecimal
|
||||
): BigDecimal {
|
||||
if (balanceIn <= ZERO_BD || balanceOut <= ZERO_BD) return MINUS_1_BD
|
||||
debuglog('################ calcSpotPrice', null, [
|
||||
balanceIn.toString(),
|
||||
wIn.toString(),
|
||||
balanceOut.toString(),
|
||||
wOut.toString(),
|
||||
swapFee.toString()
|
||||
])
|
||||
|
||||
const numer = balanceIn.div(wIn)
|
||||
const denom = balanceOut.div(wOut)
|
||||
if (denom <= ZERO_BD) return MINUS_1_BD
|
||||
|
||||
const ratio = numer.div(denom)
|
||||
const scale = ONE_BD.div(ONE_BD.minus(swapFee))
|
||||
const price = ratio.times(scale)
|
||||
price.truncate(18)
|
||||
debuglog('################ calcSpotPrice values:', null, [
|
||||
numer.toString(),
|
||||
denom.toString(),
|
||||
ratio.toString(),
|
||||
scale.toString(),
|
||||
price.toString()
|
||||
])
|
||||
return price
|
||||
}
|
||||
|
||||
export function createPoolTransaction(
|
||||
event: ethereum.Event,
|
||||
// eslint-disable-next-line camelcase
|
||||
event_type: string,
|
||||
userAddress: string
|
||||
): void {
|
||||
const poolId = event.address.toHex()
|
||||
const pool = PoolEntity.load(poolId)
|
||||
const ptx = event.transaction.hash.toHexString()
|
||||
|
||||
const ocnToken = PoolToken.load(poolId.concat('-').concat(OCEAN))
|
||||
const dtToken = PoolToken.load(
|
||||
poolId.concat('-').concat(pool.datatokenAddress)
|
||||
)
|
||||
if (ocnToken == null || dtToken == null) {
|
||||
return
|
||||
}
|
||||
|
||||
let poolTx = PoolTransaction.load(ptx)
|
||||
if (poolTx != null) {
|
||||
return
|
||||
}
|
||||
poolTx = new PoolTransaction(ptx)
|
||||
|
||||
poolTx.poolAddress = poolId
|
||||
poolTx.userAddress = userAddress
|
||||
poolTx.poolAddressStr = poolId
|
||||
poolTx.userAddressStr = userAddress
|
||||
|
||||
poolTx.sharesTransferAmount = ZERO_BD
|
||||
poolTx.sharesBalance = ZERO_BD
|
||||
|
||||
// pool.datatokenReserve = dtToken.balance
|
||||
// pool.oceanReserve = ocnToken.balance
|
||||
// Initial reserve values, will be updated in `updatePoolTransactionToken`
|
||||
poolTx.datatokenReserve = dtToken.balance
|
||||
poolTx.oceanReserve = ocnToken.balance
|
||||
debuglog('poolTX reserves:(dt, ocean)', null, [
|
||||
poolTx.datatokenReserve.toString(),
|
||||
poolTx.oceanReserve.toString()
|
||||
])
|
||||
|
||||
const p = Pool.bind(Address.fromString(poolId))
|
||||
debuglog(
|
||||
'createPoolTransaction args sent to calcInGivenOut (ocnBalance, ocnWeight, dtBalance, dtWeight, dtAmount, swapFee)',
|
||||
null,
|
||||
[
|
||||
decimalToBigInt(ocnToken.balance).toString(),
|
||||
decimalToBigInt(ocnToken.denormWeight).toString(),
|
||||
decimalToBigInt(dtToken.balance).toString(),
|
||||
decimalToBigInt(dtToken.denormWeight).toString(),
|
||||
ONE_BASE_18.toString(),
|
||||
decimalToBigInt(pool.swapFee).toString()
|
||||
]
|
||||
)
|
||||
const priceResult = p.try_calcInGivenOut(
|
||||
decimalToBigInt(ocnToken.balance),
|
||||
decimalToBigInt(ocnToken.denormWeight),
|
||||
decimalToBigInt(dtToken.balance),
|
||||
decimalToBigInt(dtToken.denormWeight),
|
||||
ONE_BASE_18,
|
||||
decimalToBigInt(pool.swapFee)
|
||||
)
|
||||
debuglog('got results', null, [])
|
||||
poolTx.consumePrice = priceResult.reverted
|
||||
? MINUS_1_BD
|
||||
: bigIntToDecimal(priceResult.value, 18)
|
||||
debuglog('calcInGivenOut:', null, [
|
||||
priceResult.reverted ? 'failed' : priceResult.value.toString()
|
||||
])
|
||||
|
||||
const priceSpot = p.try_calcSpotPrice(
|
||||
decimalToBigInt(ocnToken.balance),
|
||||
decimalToBigInt(ocnToken.denormWeight),
|
||||
decimalToBigInt(dtToken.balance),
|
||||
decimalToBigInt(dtToken.denormWeight),
|
||||
decimalToBigInt(pool.swapFee)
|
||||
)
|
||||
poolTx.spotPrice = priceSpot.reverted
|
||||
? ZERO_BD
|
||||
: bigIntToDecimal(priceSpot.value, 18)
|
||||
debuglog('SpotPrice:', null, [
|
||||
priceSpot.reverted ? 'failed' : priceSpot.value.toString()
|
||||
])
|
||||
|
||||
pool.consumePrice = poolTx.consumePrice
|
||||
pool.spotPrice = poolTx.spotPrice
|
||||
const oldValueLocked = pool.valueLocked
|
||||
const spotPrice = pool.spotPrice >= ZERO_BD ? pool.spotPrice : ZERO_BD
|
||||
pool.valueLocked = poolTx.oceanReserve.plus(
|
||||
poolTx.datatokenReserve.times(spotPrice)
|
||||
)
|
||||
const factory = PoolFactory.load('1')
|
||||
if (oldValueLocked < ZERO_BD || pool.valueLocked < ZERO_BD) {
|
||||
log.warning(
|
||||
'EEEEEEEEEEEEEEEEE valueLocked < Zero: pool={}, oldVL={}, newVL={}, OCEAN={}, DT={}, spotPrice={}',
|
||||
[
|
||||
pool.id,
|
||||
oldValueLocked.toString(),
|
||||
pool.valueLocked.toString(),
|
||||
poolTx.oceanReserve.toString(),
|
||||
poolTx.datatokenReserve.toString(),
|
||||
pool.spotPrice.toString()
|
||||
]
|
||||
)
|
||||
}
|
||||
factory.totalValueLocked = factory.totalValueLocked
|
||||
.minus(oldValueLocked)
|
||||
.plus(pool.valueLocked)
|
||||
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
|
||||
gStats.totalValueLocked = factory.totalValueLocked
|
||||
gStats.save()
|
||||
|
||||
pool.transactionCount = pool.transactionCount.plus(BigInt.fromI32(1))
|
||||
|
||||
pool.save()
|
||||
factory.save()
|
||||
|
||||
debuglog(
|
||||
'updated pool reserves (source, dtBalance, ocnBalance, dtReserve, ocnReserve): ',
|
||||
event,
|
||||
[
|
||||
'createPoolTransaction',
|
||||
dtToken.balance.toString(),
|
||||
ocnToken.balance.toString(),
|
||||
pool.datatokenReserve.toString(),
|
||||
pool.oceanReserve.toString()
|
||||
]
|
||||
)
|
||||
|
||||
poolTx.tx = event.transaction.hash
|
||||
// eslint-disable-next-line camelcase
|
||||
poolTx.event = event_type
|
||||
poolTx.block = event.block.number.toI32()
|
||||
poolTx.timestamp = event.block.timestamp.toI32()
|
||||
poolTx.gasUsed = event.transaction.gasUsed.toBigDecimal()
|
||||
poolTx.gasPrice = event.transaction.gasPrice.toBigDecimal()
|
||||
|
||||
debuglog('####################### poolTransaction: ', event, [
|
||||
ptx,
|
||||
BigInt.fromI32(poolTx.block).toString(),
|
||||
BigInt.fromI32(poolTx.timestamp).toString(),
|
||||
pool.oceanReserve.toString()
|
||||
])
|
||||
|
||||
poolTx.save()
|
||||
}
|
||||
|
||||
export function decrPoolCount(finalized: boolean): void {
|
||||
const factory = PoolFactory.load('1')
|
||||
factory.poolCount -= 1
|
||||
if (finalized) factory.finalizedPoolCount -= 1
|
||||
factory.save()
|
||||
}
|
||||
|
||||
export function saveTokenTransaction(
|
||||
event: ethereum.Event,
|
||||
eventName: string
|
||||
): void {
|
||||
const tx = event.transaction.hash
|
||||
.toHexString()
|
||||
.concat('-')
|
||||
.concat(event.logIndex.toString())
|
||||
const userAddress = event.transaction.from.toHex()
|
||||
let transaction = TokenTransaction.load(tx)
|
||||
if (transaction == null) {
|
||||
transaction = new TokenTransaction(tx)
|
||||
}
|
||||
transaction.event = eventName
|
||||
transaction.datatokenAddress = event.address.toHex()
|
||||
transaction.userAddress = userAddress
|
||||
transaction.gasUsed = event.transaction.gasUsed.toBigDecimal()
|
||||
transaction.gasPrice = event.transaction.gasPrice.toBigDecimal()
|
||||
transaction.tx = event.transaction.hash
|
||||
transaction.timestamp = event.block.timestamp.toI32()
|
||||
transaction.block = event.block.number.toI32()
|
||||
transaction.save()
|
||||
|
||||
createUserEntity(userAddress)
|
||||
}
|
||||
|
||||
export function updateTokenBalance(
|
||||
id: string,
|
||||
token: string,
|
||||
user: string,
|
||||
amount: BigDecimal
|
||||
): void {
|
||||
let tokenBalance = TokenBalance.load(id)
|
||||
if (tokenBalance == null) {
|
||||
tokenBalance = new TokenBalance(id)
|
||||
createUserEntity(user)
|
||||
tokenBalance.userAddress = user
|
||||
tokenBalance.datatokenId = token
|
||||
tokenBalance.balance = ZERO_BD
|
||||
}
|
||||
|
||||
tokenBalance.balance = tokenBalance.balance.plus(amount)
|
||||
tokenBalance.save()
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
import { BigInt, BigDecimal } from '@graphprotocol/graph-ts'
|
||||
import { OrderStarted, Transfer } from '../@types/templates/DataToken/DataToken'
|
||||
|
||||
import {
|
||||
Datatoken,
|
||||
Global,
|
||||
PoolFactory,
|
||||
TokenBalance,
|
||||
TokenOrder
|
||||
} from '../@types/schema'
|
||||
import {
|
||||
tokenToDecimal,
|
||||
updateTokenBalance,
|
||||
ZERO_BD,
|
||||
MINUS_1_BD,
|
||||
saveTokenTransaction,
|
||||
getGlobalStats
|
||||
} from '../helpers'
|
||||
|
||||
/************************************
|
||||
********** Pool Controls ***********
|
||||
************************************/
|
||||
|
||||
export function handleTransfer(event: Transfer): void {
|
||||
const tokenId = event.address.toHex()
|
||||
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
|
||||
const amount = tokenToDecimal(event.params.value.toBigDecimal(), 18)
|
||||
const tokenShareFrom = event.params.from.toHex()
|
||||
const tokenShareTo = event.params.to.toHex()
|
||||
const tokenBalanceFromId = tokenId.concat('-').concat(tokenShareFrom)
|
||||
const tokenBalanceToId = tokenId.concat('-').concat(tokenShareTo)
|
||||
let tokenBalanceFrom = TokenBalance.load(tokenBalanceFromId)
|
||||
let tokenBalanceTo = TokenBalance.load(tokenBalanceToId)
|
||||
let oldBalanceFrom = BigDecimal.fromString('0.0')
|
||||
let oldBalanceTo = BigDecimal.fromString('0.0')
|
||||
|
||||
const isMint = tokenShareFrom == ZERO_ADDRESS
|
||||
const isBurn = tokenShareTo == ZERO_ADDRESS
|
||||
|
||||
const datatoken = Datatoken.load(tokenId)
|
||||
|
||||
if (isMint) {
|
||||
tokenBalanceTo = TokenBalance.load(tokenBalanceToId)
|
||||
oldBalanceTo = tokenBalanceTo == null ? ZERO_BD : tokenBalanceTo.balance
|
||||
datatoken.supply = datatoken.supply.plus(amount)
|
||||
updateTokenBalance(tokenBalanceToId, tokenId, tokenShareTo, amount)
|
||||
} else if (isBurn) {
|
||||
tokenBalanceFrom = TokenBalance.load(tokenBalanceFromId)
|
||||
oldBalanceFrom =
|
||||
tokenBalanceFrom == null ? ZERO_BD : tokenBalanceFrom.balance
|
||||
datatoken.supply = datatoken.supply.minus(amount)
|
||||
updateTokenBalance(
|
||||
tokenBalanceFromId,
|
||||
tokenId,
|
||||
tokenShareFrom,
|
||||
amount.times(MINUS_1_BD)
|
||||
)
|
||||
} else {
|
||||
tokenBalanceFrom = TokenBalance.load(tokenBalanceFromId)
|
||||
oldBalanceFrom =
|
||||
tokenBalanceFrom == null ? ZERO_BD : tokenBalanceFrom.balance
|
||||
datatoken.supply = datatoken.supply.minus(amount)
|
||||
updateTokenBalance(
|
||||
tokenBalanceFromId,
|
||||
tokenId,
|
||||
tokenShareFrom,
|
||||
amount.times(MINUS_1_BD)
|
||||
)
|
||||
|
||||
tokenBalanceTo = TokenBalance.load(tokenBalanceToId)
|
||||
oldBalanceTo = tokenBalanceTo == null ? ZERO_BD : tokenBalanceTo.balance
|
||||
datatoken.supply = datatoken.supply.plus(amount)
|
||||
updateTokenBalance(tokenBalanceToId, tokenId, tokenShareTo, amount)
|
||||
}
|
||||
|
||||
if (
|
||||
tokenBalanceTo != null &&
|
||||
tokenBalanceTo.balance.notEqual(ZERO_BD) &&
|
||||
oldBalanceTo.equals(ZERO_BD)
|
||||
) {
|
||||
datatoken.holderCount += BigInt.fromI32(1)
|
||||
}
|
||||
|
||||
if (
|
||||
tokenBalanceFrom != null &&
|
||||
tokenBalanceFrom.balance.equals(ZERO_BD) &&
|
||||
oldBalanceFrom.notEqual(ZERO_BD)
|
||||
) {
|
||||
datatoken.holderCount -= BigInt.fromI32(1)
|
||||
}
|
||||
|
||||
datatoken.save()
|
||||
saveTokenTransaction(event, 'Transfer')
|
||||
}
|
||||
|
||||
export function handleOrderStarted(event: OrderStarted): void {
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
const tokenId = event.address.toHex()
|
||||
const datatoken = Datatoken.load(tokenId)
|
||||
if (datatoken == null) return
|
||||
|
||||
const payer = event.params.payer.toHex()
|
||||
// let feeCollector = event.params.mrktFeeCollector
|
||||
// let marketFee = event.params.marketFee
|
||||
const tx = event.transaction.hash
|
||||
const orderId = tokenId
|
||||
.concat('-')
|
||||
.concat(payer)
|
||||
.concat('-')
|
||||
.concat(tx.toHexString())
|
||||
let order = TokenOrder.load(orderId)
|
||||
if (order == null) {
|
||||
order = new TokenOrder(orderId)
|
||||
}
|
||||
order.datatokenId = tokenId
|
||||
order.amount = tokenToDecimal(event.params.amount.toBigDecimal(), 18)
|
||||
order.consumer = event.params.consumer.toHex()
|
||||
order.payer = payer
|
||||
order.serviceId = event.params.serviceId.toI32()
|
||||
order.timestamp = event.params.timestamp.toI32()
|
||||
if (
|
||||
event.params.mrktFeeCollector != null &&
|
||||
event.params.mrktFeeCollector.toHex() != ZERO_ADDRESS
|
||||
) {
|
||||
order.marketFeeCollector = event.params.mrktFeeCollector.toHexString()
|
||||
}
|
||||
order.marketFee = tokenToDecimal(event.params.marketFee.toBigDecimal(), 18)
|
||||
order.tx = tx
|
||||
order.block = event.block.number.toI32()
|
||||
|
||||
order.save()
|
||||
|
||||
datatoken.orderVolume = datatoken.orderVolume.plus(order.amount)
|
||||
datatoken.orderCount = datatoken.orderCount.plus(BigInt.fromI32(1))
|
||||
|
||||
datatoken.save()
|
||||
|
||||
saveTokenTransaction(event, 'OrderStarted')
|
||||
|
||||
let factory = PoolFactory.load('1')
|
||||
|
||||
if (factory == null) {
|
||||
factory = new PoolFactory('1')
|
||||
factory.totalOceanLiquidity = ZERO_BD
|
||||
factory.totalSwapVolume = ZERO_BD
|
||||
factory.totalSwapFee = ZERO_BD
|
||||
factory.totalValueLocked = ZERO_BD
|
||||
factory.orderCount = BigInt.fromI32(0)
|
||||
factory.poolCount = 0
|
||||
factory.finalizedPoolCount = 0
|
||||
}
|
||||
|
||||
factory.orderCount = factory.orderCount.plus(BigInt.fromI32(1))
|
||||
factory.totalOrderVolume = factory.totalOrderVolume.plus(order.amount)
|
||||
factory.save()
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
gStats.orderCount = factory.orderCount
|
||||
gStats.totalOrderVolume = factory.totalOrderVolume
|
||||
gStats.save()
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
import { Allocated, Claimed } from '../@types/DFRewards/DFRewards'
|
||||
import { DFHistory } from '../@types/schema'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
import { getDFReward, getDFAvailableClaim } from './utils/dfUtils'
|
||||
|
||||
export function handleAllocated(event: Allocated): void {
|
||||
// loop all allocations
|
||||
const token = getToken(event.params.tokenAddress, false)
|
||||
for (let i = 0; i < event.params.tos.length; i++) {
|
||||
const reward = getDFReward(event.params.tos[i])
|
||||
const history = new DFHistory(
|
||||
event.params.tos[i].toHexString() +
|
||||
'-' +
|
||||
event.transaction.hash.toHex() +
|
||||
'-' +
|
||||
event.logIndex.toString()
|
||||
)
|
||||
history.amount = weiToDecimal(
|
||||
event.params.values[i].toBigDecimal(),
|
||||
BigInt.fromI32(token.decimals).toI32()
|
||||
)
|
||||
history.receiver = reward.id
|
||||
history.token = token.id
|
||||
history.type = 'Allocated'
|
||||
history.timestamp = event.block.timestamp
|
||||
history.tx = event.transaction.hash.toHex()
|
||||
history.eventIndex = event.logIndex.toI32()
|
||||
history.block = event.block.number.toI32()
|
||||
history.save()
|
||||
|
||||
// update available claims
|
||||
const claim = getDFAvailableClaim(
|
||||
event.params.tos[i],
|
||||
event.params.tokenAddress
|
||||
)
|
||||
claim.amount = claim.amount.plus(history.amount)
|
||||
claim.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handleClaimed(event: Claimed): void {
|
||||
// loop all allocations
|
||||
const token = getToken(event.params.tokenAddress, false)
|
||||
const reward = getDFReward(event.params.to)
|
||||
const history = new DFHistory(
|
||||
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||
)
|
||||
history.amount = weiToDecimal(
|
||||
event.params.value.toBigDecimal(),
|
||||
BigInt.fromI32(token.decimals).toI32()
|
||||
)
|
||||
history.receiver = reward.id
|
||||
history.token = token.id
|
||||
history.type = 'Claimed'
|
||||
history.timestamp = event.block.timestamp
|
||||
history.tx = event.transaction.hash.toHex()
|
||||
history.eventIndex = event.logIndex.toI32()
|
||||
history.block = event.block.number.toI32()
|
||||
history.save()
|
||||
|
||||
// update available claims
|
||||
const claim = getDFAvailableClaim(event.params.to, event.params.tokenAddress)
|
||||
claim.amount = claim.amount.minus(history.amount)
|
||||
claim.save()
|
||||
}
|
|
@ -1,176 +1,119 @@
|
|||
import { Address, BigInt, ethereum, log } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
Activated,
|
||||
Deactivated,
|
||||
AcceptedMinter,
|
||||
RemovedMinter,
|
||||
TokensDispensed,
|
||||
DispenserActivated,
|
||||
DispenserAllowedSwapperChanged,
|
||||
DispenserDeactivated,
|
||||
OwnerWithdrawed,
|
||||
Dispenser as DispenserEntity
|
||||
} from '../@types/Dispenser/Dispenser'
|
||||
|
||||
TokensDispensed
|
||||
} from '../@types/templates/Dispenser/Dispenser'
|
||||
import { DispenserCreated } from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { Dispenser, DispenserTransaction } from '../@types/schema'
|
||||
import { decimal } from './utils/constants'
|
||||
import {
|
||||
Dispenser,
|
||||
DispenserTransaction,
|
||||
User,
|
||||
Datatoken
|
||||
} from '../@types/schema'
|
||||
getDispenser,
|
||||
getDispenserGraphID,
|
||||
updateDispenserDetails
|
||||
} from './utils/dispenserUtils'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { addDispenser } from './utils/globalUtils'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
import { BigDecimal } from '@graphprotocol/graph-ts'
|
||||
|
||||
import { tokenToDecimal, _debuglog } from '../helpers'
|
||||
export function handleNewDispenser(event: DispenserCreated): void {
|
||||
const dispenserID = getDispenserGraphID(
|
||||
event.address,
|
||||
event.params.datatokenAddress
|
||||
)
|
||||
const dispenser = new Dispenser(dispenserID)
|
||||
const token = getToken(event.params.datatokenAddress, false)
|
||||
dispenser.token = token.id
|
||||
dispenser.contract = event.address.toHexString()
|
||||
|
||||
function _processDispenserUpdate(
|
||||
event: ethereum.Event,
|
||||
datatoken: string,
|
||||
contractAddress: Address
|
||||
): void {
|
||||
_debuglog('Start processDispenserUpdate', null, [
|
||||
datatoken,
|
||||
contractAddress.toHexString()
|
||||
])
|
||||
const dt = Datatoken.load(datatoken)
|
||||
if (!dt) {
|
||||
return
|
||||
}
|
||||
let dispenser = Dispenser.load(datatoken)
|
||||
if (!dispenser) {
|
||||
_debuglog('Creating new dispenser', null, null)
|
||||
dispenser = new Dispenser(datatoken)
|
||||
}
|
||||
const dispenserEntity = DispenserEntity.bind(contractAddress)
|
||||
_debuglog('Bound dispenser entity', null, null)
|
||||
const dispenserStatus = dispenserEntity.try_status(
|
||||
Address.fromString(datatoken)
|
||||
dispenser.owner = event.params.owner.toHexString()
|
||||
dispenser.maxBalance = weiToDecimal(
|
||||
event.params.maxBalance.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
_debuglog('Got status', null, null)
|
||||
if (dispenserStatus.reverted) return
|
||||
dispenser.active = dispenserStatus.value.value0
|
||||
let owner = User.load(dispenserStatus.value.value1.toHexString())
|
||||
if (!owner) {
|
||||
owner = new User(dispenserStatus.value.value1.toHexString())
|
||||
owner.save()
|
||||
}
|
||||
dispenser.owner = owner.id
|
||||
dispenser.minterApproved = dispenserStatus.value.value2
|
||||
dispenser.isTrueMinter = dispenserStatus.value.value3
|
||||
dispenser.maxTokens = tokenToDecimal(
|
||||
dispenserStatus.value.value4.toBigDecimal(),
|
||||
18
|
||||
dispenser.maxTokens = weiToDecimal(
|
||||
event.params.maxTokens.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
dispenser.maxBalance = tokenToDecimal(
|
||||
dispenserStatus.value.value5.toBigDecimal(),
|
||||
18
|
||||
dispenser.active = true
|
||||
dispenser.balance = BigDecimal.zero()
|
||||
dispenser.allowedSwapper = event.params.allowedSwapper.toHex()
|
||||
dispenser.createdTimestamp = event.block.timestamp.toI32()
|
||||
dispenser.tx = event.transaction.hash.toHex()
|
||||
dispenser.eventIndex = event.logIndex.toI32()
|
||||
dispenser.block = event.block.number.toI32()
|
||||
dispenser.save()
|
||||
|
||||
addDispenser()
|
||||
updateDispenserDetails(event.address, event.params.datatokenAddress)
|
||||
}
|
||||
|
||||
export function handleActivate(event: DispenserActivated): void {
|
||||
const dispenserID = getDispenserGraphID(
|
||||
event.address,
|
||||
event.params.datatokenAddress
|
||||
)
|
||||
dispenser.balance = tokenToDecimal(
|
||||
dispenserStatus.value.value6.toBigDecimal(),
|
||||
18
|
||||
)
|
||||
dispenser.datatoken = dt.id
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
dispenser.active = true
|
||||
dispenser.eventIndex = event.logIndex.toI32()
|
||||
dispenser.save()
|
||||
}
|
||||
|
||||
export function handleDispenserActivated(event: Activated): void {
|
||||
_debuglog('Start handleDispenserActivated', event, [
|
||||
event.params.datatokenAddress.toHexString()
|
||||
])
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatokenAddress.toHexString(),
|
||||
event.address
|
||||
export function handleDeactivate(event: DispenserDeactivated): void {
|
||||
const dispenserID = getDispenserGraphID(
|
||||
event.address,
|
||||
event.params.datatokenAddress
|
||||
)
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
dispenser.active = false
|
||||
dispenser.eventIndex = event.logIndex.toI32()
|
||||
dispenser.save()
|
||||
}
|
||||
|
||||
export function handleDispenserDeactivated(event: Deactivated): void {
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatokenAddress.toHexString(),
|
||||
event.address
|
||||
)
|
||||
}
|
||||
export function handleDispenserAcceptedMinter(event: AcceptedMinter): void {
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatokenAddress.toHexString(),
|
||||
event.address
|
||||
)
|
||||
}
|
||||
export function handleDispenserRemovedMinter(event: RemovedMinter): void {
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatokenAddress.toHexString(),
|
||||
event.address
|
||||
)
|
||||
export function handleAllowedSwapperChanged(
|
||||
event: DispenserAllowedSwapperChanged
|
||||
): void {
|
||||
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
dispenser.allowedSwapper = event.params.newAllowedSwapper.toHex()
|
||||
dispenser.eventIndex = event.logIndex.toI32()
|
||||
dispenser.save()
|
||||
}
|
||||
|
||||
export function handleDispenserTokensDispensed(event: TokensDispensed): void {
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatokenAddress.toHexString(),
|
||||
event.address
|
||||
export function handleTokensDispensed(event: TokensDispensed): void {
|
||||
const dispenserID = getDispenserGraphID(
|
||||
event.address,
|
||||
event.params.datatokenAddress
|
||||
)
|
||||
const dt = Datatoken.load(event.params.datatokenAddress.toHexString())
|
||||
if (!dt) {
|
||||
log.warning('Tokens dispensed, but no datatoken ? ', [
|
||||
event.params.datatokenAddress.toHexString()
|
||||
])
|
||||
return
|
||||
}
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const id = `${event.transaction.hash.toHexString()}-${dispenserID}-${eventIndex}`
|
||||
|
||||
const tx = event.transaction.hash
|
||||
const id = tx
|
||||
.toHexString()
|
||||
.concat('-')
|
||||
.concat(event.params.datatokenAddress.toHexString())
|
||||
log.info('Created dispenser in handleDispenserTokensDispensed with id {}', [
|
||||
id
|
||||
])
|
||||
const dispensers = new DispenserTransaction(id)
|
||||
dispensers.dispenserId = event.params.datatokenAddress.toHexString()
|
||||
dispensers.datatoken = event.params.datatokenAddress.toHexString()
|
||||
dispensers.user = event.params.userAddress.toHexString()
|
||||
dispensers.amount = tokenToDecimal(
|
||||
const dispenserTransaction = new DispenserTransaction(id)
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
updateDispenserDetails(event.address, event.params.datatokenAddress)
|
||||
dispenserTransaction.dispenser = dispenser.id
|
||||
const user = getUser(event.params.userAddress.toHex())
|
||||
dispenserTransaction.user = user.id
|
||||
|
||||
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
||||
dispenserTransaction.tx = event.transaction.hash.toHex()
|
||||
dispenserTransaction.eventIndex = event.logIndex.toI32()
|
||||
dispenserTransaction.block = event.block.number.toI32()
|
||||
const token = getToken(event.params.datatokenAddress, true)
|
||||
dispenserTransaction.amount = weiToDecimal(
|
||||
event.params.amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
token.decimals
|
||||
)
|
||||
dispensers.block = event.block.number.toI32()
|
||||
dispensers.timestamp = event.block.timestamp.toI32()
|
||||
dispensers.tx = tx
|
||||
dispensers.type = 'dispense'
|
||||
dispensers.save()
|
||||
dispenserTransaction.save()
|
||||
}
|
||||
|
||||
export function handleDispenserOwnerWithdrawed(event: OwnerWithdrawed): void {
|
||||
_processDispenserUpdate(
|
||||
event,
|
||||
event.params.datatoken.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const dt = Datatoken.load(event.params.datatoken.toHexString())
|
||||
if (!dt) {
|
||||
log.warning('Tokens dispensed, but no datatoken ? ', [
|
||||
event.params.datatoken.toHexString()
|
||||
])
|
||||
return
|
||||
}
|
||||
|
||||
const tx = event.transaction.hash
|
||||
const id = tx
|
||||
.toHexString()
|
||||
.concat('-')
|
||||
.concat(event.params.datatoken.toHexString())
|
||||
log.info('Created dispenser in handleDispenserOwnerWithdrawed with id {} ', [
|
||||
id
|
||||
])
|
||||
const dispensers = new DispenserTransaction(id)
|
||||
dispensers.dispenserId = event.params.datatoken.toHexString()
|
||||
dispensers.datatoken = event.params.datatoken.toHexString()
|
||||
dispensers.user = event.params.owner.toHexString()
|
||||
dispensers.amount = tokenToDecimal(
|
||||
event.params.amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
dispensers.block = event.block.number.toI32()
|
||||
dispensers.timestamp = event.block.timestamp.toI32()
|
||||
dispensers.tx = tx
|
||||
dispensers.type = 'withdraw'
|
||||
dispensers.save()
|
||||
export function handleOwnerWinthdraw(event: OwnerWithdrawed): void {
|
||||
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
dispenser.balance = decimal.ZERO
|
||||
dispenser.eventIndex = event.logIndex.toI32()
|
||||
dispenser.save()
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
import { BigInt, log } from '@graphprotocol/graph-ts'
|
||||
import { TokenRegistered } from '../@types/DTFactory/DTFactory'
|
||||
import {
|
||||
DatatokenFactory,
|
||||
Datatoken as DatatokenEntity
|
||||
} from '../@types/schema'
|
||||
import { DataToken as DatatokenDataSource } from '../@types/templates'
|
||||
|
||||
import { createUserEntity, tokenToDecimal, ZERO_BD } from '../helpers'
|
||||
|
||||
export function handleNewToken(event: TokenRegistered): void {
|
||||
let factory = DatatokenFactory.load('1')
|
||||
|
||||
// if no factory yet, set up blank initial
|
||||
if (factory == null) {
|
||||
factory = new DatatokenFactory('1')
|
||||
factory.tokenCount = 0
|
||||
}
|
||||
|
||||
const datatoken = new DatatokenEntity(event.params.tokenAddress.toHexString())
|
||||
log.warning('************************ handleNewToken: datatokenId {}', [
|
||||
datatoken.id.toString()
|
||||
])
|
||||
|
||||
datatoken.factoryID = event.address.toHexString()
|
||||
|
||||
datatoken.symbol = event.params.tokenSymbol
|
||||
datatoken.name = event.params.tokenName
|
||||
datatoken.decimals = 18
|
||||
datatoken.address = event.params.tokenAddress.toHexString()
|
||||
datatoken.cap = tokenToDecimal(event.params.tokenCap.toBigDecimal(), 18)
|
||||
datatoken.supply = ZERO_BD
|
||||
|
||||
createUserEntity(event.params.registeredBy.toHex())
|
||||
datatoken.minter = event.params.registeredBy.toHex()
|
||||
datatoken.publisher = event.params.registeredBy.toHex()
|
||||
|
||||
datatoken.holderCount = BigInt.fromI32(0)
|
||||
datatoken.orderCount = BigInt.fromI32(0)
|
||||
datatoken.orderVolume = BigInt.fromI32(0).toBigDecimal()
|
||||
datatoken.metadataUpdateCount = BigInt.fromI32(0)
|
||||
|
||||
datatoken.createTime = event.block.timestamp.toI32()
|
||||
datatoken.tx = event.transaction.hash
|
||||
datatoken.save()
|
||||
|
||||
factory.tokenCount = factory.tokenCount + 1
|
||||
factory.save()
|
||||
|
||||
DatatokenDataSource.create(event.params.tokenAddress)
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
import {
|
||||
PredictSubscription,
|
||||
PredictPayout,
|
||||
PredictPrediction,
|
||||
PredictTrueVal,
|
||||
PredictSlot,
|
||||
PredictSettingUpdate,
|
||||
PredictionRevenue
|
||||
} from '../@types/schema'
|
||||
import { BigInt, BigDecimal, Address } from '@graphprotocol/graph-ts'
|
||||
|
||||
import {
|
||||
PredictionSubmitted,
|
||||
PredictionPayout,
|
||||
NewSubscription,
|
||||
TruevalSubmitted,
|
||||
SettingChanged,
|
||||
RevenueAdded,
|
||||
Paused
|
||||
} from '../@types/templates/ERC20Template3/ERC20Template3'
|
||||
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getPredictContract, getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
function getPredictSlot(
|
||||
predictContractAddress: string,
|
||||
slot: i32
|
||||
): PredictSlot {
|
||||
const id = predictContractAddress + '-' + slot.toString()
|
||||
let newPredictSlot = PredictSlot.load(id)
|
||||
if (newPredictSlot === null) {
|
||||
newPredictSlot = new PredictSlot(id)
|
||||
newPredictSlot.predictContract = predictContractAddress
|
||||
newPredictSlot.slot = slot
|
||||
newPredictSlot.revenue = BigDecimal.zero()
|
||||
newPredictSlot.roundSumStakesUp = BigDecimal.zero()
|
||||
newPredictSlot.roundSumStakes = BigDecimal.zero()
|
||||
newPredictSlot.status = 'Pending'
|
||||
newPredictSlot.save()
|
||||
}
|
||||
return newPredictSlot
|
||||
}
|
||||
|
||||
export function handlePredictionSubmitted(event: PredictionSubmitted): void {
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
const user = getUser(event.params.predictoor.toHex())
|
||||
const id =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.params.slot.toString() +
|
||||
'-' +
|
||||
user.id
|
||||
const predictPrediction = new PredictPrediction(id)
|
||||
predictPrediction.slot = predictSlot.id
|
||||
predictPrediction.user = user.id
|
||||
const predictContract = getPredictContract(event.address)
|
||||
let decimals = 18
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
predictPrediction.stake = weiToDecimal(
|
||||
event.params.stake.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
predictPrediction.payout = null
|
||||
predictPrediction.block = event.block.number.toI32()
|
||||
predictPrediction.txId = event.transaction.hash.toHexString()
|
||||
predictPrediction.eventIndex = event.logIndex.toI32()
|
||||
predictPrediction.timestamp = event.block.timestamp.toI32()
|
||||
predictPrediction.save()
|
||||
}
|
||||
|
||||
export function handlePredictionPayout(event: PredictionPayout): void {
|
||||
const user = getUser(event.params.predictoor.toHex())
|
||||
const predictionId =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.params.slot.toString() +
|
||||
'-' +
|
||||
user.id
|
||||
const predictPrediction = PredictPrediction.load(predictionId)
|
||||
if (!predictPrediction) return
|
||||
const predictionPayout = new PredictPayout(predictionId)
|
||||
predictionPayout.prediction = predictPrediction.id
|
||||
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
predictionPayout.payout = weiToDecimal(
|
||||
event.params.payout.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
predictionPayout.predictedValue = event.params.predictedValue
|
||||
predictionPayout.trueValue = event.params.trueValue
|
||||
predictionPayout.aggregatedPredictedValue = weiToDecimal(
|
||||
event.params.aggregatedPredictedValue.toBigDecimal(),
|
||||
18
|
||||
)
|
||||
predictionPayout.block = event.block.number.toI32()
|
||||
predictionPayout.txId = event.transaction.hash.toHexString()
|
||||
predictionPayout.eventIndex = event.logIndex.toI32()
|
||||
predictionPayout.timestamp = event.block.timestamp.toI32()
|
||||
predictionPayout.save()
|
||||
|
||||
predictPrediction.payout = predictionPayout.id
|
||||
predictPrediction.save()
|
||||
|
||||
let shouldUpdateSlot = false
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
if (event.params.status == 1 && predictSlot.status !== 'Paying') {
|
||||
predictSlot.status = 'Paying'
|
||||
shouldUpdateSlot = true
|
||||
}
|
||||
if (event.params.status == 2 && predictSlot.status !== 'Canceled') {
|
||||
predictSlot.status = 'Canceled'
|
||||
shouldUpdateSlot = true
|
||||
}
|
||||
if (shouldUpdateSlot == true) predictSlot.save()
|
||||
}
|
||||
|
||||
export function handleNewSubscription(event: NewSubscription): void {
|
||||
const id =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toString()
|
||||
const newSubscription = new PredictSubscription(id)
|
||||
const predictContract = getPredictContract(event.address)
|
||||
newSubscription.predictContract = predictContract.id
|
||||
const user = getUser(event.params.user.toHex())
|
||||
newSubscription.user = user.id
|
||||
newSubscription.expireTime = event.params.expires
|
||||
newSubscription.block = event.block.number.toI32()
|
||||
newSubscription.txId = event.transaction.hash.toHexString()
|
||||
newSubscription.eventIndex = event.logIndex.toI32()
|
||||
newSubscription.timestamp = event.block.timestamp.toI32()
|
||||
newSubscription.save()
|
||||
}
|
||||
|
||||
export function handleTruevalSubmitted(event: TruevalSubmitted): void {
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
const id = event.address.toHexString() + '-' + event.params.slot.toString()
|
||||
const newPredictTrueVals = new PredictTrueVal(id) // they share the same id
|
||||
newPredictTrueVals.slot = predictSlot.id
|
||||
newPredictTrueVals.trueValue = event.params.trueValue
|
||||
newPredictTrueVals.block = event.block.number.toI32()
|
||||
newPredictTrueVals.txId = event.transaction.hash.toHexString()
|
||||
newPredictTrueVals.eventIndex = event.logIndex.toI32()
|
||||
newPredictTrueVals.timestamp = event.block.timestamp.toI32()
|
||||
newPredictTrueVals.save()
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
predictSlot.roundSumStakesUp = weiToDecimal(
|
||||
event.params.roundSumStakesUp.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
predictSlot.roundSumStakes = weiToDecimal(
|
||||
event.params.roundSumStakes.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
|
||||
if (event.params.status == 1) {
|
||||
predictSlot.status = 'Paying'
|
||||
}
|
||||
if (event.params.status == 2) {
|
||||
predictSlot.status = 'Canceled'
|
||||
}
|
||||
predictSlot.save()
|
||||
}
|
||||
|
||||
export function handleSettingChanged(event: SettingChanged): void {
|
||||
const predictContract = getPredictContract(event.address)
|
||||
predictContract.secondsPerEpoch = event.params.secondsPerEpoch
|
||||
predictContract.secondsPerSubscription = event.params.secondsPerSubscription
|
||||
predictContract.truevalSubmitTimeout = event.params.trueValueSubmitTimeout
|
||||
const stakeToken = getToken(event.params.stakeToken, false)
|
||||
predictContract.stakeToken = stakeToken.id
|
||||
predictContract.save()
|
||||
const predictSettingsUpdate = new PredictSettingUpdate(
|
||||
event.address.toHexString() +
|
||||
'- ' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toHexString()
|
||||
)
|
||||
predictSettingsUpdate.block = event.block.number.toI32()
|
||||
predictSettingsUpdate.txId = event.transaction.hash.toHexString()
|
||||
predictSettingsUpdate.eventIndex = event.logIndex.toI32()
|
||||
predictSettingsUpdate.timestamp = event.block.timestamp.toI32()
|
||||
predictSettingsUpdate.predictContract = predictContract.id
|
||||
predictSettingsUpdate.secondsPerEpoch = event.params.secondsPerEpoch
|
||||
predictSettingsUpdate.secondsPerSubscription =
|
||||
event.params.secondsPerSubscription
|
||||
predictSettingsUpdate.truevalSubmitTimeout =
|
||||
event.params.trueValueSubmitTimeout
|
||||
predictSettingsUpdate.stakeToken = stakeToken.id
|
||||
predictSettingsUpdate.save()
|
||||
}
|
||||
|
||||
export function handlePaused(event: Paused): void {
|
||||
const predictContract = getPredictContract(event.address)
|
||||
predictContract.paused = event.params.paused
|
||||
predictContract.save()
|
||||
}
|
||||
|
||||
export function handleRevenueAdded(event: RevenueAdded): void {
|
||||
/*
|
||||
for (uint256 i = 0; i < num_epochs; i++) {
|
||||
subscriptionRevenueAtBlock[
|
||||
slot + secondsPerEpoch * (i)
|
||||
] += amt_per_epoch;
|
||||
}
|
||||
emit RevenueAdded(amount,slot,amt_per_epoch,num_epochs,secondsPerEpoch);
|
||||
*/
|
||||
const numEpochs = event.params.numEpochs
|
||||
const secondsPerEpoch = event.params.secondsPerEpoch
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
const amountPerEpoch = weiToDecimal(
|
||||
event.params.amountPerEpoch.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
const slot = event.params.slot
|
||||
for (let i = BigInt.zero(); i.lt(numEpochs); i = i.plus(BigInt.fromI32(1))) {
|
||||
const targetSlot = slot.plus(secondsPerEpoch.times(i))
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
targetSlot.toI32()
|
||||
)
|
||||
predictSlot.revenue = predictSlot.revenue.plus(amountPerEpoch)
|
||||
predictSlot.save()
|
||||
const revenueId =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
targetSlot.toString() +
|
||||
'-' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toHexString()
|
||||
const predictRevenue = new PredictionRevenue(revenueId)
|
||||
predictRevenue.slot = predictSlot.id
|
||||
predictRevenue.amount = amountPerEpoch
|
||||
predictRevenue.block = event.block.number.toI32()
|
||||
predictRevenue.txId = event.transaction.hash.toHexString()
|
||||
predictRevenue.eventIndex = event.logIndex.toI32()
|
||||
predictRevenue.timestamp = event.block.timestamp.toI32()
|
||||
predictRevenue.save()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,319 @@
|
|||
import { Order, Nft, OrderReuse } from '../@types/schema'
|
||||
import { BigInt, BigDecimal, Address, log } from '@graphprotocol/graph-ts'
|
||||
|
||||
import {
|
||||
NewPaymentCollector,
|
||||
OrderStarted,
|
||||
PublishMarketFee,
|
||||
PublishMarketFeeChanged,
|
||||
ConsumeMarketFee,
|
||||
AddedMinter,
|
||||
AddedPaymentManager,
|
||||
RemovedMinter,
|
||||
RemovedPaymentManager,
|
||||
CleanedPermissions,
|
||||
OrderReused,
|
||||
ProviderFee
|
||||
} from '../@types/templates/ERC20Template/ERC20Template'
|
||||
|
||||
import { integer } from './utils/constants'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { addOrder } from './utils/globalUtils'
|
||||
import { getToken, getUSDValue } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
import {
|
||||
getOrderId,
|
||||
searchOrderForEvent,
|
||||
searchOrderReusedForEvent
|
||||
} from './utils/orderUtils'
|
||||
|
||||
export function handleOrderStarted(event: OrderStarted): void {
|
||||
const order = new Order(
|
||||
getOrderId(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
)
|
||||
|
||||
const token = getToken(event.address, true)
|
||||
order.datatoken = token.id
|
||||
token.orderCount = token.orderCount.plus(integer.ONE)
|
||||
|
||||
const consumer = getUser(event.params.consumer.toHex())
|
||||
order.consumer = consumer.id
|
||||
|
||||
if (token.nft) {
|
||||
const nft = Nft.load(token.nft as string) as Nft
|
||||
const nftOwner = getUser(nft.owner)
|
||||
order.nftOwner = nftOwner.id
|
||||
}
|
||||
|
||||
const payer = getUser(event.params.payer.toHex())
|
||||
payer.totalOrders = payer.totalOrders.plus(integer.ONE)
|
||||
payer.save()
|
||||
order.payer = payer.id
|
||||
|
||||
order.amount = weiToDecimal(
|
||||
event.params.amount.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
|
||||
order.serviceIndex = event.params.serviceIndex.toI32()
|
||||
|
||||
const publishMarket = getUser(event.params.publishMarketAddress.toHex())
|
||||
order.publishingMarket = publishMarket.id
|
||||
|
||||
order.createdTimestamp = event.block.timestamp.toI32()
|
||||
order.tx = event.transaction.hash.toHex()
|
||||
order.eventIndex = event.logIndex.toI32()
|
||||
order.block = event.block.number.toI32()
|
||||
const tokenId = token.lastPriceToken
|
||||
if (tokenId) {
|
||||
const priceToken = getToken(Address.fromString(tokenId), false)
|
||||
order.lastPriceToken = priceToken.id
|
||||
order.lastPriceValue = token.lastPriceValue
|
||||
order.estimatedUSDValue = getUSDValue(
|
||||
priceToken.id,
|
||||
order.lastPriceValue,
|
||||
order.createdTimestamp
|
||||
)
|
||||
}
|
||||
|
||||
if (event.receipt !== null && event.receipt!.gasUsed) {
|
||||
order.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
||||
} else {
|
||||
order.gasUsed = BigDecimal.zero()
|
||||
}
|
||||
if (event.transaction.gasPrice) {
|
||||
order.gasPrice = event.transaction.gasPrice
|
||||
} else {
|
||||
order.gasPrice = BigInt.zero()
|
||||
}
|
||||
order.save()
|
||||
token.save()
|
||||
addOrder()
|
||||
if (token.nft) {
|
||||
const nft = Nft.load(token.nft as string) as Nft
|
||||
if (nft) {
|
||||
nft.orderCount = nft.orderCount.plus(integer.ONE)
|
||||
nft.save()
|
||||
}
|
||||
const owner = getUser(nft.owner)
|
||||
owner.totalSales = owner.totalSales.plus(integer.ONE)
|
||||
owner.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handlerOrderReused(event: OrderReused): void {
|
||||
const order = searchOrderForEvent(
|
||||
event.params.orderTxId.toHexString(),
|
||||
event.address.toHex(),
|
||||
event.params.caller.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
|
||||
if (!order) return
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
|
||||
const reuseOrder = new OrderReuse(
|
||||
`${event.transaction.hash.toHex()}-${eventIndex}`
|
||||
)
|
||||
if (event.transaction.gasPrice)
|
||||
reuseOrder.gasPrice = event.transaction.gasPrice
|
||||
else reuseOrder.gasPrice = BigInt.zero()
|
||||
if (event.receipt !== null && event.receipt!.gasUsed) {
|
||||
reuseOrder.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
||||
} else reuseOrder.gasUsed = BigDecimal.zero()
|
||||
reuseOrder.order = order.id
|
||||
reuseOrder.caller = event.params.caller.toHexString()
|
||||
reuseOrder.createdTimestamp = event.params.timestamp.toI32()
|
||||
reuseOrder.tx = event.transaction.hash.toHex()
|
||||
reuseOrder.eventIndex = event.logIndex.toI32()
|
||||
reuseOrder.block = event.params.number.toI32()
|
||||
|
||||
reuseOrder.save()
|
||||
}
|
||||
|
||||
export function handlePublishMarketFee(event: PublishMarketFee): void {
|
||||
const order = searchOrderForEvent(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
|
||||
if (!order) return
|
||||
const publishMarket = getUser(event.params.PublishMarketFeeAddress.toHex())
|
||||
order.publishingMarket = publishMarket.id
|
||||
|
||||
const publishMarketToken = getToken(event.params.PublishMarketFeeToken, true)
|
||||
order.publishingMarketToken = publishMarketToken.id
|
||||
order.publishingMarketAmmount = weiToDecimal(
|
||||
event.params.PublishMarketFeeAmount.toBigDecimal(),
|
||||
publishMarketToken.decimals
|
||||
)
|
||||
|
||||
order.save()
|
||||
}
|
||||
export function handlePublishMarketFeeChanged(
|
||||
event: PublishMarketFeeChanged
|
||||
): void {
|
||||
const token = getToken(event.address, true)
|
||||
if (!token) return
|
||||
|
||||
token.publishMarketFeeAddress =
|
||||
event.params.PublishMarketFeeAddress.toHexString()
|
||||
token.publishMarketFeeToken = event.params.PublishMarketFeeToken.toHexString()
|
||||
let decimals = BigInt.fromI32(18).toI32()
|
||||
if (
|
||||
token.publishMarketFeeToken != '0x0000000000000000000000000000000000000000'
|
||||
) {
|
||||
const token = getToken(event.params.PublishMarketFeeToken, false)
|
||||
decimals = BigInt.fromI32(token.decimals).toI32()
|
||||
}
|
||||
token.publishMarketFeeAmount = weiToDecimal(
|
||||
event.params.PublishMarketFeeAmount.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
// TODO - shold we have a history
|
||||
}
|
||||
|
||||
export function handleConsumeMarketFee(event: ConsumeMarketFee): void {
|
||||
const order = searchOrderForEvent(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
|
||||
if (!order) return
|
||||
const consumeMarket = getUser(event.params.consumeMarketFeeAddress.toHex())
|
||||
order.consumerMarket = consumeMarket.id
|
||||
|
||||
const consumeMarketToken = getToken(event.params.consumeMarketFeeToken, false)
|
||||
order.consumerMarketToken = consumeMarketToken.id
|
||||
order.consumerMarketAmmount = weiToDecimal(
|
||||
event.params.consumeMarketFeeAmount.toBigDecimal(),
|
||||
consumeMarketToken.decimals
|
||||
)
|
||||
|
||||
order.save()
|
||||
}
|
||||
|
||||
// roles
|
||||
// roles
|
||||
export function handleAddedMinter(event: AddedMinter): void {
|
||||
const token = getToken(event.address, true)
|
||||
let existingRoles: string[]
|
||||
if (!token.minter) existingRoles = []
|
||||
else existingRoles = token.minter as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
token.minter = existingRoles
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
|
||||
export function handleRemovedMinter(event: RemovedMinter): void {
|
||||
const token = getToken(event.address, true)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!token.minter) existingRoles = []
|
||||
else existingRoles = token.minter as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
token.minter = newList
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
|
||||
export function handleAddedPaymentManager(event: AddedPaymentManager): void {
|
||||
const token = getToken(event.address, true)
|
||||
let existingRoles: string[]
|
||||
if (!token.paymentManager) existingRoles = []
|
||||
else existingRoles = token.paymentManager as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
token.paymentManager = existingRoles
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
export function handleRemovedPaymentManager(
|
||||
event: RemovedPaymentManager
|
||||
): void {
|
||||
const token = getToken(event.address, true)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!token.paymentManager) existingRoles = []
|
||||
else existingRoles = token.paymentManager as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
token.paymentManager = newList
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
export function handleCleanedPermissions(event: CleanedPermissions): void {
|
||||
const token = getToken(event.address, true)
|
||||
const newList: string[] = []
|
||||
token.paymentManager = newList
|
||||
token.minter = newList
|
||||
const nft = Nft.load(token.nft as string)
|
||||
if (nft) token.paymentCollector = nft.owner
|
||||
else token.paymentCollector = '0x0000000000000000000000000000000000000000'
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
|
||||
export function handleNewPaymentCollector(event: NewPaymentCollector): void {
|
||||
const token = getToken(event.address, true)
|
||||
token.paymentCollector = event.params._newPaymentCollector.toHexString()
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
token.save()
|
||||
}
|
||||
|
||||
export function handleProviderFee(event: ProviderFee): void {
|
||||
const providerFee: string = `{"providerFeeAddress": "${event.params.providerFeeAddress.toHex()}", "providerFeeToken": "${event.params.providerFeeToken.toHex()}", "providerFeeAmount": "${
|
||||
event.params.providerFeeAmount
|
||||
}", "providerData": "${event.params.providerData.toHexString()}", "v": "${
|
||||
event.params.v
|
||||
}", "r": "${event.params.r.toHexString()}", "s": "${event.params.s.toHexString()}", "validUntil": "${
|
||||
event.params.validUntil
|
||||
}"}`
|
||||
|
||||
const order = searchOrderForEvent(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
|
||||
if (order) {
|
||||
order.providerFee = providerFee
|
||||
order.providerFeeValidUntil = event.params.validUntil
|
||||
order.save()
|
||||
return
|
||||
}
|
||||
const orderReuse = searchOrderReusedForEvent(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.logIndex.toI32()
|
||||
)
|
||||
if (orderReuse) {
|
||||
log.info('order reuse id in provider fee handler: {}', [orderReuse.id])
|
||||
orderReuse.providerFee = providerFee
|
||||
orderReuse.providerFeeValidUntil = event.params.validUntil
|
||||
orderReuse.save()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
import {
|
||||
NFTCreated,
|
||||
TokenCreated,
|
||||
Template721Added,
|
||||
Template20Added
|
||||
} from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { Erc721Template, Erc20Template } from '../@types/schema'
|
||||
import { decimal } from './utils/constants'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import {
|
||||
ERC20Template as factoryERC20Template,
|
||||
ERC20Template3 as factoryERC20Template3
|
||||
} from '../@types/templates'
|
||||
import { getUser } from './utils/userUtils'
|
||||
import {
|
||||
getToken,
|
||||
getNftToken,
|
||||
getErc20TemplateId,
|
||||
getPredictContract
|
||||
} from './utils/tokenUtils'
|
||||
import { addDatatoken } from './utils/globalUtils'
|
||||
|
||||
export function handleNftCreated(event: NFTCreated): void {
|
||||
// const nft = new Nft(event.params.newTokenAddress.toHexString())
|
||||
const nft = getNftToken(event.params.newTokenAddress)
|
||||
const user = getUser(event.params.admin.toHexString())
|
||||
nft.owner = user.id
|
||||
const creator = getUser(event.params.creator.toHexString())
|
||||
nft.creator = creator.id
|
||||
nft.address = event.params.newTokenAddress.toHexString()
|
||||
nft.name = event.params.tokenName
|
||||
nft.symbol = event.params.symbol.toString()
|
||||
nft.tokenUri = event.params.tokenURI.toString()
|
||||
nft.createdTimestamp = event.block.timestamp.toI32()
|
||||
nft.tx = event.transaction.hash.toHex()
|
||||
nft.block = event.block.number.toI32()
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.transferable = event.params.transferable
|
||||
nft.template = event.params.templateAddress.toHexString()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleNewToken(event: TokenCreated): void {
|
||||
const token = getToken(event.params.newTokenAddress, true)
|
||||
// const token = new Token(event.params.newTokenAddress.toHexString())
|
||||
|
||||
token.isDatatoken = true
|
||||
token.address = event.params.newTokenAddress.toHexString()
|
||||
token.createdTimestamp = event.block.timestamp.toI32()
|
||||
token.tx = event.transaction.hash.toHex()
|
||||
token.block = event.block.number.toI32()
|
||||
token.eventIndex = event.logIndex.toI32()
|
||||
|
||||
token.nft = event.params.creator.toHexString()
|
||||
|
||||
token.name = event.params.name
|
||||
token.symbol = event.params.symbol
|
||||
token.decimals = 18
|
||||
token.supply = decimal.ZERO
|
||||
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
||||
token.templateId = getErc20TemplateId(event.params.templateAddress)
|
||||
token.save()
|
||||
addDatatoken()
|
||||
if (token.templateId.toString() == '3') {
|
||||
factoryERC20Template3.create(event.params.newTokenAddress)
|
||||
const predictContract = getPredictContract(event.params.newTokenAddress)
|
||||
predictContract.timestamp = event.block.timestamp.toI32()
|
||||
predictContract.txId = event.transaction.hash.toHex()
|
||||
predictContract.block = event.block.number.toI32()
|
||||
predictContract.eventIndex = event.logIndex.toI32()
|
||||
predictContract.save()
|
||||
}
|
||||
factoryERC20Template.create(event.params.newTokenAddress)
|
||||
}
|
||||
|
||||
export function handleNew721Template(event: Template721Added): void {
|
||||
let template = Erc721Template.load(
|
||||
event.params._templateAddress.toHexString()
|
||||
)
|
||||
if (template === null) {
|
||||
template = new Erc721Template(event.params._templateAddress.toHexString())
|
||||
template.templateId = event.params.nftTemplateCount
|
||||
template.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handleNew20Template(event: Template20Added): void {
|
||||
let template = Erc20Template.load(event.params._templateAddress.toHexString())
|
||||
if (template === null) {
|
||||
template = new Erc20Template(event.params._templateAddress.toHexString())
|
||||
template.templateId = event.params.nftTemplateCount
|
||||
template.save()
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
import { BigInt, BigDecimal, log } from '@graphprotocol/graph-ts'
|
||||
import { BPoolRegistered } from '../@types/Factory/Factory'
|
||||
import { PoolFactory, Pool, Global } from '../@types/schema'
|
||||
import { Pool as PoolContract } from '../@types/templates'
|
||||
import { ZERO_BD, getGlobalStats } from '../helpers'
|
||||
|
||||
export function handleNewPool(event: BPoolRegistered): void {
|
||||
let factory = PoolFactory.load('1')
|
||||
|
||||
if (factory == null) {
|
||||
factory = new PoolFactory('1')
|
||||
factory.totalOceanLiquidity = ZERO_BD
|
||||
factory.totalSwapVolume = ZERO_BD
|
||||
factory.totalSwapFee = ZERO_BD
|
||||
factory.totalValueLocked = ZERO_BD
|
||||
factory.orderCount = BigInt.fromI32(0)
|
||||
factory.poolCount = 0
|
||||
factory.finalizedPoolCount = 0
|
||||
}
|
||||
|
||||
const pool = new Pool(event.params.bpoolAddress.toHexString())
|
||||
log.info('************************ handleNewPool: poolId {}', [
|
||||
pool.id.toString()
|
||||
])
|
||||
|
||||
pool.factoryID = event.address.toHexString()
|
||||
pool.controller = event.params.registeredBy
|
||||
pool.publicSwap = false
|
||||
pool.finalized = false
|
||||
pool.symbol = ''
|
||||
pool.name = ''
|
||||
// pool.cap =
|
||||
pool.active = true
|
||||
pool.swapFee = BigDecimal.fromString('0.000001')
|
||||
|
||||
pool.totalWeight = ZERO_BD
|
||||
pool.totalShares = ZERO_BD
|
||||
pool.totalSwapVolume = ZERO_BD
|
||||
pool.totalSwapFee = ZERO_BD
|
||||
pool.valueLocked = ZERO_BD
|
||||
|
||||
pool.datatokenReserve = ZERO_BD
|
||||
pool.oceanReserve = ZERO_BD
|
||||
pool.spotPrice = ZERO_BD // : BigDecimal!
|
||||
pool.consumePrice = ZERO_BD // : BigDecimal!
|
||||
|
||||
pool.tokenCount = BigInt.fromI32(0)
|
||||
pool.holderCount = BigInt.fromI32(0)
|
||||
pool.joinCount = BigInt.fromI32(0)
|
||||
pool.exitCount = BigInt.fromI32(0)
|
||||
pool.swapCount = BigInt.fromI32(0)
|
||||
pool.transactionCount = BigInt.fromI32(0)
|
||||
|
||||
pool.datatokenAddress = ''
|
||||
|
||||
pool.createTime = event.block.timestamp.toI32()
|
||||
pool.tx = event.transaction.hash
|
||||
|
||||
pool.save()
|
||||
|
||||
factory.poolCount = factory.poolCount + 1
|
||||
factory.save()
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
gStats.poolCount = factory.poolCount
|
||||
gStats.save()
|
||||
|
||||
PoolContract.create(event.params.bpoolAddress)
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
import {
|
||||
TokenAdded,
|
||||
TokenRemoved,
|
||||
OPCFeeChanged,
|
||||
FactoryRouter,
|
||||
FixedRateContractAdded,
|
||||
FixedRateContractRemoved,
|
||||
DispenserContractAdded,
|
||||
DispenserContractRemoved
|
||||
} from '../@types/FactoryRouter/FactoryRouter'
|
||||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
import { FixedRateExchange, Dispenser } from '../@types/templates'
|
||||
import { getOPC, getTemplates } from './utils/globalUtils'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
|
||||
export function handleOPCFeeChanged(event: OPCFeeChanged): void {
|
||||
const opc = getOPC()
|
||||
const decimals = BigInt.fromI32(18).toI32()
|
||||
opc.swapOceanFee = weiToDecimal(
|
||||
event.params.newSwapOceanFee.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
opc.swapNonOceanFee = weiToDecimal(
|
||||
event.params.newSwapNonOceanFee.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
opc.orderFee = weiToDecimal(
|
||||
event.params.newConsumeFee.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
opc.providerFee = weiToDecimal(
|
||||
event.params.newProviderFee.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
opc.save()
|
||||
}
|
||||
|
||||
export function handleTokenAdded(event: TokenAdded): void {
|
||||
const contract = FactoryRouter.bind(event.address)
|
||||
const oceanFees = contract.try_getOPCFees()
|
||||
if (oceanFees.reverted) return
|
||||
|
||||
const opc = getOPC()
|
||||
const decimals = BigInt.fromI32(18).toI32()
|
||||
opc.swapOceanFee = weiToDecimal(
|
||||
oceanFees.value.value0.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
opc.swapNonOceanFee = weiToDecimal(
|
||||
oceanFees.value.value1.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
|
||||
const newOrderFee = contract.try_getOPCConsumeFee()
|
||||
if (newOrderFee.reverted) return
|
||||
|
||||
const newProviderFee = contract.try_getOPCProviderFee()
|
||||
if (newProviderFee.reverted) return
|
||||
opc.orderFee = weiToDecimal(newOrderFee.value.toBigDecimal(), decimals)
|
||||
opc.providerFee = weiToDecimal(newProviderFee.value.toBigDecimal(), decimals)
|
||||
|
||||
// add token to approvedTokens
|
||||
let existingTokens: string[]
|
||||
if (!opc.approvedTokens) existingTokens = []
|
||||
else existingTokens = opc.approvedTokens as string[]
|
||||
if (!existingTokens.includes(event.params.token.toHexString())) {
|
||||
const newToken = getToken(event.params.token, false)
|
||||
existingTokens.push(newToken.id)
|
||||
}
|
||||
|
||||
opc.approvedTokens = existingTokens
|
||||
|
||||
opc.save()
|
||||
}
|
||||
|
||||
export function handleTokenRemoved(event: TokenRemoved): void {
|
||||
const opc = getOPC()
|
||||
const newList: string[] = []
|
||||
let existingTokens: string[]
|
||||
if (!opc.approvedTokens) existingTokens = []
|
||||
else existingTokens = opc.approvedTokens as string[]
|
||||
if (!existingTokens || existingTokens.length < 1) return
|
||||
while (existingTokens.length > 0) {
|
||||
const role = existingTokens.shift().toString()
|
||||
if (!role) break
|
||||
if (role != event.params.token.toHexString()) newList.push(role)
|
||||
}
|
||||
opc.approvedTokens = newList
|
||||
opc.save()
|
||||
}
|
||||
|
||||
export function handleFixedRateContractAdded(
|
||||
event: FixedRateContractAdded
|
||||
): void {
|
||||
FixedRateExchange.create(event.params.contractAddress)
|
||||
// add token to approvedTokens
|
||||
const templates = getTemplates()
|
||||
let existingContracts: string[]
|
||||
if (!templates.fixedRateTemplates) existingContracts = []
|
||||
else existingContracts = templates.fixedRateTemplates as string[]
|
||||
if (!existingContracts.includes(event.params.contractAddress.toHexString()))
|
||||
existingContracts.push(event.params.contractAddress.toHexString())
|
||||
templates.fixedRateTemplates = existingContracts
|
||||
templates.save()
|
||||
}
|
||||
export function handleFixedRateContractRemoved(
|
||||
event: FixedRateContractRemoved
|
||||
): void {
|
||||
const templates = getTemplates()
|
||||
const newList: string[] = []
|
||||
let existingContracts: string[]
|
||||
if (!templates.fixedRateTemplates) existingContracts = []
|
||||
else existingContracts = templates.fixedRateTemplates as string[]
|
||||
if (!existingContracts || existingContracts.length < 1) return
|
||||
while (existingContracts.length > 0) {
|
||||
const role = existingContracts.shift().toString()
|
||||
if (!role) break
|
||||
if (role != event.params.contractAddress.toHexString()) newList.push(role)
|
||||
}
|
||||
templates.fixedRateTemplates = newList
|
||||
templates.save()
|
||||
}
|
||||
export function handleDispenserContractAdded(
|
||||
event: DispenserContractAdded
|
||||
): void {
|
||||
Dispenser.create(event.params.contractAddress)
|
||||
|
||||
const templates = getTemplates()
|
||||
let existingContracts: string[]
|
||||
if (!templates.dispenserTemplates) existingContracts = []
|
||||
else existingContracts = templates.dispenserTemplates as string[]
|
||||
if (!existingContracts.includes(event.params.contractAddress.toHexString()))
|
||||
existingContracts.push(event.params.contractAddress.toHexString())
|
||||
templates.dispenserTemplates = existingContracts
|
||||
templates.save()
|
||||
}
|
||||
export function handleDispenserContractRemoved(
|
||||
event: DispenserContractRemoved
|
||||
): void {
|
||||
const templates = getTemplates()
|
||||
const newList: string[] = []
|
||||
let existingContracts: string[]
|
||||
if (!templates.dispenserTemplates) existingContracts = []
|
||||
else existingContracts = templates.dispenserTemplates as string[]
|
||||
if (!existingContracts || existingContracts.length < 1) return
|
||||
while (existingContracts.length > 0) {
|
||||
const role = existingContracts.shift().toString()
|
||||
if (!role) break
|
||||
if (role != event.params.contractAddress.toHexString()) newList.push(role)
|
||||
}
|
||||
templates.dispenserTemplates = newList
|
||||
templates.save()
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
import { BigInt, Address, BigDecimal } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
ExchangeActivated,
|
||||
ExchangeAllowedSwapperChanged,
|
||||
ExchangeCreated,
|
||||
ExchangeDeactivated,
|
||||
ExchangeMintStateChanged,
|
||||
ExchangeRateChanged,
|
||||
Swapped,
|
||||
PublishMarketFeeChanged,
|
||||
TokenCollected
|
||||
} from '../@types/templates/FixedRateExchange/FixedRateExchange'
|
||||
import {
|
||||
FixedRateExchange,
|
||||
FixedRateExchangeSwap,
|
||||
FixedRateExchangeUpdate
|
||||
} from '../@types/schema'
|
||||
import {
|
||||
getFixedRateExchange,
|
||||
getUpdateOrSwapId,
|
||||
getFixedRateGraphID,
|
||||
updateFixedRateExchangeSupply
|
||||
} from './utils/fixedRateUtils'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { addFixedRateExchange, addFixedSwap } from './utils/globalUtils'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
export function handleExchangeCreated(event: ExchangeCreated): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = new FixedRateExchange(fixedRateId)
|
||||
const user = getUser(event.params.exchangeOwner.toHexString())
|
||||
fixedRateExchange.owner = user.id
|
||||
fixedRateExchange.contract = event.address.toHexString()
|
||||
fixedRateExchange.exchangeId = event.params.exchangeId.toHexString()
|
||||
fixedRateExchange.datatoken = getToken(event.params.datatoken, true).id
|
||||
fixedRateExchange.baseToken = getToken(event.params.baseToken, false).id
|
||||
fixedRateExchange.datatokenSupply = BigDecimal.zero()
|
||||
fixedRateExchange.baseTokenSupply = BigDecimal.zero()
|
||||
fixedRateExchange.datatokenBalance = BigDecimal.zero()
|
||||
fixedRateExchange.baseTokenBalance = BigDecimal.zero()
|
||||
fixedRateExchange.totalSwapValue = BigDecimal.zero()
|
||||
fixedRateExchange.active = false
|
||||
fixedRateExchange.price = weiToDecimal(
|
||||
event.params.fixedRate.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
fixedRateExchange.createdTimestamp = event.block.timestamp.toI32()
|
||||
fixedRateExchange.tx = event.transaction.hash.toHex()
|
||||
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||
fixedRateExchange.block = event.block.number.toI32()
|
||||
fixedRateExchange.save()
|
||||
|
||||
addFixedRateExchange()
|
||||
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
||||
}
|
||||
|
||||
export function handleRateChange(event: ExchangeRateChanged): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
newExchangeUpdate.exchangeId = fixedRateId
|
||||
|
||||
fixedRateExchange.price = weiToDecimal(
|
||||
event.params.newRate.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
newExchangeUpdate.newPrice = fixedRateExchange.price
|
||||
|
||||
newExchangeUpdate.save()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
export function handleMintStateChanged(event: ExchangeMintStateChanged): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
fixedRateExchange.withMint = event.params.withMint
|
||||
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
export function handleActivated(event: ExchangeActivated): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.exchangeId = fixedRateId
|
||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||
newExchangeUpdate.newActive = true
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
|
||||
fixedRateExchange.active = true
|
||||
|
||||
newExchangeUpdate.save()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
export function handleDeactivated(event: ExchangeDeactivated): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||
newExchangeUpdate.newActive = false
|
||||
|
||||
newExchangeUpdate.exchangeId = fixedRateId
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
|
||||
fixedRateExchange.active = false
|
||||
newExchangeUpdate.save()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
export function handleAllowedSwapperChanged(
|
||||
event: ExchangeAllowedSwapperChanged
|
||||
): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
||||
newExchangeUpdate.exchangeId = fixedRateId
|
||||
fixedRateExchange.allowedSwapper = event.params.allowedSwapper.toHex()
|
||||
newExchangeUpdate.newAllowedSwapper = fixedRateExchange.allowedSwapper
|
||||
newExchangeUpdate.save()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
// TODO: implement market fee, opf fee
|
||||
export function handleSwap(event: Swapped): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const swap = new FixedRateExchangeSwap(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
swap.createdTimestamp = event.block.timestamp.toI32()
|
||||
swap.tx = event.transaction.hash.toHex()
|
||||
swap.eventIndex = event.logIndex.toI32()
|
||||
swap.block = event.block.number.toI32()
|
||||
|
||||
swap.exchangeId = fixedRateId
|
||||
swap.by = getUser(event.params.by.toHex()).id
|
||||
|
||||
// we need to fetch the decimals of the base token
|
||||
const baseToken = getToken(
|
||||
Address.fromString(fixedRateExchange.baseToken),
|
||||
false
|
||||
)
|
||||
|
||||
swap.baseTokenAmount = weiToDecimal(
|
||||
event.params.baseTokenSwappedAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
swap.dataTokenAmount = weiToDecimal(
|
||||
event.params.datatokenSwappedAmount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
|
||||
// Track fees
|
||||
swap.oceanFeeAmount = weiToDecimal(
|
||||
event.params.oceanFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
swap.marketFeeAmount = weiToDecimal(
|
||||
event.params.marketFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
swap.consumeMarketFeeAmount = weiToDecimal(
|
||||
event.params.consumeMarketFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
|
||||
swap.save()
|
||||
|
||||
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
||||
|
||||
if (event.params.tokenOutAddress.toHexString() == fixedRateExchange.baseToken)
|
||||
addFixedSwap(
|
||||
event.params.tokenOutAddress.toHexString(),
|
||||
swap.dataTokenAmount
|
||||
)
|
||||
else addFixedSwap(fixedRateExchange.baseToken, swap.baseTokenAmount)
|
||||
// update datatoken lastPriceToken and lastPriceValue
|
||||
const datatoken = getToken(
|
||||
Address.fromString(fixedRateExchange.datatoken),
|
||||
true
|
||||
)
|
||||
const priceToken = getToken(
|
||||
Address.fromString(fixedRateExchange.baseToken),
|
||||
false
|
||||
)
|
||||
datatoken.lastPriceToken = priceToken.id
|
||||
datatoken.lastPriceValue = fixedRateExchange.price
|
||||
datatoken.save()
|
||||
}
|
||||
|
||||
export function handlePublishMarketFeeChanged(
|
||||
event: PublishMarketFeeChanged
|
||||
): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
if (fixedRateExchange) {
|
||||
fixedRateExchange.publishMarketFeeAddress =
|
||||
event.params.newMarketCollector.toHexString()
|
||||
fixedRateExchange.publishMarketSwapFee = weiToDecimal(
|
||||
event.params.swapFee.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handleTokenCollected(event: TokenCollected): void {
|
||||
const fixedRateId = getFixedRateGraphID(
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
|
||||
if (event.params.token.toHexString() == fixedRateExchange.baseToken) {
|
||||
const baseToken = getToken(event.params.token, false)
|
||||
fixedRateExchange.baseTokenBalance =
|
||||
fixedRateExchange.baseTokenBalance.minus(
|
||||
weiToDecimal(event.params.amount.toBigDecimal(), baseToken.decimals)
|
||||
)
|
||||
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
import { BigInt, ethereum, log } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
ExchangeCreated,
|
||||
ExchangeActivated,
|
||||
ExchangeDeactivated,
|
||||
ExchangeRateChanged,
|
||||
Swapped
|
||||
} from '../@types/FixedRateExchange/FixedRateExchange'
|
||||
|
||||
import {
|
||||
FixedRateExchange,
|
||||
FixedRateExchangeUpdate,
|
||||
FixedRateExchangeSwap
|
||||
} from '../@types/schema'
|
||||
|
||||
import { getTokenSymbol, tokenToDecimal } from '../helpers'
|
||||
|
||||
export function handleExchangeCreated(event: ExchangeCreated): void {
|
||||
const fixedrateexchange = new FixedRateExchange(
|
||||
event.params.exchangeId.toHexString()
|
||||
)
|
||||
fixedrateexchange.exchangeOwner = event.params.exchangeOwner.toHexString()
|
||||
fixedrateexchange.datatoken = event.params.dataToken.toHexString()
|
||||
fixedrateexchange.baseToken = event.params.baseToken.toHexString()
|
||||
fixedrateexchange.baseTokenSymbol = getTokenSymbol(event.params.baseToken)
|
||||
fixedrateexchange.active = false
|
||||
log.info('new exchange with datatoken {} and base token {} ', [
|
||||
fixedrateexchange.datatoken,
|
||||
fixedrateexchange.baseToken
|
||||
])
|
||||
log.info('for new exchange {} for rate {}', [
|
||||
event.params.exchangeId.toHexString(),
|
||||
event.params.fixedRate.toString()
|
||||
])
|
||||
fixedrateexchange.rate = tokenToDecimal(
|
||||
event.params.fixedRate.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
fixedrateexchange.save()
|
||||
}
|
||||
|
||||
function _processActiveUpdated(
|
||||
event: ethereum.Event,
|
||||
exchangeId: string,
|
||||
active: boolean
|
||||
): void {
|
||||
const tx = event.transaction.hash
|
||||
const id = tx.toHexString().concat('-').concat(exchangeId)
|
||||
const fixedrateexchange = FixedRateExchange.load(exchangeId)
|
||||
|
||||
const freupdate = new FixedRateExchangeUpdate(id)
|
||||
freupdate.exchangeId = exchangeId
|
||||
freupdate.oldRate = fixedrateexchange.rate
|
||||
freupdate.newRate = fixedrateexchange.rate
|
||||
freupdate.oldActive = fixedrateexchange.active
|
||||
freupdate.newActive = active
|
||||
freupdate.block = event.block.number.toI32()
|
||||
freupdate.timestamp = event.block.timestamp.toI32()
|
||||
freupdate.tx = tx
|
||||
freupdate.save()
|
||||
|
||||
fixedrateexchange.active = active
|
||||
fixedrateexchange.save()
|
||||
}
|
||||
|
||||
export function handleExchangeActivated(event: ExchangeActivated): void {
|
||||
_processActiveUpdated(event, event.params.exchangeId.toHexString(), true)
|
||||
}
|
||||
|
||||
export function handleExchangeDeactivated(event: ExchangeDeactivated): void {
|
||||
_processActiveUpdated(event, event.params.exchangeId.toHexString(), false)
|
||||
}
|
||||
|
||||
export function handleExchangeRateChanged(event: ExchangeRateChanged): void {
|
||||
const tx = event.transaction.hash
|
||||
const id = tx
|
||||
.toHexString()
|
||||
.concat('-')
|
||||
.concat(event.params.exchangeId.toHexString())
|
||||
const fixedrateexchange = FixedRateExchange.load(
|
||||
event.params.exchangeId.toHexString()
|
||||
)
|
||||
if (!fixedrateexchange) {
|
||||
log.error('Cannot update unknown FRE {}', [
|
||||
event.params.exchangeId.toHexString()
|
||||
])
|
||||
return
|
||||
}
|
||||
|
||||
const freupdate = new FixedRateExchangeUpdate(id)
|
||||
freupdate.exchangeId = fixedrateexchange.id
|
||||
freupdate.oldRate = fixedrateexchange.rate
|
||||
log.info('for new exchange {} for rate {}', [
|
||||
id,
|
||||
event.params.newRate.toString()
|
||||
])
|
||||
freupdate.newRate = tokenToDecimal(
|
||||
event.params.newRate.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
freupdate.oldActive = fixedrateexchange.active
|
||||
freupdate.newActive = fixedrateexchange.active
|
||||
freupdate.block = event.block.number.toI32()
|
||||
freupdate.timestamp = event.block.timestamp.toI32()
|
||||
freupdate.tx = tx
|
||||
freupdate.save()
|
||||
|
||||
fixedrateexchange.rate = freupdate.newRate
|
||||
fixedrateexchange.save()
|
||||
}
|
||||
|
||||
export function handleSwapped(event: Swapped): void {
|
||||
const tx = event.transaction.hash
|
||||
const id = tx
|
||||
.toHexString()
|
||||
.concat('-')
|
||||
.concat(event.params.exchangeId.toHexString())
|
||||
const freSwap = new FixedRateExchangeSwap(id)
|
||||
freSwap.exchangeId = event.params.exchangeId.toHexString()
|
||||
freSwap.by = event.params.by.toHexString()
|
||||
freSwap.baseTokenAmount = tokenToDecimal(
|
||||
event.params.baseTokenSwappedAmount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
freSwap.dataTokenAmount = tokenToDecimal(
|
||||
event.params.dataTokenSwappedAmount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
freSwap.block = event.block.number.toI32()
|
||||
freSwap.timestamp = event.block.timestamp.toI32()
|
||||
freSwap.tx = tx
|
||||
freSwap.save()
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
import { BigInt, ethereum } from '@graphprotocol/graph-ts'
|
||||
import { MetadataUpdated, MetadataCreated } from '../@types/Metadata/Metadata'
|
||||
|
||||
import { Datatoken, MetadataUpdate } from '../@types/schema'
|
||||
|
||||
export function handleMetadataEvent(
|
||||
event: ethereum.Event,
|
||||
dtAddress: string,
|
||||
updatedBy: string,
|
||||
created: boolean
|
||||
): void {
|
||||
const datatoken = Datatoken.load(dtAddress)
|
||||
if (datatoken) {
|
||||
const tx = event.transaction.hash
|
||||
const id = tx.toHexString().concat('-').concat(dtAddress)
|
||||
const metadataUpdate = new MetadataUpdate(id)
|
||||
metadataUpdate.tx = tx
|
||||
metadataUpdate.block = event.block.number.toI32()
|
||||
metadataUpdate.timestamp = event.block.timestamp.toI32()
|
||||
metadataUpdate.datatokenAddress = dtAddress
|
||||
metadataUpdate.userAddress = updatedBy
|
||||
metadataUpdate.datatokenId = dtAddress
|
||||
metadataUpdate.save()
|
||||
datatoken.metadataUpdateCount = datatoken.metadataUpdateCount.plus(
|
||||
BigInt.fromI32(1)
|
||||
)
|
||||
datatoken.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handleMetadataUpdated(event: MetadataUpdated): void {
|
||||
handleMetadataEvent(
|
||||
event,
|
||||
event.params.dataToken.toHexString(),
|
||||
event.params.updatedBy.toHexString(),
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
export function handleMetadataCreated(event: MetadataCreated): void {
|
||||
handleMetadataEvent(
|
||||
event,
|
||||
event.params.dataToken.toHexString(),
|
||||
event.params.createdBy.toHexString(),
|
||||
true
|
||||
)
|
||||
}
|
|
@ -0,0 +1,304 @@
|
|||
import { Nft, NftUpdate, NftData, NftTransferHistory } from '../@types/schema'
|
||||
import {
|
||||
MetadataCreated,
|
||||
MetadataState,
|
||||
MetadataUpdated,
|
||||
TokenURIUpdate,
|
||||
AddedManager,
|
||||
AddedTo725StoreList,
|
||||
AddedToCreateERC20List,
|
||||
AddedToMetadataList,
|
||||
RemovedFrom725StoreList,
|
||||
RemovedFromCreateERC20List,
|
||||
RemovedFromMetadataList,
|
||||
RemovedManager,
|
||||
CleanedPermissions,
|
||||
Transfer,
|
||||
DataChanged
|
||||
} from '../@types/templates/ERC721Template/ERC721Template'
|
||||
import { NftUpdateType } from './utils/constants'
|
||||
import { getNftToken, getNftTokenWithID } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
function getId(tx: string, nftAddress: string, eventIndex: number): string {
|
||||
return `${tx}-${nftAddress}-${eventIndex}`
|
||||
}
|
||||
|
||||
export function handleMetadataCreated(event: MetadataCreated): void {
|
||||
const nftAddress = event.address.toHex()
|
||||
const nft = Nft.load(nftAddress)
|
||||
if (!nft) return
|
||||
|
||||
nft.assetState = event.params.state
|
||||
nft.providerUrl = event.params.decryptorUrl.toString()
|
||||
nft.hasMetadata = true
|
||||
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const nftUpdate = new NftUpdate(
|
||||
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||
)
|
||||
|
||||
nftUpdate.type = NftUpdateType.METADATA_CREATED
|
||||
nftUpdate.userAddress = event.params.createdBy.toHex()
|
||||
nftUpdate.assetState = event.params.state
|
||||
|
||||
nftUpdate.nft = nft.id
|
||||
nftUpdate.providerUrl = nft.providerUrl
|
||||
nftUpdate.tokenUri = nft.tokenUri
|
||||
|
||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||
nftUpdate.tx = event.transaction.hash.toHex()
|
||||
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||
nftUpdate.block = event.block.number.toI32()
|
||||
|
||||
nftUpdate.save()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleMetadataUpdated(event: MetadataUpdated): void {
|
||||
const nftAddress = event.address.toHex()
|
||||
const nft = Nft.load(nftAddress)
|
||||
if (!nft) return
|
||||
|
||||
nft.assetState = event.params.state
|
||||
nft.hasMetadata = true
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const nftUpdate = new NftUpdate(
|
||||
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||
)
|
||||
|
||||
nftUpdate.nft = nft.id
|
||||
nftUpdate.type = NftUpdateType.METADATA_UPDATED
|
||||
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||
nftUpdate.assetState = event.params.state
|
||||
|
||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||
nftUpdate.tx = event.transaction.hash.toHex()
|
||||
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||
nftUpdate.block = event.block.number.toI32()
|
||||
|
||||
nftUpdate.save()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleMetadataState(event: MetadataState): void {
|
||||
const nftAddress = event.address.toHex()
|
||||
const nft = Nft.load(nftAddress)
|
||||
if (!nft) return
|
||||
|
||||
nft.assetState = event.params.state
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const nftUpdate = new NftUpdate(
|
||||
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||
)
|
||||
|
||||
nftUpdate.nft = nft.id
|
||||
nftUpdate.type = NftUpdateType.STATE_UPDATED
|
||||
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||
nftUpdate.assetState = event.params.state
|
||||
|
||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||
nftUpdate.tx = event.transaction.hash.toHex()
|
||||
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||
nftUpdate.block = event.block.number.toI32()
|
||||
|
||||
nftUpdate.save()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleTokenUriUpdate(event: TokenURIUpdate): void {
|
||||
const nftAddress = event.address.toHex()
|
||||
const nft = Nft.load(nftAddress)
|
||||
|
||||
if (!nft) return
|
||||
|
||||
nft.tokenUri = event.params.tokenURI.toString()
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const nftUpdate = new NftUpdate(
|
||||
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||
)
|
||||
nftUpdate.nft = nft.id
|
||||
nftUpdate.type = NftUpdateType.TOKENURI_UPDATED
|
||||
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||
nftUpdate.tokenUri = nft.tokenUri
|
||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||
nftUpdate.tx = event.transaction.hash.toHex()
|
||||
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||
nftUpdate.block = event.block.number.toI32()
|
||||
nftUpdate.assetState = nft.assetState
|
||||
nftUpdate.save()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
// roles
|
||||
export function handleAddedManager(event: AddedManager): void {
|
||||
const nft = getNftToken(event.address)
|
||||
let existingRoles: string[]
|
||||
if (!nft.managerRole) existingRoles = []
|
||||
else existingRoles = nft.managerRole as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
nft.managerRole = existingRoles
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
export function handleRemovedManager(event: RemovedManager): void {
|
||||
const nft = getNftToken(event.address)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!nft.managerRole) existingRoles = []
|
||||
else existingRoles = nft.managerRole as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
nft.managerRole = newList
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
// storeUpdater
|
||||
export function handleAddedTo725StoreList(event: AddedTo725StoreList): void {
|
||||
const nft = getNftToken(event.address)
|
||||
let existingRoles: string[]
|
||||
if (!nft.storeUpdateRole) existingRoles = []
|
||||
else existingRoles = nft.storeUpdateRole as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
nft.storeUpdateRole = existingRoles
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleRemovedFrom725StoreList(
|
||||
event: RemovedFrom725StoreList
|
||||
): void {
|
||||
const nft = getNftToken(event.address)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!nft.storeUpdateRole) existingRoles = []
|
||||
else existingRoles = nft.storeUpdateRole as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
nft.storeUpdateRole = newList
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
// erc20Deployer
|
||||
export function handleAddedToCreateERC20List(
|
||||
event: AddedToCreateERC20List
|
||||
): void {
|
||||
const nft = getNftToken(event.address)
|
||||
let existingRoles: string[]
|
||||
if (!nft.erc20DeployerRole) existingRoles = []
|
||||
else existingRoles = nft.erc20DeployerRole as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
nft.erc20DeployerRole = existingRoles
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleRemovedFromCreateERC20List(
|
||||
event: RemovedFromCreateERC20List
|
||||
): void {
|
||||
const nft = getNftToken(event.address)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!nft.erc20DeployerRole) existingRoles = []
|
||||
else existingRoles = nft.erc20DeployerRole as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
nft.erc20DeployerRole = newList
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
// metadata updater
|
||||
export function handleAddedToMetadataList(event: AddedToMetadataList): void {
|
||||
const nft = getNftToken(event.address)
|
||||
let existingRoles: string[]
|
||||
if (!nft.metadataRole) existingRoles = []
|
||||
else existingRoles = nft.metadataRole as string[]
|
||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||
existingRoles.push(event.params.user.toHexString())
|
||||
nft.metadataRole = existingRoles
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleRemovedFromMetadataList(
|
||||
event: RemovedFromMetadataList
|
||||
): void {
|
||||
const nft = getNftToken(event.address)
|
||||
const newList: string[] = []
|
||||
let existingRoles: string[]
|
||||
if (!nft.metadataRole) existingRoles = []
|
||||
else existingRoles = nft.metadataRole as string[]
|
||||
if (!existingRoles || existingRoles.length < 1) return
|
||||
while (existingRoles.length > 0) {
|
||||
const role = existingRoles.shift().toString()
|
||||
if (!role) break
|
||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||
}
|
||||
nft.metadataRole = newList
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleCleanedPermissions(event: CleanedPermissions): void {
|
||||
const nft = getNftToken(event.address)
|
||||
const newList: string[] = []
|
||||
nft.metadataRole = newList
|
||||
nft.erc20DeployerRole = newList
|
||||
nft.storeUpdateRole = newList
|
||||
nft.managerRole = newList
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
export function handleNftTransferred(event: Transfer): void {
|
||||
const id = event.address.toHex()
|
||||
const nft = getNftTokenWithID(id)
|
||||
const oldOwner = nft.owner
|
||||
const newOwner = getUser(event.params.to.toHexString())
|
||||
nft.owner = newOwner.id
|
||||
nft.save()
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const transferId = `${
|
||||
nft.address
|
||||
}-${event.transaction.hash.toHex()}-${eventIndex}`
|
||||
const newTransfer = new NftTransferHistory(transferId)
|
||||
newTransfer.oldOwner = oldOwner
|
||||
newTransfer.nft = nft.id
|
||||
newTransfer.newOwner = newOwner.id
|
||||
newTransfer.txId = event.transaction.hash.toHex()
|
||||
newTransfer.eventIndex = event.logIndex.toI32()
|
||||
newTransfer.timestamp = event.block.timestamp.toI32()
|
||||
newTransfer.block = event.block.number.toI32()
|
||||
newTransfer.save()
|
||||
}
|
||||
|
||||
export function handleNftData(event: DataChanged): void {
|
||||
const id = event.address.toHexString() + '-' + event.params.key.toHexString()
|
||||
const nft = getNftToken(event.address)
|
||||
let data = NftData.load(id)
|
||||
if (data == null) {
|
||||
data = new NftData(id)
|
||||
}
|
||||
data.key = event.params.key
|
||||
data.value = event.params.value
|
||||
data.nft = nft.id
|
||||
data.save()
|
||||
}
|
|
@ -1,634 +0,0 @@
|
|||
import { BigInt, Address, BigDecimal, log } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
LOG_CALL,
|
||||
LOG_JOIN,
|
||||
LOG_EXIT,
|
||||
LOG_SWAP,
|
||||
Transfer,
|
||||
Pool as PoolEntity
|
||||
} from '../@types/templates/Pool/Pool'
|
||||
|
||||
import {
|
||||
PoolFactory,
|
||||
Pool,
|
||||
PoolToken,
|
||||
PoolShare,
|
||||
Datatoken,
|
||||
PoolTransaction,
|
||||
Global
|
||||
} from '../@types/schema'
|
||||
import {
|
||||
hexToDecimal,
|
||||
tokenToDecimal,
|
||||
createPoolShareEntity,
|
||||
createPoolTokenEntity,
|
||||
ZERO_BD,
|
||||
MINUS_1_BD,
|
||||
decrPoolCount,
|
||||
updatePoolTransactionToken,
|
||||
createPoolTransaction,
|
||||
OCEAN,
|
||||
debuglog,
|
||||
updatePoolTokenBalance,
|
||||
getOceanAddress,
|
||||
getGlobalStats,
|
||||
bigIntToDecimal
|
||||
} from '../helpers'
|
||||
|
||||
/************************************
|
||||
********** Pool Controls ***********
|
||||
************************************/
|
||||
|
||||
export function handleSetSwapFee(
|
||||
event: LOG_CALL,
|
||||
swapFeeStr: string = null
|
||||
): void {
|
||||
const poolId = event.address.toHex()
|
||||
const pool = Pool.load(poolId)
|
||||
if (!swapFeeStr) {
|
||||
swapFeeStr = event.params.data.toHexString().slice(-40)
|
||||
}
|
||||
pool.swapFee = hexToDecimal(swapFeeStr, 18)
|
||||
pool.save()
|
||||
}
|
||||
|
||||
export function handleSetController(event: LOG_CALL): void {
|
||||
const poolId = event.address.toHex()
|
||||
const pool = Pool.load(poolId)
|
||||
pool.controller = Address.fromString(
|
||||
event.params.data.toHexString().slice(-40)
|
||||
)
|
||||
pool.save()
|
||||
}
|
||||
|
||||
export function handleSetPublicSwap(event: LOG_CALL): void {
|
||||
const poolId = event.address.toHex()
|
||||
const pool = Pool.load(poolId)
|
||||
pool.publicSwap = event.params.data.toHexString().slice(-1) == '1'
|
||||
pool.save()
|
||||
}
|
||||
|
||||
export function handleFinalize(event: LOG_CALL): void {
|
||||
const poolId = event.address.toHex()
|
||||
const pool = Pool.load(poolId)
|
||||
if (pool === null) {
|
||||
log.error('Cannot handle finalize for unknown pool {} ', [poolId])
|
||||
return
|
||||
}
|
||||
if (pool.tokenCount == BigInt.fromI32(0)) {
|
||||
log.error('Cannot mark pool {} finalized, because we have 0 tokenCount', [
|
||||
poolId
|
||||
])
|
||||
return
|
||||
}
|
||||
pool.finalized = true
|
||||
pool.symbol = 'BPT'
|
||||
pool.publicSwap = true
|
||||
pool.save()
|
||||
|
||||
const factory = PoolFactory.load('1')
|
||||
factory.finalizedPoolCount = factory.finalizedPoolCount + 1
|
||||
factory.save()
|
||||
}
|
||||
|
||||
export function _handleRebind(
|
||||
event: LOG_CALL,
|
||||
poolId: string,
|
||||
tokenAddress: string,
|
||||
balanceStr: string,
|
||||
denormWeightStr: string
|
||||
): void {
|
||||
const pool = Pool.load(poolId)
|
||||
const decimals = BigInt.fromI32(18).toI32()
|
||||
|
||||
if (tokenAddress != OCEAN) {
|
||||
pool.datatokenAddress = tokenAddress
|
||||
}
|
||||
pool.tokenCount = pool.tokenCount.plus(BigInt.fromI32(1))
|
||||
const address = Address.fromString(tokenAddress)
|
||||
const denormWeight = hexToDecimal(denormWeightStr, decimals)
|
||||
const poolTokenId = poolId.concat('-').concat(address.toHexString())
|
||||
let poolToken = PoolToken.load(poolTokenId)
|
||||
if (poolToken == null) {
|
||||
createPoolTokenEntity(poolTokenId, poolId, address)
|
||||
poolToken = PoolToken.load(poolTokenId)
|
||||
pool.totalWeight = pool.totalWeight.plus(denormWeight)
|
||||
} else {
|
||||
const oldWeight = poolToken.denormWeight
|
||||
if (denormWeight > oldWeight) {
|
||||
pool.totalWeight = pool.totalWeight.plus(denormWeight).minus(oldWeight)
|
||||
} else {
|
||||
pool.totalWeight = pool.totalWeight.minus(oldWeight).minus(denormWeight)
|
||||
}
|
||||
}
|
||||
|
||||
poolToken.denormWeight = denormWeight
|
||||
const balance = hexToDecimal(balanceStr, decimals)
|
||||
updatePoolTokenBalance(poolToken as PoolToken, balance, '_handleRebind')
|
||||
|
||||
poolToken.save()
|
||||
if (balance.equals(ZERO_BD)) {
|
||||
decrPoolCount(pool.finalized)
|
||||
pool.active = false
|
||||
}
|
||||
pool.save()
|
||||
}
|
||||
|
||||
export function handleRebind(event: LOG_CALL): void {
|
||||
const poolId = event.address.toHex()
|
||||
_handleRebind(
|
||||
event,
|
||||
poolId,
|
||||
event.params.data.toHexString().slice(34, 74),
|
||||
event.params.data.toHexString().slice(74, 138),
|
||||
event.params.data.toHexString().slice(138)
|
||||
)
|
||||
}
|
||||
|
||||
export function handleSetup(event: LOG_CALL): void {
|
||||
if (PoolTransaction.load(event.transaction.hash.toHexString()) != null) {
|
||||
return
|
||||
}
|
||||
|
||||
const poolId = event.address.toHex()
|
||||
debuglog('handleSetup: ', event, [])
|
||||
const data = event.params.data.toHexString()
|
||||
// First 2 chars are 0x
|
||||
// Next there is 8 chars
|
||||
// Next starts the data each params occupies exactly 64 chars
|
||||
// Each value is padded with 0s to the left
|
||||
// For an Address, need to remove the leading 24 zeros, because the address itself is 40 chars
|
||||
// For numbers we donot need to remove the leading zeros because they have no effect being on the left of the number
|
||||
|
||||
// skip 8 then take the last 40 (2 + 8 + 24 = 34) to (2 + 8 + 64 = 74)
|
||||
const dataTokenAddress = Address.fromString(data.slice(34, 74)).toHexString()
|
||||
|
||||
const dataTokenAmount = data.slice(74, 138) // 74+64
|
||||
const dataTokenWeight = data.slice(138, 202) // (74+64,74+(2*64)
|
||||
const baseTokenAddress = Address.fromString(
|
||||
data.slice(202 + 24, 266)
|
||||
).toHexString() // (74+(2*64)+24, 74+(3*64))
|
||||
const baseTokenAmount = data.slice(266, 330) // (74+(3*64),74+(4*64))
|
||||
const baseTokenWeight = data.slice(330, 394) // (74+(4*64),74+(5*64))
|
||||
const swapFee = data.slice(394) // (74+(5*64), END)
|
||||
|
||||
if (baseTokenAddress != OCEAN) {
|
||||
log.error('baseTokenAddress is not Ocean, but is {}', [baseTokenAddress])
|
||||
return
|
||||
}
|
||||
const poolTokenId = poolId.concat('-').concat(baseTokenAddress)
|
||||
const poolToken = PoolToken.load(poolTokenId)
|
||||
if (poolToken != null) return
|
||||
|
||||
_handleRebind(
|
||||
event,
|
||||
poolId,
|
||||
dataTokenAddress,
|
||||
dataTokenAmount,
|
||||
dataTokenWeight
|
||||
)
|
||||
_handleRebind(
|
||||
event,
|
||||
poolId,
|
||||
baseTokenAddress,
|
||||
baseTokenAmount,
|
||||
baseTokenWeight
|
||||
)
|
||||
handleSetSwapFee(event, swapFee)
|
||||
handleFinalize(event)
|
||||
createPoolTransaction(event, 'setup', event.transaction.from.toHex())
|
||||
|
||||
// update base token
|
||||
let amount = hexToDecimal(baseTokenAmount, 18)
|
||||
|
||||
updatePoolTransactionToken(
|
||||
event.transaction.hash.toHexString(),
|
||||
poolTokenId,
|
||||
amount,
|
||||
PoolToken.load(poolTokenId).balance,
|
||||
ZERO_BD
|
||||
)
|
||||
// update the datatoken
|
||||
amount = hexToDecimal(dataTokenAmount, 18)
|
||||
updatePoolTransactionToken(
|
||||
event.transaction.hash.toHexString(),
|
||||
poolId.concat('-').concat(dataTokenAddress),
|
||||
amount,
|
||||
PoolToken.load(poolId.concat('-').concat(dataTokenAddress)).balance,
|
||||
ZERO_BD
|
||||
)
|
||||
}
|
||||
|
||||
/************************************
|
||||
********** JOINS & EXITS ***********
|
||||
************************************/
|
||||
|
||||
export function handleJoinPool(event: LOG_JOIN): void {
|
||||
const poolId = event.address.toHex()
|
||||
|
||||
const pool = Pool.load(poolId)
|
||||
if (pool.finalized == false) {
|
||||
return
|
||||
}
|
||||
|
||||
pool.joinCount = pool.joinCount.plus(BigInt.fromI32(1))
|
||||
pool.save()
|
||||
const ptx = event.transaction.hash.toHexString()
|
||||
const poolTx = PoolTransaction.load(ptx)
|
||||
if (poolTx != null) {
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!! JOIN JOIN JOIN !!!!!!!!!!!! PoolTransaction EXISTS: ',
|
||||
event,
|
||||
[]
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const address = event.params.tokenIn.toHex()
|
||||
const poolTokenId = poolId.concat('-').concat(address)
|
||||
const poolToken = PoolToken.load(poolTokenId)
|
||||
if (poolToken == null) {
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!! JOIN JOIN JOIN !!!!!!!!!!!! NO PoolToken: ',
|
||||
event,
|
||||
[address, poolTokenId]
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const datatoken: Datatoken | null =
|
||||
poolToken.tokenId != null ? Datatoken.load(poolToken.tokenId) : null
|
||||
const decimals =
|
||||
datatoken == null ? BigInt.fromI32(18).toI32() : datatoken.decimals
|
||||
const tokenAmountIn = tokenToDecimal(
|
||||
event.params.tokenAmountIn.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
updatePoolTokenBalance(
|
||||
poolToken as PoolToken,
|
||||
poolToken.balance.plus(tokenAmountIn),
|
||||
'handleJoinPool'
|
||||
)
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! JOIN JOIN JOIN : (token, amountIn, amountIn) ',
|
||||
event,
|
||||
[address, tokenAmountIn.toString(), event.params.tokenAmountIn.toString()]
|
||||
)
|
||||
|
||||
poolToken.save()
|
||||
createPoolTransaction(event, 'join', event.params.caller.toHexString())
|
||||
updatePoolTransactionToken(
|
||||
event.transaction.hash.toHexString(),
|
||||
poolTokenId,
|
||||
tokenAmountIn,
|
||||
poolToken.balance,
|
||||
tokenAmountIn.times(pool.swapFee)
|
||||
)
|
||||
}
|
||||
|
||||
export function handleExitPool(event: LOG_EXIT): void {
|
||||
const poolId = event.address.toHex()
|
||||
|
||||
const address = event.params.tokenOut.toHex()
|
||||
const poolTokenId = poolId.concat('-').concat(address.toString())
|
||||
const poolToken = PoolToken.load(poolTokenId)
|
||||
if (!poolToken) {
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!! EXIT EXIT EXIT !!!!!!!!!!!! NO PoolToken: ',
|
||||
event,
|
||||
[address, poolTokenId]
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const datatoken: Datatoken | null =
|
||||
poolToken.tokenId != null ? Datatoken.load(poolToken.tokenId) : null
|
||||
const decimals =
|
||||
datatoken == null ? BigInt.fromI32(18).toI32() : datatoken.decimals
|
||||
const tokenAmountOut = tokenToDecimal(
|
||||
event.params.tokenAmountOut.toBigDecimal(),
|
||||
decimals
|
||||
)
|
||||
const newAmount = poolToken.balance.minus(tokenAmountOut)
|
||||
updatePoolTokenBalance(poolToken as PoolToken, newAmount, 'handleExitPool')
|
||||
poolToken.save()
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! EXIT EXIT EXIT : (token, amountOut, amountOut)',
|
||||
event,
|
||||
[address, tokenAmountOut.toString(), event.params.tokenAmountOut.toString()]
|
||||
)
|
||||
const pool = Pool.load(poolId)
|
||||
pool.exitCount = pool.exitCount.plus(BigInt.fromI32(1))
|
||||
if (newAmount.equals(ZERO_BD)) {
|
||||
decrPoolCount(pool.finalized)
|
||||
pool.active = false
|
||||
}
|
||||
pool.save()
|
||||
|
||||
createPoolTransaction(event, 'exit', event.params.caller.toHexString())
|
||||
updatePoolTransactionToken(
|
||||
event.transaction.hash.toHexString(),
|
||||
poolTokenId,
|
||||
tokenAmountOut.times(MINUS_1_BD),
|
||||
poolToken.balance,
|
||||
tokenAmountOut.times(pool.swapFee)
|
||||
)
|
||||
}
|
||||
|
||||
/************************************
|
||||
************** SWAPS ***************
|
||||
************************************/
|
||||
|
||||
export function handleSwap(event: LOG_SWAP): void {
|
||||
const poolId = event.address.toHex()
|
||||
const ptx = event.transaction.hash.toHexString()
|
||||
|
||||
const tokenIn = event.params.tokenIn.toHex()
|
||||
const poolTokenInId = poolId.concat('-').concat(tokenIn.toString())
|
||||
const poolTokenIn = PoolToken.load(poolTokenInId)
|
||||
if (!poolTokenIn) {
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!! SWAP SWAP SWAP !!!!!!!!!!!! NO PoolToken: ',
|
||||
event,
|
||||
[tokenIn, poolTokenInId]
|
||||
)
|
||||
return
|
||||
}
|
||||
const dtIn = Datatoken.load(tokenIn)
|
||||
const tokenAmountIn = tokenToDecimal(
|
||||
event.params.tokenAmountIn.toBigDecimal(),
|
||||
dtIn == null ? 18 : dtIn.decimals
|
||||
)
|
||||
const newAmountIn = poolTokenIn.balance.plus(tokenAmountIn)
|
||||
updatePoolTokenBalance(
|
||||
poolTokenIn as PoolToken,
|
||||
newAmountIn,
|
||||
'handleSwap.tokenIn'
|
||||
)
|
||||
poolTokenIn.save()
|
||||
|
||||
const tokenOut = event.params.tokenOut.toHex()
|
||||
const poolTokenOutId = poolId.concat('-').concat(tokenOut.toString())
|
||||
const poolTokenOut = PoolToken.load(poolTokenOutId)
|
||||
const dtOut = Datatoken.load(tokenOut)
|
||||
const tokenAmountOut = tokenToDecimal(
|
||||
event.params.tokenAmountOut.toBigDecimal(),
|
||||
dtOut == null ? 18 : dtOut.decimals
|
||||
)
|
||||
const newAmountOut = poolTokenOut.balance.minus(tokenAmountOut)
|
||||
updatePoolTokenBalance(
|
||||
poolTokenOut as PoolToken,
|
||||
newAmountOut,
|
||||
'handleSwap.tokenOut'
|
||||
)
|
||||
poolTokenOut.save()
|
||||
debuglog(
|
||||
'!!!!!!!!!!!!!!!!!! SWAP SWAP SWAP : (tokenIn, tokenOut, amountIn, amountIn, amountOut, amountOut)',
|
||||
event,
|
||||
[
|
||||
tokenIn,
|
||||
tokenOut,
|
||||
tokenAmountIn.toString(),
|
||||
event.params.tokenAmountIn.toString(),
|
||||
tokenAmountOut.toString(),
|
||||
event.params.tokenAmountOut.toString()
|
||||
]
|
||||
)
|
||||
const pool = Pool.load(poolId)
|
||||
const factory = PoolFactory.load('1')
|
||||
|
||||
pool.swapCount = pool.swapCount.plus(BigInt.fromI32(1))
|
||||
if (newAmountIn.equals(ZERO_BD) || newAmountOut.equals(ZERO_BD)) {
|
||||
decrPoolCount(pool.finalized)
|
||||
pool.active = false
|
||||
}
|
||||
if (tokenIn === getOceanAddress()) {
|
||||
pool.totalSwapVolume = pool.totalSwapVolume.plus(tokenAmountIn)
|
||||
factory.totalSwapVolume = factory.totalSwapVolume.plus(tokenAmountIn)
|
||||
} else {
|
||||
pool.totalSwapVolume = pool.totalSwapVolume.plus(tokenAmountOut)
|
||||
factory.totalSwapVolume = factory.totalSwapVolume.plus(tokenAmountOut)
|
||||
}
|
||||
|
||||
factory.save()
|
||||
pool.save()
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
gStats.totalSwapVolume = factory.totalSwapVolume
|
||||
|
||||
gStats.save()
|
||||
|
||||
createPoolTransaction(event, 'swap', event.params.caller.toHexString())
|
||||
updatePoolTransactionToken(
|
||||
ptx,
|
||||
poolTokenIn.id,
|
||||
tokenAmountIn,
|
||||
poolTokenIn.balance,
|
||||
tokenAmountIn.times(pool.swapFee)
|
||||
)
|
||||
updatePoolTransactionToken(
|
||||
ptx,
|
||||
poolTokenOut.id,
|
||||
tokenAmountOut.times(MINUS_1_BD),
|
||||
poolTokenOut.balance,
|
||||
BigDecimal.fromString('0.0')
|
||||
)
|
||||
}
|
||||
|
||||
/************************************
|
||||
*********** POOL SHARES ************
|
||||
************************************/
|
||||
|
||||
export function handleTransfer(event: Transfer): void {
|
||||
const poolId = event.address.toHex()
|
||||
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
|
||||
const isMint = event.params.from.toHex() == ZERO_ADDRESS
|
||||
const isBurn = event.params.to.toHex() == ZERO_ADDRESS
|
||||
|
||||
const poolShareFromId = poolId.concat('-').concat(event.params.from.toHex())
|
||||
let poolShareFrom = PoolShare.load(poolShareFromId)
|
||||
const poolShareFromBalance =
|
||||
poolShareFrom == null ? ZERO_BD : poolShareFrom.balance
|
||||
|
||||
const poolShareToId = poolId.concat('-').concat(event.params.to.toHex())
|
||||
let poolShareTo = PoolShare.load(poolShareToId)
|
||||
const poolShareToBalance = poolShareTo == null ? ZERO_BD : poolShareTo.balance
|
||||
|
||||
const pool = Pool.load(poolId)
|
||||
const poolTx = PoolTransaction.load(event.transaction.hash.toHexString())
|
||||
const value = tokenToDecimal(event.params.value.toBigDecimal(), 18)
|
||||
debuglog('poolShare Transfer event: (from, to, value)', event, [
|
||||
event.params.from.toHex(),
|
||||
event.params.to.toHex(),
|
||||
value.toString()
|
||||
])
|
||||
|
||||
if (isMint) {
|
||||
if (poolShareTo == null) {
|
||||
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
|
||||
poolShareTo = PoolShare.load(poolShareToId)
|
||||
}
|
||||
poolShareTo.balance = poolShareTo.balance.plus(value)
|
||||
poolShareTo.save()
|
||||
pool.totalShares = pool.totalShares.plus(value)
|
||||
if (poolTx != null) {
|
||||
poolTx.sharesTransferAmount = value
|
||||
poolTx.sharesBalance = poolShareTo.balance
|
||||
}
|
||||
debuglog(
|
||||
'pool shares mint: (id, value, totalShares, shareToBalance, toAddress)',
|
||||
event,
|
||||
[
|
||||
poolId,
|
||||
value.toString(),
|
||||
pool.totalShares.toString(),
|
||||
poolShareTo.balance.toString(),
|
||||
poolShareTo.userAddress
|
||||
]
|
||||
)
|
||||
} else if (isBurn) {
|
||||
if (poolShareFrom == null) {
|
||||
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
|
||||
poolShareFrom = PoolShare.load(poolShareFromId)
|
||||
}
|
||||
poolShareFrom.balance = poolShareFrom.balance.minus(value)
|
||||
poolShareFrom.save()
|
||||
pool.totalShares = pool.totalShares.minus(value)
|
||||
if (poolTx != null) {
|
||||
poolTx.sharesTransferAmount = poolTx.sharesTransferAmount.minus(value)
|
||||
poolTx.sharesBalance = poolShareFrom.balance
|
||||
}
|
||||
debuglog(
|
||||
'pool shares burn: (id, value, totalShares, shareFromBalance, fromAddress)',
|
||||
event,
|
||||
[
|
||||
poolId,
|
||||
value.toString(),
|
||||
pool.totalShares.toString(),
|
||||
poolShareFrom.balance.toString(),
|
||||
poolShareFrom.userAddress
|
||||
]
|
||||
)
|
||||
} else {
|
||||
if (poolShareTo == null) {
|
||||
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
|
||||
poolShareTo = PoolShare.load(poolShareToId)
|
||||
}
|
||||
poolShareTo.balance = poolShareTo.balance.plus(value)
|
||||
poolShareTo.save()
|
||||
|
||||
if (poolShareFrom == null) {
|
||||
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
|
||||
poolShareFrom = PoolShare.load(poolShareFromId)
|
||||
}
|
||||
poolShareFrom.balance = poolShareFrom.balance.minus(value)
|
||||
poolShareFrom.save()
|
||||
debuglog(
|
||||
'pool shares transfer: ' +
|
||||
'(id, value, totalShares, shareToBalance, shareFromBalance, toAddress, fromAddress)',
|
||||
event,
|
||||
[
|
||||
poolId,
|
||||
value.toString(),
|
||||
pool.totalShares.toString(),
|
||||
poolShareTo.balance.toString(),
|
||||
poolShareFrom.balance.toString(),
|
||||
poolShareTo.userAddress,
|
||||
poolShareFrom.userAddress
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
poolShareTo != null &&
|
||||
poolShareTo.balance.notEqual(ZERO_BD) &&
|
||||
poolShareToBalance.equals(ZERO_BD)
|
||||
) {
|
||||
pool.holderCount = pool.holderCount.plus(BigInt.fromI32(1))
|
||||
}
|
||||
|
||||
if (
|
||||
poolShareFrom != null &&
|
||||
poolShareFrom.balance.equals(ZERO_BD) &&
|
||||
poolShareFromBalance.notEqual(ZERO_BD)
|
||||
) {
|
||||
pool.holderCount = pool.holderCount.plus(BigInt.fromI32(1))
|
||||
}
|
||||
|
||||
if (poolTx != null) {
|
||||
poolTx.save()
|
||||
}
|
||||
|
||||
pool.save()
|
||||
}
|
||||
|
||||
/************************************
|
||||
*********** GULP ************
|
||||
************************************/
|
||||
export function handleGulp(event: LOG_CALL): void {
|
||||
const poolId = event.address.toHex()
|
||||
const ptx = event.transaction.hash.toHexString()
|
||||
// we need to check the contract balance & compare with our internal balances
|
||||
const pool = Pool.load(poolId)
|
||||
const poolEbtity = PoolEntity.bind(Address.fromString(poolId))
|
||||
if (!pool) {
|
||||
log.warning('Gulp called, but cannot load pool {}', [poolId])
|
||||
return
|
||||
}
|
||||
const ocnToken = PoolToken.load(poolId.concat('-').concat(OCEAN))
|
||||
const dtToken = PoolToken.load(
|
||||
poolId.concat('-').concat(pool.datatokenAddress)
|
||||
)
|
||||
const ocnTokenBalance = ocnToken.balance
|
||||
const dtTokenBalance = dtToken.balance
|
||||
// get the balances from the contract
|
||||
// for ocean
|
||||
if (ocnToken) {
|
||||
const balanceAttempt = poolEbtity.try_getBalance(Address.fromString(OCEAN))
|
||||
if (!balanceAttempt.reverted) {
|
||||
const contractBalance = bigIntToDecimal(balanceAttempt.value, 18)
|
||||
if (
|
||||
ocnToken.balance.notEqual(contractBalance) &&
|
||||
contractBalance.ge(ZERO_BD)
|
||||
) {
|
||||
// we have a difference. let's absorb that
|
||||
createPoolTransaction(event, 'gulp', event.params.caller.toHexString())
|
||||
ocnToken.balance = contractBalance
|
||||
ocnToken.save()
|
||||
updatePoolTransactionToken(
|
||||
ptx,
|
||||
ocnToken.id,
|
||||
contractBalance.minus(ocnTokenBalance),
|
||||
contractBalance,
|
||||
ZERO_BD
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
// for dt
|
||||
if (dtToken) {
|
||||
const balanceAttempt = poolEbtity.try_getBalance(
|
||||
Address.fromString(pool.datatokenAddress)
|
||||
)
|
||||
if (!balanceAttempt.reverted) {
|
||||
const contractBalance = bigIntToDecimal(balanceAttempt.value, 18)
|
||||
if (
|
||||
dtToken.balance.notEqual(contractBalance) &&
|
||||
contractBalance.ge(ZERO_BD)
|
||||
) {
|
||||
// we have a difference. let's absorb that
|
||||
createPoolTransaction(event, 'gulp', event.params.caller.toHexString())
|
||||
dtToken.balance = contractBalance
|
||||
dtToken.save()
|
||||
updatePoolTransactionToken(
|
||||
ptx,
|
||||
dtToken.id,
|
||||
contractBalance.minus(dtTokenBalance),
|
||||
contractBalance,
|
||||
ZERO_BD
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
|
||||
export const ENABLE_DEBUG = true
|
||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
|
||||
export const DAY = 24 * 60 * 60
|
||||
|
||||
export namespace integer {
|
||||
export const NEGATIVE_ONE = BigInt.fromI32(-1)
|
||||
export const ZERO = BigInt.fromI32(0)
|
||||
export const ONE = BigInt.fromI32(1)
|
||||
export const TWO = BigInt.fromI32(2)
|
||||
export const ONE_BASE_18 = BigInt.fromI32(10).pow(18 as u8)
|
||||
}
|
||||
|
||||
export namespace decimal {
|
||||
export const ZERO = BigDecimal.fromString('0.0')
|
||||
export const MINUS_1 = BigDecimal.fromString('-1.0')
|
||||
export const ONE = BigDecimal.fromString('1.0')
|
||||
export const BONE = BigDecimal.fromString('1000000000000000000')
|
||||
}
|
||||
|
||||
// string enums don't work in wasm so this was the alternative, not optimal
|
||||
|
||||
export namespace NftUpdateType {
|
||||
export const METADATA_CREATED = 'METADATA_CREATED'
|
||||
export const METADATA_UPDATED = 'METADATA_UPDATED'
|
||||
export const STATE_UPDATED = 'STATE_UPDATED'
|
||||
export const TOKENURI_UPDATED = 'TOKENURI_UPDATED'
|
||||
}
|
||||
|
||||
export namespace veAllocationUpdateType {
|
||||
export const SET = 'SET'
|
||||
export const REMOVED = 'REMOVED'
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import { Address, BigDecimal } from '@graphprotocol/graph-ts'
|
||||
import { DFAvailableClaim, DFReward } from '../../@types/schema'
|
||||
import { getUser } from './userUtils'
|
||||
|
||||
export function createDFReward(address: Address): DFReward {
|
||||
const dfRewards = new DFReward(address.toHexString())
|
||||
const user = getUser(address.toHexString())
|
||||
dfRewards.receiver = user.id
|
||||
dfRewards.save()
|
||||
return dfRewards
|
||||
}
|
||||
|
||||
export function getDFReward(address: Address): DFReward {
|
||||
let dfRewards = DFReward.load(address.toHexString())
|
||||
if (dfRewards === null) {
|
||||
dfRewards = createDFReward(address)
|
||||
}
|
||||
return dfRewards
|
||||
}
|
||||
|
||||
export function getDFAvailableClaim(
|
||||
user: Address,
|
||||
token: Address
|
||||
): DFAvailableClaim {
|
||||
const id = user.toHexString() + '-' + token.toHexString()
|
||||
let dfClaim = DFAvailableClaim.load(id)
|
||||
if (dfClaim == null) {
|
||||
dfClaim = new DFAvailableClaim(id)
|
||||
dfClaim.receiver = user.toHexString()
|
||||
dfClaim.amount = BigDecimal.zero()
|
||||
dfClaim.token = token.toHexString()
|
||||
}
|
||||
return dfClaim
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Dispenser } from '../../@types/schema'
|
||||
import { getToken } from './tokenUtils'
|
||||
import { Address } from '@graphprotocol/graph-ts'
|
||||
import { weiToDecimal } from './generic'
|
||||
import { Dispenser as DispenserContract } from '../../@types/templates/Dispenser/Dispenser'
|
||||
|
||||
export function getDispenserGraphID(
|
||||
contractAddress: Address,
|
||||
datatokenAddress: Address
|
||||
): string {
|
||||
return contractAddress.toHexString() + '-' + datatokenAddress.toHexString()
|
||||
}
|
||||
|
||||
export function createDispenser(dispenserID: string): Dispenser {
|
||||
const dispenser = new Dispenser(dispenserID)
|
||||
dispenser.save()
|
||||
return dispenser
|
||||
}
|
||||
|
||||
export function getDispenser(dispenserID: string): Dispenser {
|
||||
let dispenser = Dispenser.load(dispenserID)
|
||||
if (dispenser === null) {
|
||||
dispenser = createDispenser(dispenserID)
|
||||
}
|
||||
return dispenser
|
||||
}
|
||||
|
||||
export function updateDispenserDetails(
|
||||
contractAddress: Address,
|
||||
datatokenAddress: Address
|
||||
): void {
|
||||
const dispenserID = getDispenserGraphID(contractAddress, datatokenAddress)
|
||||
const dispenser = getDispenser(dispenserID)
|
||||
const contract = DispenserContract.bind(contractAddress)
|
||||
const dispenserDetails = contract.try_status(datatokenAddress)
|
||||
if (dispenserDetails == null) return
|
||||
const token = getToken(datatokenAddress, true)
|
||||
dispenser.balance = weiToDecimal(
|
||||
dispenserDetails.value.value5.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
dispenser.isMinter = dispenserDetails.value.value2
|
||||
dispenser.active = dispenserDetails.value.value0
|
||||
dispenser.save()
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import { FixedRateExchange } from '../../@types/schema'
|
||||
|
||||
import { FixedRateExchange as FixedRateExchangeContract } from '../../@types/templates/FixedRateExchange/FixedRateExchange'
|
||||
import { Address, Bytes } from '@graphprotocol/graph-ts'
|
||||
import { getToken } from './tokenUtils'
|
||||
import { weiToDecimal } from './generic'
|
||||
|
||||
export function getFixedRateGraphID(
|
||||
exchangeId: string,
|
||||
contractAddress: Address
|
||||
): string {
|
||||
return contractAddress.toHexString() + '-' + exchangeId
|
||||
}
|
||||
|
||||
export function getFixedRateExchange(fixedRateId: string): FixedRateExchange {
|
||||
let fixedRateExhange = FixedRateExchange.load(fixedRateId)
|
||||
if (fixedRateExhange === null) {
|
||||
fixedRateExhange = new FixedRateExchange(fixedRateId)
|
||||
// TODO: get data from contract and fill in new fixed rate exchange, this is just a worst case scenario. We shouldn't reach this code
|
||||
fixedRateExhange.save()
|
||||
}
|
||||
|
||||
return fixedRateExhange
|
||||
}
|
||||
|
||||
export function updateFixedRateExchangeSupply(
|
||||
exchangeId: Bytes,
|
||||
contractAddress: Address
|
||||
): void {
|
||||
const fixedRateID =
|
||||
contractAddress.toHexString() + '-' + exchangeId.toHexString()
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateID)
|
||||
const contract = FixedRateExchangeContract.bind(contractAddress)
|
||||
const fixedRateDetails = contract.try_getExchange(exchangeId)
|
||||
|
||||
if (fixedRateDetails == null || fixedRateDetails.reverted === true) return
|
||||
const baseToken = getToken(fixedRateDetails.value.value3, false)
|
||||
const datatoken = getToken(fixedRateDetails.value.value1, true)
|
||||
fixedRateExchange.datatokenBalance = weiToDecimal(
|
||||
fixedRateDetails.value.value9.toBigDecimal(),
|
||||
datatoken.decimals
|
||||
)
|
||||
fixedRateExchange.baseTokenBalance = weiToDecimal(
|
||||
fixedRateDetails.value.value10.toBigDecimal(),
|
||||
baseToken.decimals
|
||||
)
|
||||
fixedRateExchange.datatokenSupply = weiToDecimal(
|
||||
fixedRateDetails.value.value7.toBigDecimal(),
|
||||
datatoken.decimals
|
||||
)
|
||||
fixedRateExchange.baseTokenSupply = weiToDecimal(
|
||||
fixedRateDetails.value.value8.toBigDecimal(),
|
||||
baseToken.decimals
|
||||
)
|
||||
// update withMint state
|
||||
fixedRateExchange.withMint = fixedRateDetails.value.value11
|
||||
|
||||
// update active state
|
||||
fixedRateExchange.active = fixedRateDetails.value.value6
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
export function getUpdateOrSwapId(
|
||||
txAddress: string,
|
||||
exchangeId: string,
|
||||
eventIndex: number
|
||||
): string {
|
||||
return `${txAddress}-${exchangeId}-${eventIndex}`
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
import { BigDecimal, BigInt, dataSource } from '@graphprotocol/graph-ts'
|
||||
|
||||
const network = dataSource.network()
|
||||
|
||||
export function getOceanAddress(): string {
|
||||
// switch is not working for some reason
|
||||
if (network == 'ropsten') return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
|
||||
if (network == 'rinkeby') return '0x5e8DCB2AfA23844bcc311B00Ad1A0C30025aADE9'
|
||||
if (network == 'polygon') return '0x282d8efce846a88b159800bd4130ad77443fa1a1'
|
||||
if (network == 'moonbeamalpha')
|
||||
return '0xf6410bf5d773c7a41ebff972f38e7463fa242477'
|
||||
if (network == 'gaiaxtestnet')
|
||||
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
|
||||
if (network == 'catenaxtestnet')
|
||||
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
|
||||
if (network == 'mumbai') return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
|
||||
if (network == 'bsc') return '0xdce07662ca8ebc241316a15b611c89711414dd1a'
|
||||
if (network == 'celoalfajores')
|
||||
return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
|
||||
if (network == 'energyweb')
|
||||
return '0x593122aae80a6fc3183b2ac0c4ab3336debee528'
|
||||
if (network == 'moonriver')
|
||||
return '0x99c409e5f62e4bd2ac142f17cafb6810b8f0baae'
|
||||
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
|
||||
}
|
||||
|
||||
export function getOpfCollectorAddress(): string {
|
||||
// switch is not working for some reason
|
||||
if (network == 'ropsten') return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
|
||||
if (network == 'rinkeby') return '0x2f311Ba88e2609D3A100822EdAC798eb0a8F4835'
|
||||
if (network == 'polygon') return '0x282d8efce846a88b159800bd4130ad77443fa1a1'
|
||||
if (network == 'moonbeamalpha')
|
||||
return '0xf6410bf5d773c7a41ebff972f38e7463fa242477'
|
||||
if (network == 'gaiaxtestnet')
|
||||
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
|
||||
if (network == 'catenaxtestnet')
|
||||
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
|
||||
if (network == 'mumbai') return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
|
||||
if (network == 'bsc') return '0xdce07662ca8ebc241316a15b611c89711414dd1a'
|
||||
if (network == 'celoalfajores')
|
||||
return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
|
||||
if (network == 'energyweb')
|
||||
return '0x593122aae80a6fc3183b2ac0c4ab3336debee528'
|
||||
if (network == 'moonriver')
|
||||
return '0x99c409e5f62e4bd2ac142f17cafb6810b8f0baae'
|
||||
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
|
||||
}
|
||||
|
||||
export const OCEAN: string = getOceanAddress()
|
||||
|
||||
export function weiToDecimal(amount: BigDecimal, decimals: i32): BigDecimal {
|
||||
const scale = BigInt.fromI32(10)
|
||||
.pow(decimals as u8)
|
||||
.toBigDecimal()
|
||||
return amount.div(scale)
|
||||
}
|
||||
|
||||
export function gweiToEth(ammount: BigDecimal): BigDecimal {
|
||||
return ammount.div(BigDecimal.fromString('1000000000'))
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
GlobalStatistic,
|
||||
GlobalTotalFixedSwapPair,
|
||||
GlobalTotalLiquidityPair,
|
||||
OPC,
|
||||
Template
|
||||
} from '../../@types/schema'
|
||||
|
||||
const GLOBAL_ID = '1'
|
||||
|
||||
export function getGlobalStats(): GlobalStatistic {
|
||||
let globalStats = GlobalStatistic.load(GLOBAL_ID)
|
||||
if (!globalStats) {
|
||||
globalStats = new GlobalStatistic(GLOBAL_ID)
|
||||
globalStats.version = '4.0.2'
|
||||
globalStats.orderCount = 0
|
||||
globalStats.fixedCount = 0
|
||||
globalStats.datatokenCount = 0
|
||||
globalStats.dispenserCount = 0
|
||||
globalStats.nftCount = 0
|
||||
globalStats.totalOceanLocked = BigDecimal.zero()
|
||||
globalStats.save()
|
||||
}
|
||||
return globalStats
|
||||
}
|
||||
|
||||
export function getOPC(): OPC {
|
||||
let globalStats = OPC.load(GLOBAL_ID)
|
||||
if (!globalStats) {
|
||||
globalStats = new OPC(GLOBAL_ID)
|
||||
globalStats.save()
|
||||
}
|
||||
return globalStats
|
||||
}
|
||||
|
||||
export function getTotalOceanLocked(): BigDecimal {
|
||||
const globalStats = getGlobalStats()
|
||||
return globalStats.totalOceanLocked
|
||||
}
|
||||
|
||||
export function getTemplates(): Template {
|
||||
let templates = Template.load(GLOBAL_ID)
|
||||
if (!templates) {
|
||||
templates = new Template(GLOBAL_ID)
|
||||
templates.save()
|
||||
}
|
||||
return templates
|
||||
}
|
||||
|
||||
export function updateTotalOceanLocked(amount: BigDecimal): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.totalOceanLocked = amount
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addOrder(): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.orderCount = globalStats.orderCount + 1
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addDatatoken(): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.datatokenCount = globalStats.datatokenCount + 1
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addNft(): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.nftCount = globalStats.nftCount + 1
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addFixedRateExchange(): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.fixedCount = globalStats.fixedCount + 1
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addDispenser(): void {
|
||||
const globalStats = getGlobalStats()
|
||||
globalStats.dispenserCount = globalStats.dispenserCount + 1
|
||||
globalStats.save()
|
||||
}
|
||||
|
||||
export function addFixedSwap(tokenAddress: string, value: BigDecimal): void {
|
||||
let fixedSwapPair = GlobalTotalFixedSwapPair.load(tokenAddress)
|
||||
if (!fixedSwapPair) {
|
||||
fixedSwapPair = new GlobalTotalFixedSwapPair(tokenAddress)
|
||||
fixedSwapPair.globalStatistic = GLOBAL_ID
|
||||
fixedSwapPair.token = tokenAddress
|
||||
fixedSwapPair.value = BigDecimal.zero()
|
||||
fixedSwapPair.count = BigInt.zero()
|
||||
}
|
||||
fixedSwapPair.value = fixedSwapPair.value.plus(value)
|
||||
fixedSwapPair.count = fixedSwapPair.count.plus(BigInt.fromI32(1))
|
||||
fixedSwapPair.save()
|
||||
}
|
||||
|
||||
export function addLiquidity(tokenAddress: string, value: BigDecimal): void {
|
||||
let liquidityPair = GlobalTotalLiquidityPair.load(tokenAddress)
|
||||
if (!liquidityPair) {
|
||||
liquidityPair = new GlobalTotalLiquidityPair(tokenAddress)
|
||||
liquidityPair.globalStatistic = GLOBAL_ID
|
||||
liquidityPair.token = tokenAddress
|
||||
}
|
||||
liquidityPair.value = liquidityPair.value.plus(value)
|
||||
|
||||
liquidityPair.save()
|
||||
}
|
||||
|
||||
export function removeLiquidity(tokenAddress: string, value: BigDecimal): void {
|
||||
let liquidityPair = GlobalTotalLiquidityPair.load(tokenAddress)
|
||||
if (!liquidityPair) {
|
||||
liquidityPair = new GlobalTotalLiquidityPair(tokenAddress)
|
||||
liquidityPair.globalStatistic = GLOBAL_ID
|
||||
liquidityPair.token = tokenAddress
|
||||
}
|
||||
liquidityPair.value = liquidityPair.value.minus(value)
|
||||
|
||||
liquidityPair.save()
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import { Order, OrderReuse } from '../../@types/schema'
|
||||
|
||||
export function getOrderId(
|
||||
tx: string,
|
||||
tokenAddress: string,
|
||||
fromAddress: string,
|
||||
eventIndex: number
|
||||
): string {
|
||||
return `${tx}-${tokenAddress}-${fromAddress}-${eventIndex}`
|
||||
}
|
||||
|
||||
export function createOrder(orderId: string): Order {
|
||||
const order = new Order(orderId)
|
||||
return order
|
||||
}
|
||||
|
||||
export function getOrder(
|
||||
transactionHash: string,
|
||||
address: string,
|
||||
transactionFrom: string,
|
||||
eventIndex: number
|
||||
): Order {
|
||||
const orderId = getOrderId(
|
||||
transactionHash,
|
||||
address,
|
||||
transactionFrom,
|
||||
eventIndex
|
||||
)
|
||||
let newOrder = Order.load(orderId)
|
||||
if (newOrder === null) {
|
||||
newOrder = createOrder(orderId)
|
||||
}
|
||||
return newOrder
|
||||
}
|
||||
|
||||
export function searchOrderForEvent(
|
||||
transactionHash: string,
|
||||
address: string,
|
||||
transactionFrom: string,
|
||||
eventIndex: number
|
||||
): Order | null {
|
||||
for (let i = eventIndex; i >= 0; i--) {
|
||||
const orderId = getOrderId(transactionHash, address, transactionFrom, i)
|
||||
const order = Order.load(orderId)
|
||||
if (order && order.datatoken == address) {
|
||||
return order
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function searchOrderReusedForEvent(
|
||||
transactionHash: string,
|
||||
eventAddress: string,
|
||||
eventIndex: number
|
||||
): OrderReuse | null {
|
||||
for (let i = eventIndex; i >= 0; i--) {
|
||||
const orderReused = OrderReuse.load(`${transactionHash}-${i}`)
|
||||
if (!orderReused) {
|
||||
continue
|
||||
}
|
||||
const order = Order.load(orderReused.order)
|
||||
|
||||
if (order && order.datatoken == eventAddress) {
|
||||
return orderReused
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
import { Address, log, BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
Nft,
|
||||
Token,
|
||||
PredictContract,
|
||||
Erc721Template,
|
||||
Erc20Template
|
||||
} from '../../@types/schema'
|
||||
import { ERC20 } from '../../@types/templates/ERC20Template/ERC20'
|
||||
import { ERC721Template } from '../../@types/templates'
|
||||
import { addNft } from './globalUtils'
|
||||
import { ZERO_ADDRESS } from './constants'
|
||||
|
||||
export function createToken(address: Address, isDatatoken: boolean): Token {
|
||||
log.debug('started creating token with address: {}', [address.toHexString()])
|
||||
const token = new Token(address.toHexString())
|
||||
const contract = ERC20.bind(address)
|
||||
const name = contract.try_name()
|
||||
if (name.reverted) token.name = ''
|
||||
else token.name = name.value
|
||||
const symbol = contract.try_symbol()
|
||||
if (name.reverted) token.symbol = ''
|
||||
else token.symbol = symbol.value
|
||||
token.address = address.toHexString()
|
||||
token.isDatatoken = isDatatoken
|
||||
const decimals = contract.try_decimals()
|
||||
if (decimals.reverted) token.decimals = 18
|
||||
else token.decimals = decimals.value
|
||||
token.lastPriceToken = ZERO_ADDRESS
|
||||
token.lastPriceValue = BigDecimal.zero()
|
||||
token.orderCount = BigInt.zero()
|
||||
token.holderCount = BigInt.zero()
|
||||
token.createdTimestamp = 0
|
||||
token.block = 0
|
||||
token.tx = ''
|
||||
token.eventIndex = 0
|
||||
token.templateId = BigInt.zero()
|
||||
token.save()
|
||||
return token
|
||||
}
|
||||
|
||||
export function getToken(address: Address, isDatatoken: boolean): Token {
|
||||
let newToken = Token.load(address.toHexString())
|
||||
if (newToken === null) {
|
||||
newToken = createToken(address, isDatatoken)
|
||||
}
|
||||
return newToken
|
||||
}
|
||||
|
||||
export function createNftToken(address: Address): Nft {
|
||||
ERC721Template.create(address)
|
||||
const token = new Nft(address.toHexString())
|
||||
token.name = ''
|
||||
token.symbol = ''
|
||||
token.address = address.toHexString()
|
||||
token.providerUrl = ''
|
||||
token.tokenUri = ''
|
||||
token.owner = ''
|
||||
token.creator = ''
|
||||
token.assetState = 0
|
||||
token.template = ''
|
||||
token.transferable = true
|
||||
token.createdTimestamp = 0
|
||||
token.block = 0
|
||||
token.tx = ''
|
||||
token.orderCount = BigInt.zero()
|
||||
token.hasMetadata = false
|
||||
token.eventIndex = 0
|
||||
token.save()
|
||||
addNft()
|
||||
return token
|
||||
}
|
||||
|
||||
export function getNftToken(address: Address): Nft {
|
||||
let newToken = Nft.load(address.toHexString())
|
||||
if (newToken === null) {
|
||||
newToken = createNftToken(address)
|
||||
}
|
||||
return newToken
|
||||
}
|
||||
|
||||
export function getNftTokenWithID(tokenId: string): Nft {
|
||||
let nftToken = Nft.load(tokenId)
|
||||
if (nftToken === null) {
|
||||
nftToken = new Nft(tokenId)
|
||||
// const contract = ERC721Template.bind(address)
|
||||
nftToken.name = ''
|
||||
nftToken.symbol = ''
|
||||
nftToken.address = tokenId
|
||||
nftToken.providerUrl = ''
|
||||
nftToken.tokenUri = ''
|
||||
nftToken.owner = ''
|
||||
nftToken.creator = ''
|
||||
nftToken.assetState = 0
|
||||
nftToken.template = ''
|
||||
nftToken.transferable = true
|
||||
nftToken.createdTimestamp = 0
|
||||
nftToken.block = 0
|
||||
nftToken.tx = ''
|
||||
nftToken.orderCount = BigInt.zero()
|
||||
nftToken.hasMetadata = false
|
||||
nftToken.eventIndex = 0
|
||||
nftToken.save()
|
||||
addNft()
|
||||
}
|
||||
return nftToken
|
||||
}
|
||||
|
||||
export function getUSDValue(
|
||||
address: string,
|
||||
value: BigDecimal,
|
||||
timestamp: number
|
||||
): BigDecimal {
|
||||
return BigDecimal.zero()
|
||||
}
|
||||
|
||||
export function getErc721TemplateId(address: Address): BigInt {
|
||||
const template = Erc721Template.load(address.toHexString())
|
||||
if (template) {
|
||||
return template.templateId
|
||||
}
|
||||
return BigInt.zero()
|
||||
}
|
||||
|
||||
export function getErc20TemplateId(address: Address): BigInt {
|
||||
const template = Erc20Template.load(address.toHexString())
|
||||
if (template) {
|
||||
return template.templateId
|
||||
}
|
||||
return BigInt.zero()
|
||||
}
|
||||
|
||||
export function createPredictContract(address: Address): PredictContract {
|
||||
const predictContract = new PredictContract(address.toHexString())
|
||||
const token = getToken(address, true)
|
||||
predictContract.token = token.id
|
||||
predictContract.secondsPerEpoch = BigInt.zero()
|
||||
predictContract.secondsPerSubscription = BigInt.zero()
|
||||
predictContract.truevalSubmitTimeout = BigInt.zero()
|
||||
predictContract.stakeToken = null
|
||||
predictContract.txId = ''
|
||||
predictContract.timestamp = 0
|
||||
predictContract.block = 0
|
||||
predictContract.eventIndex = 0
|
||||
predictContract.paused = false
|
||||
predictContract.save()
|
||||
return predictContract
|
||||
}
|
||||
|
||||
export function getPredictContract(address: Address): PredictContract {
|
||||
let newPredictContract = PredictContract.load(address.toHexString())
|
||||
if (newPredictContract === null) {
|
||||
newPredictContract = createPredictContract(address)
|
||||
}
|
||||
return newPredictContract
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
import { User } from '../../@types/schema'
|
||||
|
||||
export function getUser(address: string): User {
|
||||
let user = User.load(address)
|
||||
if (user === null) {
|
||||
user = new User(address)
|
||||
user.totalOrders = BigInt.zero()
|
||||
user.totalSales = BigInt.zero()
|
||||
user.save()
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
import { BigDecimal, ethereum, BigInt, Address } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
VeAllocateUser,
|
||||
VeAllocateId,
|
||||
VeAllocation,
|
||||
VeAllocationUpdate,
|
||||
VeDelegation,
|
||||
VeOCEAN,
|
||||
VeDeposit,
|
||||
VeFeeDistributor
|
||||
} from '../../@types/schema'
|
||||
import { veFeeDistributor as VeFeeDistributorContract } from '../../@types/veFeeDistributor/veFeeDistributor'
|
||||
import { veAllocationUpdateType } from './constants'
|
||||
import { getToken } from './tokenUtils'
|
||||
|
||||
export function getveOCEAN(id: string): VeOCEAN {
|
||||
let ve = VeOCEAN.load(id)
|
||||
|
||||
if (ve === null) {
|
||||
ve = new VeOCEAN(id)
|
||||
ve.unlockTime = BigInt.zero()
|
||||
ve.lockedAmount = BigDecimal.zero()
|
||||
ve.block = 0
|
||||
ve.save()
|
||||
}
|
||||
|
||||
return ve
|
||||
}
|
||||
|
||||
export function getveAllocateUser(
|
||||
event: ethereum.Event,
|
||||
sender: string
|
||||
): VeAllocateUser {
|
||||
let allocateUser = VeAllocateUser.load(sender)
|
||||
if (allocateUser === null) {
|
||||
allocateUser = new VeAllocateUser(sender)
|
||||
allocateUser.allocatedTotal = BigDecimal.zero()
|
||||
|
||||
allocateUser.firstContact = event.block.timestamp.toI32()
|
||||
allocateUser.tx = event.transaction.hash.toHex()
|
||||
allocateUser.eventIndex = event.logIndex.toI32()
|
||||
allocateUser.block = event.block.number.toI32()
|
||||
allocateUser.lastContact = 0
|
||||
const veOcean = getveOCEAN(sender)
|
||||
allocateUser.veOcean = veOcean.id
|
||||
|
||||
allocateUser.save()
|
||||
}
|
||||
|
||||
return allocateUser
|
||||
}
|
||||
|
||||
export function getveAllocateId(
|
||||
event: ethereum.Event,
|
||||
id: string
|
||||
): VeAllocateId {
|
||||
let allocateId = VeAllocateId.load(id)
|
||||
if (allocateId === null) {
|
||||
allocateId = new VeAllocateId(id)
|
||||
allocateId.allocatedTotal = BigDecimal.zero()
|
||||
|
||||
allocateId.firstContact = event.block.timestamp.toI32()
|
||||
allocateId.tx = event.transaction.hash.toHex()
|
||||
allocateId.eventIndex = event.logIndex.toI32()
|
||||
allocateId.block = event.block.number.toI32()
|
||||
allocateId.lastContact = 0
|
||||
allocateId.chainId = BigInt.zero()
|
||||
allocateId.nftAddress = ''
|
||||
|
||||
allocateId.save()
|
||||
}
|
||||
|
||||
return allocateId
|
||||
}
|
||||
|
||||
export function getveAllocation(
|
||||
event: ethereum.Event,
|
||||
sender: string,
|
||||
id: string
|
||||
): VeAllocation {
|
||||
let veAllocation = VeAllocation.load(sender + '-' + id)
|
||||
if (veAllocation === null) {
|
||||
veAllocation = new VeAllocation(sender + '-' + id)
|
||||
veAllocation.allocationUser = getveAllocateUser(event, sender).id
|
||||
veAllocation.allocationId = getveAllocateId(event, id).id
|
||||
veAllocation.allocated = BigDecimal.zero()
|
||||
veAllocation.chainId = BigInt.zero()
|
||||
veAllocation.nftAddress = ''
|
||||
|
||||
veAllocation.firstContact = event.block.timestamp.toI32()
|
||||
veAllocation.tx = event.transaction.hash.toHex()
|
||||
veAllocation.eventIndex = event.logIndex.toI32()
|
||||
veAllocation.block = event.block.number.toI32()
|
||||
veAllocation.lastContact = 0
|
||||
|
||||
veAllocation.save()
|
||||
}
|
||||
|
||||
return veAllocation
|
||||
}
|
||||
|
||||
// Pass veAllocation being updated
|
||||
export function writeveAllocationUpdate(
|
||||
event: ethereum.Event,
|
||||
veAllocationId: string,
|
||||
allocationType: string,
|
||||
amount: BigDecimal
|
||||
): VeAllocationUpdate {
|
||||
const id = `${event.transaction.hash.toHex()}-${veAllocationId}-${event.logIndex.toString()}`
|
||||
let allocationUpdate = VeAllocationUpdate.load(id)
|
||||
if (allocationUpdate === null) {
|
||||
allocationUpdate = new VeAllocationUpdate(id)
|
||||
allocationUpdate.veAllocation = veAllocationId
|
||||
allocationUpdate.type = allocationType
|
||||
allocationUpdate.allocatedTotal = amount
|
||||
|
||||
allocationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
allocationUpdate.tx = event.transaction.hash.toHex()
|
||||
allocationUpdate.eventIndex = event.logIndex.toI32()
|
||||
allocationUpdate.block = event.block.number.toI32()
|
||||
|
||||
allocationUpdate.save()
|
||||
}
|
||||
|
||||
return allocationUpdate
|
||||
}
|
||||
|
||||
export function getveDelegation(
|
||||
contract: Address,
|
||||
eventid: string
|
||||
): VeDelegation {
|
||||
const id = contract.toHex() + '-' + eventid
|
||||
let veDelegation = VeDelegation.load(id)
|
||||
|
||||
if (veDelegation === null) {
|
||||
veDelegation = new VeDelegation(id)
|
||||
veDelegation.cancelTime = BigInt.zero()
|
||||
veDelegation.expireTime = BigInt.zero()
|
||||
veDelegation.tokenId = BigInt.zero()
|
||||
veDelegation.amount = BigDecimal.zero()
|
||||
veDelegation.receiver = ''
|
||||
veDelegation.delegator = ''
|
||||
veDelegation.lockedAmount = BigDecimal.zero()
|
||||
veDelegation.timeLeftUnlock = 0
|
||||
veDelegation.save()
|
||||
}
|
||||
return veDelegation
|
||||
}
|
||||
export function getDeposit(id: string): VeDeposit {
|
||||
let deposit = VeDeposit.load(id)
|
||||
if (deposit === null) {
|
||||
deposit = new VeDeposit(id)
|
||||
deposit.provider = ''
|
||||
deposit.sender = ''
|
||||
deposit.value = BigDecimal.zero()
|
||||
deposit.unlockTime = BigInt.zero()
|
||||
deposit.type = BigInt.zero()
|
||||
deposit.timestamp = BigInt.zero()
|
||||
deposit.tx = ''
|
||||
deposit.eventIndex = 0
|
||||
deposit.block = 0
|
||||
// do not save it
|
||||
// deposit.save()
|
||||
}
|
||||
return deposit
|
||||
}
|
||||
|
||||
export function handleOneAllocation(
|
||||
eventSender: string,
|
||||
nftAddress: string,
|
||||
chainId: BigInt,
|
||||
allocationAmount: BigDecimal,
|
||||
event: ethereum.Event
|
||||
): void {
|
||||
const eventId = nftAddress + '-' + chainId.toString()
|
||||
|
||||
const allocateUser = getveAllocateUser(event, eventSender)
|
||||
const allocateId = getveAllocateId(event, eventId)
|
||||
const veAllocation = getveAllocation(event, eventSender, eventId)
|
||||
|
||||
// Update user allocation
|
||||
const newUserAllocation = allocateUser.allocatedTotal.minus(
|
||||
veAllocation.allocated
|
||||
)
|
||||
allocateUser.allocatedTotal = newUserAllocation.plus(allocationAmount)
|
||||
|
||||
// Update id allocation
|
||||
const newIdAllocation = allocateId.allocatedTotal.minus(
|
||||
veAllocation.allocated
|
||||
)
|
||||
allocateId.allocatedTotal = newIdAllocation.plus(allocationAmount)
|
||||
|
||||
veAllocation.allocated = allocationAmount
|
||||
veAllocation.chainId = chainId
|
||||
veAllocation.nftAddress = nftAddress
|
||||
|
||||
allocateUser.lastContact = event.block.timestamp.toI32()
|
||||
allocateId.lastContact = event.block.timestamp.toI32()
|
||||
veAllocation.lastContact = event.block.timestamp.toI32()
|
||||
|
||||
// register allocation update event
|
||||
writeveAllocationUpdate(
|
||||
event,
|
||||
veAllocation.id,
|
||||
veAllocationUpdateType.SET,
|
||||
allocationAmount
|
||||
)
|
||||
|
||||
allocateId.chainId = chainId
|
||||
allocateId.nftAddress = nftAddress
|
||||
|
||||
// save entities
|
||||
allocateUser.save()
|
||||
allocateId.save()
|
||||
veAllocation.save()
|
||||
}
|
||||
|
||||
export function getVeFeeDistributor(id: Address): VeFeeDistributor {
|
||||
let distributor = VeFeeDistributor.load(id.toHexString())
|
||||
|
||||
if (distributor === null) {
|
||||
distributor = new VeFeeDistributor(id.toHexString())
|
||||
const contract = VeFeeDistributorContract.bind(id)
|
||||
const tokenAddress = contract.try_token()
|
||||
const token = getToken(tokenAddress.value, false)
|
||||
distributor.token = token.id
|
||||
distributor.save()
|
||||
}
|
||||
return distributor
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
import {
|
||||
AllocationSet,
|
||||
AllocationSetMultiple
|
||||
} from '../@types/veAllocate/veAllocate'
|
||||
|
||||
import { handleOneAllocation } from './utils/veUtils'
|
||||
|
||||
export function handleAllocationSet(event: AllocationSet): void {
|
||||
// get allocation entities
|
||||
const eventSender = event.params.sender.toHexString()
|
||||
const nftAddress = event.params.nft.toHexString()
|
||||
const chainId = event.params.chainId
|
||||
const allocationAmount = event.params.amount.toBigDecimal()
|
||||
|
||||
handleOneAllocation(eventSender, nftAddress, chainId, allocationAmount, event)
|
||||
}
|
||||
|
||||
export function handleAllocationSetMultiple(
|
||||
event: AllocationSetMultiple
|
||||
): void {
|
||||
// loop
|
||||
for (let i = 0; i < event.params.nft.length; i++) {
|
||||
const eventSender = event.params.sender.toHexString()
|
||||
const nftAddress = event.params.nft[i].toHexString()
|
||||
const chainId = event.params.chainId[i]
|
||||
const allocationAmount = event.params.amount[i].toBigDecimal()
|
||||
handleOneAllocation(
|
||||
eventSender,
|
||||
nftAddress,
|
||||
chainId,
|
||||
allocationAmount,
|
||||
event
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import { VeDelegationUpdate } from '../@types/schema'
|
||||
import {
|
||||
BurnBoost,
|
||||
DelegateBoost,
|
||||
ExtendBoost,
|
||||
TransferBoost
|
||||
} from '../@types/veDelegation/veDelegation'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
||||
|
||||
export function handleDelegation(event: DelegateBoost): void {
|
||||
const _delegator = event.params._delegator.toHex()
|
||||
const _receiver = event.params._receiver.toHex()
|
||||
const _tokenId = event.params._token_id
|
||||
const _amount = event.params._amount
|
||||
const _cancelTime = event.params._cancel_time
|
||||
const _expireTime = event.params._expire_time
|
||||
// create veOcean if does not exists
|
||||
getveOCEAN(_receiver)
|
||||
const delegator = getveOCEAN(_delegator)
|
||||
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||
const ts = event.block.timestamp.toI32()
|
||||
|
||||
veDelegation.delegator = _delegator
|
||||
veDelegation.receiver = _receiver
|
||||
veDelegation.tokenId = _tokenId
|
||||
veDelegation.amount = weiToDecimal(
|
||||
_amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
veDelegation.lockedAmount = delegator.lockedAmount
|
||||
veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
|
||||
veDelegation.cancelTime = _cancelTime
|
||||
veDelegation.expireTime = _expireTime
|
||||
veDelegation.save()
|
||||
|
||||
const veDelegationUpdate = new VeDelegationUpdate(
|
||||
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||
)
|
||||
veDelegationUpdate.type = 0
|
||||
veDelegationUpdate.veDelegation = veDelegation.id
|
||||
veDelegationUpdate.block = event.block.number.toI32()
|
||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||
veDelegationUpdate.amount = veDelegation.amount
|
||||
veDelegationUpdate.cancelTime = _cancelTime
|
||||
veDelegationUpdate.expireTime = _expireTime
|
||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||
veDelegationUpdate.save()
|
||||
}
|
||||
|
||||
export function handleExtendBoost(event: ExtendBoost): void {
|
||||
const _delegator = event.params._delegator.toHex()
|
||||
const _receiver = event.params._receiver.toHex()
|
||||
const _tokenId = event.params._token_id
|
||||
const _amount = event.params._amount
|
||||
const _cancelTime = event.params._cancel_time
|
||||
const _expireTime = event.params._expire_time
|
||||
// create veOcean if does not exists
|
||||
getveOCEAN(_receiver)
|
||||
getveOCEAN(_delegator)
|
||||
// it's possible to not have veDelegation object, because we missed handleDelegation
|
||||
// that should not happend, but we create the object anyway
|
||||
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||
veDelegation.delegator = _delegator
|
||||
veDelegation.receiver = _receiver
|
||||
veDelegation.tokenId = _tokenId
|
||||
veDelegation.amount = weiToDecimal(
|
||||
_amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
veDelegation.cancelTime = _cancelTime
|
||||
veDelegation.expireTime = _expireTime
|
||||
veDelegation.save()
|
||||
|
||||
const veDelegationUpdate = new VeDelegationUpdate(
|
||||
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||
)
|
||||
veDelegationUpdate.veDelegation = veDelegation.id
|
||||
veDelegationUpdate.type = 1
|
||||
veDelegationUpdate.block = event.block.number.toI32()
|
||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||
veDelegationUpdate.amount = veDelegation.amount
|
||||
veDelegationUpdate.cancelTime = _cancelTime
|
||||
veDelegationUpdate.expireTime = _expireTime
|
||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||
veDelegationUpdate.save()
|
||||
}
|
||||
|
||||
export function handleTransferBoost(event: TransferBoost): void {
|
||||
// TODO not sure if we need this
|
||||
// --------------------------------
|
||||
// const _from = event.params._from
|
||||
// const _to = event.params._to
|
||||
// const _tokenId = event.params._token_id
|
||||
// const _amount = event.params._amount
|
||||
// const _expireTime = event.params._expire_time
|
||||
}
|
||||
export function handleBurnBoost(event: BurnBoost): void {
|
||||
const _tokenId = event.params._token_id
|
||||
|
||||
// delete
|
||||
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||
veDelegation.amount = BigDecimal.zero()
|
||||
veDelegation.save()
|
||||
|
||||
const veDelegationUpdate = new VeDelegationUpdate(
|
||||
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||
)
|
||||
veDelegationUpdate.veDelegation = veDelegation.id
|
||||
veDelegationUpdate.type = 2
|
||||
veDelegationUpdate.block = event.block.number.toI32()
|
||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||
veDelegationUpdate.amount = veDelegation.amount
|
||||
veDelegationUpdate.cancelTime = veDelegation.cancelTime
|
||||
veDelegationUpdate.expireTime = veDelegation.expireTime
|
||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||
veDelegationUpdate.save()
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
import { Address } from '@graphprotocol/graph-ts'
|
||||
import {
|
||||
Claimed,
|
||||
CheckpointToken
|
||||
} from '../@types/veFeeDistributor/veFeeDistributor'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getveOCEAN, getVeFeeDistributor } from './utils/veUtils'
|
||||
import { VeClaim, VeFeeDistributorCheckPoint } from '../@types/schema'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
|
||||
export function handleClaimed(event: Claimed): void {
|
||||
const distributor = getVeFeeDistributor(event.address)
|
||||
const id =
|
||||
event.transaction.hash.toHexString() + '-' + event.logIndex.toString()
|
||||
const veOcean = getveOCEAN(event.params.recipient.toHexString())
|
||||
const token = getToken(Address.fromString(distributor.token), false)
|
||||
const claim = new VeClaim(id)
|
||||
claim.amount = weiToDecimal(
|
||||
event.params.amount.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
claim.claim_epoch = event.params.claim_epoch
|
||||
claim.max_epoch = event.params.max_epoch
|
||||
|
||||
claim.veOcean = veOcean.id
|
||||
claim.VeFeeDistributor = distributor.id
|
||||
|
||||
claim.block = event.block.number.toI32()
|
||||
claim.tx = event.transaction.hash.toHex()
|
||||
claim.eventIndex = event.logIndex.toI32()
|
||||
claim.timestamp = event.block.timestamp
|
||||
claim.save()
|
||||
}
|
||||
|
||||
export function handleCheckpoint(event: CheckpointToken): void {
|
||||
const distributor = getVeFeeDistributor(event.address)
|
||||
const id =
|
||||
event.transaction.hash.toHexString() + '-' + event.logIndex.toString()
|
||||
const token = getToken(Address.fromString(distributor.token), false)
|
||||
const checkpoint = new VeFeeDistributorCheckPoint(id)
|
||||
checkpoint.tokens = weiToDecimal(
|
||||
event.params.tokens.toBigDecimal(),
|
||||
token.decimals
|
||||
)
|
||||
checkpoint.sender = event.transaction.from.toHexString()
|
||||
checkpoint.block = event.block.number.toI32()
|
||||
checkpoint.tx = event.transaction.hash.toHex()
|
||||
checkpoint.eventIndex = event.logIndex.toI32()
|
||||
checkpoint.timestamp = event.params.time
|
||||
checkpoint.VeFeeDistributor = distributor.id
|
||||
checkpoint.save()
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import { Deposit, Supply, Withdraw } from '../@types/veOCEAN/veOCEAN'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getDeposit, getveOCEAN } from './utils/veUtils'
|
||||
import {
|
||||
getTotalOceanLocked,
|
||||
updateTotalOceanLocked
|
||||
} from './utils/globalUtils'
|
||||
|
||||
export function handleDeposit(event: Deposit): void {
|
||||
const provider = event.params.provider
|
||||
const value = event.params.value
|
||||
const locktime = event.params.locktime
|
||||
const type = event.params.type
|
||||
const ts = event.params.ts
|
||||
const totalOceanLocked = getTotalOceanLocked()
|
||||
const veOCEAN = getveOCEAN(provider.toHex())
|
||||
// Create new Deposit entity
|
||||
const deposit = getDeposit(
|
||||
provider.toHex() +
|
||||
'-' +
|
||||
event.transaction.hash.toHex() +
|
||||
'-' +
|
||||
event.logIndex.toString()
|
||||
)
|
||||
deposit.provider = provider.toHex()
|
||||
deposit.value = weiToDecimal(value.toBigDecimal(), 18)
|
||||
deposit.unlockTime = locktime
|
||||
deposit.type = type
|
||||
deposit.timestamp = ts
|
||||
deposit.block = event.block.number.toI32()
|
||||
deposit.tx = event.transaction.hash.toHex()
|
||||
deposit.sender = event.transaction.from.toHex()
|
||||
deposit.veOcean = veOCEAN.id
|
||||
|
||||
deposit.totalOceanLocked = totalOceanLocked.plus(deposit.value)
|
||||
updateTotalOceanLocked(deposit.totalOceanLocked)
|
||||
|
||||
deposit.save()
|
||||
// --------------------------------------------
|
||||
|
||||
const lockedAmount = weiToDecimal(value.toBigDecimal(), 18)
|
||||
veOCEAN.unlockTime = locktime
|
||||
veOCEAN.lockedAmount = veOCEAN.lockedAmount.plus(lockedAmount)
|
||||
veOCEAN.block = event.block.number.toI32()
|
||||
veOCEAN.save()
|
||||
}
|
||||
export function handleSupply(event: Supply): void {}
|
||||
export function handleWithdraw(event: Withdraw): void {
|
||||
const totalOceanLocked = getTotalOceanLocked()
|
||||
const provider = event.params.provider
|
||||
const value = event.params.value
|
||||
const ts = event.params.ts
|
||||
|
||||
const veOCEAN = getveOCEAN(provider.toHex())
|
||||
// Create new Deposit entity
|
||||
const deposit = getDeposit(
|
||||
provider.toHex() +
|
||||
'-' +
|
||||
event.transaction.hash.toHex() +
|
||||
'-' +
|
||||
event.logIndex.toString()
|
||||
)
|
||||
deposit.provider = provider.toHex()
|
||||
deposit.value = weiToDecimal(value.toBigDecimal(), 18).neg()
|
||||
deposit.unlockTime = BigInt.zero()
|
||||
deposit.type = BigInt.fromI32(4)
|
||||
deposit.timestamp = ts
|
||||
deposit.block = event.block.number.toI32()
|
||||
deposit.tx = event.transaction.hash.toHex()
|
||||
deposit.eventIndex = event.logIndex.toI32()
|
||||
deposit.sender = event.transaction.from.toHex()
|
||||
deposit.veOcean = veOCEAN.id
|
||||
deposit.totalOceanLocked = totalOceanLocked.plus(deposit.value) // it's already negated above
|
||||
updateTotalOceanLocked(deposit.totalOceanLocked)
|
||||
deposit.save()
|
||||
// --------------------------------------------
|
||||
|
||||
veOCEAN.lockedAmount = BigDecimal.zero()
|
||||
veOCEAN.unlockTime = BigInt.zero()
|
||||
veOCEAN.block = event.block.number.toI32()
|
||||
veOCEAN.save()
|
||||
}
|
|
@ -1,213 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: bsc
|
||||
source:
|
||||
address: '0xc313e19146Fc9a04470689C9d41a4D3054693531'
|
||||
abi: Factory
|
||||
startBlock: 8114772
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: bsc
|
||||
source:
|
||||
address: '0xE9397625Df9B63f0C152f975234b7988b54710B8'
|
||||
abi: DTFactory
|
||||
startBlock: 8114772
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: bsc
|
||||
source:
|
||||
address: '0x1d535147a97bd87c8443125376E6671B60556E07'
|
||||
abi: Metadata
|
||||
startBlock: 8114772
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: bsc
|
||||
source:
|
||||
address: '0x98679D582AB3398C03D3308dEB9c7AeC50B52ded'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 8114772
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: bsc
|
||||
source:
|
||||
address: '0xFe7967A5176fDAFa8DE109b3507016B885a82D6e'
|
||||
abi: Dispenser
|
||||
startBlock: 8114772
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: bsc
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: bsc
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,207 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
address: '0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0'
|
||||
abi: Factory
|
||||
startBlock: 177644
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
address: '0x2720d405ef7cDC8a2E2e5AeBC8883C99611d893C'
|
||||
abi: DTFactory
|
||||
startBlock: 177644
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
address: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a'
|
||||
abi: Metadata
|
||||
startBlock: 177644
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
address: '0x3c21a90599b5B7f37014cA5Bf30d3f1b73d7e391'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 177644
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
address: '0x4E6058dC00e90C0DCA47A5d0D3346F409939A5ab'
|
||||
abi: Dispenser
|
||||
startBlock: 177644
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: gaiaxtestnet
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,207 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
address: '0xEF62FB495266C72a5212A11Dce8baa79Ec0ABeB1'
|
||||
abi: Factory
|
||||
startBlock: 281776
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
address: '0x9C9eE07b8Ce907D2f9244F8317C1Ed29A3193bAe'
|
||||
abi: DTFactory
|
||||
startBlock: 281773
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
address: '0x3c21a90599b5B7f37014cA5Bf30d3f1b73d7e391'
|
||||
abi: Metadata
|
||||
startBlock: 281778
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
address: '0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 281777
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
address: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a'
|
||||
abi: Dispenser
|
||||
startBlock: 281779
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: moonbeamalpha
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,207 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: mumbai
|
||||
source:
|
||||
address: '0x159924ca0F47D6F704B97E29099b89e518A17B5E'
|
||||
abi: Factory
|
||||
startBlock: 14791845
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: mumbai
|
||||
source:
|
||||
address: '0x4E6058dC00e90C0DCA47A5d0D3346F409939A5ab'
|
||||
abi: DTFactory
|
||||
startBlock: 14791845
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: mumbai
|
||||
source:
|
||||
address: '0x98679D582AB3398C03D3308dEB9c7AeC50B52ded'
|
||||
abi: Metadata
|
||||
startBlock: 14791845
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: mumbai
|
||||
source:
|
||||
address: '0xc313e19146Fc9a04470689C9d41a4D3054693531'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 14791845
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: mumbai
|
||||
source:
|
||||
address: '0x1d535147a97bd87c8443125376E6671B60556E07'
|
||||
abi: Dispenser
|
||||
startBlock: 14791845
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: mumbai
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: mumbai
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,213 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: polygon
|
||||
source:
|
||||
address: '0x69B6E54Ad2b3c2801d11d8Ad56ea1d892555b776'
|
||||
abi: Factory
|
||||
startBlock: 11005239
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: polygon
|
||||
source:
|
||||
address: '0xF6410bf5d773C7a41ebFf972f38e7463FA242477'
|
||||
abi: DTFactory
|
||||
startBlock: 11005230
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: polygon
|
||||
source:
|
||||
address: '0x80E63f73cAc60c1662f27D2DFd2EA834acddBaa8'
|
||||
abi: Metadata
|
||||
startBlock: 11005247
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: polygon
|
||||
source:
|
||||
address: '0x2112Eb973af1DBf83a4f11eda82f7a7527D7Fde5'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 11005247
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: polygon
|
||||
source:
|
||||
address: '0x30E4CC2C7A9c6aA2b2Ce93586E3Df24a3A00bcDD'
|
||||
abi: Dispenser
|
||||
startBlock: 14275634
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: polygon
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: polygon
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,213 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: rinkeby
|
||||
source:
|
||||
address: '0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8'
|
||||
abi: Factory
|
||||
startBlock: 7298806
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: rinkeby
|
||||
source:
|
||||
address: '0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a'
|
||||
abi: DTFactory
|
||||
startBlock: 7298804
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: rinkeby
|
||||
source:
|
||||
address: '0xfd8a7b6297153397b7eb4356c47dbd381d58bff4'
|
||||
abi: Metadata
|
||||
startBlock: 7298808
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: rinkeby
|
||||
source:
|
||||
address: '0xeD1DfC5F3a589CfC4E8B91C1fbfC18FC6699Fbde'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 7298808
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: rinkeby
|
||||
source:
|
||||
address: '0x623744Cd25Ed553d3b4722667697F926cf99658B'
|
||||
abi: Dispenser
|
||||
startBlock: 8554110
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: rinkeby
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: rinkeby
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -1,213 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: ropsten
|
||||
source:
|
||||
address: '0x75be6e18c80A487C8b49663bf14f80A6495045B2'
|
||||
abi: Factory
|
||||
startBlock: 9227587
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: ropsten
|
||||
source:
|
||||
address: '0x6ebcCa6df2CAba986FCF44E64Ee82251c1455Dcc'
|
||||
abi: DTFactory
|
||||
startBlock: 9227578
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: ropsten
|
||||
source:
|
||||
address: '0x3cd7Ef1F207E1a46AAd7D5d7F5f0A5cF081Fc726'
|
||||
abi: Metadata
|
||||
startBlock: 9227595
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: ropsten
|
||||
source:
|
||||
address: '0xA7a711A09396DF82D9be46A26B48BafdB9BB4fA6'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 9227595
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: ropsten
|
||||
source:
|
||||
address: '0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0'
|
||||
abi: Dispenser
|
||||
startBlock: 10201082
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: ropsten
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: ropsten
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -0,0 +1,278 @@
|
|||
specVersion: 0.0.3
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
templates:
|
||||
- name: ERC20Template
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: ERC20Template
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/erc20Templates.ts
|
||||
entities:
|
||||
- ERC20Template
|
||||
abis:
|
||||
- name: ERC20Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
- name: ERC20TemplateEnterprise
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20Roles
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
eventHandlers:
|
||||
- event: OrderStarted(indexed address,address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
||||
receipt: true
|
||||
- event: OrderReused(bytes32,address,uint256,uint256)
|
||||
handler: handlerOrderReused
|
||||
receipt: true
|
||||
- event: NewPaymentCollector(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleNewPaymentCollector
|
||||
- event: PublishMarketFee(indexed address,indexed address,uint256)
|
||||
handler: handlePublishMarketFee
|
||||
- event: PublishMarketFeeChanged(address,address,address,uint256)
|
||||
handler: handlePublishMarketFeeChanged
|
||||
- event: ConsumeMarketFee(indexed address,indexed address,uint256)
|
||||
handler: handleConsumeMarketFee
|
||||
- event: AddedMinter(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedMinter
|
||||
- event: AddedPaymentManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedPaymentManager
|
||||
- event: RemovedMinter(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedMinter
|
||||
- event: RemovedPaymentManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedPaymentManager
|
||||
- event: CleanedPermissions(indexed address,uint256,uint256)
|
||||
handler: handleCleanedPermissions
|
||||
- event: ProviderFee(indexed address,indexed address,uint256,bytes,uint8,bytes32,bytes32,uint256)
|
||||
handler: handleProviderFee
|
||||
receipt: true
|
||||
|
||||
- name: ERC20Template3
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: ERC20Template3
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/erc20Template3.ts
|
||||
entities:
|
||||
- ERC20Template3
|
||||
abis:
|
||||
- name: ERC20Template3
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template3.sol/ERC20Template3.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20Roles
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
eventHandlers:
|
||||
- event: PredictionSubmitted(indexed address,indexed uint256,uint256)
|
||||
handler: handlePredictionSubmitted
|
||||
- event: PredictionPayout(indexed address,indexed uint256,uint256,uint256,bool,bool,uint256,uint8)
|
||||
handler: handlePredictionPayout
|
||||
- event: NewSubscription(indexed address,uint256,uint256)
|
||||
handler: handleNewSubscription
|
||||
- event: TruevalSubmitted(indexed uint256,bool,uint8,uint256,uint256)
|
||||
handler: handleTruevalSubmitted
|
||||
- event: SettingChanged(uint256,uint256,uint256,address)
|
||||
handler: handleSettingChanged
|
||||
- event: RevenueAdded(uint256,uint256,uint256,uint256,uint256)
|
||||
handler: handleRevenueAdded
|
||||
- event: Paused(bool)
|
||||
handler: handlePaused
|
||||
|
||||
- name: ERC721Template
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: ERC721Template
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/nftUpdate.ts
|
||||
entities:
|
||||
- ERC721Template
|
||||
abis:
|
||||
- name: ERC721Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
- name: ERC721RolesAddress
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,uint8,string,bytes,bytes,bytes32,uint256,uint256)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,uint8,string,bytes,bytes,bytes32,uint256,uint256)
|
||||
handler: handleMetadataUpdated
|
||||
- event: MetadataState(indexed address,uint8,uint256,uint256)
|
||||
handler: handleMetadataState
|
||||
- event: TokenURIUpdate(indexed address,string,uint256,uint256,uint256)
|
||||
handler: handleTokenUriUpdate
|
||||
- event: AddedManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedManager
|
||||
- event: AddedTo725StoreList(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedTo725StoreList
|
||||
- event: AddedToCreateERC20List(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedToCreateERC20List
|
||||
- event: AddedToMetadataList(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddedToMetadataList
|
||||
- event: RemovedFrom725StoreList(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedFrom725StoreList
|
||||
- event: RemovedFromCreateERC20List(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedFromCreateERC20List
|
||||
- event: RemovedFromMetadataList(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedFromMetadataList
|
||||
- event: RemovedManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemovedManager
|
||||
- event: CleanedPermissions(indexed address,uint256,uint256)
|
||||
handler: handleCleanedPermissions
|
||||
- event: Transfer(indexed address,indexed address,indexed uint256)
|
||||
handler: handleNftTransferred
|
||||
- event: DataChanged(indexed bytes32,bytes)
|
||||
handler: handleNftData
|
||||
|
||||
- name: Dispenser
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: Dispenser
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
eventHandlers:
|
||||
- event: DispenserCreated(indexed address,indexed address,uint256,uint256,address)
|
||||
handler: handleNewDispenser
|
||||
- event: DispenserActivated(indexed address)
|
||||
handler: handleActivate
|
||||
- event: DispenserDeactivated(indexed address)
|
||||
handler: handleDeactivate
|
||||
- event: DispenserAllowedSwapperChanged(indexed address,indexed address)
|
||||
handler: handleAllowedSwapperChanged
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleOwnerWinthdraw
|
||||
|
||||
- name: FixedRateExchange
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: FixedRateExchange
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedRateExchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleRateChange
|
||||
- event: ExchangeMintStateChanged(indexed bytes32,indexed address,bool)
|
||||
handler: handleMintStateChanged
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleDeactivated
|
||||
- event: ExchangeAllowedSwapperChanged(indexed bytes32,indexed address)
|
||||
handler: handleAllowedSwapperChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256,address,uint256,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: PublishMarketFeeChanged(indexed bytes32,address,address,uint256)
|
||||
handler: handlePublishMarketFeeChanged
|
||||
- event: TokenCollected(indexed bytes32,indexed address,indexed address,uint256)
|
||||
handler: handleTokenCollected
|
||||
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: ERC721Factory
|
||||
network: __NETWORK__
|
||||
source:
|
||||
address: __ERC721FACTORYADDRESS__
|
||||
abi: ERC721Factory
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/erc721Factory.ts
|
||||
entities:
|
||||
- ERC721Factory
|
||||
abis:
|
||||
- name: ERC721Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
- name: ERC20Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
- name: ERC721Factory
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
eventHandlers:
|
||||
- event: NFTCreated(address,indexed address,string,indexed address,string,string,bool,indexed address)
|
||||
handler: handleNftCreated
|
||||
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
|
||||
handler: handleNewToken
|
||||
- event: Template721Added(indexed address,indexed uint256)
|
||||
handler: handleNew721Template
|
||||
- event: Template20Added(indexed address,indexed uint256)
|
||||
handler: handleNew20Template
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: FactoryRouter
|
||||
network: __NETWORK__
|
||||
source:
|
||||
address: __FACTORYROUTERADDRESS__
|
||||
abi: FactoryRouter
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factoryRouter.ts
|
||||
entities:
|
||||
- FactoryRouter
|
||||
abis:
|
||||
- name: FactoryRouter
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
eventHandlers:
|
||||
- event: TokenAdded(indexed address,indexed address)
|
||||
handler: handleTokenAdded
|
||||
- event: TokenRemoved(indexed address,indexed address)
|
||||
handler: handleTokenRemoved
|
||||
- event: OPCFeeChanged(indexed address,uint256,uint256,uint256,uint256)
|
||||
handler: handleOPCFeeChanged
|
||||
- event: FixedRateContractAdded(indexed address,indexed address)
|
||||
handler: handleFixedRateContractAdded
|
||||
- event: FixedRateContractRemoved(indexed address,indexed address)
|
||||
handler: handleFixedRateContractRemoved
|
||||
- event: DispenserContractAdded(indexed address,indexed address)
|
||||
handler: handleDispenserContractAdded
|
||||
- event: DispenserContractRemoved(indexed address,indexed address)
|
||||
handler: handleDispenserContractRemoved
|
213
subgraph.yaml
213
subgraph.yaml
|
@ -1,213 +0,0 @@
|
|||
specVersion: 0.0.2
|
||||
description: Ocean provides data sharing through IDOs
|
||||
repository: https://github.com/oceanprotocol/ocean-subgraph
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: mainnet
|
||||
source:
|
||||
address: '0xbe0083053744ECb871510C88dC0f6b77Da162706'
|
||||
abi: Factory
|
||||
startBlock: 11105585
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factory.ts
|
||||
entities:
|
||||
- PoolFactory
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/BFactory.json
|
||||
eventHandlers:
|
||||
- event: BPoolRegistered(address,indexed address)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: DTFactory
|
||||
network: mainnet
|
||||
source:
|
||||
address: '0x57317f97E9EA49eBd19f7c9bB7c180b8cDcbDeB9'
|
||||
abi: DTFactory
|
||||
startBlock: 11105560
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dtfactory.ts
|
||||
entities:
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DTFactory
|
||||
file: ./abis/DTFactory.json
|
||||
eventHandlers:
|
||||
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
|
||||
handler: handleNewToken
|
||||
- kind: ethereum/contract
|
||||
name: Metadata
|
||||
network: mainnet
|
||||
source:
|
||||
address: '0x1a4b70d8c9DcA47cD6D0Fb3c52BB8634CA1C0Fdf'
|
||||
abi: Metadata
|
||||
startBlock: 11105610
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/metadata.ts
|
||||
entities:
|
||||
- Metadata
|
||||
abis:
|
||||
- name: Metadata
|
||||
file: ./abis/Metadata.json
|
||||
eventHandlers:
|
||||
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataCreated
|
||||
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
|
||||
handler: handleMetadataUpdated
|
||||
- kind: ethereum/contract
|
||||
name: FixedRateExchange
|
||||
network: mainnet
|
||||
source:
|
||||
address: '0x608d05214E42722B94a54cF6114d4840FCfF84e1'
|
||||
abi: FixedRateExchange
|
||||
startBlock: 11105610
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/fixedrateexchange.ts
|
||||
entities:
|
||||
- FixedRateExchange
|
||||
abis:
|
||||
- name: FixedRateExchange
|
||||
file: ./abis/FixedRateExchange.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
|
||||
handler: handleExchangeCreated
|
||||
- event: ExchangeActivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeActivated
|
||||
- event: ExchangeDeactivated(indexed bytes32,indexed address)
|
||||
handler: handleExchangeDeactivated
|
||||
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
|
||||
handler: handleExchangeRateChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
|
||||
handler: handleSwapped
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: mainnet
|
||||
source:
|
||||
address: '0xDEfD0018969cd2d4E648209F876ADe184815f038'
|
||||
abi: Dispenser
|
||||
startBlock: 12398958
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dispenser.ts
|
||||
entities:
|
||||
- Dispenser
|
||||
abis:
|
||||
- name: Dispenser
|
||||
file: ./abis/Dispenser.json
|
||||
eventHandlers:
|
||||
- event: Activated(indexed address)
|
||||
handler: handleDispenserActivated
|
||||
- event: Deactivated(indexed address)
|
||||
handler: handleDispenserDeactivated
|
||||
- event: AcceptedMinter(indexed address)
|
||||
handler: handleDispenserAcceptedMinter
|
||||
- event: RemovedMinter(indexed address)
|
||||
handler: handleDispenserRemovedMinter
|
||||
- event: TokensDispensed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserTokensDispensed
|
||||
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
|
||||
handler: handleDispenserOwnerWithdrawed
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: mainnet
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- Pool
|
||||
- PoolFactory
|
||||
- Swap
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/BPool.json
|
||||
- name: BToken
|
||||
file: ./abis/BToken.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20SymbolBytes
|
||||
file: ./abis/ERC20SymbolBytes.json
|
||||
- name: ERC20NameBytes
|
||||
file: ./abis/ERC20NameBytes.json
|
||||
eventHandlers:
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetSwapFee
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetController
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetPublicSwap
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleFinalize
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleSetup
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleRebind
|
||||
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
|
||||
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
|
||||
handler: handleGulp
|
||||
- event: LOG_JOIN(indexed address,indexed address,uint256)
|
||||
handler: handleJoinPool
|
||||
- event: LOG_EXIT(indexed address,indexed address,uint256)
|
||||
handler: handleExitPool
|
||||
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: DataToken
|
||||
network: mainnet
|
||||
source:
|
||||
abi: DataToken
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.4
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/datatoken.ts
|
||||
entities:
|
||||
- DataToken
|
||||
- DatatokenFactory
|
||||
abis:
|
||||
- name: DataToken
|
||||
file: ./abis/DataTokenTemplate.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed address,indexed address,uint256)
|
||||
handler: handleTransfer
|
||||
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
|
||||
handler: handleOrderStarted
|
|
@ -0,0 +1,118 @@
|
|||
- name: veAllocate
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: veAllocate
|
||||
address: __VEALLOCATEADDRESS__
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/veAllocate.ts
|
||||
entities:
|
||||
- veAllocate
|
||||
abis:
|
||||
- name: veAllocate
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
eventHandlers:
|
||||
- event: AllocationSet(indexed address,indexed address,indexed uint256,uint256)
|
||||
handler: handleAllocationSet
|
||||
- event: AllocationSetMultiple(indexed address,address[],uint256[],uint256[])
|
||||
handler: handleAllocationSetMultiple
|
||||
|
||||
- name: veOCEAN
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: veOCEAN
|
||||
address: __VEOCEANADDRESS__
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/veOCEAN.ts
|
||||
entities:
|
||||
- veOCEAN
|
||||
abis:
|
||||
- name: veOCEAN
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
eventHandlers:
|
||||
- event: Deposit(indexed address,uint256,indexed uint256,int128,uint256)
|
||||
handler: handleDeposit
|
||||
- event: Withdraw(indexed address,uint256,uint256)
|
||||
handler: handleWithdraw
|
||||
- event: Supply(uint256,uint256)
|
||||
handler: handleSupply
|
||||
|
||||
- name: veDelegation
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: veDelegation
|
||||
address: __VEDELEGATIONADDRESS__
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/veDelegation.ts
|
||||
entities:
|
||||
- veDelegation
|
||||
abis:
|
||||
- name: veDelegation
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
eventHandlers:
|
||||
- event: DelegateBoost(indexed address,indexed address,indexed uint256,uint256,uint256,uint256)
|
||||
handler: handleDelegation
|
||||
- event: ExtendBoost(indexed address,indexed address,indexed uint256,uint256,uint256,uint256)
|
||||
handler: handleExtendBoost
|
||||
- event: BurnBoost(indexed address,indexed address,indexed uint256)
|
||||
handler: handleBurnBoost
|
||||
|
||||
- name: veFeeDistributor
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: veFeeDistributor
|
||||
address: __VEFEEDISTRIBUTORNADDRESS__
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/veFeeDistributor.ts
|
||||
entities:
|
||||
- veFeeDistributor
|
||||
abis:
|
||||
- name: veFeeDistributor
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
eventHandlers:
|
||||
- event: Claimed(indexed address,uint256,uint256,uint256)
|
||||
handler: handleClaimed
|
||||
- event: CheckpointToken(uint256,uint256)
|
||||
handler: handleCheckpoint
|
||||
|
||||
- name: DFRewards
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: DFRewards
|
||||
address: __DFREWARDSADDRESS__
|
||||
startBlock: __STARTBLOCK__
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/dfRewards.ts
|
||||
entities:
|
||||
- DFRewards
|
||||
abis:
|
||||
- name: DFRewards
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
eventHandlers:
|
||||
- event: Allocated(address[],uint256[],address)
|
||||
handler: handleAllocated
|
||||
- event: Claimed(address,uint256,address)
|
||||
handler: handleClaimed
|
|
@ -0,0 +1,243 @@
|
|||
import { NftFactory, sleep, Datatoken, DfRewards } from '@oceanprotocol/lib'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
// const aquarius = new Aquarius('http://127.0.0.1:5000')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
describe('DFRewards tests', async () => {
|
||||
const nftName = 'testNFT'
|
||||
const nftSymbol = 'TST'
|
||||
const marketPlaceFeeAddress = '0x1230000000000000000000000000000000000000'
|
||||
const feeToken = '0x3210000000000000000000000000000000000000'
|
||||
const publishMarketFeeAmount = '0.1'
|
||||
const cap = '10000'
|
||||
const templateIndex = 1
|
||||
let datatokenAddress1: string
|
||||
let datatokenAddress2: string
|
||||
let dataToken: Datatoken
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let publisher: string
|
||||
let dfRewards: DfRewards
|
||||
let user1: string
|
||||
let user2: string
|
||||
|
||||
before(async () => {
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
dataToken = new Datatoken(web3)
|
||||
dfRewards = new DfRewards(addresses.DFRewards, web3)
|
||||
publisher = accounts[0].toLowerCase()
|
||||
user1 = accounts[1].toLowerCase()
|
||||
user2 = accounts[2].toLowerCase()
|
||||
})
|
||||
|
||||
it('should publish two datatokens', async () => {
|
||||
let result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
{
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
},
|
||||
{
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount: publishMarketFeeAmount,
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken,
|
||||
minter: publisher,
|
||||
mpFeeAddress: marketPlaceFeeAddress,
|
||||
name: 'DT1',
|
||||
symbol: 'DT1'
|
||||
}
|
||||
)
|
||||
datatokenAddress1 = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
|
||||
result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
{
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
},
|
||||
{
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount: publishMarketFeeAmount,
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken,
|
||||
minter: publisher,
|
||||
mpFeeAddress: marketPlaceFeeAddress,
|
||||
name: 'DT2',
|
||||
symbol: 'DT2'
|
||||
}
|
||||
)
|
||||
datatokenAddress2 = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
})
|
||||
|
||||
it('should top-up DF Rewards', async () => {
|
||||
// mint tokens
|
||||
await dataToken.mint(datatokenAddress1, publisher, '1000')
|
||||
await dataToken.mint(datatokenAddress2, publisher, '1000')
|
||||
// approve
|
||||
await dataToken.approve(
|
||||
datatokenAddress1,
|
||||
addresses.DFRewards,
|
||||
'1000',
|
||||
publisher
|
||||
)
|
||||
await dataToken.approve(
|
||||
datatokenAddress2,
|
||||
addresses.DFRewards,
|
||||
'1000',
|
||||
publisher
|
||||
)
|
||||
|
||||
// top-up DF Rewards
|
||||
const tx = await dfRewards.allocateRewards(
|
||||
publisher,
|
||||
[user1, user2],
|
||||
['100', '200'],
|
||||
datatokenAddress1
|
||||
)
|
||||
const user1Balance = await dfRewards.getAvailableRewards(
|
||||
user1,
|
||||
datatokenAddress1
|
||||
)
|
||||
// check subgraph
|
||||
await sleep(2000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
dfrewards(where: {id:"${user1.toLowerCase()}"}){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
availableClaims(where: {token:"${datatokenAddress1.toLowerCase()}"}){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
amount
|
||||
token {
|
||||
id
|
||||
}
|
||||
}
|
||||
history(orderBy:timestamp,orderDirection:desc){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
amount
|
||||
token {
|
||||
id
|
||||
}
|
||||
type
|
||||
tx
|
||||
eventIndex
|
||||
}
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.dfrewards
|
||||
assert(info[0].receiver.id === user1.toLowerCase())
|
||||
assert(String(info[0].availableClaims[0].amount) === user1Balance)
|
||||
assert(
|
||||
info[0].availableClaims[0].token.id === datatokenAddress1.toLowerCase()
|
||||
)
|
||||
assert(info[0].history[0].amount === '100')
|
||||
assert(info[0].history[0].tx === tx.transactionHash.toLowerCase())
|
||||
assert(info[0].history[0].eventIndex === tx.events.Allocated.logIndex)
|
||||
assert(info[0].history[0].type === 'Allocated')
|
||||
})
|
||||
|
||||
it('user2 claims some rewards', async () => {
|
||||
const expectedReward = await dfRewards.getAvailableRewards(
|
||||
user2,
|
||||
datatokenAddress1
|
||||
)
|
||||
const tx = await dfRewards.claimRewards(user2, user2, datatokenAddress1)
|
||||
|
||||
const user2Balance = await dfRewards.getAvailableRewards(
|
||||
user2,
|
||||
datatokenAddress1
|
||||
)
|
||||
// check subgraph
|
||||
await sleep(2000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
dfrewards(where: {id:"${user2.toLowerCase()}"}){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
availableClaims(where: {token:"${datatokenAddress1.toLowerCase()}"}){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
amount
|
||||
token {
|
||||
id
|
||||
}
|
||||
}
|
||||
history(orderBy:timestamp,orderDirection:desc){
|
||||
id
|
||||
receiver {
|
||||
id
|
||||
}
|
||||
amount
|
||||
token {
|
||||
id
|
||||
}
|
||||
type
|
||||
tx
|
||||
eventIndex
|
||||
}
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.dfrewards
|
||||
assert(info[0].receiver.id === user2.toLowerCase())
|
||||
assert(String(info[0].availableClaims[0].amount) === user2Balance)
|
||||
assert(
|
||||
info[0].availableClaims[0].token.id === datatokenAddress1.toLowerCase()
|
||||
)
|
||||
assert(info[0].history[0].amount === expectedReward)
|
||||
assert(info[0].history[0].type === 'Claimed')
|
||||
assert(info[0].history[0].eventIndex === tx.events.Claimed.logIndex)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,557 @@
|
|||
import 'mocha'
|
||||
import {
|
||||
DatatokenCreateParams,
|
||||
ProviderInstance,
|
||||
Nft,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
getHash,
|
||||
sleep,
|
||||
Datatoken,
|
||||
ProviderFees,
|
||||
ZERO_ADDRESS,
|
||||
signHash
|
||||
} from '@oceanprotocol/lib'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
// const aquarius = new Aquarius('http://127.0.0.1:5000')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const providerUrl = 'http://172.15.0.4:8030'
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
const assetUrl = [
|
||||
{
|
||||
type: 'url',
|
||||
url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt',
|
||||
method: 'GET'
|
||||
}
|
||||
]
|
||||
const ddo = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||
version: '4.0.0',
|
||||
chainId: 4,
|
||||
nftAddress: '0x0',
|
||||
metadata: {
|
||||
created: '2021-12-20T14:35:20Z',
|
||||
updated: '2021-12-20T14:35:20Z',
|
||||
type: 'dataset',
|
||||
name: 'dfgdfgdg',
|
||||
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||
tags: [''],
|
||||
author: 'dd',
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
additionalInformation: {
|
||||
termsAndConditions: true
|
||||
}
|
||||
},
|
||||
services: [
|
||||
{
|
||||
id: 'notAnId',
|
||||
type: 'access',
|
||||
files: '',
|
||||
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||
timeout: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
describe('Datatoken tests', async () => {
|
||||
const nftName = 'testNFT'
|
||||
const nftSymbol = 'TST'
|
||||
const marketPlaceFeeAddress = '0x1230000000000000000000000000000000000000'
|
||||
const feeToken = '0x3210000000000000000000000000000000000000'
|
||||
const publishMarketFeeAmount = '0.1'
|
||||
const cap = '10000'
|
||||
const templateIndex = 1
|
||||
let datatokenAddress: string
|
||||
let nft: Nft
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let publisher: string
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
let erc721Address: string
|
||||
let time: number
|
||||
let blockNumber: number
|
||||
|
||||
before(async () => {
|
||||
nft = new Nft(web3)
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisher = accounts[0].toLowerCase()
|
||||
user1 = accounts[1].toLowerCase()
|
||||
user2 = accounts[2].toLowerCase()
|
||||
user3 = accounts[3].toLowerCase()
|
||||
})
|
||||
|
||||
it('should publish an NFT & datatoken', async () => {
|
||||
const date = new Date()
|
||||
time = Math.floor(date.getTime() / 1000)
|
||||
blockNumber = await web3.eth.getBlockNumber()
|
||||
|
||||
const nftParams: NftCreateData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount: publishMarketFeeAmount,
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken,
|
||||
minter: publisher,
|
||||
mpFeeAddress: marketPlaceFeeAddress
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
erc721Address = result.events.NFTCreated.returnValues[0].toLowerCase()
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
|
||||
// Check values before updating metadata
|
||||
await sleep(3000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
token(id: "${datatokenAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
decimals,
|
||||
address,
|
||||
cap,
|
||||
supply,
|
||||
isDatatoken,
|
||||
nft {id},
|
||||
minter,
|
||||
paymentManager,
|
||||
paymentCollector,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeAmount,
|
||||
templateId,
|
||||
holderCount,
|
||||
orderCount,
|
||||
orders {id},
|
||||
fixedRateExchanges {id},
|
||||
dispensers {id},
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
lastPriceValue
|
||||
}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
await sleep(2000)
|
||||
const dt = (await initialResponse.json()).data.token
|
||||
|
||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
||||
assert(dt.id === datatokenAddress, 'incorrect value for: id')
|
||||
assert(dt.symbol, 'incorrect value for: symbol')
|
||||
assert(dt.name, 'incorrect value for: name')
|
||||
assert(dt.decimals === 18, 'incorrect value for: decimals')
|
||||
assert(dt.address === datatokenAddress, 'incorrect value for: address')
|
||||
assert(dt.cap === cap, 'incorrect value for: cap')
|
||||
assert(dt.supply === '0', 'incorrect value for: supply')
|
||||
assert(dt.isDatatoken === true, 'incorrect value for: isDatatoken')
|
||||
assert(dt.nft.id === erc721Address, 'incorrect value for: nft.id')
|
||||
assert(dt.minter[0] === publisher, 'incorrect value for: minter')
|
||||
assert(dt.paymentManager === null, 'incorrect value for: paymentManager')
|
||||
assert(
|
||||
dt.paymentCollector === null,
|
||||
'incorrect value for: paymentCollector'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAddress === marketPlaceFeeAddress,
|
||||
'incorrect value for: publishMarketFeeAddress'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
assert(dt.fixedRateExchanges, 'incorrect value for: fixedRateExchanges')
|
||||
assert(dt.dispensers, 'incorrect value for: dispensers')
|
||||
assert(dt.createdTimestamp >= time, 'incorrect value for: createdTimestamp')
|
||||
assert(
|
||||
dt.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(tx.from === publisher, 'incorrect value for: tx')
|
||||
assert(tx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||
assert(
|
||||
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Correct Datatoken fields after updating metadata', async () => {
|
||||
// create the files encrypted string
|
||||
const chain = await web3.eth.getChainId()
|
||||
let providerResponse = await ProviderInstance.encrypt(
|
||||
assetUrl,
|
||||
chain,
|
||||
providerUrl
|
||||
)
|
||||
ddo.services[0].files = await providerResponse
|
||||
ddo.services[0].datatokenAddress = datatokenAddress
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = erc721Address
|
||||
ddo.id =
|
||||
'did:op:' +
|
||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
publisher,
|
||||
0,
|
||||
providerUrl,
|
||||
'',
|
||||
'0x2',
|
||||
encryptedResponse,
|
||||
'0x' + metadataHash
|
||||
)
|
||||
|
||||
// Check values before updating metadata
|
||||
await sleep(3000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
token(id: "${datatokenAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
decimals,
|
||||
address,
|
||||
cap,
|
||||
supply,
|
||||
isDatatoken,
|
||||
nft {id},
|
||||
minter,
|
||||
paymentManager,
|
||||
paymentCollector,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeAmount,
|
||||
templateId,
|
||||
holderCount,
|
||||
orderCount,
|
||||
orders {id},
|
||||
fixedRateExchanges {id},
|
||||
dispensers {id},
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
lastPriceValue
|
||||
}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
await sleep(3000)
|
||||
const dt = (await initialResponse.json()).data.token
|
||||
|
||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
||||
assert(dt.id === datatokenAddress, 'incorrect value for: id')
|
||||
assert(dt.symbol, 'incorrect value for: symbol')
|
||||
assert(dt.name, 'incorrect value for: name')
|
||||
assert(dt.decimals === 18, 'incorrect value for: decimals')
|
||||
assert(dt.address === datatokenAddress, 'incorrect value for: address')
|
||||
assert(dt.cap === cap, 'incorrect value for: cap')
|
||||
assert(dt.supply === '0', 'incorrect value for: supply')
|
||||
assert(dt.isDatatoken === true, 'incorrect value for: isDatatoken')
|
||||
assert(dt.nft.id === erc721Address, 'incorrect value for: nft.id')
|
||||
assert(dt.minter[0] === publisher, 'incorrect value for: minter')
|
||||
assert(dt.paymentManager === null, 'incorrect value for: paymentManager')
|
||||
assert(
|
||||
dt.paymentCollector === null,
|
||||
'incorrect value for: paymentCollector'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAddress === marketPlaceFeeAddress,
|
||||
'incorrect value for: publishMarketFeeAddress'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
assert(dt.fixedRateExchanges, 'incorrect value for: fixedRateExchanges')
|
||||
assert(dt.dispensers, 'incorrect value for: dispensers')
|
||||
assert(dt.createdTimestamp >= time, 'incorrect value for: createdTimestamp')
|
||||
assert(
|
||||
dt.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(tx.from === publisher, 'incorrect value for: tx')
|
||||
assert(tx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||
assert(
|
||||
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Check datatoken orders are updated correctly after publishing & ordering a datatoken with fees', async () => {
|
||||
// Publish a datatoken for publishingMarketFeeToken
|
||||
const nftParams1: NftCreateData = {
|
||||
name: 'newNFT1',
|
||||
symbol: 'newTST1',
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params1: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisher,
|
||||
mpFeeAddress: ZERO_ADDRESS
|
||||
}
|
||||
const result1 = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams1,
|
||||
erc20Params1
|
||||
)
|
||||
await sleep(3000)
|
||||
const publishingTokenAddress = result1.events.TokenCreated.returnValues[0]
|
||||
const publishingDatatoken = new Datatoken(web3, 8996)
|
||||
|
||||
// Start with publishing the datatoken used for startOrder
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'newNFT',
|
||||
symbol: 'newTST',
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap: '100000',
|
||||
feeAmount: '0.2',
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: publishingTokenAddress,
|
||||
minter: publisher,
|
||||
mpFeeAddress: publisher
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
await sleep(3000)
|
||||
const newDtAddress = result.events.TokenCreated.returnValues[0]
|
||||
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
|
||||
await datatoken.approve(
|
||||
newDtAddress,
|
||||
publishingTokenAddress,
|
||||
'100000000000000000000000000',
|
||||
user1
|
||||
)
|
||||
await publishingDatatoken.approve(
|
||||
publishingTokenAddress,
|
||||
newDtAddress,
|
||||
'100000000000000000000000000',
|
||||
user1
|
||||
)
|
||||
await datatoken.mint(newDtAddress, publisher, '100', user1)
|
||||
await publishingDatatoken.mint(
|
||||
publishingTokenAddress,
|
||||
publisher,
|
||||
'100',
|
||||
user1
|
||||
)
|
||||
const user1balance = await datatoken.balance(newDtAddress, user1)
|
||||
const user2balance = await datatoken.balance(newDtAddress, user2)
|
||||
assert(Number(user1balance) === 100, 'Invalid user1 balance')
|
||||
assert(Number(user2balance) === 0, 'Invalid user2 balance')
|
||||
|
||||
const user1balanceOfPublishing = await datatoken.balance(
|
||||
publishingTokenAddress,
|
||||
user1
|
||||
)
|
||||
const user2balanceOfPublishing = await datatoken.balance(
|
||||
publishingTokenAddress,
|
||||
user2
|
||||
)
|
||||
assert(Number(user1balanceOfPublishing) === 100, 'Invalid user1 balance')
|
||||
assert(Number(user2balanceOfPublishing) === 0, 'Invalid user2 balance')
|
||||
|
||||
const query = {
|
||||
query: `query {token(id: "${newDtAddress.toLowerCase()}"){id,orderCount,orders {id, nftOwner{id}, lastPriceToken{id}, eventIndex}, eventIndex}}`
|
||||
}
|
||||
|
||||
await sleep(3000)
|
||||
let response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
const initialToken = (await response.json()).data.token
|
||||
|
||||
assert(initialToken, 'Invalid initialToken')
|
||||
assert(initialToken.orderCount === '0', 'Invalid initial orderCount')
|
||||
assert(initialToken.orders.length === 0, 'Invalid initial orders')
|
||||
assert(
|
||||
initialToken.eventIndex !== null && initialToken.eventIndex > 0,
|
||||
'Invalid eventIndex'
|
||||
)
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
const providerFeeAmount = '10000'
|
||||
const providerValidUntil = '0'
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
{ t: 'address', v: providerFeeToken },
|
||||
{ t: 'uint256', v: providerFeeAmount },
|
||||
{ t: 'uint256', v: providerValidUntil }
|
||||
)
|
||||
assert(message, 'Invalid message')
|
||||
const { v, r, s } = await signHash(web3, message, user3)
|
||||
const setProviderFee: ProviderFees = {
|
||||
providerFeeAddress: user3,
|
||||
providerFeeToken,
|
||||
providerFeeAmount,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
const consumeMarketFees = {
|
||||
consumeMarketFeeAddress: publisher,
|
||||
consumeMarketFeeToken: publishingTokenAddress,
|
||||
consumeMarketFeeAmount: '20000'
|
||||
}
|
||||
assert(setProviderFee, 'Invalid setProviderFee')
|
||||
const orderTx = await datatoken.startOrder(
|
||||
newDtAddress,
|
||||
user1,
|
||||
user2,
|
||||
1,
|
||||
setProviderFee,
|
||||
consumeMarketFees
|
||||
)
|
||||
assert(orderTx, 'Invalid orderTx')
|
||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${newDtAddress.toLowerCase()}-${user1.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||
1
|
||||
)}`
|
||||
|
||||
await sleep(3000)
|
||||
response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
|
||||
const token = (await response.json()).data.token
|
||||
|
||||
assert(token, 'Invalid token')
|
||||
assert(token.orderCount === '1', 'Invalid orderCount after order')
|
||||
assert(token.orders[0].id === orderId)
|
||||
assert(token.orders[0].lastPriceToken.id === ZERO_ADDRESS)
|
||||
assert(token.orders[0].nftOwner.id === publisher, 'invalid nftOwner')
|
||||
assert(token.orders[0].eventIndex === 0, 'invalid order eventIndex')
|
||||
assert(token.eventIndex !== null, 'Invalid eventIndex')
|
||||
assert(
|
||||
token.eventIndex !== token.orders[0].eventIndex,
|
||||
'Invalid log indeces'
|
||||
)
|
||||
const orderQuery = {
|
||||
query: `query {order(id:"${orderId}"){id, publishingMarket{id}, publishingMarketToken{id}, publishingMarketAmmount, consumerMarket{id}, consumerMarketToken{id}, consumerMarketAmmount, eventIndex}}`
|
||||
}
|
||||
await sleep(3000)
|
||||
const orderResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(orderQuery)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await orderResponse.json()
|
||||
const order = queryResult.data.order
|
||||
assert(
|
||||
order.publishingMarket.id === erc20Params.mpFeeAddress.toLowerCase(),
|
||||
'incorrect publish market fee address'
|
||||
)
|
||||
assert(
|
||||
order.publishingMarketToken.id === erc20Params.feeToken.toLowerCase(),
|
||||
'incorrect publish market fee token'
|
||||
)
|
||||
assert(
|
||||
order.publishingMarketAmmount === erc20Params.feeAmount,
|
||||
'incorrect publish market fee amount'
|
||||
)
|
||||
assert(
|
||||
order.consumerMarket.id ===
|
||||
consumeMarketFees.consumeMarketFeeAddress.toLowerCase(),
|
||||
'incorrect consume market fee address'
|
||||
)
|
||||
assert(
|
||||
order.consumerMarketToken.id ===
|
||||
consumeMarketFees.consumeMarketFeeToken.toLowerCase(),
|
||||
'incorrect consume market fee token'
|
||||
)
|
||||
assert(
|
||||
order.consumerMarketAmmount === '0.00000000000002',
|
||||
'incorrect consume market fee amount'
|
||||
)
|
||||
})
|
||||
})
|
|
@ -1,44 +0,0 @@
|
|||
/* eslint-disable prefer-destructuring */
|
||||
import { assert, use } from 'chai'
|
||||
import spies from 'chai-spies'
|
||||
import Web3 from 'web3'
|
||||
import { Ocean, ConfigHelper, Account } from '@oceanprotocol/lib'
|
||||
const fetch = require('cross-fetch')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
function sleep(ms: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
use(spies)
|
||||
|
||||
describe('Datatokens test flow', () => {
|
||||
let alice: Account
|
||||
let ocean: Ocean
|
||||
|
||||
it('Initialize Ocean Library', async () => {
|
||||
// await sleep(60000) // wait 1 min for graph
|
||||
const config = new ConfigHelper().getConfig('development')
|
||||
config.web3Provider = web3
|
||||
ocean = await Ocean.getInstance(config)
|
||||
alice = (await ocean.accounts.list())[0]
|
||||
})
|
||||
|
||||
it('Alice publishes a datatoken and querys the graph', async () => {
|
||||
const datatoken = await ocean.datatokens.create('', alice.getId())
|
||||
const graphToken = datatoken.toLowerCase()
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const query = {
|
||||
query: `query {
|
||||
datatoken(id:"${graphToken}"){symbol,id}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
const result = await response.json()
|
||||
assert(result.data.datatoken.id === graphToken)
|
||||
})
|
||||
})
|
|
@ -1,235 +1,534 @@
|
|||
/* eslint-disable prefer-destructuring */
|
||||
import { assert, use } from 'chai'
|
||||
import spies from 'chai-spies'
|
||||
import {
|
||||
DatatokenCreateParams,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
sleep,
|
||||
ZERO_ADDRESS,
|
||||
Dispenser,
|
||||
Datatoken,
|
||||
DispenserParams
|
||||
} from '@oceanprotocol/lib'
|
||||
import DispenserTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { Ocean, ConfigHelper, Account } from '@oceanprotocol/lib'
|
||||
const fetch = require('cross-fetch')
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
|
||||
const sleepMs = 1800
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
function sleep(ms: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
async function getDispenserStatusFromGraph(datatoken: string) {
|
||||
const id = datatoken.toLowerCase()
|
||||
const query = {
|
||||
query: `query {
|
||||
dispenser(id:"${id}"){active,owner{id},minterApproved,isTrueMinter,maxTokens,maxBalance,balance,datatoken{id}}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
const result = await response.json()
|
||||
return result
|
||||
}
|
||||
describe('Dispenser tests', async () => {
|
||||
const nftName = 'test-Fixed-Price-NFT'
|
||||
const nftSymbol = 'TST-FIXED'
|
||||
const tokenURI = 'https://oceanprotocol.com/nft/fixed'
|
||||
const cap = '10000'
|
||||
const feeAmount = '0.2'
|
||||
const templateIndex = 1
|
||||
const dispenserAddress = addresses.Dispenser.toLowerCase()
|
||||
let dtAddress: string
|
||||
let marketPlaceFeeAddress: string
|
||||
let dt
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let publisher: string
|
||||
let nftAddress: string
|
||||
let time: number
|
||||
let blockNumber: number
|
||||
let dispenser: Dispenser
|
||||
let dispenserId: string
|
||||
let datatoken: Datatoken
|
||||
let user1: string
|
||||
let user2: string
|
||||
|
||||
use(spies)
|
||||
|
||||
describe('Dispenser test flow', () => {
|
||||
let alice: Account
|
||||
let bob: Account
|
||||
let ocean: Ocean
|
||||
let tokenAddress
|
||||
let tokenAddress2
|
||||
let tokenAddress3
|
||||
const tokenAmount = '1000'
|
||||
it('Initialize Ocean Library', async () => {
|
||||
const config = new ConfigHelper().getConfig('development')
|
||||
config.web3Provider = web3
|
||||
ocean = await Ocean.getInstance(config)
|
||||
alice = (await ocean.accounts.list())[0]
|
||||
bob = (await ocean.accounts.list())[1]
|
||||
before(async () => {
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisher = accounts[0].toLowerCase()
|
||||
marketPlaceFeeAddress = accounts[1].toLowerCase()
|
||||
user1 = accounts[2].toLowerCase()
|
||||
user2 = accounts[3].toLowerCase()
|
||||
})
|
||||
|
||||
it('should create some datatokens', async () => {
|
||||
tokenAddress = await ocean.datatokens.create(
|
||||
'',
|
||||
alice.getId(),
|
||||
'1000000000000000',
|
||||
'AliceDT',
|
||||
'DTA'
|
||||
it('should initialize Dispenser and datatoken class', async () => {
|
||||
dispenser = new Dispenser(
|
||||
addresses.Dispenser,
|
||||
web3,
|
||||
8996,
|
||||
null,
|
||||
DispenserTemplate.abi as AbiItem[]
|
||||
)
|
||||
assert(tokenAddress !== null)
|
||||
tokenAddress2 = await ocean.datatokens.create(
|
||||
'',
|
||||
alice.getId(),
|
||||
'1000000000000000',
|
||||
'AliceDT2',
|
||||
'DTA2'
|
||||
)
|
||||
assert(tokenAddress2 !== null)
|
||||
tokenAddress3 = await ocean.datatokens.create(
|
||||
'',
|
||||
alice.getId(),
|
||||
'1000000000000000',
|
||||
'AliceDT3',
|
||||
'DTA3'
|
||||
)
|
||||
assert(tokenAddress3 !== null)
|
||||
assert(dispenser.getDefaultAbi() !== null)
|
||||
|
||||
datatoken = new Datatoken(web3, 8996, null, ERC20Template.abi as AbiItem[])
|
||||
assert(datatoken.getDefaultAbi() !== null)
|
||||
})
|
||||
|
||||
it('Alice mints 1000 tokens', async () => {
|
||||
const txid = await ocean.datatokens.mint(
|
||||
tokenAddress,
|
||||
alice.getId(),
|
||||
tokenAmount
|
||||
it('Deploying an NFT with ERC20', async () => {
|
||||
const date = new Date()
|
||||
time = Math.floor(date.getTime() / 1000)
|
||||
blockNumber = await web3.eth.getBlockNumber()
|
||||
|
||||
const nftParams: NftCreateData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
tokenURI,
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisher,
|
||||
mpFeeAddress: marketPlaceFeeAddress
|
||||
}
|
||||
|
||||
const tx = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
assert(tx.events.NFTCreated.event === 'NFTCreated')
|
||||
assert(tx.events.TokenCreated.event === 'TokenCreated')
|
||||
nftAddress = tx.events.NFTCreated.returnValues.newTokenAddress.toLowerCase()
|
||||
dtAddress =
|
||||
tx.events.TokenCreated.returnValues.newTokenAddress.toLowerCase()
|
||||
|
||||
// Check NFT values
|
||||
await sleep(sleepMs)
|
||||
const nftQuery = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
tokenUri,
|
||||
owner{id},
|
||||
creator{id},
|
||||
address,
|
||||
providerUrl,
|
||||
assetState,
|
||||
managerRole,
|
||||
erc20DeployerRole,
|
||||
storeUpdateRole,
|
||||
metadataRole,
|
||||
template,
|
||||
transferable,
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
orderCount}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(nftQuery)
|
||||
})
|
||||
const nft = (await initialResponse.json()).data.nft
|
||||
const nftTx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
||||
nft.tx
|
||||
)
|
||||
assert(nft.id === nftAddress, 'incorrect value for: id')
|
||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||
assert(nft.name === nftName, 'incorrect value for: name')
|
||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||
assert(
|
||||
nft.erc20DeployerRole[0] === factoryAddress,
|
||||
'incorrect value for: erc20DeployerRole'
|
||||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(nft.createdTimestamp >= time, 'incorrect value: createdTimestamp')
|
||||
assert(nft.createdTimestamp < time + 5, 'incorrect value: createdTimestamp')
|
||||
assert(nftTx.from === publisher, 'incorrect value for: tx')
|
||||
assert(nftTx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(nftTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(
|
||||
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT creation'
|
||||
)
|
||||
assert(txid !== null)
|
||||
})
|
||||
|
||||
it('Alice creates a dispenser', async () => {
|
||||
const tx = await ocean.OceanDispenser.activate(
|
||||
tokenAddress,
|
||||
'1',
|
||||
'1',
|
||||
alice.getId()
|
||||
it('Test all DT Fields after deploying', async () => {
|
||||
// Check Datatoken Values
|
||||
const dtQuery = {
|
||||
query: `query {
|
||||
token(id: "${dtAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
decimals,
|
||||
address,
|
||||
cap,
|
||||
supply,
|
||||
isDatatoken,
|
||||
nft {id},
|
||||
minter,
|
||||
paymentManager,
|
||||
paymentCollector,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeAmount,
|
||||
templateId,
|
||||
holderCount,
|
||||
orderCount,
|
||||
orders {id},
|
||||
fixedRateExchanges {id},
|
||||
dispensers {id},
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
lastPriceValue
|
||||
}}`
|
||||
}
|
||||
const dtResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dtQuery)
|
||||
})
|
||||
dt = (await dtResponse.json()).data.token
|
||||
|
||||
const dtTx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
||||
|
||||
assert(dt.id === dtAddress, 'incorrect value for: id')
|
||||
assert(dt.symbol, 'incorrect value for: symbol')
|
||||
assert(dt.name, 'incorrect value for: name')
|
||||
assert(dt.decimals === 18, 'incorrect value for: decimals')
|
||||
assert(dt.address === dtAddress, 'incorrect value for: address')
|
||||
assert(dt.cap === cap, 'incorrect value for: cap')
|
||||
assert(dt.supply === '0', 'incorrect value for: supply')
|
||||
assert(dt.isDatatoken === true, 'incorrect value for: isDatatoken')
|
||||
assert(dt.nft.id === nftAddress, 'incorrect value for: nft.id')
|
||||
assert(dt.minter[0] === publisher, 'incorrect value for: minter')
|
||||
assert(dt.paymentManager === null, 'incorrect value for: paymentManager')
|
||||
assert(
|
||||
dt.paymentCollector === null,
|
||||
'incorrect value for: paymentCollector'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAddress === marketPlaceFeeAddress,
|
||||
'incorrect value for: publishMarketFeeAddress'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAmount === feeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
assert(dt.fixedRateExchanges, 'incorrect value for: fixedRateExchanges')
|
||||
assert(dt.dispensers, 'incorrect value for: dispensers')
|
||||
assert(dt.createdTimestamp >= time, 'incorrect value for: createdTimestamp')
|
||||
assert(
|
||||
dt.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(dtTx.from === publisher, 'incorrect value for: tx')
|
||||
assert(dtTx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||
assert(
|
||||
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
assert(tx, 'Cannot activate dispenser')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.isTrueMinter === false)
|
||||
assert(status.data.dispenser.minterApproved === false)
|
||||
assert(status.data.dispenser.active === true)
|
||||
assert(status.data.dispenser.balance === '0')
|
||||
})
|
||||
|
||||
it('Alice should make the dispenser a minter', async () => {
|
||||
const tx = await ocean.OceanDispenser.makeMinter(
|
||||
tokenAddress,
|
||||
alice.getId()
|
||||
)
|
||||
assert(tx, 'Cannot make dispenser a minter')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.isTrueMinter === true)
|
||||
assert(status.data.dispenser.minterApproved === true)
|
||||
it('Make user1 minter', async () => {
|
||||
await datatoken.addMinter(dtAddress, publisher, user1)
|
||||
|
||||
assert((await datatoken.getPermissions(dtAddress, user1)).minter === true)
|
||||
await sleep(sleepMs)
|
||||
const minterQuery = {
|
||||
query: `query {token(id: "${dtAddress}"){minter{id}, eventIndex}}`
|
||||
}
|
||||
|
||||
const minterResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(minterQuery)
|
||||
})
|
||||
const dt = (await minterResponse.json()).data.token
|
||||
assert(dt.minter[1] === user1, 'incorrect value for: minter')
|
||||
assert(dt.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
})
|
||||
|
||||
it('Bob requests datatokens', async () => {
|
||||
const tx = await ocean.OceanDispenser.dispense(
|
||||
tokenAddress,
|
||||
bob.getId(),
|
||||
'1'
|
||||
it('Create dispenser', async () => {
|
||||
const maxTokens = '921'
|
||||
const maxBalance = '9032'
|
||||
const dispenserParams: DispenserParams = {
|
||||
maxTokens,
|
||||
maxBalance,
|
||||
withMint: true
|
||||
}
|
||||
const tx = (
|
||||
await datatoken.createDispenser(
|
||||
dtAddress,
|
||||
publisher,
|
||||
dispenserAddress,
|
||||
dispenserParams
|
||||
)
|
||||
).events.NewDispenser
|
||||
await sleep(sleepMs)
|
||||
assert(tx, 'Cannot create dispenser')
|
||||
dispenserId = `${dispenserAddress}-${dtAddress}`
|
||||
|
||||
const dispenserQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){
|
||||
id
|
||||
contract
|
||||
active
|
||||
owner
|
||||
token {
|
||||
id
|
||||
}
|
||||
allowedSwapper
|
||||
isMinter
|
||||
maxTokens
|
||||
maxBalance
|
||||
balance
|
||||
block
|
||||
createdTimestamp
|
||||
tx
|
||||
eventIndex
|
||||
dispenses {
|
||||
id
|
||||
}
|
||||
__typename
|
||||
}}`
|
||||
}
|
||||
const graphResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dispenserQuery)
|
||||
})
|
||||
const response = (await graphResponse.json()).data.dispenser
|
||||
|
||||
assert(response.id === dispenserId, 'incorrect value for: id')
|
||||
assert(response.contract === dispenserAddress, 'incorrect value: contract')
|
||||
assert(response.active === true, 'incorrect value for: active')
|
||||
assert(response.owner === publisher, 'incorrect value for: owner')
|
||||
assert(response.token.id === dtAddress, 'incorrect value for: token.id')
|
||||
assert(response.allowedSwapper === ZERO_ADDRESS, 'incorrect allowedSwapper')
|
||||
assert(response.isMinter === true, 'incorrect value for: isMinter')
|
||||
assert(response.maxTokens === web3.utils.fromWei(maxTokens), 'maxTokens')
|
||||
assert(response.maxBalance === web3.utils.fromWei(maxBalance), 'maxBalance')
|
||||
assert(response.balance === '0', 'maxBalance')
|
||||
assert(response.block === tx.blockNumber, 'wrong block')
|
||||
assert(response.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||
assert(response.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
||||
assert(response.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||
assert(
|
||||
response.eventIndex !== null && response.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
assert(tx, 'Bob failed to get 1DT')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const id = tx.transactionHash.toLowerCase()
|
||||
const query = {
|
||||
query: `query DispenserHistory {
|
||||
dispenserTransactions(orderBy: timestamp, orderDirection: desc,
|
||||
where: {tx: "${id}"}) {
|
||||
datatoken{id},
|
||||
user{id},
|
||||
amount,
|
||||
block,
|
||||
timestamp,
|
||||
tx,
|
||||
type
|
||||
}
|
||||
}`
|
||||
assert(response.dispenses.length === 0, 'incorrect value for: dispenses')
|
||||
assert(response.__typename === 'Dispenser', 'incorrect value: __typename')
|
||||
})
|
||||
|
||||
it('Deactivates dispenser', async () => {
|
||||
const deactiveQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){active, eventIndex}}`
|
||||
}
|
||||
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.dispenser.active
|
||||
assert(initialActive === true, 'incorrect value for: initialActive')
|
||||
|
||||
// Deactivate exchange
|
||||
const tx = await dispenser.deactivate(dtAddress, publisher)
|
||||
const status = await dispenser.status(dtAddress)
|
||||
assert(status.active === false, 'Dispenser is still active')
|
||||
await sleep(sleepMs)
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.dispenser
|
||||
assert(updatedActive.active === false, 'incorrect value for: updatedActive')
|
||||
assert(updatedActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
assert(
|
||||
updatedActive.eventIndex === tx.events.DispenserDeactivated.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Activates dispenser', async () => {
|
||||
const activeQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){active, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.dispenser
|
||||
assert(initialActive.active === false, 'incorrect value for: initialActive')
|
||||
assert(initialActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
|
||||
// Activate dispenser
|
||||
const tx = await dispenser.activate(dtAddress, '100', '100', publisher)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.dispenser
|
||||
assert(updatedActive.active === true, 'incorrect value for: updatedActive')
|
||||
assert(updatedActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
assert(
|
||||
updatedActive.eventIndex === tx.events.DispenserActivated.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('User2 gets datatokens from the dispenser', async () => {
|
||||
const amount = '3'
|
||||
const dispenseQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){
|
||||
dispenses{
|
||||
id
|
||||
dispenser{id}
|
||||
user {id}
|
||||
amount
|
||||
block
|
||||
createdTimestamp
|
||||
tx
|
||||
eventIndex
|
||||
__typename
|
||||
}}}`
|
||||
}
|
||||
// Check initial values before dispense
|
||||
const response1 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dispenseQuery)
|
||||
})
|
||||
await sleep(sleepMs)
|
||||
const before = (await response1.json()).data.dispenser.dispenses
|
||||
assert(before.length === 0, 'incorrect value for: dispenses')
|
||||
|
||||
const tx = await dispenser.dispense(dtAddress, user2, amount, user2)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check values after dispense
|
||||
const response2 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dispenseQuery)
|
||||
})
|
||||
const dispense = (await response2.json()).data.dispenser.dispenses[0]
|
||||
|
||||
assert(
|
||||
dispense.id ===
|
||||
`${
|
||||
tx.transactionHash
|
||||
}-${dispenserId}-${tx.events.TokensDispensed.logIndex.toFixed(1)}`,
|
||||
'wrong id'
|
||||
)
|
||||
assert(dispense.dispenser.id === dispenserId, 'incorrect value for: user')
|
||||
assert(dispense.user.id === user2, 'incorrect value for: user')
|
||||
assert(dispense.amount === amount, 'incorrect value for: user')
|
||||
assert(dispense.block === tx.blockNumber, 'incorrect value for: block')
|
||||
assert(dispense.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||
assert(dispense.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
||||
assert(dispense.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||
assert(dispense.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
assert(dispense.__typename === 'DispenserTransaction', 'wrong __typename')
|
||||
})
|
||||
|
||||
it('Owner withdraws all of the datatokens', async () => {
|
||||
await dispenser.ownerWithdraw(dtAddress, publisher)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check balance after owner withdraw
|
||||
const balanceQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){balance, eventIndex}}`
|
||||
}
|
||||
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
body: JSON.stringify(balanceQuery)
|
||||
})
|
||||
const result = await response.json()
|
||||
|
||||
assert(result.data.dispenserTransactions[0].type === 'dispense')
|
||||
})
|
||||
it('Alice calls removeMinter role and checks if she is the new minter', async () => {
|
||||
const tx = await ocean.OceanDispenser.cancelMinter(
|
||||
tokenAddress,
|
||||
alice.getId()
|
||||
)
|
||||
assert(tx, 'Cannot cancel minter role')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.isTrueMinter === false)
|
||||
assert(status.data.dispenser.minterApproved === false)
|
||||
assert(status.data.dispenser.active === true)
|
||||
})
|
||||
it('Alice deactivates the dispenser', async () => {
|
||||
const tx = await ocean.OceanDispenser.deactivate(
|
||||
tokenAddress,
|
||||
alice.getId()
|
||||
)
|
||||
assert(tx, 'Cannot make dispenser a minter')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.active === false)
|
||||
const balance = (await response.json()).data.dispenser
|
||||
assert(balance.balance === '0', 'incorrect value for: balance')
|
||||
assert(balance.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||
})
|
||||
|
||||
it('Alice creates a dispenser without minter role', async () => {
|
||||
const tx = await ocean.OceanDispenser.activate(
|
||||
tokenAddress2,
|
||||
'1',
|
||||
'1',
|
||||
alice.getId()
|
||||
)
|
||||
assert(tx, 'Cannot activate dispenser')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress2)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress2.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.isTrueMinter === false)
|
||||
assert(status.data.dispenser.minterApproved === false)
|
||||
assert(status.data.dispenser.active === true)
|
||||
})
|
||||
it('Alice withdraws all datatokens', async () => {
|
||||
const mintTx = await ocean.datatokens.mint(
|
||||
tokenAddress2,
|
||||
alice.getId(),
|
||||
'10',
|
||||
ocean.OceanDispenser.dispenserAddress
|
||||
)
|
||||
assert(mintTx, 'Alice cannot mint tokens')
|
||||
const tx = await ocean.OceanDispenser.ownerWithdraw(
|
||||
tokenAddress2,
|
||||
alice.getId()
|
||||
)
|
||||
assert(tx, 'Alice failed to withdraw all her tokens')
|
||||
await sleep(3000) // let graph ingest our transaction
|
||||
const status = await getDispenserStatusFromGraph(tokenAddress2)
|
||||
assert(status.data.dispenser.datatoken.id === tokenAddress2.toLowerCase())
|
||||
assert(status.data.dispenser.owner.id === alice.getId().toLowerCase())
|
||||
assert(status.data.dispenser.isTrueMinter === false)
|
||||
assert(status.data.dispenser.minterApproved === false)
|
||||
assert(status.data.dispenser.active === true)
|
||||
assert(status.data.dispenser.balance === '0')
|
||||
const id = tx.transactionHash.toLowerCase()
|
||||
const query = {
|
||||
query: `query DispenserHistory {
|
||||
dispenserTransactions(orderBy: timestamp, orderDirection: desc,
|
||||
where: {tx: "${id}"}) {
|
||||
datatoken{id},
|
||||
user{id},
|
||||
amount,
|
||||
block,
|
||||
timestamp,
|
||||
tx,
|
||||
type
|
||||
}
|
||||
}`
|
||||
it('Updates allowed swapper', async () => {
|
||||
const swapperQuery = {
|
||||
query: `query {dispenser(id: "${dispenserId}"){allowedSwapper, eventIndex}}`
|
||||
}
|
||||
// console.log(query)
|
||||
const response = await fetch(subgraphUrl, {
|
||||
// Check initial allowedSwapper
|
||||
const swapperResponse1 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
body: JSON.stringify(swapperQuery)
|
||||
})
|
||||
const result = await response.json()
|
||||
assert(result.data.dispenserTransactions[0].type === 'withdraw')
|
||||
const allowedSwapper1 = (await swapperResponse1.json()).data.dispenser
|
||||
.allowedSwapper
|
||||
assert(
|
||||
allowedSwapper1 === ZERO_ADDRESS,
|
||||
'incorrect value for: allowedSwapper'
|
||||
)
|
||||
|
||||
const tx = await dispenser.setAllowedSwapper(dtAddress, publisher, user1)
|
||||
await sleep(sleepMs)
|
||||
|
||||
const swapperResponse2 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapperQuery)
|
||||
})
|
||||
const allowedSwapper2 = (await swapperResponse2.json()).data.dispenser
|
||||
|
||||
assert(
|
||||
allowedSwapper2.allowedSwapper === user1,
|
||||
'incorrect value for: allowedSwapper 2'
|
||||
)
|
||||
assert(
|
||||
allowedSwapper2.eventIndex !== null &&
|
||||
allowedSwapper2.eventIndex ===
|
||||
tx.events.DispenserAllowedSwapperChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
import {
|
||||
Router,
|
||||
NftFactory,
|
||||
calculateEstimatedGas,
|
||||
sendTx,
|
||||
sleep
|
||||
} from '@oceanprotocol/lib'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
const minAbi = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{ name: 'to', type: 'address' },
|
||||
{ name: 'value', type: 'uint256' }
|
||||
],
|
||||
name: 'mint',
|
||||
outputs: [{ name: '', type: 'bool' }],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function'
|
||||
}
|
||||
] as AbiItem[]
|
||||
|
||||
async function getSubgraphApprovedTokens() {
|
||||
const tokens: string[] = []
|
||||
const initialQuery = {
|
||||
query: `query{
|
||||
opcs{
|
||||
approvedTokens{
|
||||
id
|
||||
}
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.opcs[0].approvedTokens
|
||||
for (let i = 0; i < info.length; i++) tokens.push(info[i].id)
|
||||
return tokens
|
||||
}
|
||||
|
||||
describe('FactoryRouter tests', async () => {
|
||||
let factory
|
||||
let router: Router
|
||||
let ownerAccount: string
|
||||
let Alice: string
|
||||
let Bob: string
|
||||
let datatokenAddress
|
||||
// let nft1, nft2, nft3
|
||||
// let chainId
|
||||
// const configHelper = new ConfigHelper()
|
||||
// const config = configHelper.getConfig('development')
|
||||
|
||||
before(async () => {
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
// chainId = await web3.eth.getChainId()
|
||||
ownerAccount = accounts[0]
|
||||
Alice = accounts[1]
|
||||
Bob = accounts[2]
|
||||
|
||||
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||
const estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.mint,
|
||||
Alice,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
Alice,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
Bob,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
router = new Router(addresses.Router, web3)
|
||||
// nftFactory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
})
|
||||
|
||||
it('Ocean token should be in the approve token list', async () => {
|
||||
// since we can only lock once, we test if tx fails or not
|
||||
// so if there is already a lock, skip it
|
||||
const tokens = await getSubgraphApprovedTokens()
|
||||
assert(tokens.includes(addresses.Ocean.toLowerCase()))
|
||||
assert(tokens.length === 1)
|
||||
})
|
||||
it('Owner should add another token in the approved list', async () => {
|
||||
const nftName = 'testNFT'
|
||||
const nftSymbol = 'TST'
|
||||
const marketPlaceFeeAddress = '0x1230000000000000000000000000000000000000'
|
||||
const feeToken = '0x3210000000000000000000000000000000000000'
|
||||
const publishMarketFeeAmount = '0.1'
|
||||
const cap = '10000'
|
||||
const templateIndex = 1
|
||||
const result = await factory.createNftWithDatatoken(
|
||||
Alice,
|
||||
{
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: Alice
|
||||
},
|
||||
{
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount: publishMarketFeeAmount,
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken,
|
||||
minter: Alice,
|
||||
mpFeeAddress: marketPlaceFeeAddress,
|
||||
name: 'DT1',
|
||||
symbol: 'DT1'
|
||||
}
|
||||
)
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
await router.addApprovedToken(ownerAccount, datatokenAddress)
|
||||
await sleep(2000)
|
||||
const tokens = await getSubgraphApprovedTokens()
|
||||
assert(tokens.includes(datatokenAddress.toLowerCase()))
|
||||
assert(tokens.length === 2)
|
||||
})
|
||||
|
||||
it('Owner should remove token from the approved list', async () => {
|
||||
await router.removeApprovedToken(ownerAccount, datatokenAddress)
|
||||
await sleep(2000)
|
||||
const tokens = await getSubgraphApprovedTokens()
|
||||
assert(!tokens.includes(datatokenAddress.toLowerCase()))
|
||||
assert(tokens.length === 1)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,760 @@
|
|||
import {
|
||||
DatatokenCreateParams,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
sleep,
|
||||
FreCreationParams,
|
||||
ZERO_ADDRESS,
|
||||
FixedRateExchange,
|
||||
Datatoken
|
||||
} from '@oceanprotocol/lib'
|
||||
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import BN from 'bn.js'
|
||||
|
||||
const sleepMs = 1700
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
describe('Fixed Rate Exchange tests', async () => {
|
||||
const nftName = 'test-Fixed-Price-NFT'
|
||||
const nftSymbol = 'TST-FIXED'
|
||||
const tokenURI = 'https://oceanprotocol.com/nft/fixed'
|
||||
const cap = '10000'
|
||||
const feeAmount = '0.2'
|
||||
const price = '123'
|
||||
const publishMarketSwapFee = '0.003'
|
||||
const templateIndex = 1
|
||||
const dtAmount = '10'
|
||||
// const datatoken = new Datatoken(web3, 8996)
|
||||
let datatokenAddress: string
|
||||
let fixedRateAddress: string
|
||||
let baseTokenAddress: string
|
||||
let marketPlaceFeeAddress: string
|
||||
let fixedRateId: string
|
||||
let dt
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let publisher: string
|
||||
let erc721Address: string
|
||||
let nftAddress: string
|
||||
let time: number
|
||||
let blockNumber: number
|
||||
let exchangeContract: string
|
||||
let exchangeId: string
|
||||
let transactionHash: string
|
||||
let fixedRate: FixedRateExchange
|
||||
let user1: string
|
||||
|
||||
before(async () => {
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
fixedRateAddress = addresses.FixedPrice.toLowerCase()
|
||||
baseTokenAddress = addresses.MockDAI.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisher = accounts[0].toLowerCase()
|
||||
marketPlaceFeeAddress = accounts[1].toLowerCase()
|
||||
user1 = accounts[2].toLowerCase()
|
||||
})
|
||||
|
||||
it('Deploying a Fixed Rate Exchange & Test NFT Fields', async () => {
|
||||
const date = new Date()
|
||||
time = Math.floor(date.getTime() / 1000)
|
||||
blockNumber = await web3.eth.getBlockNumber()
|
||||
|
||||
const nftParams: NftCreateData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
tokenURI,
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisher,
|
||||
mpFeeAddress: marketPlaceFeeAddress
|
||||
}
|
||||
const fixedRateParams: FreCreationParams = {
|
||||
fixedRateAddress,
|
||||
baseTokenAddress,
|
||||
owner: publisher,
|
||||
marketFeeCollector: marketPlaceFeeAddress,
|
||||
baseTokenDecimals: 18,
|
||||
datatokenDecimals: 18,
|
||||
fixedRate: price,
|
||||
marketFee: publishMarketSwapFee,
|
||||
allowedConsumer: ZERO_ADDRESS,
|
||||
withMint: true
|
||||
}
|
||||
|
||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params,
|
||||
fixedRateParams
|
||||
)
|
||||
transactionHash = result.transactionHash.toLowerCase()
|
||||
erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
|
||||
exchangeContract =
|
||||
result.events.NewFixedRate.returnValues.exchangeContract.toLowerCase()
|
||||
exchangeId =
|
||||
result.events.NewFixedRate.returnValues.exchangeId.toLowerCase()
|
||||
|
||||
fixedRateId = `${exchangeContract}-${exchangeId}`
|
||||
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
|
||||
// Check NFT values
|
||||
await sleep(sleepMs)
|
||||
nftAddress = erc721Address.toLowerCase()
|
||||
const nftQuery = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
tokenUri,
|
||||
owner{id},
|
||||
creator{id},
|
||||
address,
|
||||
providerUrl,
|
||||
assetState,
|
||||
managerRole,
|
||||
erc20DeployerRole,
|
||||
storeUpdateRole,
|
||||
metadataRole,
|
||||
template,
|
||||
transferable,
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
orderCount}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(nftQuery)
|
||||
})
|
||||
const nft = (await initialResponse.json()).data.nft
|
||||
const nftTx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
||||
nft.tx
|
||||
)
|
||||
assert(nft.id === nftAddress, 'incorrect value for: id')
|
||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||
assert(nft.name === nftName, 'incorrect value for: name')
|
||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||
assert(
|
||||
nft.erc20DeployerRole[0] === factoryAddress,
|
||||
'incorrect value for: erc20DeployerRole'
|
||||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(
|
||||
nft.createdTimestamp >= time,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(
|
||||
nft.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(nftTx.from === publisher, 'incorrect value for: tx')
|
||||
assert(nftTx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(nftTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(
|
||||
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Test DT Fields after deploying Fixed rate exchange', async () => {
|
||||
// Check Datatoken Values
|
||||
const dtQuery = {
|
||||
query: `query {
|
||||
token(id: "${datatokenAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
decimals,
|
||||
address,
|
||||
cap,
|
||||
supply,
|
||||
isDatatoken,
|
||||
nft {id},
|
||||
minter,
|
||||
paymentManager,
|
||||
paymentCollector,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeAmount,
|
||||
templateId,
|
||||
holderCount,
|
||||
orderCount,
|
||||
orders {id},
|
||||
fixedRateExchanges {id},
|
||||
dispensers {id},
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
lastPriceToken,
|
||||
lastPriceValue
|
||||
}}`
|
||||
}
|
||||
const dtResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dtQuery)
|
||||
})
|
||||
dt = (await dtResponse.json()).data.token
|
||||
|
||||
const dtTx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
||||
|
||||
assert(dt.id === datatokenAddress, 'incorrect value for: id')
|
||||
assert(dt.symbol, 'incorrect value for: symbol')
|
||||
assert(dt.name, 'incorrect value for: name')
|
||||
assert(dt.decimals === 18, 'incorrect value for: decimals')
|
||||
assert(dt.address === datatokenAddress, 'incorrect value for: address')
|
||||
assert(dt.cap === cap, 'incorrect value for: cap')
|
||||
assert(dt.supply === '0', 'incorrect value for: supply')
|
||||
assert(dt.isDatatoken === true, 'incorrect value for: isDatatoken')
|
||||
assert(dt.nft.id === nftAddress, 'incorrect value for: nft.id')
|
||||
assert(dt.minter[0] === publisher, 'incorrect value for: minter')
|
||||
assert(dt.paymentManager === null, 'incorrect value for: paymentManager')
|
||||
assert(
|
||||
dt.paymentCollector === null,
|
||||
'incorrect value for: paymentCollector'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAddress === marketPlaceFeeAddress,
|
||||
'incorrect value for: publishMarketFeeAddress'
|
||||
)
|
||||
assert(
|
||||
dt.publishMarketFeeAmount === feeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
assert(dt.fixedRateExchanges, 'incorrect value for: fixedRateExchanges')
|
||||
assert(dt.dispensers, 'incorrect value for: dispensers')
|
||||
assert(dt.createdTimestamp >= time, 'incorrect value for: createdTimestamp')
|
||||
assert(
|
||||
dt.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(dtTx.from === publisher, 'incorrect value for: tx')
|
||||
assert(dtTx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||
assert(
|
||||
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Test fixedRateExchanges Fields', async () => {
|
||||
const fixedQuery = {
|
||||
query: `query {
|
||||
fixedRateExchange(id: "${fixedRateId}"){
|
||||
id
|
||||
contract
|
||||
exchangeId
|
||||
owner {
|
||||
id
|
||||
}
|
||||
datatoken {
|
||||
id
|
||||
}
|
||||
baseToken {
|
||||
id
|
||||
}
|
||||
datatokenSupply
|
||||
baseTokenSupply
|
||||
datatokenBalance
|
||||
baseTokenBalance
|
||||
price
|
||||
active
|
||||
totalSwapValue
|
||||
allowedSwapper
|
||||
withMint
|
||||
isMinter
|
||||
updates {
|
||||
id
|
||||
}
|
||||
swaps {
|
||||
id
|
||||
}
|
||||
createdTimestamp
|
||||
tx
|
||||
eventIndex
|
||||
block
|
||||
publishMarketFeeAddress
|
||||
publishMarketSwapFee
|
||||
}
|
||||
}`
|
||||
}
|
||||
const fixedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(fixedQuery)
|
||||
})
|
||||
const fixed = (await fixedResponse.json()).data.fixedRateExchange
|
||||
const fixedTx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
||||
fixed.tx
|
||||
)
|
||||
// Test Fixed Rate Exchange Values
|
||||
assert(fixed.id === fixedRateId, 'incorrect value for: id')
|
||||
assert(fixed.contract === exchangeContract, 'incorrect value for: contract')
|
||||
assert(fixed.exchangeId === exchangeId, 'incorrect value for: exchangeId')
|
||||
assert(fixed.owner.id === publisher, 'incorrect value for: owner.id')
|
||||
assert(
|
||||
fixed.datatoken.id === datatokenAddress,
|
||||
'incorrect value for: datatoken.id'
|
||||
)
|
||||
assert(
|
||||
fixed.baseToken.id === baseTokenAddress,
|
||||
'incorrect value for: baseToken.id'
|
||||
)
|
||||
assert(
|
||||
fixed.datatokenSupply ===
|
||||
'115792089237316195423570985008687900000000000000000000000000',
|
||||
'incorrect value for: datatokenSupply'
|
||||
)
|
||||
assert(
|
||||
fixed.baseTokenSupply === '0',
|
||||
'incorrect value for: baseTokenSupply'
|
||||
)
|
||||
assert(
|
||||
fixed.datatokenBalance === '0',
|
||||
'incorrect value for: datatokenBalance'
|
||||
)
|
||||
assert(
|
||||
fixed.baseTokenBalance === '0',
|
||||
'incorrect value for: baseTokenBalance'
|
||||
)
|
||||
assert(fixed.price === price, 'incorrect value for: price')
|
||||
assert(fixed.active === true, 'incorrect value for: active')
|
||||
assert(fixed.totalSwapValue === '0', 'incorrect value for: totalSwapValue')
|
||||
assert(
|
||||
fixed.allowedSwapper === ZERO_ADDRESS,
|
||||
'incorrect value for: allowedSwapper'
|
||||
)
|
||||
assert(fixed.withMint === true, 'incorrect value for: withMint')
|
||||
assert(fixed.isMinter === null, 'incorrect value for: isMinter')
|
||||
assert(fixed.updates, 'incorrect value for: updates.id')
|
||||
assert(fixed.swaps, 'incorrect value for: swaps')
|
||||
assert(
|
||||
fixed.createdTimestamp >= time,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(
|
||||
fixed.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(fixed.tx === transactionHash, 'incorrect value for: tx')
|
||||
assert(fixed.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(fixed.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(
|
||||
fixed.publishMarketFeeAddress === marketPlaceFeeAddress,
|
||||
'incorrect value for: publishMarketFeeAddress'
|
||||
)
|
||||
assert(
|
||||
fixed.publishMarketSwapFee === publishMarketSwapFee,
|
||||
'incorrect value for: publishMarketSwapFee'
|
||||
)
|
||||
assert(fixedTx.from === publisher, 'incorrect value for: tx')
|
||||
assert(fixedTx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(
|
||||
fixed.eventIndex !== null && fixed.eventIndex > 0,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Updates Fixed Rate Price', async () => {
|
||||
fixedRate = new FixedRateExchange(fixedRateAddress, web3, 8996)
|
||||
const priceQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){
|
||||
price
|
||||
updates(orderBy: createdTimestamp, orderDirection: desc){
|
||||
exchangeId {
|
||||
id
|
||||
}
|
||||
oldPrice
|
||||
newPrice
|
||||
eventIndex
|
||||
}
|
||||
}}`
|
||||
}
|
||||
|
||||
// Check initial price
|
||||
const priceResponse1 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(priceQuery)
|
||||
})
|
||||
const fixedResponse1 = (await priceResponse1.json()).data.fixedRateExchange
|
||||
|
||||
const price1 = fixedResponse1.price
|
||||
const updates1 = fixedResponse1.updates[0]
|
||||
|
||||
assert(price1 === price, 'incorrect value for: price 1')
|
||||
assert(
|
||||
updates1.exchangeId.id === fixedRateId,
|
||||
'incorrect value: initial fixedRateId'
|
||||
)
|
||||
assert(updates1.oldPrice === null, 'incorrect value: initial oldPrice')
|
||||
assert(updates1.newPrice === null, 'incorrect value: initial oldPrice')
|
||||
|
||||
// Update price
|
||||
const newPrice = '999'
|
||||
const tx = await fixedRate.setRate(publisher, exchangeId, newPrice)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check price after first update
|
||||
const priceResponse2 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(priceQuery)
|
||||
})
|
||||
const fixedResponse2 = (await priceResponse2.json()).data.fixedRateExchange
|
||||
const price2 = fixedResponse2.price
|
||||
const updates2 = fixedResponse2.updates[0]
|
||||
|
||||
assert(price2 === newPrice, 'incorrect value for: price 2')
|
||||
assert(
|
||||
updates2.exchangeId.id === fixedRateId,
|
||||
'incorrect value: 2nd fixedRateId'
|
||||
)
|
||||
assert(updates2.oldPrice === price1, 'incorrect value: 2nd oldPrice')
|
||||
assert(updates2.newPrice === newPrice, 'incorrect value: 2nd newPrice')
|
||||
assert(
|
||||
updates2.eventIndex === tx.events.ExchangeRateChanged.logIndex,
|
||||
'incorrect value: 2nd eventIndex'
|
||||
)
|
||||
|
||||
// Update price a 2nd time
|
||||
const newPrice2 = '1' // '5.123'
|
||||
const tx2 = await fixedRate.setRate(publisher, exchangeId, newPrice2)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check price after 2nd update
|
||||
const priceResponse3 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(priceQuery)
|
||||
})
|
||||
|
||||
const fixedResponse3 = (await priceResponse3.json()).data.fixedRateExchange
|
||||
const price3 = fixedResponse3.price
|
||||
const updates3 = fixedResponse3.updates[0]
|
||||
|
||||
assert(price3 === newPrice2, 'incorrect value for: price 3')
|
||||
assert(
|
||||
updates3.exchangeId.id === fixedRateId,
|
||||
'incorrect value: 3rd fixedRateId'
|
||||
)
|
||||
assert(updates3.oldPrice === newPrice, 'incorrect value: 3rd oldPrice')
|
||||
assert(updates3.newPrice === newPrice2, 'incorrect value: 3rd newPrice')
|
||||
assert(
|
||||
updates3.eventIndex === tx2.events.ExchangeRateChanged.logIndex,
|
||||
'incorrect value: 3nd eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('User1 buys a datatoken', async () => {
|
||||
const swapsQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){
|
||||
swaps{
|
||||
id
|
||||
exchangeId{id}
|
||||
by{id}
|
||||
baseTokenAmount
|
||||
dataTokenAmount
|
||||
block
|
||||
createdTimestamp
|
||||
tx
|
||||
eventIndex
|
||||
oceanFeeAmount
|
||||
marketFeeAmount
|
||||
consumeMarketFeeAmount
|
||||
__typename
|
||||
}
|
||||
}}`
|
||||
}
|
||||
// Check initial swaps
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapsQuery)
|
||||
})
|
||||
const initialSwaps = (await initialResponse.json()).data.fixedRateExchange
|
||||
.swaps
|
||||
assert(initialSwaps.length === 0, 'incorrect value for: initialSwaps')
|
||||
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
// Mint datatokens as initial supply is 0
|
||||
await datatoken.mint(datatokenAddress, publisher, '100')
|
||||
await datatoken.approve(
|
||||
datatokenAddress,
|
||||
fixedRateAddress,
|
||||
'100',
|
||||
publisher
|
||||
)
|
||||
|
||||
const daiContract = new web3.eth.Contract(
|
||||
MockERC20.abi as AbiItem[],
|
||||
addresses.MockDAI
|
||||
)
|
||||
// user1 need DAI so that they can buy the datatoken
|
||||
await daiContract.methods
|
||||
.transfer(user1, web3.utils.toWei('100'))
|
||||
.send({ from: publisher })
|
||||
await daiContract.methods
|
||||
.approve(fixedRateAddress, web3.utils.toWei('10000000'))
|
||||
.send({ from: user1 })
|
||||
|
||||
// user1 has no DTs before buying one
|
||||
let user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
assert(user1Balance === '0', 'incorrect value for: user1Balance')
|
||||
|
||||
const tx = (
|
||||
await fixedRate.buyDatatokens(user1, exchangeId, dtAmount, '100')
|
||||
).events?.Swapped
|
||||
|
||||
const oceanFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.oceanFeeAmount)
|
||||
)
|
||||
const marketFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.marketFeeAmount)
|
||||
)
|
||||
const consumeMarketFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.consumeMarketFeeAmount)
|
||||
)
|
||||
|
||||
await sleep(sleepMs)
|
||||
user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
// user1 has 1 datatoken
|
||||
assert(user1Balance === dtAmount, 'incorrect value for: user1Balance')
|
||||
|
||||
// Check updated swaps
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapsQuery)
|
||||
})
|
||||
const swaps = (await updatedResponse.json()).data.fixedRateExchange.swaps[0]
|
||||
const swappedAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
||||
)
|
||||
assert(
|
||||
swaps.id ===
|
||||
`${tx.transactionHash}-${fixedRateId}-${tx.logIndex.toFixed(1)}`,
|
||||
'incorrect: id'
|
||||
)
|
||||
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
||||
assert(swaps.by.id === user1, 'incorrect value for: id')
|
||||
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
||||
assert(swaps.dataTokenAmount === dtAmount, 'incorrect: dataTokenAmount')
|
||||
assert(swaps.block === tx.blockNumber, 'incorrect value for: block')
|
||||
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2')
|
||||
assert(swaps.oceanFeeAmount === oceanFeeAmount, 'incorrect: oceanFeeAmount')
|
||||
assert(swaps.marketFeeAmount === marketFeeAmount, 'wrong marketFeeAmount')
|
||||
assert(
|
||||
swaps.consumeMarketFeeAmount === consumeMarketFeeAmount,
|
||||
'wrong consumeMarketFeeAmount'
|
||||
)
|
||||
assert(swaps.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||
assert(swaps.eventIndex === tx.logIndex, 'incorrect value for: eventIndex')
|
||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
||||
})
|
||||
|
||||
it('Deactivate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === true, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.deactivateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === false, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
it('Activate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === false, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.activateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === true, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Updates allowed swapper', async () => {
|
||||
const swapperQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){allowedSwapper, eventIndex}}`
|
||||
}
|
||||
// Check initial allowedSwapper
|
||||
const swapperResponse1 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapperQuery)
|
||||
})
|
||||
const allowedSwapper1 = (await swapperResponse1.json()).data
|
||||
.fixedRateExchange.allowedSwapper
|
||||
assert(
|
||||
allowedSwapper1 === ZERO_ADDRESS,
|
||||
'incorrect value for: allowedSwapper'
|
||||
)
|
||||
|
||||
const tx = await fixedRate.setAllowedSwapper(publisher, exchangeId, user1)
|
||||
await sleep(sleepMs)
|
||||
|
||||
const swapperResponse2 = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapperQuery)
|
||||
})
|
||||
const allowedSwapper2 = (await swapperResponse2.json()).data
|
||||
.fixedRateExchange
|
||||
|
||||
assert(
|
||||
allowedSwapper2.allowedSwapper === user1,
|
||||
'incorrect value for: allowedSwapper 2'
|
||||
)
|
||||
assert(
|
||||
allowedSwapper2.eventIndex ===
|
||||
tx.events.ExchangeAllowedSwapperChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
it('Deactivates exchange', async () => {
|
||||
const deactiveQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === true, 'incorrect value for: initialActive')
|
||||
|
||||
// Deactivate exchange
|
||||
await fixedRate.deactivate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
|
||||
assert(updatedActive.active === false, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex >= 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Activates exchange', async () => {
|
||||
const activeQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === false, 'incorrect value for: initialActive')
|
||||
|
||||
// Activate exchange
|
||||
await fixedRate.activate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedActive.active === true, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex >= 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,337 @@
|
|||
import {
|
||||
DatatokenCreateParams,
|
||||
ProviderInstance,
|
||||
Nft,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
getHash,
|
||||
sleep
|
||||
} from '@oceanprotocol/lib'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const providerUrl = 'http://172.15.0.4:8030'
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
const assetUrl = [
|
||||
{
|
||||
type: 'url',
|
||||
url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt',
|
||||
method: 'GET'
|
||||
}
|
||||
]
|
||||
const ddo = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||
version: '4.0.0',
|
||||
chainId: 4,
|
||||
nftAddress: '0x0',
|
||||
metadata: {
|
||||
created: '2021-12-20T14:35:20Z',
|
||||
updated: '2021-12-20T14:35:20Z',
|
||||
type: 'dataset',
|
||||
name: 'dfgdfgdg',
|
||||
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||
tags: [''],
|
||||
author: 'dd',
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
additionalInformation: {
|
||||
termsAndConditions: true
|
||||
}
|
||||
},
|
||||
services: [
|
||||
{
|
||||
id: 'notAnId',
|
||||
type: 'access',
|
||||
files: '',
|
||||
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||
timeout: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
let nftTemplate
|
||||
|
||||
describe('NFT tests', async () => {
|
||||
const nftName = 'testNFT'
|
||||
const nftSymbol = 'TST'
|
||||
const tokenURI = 'https://oceanprotocol.com/nft/'
|
||||
let datatokenAddress: string
|
||||
let nft: Nft
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let publisher: string
|
||||
let erc721Address: string
|
||||
let nftAddress: string
|
||||
let time: number
|
||||
let blockNumber: number
|
||||
|
||||
before(async () => {
|
||||
nft = new Nft(web3)
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisher = accounts[0].toLowerCase()
|
||||
})
|
||||
|
||||
it('Should publish an NFT & datatoken', async () => {
|
||||
const date = new Date()
|
||||
time = Math.floor(date.getTime() / 1000)
|
||||
blockNumber = await web3.eth.getBlockNumber()
|
||||
|
||||
const nftParams: NftCreateData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
tokenURI,
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisher,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||
nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
// Check values before updating metadata
|
||||
await sleep(3000)
|
||||
nftAddress = erc721Address.toLowerCase()
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
tokenUri,
|
||||
owner{id},
|
||||
creator{id},
|
||||
address,
|
||||
providerUrl,
|
||||
assetState,
|
||||
managerRole,
|
||||
erc20DeployerRole,
|
||||
storeUpdateRole,
|
||||
metadataRole,
|
||||
template,
|
||||
transferable,
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
orderCount}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
await sleep(3000)
|
||||
const nft = (await initialResponse.json()).data.nft
|
||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(nft.tx)
|
||||
assert(nft.id === nftAddress, 'incorrect value for: id')
|
||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||
assert(nft.name === nftName, 'incorrect value for: name')
|
||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||
assert(
|
||||
nft.erc20DeployerRole[0] === factoryAddress,
|
||||
'incorrect value for: erc20DeployerRole'
|
||||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(
|
||||
nft.createdTimestamp >= time,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(
|
||||
nft.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(tx.from === publisher, 'incorrect value for: tx')
|
||||
assert(tx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(
|
||||
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT creation'
|
||||
)
|
||||
})
|
||||
|
||||
it('Update metadata', async () => {
|
||||
const chain = await web3.eth.getChainId()
|
||||
// create the files encrypted string
|
||||
let providerResponse = await ProviderInstance.encrypt(
|
||||
assetUrl,
|
||||
chain,
|
||||
providerUrl
|
||||
)
|
||||
ddo.services[0].files = await providerResponse
|
||||
ddo.services[0].datatokenAddress = datatokenAddress
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = erc721Address
|
||||
ddo.id =
|
||||
'did:op:' +
|
||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
publisher,
|
||||
0,
|
||||
providerUrl,
|
||||
'',
|
||||
'0x2',
|
||||
encryptedResponse,
|
||||
'0x' + metadataHash
|
||||
)
|
||||
|
||||
// graph tests here
|
||||
await sleep(3000)
|
||||
const query = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
id,
|
||||
symbol,
|
||||
name,
|
||||
tokenUri,
|
||||
owner{id},
|
||||
creator{id},
|
||||
address,
|
||||
providerUrl,
|
||||
assetState,
|
||||
managerRole,
|
||||
erc20DeployerRole,
|
||||
storeUpdateRole,
|
||||
metadataRole,
|
||||
template,
|
||||
transferable,
|
||||
createdTimestamp,
|
||||
tx,
|
||||
eventIndex,
|
||||
block,
|
||||
orderCount}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
const updatedNft = (await response.json()).data.nft
|
||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
||||
updatedNft.tx
|
||||
)
|
||||
assert(updatedNft.id === nftAddress, 'incorrect value for: id')
|
||||
assert(updatedNft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||
assert(updatedNft.name === nftName, 'incorrect value for: name')
|
||||
assert(updatedNft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||
assert(updatedNft.owner.id === publisher, 'incorrect value for: owner')
|
||||
assert(updatedNft.creator.id === publisher, 'incorrect value for: creator')
|
||||
assert(
|
||||
updatedNft.managerRole[0] === publisher,
|
||||
'incorrect value for: managerRole'
|
||||
)
|
||||
assert(
|
||||
updatedNft.erc20DeployerRole[0] === factoryAddress,
|
||||
'incorrect value for: erc20DeployerRole'
|
||||
)
|
||||
assert(
|
||||
updatedNft.storeUpdateRole === null,
|
||||
'incorrect value for: storeUpdateRole'
|
||||
)
|
||||
assert(
|
||||
updatedNft.metadataRole === null,
|
||||
'incorrect value for: metadataRole'
|
||||
)
|
||||
assert(
|
||||
updatedNft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(
|
||||
updatedNft.transferable === true,
|
||||
'incorrect value for: transferable'
|
||||
)
|
||||
assert(
|
||||
updatedNft.createdTimestamp >= time,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(
|
||||
updatedNft.createdTimestamp < time + 5,
|
||||
'incorrect value for: createdTimestamp'
|
||||
)
|
||||
assert(tx.from === publisher, 'incorrect value for: tx')
|
||||
assert(tx.to === factoryAddress, 'incorrect value for: tx')
|
||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||
assert(updatedNft.block >= blockNumber, 'incorrect value for: block')
|
||||
assert(updatedNft.block < blockNumber + 50, 'incorrect value for: block')
|
||||
assert(updatedNft.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(
|
||||
updatedNft.eventIndex !== null && updatedNft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT update'
|
||||
)
|
||||
})
|
||||
|
||||
it('Set a key/value in erc725 store', async () => {
|
||||
await nft.setData(nftAddress, publisher, 'test_key', 'test_value')
|
||||
await sleep(2000)
|
||||
const query = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
nftData{
|
||||
id
|
||||
key
|
||||
value
|
||||
}
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
const updatedNft = (await response.json()).data.nft
|
||||
assert(updatedNft.nftData.key !== null, 'incorrect value for key')
|
||||
assert(
|
||||
updatedNft.eventIndex !== null && updatedNft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT update'
|
||||
)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,515 @@
|
|||
import {
|
||||
Datatoken,
|
||||
DatatokenCreateParams,
|
||||
ProviderInstance,
|
||||
ProviderFees,
|
||||
Nft,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
getHash,
|
||||
sleep,
|
||||
ZERO_ADDRESS,
|
||||
signHash
|
||||
} from '@oceanprotocol/lib'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const providerUrl = 'http://172.15.0.4:8030'
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
const assetUrl = [
|
||||
{
|
||||
type: 'url',
|
||||
url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt',
|
||||
method: 'GET'
|
||||
}
|
||||
]
|
||||
const ddo = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||
version: '4.0.0',
|
||||
chainId: 4,
|
||||
nftAddress: '0x0',
|
||||
metadata: {
|
||||
created: '2021-12-20T14:35:20Z',
|
||||
updated: '2021-12-20T14:35:20Z',
|
||||
type: 'dataset',
|
||||
name: 'dfgdfgdg',
|
||||
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||
tags: [''],
|
||||
author: 'dd',
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
additionalInformation: {
|
||||
termsAndConditions: true
|
||||
}
|
||||
},
|
||||
services: [
|
||||
{
|
||||
id: 'notAnId',
|
||||
type: 'access',
|
||||
files: '',
|
||||
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||
timeout: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
describe('Simple Publish & consume test', async () => {
|
||||
let datatokenAddress: string
|
||||
let datatoken: Datatoken
|
||||
let nft: Nft
|
||||
let Factory: NftFactory
|
||||
let accounts: string[]
|
||||
let publisherAccount: string
|
||||
let newOwnerAccount: string
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
let user4: string
|
||||
|
||||
before(async () => {
|
||||
nft = new Nft(web3)
|
||||
Factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisherAccount = accounts[0]
|
||||
newOwnerAccount = accounts[1].toLowerCase()
|
||||
user1 = accounts[2]
|
||||
user2 = accounts[3]
|
||||
user3 = accounts[4]
|
||||
user4 = accounts[5]
|
||||
})
|
||||
|
||||
it('should publish a dataset (create NFT + ERC20)', async () => {
|
||||
// const consumerAccount = accounts[1]
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'testNFT',
|
||||
symbol: 'TST',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisherAccount
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisherAccount,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||
|
||||
const chain = await web3.eth.getChainId()
|
||||
// create the files encrypted string
|
||||
let providerResponse = await ProviderInstance.encrypt(
|
||||
assetUrl,
|
||||
chain,
|
||||
providerUrl
|
||||
)
|
||||
ddo.services[0].files = await providerResponse
|
||||
ddo.services[0].datatokenAddress = datatokenAddress
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = erc721Address
|
||||
ddo.id =
|
||||
'did:op:' +
|
||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
publisherAccount,
|
||||
0,
|
||||
providerUrl,
|
||||
'',
|
||||
'0x2',
|
||||
encryptedResponse,
|
||||
'0x' + metadataHash
|
||||
)
|
||||
|
||||
// graph tests here
|
||||
await sleep(3000)
|
||||
const graphNftToken = erc721Address.toLowerCase()
|
||||
const query = {
|
||||
query: `query {
|
||||
nft(id:"${graphNftToken}"){symbol,id,eventIndex}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await response.json()
|
||||
assert(queryResult.data.nft.id === graphNftToken)
|
||||
assert(
|
||||
queryResult.data.nft.eventIndex !== null &&
|
||||
queryResult.data.nft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT creation'
|
||||
)
|
||||
})
|
||||
it('should publish and transfer an NFT', async () => {
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'testNFT',
|
||||
symbol: 'TST',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisherAccount
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisherAccount,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
await sleep(3000)
|
||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
const datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||
const graphNftToken = erc721Address.toLowerCase()
|
||||
|
||||
const queryOriginalOwner = {
|
||||
query: `query {
|
||||
nft(id:"${graphNftToken}"){symbol,id,owner{id},eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(queryOriginalOwner)
|
||||
})
|
||||
await sleep(3000)
|
||||
const initialResult = await initialResponse.json()
|
||||
// Checking original owner account has been set correctly
|
||||
assert(
|
||||
initialResult.data.nft.owner.id.toLowerCase() ===
|
||||
publisherAccount.toLowerCase()
|
||||
)
|
||||
assert(
|
||||
initialResult.data.nft.eventIndex !== null &&
|
||||
initialResult.data.nft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT creation'
|
||||
)
|
||||
|
||||
// create the files encrypted string
|
||||
const chain = await web3.eth.getChainId()
|
||||
let providerResponse = await ProviderInstance.encrypt(
|
||||
assetUrl,
|
||||
chain,
|
||||
providerUrl
|
||||
)
|
||||
ddo.services[0].files = await providerResponse
|
||||
ddo.services[0].datatokenAddress = datatokenAddress
|
||||
// update ddo and set the right did
|
||||
ddo.nftAddress = erc721Address
|
||||
ddo.id =
|
||||
'did:op:' +
|
||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
publisherAccount,
|
||||
0,
|
||||
providerUrl,
|
||||
'',
|
||||
'0x2',
|
||||
encryptedResponse,
|
||||
'0x' + metadataHash
|
||||
)
|
||||
await sleep(3000)
|
||||
|
||||
// Transfer the NFT
|
||||
await nft.transferNft(graphNftToken, publisherAccount, newOwnerAccount)
|
||||
await sleep(3000)
|
||||
const query2 = {
|
||||
query: `query {
|
||||
nft(id:"${graphNftToken}"){symbol,id,owner{id}, transferable, eventIndex}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query2)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await response.json()
|
||||
assert(queryResult.data.nft.owner.id === newOwnerAccount)
|
||||
assert(
|
||||
queryResult.data.nft.eventIndex !== null &&
|
||||
queryResult.data.nft.eventIndex > 0,
|
||||
'Invalid eventIndex for NFT creation'
|
||||
)
|
||||
})
|
||||
|
||||
it('should save provider fees after startOrder is called', async () => {
|
||||
datatoken = new Datatoken(web3, 8996)
|
||||
await datatoken.mint(datatokenAddress, publisherAccount, '100', user1)
|
||||
const user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
assert(user1Balance === '100', 'user1 has no datatokens')
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
const providerFeeAmount = '10000'
|
||||
const providerValidUntil = '0'
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
{ t: 'address', v: providerFeeToken },
|
||||
{ t: 'uint256', v: providerFeeAmount },
|
||||
{ t: 'uint256', v: providerValidUntil }
|
||||
)
|
||||
const { v, r, s } = await signHash(web3, message, user3)
|
||||
const setProviderFee: ProviderFees = {
|
||||
providerFeeAddress: user3,
|
||||
providerFeeToken,
|
||||
providerFeeAmount,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
const orderTx = await datatoken.startOrder(
|
||||
datatokenAddress,
|
||||
user1,
|
||||
user2,
|
||||
1,
|
||||
setProviderFee
|
||||
)
|
||||
await sleep(3000)
|
||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user1.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||
1
|
||||
)}`
|
||||
const query = {
|
||||
query: `query {order(id:"${orderId}"){id, providerFee, lastPriceToken{id}, eventIndex}}`
|
||||
}
|
||||
|
||||
await sleep(3000)
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await response.json()
|
||||
|
||||
const providerFeeJSON = JSON.parse(queryResult.data.order.providerFee)
|
||||
const lastPriceToken = queryResult.data.order.lastPriceToken.id
|
||||
|
||||
assert(lastPriceToken === ZERO_ADDRESS, 'Wrong lastPriceToken')
|
||||
|
||||
assert(
|
||||
providerFeeJSON.providerFeeAddress.toLowerCase() ===
|
||||
setProviderFee.providerFeeAddress.toLowerCase(),
|
||||
'Wrong providerFeeAddress set'
|
||||
)
|
||||
assert(
|
||||
providerFeeJSON.providerFeeAmount.toLowerCase() ===
|
||||
setProviderFee.providerFeeAmount.toLowerCase(),
|
||||
'Wrong providerFeeAmount set'
|
||||
)
|
||||
assert(
|
||||
providerFeeJSON.providerFeeToken.toLowerCase() ===
|
||||
setProviderFee.providerFeeToken.toLowerCase(),
|
||||
'Wrong providerFeeToken set'
|
||||
)
|
||||
assert(
|
||||
queryResult.data.order.eventIndex !== null,
|
||||
'Invalid eventIndex for order'
|
||||
)
|
||||
})
|
||||
|
||||
it('should save provider fees after calling reuseOrder on a using a previous txId', async () => {
|
||||
await datatoken.mint(datatokenAddress, publisherAccount, '100', user4)
|
||||
const user4Balance = await datatoken.balance(datatokenAddress, user4)
|
||||
assert(user4Balance === '100', 'publisherAccount has no datatokens')
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
let providerFeeAmount = '90'
|
||||
let providerValidUntil = '0'
|
||||
let message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
{ t: 'address', v: providerFeeToken },
|
||||
{ t: 'uint256', v: providerFeeAmount },
|
||||
{ t: 'uint256', v: providerValidUntil }
|
||||
)
|
||||
let { v, r, s } = await signHash(web3, message, user3)
|
||||
const setInitialProviderFee: ProviderFees = {
|
||||
providerFeeAddress: user3,
|
||||
providerFeeToken,
|
||||
providerFeeAmount,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
|
||||
const orderTx = await datatoken.startOrder(
|
||||
datatokenAddress,
|
||||
user4,
|
||||
user2,
|
||||
1,
|
||||
setInitialProviderFee
|
||||
)
|
||||
assert(orderTx.transactionHash, 'Failed to start order')
|
||||
|
||||
// Check initial provider fee has been set correctly
|
||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user4.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||
1
|
||||
)}`
|
||||
|
||||
const initialQuery = {
|
||||
query: `query {order(id:"${orderId}"){id, providerFee, lastPriceToken{id}, eventIndex}}`
|
||||
}
|
||||
await sleep(3000)
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
await sleep(3000)
|
||||
const initialQueryResult = await initialResponse.json()
|
||||
const initialProviderFeeJSON = JSON.parse(
|
||||
initialQueryResult.data.order.providerFee
|
||||
)
|
||||
const lastPriceToken = initialQueryResult.data.order.lastPriceToken.id
|
||||
|
||||
assert(lastPriceToken === ZERO_ADDRESS, 'Wrong initial lastPriceToken set')
|
||||
assert(
|
||||
initialProviderFeeJSON.providerFeeAddress.toLowerCase() ===
|
||||
setInitialProviderFee.providerFeeAddress.toLowerCase(),
|
||||
'Wrong initial providerFeeAddress set'
|
||||
)
|
||||
assert(
|
||||
initialProviderFeeJSON.providerFeeAmount.toLowerCase() ===
|
||||
setInitialProviderFee.providerFeeAmount.toLowerCase(),
|
||||
'Wrong initial providerFeeAmount set'
|
||||
)
|
||||
assert(
|
||||
initialProviderFeeJSON.providerFeeToken.toLowerCase() ===
|
||||
setInitialProviderFee.providerFeeToken.toLowerCase(),
|
||||
'Wrong initial providerFeeToken set'
|
||||
)
|
||||
assert(
|
||||
initialQueryResult.data.order.eventIndex !== null,
|
||||
'Invalid eventIndex for order'
|
||||
)
|
||||
|
||||
providerFeeAmount = '990000'
|
||||
providerValidUntil = '10000'
|
||||
message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: user3 },
|
||||
{ t: 'address', v: providerFeeToken },
|
||||
{ t: 'uint256', v: providerFeeAmount },
|
||||
{ t: 'uint256', v: providerValidUntil }
|
||||
)
|
||||
const msgResult = await signHash(web3, message, user3)
|
||||
v = msgResult.v
|
||||
r = msgResult.r
|
||||
s = msgResult.s
|
||||
|
||||
const setNewProviderFee: ProviderFees = {
|
||||
providerFeeAddress: user3,
|
||||
providerFeeToken,
|
||||
providerFeeAmount,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
|
||||
const reusedOrder = await datatoken.reuseOrder(
|
||||
datatokenAddress,
|
||||
user4,
|
||||
orderTx.transactionHash,
|
||||
setNewProviderFee
|
||||
)
|
||||
|
||||
assert(reusedOrder.events.OrderReused.event === 'OrderReused')
|
||||
assert(reusedOrder.events.ProviderFee.event === 'ProviderFee')
|
||||
|
||||
sleep(4000)
|
||||
// Check the new provider fee has been set in OrderReuse
|
||||
|
||||
const reuseQuery = {
|
||||
query: `query {orderReuse(id:"${
|
||||
reusedOrder.transactionHash
|
||||
}-${reusedOrder.events.OrderReused.logIndex.toFixed(
|
||||
1
|
||||
)}"){id, providerFee, eventIndex}}`
|
||||
}
|
||||
|
||||
await sleep(2000)
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(reuseQuery)
|
||||
})
|
||||
|
||||
const reuseQueryResult = await response.json()
|
||||
|
||||
const reuseProviderFeeJSON = JSON.parse(
|
||||
reuseQueryResult.data.orderReuse.providerFee
|
||||
)
|
||||
|
||||
assert(
|
||||
reuseProviderFeeJSON.providerFeeAddress.toLowerCase() ===
|
||||
setNewProviderFee.providerFeeAddress.toLowerCase(),
|
||||
'New providerFeeAddress set in reuse order is wrong'
|
||||
)
|
||||
assert(
|
||||
reuseProviderFeeJSON.providerFeeAmount.toLowerCase() ===
|
||||
setNewProviderFee.providerFeeAmount.toLowerCase(),
|
||||
'New providerFeeAmount set in reuse order is wrong'
|
||||
)
|
||||
assert(
|
||||
reuseProviderFeeJSON.providerFeeToken.toLowerCase() ===
|
||||
setNewProviderFee.providerFeeToken.toLowerCase(),
|
||||
'New providerFeeToken set in reuse order is wrong'
|
||||
)
|
||||
assert(
|
||||
reuseQueryResult.data.orderReuse.eventIndex !== null,
|
||||
'Invalid eventIndex for reuse order'
|
||||
)
|
||||
assert(
|
||||
reuseQueryResult.data.orderReuse.eventIndex === 0,
|
||||
'Invalid reuse order event index'
|
||||
)
|
||||
assert(
|
||||
initialQueryResult.data.order.eventIndex === 0,
|
||||
'Invalid start order event index'
|
||||
)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,163 @@
|
|||
import {
|
||||
DatatokenCreateParams,
|
||||
Nft,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
sleep
|
||||
} from '@oceanprotocol/lib'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
describe('Tests coverage without provider/aquarius', async () => {
|
||||
let nft: Nft
|
||||
let Factory: NftFactory
|
||||
let accounts: string[]
|
||||
let publisherAccount: string
|
||||
let newOwnerAccount: string
|
||||
let time: number
|
||||
|
||||
before(async () => {
|
||||
nft = new Nft(web3)
|
||||
Factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
publisherAccount = accounts[0]
|
||||
newOwnerAccount = accounts[1].toLowerCase()
|
||||
const date = new Date()
|
||||
time = Math.floor(date.getTime() / 1000)
|
||||
})
|
||||
|
||||
it('should publish a dataset (create NFT + ERC20)', async () => {
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'testNFT',
|
||||
symbol: 'TST',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisherAccount
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisherAccount,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
|
||||
// graph tests here
|
||||
await sleep(3000)
|
||||
const graphNftToken = erc721Address.toLowerCase()
|
||||
const query = {
|
||||
query: `query {
|
||||
nft(id:"${graphNftToken}"){symbol,id,eventIndex}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await response.json()
|
||||
assert(queryResult.data.nft.id === graphNftToken)
|
||||
assert(
|
||||
queryResult.data.nft.eventIndex !== null &&
|
||||
queryResult.data.nft.eventIndex > 0
|
||||
)
|
||||
})
|
||||
|
||||
it('should publish and transfer an NFT', async () => {
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'testNFT',
|
||||
symbol: 'TST',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisherAccount
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisherAccount,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
await sleep(3000)
|
||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
const nftAddress = erc721Address.toLowerCase()
|
||||
|
||||
// Transfer the NFT
|
||||
const tx = await nft.transferNft(
|
||||
nftAddress,
|
||||
publisherAccount,
|
||||
newOwnerAccount
|
||||
)
|
||||
|
||||
await sleep(3000)
|
||||
const query2 = {
|
||||
query: `query {
|
||||
nft(id:"${nftAddress}"){
|
||||
symbol,
|
||||
id,
|
||||
owner{id},
|
||||
transferable,
|
||||
transferHistory(orderBy: timestamp, orderDirection: desc){id,nft,oldOwner,newOwner,txId,eventIndex,timestamp,block}
|
||||
}}`
|
||||
}
|
||||
const response = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query2)
|
||||
})
|
||||
await sleep(3000)
|
||||
const queryResult = await response.json()
|
||||
const transferHistory = queryResult.data.nft.transferHistory[0]
|
||||
|
||||
assert(queryResult.data.nft.owner.id === newOwnerAccount)
|
||||
assert(
|
||||
transferHistory.id ===
|
||||
`${nftAddress}-${
|
||||
tx.transactionHash
|
||||
}-${tx.events.Transfer.logIndex.toFixed(1)}`,
|
||||
'Invalid transferHistory Id'
|
||||
)
|
||||
assert(transferHistory.txId === tx.transactionHash, 'invalid txId')
|
||||
assert(
|
||||
transferHistory.eventIndex === tx.events.Transfer.logIndex,
|
||||
'invalid eventIndex'
|
||||
)
|
||||
assert(transferHistory.timestamp)
|
||||
|
||||
assert(transferHistory.timestamp >= time - 500, 'incorrect value timestamp')
|
||||
assert(transferHistory.timestamp < time + 500, 'incorrect value timestamp')
|
||||
assert(transferHistory.block === tx.blockNumber, 'blockNumber')
|
||||
})
|
||||
})
|
|
@ -0,0 +1,829 @@
|
|||
import {
|
||||
VeOcean,
|
||||
VeAllocate,
|
||||
NftFactory,
|
||||
calculateEstimatedGas,
|
||||
sendTx,
|
||||
approve,
|
||||
ConfigHelper,
|
||||
sleep,
|
||||
VeFeeDistributor
|
||||
} from '@oceanprotocol/lib'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { HttpProvider } from 'web3-providers-http'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import veDelegation from '@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
const subgraphUrl =
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||
|
||||
function evmMine() {
|
||||
const provider = web3.currentProvider as HttpProvider
|
||||
return new Promise((resolve, reject) => {
|
||||
provider.send(
|
||||
{
|
||||
jsonrpc: '2.0',
|
||||
method: 'evm_mine',
|
||||
id: new Date().getTime()
|
||||
},
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
return reject(error)
|
||||
}
|
||||
return resolve(result)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
function evmIncreaseTime(seconds) {
|
||||
const provider = web3.currentProvider as HttpProvider
|
||||
return new Promise((resolve, reject) => {
|
||||
provider.send(
|
||||
{
|
||||
method: 'evm_increaseTime',
|
||||
params: [seconds],
|
||||
jsonrpc: '2.0',
|
||||
id: new Date().getTime()
|
||||
},
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
return reject(error)
|
||||
}
|
||||
return evmMine().then(() => resolve(result))
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
async function getTotalLockedOcean() {
|
||||
const initialQuery = {
|
||||
query: `query{
|
||||
globalStatistics{
|
||||
totalOceanLocked
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const data = (await initialResponse.json()).data.globalStatistics
|
||||
if (data.length == 0) return 0
|
||||
|
||||
return data[0].totalOceanLocked
|
||||
}
|
||||
const minAbi = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{ name: 'to', type: 'address' },
|
||||
{ name: 'value', type: 'uint256' }
|
||||
],
|
||||
name: 'mint',
|
||||
outputs: [{ name: '', type: 'bool' }],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function'
|
||||
}
|
||||
] as AbiItem[]
|
||||
|
||||
describe('veOcean tests', async () => {
|
||||
let nftFactory
|
||||
let veOcean: VeOcean
|
||||
let delegateContract
|
||||
let veAllocate: VeAllocate
|
||||
let veFeeDistributor: VeFeeDistributor
|
||||
let ownerAccount: string
|
||||
let Alice: string
|
||||
let Bob: string
|
||||
let nft1, nft2, nft3
|
||||
let chainId
|
||||
const configHelper = new ConfigHelper()
|
||||
const config = configHelper.getConfig('development')
|
||||
|
||||
before(async () => {
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
chainId = await web3.eth.getChainId()
|
||||
ownerAccount = accounts[0]
|
||||
Alice = accounts[1]
|
||||
Bob = accounts[2]
|
||||
delegateContract = new web3.eth.Contract(
|
||||
veDelegation.abi as AbiItem[],
|
||||
addresses.veDelegation
|
||||
)
|
||||
|
||||
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||
const estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.mint,
|
||||
Alice,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
Alice,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
Bob,
|
||||
web3.utils.toWei('100000')
|
||||
)
|
||||
veOcean = new VeOcean(addresses.veOCEAN, web3)
|
||||
veAllocate = new VeAllocate(addresses.veAllocate, web3)
|
||||
nftFactory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
veFeeDistributor = new VeFeeDistributor(addresses.veFeeDistributor, web3)
|
||||
})
|
||||
|
||||
it('Alice should lock 100 Ocean', async () => {
|
||||
// since we can only lock once, we test if tx fails or not
|
||||
// so if there is already a lock, skip it
|
||||
const totalOceanLockedBefore = await getTotalLockedOcean()
|
||||
let currentBalance = await veOcean.getLockedAmount(Alice)
|
||||
let currentLock = await veOcean.lockEnd(Alice)
|
||||
const amount = '100'
|
||||
await approve(
|
||||
web3,
|
||||
config,
|
||||
Alice,
|
||||
addresses.Ocean,
|
||||
addresses.veOCEAN,
|
||||
amount
|
||||
)
|
||||
const timestamp = Math.floor(Date.now() / 1000)
|
||||
const unlockTime = timestamp + 7 * 86400
|
||||
|
||||
if (parseInt(currentBalance) > 0 || currentLock > 0) {
|
||||
// we already have some locked tokens, so our transaction should fail
|
||||
try {
|
||||
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||
assert(false, 'This should fail!')
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
} else {
|
||||
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||
}
|
||||
currentBalance = await veOcean.getLockedAmount(Alice)
|
||||
currentLock = await veOcean.lockEnd(Alice)
|
||||
await sleep(2000)
|
||||
const totalOceanLockedAfter = await getTotalLockedOcean()
|
||||
assert(
|
||||
parseFloat(totalOceanLockedAfter) > parseFloat(totalOceanLockedBefore),
|
||||
'After (' +
|
||||
totalOceanLockedAfter +
|
||||
') shold be higher then ' +
|
||||
totalOceanLockedBefore
|
||||
)
|
||||
assert(
|
||||
parseFloat(totalOceanLockedAfter) ==
|
||||
parseFloat(totalOceanLockedBefore + amount),
|
||||
'Invalid totalOceanLockedAfter (' + totalOceanLockedAfter + ')'
|
||||
)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
lockedAmount,
|
||||
unlockTime
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.veOCEANs
|
||||
assert(info[0].id === Alice.toLowerCase())
|
||||
assert(info[0].lockedAmount === currentBalance)
|
||||
assert(info[0].unlockTime === currentLock)
|
||||
})
|
||||
|
||||
it('Alice should increase the lock time', async () => {
|
||||
const currentLock = await veOcean.lockEnd(Alice)
|
||||
const newLock = parseInt(String(currentLock)) + 7 * 86400
|
||||
await veOcean.increaseUnlockTime(Alice, newLock)
|
||||
const newCurrentLock = await veOcean.lockEnd(Alice)
|
||||
await sleep(2000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
lockedAmount,
|
||||
unlockTime
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.veOCEANs
|
||||
assert(
|
||||
info[0].unlockTime === newCurrentLock,
|
||||
'Expected lock ' +
|
||||
newCurrentLock +
|
||||
' to equal subgraph value ' +
|
||||
info[0].unlockTime
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should increase the locked amount', async () => {
|
||||
const amount = '200'
|
||||
await approve(
|
||||
web3,
|
||||
config,
|
||||
Alice,
|
||||
addresses.Ocean,
|
||||
addresses.veOCEAN,
|
||||
amount
|
||||
)
|
||||
await veOcean.increaseAmount(Alice, amount)
|
||||
const newCurrentBalance = await veOcean.getLockedAmount(Alice)
|
||||
const newCurrentLock = await veOcean.lockEnd(Alice)
|
||||
await sleep(2000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
lockedAmount,
|
||||
unlockTime
|
||||
}
|
||||
}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
const info = (await initialResponse.json()).data.veOCEANs
|
||||
assert(
|
||||
info[0].unlockTime === newCurrentLock,
|
||||
'Expected lock ' +
|
||||
newCurrentLock +
|
||||
' to equal subgraph value ' +
|
||||
info[0].unlockTime
|
||||
)
|
||||
assert(
|
||||
info[0].lockedAmount === newCurrentBalance,
|
||||
'Expected balance ' +
|
||||
newCurrentBalance +
|
||||
' to equal subgraph value ' +
|
||||
info[0].lockedAmount
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should publish 3 NFTs', async () => {
|
||||
// publish 3 nfts
|
||||
nft1 = await nftFactory.createNFT(Alice, {
|
||||
name: 'testNft1',
|
||||
symbol: 'TSTF1',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: Alice
|
||||
})
|
||||
nft2 = await nftFactory.createNFT(Alice, {
|
||||
name: 'testNft2',
|
||||
symbol: 'TSTF2',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: Alice
|
||||
})
|
||||
nft3 = await nftFactory.createNFT(Alice, {
|
||||
name: 'testNft3',
|
||||
symbol: 'TSTF3',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: Alice
|
||||
})
|
||||
})
|
||||
|
||||
it('Alice should allocate 10% to NFT1', async () => {
|
||||
const tx = await veAllocate.setAllocation(Alice, '1000', nft1, chainId)
|
||||
const newTotalAllocation = await veAllocate.getTotalAllocation(Alice)
|
||||
await sleep(2000)
|
||||
let initialQuery = {
|
||||
query: `query {
|
||||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
allocatedTotal
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
let initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
let info = (await initialResponse.json()).data.veAllocateUsers
|
||||
assert(
|
||||
info[0].allocatedTotal === newTotalAllocation,
|
||||
'Expected totalAllocation ' +
|
||||
newTotalAllocation +
|
||||
' to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft1.toLowerCase()}"}
|
||||
){
|
||||
id,
|
||||
allocated,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
info = (await initialResponse.json()).data.veAllocations
|
||||
assert(
|
||||
info[0].allocated === '1000',
|
||||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||
})
|
||||
|
||||
it('Alice should allocate 10% to NFT2 and 20% to NFT3', async () => {
|
||||
const tx = await veAllocate.setBatchAllocation(
|
||||
Alice,
|
||||
['1000', '2000'],
|
||||
[nft2, nft3],
|
||||
[chainId, chainId]
|
||||
)
|
||||
const totalAllocation = await veAllocate.getTotalAllocation(Alice)
|
||||
|
||||
await sleep(2000)
|
||||
let initialQuery = {
|
||||
query: `query {
|
||||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
allocatedTotal,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
let initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
let info = (await initialResponse.json()).data.veAllocateUsers
|
||||
assert(
|
||||
info[0].allocatedTotal === totalAllocation,
|
||||
'Expected totalAllocation ' +
|
||||
totalAllocation +
|
||||
' to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft2.toLowerCase()}"}
|
||||
){
|
||||
id,
|
||||
allocated,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
info = (await initialResponse.json()).data.veAllocations
|
||||
assert(
|
||||
info[0].allocated === '1000',
|
||||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft3.toLowerCase()}"}
|
||||
){
|
||||
id,
|
||||
allocated
|
||||
}
|
||||
}`
|
||||
}
|
||||
initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
info = (await initialResponse.json()).data.veAllocations
|
||||
assert(
|
||||
info[0].allocated === '2000',
|
||||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should advance chain one day', async () => {
|
||||
await evmIncreaseTime(60 * 60 * 24)
|
||||
})
|
||||
|
||||
it('Alice should add ocean rewards to feeDistrib', async () => {
|
||||
// mint 10 ocean and send them to feeDistrib
|
||||
let tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||
let estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.mint,
|
||||
addresses.veFeeDistributor,
|
||||
web3.utils.toWei('10')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
addresses.veFeeDistributor,
|
||||
web3.utils.toWei('10')
|
||||
)
|
||||
const minAbiFee = [
|
||||
{
|
||||
name: 'checkpoint_token',
|
||||
outputs: [],
|
||||
inputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
gas: 820723
|
||||
},
|
||||
{
|
||||
name: 'checkpoint_total_supply',
|
||||
outputs: [],
|
||||
inputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
gas: 10592405
|
||||
}
|
||||
] as AbiItem[]
|
||||
tokenContract = new web3.eth.Contract(minAbiFee, addresses.veFeeDistributor)
|
||||
estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.checkpoint_token
|
||||
)
|
||||
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.checkpoint_token
|
||||
)
|
||||
estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.checkpoint_total_supply
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.checkpoint_total_supply
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should advance chain 7 day', async () => {
|
||||
await evmIncreaseTime(60 * 60 * 24 * 7)
|
||||
})
|
||||
|
||||
it('Alice should add again ocean rewards to feeDistrib', async () => {
|
||||
// mint 20 ocean and send them to feeDistrib
|
||||
let tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||
let estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.mint,
|
||||
addresses.veFeeDistributor,
|
||||
web3.utils.toWei('20')
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.mint,
|
||||
addresses.veFeeDistributor,
|
||||
web3.utils.toWei('20')
|
||||
)
|
||||
const minAbiFee = [
|
||||
{
|
||||
name: 'checkpoint_token',
|
||||
outputs: [],
|
||||
inputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
gas: 820723
|
||||
},
|
||||
{
|
||||
name: 'checkpoint_total_supply',
|
||||
outputs: [],
|
||||
inputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
gas: 10592405
|
||||
}
|
||||
] as AbiItem[]
|
||||
tokenContract = new web3.eth.Contract(minAbiFee, addresses.veFeeDistributor)
|
||||
estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.checkpoint_token
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.checkpoint_token
|
||||
)
|
||||
estGas = await calculateEstimatedGas(
|
||||
ownerAccount,
|
||||
tokenContract.methods.checkpoint_total_supply
|
||||
)
|
||||
await sendTx(
|
||||
ownerAccount,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
tokenContract.methods.checkpoint_total_supply
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should advance chain 7 day', async () => {
|
||||
await evmIncreaseTime(60 * 60 * 24 * 7)
|
||||
})
|
||||
|
||||
it('Alice should claim rewards', async () => {
|
||||
await veFeeDistributor.claim(Alice)
|
||||
})
|
||||
it('Alice should withdraw locked tokens', async () => {
|
||||
await evmIncreaseTime(60 * 60 * 24 * 7)
|
||||
const totalOceanLockedBefore = await getTotalLockedOcean()
|
||||
await veOcean.withdraw(Alice)
|
||||
await sleep(2000)
|
||||
const totalOceanLockedAfter = await getTotalLockedOcean()
|
||||
assert(
|
||||
parseFloat(totalOceanLockedAfter) < parseFloat(totalOceanLockedBefore),
|
||||
'After (' +
|
||||
totalOceanLockedAfter +
|
||||
') shold be lower then ' +
|
||||
totalOceanLockedBefore
|
||||
)
|
||||
})
|
||||
|
||||
it('Alice should lock 100 Ocean and Delegate them to Bob', async () => {
|
||||
// since we can only lock once, we test if tx fails or not
|
||||
// so if there is already a lock, skip it
|
||||
let currentBalance = await veOcean.getLockedAmount(Alice)
|
||||
let currentLock = await veOcean.lockEnd(Alice)
|
||||
const amount = '100'
|
||||
await approve(
|
||||
web3,
|
||||
config,
|
||||
Alice,
|
||||
addresses.Ocean,
|
||||
addresses.veOCEAN,
|
||||
amount
|
||||
)
|
||||
const timestamp = Math.floor(Date.now() / 1000)
|
||||
const unlockTime = timestamp + 30 * 86400
|
||||
|
||||
if (parseInt(currentBalance) > 0 || currentLock > 0) {
|
||||
// we already have some locked tokens, so our transaction should fail
|
||||
try {
|
||||
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||
assert(false, 'This should fail!')
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
} else {
|
||||
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||
}
|
||||
currentBalance = await veOcean.getLockedAmount(Alice)
|
||||
currentLock = await veOcean.lockEnd(Alice)
|
||||
await sleep(2000)
|
||||
const initialQuery = {
|
||||
query: `query {
|
||||
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
lockedAmount,
|
||||
unlockTime
|
||||
}
|
||||
}`
|
||||
}
|
||||
await sleep(2000)
|
||||
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(initialQuery)
|
||||
})
|
||||
await sleep(2000)
|
||||
const info = (await initialResponse.json()).data.veOCEANs
|
||||
assert(info[0].id === Alice.toLowerCase(), 'ID is incorrect')
|
||||
assert(info[0].lockedAmount === currentBalance, 'LockedAmount is incorrect')
|
||||
assert(info[0].unlockTime === currentLock, 'Unlock time is not correct')
|
||||
|
||||
const lockTime = await veOcean.lockEnd(Alice)
|
||||
const extLockTime = Number(lockTime) + 31556926
|
||||
|
||||
await delegateContract.methods.setApprovalForAll(Alice, true).send({
|
||||
from: Alice
|
||||
})
|
||||
|
||||
await veOcean.increaseUnlockTime(Alice, extLockTime)
|
||||
|
||||
const initalBoostExpiry = extLockTime - 100000
|
||||
let estGas = await calculateEstimatedGas(
|
||||
Alice,
|
||||
delegateContract.methods.create_boost,
|
||||
Alice,
|
||||
Bob,
|
||||
5000,
|
||||
0,
|
||||
initalBoostExpiry,
|
||||
0
|
||||
)
|
||||
|
||||
const tx3 = await sendTx(
|
||||
Alice,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
delegateContract.methods.create_boost,
|
||||
Alice,
|
||||
Bob,
|
||||
5000,
|
||||
0,
|
||||
initalBoostExpiry,
|
||||
0
|
||||
)
|
||||
|
||||
assert(tx3, 'Transaction failed')
|
||||
assert(tx3.events.DelegateBoost, 'No Delegate boost event')
|
||||
const tokenId = tx3.events.DelegateBoost.returnValues._token_id
|
||||
await evmIncreaseTime(60)
|
||||
// extend boost
|
||||
estGas = await calculateEstimatedGas(
|
||||
Alice,
|
||||
delegateContract.methods.extend_boost,
|
||||
tokenId,
|
||||
10000,
|
||||
extLockTime,
|
||||
0
|
||||
)
|
||||
|
||||
const tx4 = await sendTx(
|
||||
Alice,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
delegateContract.methods.extend_boost,
|
||||
tokenId,
|
||||
10000,
|
||||
extLockTime,
|
||||
0
|
||||
)
|
||||
|
||||
assert(tx4, 'Transaction failed')
|
||||
assert(tx4.events.ExtendBoost, 'No ExtendBoost event')
|
||||
await evmIncreaseTime(60)
|
||||
// burn it
|
||||
estGas = await calculateEstimatedGas(
|
||||
Alice,
|
||||
delegateContract.methods.cancel_boost,
|
||||
tokenId
|
||||
)
|
||||
|
||||
const tx5 = await sendTx(
|
||||
Alice,
|
||||
estGas,
|
||||
web3,
|
||||
1,
|
||||
delegateContract.methods.cancel_boost,
|
||||
tokenId
|
||||
)
|
||||
|
||||
assert(tx5, 'Transaction failed')
|
||||
assert(tx5.events.BurnBoost, 'No BurnBoost event')
|
||||
|
||||
await sleep(3000)
|
||||
const delegateQuery = {
|
||||
query: `query{
|
||||
veDelegations(where:{delegator:"${Alice.toLowerCase()}"}){
|
||||
id
|
||||
delegator {
|
||||
id
|
||||
}
|
||||
receiver{
|
||||
id
|
||||
}
|
||||
amount
|
||||
tokenId
|
||||
cancelTime
|
||||
expireTime
|
||||
updates(orderBy:timestamp orderDirection:asc){
|
||||
id
|
||||
block
|
||||
timestamp
|
||||
tx
|
||||
eventIndex
|
||||
sender
|
||||
amount
|
||||
cancelTime
|
||||
expireTime
|
||||
type
|
||||
}
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
||||
const delegateResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(delegateQuery)
|
||||
})
|
||||
const resp = await delegateResponse.json()
|
||||
const delegations = resp.data.veDelegations
|
||||
|
||||
assert(delegations.length > 0, 'No veDelegations')
|
||||
assert(
|
||||
delegations[0].tokenId.toLowerCase() ==
|
||||
tx3.events.DelegateBoost.returnValues._token_id.toLowerCase(),
|
||||
'Invalid tokenID'
|
||||
)
|
||||
assert(delegations[0].amount == '0', 'Invalid amount, should be 0')
|
||||
assert(delegations[0].updates.length > 0, 'No updates')
|
||||
// check updates. first is create boost
|
||||
assert(
|
||||
delegations[0].updates[0].type == 0,
|
||||
'Invalid type. should be createBoost'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[0].cancelTime ==
|
||||
tx3.events.DelegateBoost.returnValues._cancel_time,
|
||||
'Invalid cancelTime'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[0].expireTime ==
|
||||
tx3.events.DelegateBoost.returnValues._expire_time,
|
||||
'Invalid expireTime'
|
||||
)
|
||||
assert(
|
||||
web3.utils.toWei(delegations[0].updates[0].amount) ==
|
||||
tx3.events.DelegateBoost.returnValues._amount,
|
||||
'Invalid amount'
|
||||
)
|
||||
// check extend boos update
|
||||
assert(
|
||||
delegations[0].updates[1].type == 1,
|
||||
'Invalid type. should be extend Boost'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[1].cancelTime ==
|
||||
tx4.events.ExtendBoost.returnValues._cancel_time,
|
||||
'Invalid cancelTime for extend boost'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[1].expireTime ==
|
||||
tx4.events.ExtendBoost.returnValues._expire_time,
|
||||
'Invalid expireTime for extend boost'
|
||||
)
|
||||
assert(
|
||||
web3.utils.toWei(delegations[0].updates[1].amount) ==
|
||||
tx4.events.ExtendBoost.returnValues._amount,
|
||||
'Invalid amount for extend boost'
|
||||
)
|
||||
// check burn
|
||||
assert(delegations[0].updates[2].type == 2, 'Invalid type. should be burn')
|
||||
})
|
||||
})
|
|
@ -19,8 +19,8 @@ describe('Ending tests', () => {
|
|||
let result: any
|
||||
let lastblock
|
||||
it('Get Graph status', async () => {
|
||||
await sleep(1000) // let graph ingest our last transactions
|
||||
lastblock = await web3.eth.getBlockNumber()
|
||||
await sleep(3000) // let graph ingest our last transactions
|
||||
const query = {
|
||||
query: `query {
|
||||
_meta{hasIndexingErrors,
|
||||
|
@ -36,10 +36,10 @@ describe('Ending tests', () => {
|
|||
result = await response.json()
|
||||
})
|
||||
|
||||
it('Make sure that graph has no sync errors', async () => {
|
||||
it('Make sure that graph has no index errors', async () => {
|
||||
assert(result.data._meta.hasIndexingErrors == false)
|
||||
})
|
||||
it('Make sure that graph has synced to last block', async () => {
|
||||
assert(result.data._meta.block.number === lastblock)
|
||||
assert(result.data._meta.block.number >= lastblock)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "node",
|
||||
"lib": ["es2017", "es6", "es7", "dom"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"removeComments": true,
|
||||
"experimentalDecorators": true,
|
||||
"preserveConstEnums": true,
|
||||
"typeRoots": ["../node_modules/@types"],
|
||||
"types": ["...", "@types/mocha"],
|
||||
}
|
||||
}
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "node",
|
||||
"lib": ["es2017", "es6", "es7", "dom"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"removeComments": true,
|
||||
"experimentalDecorators": true,
|
||||
"preserveConstEnums": true,
|
||||
"typeRoots": ["../node_modules/@types"],
|
||||
"types": ["...", "@types/mocha"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
import {
|
||||
DatatokenCreateParams,
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
sleep,
|
||||
FreCreationParams,
|
||||
ZERO_ADDRESS,
|
||||
FixedRateExchange,
|
||||
Datatoken,
|
||||
ProviderFees,
|
||||
signHash
|
||||
} from '@oceanprotocol/lib'
|
||||
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import { assert } from 'chai'
|
||||
import Web3 from 'web3'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { fetch } from 'cross-fetch'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
|
||||
const sleepMs = 1700
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
process.env.ADDRESS_FILE ||
|
||||
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
async function userQuery(user: string) {
|
||||
const query = {
|
||||
query: `query {
|
||||
user(id:"${user}"){
|
||||
id
|
||||
tokenBalancesOwned {id}
|
||||
orders {id, lastPriceToken{id}}
|
||||
freSwaps {id}
|
||||
totalOrders
|
||||
totalSales
|
||||
__typename
|
||||
}}`
|
||||
}
|
||||
const response = await fetch(
|
||||
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query)
|
||||
}
|
||||
)
|
||||
const data = (await response.json()).data.user
|
||||
return data
|
||||
}
|
||||
|
||||
const addresses = data.development
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('User tests', async () => {
|
||||
const nftName = 'test-Fixed-Price-NFT'
|
||||
const nftSymbol = 'TST-FIXED'
|
||||
const tokenURI = 'https://oceanprotocol.com/nft/fixed'
|
||||
const cap = '10000'
|
||||
const feeAmount = '0.2'
|
||||
const price = '3'
|
||||
const publishMarketSwapFee = '0.003'
|
||||
const templateIndex = 1
|
||||
const dtAmount = '10'
|
||||
// const datatoken = new Datatoken(web3, 8996)
|
||||
let datatokenAddress: string
|
||||
let fixedRateAddress: string
|
||||
let baseTokenAddress: string
|
||||
let feeAddress: string
|
||||
let Factory: NftFactory
|
||||
let factoryAddress: string
|
||||
let accounts: string[]
|
||||
let contractDeployer: string
|
||||
let publisher: string
|
||||
let exchangeId: string
|
||||
let fixedRate: FixedRateExchange
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
|
||||
before(async () => {
|
||||
factoryAddress = addresses.ERC721Factory.toLowerCase()
|
||||
fixedRateAddress = addresses.FixedPrice.toLowerCase()
|
||||
baseTokenAddress = addresses.MockDAI.toLowerCase()
|
||||
Factory = new NftFactory(factoryAddress, web3)
|
||||
accounts = await web3.eth.getAccounts()
|
||||
contractDeployer = accounts[0].toLowerCase()
|
||||
feeAddress = accounts[1].toLowerCase()
|
||||
// Using different accounts from other tests to ensure that all user fields start at null
|
||||
publisher = accounts[6].toLowerCase()
|
||||
user1 = accounts[7].toLowerCase()
|
||||
user2 = accounts[8].toLowerCase()
|
||||
user3 = accounts[9].toLowerCase()
|
||||
})
|
||||
|
||||
it('Deploying a Fixed Rate Exchange & Test User Fields', async () => {
|
||||
const nftParams: NftCreateData = {
|
||||
name: nftName,
|
||||
symbol: nftSymbol,
|
||||
templateIndex: 1,
|
||||
tokenURI,
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap,
|
||||
feeAmount,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisher,
|
||||
mpFeeAddress: feeAddress
|
||||
}
|
||||
const fixedRateParams: FreCreationParams = {
|
||||
fixedRateAddress,
|
||||
baseTokenAddress,
|
||||
owner: publisher,
|
||||
marketFeeCollector: feeAddress,
|
||||
baseTokenDecimals: 18,
|
||||
datatokenDecimals: 18,
|
||||
fixedRate: price,
|
||||
marketFee: publishMarketSwapFee,
|
||||
allowedConsumer: ZERO_ADDRESS,
|
||||
withMint: true
|
||||
}
|
||||
|
||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params,
|
||||
fixedRateParams
|
||||
)
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||
|
||||
exchangeId =
|
||||
result.events.NewFixedRate.returnValues.exchangeId.toLowerCase()
|
||||
|
||||
// Check User values
|
||||
await sleep(sleepMs)
|
||||
const user = await userQuery(publisher)
|
||||
|
||||
assert(user.id === publisher, 'incorrect value for: id')
|
||||
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
||||
assert(user.orders.length === 0, 'incorrect value for: orders')
|
||||
assert(user.freSwaps.length === 0, 'incorrect value for: freSwaps')
|
||||
assert(user.totalOrders === '0', 'incorrect value for: totalOrders')
|
||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||
})
|
||||
|
||||
it('User1 buys a datatoken', async () => {
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
// Mint datatokens as initial supply is 0
|
||||
await datatoken.mint(datatokenAddress, publisher, '100')
|
||||
await datatoken.approve(
|
||||
datatokenAddress,
|
||||
fixedRateAddress,
|
||||
'100',
|
||||
publisher
|
||||
)
|
||||
|
||||
const daiContract = new web3.eth.Contract(
|
||||
MockERC20.abi as AbiItem[],
|
||||
addresses.MockDAI
|
||||
)
|
||||
// user1 need DAI so that they can buy the datatoken
|
||||
await daiContract.methods
|
||||
.transfer(user1, web3.utils.toWei('100'))
|
||||
.send({ from: contractDeployer })
|
||||
await daiContract.methods
|
||||
.approve(fixedRateAddress, web3.utils.toWei('10000000'))
|
||||
.send({ from: user1 })
|
||||
|
||||
// user1 has no DTs before buying one
|
||||
let user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
assert(user1Balance === '0', 'incorrect value for: user1Balance')
|
||||
|
||||
fixedRate = new FixedRateExchange(fixedRateAddress, web3, 8996)
|
||||
await fixedRate.buyDatatokens(user1, exchangeId, dtAmount, '100')
|
||||
await sleep(sleepMs)
|
||||
|
||||
user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
// user1 has 1 datatoken
|
||||
assert(user1Balance === dtAmount, 'incorrect value for: user1Balance')
|
||||
|
||||
// Check User values
|
||||
const user = await userQuery(user1)
|
||||
|
||||
assert(user.id === user1, 'incorrect value for: id')
|
||||
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
||||
assert(user.orders.length === 0, 'incorrect value for: orders')
|
||||
assert(user.freSwaps.length === 1, 'incorrect value for: freSwaps')
|
||||
assert(user.totalOrders === '0', 'incorrect value for: totalOrders')
|
||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||
})
|
||||
it('Check user fields after publishing & ordering a datatoken', async () => {
|
||||
// Start with publishing a new datatoken
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'newNFT',
|
||||
symbol: 'newTST',
|
||||
templateIndex,
|
||||
tokenURI: '',
|
||||
transferable: true,
|
||||
owner: publisher
|
||||
}
|
||||
const erc20Params: DatatokenCreateParams = {
|
||||
templateIndex,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisher,
|
||||
mpFeeAddress: feeAddress
|
||||
}
|
||||
const result = await Factory.createNftWithDatatoken(
|
||||
publisher,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const newDtAddress = result.events.TokenCreated.returnValues[0]
|
||||
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
await datatoken.mint(newDtAddress, publisher, '100', user3)
|
||||
const user1balance = await datatoken.balance(newDtAddress, user3)
|
||||
assert(Number(user1balance) === 100, 'Invalid user1 balance')
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerFeeToken = ZERO_ADDRESS
|
||||
const providerFeeAmount = '10000'
|
||||
const providerValidUntil = '0'
|
||||
const message = web3.utils.soliditySha3(
|
||||
{ t: 'bytes', v: web3.utils.toHex(web3.utils.asciiToHex(providerData)) },
|
||||
{ t: 'address', v: feeAddress },
|
||||
{ t: 'address', v: providerFeeToken },
|
||||
{ t: 'uint256', v: providerFeeAmount },
|
||||
{ t: 'uint256', v: providerValidUntil }
|
||||
)
|
||||
assert(message, 'Invalid message')
|
||||
const { v, r, s } = await signHash(web3, message, feeAddress)
|
||||
const setProviderFee: ProviderFees = {
|
||||
providerFeeAddress: feeAddress,
|
||||
providerFeeToken,
|
||||
providerFeeAmount,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
assert(setProviderFee, 'Invalid setProviderFee')
|
||||
const orderTx = await datatoken.startOrder(
|
||||
newDtAddress,
|
||||
user3,
|
||||
user2,
|
||||
1,
|
||||
setProviderFee
|
||||
)
|
||||
assert(orderTx.events.OrderStarted, 'Invalid orderTx')
|
||||
|
||||
await sleep(2000)
|
||||
|
||||
const user = await userQuery(user3)
|
||||
assert(user.id === user3, 'incorrect value for: id')
|
||||
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
||||
assert(user.orders.length === 1, 'incorrect value for: orders')
|
||||
assert(user.freSwaps.length === 0, 'incorrect value for: freSwaps')
|
||||
assert(user.totalOrders === '1', 'incorrect value for: totalOrders')
|
||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||
assert(
|
||||
user.orders[0].lastPriceToken.id === ZERO_ADDRESS,
|
||||
'incorrect value for: lastPriceToken'
|
||||
)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue