MureDistribution
Inherits: EIP712Upgradeable, ERC165Upgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable, Distributable
Author: Mure
Distribution contract for distributing assets described by PoolMetadata
contracts.
Recommended use is with a MurePool
contract, where off-chain signatures are provided for
permits and saving gas by depending on off-chain compute power for complex computations based on
on-chain state.
State Variables
DISTRIBUTION_ADMIN_ROLE
Role allows user to create and update pools along with pool administration
bytes32 public constant DISTRIBUTION_ADMIN_ROLE = keccak256("DISTRIBUTION_ADMIN");
MureDistributionStorageLocation
Hash for storage location
keccak256(abi.encode(uint256(keccak256("mure.MureDistribution")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant MureDistributionStorageLocation =
0xcb2c43c8a077042ee388281b9a5a398915ca6047194d75b071075a7b241a5800;
DISTRIBUTION_HASH
Struct hash for validating deposits
keccak256("Distribution(address token,address source,string pool,address repository,address depositor,address claimer,uint256 amount,uint256 deadline,uint24 nonce)")
bytes32 private constant DISTRIBUTION_HASH = 0xc947aa90aaf074203df95a7de07adb71025f14e165fb180a3c83663110a02ce1;
Functions
distributable
modifier distributable(DistributionRecord calldata distribution);
validManager
modifier validManager(address source);
initialize
function initialize(string calldata name, string calldata version, address owner) external initializer;
supportsInterface
See IERC165-supportsInterface.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, AccessControlUpgradeable)
returns (bool);
distribute
function distribute(DistributionRecord calldata distribution, bytes calldata signature) external;
distribute
function distribute(DistributionRecord calldata distribution, address to, bytes calldata signature) external;
moveDistribution
Moves a distribution record from one depositor to another.
Only used for moving complete distributions in cases such as from
being a compromised wallet.
function moveDistribution(address source, string calldata poolName, address from, address to)
external
validManager(source);
Parameters
Name | Type | Description |
---|---|---|
source | address | the address to the application contract where the deposit information exists |
poolName | string | the name of the pool where the deposit was conducted |
from | address | the address of the original depositor |
to | address | the address of the new depositor |
distribution
Read distribution history of depositor
in the designated source
and poolName
function distribution(address source, string calldata poolName, address depositor)
external
view
returns (DistributionHistory memory);
Parameters
Name | Type | Description |
---|---|---|
source | address | the address of the pooling contract |
poolName | string | the name pf the pool |
depositor | address | the address of the depositor |
nonce
Read nonce of depositor
function nonce(address depositor) external view returns (uint24);
Parameters
Name | Type | Description |
---|---|---|
depositor | address | the address of the depositor |
_distribute
Assumes that the token
address is a valid ERC20
token as the standard doesn't
depend on ERC165
. Make sure that the token is valid to avoid reverts without error codes
function _distribute(DistributionRecord calldata distribution, address to, bytes calldata signature)
internal
distributable(distribution)
nonReentrant;
_hashDistribution
Generates a struct hash for a distribution.
function _hashDistribution(DistributionRecord calldata distribution, address to) private view returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
distribution | DistributionRecord | the distribution information |
to | address |
_transferAssets
function _transferAssets(DistributionRecord calldata distribution, address to) internal;
_encodeDistributionKey
function _encodeDistributionKey(address source, string calldata poolName, address depositor)
internal
pure
returns (bytes32);
_verifySignature
function _verifySignature(DistributionRecord calldata distribution, address signer, address to, bytes calldata sig)
private
view;
_getDistributionStorage
Retrieves the storage for the pool metrics.
function _getDistributionStorage() private pure returns (MureDistributionStorage storage $);
_authorizeUpgrade
function _authorizeUpgrade(address) internal override onlyRole(DISTRIBUTION_ADMIN_ROLE);
Structs
MureDistributionStorage
Note: storage-location: erc7201:mure.MureDistribution
struct MureDistributionStorage {
mapping(bytes32 => DistributionHistory) distributions;
mapping(address => uint24) nonces;
}