Skip to content
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
64 changes: 64 additions & 0 deletions contracts/merkle-distributor/AcrossMerkleDistributor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@uma/core/contracts/merkle-distributor/implementation/MerkleDistributor.sol";

/**
* @title Extended MerkleDistributor contract.
* @notice Adds additional constraints governing who can claim leaves from merkle windows.
*/
contract AcrossMerkleDistributor is MerkleDistributor {
// Addresses that can claim on user's behalf. Useful to get around the requirement that claim recipient
// must also be claimer.
mapping(address => bool) public whitelistedClaimers;

/****************************************
* EVENTS
****************************************/
event WhitelistedClaimer(address indexed claimer, bool indexed whitelist);

/****************************
* ADMIN FUNCTIONS
****************************/

/**
* @notice Updates whitelisted claimer status.
* @dev Callable only by owner.
* @param newContract Reset claimer contract to this address.
* @param whitelist True to whitelist claimer, False otherwise.
*/
function whitelistClaimer(address newContract, bool whitelist) external onlyOwner {
whitelistedClaimers[newContract] = whitelist;
emit WhitelistedClaimer(newContract, whitelist);
}

/****************************
* NON-ADMIN FUNCTIONS
****************************/

/**
* @notice Batch claims to reduce gas versus individual submitting all claims. Method will fail
* if any individual claims within the batch would fail.
* @dev All claim recipients must be equal to msg.sender or claimer must be whitelisted.
* @param claims array of claims to claim.
*/
function claimMulti(Claim[] memory claims) public override {
if (!whitelistedClaimers[msg.sender]) {
uint256 claimCount = claims.length;
for (uint256 i = 0; i < claimCount; i++) {
require(claims[i].account == msg.sender, "invalid claimer");
}
}
super.claimMulti(claims);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming claimMulti and claim from within the MerkleDistributor works correctly, this wrapper contract looks perfect to me!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup and the tests give me confidence, which i didn't modify and should work against the parent's behavior

}

/**
* @notice Claim amount of reward tokens for account, as described by Claim input object.
* @dev Claim recipient must be equal to msg.sender or caller must be whitelisted.
* @param _claim claim object describing amount, accountIndex, account, window index, and merkle proof.
*/
function claim(Claim memory _claim) public override {
require(whitelistedClaimers[msg.sender] || _claim.account == msg.sender, "invalid claimer");
super.claim(_claim);
}
}
265 changes: 0 additions & 265 deletions contracts/merkle-distributor/MerkleDistributor.sol

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts-v2",
"version": "1.0.5",
"version": "1.0.6",
"author": "UMA Team",
"license": "AGPL-3.0",
"repository": {
Expand Down Expand Up @@ -37,7 +37,7 @@
"@openzeppelin/contracts": "^4.7.3",
"@uma/common": "^2.28.0",
"@uma/contracts-node": "^0.3.18",
"@uma/core": "^2.38.0",
"@uma/core": "^2.40.0",
"@uma/merkle-distributor": "^1.3.38",
"arb-bridge-eth": "^0.7.4",
"arb-bridge-peripherals": "^1.0.5"
Expand Down
2 changes: 1 addition & 1 deletion tasks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function _findL2TokenFromTokenList(l2ChainId: number, l1TokenAddress: stri
}
if (l2ChainId === 137) {
const response = await fetch(
"https://raw.githubusercontent.com/maticnetwork/polygon-token-list/master/src/tokens/allTokens.json"
"https://raw.githubusercontent.com/maticnetwork/polygon-token-list/master/src/tokens/polygonTokens.json"
);
const body = await response.text();
const tokenList = JSON.parse(body);
Expand Down
4 changes: 3 additions & 1 deletion test/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { toWei, utf8ToHex, toBN, createRandomBytes32, ethers, hre } from "./utils";
import { toWei, utf8ToHex, toBN, createRandomBytes32 } from "./utils";

import { ethers } from "ethers";

export { TokenRolesEnum } from "@uma/common";

Expand Down
Loading