Ci/generate tranches (#401)
* ci: generate tranches * some tidying * first run done locally * ignore auto generated files for linting * fix ignore
This commit is contained in:
parent
04a9ef4ada
commit
b10432fdf3
35
.github/workflows/process-tranches.yml
vendored
Normal file
35
.github/workflows/process-tranches.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Generate tranches
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 8 * * *'
|
||||
|
||||
jobs:
|
||||
master:
|
||||
name: Generate Queries
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Use Node.js 16
|
||||
id: Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16.14.0
|
||||
- name: Install root dependencies
|
||||
run: yarn install
|
||||
- name: Generate queries
|
||||
run: node ./scripts/get-tranches.js
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: queries
|
||||
path: ./queries.graphql
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: 'chore: update tranches'
|
||||
commit_options: '--no-verify --signoff'
|
||||
skip_fetch: true
|
||||
skip_checkout: true
|
@ -3,3 +3,9 @@
|
||||
/dist
|
||||
/coverage
|
||||
__generated__
|
||||
|
||||
apps/static/src/assets/devnet-tranches.json
|
||||
apps/static/src/assets/mainnet-tranches.json
|
||||
apps/static/src/assets/stagnet1-tranches.json
|
||||
apps/static/src/assets/stagnet2-tranches.json
|
||||
apps/static/src/assets/testnet-tranches.json
|
||||
|
1
apps/static/src/assets/devnet-tranches.json
Normal file
1
apps/static/src/assets/devnet-tranches.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
96386
apps/static/src/assets/mainnet-tranches.json
Normal file
96386
apps/static/src/assets/mainnet-tranches.json
Normal file
File diff suppressed because it is too large
Load Diff
272
apps/static/src/assets/stagnet1-tranches.json
Normal file
272
apps/static/src/assets/stagnet1-tranches.json
Normal file
@ -0,0 +1,272 @@
|
||||
[
|
||||
{
|
||||
"tranche_id": 4,
|
||||
"tranche_start": "2021-05-15T09:09:30.000Z",
|
||||
"tranche_end": "2022-05-15T09:09:30.000Z",
|
||||
"total_added": "100",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "0",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"tx": "0xaf36ffbe4a40813ef0f778054f78aa0a506211a56e976193fb046571995cc76a"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"tranche_id": 4,
|
||||
"tx": "0xaf36ffbe4a40813ef0f778054f78aa0a506211a56e976193fb046571995cc76a"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "100"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tranche_id": 5,
|
||||
"tranche_start": "2021-11-26T13:48:10.000Z",
|
||||
"tranche_end": "2022-11-26T13:48:10.000Z",
|
||||
"total_added": "100",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "53.17257102993405",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xaA383f95fa88e979e7de91B37433a38B293b7432",
|
||||
"tx": "0x8f97b9e33af057e155f3d745cefe43ee2408f0ae8df89ecbc2d4dedbd1389114"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0xaA383f95fa88e979e7de91B37433a38B293b7432",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xaA383f95fa88e979e7de91B37433a38B293b7432",
|
||||
"tranche_id": 5,
|
||||
"tx": "0x8f97b9e33af057e155f3d745cefe43ee2408f0ae8df89ecbc2d4dedbd1389114"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "100"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tranche_id": 1,
|
||||
"tranche_start": "1970-01-01T00:00:00.000Z",
|
||||
"tranche_end": "1970-01-01T00:00:00.000Z",
|
||||
"total_added": "11200",
|
||||
"total_removed": "10100",
|
||||
"locked_amount": "0",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "600",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tx": "0xbcccc6382d70694e48c342c00b52422a1594be74cedf18dcf0f76d1049484868"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tx": "0xf1902e5ef53e51dfd8b8c95babd22118c3c3818d6ca775530885808ab2125eb9"
|
||||
},
|
||||
{
|
||||
"amount": "500",
|
||||
"user": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"tx": "0xde7f73f9c46a83796467a12987a2946dea081124483bc3477ca8e0596c03421e"
|
||||
},
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x7382EF0cDb0168D9c1106Efbc43e8a12fB6106cB",
|
||||
"tx": "0xfaf9be231e81948888804534a2f1869e270086583570f3c802507f9e9388d238"
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tx": "0x3ca0e398ef7d33731d65f4de0c73c24a5dd3604a959d58553bebcae166dc24cc"
|
||||
},
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x7382EF0cDb0168D9c1106Efbc43e8a12fB6106cB",
|
||||
"tx": "0x00ca6784af8d8674d4cc418abb3aab601efa0e2968720610b0094c84366bf5a7"
|
||||
}
|
||||
],
|
||||
"users": [
|
||||
{
|
||||
"address": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "600",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tranche_id": 1,
|
||||
"tx": "0xbcccc6382d70694e48c342c00b52422a1594be74cedf18dcf0f76d1049484868"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "600",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "600"
|
||||
},
|
||||
{
|
||||
"address": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tranche_id": 1,
|
||||
"tx": "0xf1902e5ef53e51dfd8b8c95babd22118c3c3818d6ca775530885808ab2125eb9"
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x3ca0e398ef7d33731d65f4de0c73c24a5dd3604a959d58553bebcae166dc24cc"
|
||||
}
|
||||
],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "100",
|
||||
"remaining_tokens": "0"
|
||||
},
|
||||
{
|
||||
"address": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "500",
|
||||
"user": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"tranche_id": 1,
|
||||
"tx": "0xde7f73f9c46a83796467a12987a2946dea081124483bc3477ca8e0596c03421e"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "500",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "500"
|
||||
},
|
||||
{
|
||||
"address": "0x7382EF0cDb0168D9c1106Efbc43e8a12fB6106cB",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x7382EF0cDb0168D9c1106Efbc43e8a12fB6106cB",
|
||||
"tranche_id": 1,
|
||||
"tx": "0xfaf9be231e81948888804534a2f1869e270086583570f3c802507f9e9388d238"
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x7382EF0cDb0168D9c1106Efbc43e8a12fB6106cB",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x00ca6784af8d8674d4cc418abb3aab601efa0e2968720610b0094c84366bf5a7"
|
||||
}
|
||||
],
|
||||
"total_tokens": "10000",
|
||||
"withdrawn_tokens": "10000",
|
||||
"remaining_tokens": "0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tranche_id": 2,
|
||||
"tranche_start": "2033-05-18T03:33:20.000Z",
|
||||
"tranche_end": "2033-05-18T03:33:20.000Z",
|
||||
"total_added": "600",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "600",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tx": "0x1de2c1884b96c2f58930cc08e0eb2739abedeea4527943cd4989310415e142ed"
|
||||
},
|
||||
{
|
||||
"amount": "500",
|
||||
"user": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"tx": "0x54b0c591f9582767aaa3ea9661ed65bbe4ba5cacc66f292b4978fd3b93dec8e6"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xAbEbf1f93aA8C80fB38C896c9a76e266A8EB1d99",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x1de2c1884b96c2f58930cc08e0eb2739abedeea4527943cd4989310415e142ed"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "100"
|
||||
},
|
||||
{
|
||||
"address": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "500",
|
||||
"user": "0x58F0F575eFA3De140aaEDcbffe31B724994e2ec6",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x54b0c591f9582767aaa3ea9661ed65bbe4ba5cacc66f292b4978fd3b93dec8e6"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "500",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "500"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tranche_id": 3,
|
||||
"tranche_start": "2021-10-12T00:53:20.000Z",
|
||||
"tranche_end": "2022-10-12T00:53:20.000Z",
|
||||
"total_added": "100",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "40.69638508371385",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"tx": "0xf3a97d073a229b78b0dfacb6b24d6eb2fc89d79dc003bff114c1d205705f880b"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0xFc00fa2A8B7f0D85a39e101B985a74e83f5c8980",
|
||||
"tranche_id": 3,
|
||||
"tx": "0xf3a97d073a229b78b0dfacb6b24d6eb2fc89d79dc003bff114c1d205705f880b"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
13
apps/static/src/assets/stagnet2-tranches.json
Normal file
13
apps/static/src/assets/stagnet2-tranches.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"tranche_id": 1,
|
||||
"tranche_start": "2022-02-04T14:08:37.000Z",
|
||||
"tranche_end": "2023-02-04T14:08:37.000Z",
|
||||
"total_added": "0",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "0",
|
||||
"deposits": [],
|
||||
"withdrawals": [],
|
||||
"users": []
|
||||
}
|
||||
]
|
110
apps/static/src/assets/testnet-tranches.json
Normal file
110
apps/static/src/assets/testnet-tranches.json
Normal file
@ -0,0 +1,110 @@
|
||||
[
|
||||
{
|
||||
"tranche_id": 1,
|
||||
"tranche_start": "2033-05-18T03:33:20.000Z",
|
||||
"tranche_end": "2033-05-18T03:33:20.000Z",
|
||||
"total_added": "17510",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "17510",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "1555",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tx": "0x5234601be5b86d66fa8ca90d0ccdf97ff6ed8c910f0b42d28c44fabf8fec8f82"
|
||||
},
|
||||
{
|
||||
"amount": "15855",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tx": "0x027b115dd905705464754f1d880b4466a80940a48229a184fe8c5a6c37f665f6"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0x5b0F5e691A6a22493e922FEa7b6E5f079dd54B45",
|
||||
"tx": "0x1d210f5d6b96bdc37987355af034cff5e2f976a84a57fa82ce31ee05509556e8"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "1555",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x5234601be5b86d66fa8ca90d0ccdf97ff6ed8c910f0b42d28c44fabf8fec8f82"
|
||||
},
|
||||
{
|
||||
"amount": "15855",
|
||||
"user": "0x9804C6E98dA75e3271ccE3aA56728FD8e9376155",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x027b115dd905705464754f1d880b4466a80940a48229a184fe8c5a6c37f665f6"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "17410",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "17410"
|
||||
},
|
||||
{
|
||||
"address": "0x5b0F5e691A6a22493e922FEa7b6E5f079dd54B45",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "100",
|
||||
"user": "0x5b0F5e691A6a22493e922FEa7b6E5f079dd54B45",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x1d210f5d6b96bdc37987355af034cff5e2f976a84a57fa82ce31ee05509556e8"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "100",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "100"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tranche_id": 2,
|
||||
"tranche_start": "2021-10-12T00:53:20.000Z",
|
||||
"tranche_end": "2022-10-12T00:53:20.000Z",
|
||||
"total_added": "0",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "0",
|
||||
"deposits": [],
|
||||
"withdrawals": [],
|
||||
"users": []
|
||||
},
|
||||
{
|
||||
"tranche_id": 3,
|
||||
"tranche_start": "2021-05-15T09:09:30.000Z",
|
||||
"tranche_end": "2022-05-15T09:09:30.000Z",
|
||||
"total_added": "10000",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "0",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x1FF32F8A5895DAcdcC0Fe8bC6dDAa7D2c7717f3e",
|
||||
"tx": "0x085994c06447bb8ed4b305a5fa5485e38e34b0347a40ee4a66233c8151fac0be"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"users": [
|
||||
{
|
||||
"address": "0x1FF32F8A5895DAcdcC0Fe8bC6dDAa7D2c7717f3e",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "10000",
|
||||
"user": "0x1FF32F8A5895DAcdcC0Fe8bC6dDAa7D2c7717f3e",
|
||||
"tranche_id": 3,
|
||||
"tx": "0x085994c06447bb8ed4b305a5fa5485e38e34b0347a40ee4a66233c8151fac0be"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "10000",
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "10000"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
992
scripts/get-tranches.js
Normal file
992
scripts/get-tranches.js
Normal file
@ -0,0 +1,992 @@
|
||||
const ethers = require('ethers');
|
||||
const BigNumber = require('bignumber.js');
|
||||
const uniq = require('lodash/uniq');
|
||||
const fs = require('fs');
|
||||
|
||||
const MAX_ATTEMPTS = 5;
|
||||
|
||||
const CONFIG = [
|
||||
{
|
||||
env: 'mainnet',
|
||||
contract: '0x23d1bfe8fa50a167816fbd79d7932577c06011f4',
|
||||
provider: 'https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
startBlock: 12834524,
|
||||
},
|
||||
{
|
||||
env: 'testnet',
|
||||
contract: '0xe2deBB240b43EDfEBc9c38B67c0894B9A92Bf07c',
|
||||
provider: 'https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
startBlock: 11340808,
|
||||
},
|
||||
{
|
||||
env: 'stagnet1',
|
||||
contract: '0xfCe6eB272D3d4146A96bC28de71212b327F575fa',
|
||||
provider: 'https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
startBlock: 11259488,
|
||||
},
|
||||
{
|
||||
env: 'stagnet2',
|
||||
contract: '0x9F10cBeEf03A564Fb914c2010c0Cd55E9BB11406',
|
||||
provider: 'https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
startBlock: 11790009,
|
||||
},
|
||||
{
|
||||
env: 'devnet',
|
||||
contract: '0xd1216AAb948f5FC706Df73df6d71c64CcaA8550a',
|
||||
provider: 'https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
startBlock: 11790003,
|
||||
},
|
||||
];
|
||||
|
||||
const vestingAbi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'token_v1_address',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'token_v2_address',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: 'old_addresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: 'new_addresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'new_controller',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'Controller_Set',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'issuer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Issuer_Permitted',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'issuer',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'Issuer_Revoked',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'Stake_Deposited',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'Stake_Removed',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'from',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'Stake_Transferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Tranche_Balance_Added',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Tranche_Balance_Removed',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'cliff_start',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'duration',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Tranche_Created',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'accuracy_scale',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'address_migration',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'assisted_withdraw_from_tranche',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'controller',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'cliff_start',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'duration',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'create_tranche',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'default_tranche_id',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: '',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'get_tranche_balance',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'get_vested_for_tranche',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'issue_into_tranche',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'move_into_tranche',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'issuer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'permit_issuer',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'permitted_issuance',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'remove_stake',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'issuer',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'revoke_issuer',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'new_controller',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'set_controller',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'stake_balance',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'vega_public_key',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
name: 'stake_tokens',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'staking_token',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'total_locked',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'total_staked',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'tranche_count',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: '',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: '',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'tranches',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'cliff_start',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'duration',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'user_stats',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'total_in_all_tranches',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'lien',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'user_total_all_tranches',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'v1_address',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'v1_migrated',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'v2_address',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint8',
|
||||
name: 'tranche_id',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'withdraw_from_tranche',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
||||
|
||||
function addDecimal(value, decimals) {
|
||||
return value.dividedBy(Math.pow(10, decimals)).decimalPlaces(decimals);
|
||||
}
|
||||
|
||||
function createUserTransactions(events, decimals) {
|
||||
return events.map((event) => {
|
||||
return {
|
||||
amount: addDecimal(
|
||||
new BigNumber(event.args?.amount.toString()),
|
||||
decimals
|
||||
),
|
||||
user: event.args?.user,
|
||||
tranche_id: event.args?.tranche_id,
|
||||
tx: event.transactionHash,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function getUsersInTranche(
|
||||
balanceAddedEvents,
|
||||
balanceRemovedEvents,
|
||||
addresses,
|
||||
decimals
|
||||
) {
|
||||
return addresses.map((address) => {
|
||||
const userDeposits = balanceAddedEvents.filter(
|
||||
(event) => event.args?.user === address
|
||||
);
|
||||
const userWithdraws = balanceRemovedEvents.filter(
|
||||
(event) => event.args?.user === address
|
||||
);
|
||||
const deposits = createUserTransactions(userDeposits, decimals);
|
||||
const withdrawals = createUserTransactions(userWithdraws, decimals);
|
||||
const total_tokens = deposits.reduce(
|
||||
(pre, cur) => pre.plus(cur.amount),
|
||||
new BigNumber(0)
|
||||
);
|
||||
const withdrawn_tokens = withdrawals.reduce(
|
||||
(pre, cur) => pre.plus(cur.amount),
|
||||
new BigNumber(0)
|
||||
);
|
||||
const remaining_tokens = total_tokens.minus(withdrawn_tokens);
|
||||
|
||||
return {
|
||||
address,
|
||||
deposits,
|
||||
withdrawals,
|
||||
total_tokens,
|
||||
withdrawn_tokens,
|
||||
remaining_tokens,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function sumFromEvents(events, decimals) {
|
||||
const amounts = events.map((e) =>
|
||||
addDecimal(new BigNumber(e.args?.amount.toString()), decimals)
|
||||
);
|
||||
// Start with a 0 so if there are none there is no NaN
|
||||
return BigNumber.sum.apply(null, [new BigNumber(0), ...amounts]);
|
||||
}
|
||||
|
||||
function getLockedAmount(totalAdded, cliffStart, trancheDuration) {
|
||||
let amount = new BigNumber(0);
|
||||
const ts = Math.round(new Date().getTime() / 1000);
|
||||
const tranche_progress = (ts - cliffStart) / trancheDuration;
|
||||
|
||||
if (tranche_progress < 0) {
|
||||
amount = totalAdded;
|
||||
} else if (tranche_progress < 1) {
|
||||
amount = totalAdded.times(1 - tranche_progress);
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
function createTransactions(events, decimals) {
|
||||
return events.map((event) => {
|
||||
return {
|
||||
amount: addDecimal(
|
||||
new BigNumber(event.args?.amount.toString()),
|
||||
decimals
|
||||
),
|
||||
user: event.args?.user,
|
||||
tx: event.transactionHash,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function getTranchesFromHistory(
|
||||
createEvents,
|
||||
addEvents,
|
||||
removeEvents,
|
||||
decimals
|
||||
) {
|
||||
return createEvents.map((event) => {
|
||||
const tranche_id = event.args?.tranche_id;
|
||||
const balanceAddedEvents = addEvents.filter(
|
||||
(e) =>
|
||||
e.event === 'Tranche_Balance_Added' && e.args?.tranche_id === tranche_id
|
||||
);
|
||||
const balanceRemovedEvents = removeEvents.filter(
|
||||
(e) =>
|
||||
e.event === 'Tranche_Balance_Removed' &&
|
||||
e.args?.tranche_id === tranche_id
|
||||
);
|
||||
|
||||
//get tranche start and end dates
|
||||
const tranche_duration = event.args?.duration;
|
||||
const cliff_start = event.args?.cliff_start;
|
||||
const tranche_start = new Date(cliff_start.mul(1000).toNumber());
|
||||
const tranche_end = new Date(
|
||||
cliff_start.add(tranche_duration).mul(1000).toNumber()
|
||||
);
|
||||
|
||||
// get added and removed values
|
||||
const total_added = sumFromEvents(balanceAddedEvents, decimals);
|
||||
const total_removed = sumFromEvents(balanceRemovedEvents, decimals);
|
||||
// get locked amount
|
||||
const locked_amount = getLockedAmount(
|
||||
total_added,
|
||||
cliff_start,
|
||||
tranche_duration
|
||||
);
|
||||
|
||||
// get all deposits and withdrawals
|
||||
const deposits = createTransactions(balanceAddedEvents, decimals);
|
||||
const withdrawals = createTransactions(balanceRemovedEvents, decimals);
|
||||
|
||||
// get all users
|
||||
const uniqueAddresses = uniq(
|
||||
balanceAddedEvents.map((event) => event.args?.user)
|
||||
);
|
||||
const users = getUsersInTranche(
|
||||
balanceAddedEvents,
|
||||
balanceRemovedEvents,
|
||||
uniqueAddresses,
|
||||
decimals
|
||||
);
|
||||
|
||||
return {
|
||||
tranche_id: parseInt(tranche_id),
|
||||
tranche_start,
|
||||
tranche_end,
|
||||
total_added,
|
||||
total_removed,
|
||||
locked_amount,
|
||||
deposits,
|
||||
withdrawals,
|
||||
users,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const getBatched = async (filter, contract, provider, startblock) => {
|
||||
const batchSize = 100000;
|
||||
const currentBlockNumber = await provider.getBlockNumber();
|
||||
const batches = Math.ceil(currentBlockNumber / batchSize);
|
||||
const startIndex = Math.floor(startblock / batchSize);
|
||||
|
||||
console.log(
|
||||
`Processing batches of size ${batches} starting at batch ${startIndex}`
|
||||
);
|
||||
let res = [];
|
||||
for (let index = startIndex; index < batches; index++) {
|
||||
let events = [];
|
||||
let attempts = 1;
|
||||
// Sometimes the queries fail for timeout even on small batch sizes. Some basic retry logic.
|
||||
while (attempts < MAX_ATTEMPTS) {
|
||||
try {
|
||||
events = await contract.queryFilter(
|
||||
filter,
|
||||
index * batchSize,
|
||||
(index + 1) * batchSize - 1
|
||||
);
|
||||
break;
|
||||
} catch {
|
||||
console.log('retry batch', index);
|
||||
++attempts;
|
||||
if (attempts >= MAX_ATTEMPTS) {
|
||||
throw new Error('Could not get in 4 attempts');
|
||||
}
|
||||
}
|
||||
}
|
||||
res = [...events, ...res];
|
||||
|
||||
console.log(
|
||||
`Processed blocks ${index * batchSize} to ${
|
||||
(index + 1) * batchSize - 1
|
||||
} as part of batch ${index}`
|
||||
);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
const run = async (c) => {
|
||||
const provider = new ethers.providers.JsonRpcProvider({
|
||||
url: c.provider,
|
||||
timeout: 1000 * 60 * 1000,
|
||||
});
|
||||
|
||||
const contract = new ethers.Contract(c.contract, vestingAbi, provider);
|
||||
const [created, added, removed] = await Promise.all([
|
||||
getBatched(
|
||||
contract.filters.Tranche_Created(),
|
||||
contract,
|
||||
provider,
|
||||
c.startBlock
|
||||
),
|
||||
getBatched(
|
||||
contract.filters.Tranche_Balance_Added(),
|
||||
contract,
|
||||
provider,
|
||||
c.startBlock
|
||||
),
|
||||
getBatched(
|
||||
contract.filters.Tranche_Balance_Removed(),
|
||||
contract,
|
||||
provider,
|
||||
c.startBlock
|
||||
),
|
||||
]);
|
||||
fs.writeFileSync(
|
||||
`./apps/static/src/assets/${c.env}-tranches.json`,
|
||||
JSON.stringify(
|
||||
getTranchesFromHistory(created, added, removed, 18),
|
||||
null,
|
||||
2
|
||||
),
|
||||
{ encoding: 'UTF-8' }
|
||||
);
|
||||
};
|
||||
|
||||
CONFIG.forEach((c) => run(c));
|
Loading…
Reference in New Issue
Block a user