Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuke distributors package #2111

Merged
merged 5 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ jobs:
- name: Benchmark Join/Exit
run: yarn workspace @balancer-labs/v2-benchmarks measure-join-exit

merkle-claim:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Benchmark Merkle Claim
run: yarn workspace @balancer-labs/v2-benchmarks measure-merkle-claim

relayer:
runs-on: ubuntu-latest
steps:
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,6 @@ jobs:
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-pool-linear test-fuzz

test-distributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-distributors test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-distributors test-fuzz

test-liquidity-mining:
runs-on: ubuntu-latest
steps:
Expand Down
67 changes: 0 additions & 67 deletions audits/test-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,73 +138,6 @@ codes instead of standard revert strings.
➤ [@balancer-labs/v2-asset-manager-utils]:
➤ [@balancer-labs/v2-asset-manager-utils]: 54 passing (41s)
➤ [@balancer-labs/v2-asset-manager-utils]:
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]: MerkleRedeem
➤ [@balancer-labs/v2-distributors]: ✓ stores an allocation (284ms)
➤ [@balancer-labs/v2-distributors]: ✓ emits RewardAdded when an allocation is stored (252ms)
➤ [@balancer-labs/v2-distributors]: ✓ requisitions tokens when it stores a balance
➤ [@balancer-labs/v2-distributors]: ✓ reverts when unauthorized to seed allocation
➤ [@balancer-labs/v2-distributors]: ✓ stores multiple allocations
➤ [@balancer-labs/v2-distributors]: with an allocation
➤ [@balancer-labs/v2-distributors]: ✓ allows the user to claimWeek (255ms)
➤ [@balancer-labs/v2-distributors]: ✓ emits RewardPaid when an allocation is claimed
➤ [@balancer-labs/v2-distributors]: ✓ marks claimed weeks as claimed
➤ [@balancer-labs/v2-distributors]: ✓ allows the user to claimWeek to internal balance
➤ [@balancer-labs/v2-distributors]: ✓ reverts when a user attempts to claim for another user
➤ [@balancer-labs/v2-distributors]: ✓ reverts when the user attempts to claim the wrong balance
➤ [@balancer-labs/v2-distributors]: ✓ reverts when the user attempts to claim twice
➤ [@balancer-labs/v2-distributors]: ✓ reverts when an admin attempts to overwrite an allocationn
➤ [@balancer-labs/v2-distributors]: with several allocations
➤ [@balancer-labs/v2-distributors]: ✓ allows the user to claim multiple weeks at once
➤ [@balancer-labs/v2-distributors]: ✓ reports weeks as unclaimed
➤ [@balancer-labs/v2-distributors]: ✓ returns an array of merkle roots
➤ [@balancer-labs/v2-distributors]: When a user has claimed one of their allocations
➤ [@balancer-labs/v2-distributors]: ✓ reports one of the weeks as claimed
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]: Staking contract
➤ [@balancer-labs/v2-distributors]: isAllowlistedRewarder
➤ [@balancer-labs/v2-distributors]: ✓ allows thet asset managers to allowlist themselves
➤ [@balancer-labs/v2-distributors]: ✓ allows the owner to allowlist someone
➤ [@balancer-labs/v2-distributors]: ✓ returns false for random users
➤ [@balancer-labs/v2-distributors]: addReward
➤ [@balancer-labs/v2-distributors]: ✓ sets up a reward for an asset manager
➤ [@balancer-labs/v2-distributors]: stakeWithPermit
➤ [@balancer-labs/v2-distributors]: ✓ stakes with a permit signature
➤ [@balancer-labs/v2-distributors]: ✓ stakes with a permit signature to a recipient
➤ [@balancer-labs/v2-distributors]: with two stakes
➤ [@balancer-labs/v2-distributors]: ✓ sends expected amount of reward token to the rewards contract
➤ [@balancer-labs/v2-distributors]: ✓ emits RewardAdded when an allocation is stored
➤ [@balancer-labs/v2-distributors]: when the rewarder has called notifyRewardAmount
➤ [@balancer-labs/v2-distributors]: ✓ distributes the reward according to the fraction of staked LP tokens
➤ [@balancer-labs/v2-distributors]: ✓ allows a user to claim the reward to an EOA
➤ [@balancer-labs/v2-distributors]: ✓ allows a user to claim the reward to internal balance
➤ [@balancer-labs/v2-distributors]: ✓ emits RewardPaid when an allocation is claimed
➤ [@balancer-labs/v2-distributors]: with a second distribution from the same rewarder
➤ [@balancer-labs/v2-distributors]: ✓ calculates totalEarned from both distributions
➤ [@balancer-labs/v2-distributors]: with a second distributions from another rewarder
➤ [@balancer-labs/v2-distributors]: ✓ calculates totalEarned from both distributions
➤ [@balancer-labs/v2-distributors]: with two pools
➤ [@balancer-labs/v2-distributors]: ✓ allows you to claim across multiple pools (431ms)
➤ [@balancer-labs/v2-distributors]: - emits RewardPaid for each pool
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]: Staking contract
➤ [@balancer-labs/v2-distributors]: with a stake and a reward
➤ [@balancer-labs/v2-distributors]: ✓ allows a user to claim the reward to a callback contract
➤ [@balancer-labs/v2-distributors]: ✓ calls the callback on the contract
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]: Reinvestor
➤ [@balancer-labs/v2-distributors]: with a stake and a reward
➤ [@balancer-labs/v2-distributors]: with a pool to claim into
➤ [@balancer-labs/v2-distributors]: ✓ emits PoolBalanceChanged when a LP claims to weighted pool (413ms)
➤ [@balancer-labs/v2-distributors]: ✓ mints bpt to a LP when they claim to weighted pool (380ms)
➤ [@balancer-labs/v2-distributors]: addReward
➤ [@balancer-labs/v2-distributors]: ✓ returns rewards that are unused in reinvestment (438ms)
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-distributors]: 37 passing (41s)
➤ [@balancer-labs/v2-distributors]: 1 pending
➤ [@balancer-labs/v2-distributors]:
➤ [@balancer-labs/v2-solidity-utils]:
➤ [@balancer-labs/v2-solidity-utils]:
➤ [@balancer-labs/v2-solidity-utils]: BalancerErrors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import hre, { ethers } from 'hardhat';
import { Contract, BigNumber, utils } from 'ethers';
import { Contract, BigNumber } from 'ethers';

