14 | fromBlock - toBlock 15 |
16 |├── .github └── workflows │ ├── deploy-admin-state.yml │ ├── deploy.yml │ ├── docker-reward-calculator.yml │ ├── docker.yml │ ├── monitors-docker.yml │ ├── reclaim-docker.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── Readme.md ├── package.json ├── packages ├── balance-monitor │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── contract-admin-state │ ├── .env.example │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── assets │ │ └── logo.png │ ├── index.html │ ├── package.json │ ├── postcss.config.js │ ├── prettier.config.js │ ├── src │ │ ├── App.tsx │ │ ├── config │ │ │ └── contracts.ts │ │ ├── hooks │ │ │ └── useMulticall.ts │ │ ├── index.css │ │ ├── main.tsx │ │ ├── utils │ │ │ ├── formatToken.ts │ │ │ └── toNumber.ts │ │ ├── vite-env.d.ts │ │ └── wagmi.ts │ ├── tailwind.config.js │ ├── tsconfig.json │ └── vite.config.ts ├── contracts │ ├── .dockerignore │ ├── .gitignore │ ├── DEPLOY_TO_MAINNET.md │ ├── Dockerfile │ ├── Dockerfile-playground │ ├── Dockerfile-reclaimFunds │ ├── Dockerfile-registerGateway │ ├── Dockerfile.common │ ├── README.md │ ├── b58.py │ ├── deploy │ │ └── hardhat │ │ │ ├── 00_SQD.js │ │ │ ├── 01_WorkerRegistration.js │ │ │ ├── 02_RewardCalculation.js │ │ │ └── 03_RewardsDistribution.js │ ├── deployments │ │ ├── 42161.json │ │ ├── 421613.json │ │ ├── 421614.json │ │ └── arbitrum-goerli │ │ │ ├── .chainId │ │ │ ├── RewardCalculation.json │ │ │ ├── RewardTreasury.json │ │ │ ├── RewardsDistribution.json │ │ │ ├── WorkerRegistration.json │ │ │ ├── WorkerRegistrationFacade.json │ │ │ ├── solcInputs │ │ │ └── 4748128410615c77f58b8d981c2a2cb5.json │ │ │ └── tSQD.json │ ├── docker-compose.yaml │ ├── foundry.toml │ ├── package.json │ ├── register-gateway.sh │ ├── script │ │ ├── Bounty.s.sol │ │ ├── CreateVestings.s.sol │ │ ├── Deploy.s.sol │ │ ├── DeployDistributor.s.sol │ │ ├── PreparePlayground.s.sol │ │ ├── RedeployGateways.s.sol │ │ ├── RegisterGateway.s.sol │ │ ├── RegisterWorker.s.sol │ │ ├── UnlockFunds.s.sol │ │ ├── vestings.json │ │ └── workersSurvey.json │ ├── scripts │ │ ├── createMerkleTree.ts │ │ ├── fordefi │ │ │ ├── request.ts │ │ │ └── sendTransaction.ts │ │ └── sendVaultTokens.ts │ ├── spinup-testnet.sh │ ├── src │ │ ├── AccessControlledPausable.sol │ │ ├── AllocationsViewer.sol │ │ ├── DistributedRewardDistribution.sol │ │ ├── Executable.sol │ │ ├── GatewayRegistry.sol │ │ ├── LinearToSqrtCap.sol │ │ ├── MerkleDistributor.sol │ │ ├── NetworkController.sol │ │ ├── RewardCalculation.sol │ │ ├── RewardTreasury.sol │ │ ├── Router.sol │ │ ├── SQD.sol │ │ ├── SoftCap.sol │ │ ├── Staking.sol │ │ ├── TemporaryHolding.sol │ │ ├── TemporaryHoldingFactory.sol │ │ ├── Vesting.sol │ │ ├── VestingFactory.sol │ │ ├── WorkerRegistration.sol │ │ ├── arbitrum │ │ │ └── SQD.sol │ │ ├── gateway-strategies │ │ │ ├── EqualStrategy.sol │ │ │ └── SubequalStrategy.sol │ │ └── interfaces │ │ │ ├── IERC20WithMetadata.sol │ │ │ ├── IGatewayRegistry.sol │ │ │ ├── IGatewayStrategy.sol │ │ │ ├── INetworkController.sol │ │ │ ├── IRewardCalculation.sol │ │ │ ├── IRewardsDistribution.sol │ │ │ ├── IRouter.sol │ │ │ ├── IStaking.sol │ │ │ └── IWorkerRegistration.sol │ ├── test │ │ ├── BaseTest.sol │ │ ├── DistributedRewardsDistribution │ │ │ ├── DistributedRewardsDistribution.addAndRemoveDistributors.t.sol │ │ │ ├── DistributedRewardsDistribution.claim.t.sol │ │ │ ├── DistributedRewardsDistribution.commitAndApprove.t.sol │ │ │ ├── DistributedRewardsDistribution.distribute.t.sol │ │ │ └── DistributedRewardsDistribution.sol │ │ ├── GatewayRegistry │ │ │ ├── GatewayRegistry.allocate.t.sol │ │ │ ├── GatewayRegistry.allocatedCUs.t.sol │ │ │ ├── GatewayRegistry.autoextend.t.sol │ │ │ ├── GatewayRegistry.clusters.t.sol │ │ │ ├── GatewayRegistry.getActiveGateways.t.sol │ │ │ ├── GatewayRegistry.registrAndUnregister.t.sol │ │ │ ├── GatewayRegistry.stake.t.sol │ │ │ ├── GatewayRegistry.unstake.t.sol │ │ │ └── GatewayRegistryTest.sol │ │ ├── LinearToSqerCap.t.sol │ │ ├── NetworkController.t.sol │ │ ├── RewardCalculation.t.sol │ │ ├── RewardTreasury.t.sol │ │ ├── SoftCap.t.sol │ │ ├── Staking │ │ │ ├── StakersRewardDistributor.accessControl.t.sol │ │ │ ├── StakersRewardDistributor.deposit.t.sol │ │ │ ├── StakersRewardDistributor.withdraw.t.sol │ │ │ └── StakersRewardDistributorTest.sol │ │ ├── Vesting │ │ │ ├── SubsquidVesting.t.sol │ │ │ └── vesting_schedules.json │ │ ├── WorkerRegistration │ │ │ ├── WorkerRegistration.constructor.t.sol │ │ │ ├── WorkerRegistration.deregister.t.sol │ │ │ ├── WorkerRegistration.excessiveBond.t.sol │ │ │ ├── WorkerRegistration.register.t.sol │ │ │ ├── WorkerRegistration.sol │ │ │ ├── WorkerRegistration.updateMetadata.t.sol │ │ │ └── WorkerRegistration.withdraw.t.sol │ │ └── strategies │ │ │ └── EqualStrategy.t.sol │ └── tsconfig.json ├── reward-stats │ ├── .env.example │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── assets │ │ └── logo.png │ ├── index.html │ ├── package.json │ ├── polyfills.ts │ ├── postcss.config.js │ ├── prettier.config.js │ ├── src │ │ ├── App.tsx │ │ ├── components │ │ │ ├── RewardLinks.tsx │ │ │ ├── RewardsChart.tsx │ │ │ └── Stats.tsx │ │ ├── config │ │ │ └── contracts.ts │ │ ├── hooks │ │ │ ├── useBlockTimestamp.ts │ │ │ ├── useBond.ts │ │ │ ├── useRewards.ts │ │ │ ├── useStakes.ts │ │ │ └── useWorkers.ts │ │ ├── index.css │ │ ├── main.tsx │ │ ├── utils │ │ │ ├── allWorkerIds.ts │ │ │ ├── formatToken.ts │ │ │ ├── stringify.ts │ │ │ └── toNumber.tsx │ │ ├── vite-env.d.ts │ │ └── wagmi.ts │ ├── tailwind.config.js │ ├── tsconfig.json │ └── vite.config.ts └── rewards-calculator │ ├── .dockerignore │ ├── .gitignore │ ├── .mocharc.json │ ├── Dockerfile │ ├── Dockerfile-endpoints │ ├── Readme.md │ ├── package.json │ ├── src │ ├── chain.ts │ ├── clickhouseClient.ts │ ├── config.ts │ ├── endpoints.ts │ ├── epochStats.ts │ ├── fordefi │ │ ├── getAddress.ts │ │ ├── request.ts │ │ └── sendTransaction.ts │ ├── index.ts │ ├── logger.ts │ ├── protobuf │ │ └── query.proto │ ├── reward.ts │ ├── rewardBot.ts │ ├── signatureVerification.ts │ ├── startBot.ts │ ├── testRPC.ts │ ├── utils.ts │ ├── worker.ts │ └── workers.ts │ ├── test │ ├── data │ │ └── test_log.json │ └── signature-verification.ts │ └── tsconfig.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml └── turbo.json /.github/workflows/deploy-admin-state.yml: -------------------------------------------------------------------------------- 1 | # Simple workflow for deploying static content to GitHub Pages 2 | name: Deploy contract admin state to Netlify 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ['main'] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | env: 13 | FOUNDRY_PROFILE: ci 14 | 15 | 16 | jobs: 17 | # Single deploy job since we're just deploying 18 | deploy: 19 | environment: 20 | name: github-pages 21 | url: ${{ steps.deployment.outputs.page_url }} 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v3 26 | - name: Setup pnpm 27 | uses: pnpm/action-setup@v2.0.1 28 | with: 29 | version: 9.0.3 30 | 31 | - name: Install deps 32 | run: pnpm i 33 | 34 | - name: Install Foundry 35 | uses: foundry-rs/foundry-toolchain@v1 36 | with: 37 | version: nightly 38 | - name: Run Build 39 | run: | 40 | pnpm build 41 | id: build 42 | - name: Deploy to Netlify 43 | uses: nwtgck/actions-netlify@v2.0 44 | with: 45 | publish-dir: './packages/contract-admin-state/dist' 46 | production-branch: main 47 | github-token: ${{ secrets.GITHUB_TOKEN }} 48 | deploy-message: "Deploy from GitHub Actions" 49 | enable-pull-request-comment: false 50 | enable-commit-comment: true 51 | overwrites-pull-request-comment: true 52 | env: 53 | NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} 54 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_ADMIN_SITE_ID }} 55 | timeout-minutes: 1 56 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | # Simple workflow for deploying static content to GitHub Pages 2 | name: Deploy stats to Netlify 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ['main'] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | env: 13 | FOUNDRY_PROFILE: ci 14 | 15 | 16 | jobs: 17 | # Single deploy job since we're just deploying 18 | deploy: 19 | environment: 20 | name: github-pages 21 | url: ${{ steps.deployment.outputs.page_url }} 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v3 26 | - name: Setup pnpm 27 | uses: pnpm/action-setup@v2.0.1 28 | with: 29 | version: 9.0.3 30 | 31 | - name: Install deps 32 | run: pnpm i 33 | 34 | - name: Install Foundry 35 | uses: foundry-rs/foundry-toolchain@v1 36 | with: 37 | version: nightly 38 | - name: Run Build 39 | run: | 40 | pnpm build 41 | id: build 42 | - name: Deploy to Netlify 43 | uses: nwtgck/actions-netlify@v2.0 44 | with: 45 | publish-dir: './packages/reward-stats/dist' 46 | production-branch: main 47 | github-token: ${{ secrets.GITHUB_TOKEN }} 48 | deploy-message: "Deploy from GitHub Actions" 49 | enable-pull-request-comment: false 50 | enable-commit-comment: true 51 | overwrites-pull-request-comment: true 52 | env: 53 | NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} 54 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} 55 | timeout-minutes: 1 56 | -------------------------------------------------------------------------------- /.github/workflows/docker-reward-calculator.yml: -------------------------------------------------------------------------------- 1 | name: docker-rewards-calculator 2 | on: 3 | workflow_dispatch: # manually run 4 | inputs: 5 | tag: 6 | description: image tag 7 | required: true 8 | 9 | env: 10 | CI: true 11 | 12 | jobs: 13 | publish: 14 | name: Build & publish docker image 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | 20 | - name: Docker login 21 | uses: docker/login-action@v1 22 | with: 23 | username: ${{ secrets.DOCKER_LOGIN }} 24 | password: ${{ secrets.DOCKER_TOKEN }} 25 | 26 | - name: Build & publish calculator image 27 | uses: docker/build-push-action@v3 28 | with: 29 | push: true 30 | context: . 31 | file: packages/rewards-calculator/Dockerfile 32 | tags: subsquid/rewards-calculator:${{ inputs.tag }} 33 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: docker 2 | on: 3 | workflow_dispatch: # manually run 4 | inputs: 5 | tag: 6 | description: image tag 7 | required: true 8 | 9 | env: 10 | CI: true 11 | 12 | jobs: 13 | publish: 14 | name: Build & publish docker image 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | - name: Set up QEMU 20 | uses: docker/setup-qemu-action@v3 21 | - name: Set up Docker Buildx 22 | uses: docker/setup-buildx-action@v3 23 | 24 | - run: cd packages/contracts 25 | 26 | - name: Docker login 27 | uses: docker/login-action@v1 28 | with: 29 | username: ${{ secrets.DOCKER_LOGIN }} 30 | password: ${{ secrets.DOCKER_TOKEN }} 31 | 32 | - name: Build & publish playground image 33 | uses: docker/build-push-action@v5 34 | with: 35 | push: true 36 | context: packages/contracts 37 | file: packages/contracts/Dockerfile-playground 38 | tags: subsquid/playground:${{ inputs.tag }} 39 | - name: Build & publish contracts image 40 | uses: docker/build-push-action@v5 41 | with: 42 | push: true 43 | context: packages/contracts 44 | platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,windows/amd64 45 | file: packages/contracts/Dockerfile-registerGateway 46 | tags: subsquid/register-gateway:latest 47 | -------------------------------------------------------------------------------- /.github/workflows/monitors-docker.yml: -------------------------------------------------------------------------------- 1 | name: Build balance monitor 2 | on: 3 | workflow_dispatch: # manually run 4 | inputs: 5 | tag: 6 | description: image tag 7 | required: true 8 | 9 | env: 10 | CI: true 11 | 12 | jobs: 13 | publish: 14 | name: Build & publish docker image 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | - name: Set up QEMU 20 | uses: docker/setup-qemu-action@v3 21 | - name: Set up Docker Buildx 22 | uses: docker/setup-buildx-action@v3 23 | 24 | - run: cd packages/contracts 25 | 26 | - name: Docker login 27 | uses: docker/login-action@v1 28 | with: 29 | username: ${{ secrets.DOCKER_LOGIN }} 30 | password: ${{ secrets.DOCKER_TOKEN }} 31 | 32 | - name: Build & publish balance monitor image 33 | uses: docker/build-push-action@v5 34 | with: 35 | push: true 36 | context: packages/balance-monitor 37 | platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 38 | tags: subsquid/balance-monitor:${{ inputs.tag }} 39 | 40 | - name: Build & publish rewards monitor image 41 | uses: docker/build-push-action@v5 42 | with: 43 | push: true 44 | context: . 45 | file: packages/rewards-calculator/Dockerfile-endpoints 46 | platforms: linux/amd64 47 | tags: subsquid/reward-monitor:${{ inputs.tag }} 48 | -------------------------------------------------------------------------------- /.github/workflows/reclaim-docker.yml: -------------------------------------------------------------------------------- 1 | name: Build reclaim image 2 | on: 3 | workflow_dispatch: # manually run 4 | inputs: 5 | tag: 6 | description: image tag 7 | required: true 8 | 9 | env: 10 | CI: true 11 | 12 | jobs: 13 | publish: 14 | name: Build & publish docker image 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | - name: Set up QEMU 20 | uses: docker/setup-qemu-action@v3 21 | - name: Set up Docker Buildx 22 | uses: docker/setup-buildx-action@v3 23 | 24 | - run: cd packages/contracts 25 | 26 | - name: Docker login 27 | uses: docker/login-action@v1 28 | with: 29 | username: ${{ secrets.DOCKER_LOGIN }} 30 | password: ${{ secrets.DOCKER_TOKEN }} 31 | 32 | - name: Build & publish contracts image 33 | uses: docker/build-push-action@v5 34 | with: 35 | push: true 36 | context: packages/contracts 37 | platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,windows/amd64 38 | file: packages/contracts/Dockerfile-reclaimFunds 39 | tags: subsquid/reclaim:latest 40 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | env: 10 | FOUNDRY_PROFILE: ci 11 | 12 | jobs: 13 | check: 14 | strategy: 15 | fail-fast: true 16 | 17 | name: CI 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | with: 22 | submodules: recursive 23 | 24 | - name: Setup pnpm 25 | uses: pnpm/action-setup@v2.0.1 26 | with: 27 | version: 9.0.3 28 | 29 | - name: Install deps 30 | run: pnpm i 31 | 32 | - name: Install Foundry 33 | uses: foundry-rs/foundry-toolchain@v1 34 | with: 35 | version: nightly 36 | 37 | - name: Run Forge build 38 | run: | 39 | pnpm build 40 | id: build 41 | 42 | - name: Run Lint 43 | run: | 44 | pnpm lint 45 | id: lint 46 | 47 | - name: Run Forge tests 48 | run: | 49 | pnpm test 50 | id: test 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | .env 4 | .turbo 5 | .lockb -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "packages/contracts/lib/forge-std"] 2 | path = packages/contracts/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "packages/contracts/lib/openzeppelin-contracts"] 5 | path = packages/contracts/lib/openzeppelin-contracts 6 | url = https://github.com/OpenZeppelin/openzeppelin-contracts 7 | [submodule "packages/contracts/lib/prb-math"] 8 | path = packages/contracts/lib/prb-math 9 | url = https://github.com/PaulRBerg/prb-math 10 | [submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"] 11 | path = packages/contracts/lib/openzeppelin-contracts-upgradeable 12 | url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable 13 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Subsquid Network Contracts 2 | 3 |
4 |
5 |
14 | fromBlock - toBlock 15 |
16 |{workers?.[label]?.peerId}
55 |{workers?.[label]?.metadata.description}
56 |{workers?.[label]?.metadata.email}
57 |58 | Worker reward: {payload[0].payload.workerReward} 59 | (bond: {formatToken(bond)}) 60 |
61 |62 | Staker reward: {payload[0].payload.stakerReward} 63 | (staked: {formatToken(stakes[label])}) 64 |
65 |66 | Worker APY:{" "} 67 | {( 68 | (100 * payload[0].payload.workerReward * year) / 69 | toNumber(bond) / 70 | timeDiff 71 | ).toFixed(2)} 72 | % 73 |
74 | {!!stakes[label] && ( 75 |76 | Staker APY:{" "} 77 | {( 78 | (100 * payload[0].payload.stakerReward * year) / 79 | toNumber(stakes[label]) / 80 | timeDiff 81 | ).toFixed(2)} 82 | % 83 |
84 | )} 85 |