import { bn, fp } from '@balancer-labs/v2-helpers/src/numbers';
import { expectEqualWithError } from '@balancer-labs/v2-helpers/src/test/relativeError';
import { MerkleTree } from '@balancer-labs/v2-distributors/lib/merkleTree';
import { deploy } from '@balancer-labs/v2-helpers/src/contract';
import { MerkleTree } from '@balancer-labs/v2-helpers/src/merkleTree';

import { MAX_UINT256 } from '@balancer-labs/v2-helpers/src/constants';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address';
Expand Down Expand Up @@ -66,17 +65,5 @@ describeForkTest('MerkleRedeem', 'mainnet', 14850000, function () {
await distributor.connect(lp).claimWeek(lp.address, bn(1), fp(66), proof);
expectEqualWithError(await token.balanceOf(lp.address), fp(66), fp(1));
});

it('can claim a reward to a callback', async () => {
await distributor.connect(whale).seedAllocations(bn(2), root, fp(100));

const calldata = utils.defaultAbiCoder.encode([], []);
const callbackContract = await deploy('v2-distributors/MockRewardCallback', { args: [] });

const claims = [{ week: bn(2), balance: fp(66), merkleProof: proof }];

await distributor.connect(lp).claimWeeksWithCallback(lp.address, callbackContract.address, calldata, claims);
expectEqualWithError(await token.balanceOf(callbackContract.address), fp(66), fp(1));
});
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import hre, { ethers } from 'hardhat';
import { Contract, BigNumber, utils } from 'ethers';
import { Contract, BigNumber } from 'ethers';

import { bn, fp } from '@balancer-labs/v2-helpers/src/numbers';
import { expectEqualWithError } from '@balancer-labs/v2-helpers/src/test/relativeError';
import { MerkleTree } from '@balancer-labs/v2-distributors/lib/merkleTree';
import { deploy } from '@balancer-labs/v2-helpers/src/contract';
import { MerkleTree } from '@balancer-labs/v2-helpers/src/merkleTree';

import { MAX_UINT256 } from '@balancer-labs/v2-helpers/src/constants';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address';
Expand Down Expand Up @@ -66,17 +65,5 @@ describeForkTest('MerkleRedeem', 'arbitrum', 846769, function () {
await distributor.connect(lp).claimWeek(lp.address, bn(1), fp(66), proof);
expectEqualWithError(await token.balanceOf(lp.address), fp(66), fp(1));
});

it('can claim a reward to a callback', async () => {
await distributor.connect(whale).seedAllocations(bn(2), root, fp(100));

const calldata = utils.defaultAbiCoder.encode([], []);
const callbackContract = await deploy('v2-distributors/MockRewardCallback', { args: [] });

const claims = [{ week: bn(2), balance: fp(66), merkleProof: proof }];

await distributor.connect(lp).claimWeeksWithCallback(lp.address, callbackContract.address, calldata, claims);
expectEqualWithError(await token.balanceOf(callbackContract.address), fp(66), fp(1));
});
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import hre, { ethers } from 'hardhat';
import { Contract, BigNumber, utils } from 'ethers';
import { Contract, BigNumber } from 'ethers';

import { bn, fp } from '@balancer-labs/v2-helpers/src/numbers';
import { expectEqualWithError } from '@balancer-labs/v2-helpers/src/test/relativeError';
import { MerkleTree } from '@balancer-labs/v2-distributors/lib/merkleTree';
import { deploy } from '@balancer-labs/v2-helpers/src/contract';
import { MerkleTree } from '@balancer-labs/v2-helpers/src/merkleTree';

import { MAX_UINT256 } from '@balancer-labs/v2-helpers/src/constants';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address';
Expand Down Expand Up @@ -66,17 +65,5 @@ describeForkTest('MerkleRedeem', 'arbitrum', 1731663, function () {
await distributor.connect(lp).claimWeek(lp.address, bn(1), fp(66), proof);
expectEqualWithError(await token.balanceOf(lp.address), fp(66), fp(1));
});

it('can claim a reward to a callback', async () => {
await distributor.connect(whale).seedAllocations(bn(2), root, fp(100));

const calldata = utils.defaultAbiCoder.encode([], []);
const callbackContract = await deploy('v2-distributors/MockRewardCallback', { args: [] });

const claims = [{ week: bn(2), balance: fp(66), merkleProof: proof }];

await distributor.connect(lp).claimWeeksWithCallback(lp.address, callbackContract.address, calldata, claims);
expectEqualWithError(await token.balanceOf(callbackContract.address), fp(66), fp(1));
});
});
});
Loading