Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mure: Smart Contract Suite

Welcome to Mure, a comprehensive suite of smart contracts designed for easy transactions regarding fundraising, distribution, and payments. Our project is built with security, efficiency, and scalability in mind, leveraging the robust capabilities of the Ethereum blockchain.

About

Mure aims to make safe, scalable and trustless transactions available for anyone, even if they don't have blockchain experience. Developed using Solidity, our contracts are meticulously designed to ensure secure, gas-efficient, and self-custodial management of funds and payments.

Powered by Foundry

Our development process is empowered by Foundry, a blazing-fast, portable, and modular toolkit for Ethereum application development. Foundry allows us to:

  • Test: Conduct comprehensive tests with flexibility and high performance.
  • Build: Compile Solidity code swiftly, ensuring rapid development cycles.
  • Deploy: Streamline smart contract deployment with precise control over network interactions.

Features

  • Fundraising: Collect funds from various sources and get automatic, on-chain bookkeeping for easy dispersement of on-chain assets.
  • Distribution: Distribute funds through airdrops or claims, leveraging the data stored from the deposits made by the customer.
  • Payments: Leverage the blockchain for the on-chain security and use it as a payments confirmation layer to hook into your off-chain store or service business.

API Documentation

Our APIs are used to interface with your smart contract and help with off-chain needs like KYC, AML, allowlisting, and so on.

For detailed information about our API documentation and how to interact with them, please refer to the API Documentation.

License

Mure is released under the BUSL-1.1. See the LICENSE file for more details.

Contact

For any inquiries or to discuss collaboration, please reach out to hello@mure.app.

Contents

Chargeable

Git Source

Author: Mure

Interface for the fees related functionalities for ClaimPlugin

Functions

calculateFee

function calculateFee(address poolContract, string calldata poolName, address depositor)
    external
    view
    returns (uint256);

Claimable

Git Source

Inherits: IERC165

Author: Mure

Interface for claim functionality of pools with support for ERC-165 detection.

Functions

claim

function claim(ClaimRecord calldata claim) external returns (uint256 depositDelta, uint256 claimDelta);

deltas

function deltas(ClaimRecord calldata claimRecord)
    external
    pure
    returns (uint256 depositDelta, uint256 claimDelta, uint256 fee);

Events

Claim

event Claim(address indexed depositor, uint256 indexed amount);

Errors

BalanceMismatch

error BalanceMismatch(uint256 collectedFunds, uint256 reserves);

Structs

ClaimRecord

struct ClaimRecord {
    address claimCurrency;
    address depositor;
    uint256 share;
    uint256 supply;
    uint256 claimReserves;
    uint256 depositReserves;
    uint256 deposit;
    uint256 totalCollected;
    string poolName;
    address custodian;
    uint16 feePercentage;
}

Config

Git Source

Inherits: IERC165

Author: Mure

Interface for MureConfig core with support for ERC-165 detection.

Functions

getAppDelegate

Must not revert, should return address(0) incase delegate does not exist

function getAppDelegate(address poolApp) external returns (address);

setAppDelegate

function setAppDelegate(address poolApp, address delegate) external;

verifyMureSignature

function verifyMureSignature(bytes32 structHash, bytes memory signature) external;

toggleWhitelistedSigner

function toggleWhitelistedSigner(address mureSigner_) external;

PoolConfig

Git Source

struct PoolConfig {
uint256 claimReserves;
uint256 depositReserves;
uint256 supply;
uint16 plugins;
uint16 feePercentage; // 0 to 10000
address claimCurrency;
}

DelegateErrorReason

Git Source

enum DelegateErrorReason {
TRANSFER_FAILURE,
INVALID_PERCENTAGE,
ALREADY_DEPOSITED_FUNDS
}

Delegatable

Git Source

Inherits: IERC165, PoolMetadata

Author: Mure

Interface for Delegate core with support for ERC-165 detection.

Functions

beforeDeposit

function beforeDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig) external;

afterDeposit

function afterDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig) external;

beforeRefund

function beforeRefund(string calldata poolName, address depositor) external;

afterRefund

function afterRefund(string calldata poolName, address depositor, uint256 amount) external;

withdrawPoolFunds

function withdrawPoolFunds(string calldata poolName) external;

depositPoolFunds

function depositPoolFunds(string calldata poolName, uint256 refundFunds, uint256 claimFunds) external;

deposit

function deposit(string calldata poolName, DepositArgs calldata depositArgs) external;

refund

function refund(string calldata poolName) external;

refund

function refund(string calldata poolName, address depositor, uint256 amount) external;

claim

function claim(string calldata poolName) external;

sendFunds

function sendFunds(address to, uint256 amount, address currency) external;

poolConfig

function poolConfig(string calldata poolName) external view returns (PoolConfig memory);

poolAddress

function poolAddress() external view returns (address);

deposited

function deposited(string calldata poolName, address depositor) external view returns (uint256);

getClaimCurrency

function getClaimCurrency(string calldata poolName) external view returns (address);

Events

PoolFundsDeposit

event PoolFundsDeposit(string poolName, uint256 indexed refundFunds, uint256 indexed claimFunds);

FundTransfer

event FundTransfer(address indexed to, uint256 indexed amount, address indexed currency);

ConfigUpdate

event ConfigUpdate(string poolName);

PoolContractUpdate

event PoolContractUpdate(address indexed poolContract);

Errors

PluginDisabled

error PluginDisabled(uint16 plugin);

PluginEnabled

error PluginEnabled(uint16 plugin);

InvalidAmount

error InvalidAmount();

DelegateError

error DelegateError(DelegateErrorReason reason);

DepositArgs

Git Source

Structure of deposit arguments

struct DepositArgs {
address depositor;
address payer;
uint256 amount;
bytes data;
FeeConfig feeConfig;
bytes depositSig;
bytes permitSig;
}

DepositRecord

Git Source

Structure of a deposit

struct DepositRecord {
uint112 amount;
uint8 nonce;
}

FeeConfig

Git Source

Structure of fee configuration

struct FeeConfig {
uint112 amount;
address recipient;
}

DepositPermit

Git Source

Structure of a deposit permit

struct DepositPermit {
address depositor;
address caller;
uint256 amount;
string poolName;
}

Depositable

Git Source

Author: Mure

Interface for deposit functionality of pools.

Functions

deposit

function deposit(string calldata poolName, DepositArgs calldata depositDetails) external;

deposited

function deposited(string calldata poolName, address depositor) external view returns (uint256);

Events

Deposit

event Deposit(string poolName, uint256 indexed amount, address indexed from, uint8 indexed nonce, bytes data);

Distributable

Git Source

Functions

distribute

function distribute(DistributionRecord calldata distribution, bytes calldata signature) external;

distribute

function distribute(DistributionRecord calldata distribution, address to, bytes calldata signature) external;

moveDistribution

function moveDistribution(address source, string calldata poolName, address from, address to) external;

distribution

function distribution(address source, string calldata poolName, address depositor)
    external
    view
    returns (DistributionHistory memory);

nonce

function nonce(address depositor) external view returns (uint24);

Events

Move

event Move(address indexed source, address indexed from, address indexed to, string poolName);

Distribution

event Distribution(
    address indexed token,
    address indexed source,
    address indexed depositor,
    address repository,
    string poolName,
    uint256 amount
);

Errors

UnsupportedSource

error UnsupportedSource();

UnsupportedToken

error UnsupportedToken();

Undistributed

error Undistributed();

Structs

DistributionRecord

struct DistributionRecord {
    address token;
    address source;
    address repository;
    address depositor;
    string poolName;
    uint256 amount;
    uint256 deadline;
}

DistributionHistory

struct DistributionHistory {
    uint256 distributed;
}

IERC165

Git Source

Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.

Functions

supportsInterface

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

function supportsInterface(bytes4 interfaceId) external view returns (bool);

IERC721Metadata

Git Source

Functions

name

function name() external view returns (string memory);

symbol

function symbol() external view returns (string memory);

tokenURI

function tokenURI(uint256 tokenId) external view returns (string memory);

IERC20Burnable

Git Source

Inherits: IERC20

Author: Mure

Interface for IERC20Burnable token extension by Openzeppelin.

Functions

burn

Destroys a value amount of tokens from the caller. See ERC20-_burn.

function burn(uint256 value) external;

burnFrom

Destroys a value amount of tokens from account, deducting from the caller's allowance. See ERC20-_burn and ERC20-allowance. Requirements:

  • the caller must have allowance for accounts's tokens of at least value.
function burnFrom(address account, uint256 value) external;

PoolApp

Git Source

Inherits: IERC165, Poolable, Depositable, Refundable, PoolMetadata

Author: Mure

Interface for MurePool core with support for ERC-165 detection.

Functions

withdrawPoolFunds

function withdrawPoolFunds(string calldata poolName) external;

refundTo

function refundTo(string calldata poolName, address depositor, uint256 amount) external;

nonce

function nonce(string calldata poolName, address depositor) external view returns (uint8);

updatePoolPaused

function updatePoolPaused(string calldata poolName, bool pause) external;

updatePoolRefundable

function updatePoolRefundable(string calldata poolName, bool refundable) external;

depositPoolFunds

function depositPoolFunds(string calldata poolName, address depositor, uint256 amount) external;

Structs

Transaction

struct Transaction {
    address depositor;
    uint112 amount;
    Operation operation;
}

TransactionWithMetadata

struct TransactionWithMetadata {
    address depositor;
    uint112 amount;
    Operation operation;
    bytes data;
}

Enums

Operation

enum Operation {
    Deposit,
    Withdrawal
}

PoolState

Git Source

Structure of a pool

struct PoolState {
uint112 totalCollected;
uint112 poolSize;
uint16 flags;
uint16 depositors;
uint32 endTime; // uint32 => year 2106
address currency;
address custodian;
address signer;
}

PoolMetadata

Git Source

Author: Mure

Interface for pool information like its state and existence

Functions

isPoolActive

function isPoolActive(string calldata poolName) external view returns (bool);

poolExists

function poolExists(string calldata pool) external view returns (bool);

poolState

function poolState(string calldata poolName) external view returns (PoolState memory);

withdrawableAmount

function withdrawableAmount(string calldata poolName) external view returns (uint112);

PoolParameters

Git Source

Structure of parameters of a pool

struct PoolParameters {
uint112 poolSize;
uint32 endTime; // uint32 => year 2106
uint16 flags;
address currency;
address custodian;
address signer;
}

PoolMetrics

Git Source

Structure for pool metrics. Could be updated in future

struct PoolMetrics {
uint112 totalWithdrawn;
}

PoolParameter

Git Source

enum PoolParameter {
POOL_SIZE,
END_TIME, // UINT32 => YEAR 2106
FLAGS,
DEPOSITORS,
CURRENCY,
CUSTODIAN,
SIGNER
}

PoolErrorReason

Git Source

enum PoolErrorReason {
POOL_SIZE_TOO_SMALL,
TRANSFER_FAILURE,
ARITHMETIC_OUT_OF_BOUNDS,
ALREADY_INVESTED_POOL,
INVALID_POOL_TYPE,
POOL_EMPTY
}

Poolable

Git Source

Author: Mure

Interface for pool administration functionality and pool errors.

Functions

createPool

function createPool(string calldata poolName, PoolParameters calldata params, bytes calldata sig) external;

updatePool

function updatePool(string calldata poolName, PoolParameters calldata params) external;

poolMetrics

function poolMetrics(string calldata poolName) external view returns (PoolMetrics memory);

Events

PoolCreation

event PoolCreation(string poolName);

PoolUpdate

event PoolUpdate(string poolName);

Withdrawal

event Withdrawal(string poolName, uint256 indexed amount, address indexed to, uint8 indexed nonce, bytes data);

ConsumeDepositorNonce

event ConsumeDepositorNonce(string poolName, address indexed depositor, uint8 nonce);

FundWithdrawal

event FundWithdrawal(string poolName, uint256 indexed amount, address indexed to, bytes data);

Errors

PoolClosed

error PoolClosed();

PoolOpen

error PoolOpen();

PoolError

error PoolError(PoolErrorReason reason);

IllegalPoolState

error IllegalPoolState(PoolParameter param);

IllegalPoolOperation

error IllegalPoolOperation(PoolErrorReason reason);

PoolInitialized

error PoolInitialized();

PoolFull

error PoolFull();

PoolPaused

error PoolPaused();

PoolNotEmpty

error PoolNotEmpty();

Refundable

Git Source

Author: Mure

Interface for refund fuctionality for pools with support for ERC-165 detection.

Functions

refund

function refund(string calldata poolName) external;

updatePoolRefundable

function updatePoolRefundable(string calldata poolName, bool refundable) external;

Events

Refund

event Refund(string poolName, uint256 indexed amount, address indexed depositor, bytes data);

Errors

DepositNotFound

error DepositNotFound();

Contents

MureErrors

Git Source

Author: Mure

Library with global errors for Mure

Errors

InvalidAddress

thrown when address is invalid, eg: zero address

error InvalidAddress(address addr);

SignatureExpired

thrown when a signature has expired before verification

error SignatureExpired();

Unauthorized

thrown when any restricted operation is performed by an unauthorized entity

error Unauthorized();

InvalidDelegate

thrown when address is not a valid delegate

error InvalidDelegate();

PoolNotFound

thrown when pool with given parameters is not found

error PoolNotFound();

InvalidFee

thrown when fee is invalid

error InvalidFee();

NoAdmin

thrown when no member has a DEFAULT_ADMIN_ROLE role

error NoAdmin();

Contents

AxlOwnable

Git Source

Inherits: IOwnable

Title: AxlOwnable

A contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The owner account is set through ownership transfer. This module makes it possible to transfer the ownership of the contract to a new account in one step, as well as to an interim pending owner. In the second flow the ownership does not change until the pending owner accepts the ownership transfer.

State Variables

_OWNER_SLOT

bytes32 internal constant _OWNER_SLOT = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0

_OWNERSHIP_TRANSFER_SLOT

bytes32 internal constant _OWNERSHIP_TRANSFER_SLOT =
    0x9855384122b55936fbfb8ca5120e63c6537a1ac40caf6ae33502b3c5da8c87d1

Functions

constructor

Initializes the contract by transferring ownership to the owner parameter.

constructor(address _owner) ;

Parameters

NameTypeDescription
_owneraddressAddress to set as the initial owner of the contract

onlyOwner

Modifier that throws an error if called by any account other than the owner.

modifier onlyOwner() ;

owner

Returns the current owner of the contract.

function owner() public view returns (address owner_);

Returns

NameTypeDescription
owner_addressThe current owner of the contract

pendingOwner

Returns the pending owner of the contract.

function pendingOwner() public view returns (address owner_);

Returns

NameTypeDescription
owner_addressThe pending owner of the contract

transferOwnership

Transfers ownership of the contract to a new account newOwner.

Can only be called by the current owner.

function transferOwnership(address newOwner) external virtual onlyOwner;

Parameters

NameTypeDescription
newOwneraddressThe address to transfer ownership to

proposeOwnership

Propose to transfer ownership of the contract to a new account newOwner.

Can only be called by the current owner. The ownership does not change until the new owner accepts the ownership transfer.

function proposeOwnership(address newOwner) external virtual onlyOwner;

Parameters

NameTypeDescription
newOwneraddressThe address to transfer ownership to

acceptOwnership

Accepts ownership of the contract.

Can only be called by the pending owner

function acceptOwnership() external virtual;

_transferOwnership

Internal function to transfer ownership of the contract to a new account newOwner.

Called in the constructor to set the initial owner.

function _transferOwnership(address newOwner) internal virtual;

Parameters

NameTypeDescription
newOwneraddressThe address to transfer ownership to

Upgradable

Git Source

Inherits: AxlOwnable, Implementation, IUpgradable

Title: Upgradable Contract

This contract provides an interface for upgradable smart contracts and includes the functionality to perform upgrades.

State Variables

_IMPLEMENTATION_SLOT

bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc

Functions

constructor

Constructor sets the implementation address to the address of the contract itself

This is used in the onlyProxy modifier to prevent certain functions from being called directly on the implementation contract itself.

The owner is initially set as address(1) because the actual owner is set within the proxy. It is not set as the zero address because Ownable is designed to throw an error for ownership transfers to the zero address.

constructor() AxlOwnable(address(1));

implementation

Returns the address of the current implementation

function implementation() public view returns (address implementation_);

Returns

NameTypeDescription
implementation_addressAddress of the current implementation

upgrade

Upgrades the contract to a new implementation

This function is only callable by the owner.

function upgrade(address newImplementation, bytes32 newImplementationCodeHash, bytes calldata params)
    external
    override
    onlyOwner;

Parameters

NameTypeDescription
newImplementationaddressThe address of the new implementation contract
newImplementationCodeHashbytes32The codehash of the new implementation contract
paramsbytesOptional setup parameters for the new implementation contract

setup

Sets up the contract with initial data

This function is only callable by the proxy contract.

function setup(bytes calldata data) external override(IImplementation, Implementation) onlyProxy;

Parameters

NameTypeDescription
databytesInitialization data for the contract

_setup

Internal function to set up the contract with initial data

This function should be implemented in derived contracts.

function _setup(bytes calldata data) internal virtual;

Parameters

NameTypeDescription
databytesInitialization data for the contract

MockAxelarGasService

Git Source

Inherits: InterchainGasEstimation, Upgradable, IAxelarGasService

Title: AxelarGasService

This contract manages gas payments and refunds for cross-chain communication on the Axelar network.

The owner address of this contract should be the microservice that pays for gas.

Users pay gas for cross-chain calls, and the gasCollector can collect accumulated fees and/or refund users if needed.

State Variables

gasCollector

address public immutable gasCollector

Functions

constructor

Constructs the AxelarGasService contract.

constructor(address gasCollector_) ;

Parameters

NameTypeDescription
gasCollector_addressThe address of the gas collector

_setup

function _setup(bytes calldata data) internal override;

onlyCollector

Modifier that ensures the caller is the designated gas collector.

modifier onlyCollector() ;

payGas

Pay for gas for any type of contract execution on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

If estimateOnChain is true, the function will estimate the gas cost and revert if the payment is insufficient.

function payGas(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    uint256 executionGasLimit,
    bool estimateOnChain,
    address refundAddress,
    bytes calldata params
) external payable override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call
executionGasLimituint256The gas limit for the contract call
estimateOnChainboolFlag to enable on-chain gas estimation
refundAddressaddressThe address where refunds, if any, should be sent
paramsbytesAdditional parameters for gas payment

payGasForContractCall

Pay for gas using ERC20 tokens for a contract call on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payGasForContractCall(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    address gasToken,
    uint256 gasFeeAmount,
    address refundAddress
) external override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call
gasTokenaddressThe address of the ERC20 token used to pay for gas
gasFeeAmountuint256The amount of tokens to pay for gas
refundAddressaddressThe address where refunds, if any, should be sent

payGasForContractCallWithToken

Pay for gas using ERC20 tokens for a contract call with tokens on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payGasForContractCallWithToken(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    string memory symbol,
    uint256 amount,
    address gasToken,
    uint256 gasFeeAmount,
    address refundAddress
) external override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call with tokens will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call with tokens
symbolstringThe symbol of the token to be sent with the call
amountuint256The amount of tokens to be sent with the call
gasTokenaddressThe address of the ERC20 token used to pay for gas
gasFeeAmountuint256The amount of tokens to pay for gas
refundAddressaddressThe address where refunds, if any, should be sent

payNativeGasForContractCall

Pay for gas using native currency for a contract call on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payNativeGasForContractCall(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    address refundAddress
) external payable override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call
refundAddressaddressThe address where refunds, if any, should be sent

payNativeGasForContractCallWithToken

Pay for gas using native currency for a contract call with tokens on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payNativeGasForContractCallWithToken(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    string calldata symbol,
    uint256 amount,
    address refundAddress
) external payable override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call with tokens will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call with tokens
symbolstringThe symbol of the token to be sent with the call
amountuint256The amount of tokens to be sent with the call
refundAddressaddressThe address where refunds, if any, should be sent

payGasForExpressCall

Pay for gas using ERC20 tokens for an express contract call on a destination chain.

This function is called on the source chain before calling the gateway to express execute a remote contract.

function payGasForExpressCall(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    address gasToken,
    uint256 gasFeeAmount,
    address refundAddress
) external override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call
gasTokenaddressThe address of the ERC20 token used to pay for gas
gasFeeAmountuint256The amount of tokens to pay for gas
refundAddressaddressThe address where refunds, if any, should be sent

payGasForExpressCallWithToken

Pay for gas using ERC20 tokens for an express contract call with tokens on a destination chain.

This function is called on the source chain before calling the gateway to express execute a remote contract.

function payGasForExpressCallWithToken(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    string memory symbol,
    uint256 amount,
    address gasToken,
    uint256 gasFeeAmount,
    address refundAddress
) external override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call with tokens will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call with tokens
symbolstringThe symbol of the token to be sent with the call
amountuint256The amount of tokens to be sent with the call
gasTokenaddressThe address of the ERC20 token used to pay for gas
gasFeeAmountuint256The amount of tokens to pay for gas
refundAddressaddressThe address where refunds, if any, should be sent

payNativeGasForExpressCall

Pay for gas using native currency for an express contract call on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payNativeGasForExpressCall(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    address refundAddress
) external payable override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call
refundAddressaddressThe address where refunds, if any, should be sent

payNativeGasForExpressCallWithToken

Pay for gas using native currency for an express contract call with tokens on a destination chain.

This function is called on the source chain before calling the gateway to execute a remote contract.

function payNativeGasForExpressCallWithToken(
    address sender,
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    string calldata symbol,
    uint256 amount,
    address refundAddress
) external payable override;

Parameters

NameTypeDescription
senderaddressThe address making the payment
destinationChainstringThe target chain where the contract call with tokens will be made
destinationAddressstringThe target address on the destination chain
payloadbytesData payload for the contract call with tokens
symbolstringThe symbol of the token to be sent with the call
amountuint256The amount of tokens to be sent with the call
refundAddressaddressThe address where refunds, if any, should be sent

addGas

Add additional gas payment using ERC20 tokens after initiating a cross-chain call.

This function can be called on the source chain after calling the gateway to execute a remote contract.

function addGas(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress)
    external
    override;

Parameters

NameTypeDescription
txHashbytes32The transaction hash of the cross-chain call
logIndexuint256The log index for the cross-chain call
gasTokenaddressThe ERC20 token address used to add gas
gasFeeAmountuint256The amount of tokens to add as gas
refundAddressaddressThe address where refunds, if any, should be sent

addNativeGas

Add additional gas payment using native currency after initiating a cross-chain call.

This function can be called on the source chain after calling the gateway to execute a remote contract.

function addNativeGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable override;

Parameters

NameTypeDescription
txHashbytes32The transaction hash of the cross-chain call
logIndexuint256The log index for the cross-chain call
refundAddressaddressThe address where refunds, if any, should be sent

addExpressGas

Add additional gas payment using ERC20 tokens after initiating an express cross-chain call.

This function can be called on the source chain after calling the gateway to express execute a remote contract.

function addExpressGas(
    bytes32 txHash,
    uint256 logIndex,
    address gasToken,
    uint256 gasFeeAmount,
    address refundAddress
) external override;

Parameters

NameTypeDescription
txHashbytes32The transaction hash of the cross-chain call
logIndexuint256The log index for the cross-chain call
gasTokenaddressThe ERC20 token address used to add gas
gasFeeAmountuint256The amount of tokens to add as gas
refundAddressaddressThe address where refunds, if any, should be sent

addNativeExpressGas

Add additional gas payment using native currency after initiating an express cross-chain call.

This function can be called on the source chain after calling the gateway to express execute a remote contract.

function addNativeExpressGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable override;

Parameters

NameTypeDescription
txHashbytes32The transaction hash of the cross-chain call
logIndexuint256The log index for the cross-chain call
refundAddressaddressThe address where refunds, if any, should be sent

updateGasInfo

Updates the gas price for a specific chain.

This function is called by the gas oracle to update the gas prices for a specific chains.

function updateGasInfo(string[] calldata chains, GasInfo[] calldata gasUpdates) external onlyCollector;

Parameters

NameTypeDescription
chainsstring[]Array of chain names
gasUpdatesGasInfo[]Array of gas updates

collectFees

Allows the gasCollector to collect accumulated fees from the contract.

Use address(0) as the token address for native currency.

function collectFees(address payable receiver, address[] calldata tokens, uint256[] calldata amounts)
    external
    onlyCollector;

Parameters

NameTypeDescription
receiveraddress payableThe address to receive the collected fees
tokensaddress[]Array of token addresses to be collected
amountsuint256[]Array of amounts to be collected for each respective token address

refund

Deprecated refund function, kept for backward compatibility.

function refund(address payable receiver, address token, uint256 amount) external onlyCollector;

refund

Refunds gas payment to the receiver in relation to a specific cross-chain transaction.

Only callable by the gasCollector.

Use address(0) as the token address to refund native currency.

function refund(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount)
    external
    onlyCollector;

Parameters

NameTypeDescription
txHashbytes32The transaction hash of the cross-chain call
logIndexuint256The log index for the cross-chain call
receiveraddress payableThe address to receive the refund
tokenaddressThe token address to be refunded
amountuint256The amount to refund

_refund

Internal function to implement gas refund logic.

function _refund(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount)
    private;

contractId

Returns a unique identifier for the contract.

function contractId() external pure returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 Hash of the contract identifier

MockAxelarGateway

Git Source

Inherits: IAxelarGatewayWithToken

Title: AxelarGateway Contract

This contract serves as the gateway for cross-chain contract calls, and token transfers within the Axelar network. It includes functions for sending tokens, calling contracts, and validating contract calls. The contract is managed via the decentralized governance mechanism on the Axelar network.

EternalStorage is used to simplify storage for upgradability, and InterchainGovernance module is used for governance.

State Variables

tokenMapping

mapping(string => address) tokenMapping

Functions

constructor

constructor() ;

sendToken

Sends tokens to another chain.

Initiates a cross-chain token transfer through the gateway to the specified destination chain and recipient.

function sendToken(
    string calldata destinationChain,
    string calldata destinationAddress,
    string calldata symbol,
    uint256 amount
) external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
destinationAddressstringThe address of the recipient on the destination chain.
symbolstringThe symbol of the token being transferred.
amountuint256The amount of the tokens being transferred.

callContractWithToken

Makes a contract call on another chain with an associated token transfer.

Initiates a cross-chain contract call through the gateway that includes a token transfer to the specified contract on the destination chain.

function callContractWithToken(
    string calldata destinationChain,
    string calldata contractAddress,
    bytes calldata payload,
    string calldata symbol,
    uint256 amount
) external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
contractAddressstringThe address of the contract on the destination chain.
payloadbytesThe payload data to be used in the contract call.
symbolstringThe symbol of the token being transferred.
amountuint256The amount of the tokens being transferred.

isContractCallAndMintApproved

Checks if a contract call with token minting is approved.

Determines whether a given contract call, identified by the commandId and payloadHash, involving token minting is approved.

function isContractCallAndMintApproved(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    address contractAddress,
    bytes32 payloadHash,
    string calldata symbol,
    uint256 amount
) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
contractAddressaddressThe address of the contract where the call will be executed.
payloadHashbytes32The keccak256 hash of the payload data.
symbolstringThe symbol of the token associated with the minting.
amountuint256The amount of the tokens to be minted.

Returns

NameTypeDescription
<none>boolTrue if the contract call with token minting is approved, false otherwise.

validateContractCallAndMint

Validates and approves a contract call with token minting.

Validates the given contract call information and marks it as approved if valid. It also involves the minting of tokens.

function validateContractCallAndMint(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes32 payloadHash,
    string calldata symbol,
    uint256 amount
) external returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to validate.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
payloadHashbytes32The keccak256 hash of the payload data.
symbolstringThe symbol of the token associated with the minting.
amountuint256The amount of the tokens to be minted.

Returns

NameTypeDescription
<none>boolTrue if the contract call with token minting is validated and approved, false otherwise.

tokenAddresses

Retrieves the address of a token given its symbol.

Gets the contract address of the token registered with the given symbol.

function tokenAddresses(string memory symbol) external view returns (address);

Parameters

NameTypeDescription
symbolstringThe symbol of the token to retrieve the address for.

Returns

NameTypeDescription
<none>addressThe contract address of the token corresponding to the given symbol.

setTokenAddress

Sets the address of a token given its symbol.

Sets the contract address of the token registered with the given symbol.

function setTokenAddress(string memory symbol, address tokenAddress) external;

Parameters

NameTypeDescription
symbolstringThe symbol of the token.
tokenAddressaddressThe address of the token.

callContract

Sends a contract call to another chain.

Initiates a cross-chain contract call through the gateway to the specified destination chain and contract.

function callContract(string calldata destinationChain, string calldata contractAddress, bytes calldata payload)
    external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
contractAddressstringThe address of the contract on the destination chain.
payloadbytesThe payload data to be used in the contract call.

isContractCallApproved

Checks if a contract call is approved.

Determines whether a given contract call, identified by the commandId and payloadHash, is approved.

function isContractCallApproved(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    address contractAddress,
    bytes32 payloadHash
) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
contractAddressaddressThe address of the contract where the call will be executed.
payloadHashbytes32The keccak256 hash of the payload data.

Returns

NameTypeDescription
<none>boolTrue if the contract call is approved, false otherwise.

validateContractCall

Validates and approves a contract call.

Validates the given contract call information and marks it as approved if valid.

function validateContractCall(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes32 payloadHash
) external returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to validate.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
payloadHashbytes32The keccak256 hash of the payload data.

Returns

NameTypeDescription
<none>boolTrue if the contract call is validated and approved, false otherwise.

isCommandExecuted

Checks if a command has been executed.

Determines whether a command, identified by the commandId, has been executed.

function isCommandExecuted(bytes32 commandId) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.

Returns

NameTypeDescription
<none>boolTrue if the command has been executed, false otherwise.

ERC20BurnableMock

Git Source

Inherits: ERC20Burnable

Functions

constructor

constructor(string memory name, string memory symbol) ERC20(name, symbol);

mint

function mint(address to, uint256 amount) public;

ERC20Mock

Git Source

Inherits: ERC20

Functions

constructor

constructor() ERC20("ERC20Mock", "E20M");

mint

function mint(address account, uint256 amount) external;

burn

function burn(address account, uint256 amount) external;

MockERC20

Git Source

Inherits: ERC20

Functions

constructor

constructor(string memory name, string memory symbol) ERC20(name, symbol);

mint

function mint(address to, uint256 amount) public;

Contents

ClaimPlugin

Git Source

Inherits: UUPSUpgradeable, OwnableUpgradeable, ERC165Upgradeable, Claimable

Author: Mure Implements UUPSUpgradeable for upgradeability, OwnableUpgradeable for access control, ERC165Upgradeable for interface support, and Claimable interface for compatibility checks. Facilitates the calculation and execution of reward claims, allowing depositors to receive their entitled rewards along with their shares from the total collected pool funds.

Contract managing reward distribution to users of an application.

Functions

initialize

function initialize(address owner) external initializer;

claim

Sends reward funds from the delegate to depositor.

function claim(ClaimRecord calldata claimRecord) external returns (uint256 depositDelta, uint256 claimDelta);

Parameters

NameTypeDescription
claimRecordClaimRecordstruct containing all information needed to compute and execute a claimRecord. See Claimable.ClaimRecord for more information

deltas

Returns the refund amount, claim amount and fee.

function deltas(ClaimRecord calldata claimRecord)
    public
    pure
    returns (uint256 depositDelta, uint256 claimDelta, uint256 fee);

Parameters

NameTypeDescription
claimRecordClaimRecordstruct containing all information needed to compute and execute a claimRecord. See Claimable.ClaimRecord for more information

Returns

NameTypeDescription
depositDeltauint256amount from the original deposit to be refunded
claimDeltauint256amount from the claim reserves to be claimed
feeuint256fee to be charged from claimDelta

_calculateShare

Calculates the user share amount.

function _calculateShare(uint256 share, uint256 supply, uint256 reserve) private pure returns (uint256);

Parameters

NameTypeDescription
shareuint256share of the user
supplyuint256total supply
reserveuint256current reserve

calculateFee

Calculates the fee to be charged.

function calculateFee(uint256 amount, uint256 feePercentage) private pure returns (uint256);

Parameters

NameTypeDescription
amountuint256total amount
feePercentageuint256fee percentage in basis points

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable, IERC165)
    returns (bool);

_authorizeUpgrade

required by the OZ UUPS module

function _authorizeUpgrade(address) internal override onlyOwner;

Contents

Constants

Git Source

POOL_OPERATOR_ROLE

Role allows user to create and update pools along with pool administration

bytes32 constant POOL_OPERATOR_ROLE = keccak256("POOL_OPERATOR")

DEFAULT_ADMIN_ROLE

Default RBAC admin role

bytes32 constant DEFAULT_ADMIN_ROLE = 0x00

Role

Git Source

Enum for pool member roles

enum Role {
DEFAULT_ADMIN,
POOL_OPERATOR
}

AppMember

Git Source

Struct for a pool member

struct AppMember {
address member;
Role role;
}

Constants

Git Source

APP_MEMBER_HASH

Struct hash for validating app deployments keccak256("AppMember(address member,uint8 role)")

bytes32 constant APP_MEMBER_HASH = 0xe3128a5e7b51cb6b5d75b976cb4b51c8420a8c2a5c60709fd3af893c19fc754a

FEE_CONFIG_HASH

Struct hash for validating deposit fee config keccak256("FeeConfig(uint112 amount,address recipient)")

bytes32 constant FEE_CONFIG_HASH = 0xfec57672da62b01f006c6c3af74423cc502012ed8246681ae395eb5dbaa8e825

Delegate

Git Source

Inherits: ERC165Upgradeable, ReentrancyGuardUpgradeable, AccessControlUpgradeable, Delegatable

Author: Mure Implements AccessControlUpgradeable for access control, UUPSUpgradeable for efficient upgrades, ERC165Upgradeable for interface support, and Delegatable for plugin compatibility. Manages storage for delegated functions, including user share per pool, pool configurations, pool contract,and plugins. Also provides hooks for custom functionality in pool-related operations. Delegate handles the various plugins that might be required by a particular application, for example, for reward claims and for fees deduction. Each application can subscribe to one or more plugins which will then link to the delegate for that application and be available to use. NOTE: A single instance of a delegate shall be bound to a single instance of the pool contract.

Abstract contract governing delegated functionality for the applications in Mure protocol.

State Variables

DelegateStorageLocation

Struct hash for storage location keccak256(abi.encode(uint256(keccak256("mure.Delegate")) - 1)) & ~bytes32(uint256(0xff))

bytes32 internal constant DelegateStorageLocation =
    0xc4200f32c1c30cddd40d021baa377d96970df44812e3c252691c8e5d8633a500

CLAIM

Defines if the claim plugin is enabled

uint16 constant CLAIM = 0x01

DELEGATE_OPERATOR_ROLE

Role allows user to create and update pools along with pool administration

bytes32 public constant DELEGATE_OPERATOR_ROLE = keccak256("DELEGATE_OPERATOR")

Functions

onlyPool

modifier onlyPool() ;

validPool

modifier validPool(string calldata poolName) ;

onlyPlugin

modifier onlyPlugin() ;

pluginEnabled

modifier pluginEnabled(string calldata poolName, uint16 plugin) ;

pluginDisabled

modifier pluginDisabled(string calldata poolName, uint16 plugin) ;

onlyCustodianOrOwner

modifier onlyCustodianOrOwner(string calldata poolName) ;

__Delegate_init

Initializes the contract setting owner, poolContract, and claimPlugin.

function __Delegate_init(address owner, address poolContract_, address claimPlugin_) internal onlyInitializing;

withdrawPoolFunds

Places a delegated call to withdraw pool funds.

pauses the pool and locks refunds

function withdrawPoolFunds(string calldata poolName) external onlyCustodianOrOwner(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool

depositPoolFunds

Deposits the withdrawn pool funds back. This operation assumes that the contract is an approved spender of the depositor.

Transfers the original collected funds back to the pool app. Additional funds stay on the delegate

Unpauses the pool and unlocks refunds

function depositPoolFunds(string calldata poolName, uint256 depositFunds, uint256 claimFunds)
    external
    onlyCustodianOrOwner(poolName)
    nonReentrant;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositFundsuint256the amount to be deposited back to the pool
claimFundsuint256funds for claims

share

Returns the user depositor value.

function share(string calldata poolName, address depositor) external view returns (uint256);

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressaddress of the depositor

state

Returns the pool config state.

function state(string calldata poolName) external view returns (PoolConfig memory);

Parameters

NameTypeDescription
poolNamestringname of the pool

claim

Processes user claims.

function claim(string calldata poolName) external pluginEnabled(poolName, CLAIM) validPool(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool

activateClaimPlugin

Activates the claim plugin.

function activateClaimPlugin(string calldata poolName, address claimCurrency)
    external
    onlyRole(DELEGATE_OPERATOR_ROLE)
    validPool(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool to activate the plugin on
claimCurrencyaddress

deactivateClaimPlugin

Deactivates the claim plugin.

function deactivateClaimPlugin(string calldata poolName)
    external
    onlyRole(DELEGATE_OPERATOR_ROLE)
    validPool(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool to deactivate the plugin on

setPoolClaimCurrency

Sets the pool claim currency.

function setPoolClaimCurrency(string calldata poolName, address currency)
    external
    onlyRole(DELEGATE_OPERATOR_ROLE)
    validPool(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool
currencyaddressthe claim currency to be set

setPoolFeePercentage

Sets the pools fee percentage.

Can only be called if the fee plugin is enabled.

Fee percentage is in basis points (1 = 0.01%).

function setPoolFeePercentage(string calldata poolName, uint16 feePercentage)
    external
    onlyRole(DELEGATE_OPERATOR_ROLE)
    validPool(poolName);

Parameters

NameTypeDescription
poolNamestringname of the pool
feePercentageuint16the fee percentage to be set

setPoolContract

Sets the pool app address.

Set as address(0) to deprecate delegate.

function setPoolContract(address poolContract) external onlyRole(DELEGATE_OPERATOR_ROLE);

Parameters

NameTypeDescription
poolContractaddressaddress of the pool app

setClaimPlugin

Sets the claim plugin address.

function setClaimPlugin(address pluginAddress) external onlyRole(DELEGATE_OPERATOR_ROLE);

Parameters

NameTypeDescription
pluginAddressaddressaddress of the claim plugin

deposit

Places a delegated call to deposit on the pool app. This operation assumes that the pool app is an approved spender of the depositor.

function deposit(string calldata poolName, DepositArgs calldata depositArgs) external nonReentrant;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositArgsDepositArgsdeposit args as the DepositArgs struct

refund

Places a delegated call for refund on the pool app.

function refund(string calldata poolName) external nonReentrant pluginDisabled(poolName, CLAIM);

Parameters

NameTypeDescription
poolNamestringname of the pool

refund

Places a delegated call for refund on the pool app.

function refund(string calldata poolName, address depositor, uint256 amount) external nonReentrant onlyPlugin;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddress
amountuint256amount to refund

sendFunds

Transfers funds to a specific address.

Can only be called by a verified plugin.

function sendFunds(address to, uint256 amount, address currency) external onlyPlugin nonReentrant;

Parameters

NameTypeDescription
toaddressaddress to be transferred to
amountuint256the amount to be transferred
currencyaddressthe currency to be transferred

previewClaim

Returns the refund amount, claim amount and fee.

function previewClaim(string calldata poolName, address depositor)
    external
    view
    returns (uint256 depositDelta, uint256 claimDelta, uint256 fee);

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressaddress of the depositor

Returns

NameTypeDescription
depositDeltauint256amount from the original deposit to be refunded
claimDeltauint256amount from the claim reserves to be claimed
feeuint256fee to be charged from claimDelta

beforeDeposit

Hook to be called by the pool app before a deposit.

function beforeDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig)
    external
    virtual
    onlyPool;

Parameters

NameTypeDescription
poolNamestringname of the pool
amountuint256the amount to be deposited
depositoraddressaddress of the depositor
sigbytesthe signature used for deposit

afterDeposit

Hook to be called by the pool app after a deposit.

function afterDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig)
    external
    virtual
    onlyPool;

Parameters

NameTypeDescription
poolNamestringname of the pool
amountuint256the amount to be deposited
depositoraddressaddress of the depositor
sigbytesthe signature used for deposit

beforeRefund

Hook to be called by the pool app before a refund.

function beforeRefund(string calldata poolName, address depositor) external virtual onlyPool;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressaddress of the depositor

afterRefund

Hook to be called by the pool app after a refund.

function afterRefund(string calldata poolName, address depositor, uint256 amount) external virtual onlyPool;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressaddress of the depositor
amountuint256refunded amount

withdrawCurrency

Withdraw any token from the contract. This should only be used in emergencies as this can withdraw capital from any pool, be it active or not. Always prefer using withdraw over this function, unless you need clean up the contract by, e.g., burning garbage tokens.

function withdrawCurrency(address receiver, address currency) external onlyRole(DELEGATE_OPERATOR_ROLE);

Parameters

NameTypeDescription
receiveraddressthe address to which the token will be transferred
currencyaddressthe address of the token contract

poolConfig

Retrieves the config of the specified pool.

function poolConfig(string calldata poolName) external view returns (PoolConfig memory);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the config of

poolAddress

Retrieves the pool app address.

function poolAddress() external view returns (address);

claimPluginAddress

Retrieves the claim plugin address.

function claimPluginAddress() external view returns (address);

isPoolActive

Checks if the specified pool is active.

function isPoolActive(string calldata poolName) external view returns (bool);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check if it is active

withdrawableAmount

Checks if the specified pool is active.

function withdrawableAmount(string calldata poolName) external view returns (uint112);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check if it is active

poolState

Retrieves the state of the specified pool.

Requires the pool to exist.

function poolState(string calldata poolName) external view returns (PoolState memory);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the state of

deposited

Retrieves the amount deposited by the specified depositor in the specified pool.

Requires the pool to exist.

function deposited(string calldata poolName, address depositor) external view returns (uint256);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the deposit from
depositoraddressthe address of the depositor

poolExists

Checks if the specified pool exists.

function poolExists(string calldata poolName) external view returns (bool);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check for existence

getClaimCurrency

Returns the address of the claim currency for a pool.

function getClaimCurrency(string calldata poolName) external view returns (address);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check for claim currency

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable, IERC165, AccessControlUpgradeable)
    returns (bool);

_transferCurrency

Transfers currency between two addresses with a specified amount of a given currency.

function _transferCurrency(address from, address to, uint256 amount, address currency) internal;

Parameters

NameTypeDescription
fromaddressthe address from which the transfer is initiated
toaddressthe address to which the transfer is made
amountuint256the amount of the currency being transferred
currencyaddressthe address of the currency being transferred

_refund

function _refund(address poolContract, string calldata poolName, address depositor, uint256 amount) internal;

_addSupply

function _addSupply(string calldata poolName, address depositor, uint256 supply) internal;

_deductSupply

function _deductSupply(string calldata poolName, address depositor, uint256 supply) internal;

_claim

function _claim(string calldata poolName, uint256 totalCollected, address custodian, uint256 userDeposit) internal;

_pluginEnabled

Checks whether a specific plugin is enabled.

function _pluginEnabled(uint16 plugins, uint16 plugin) internal pure returns (bool);

Parameters

NameTypeDescription
pluginsuint16the set of plugins being checked
pluginuint16the plugin being checked for activation

_activatePlugin

Activates the specified plugin.

function _activatePlugin(uint16 plugins, uint16 plugin) internal pure returns (uint16);

Parameters

NameTypeDescription
pluginsuint16the set of plugins being modified
pluginuint16the plugin being activated

_deactivatePlugin

Deactivates the specified plugin.

function _deactivatePlugin(uint16 plugins, uint16 plugin) internal pure returns (uint16);

Parameters

NameTypeDescription
pluginsuint16the set of plugins being modified
pluginuint16the plugin being activated

_getStorage

Retrieves the storage for the Delegate contract.

function _getStorage() internal pure returns (DelegateStorage storage $);

_isPlugin

Checks if the provided address is a plugin.

function _isPlugin(address address_) internal view returns (bool);

Parameters

NameTypeDescription
address_addressthe address to check

Events

PluginActivated

event PluginActivated(string poolName, uint16 indexed plugin);

PluginDeactivated

event PluginDeactivated(string poolName, uint16 indexed plugin);

PluginUpdate

event PluginUpdate(address indexed pluginAddress, uint16 indexed plugin);

Structs

DelegateStorage

Note: storage-location: erc7201:mure.Delegate

struct DelegateStorage {
    mapping(string => mapping(address => uint256)) shares;
    mapping(string => PoolConfig) poolConfigs;
    address poolContract;
    address claimPlugin;
}

MureAxlTransceiver

Git Source

Inherits: AxelarExecutableWithToken, Context

State Variables

gasService

IAxelarGasService public immutable gasService

Functions

constructor

constructor(address gateway_, address gasService_) AxelarExecutableWithToken(gateway_);

Parameters

NameTypeDescription
gateway_addressaddress of axl gateway on deployed chain
gasService_addressaddress of axl gas service on deployed chain

transmitMessageWithToken

function transmitMessageWithToken(
    string calldata destinationChain,
    string calldata destinationAddress,
    bytes calldata payload,
    string calldata symbol,
    uint256 amount
) external payable;

_execute

function _execute(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes calldata payload
) internal override;

_executeWithToken

logic to be executed on dest chain

this is triggered automatically by relayer

function _executeWithToken(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes calldata payload,
    string calldata tokenSymbol,
    uint256 amount
) internal override;

Parameters

NameTypeDescription
commandIdbytes32
sourceChainstring
sourceAddressstring
payloadbytesencoded gmp message sent from src chain
tokenSymbolstringsymbol of token sent from src chain
amountuint256amount of tokens sent from src chain

Events

Executed

event Executed(bytes32 commandId, string sourceChain, string sourceAddress, bytes payload);

ExecutedWithToken

event ExecutedWithToken(
    bytes32 commandId, string sourceChain, string sourceAddress, bytes payload, string tokenSymbol, uint256 amount
);

Errors

CallFailed

error CallFailed();

InsufficientGas

error InsufficientGas();

MureConfig

Git Source

Inherits: EIP712Upgradeable, OwnableUpgradeable, UUPSUpgradeable, ERC165Upgradeable, Config

Title: MureConfig

Author: Mure

Upgradeable configuration contract governing Mure protocol settings, signers, and app delegates. Implements Ownable for access control, UUPSUpgradeable for efficient upgrades, ERC165Upgradeable for interface support, and Config interface for compatibility checks. Manages whitelisted signers for secure operations, like verifying any EIP-712 signature used within the Mure protocol is signed by one of the whitelisted signers. Supports toggling the whitelisting of signers. Manages app delegates for flexible app functionality. Ensures that delegate contracts being set for an application conform to the Delegatable interface, maintaining consistency and compatibility.

State Variables

MureConfigStorageLocation

Struct hash for storage location keccak256(abi.encode(uint256(keccak256("mure.MureConfig")) - 1)) & ~bytes32(uint256(0xff))

bytes32 private constant MureConfigStorageLocation =
    0x449166636934a062783bf0dfc33be04087c7302a55ece21ecb76ecfd3ffd2100

Functions

initialize

function initialize(string calldata name, string calldata version, address owner, address[] calldata signers)
    external
    initializer;

toggleWhitelistedSigner

Toggles the whitelisting of the specified address.

function toggleWhitelistedSigner(address signer_) external onlyOwner;

Parameters

NameTypeDescription
signer_addressThe address whose whitelisting is to be toggled.

setAppDelegate

Sets the app delegate.

Set to address(0) to disable delegate

function setAppDelegate(address app, address delegate) external onlyOwner;

Parameters

NameTypeDescription
appaddressaddress of the app
delegateaddressaddress of the delegate

getAppDelegate

Retrieves the app delegate.

function getAppDelegate(address app) external view returns (address);

Parameters

NameTypeDescription
appaddressaddress of the app

verifyMureSignature

Validates if the provided signature has been created by one of the whitelisted signers.

function verifyMureSignature(bytes32 structHash, bytes memory signature) external view;

Parameters

NameTypeDescription
structHashbytes32The hashed message that was signed.
signaturebytesThe signature to be validated.

isWhitelistedSigner

Checks whether the specified address is whitelisted.

function isWhitelistedSigner(address address_) public view returns (bool);

Parameters

NameTypeDescription
address_addressThe address to check.

_toggleWhitelistedSigner

Toggles the whitelisting of the specified address.

function _toggleWhitelistedSigner(address signer_) private;

Parameters

NameTypeDescription
signer_addressThe address whose whitelisting is to be toggled.

_getStorage

Retrieves the storage for the MureConfig contract.

function _getStorage() private pure returns (MureConfigStorage storage $);

_supportsDelegateInterface

Checks if delegate supports delegate interface.

function _supportsDelegateInterface(address delegate) private view returns (bool);

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable, IERC165)
    returns (bool);

_authorizeUpgrade

required by the OZ UUPS module

function _authorizeUpgrade(address) internal override onlyOwner;

Events

AppDelegated

event AppDelegated(address indexed app, address indexed delegate);

Structs

MureConfigStorage

Note: storage-location: erc7201:mure.MureConfig

struct MureConfigStorage {
    mapping(address => uint8) signers; // 1 - allowlisted
    mapping(address => address) delegate;
}

MureDelegate

Git Source

Inherits: Delegate

Functions

initialize

function initialize(address owner, address poolContract_, address claimPlugin_) external initializer;

MureDistribution

Git Source

Inherits: EIP712Upgradeable, ERC165Upgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable, Distributable

Title: MureDistribution

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

NameTypeDescription
sourceaddressthe address to the application contract where the deposit information exists
poolNamestringthe name of the pool where the deposit was conducted
fromaddressthe address of the original depositor
toaddressthe 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

NameTypeDescription
sourceaddressthe address of the pooling contract
poolNamestringthe name pf the pool
depositoraddressthe address of the depositor

nonce

Read nonce of depositor

function nonce(address depositor) external view returns (uint24);

Parameters

NameTypeDescription
depositoraddressthe 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

NameTypeDescription
distributionDistributionRecordthe distribution information
toaddress

_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;
}

MurePool

Git Source

Inherits: EIP712Upgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable, ERC165Upgradeable, AccessControlUpgradeable, PoolApp

Title: MurePool

Author: Mure

Facilitates secure and configurable pool management, supporting operations such as pool creation, deposits, withdrawals, and refunds.

Core implementation contract for pooled investments in the Mure protocol. Utilizes the beacon proxy pattern to deploy multiple proxies, each representing a distinct application within the protocol. The MureFactory contract handles these deployments. Implements the EIP-712 standard for signature validation, preventing unauthorized access. Relies on the MureConfig contract to verify EIP-712 signatures and manage the pool creation process. Interaction with the MureConfig contract allows dynamic configuration and signature validation. Security measures include the OpenZeppelin PausableUpgradeable pattern for emergency pausing, ReentrancyGuardUpgradeable to prevent reentrancy attacks, and role based access control through AccessControlUpgradeable. Flag-based functionality enables features like refundability, passthrough of funds, and more. Provides hooks for custom functionality in pool-related operations Depending on the kind of application, the MurePool proxy instance could be linked to a MureDelegate proxy instance for interacting with various plugins that the protocol provides.

State Variables

MurePoolStorageLocation

Hash for storage location keccak256(abi.encode(uint256(keccak256("mure.MurePool")) - 1)) & ~bytes32(uint256(0xff))

bytes32 private constant MurePoolStorageLocation =
    0x79bd164051f83036bb52eee1d9b6be5ba887eaf3a9d8907adbaadfa56c970700

PoolMetricsStorageLocation

Hash for storage location keccak256(abi.encode(uint256(keccak256("mure.PoolMetrics")) - 1)) & ~bytes32(uint256(0xff))

bytes32 private constant PoolMetricsStorageLocation =
    0x1ca3e723ed845754b3d7cf12c13e1b284ab752e694e983a627f991c98b3a0700

DEPOSIT_HASH

Struct hash for validating deposits keccak256("Deposit(uint256 amount,string pool,address depositor,uint8 nonce,address caller,FeeConfig feeConfig,bytes permitSig)FeeConfig(uint112 amount,address recipient)")

bytes32 private constant DEPOSIT_HASH = 0xc89d53aaf3bcb1537286e629ce2d0d2490185593558793ccb9d770ed5a9b85ba

DEPOSIT_PERMIT_HASH

Struct hash for validating deposit permits keccak256("DepositPermit(uint256 amount,string pool,address caller,uint256 depositorNonce)")

bytes32 private constant DEPOSIT_PERMIT_HASH = 0xc366e7e07f30c8c114e87a55f528d0226c44edffd2f25b0230dd00e3263a349c

CREATE_POOL_HASH

Struct hash for validating pool creation keccak256("CreatePool(string pool,uint32 endTime,uint24 nonce)")

bytes32 private constant CREATE_POOL_HASH = 0x38c6f9238aff6821963f06d84f958ebb018ff9e4343c962882ef7b3308ff1b4d

MURE_CONFIG

Address for the MureConfig contract

Update config address

address constant MURE_CONFIG = 0x2b727332eF478bAe460ecF0CAb7C1487a87D68B8

INITIALIZED

Defines if the pool is initialized

uint16 constant INITIALIZED = 0x01

PAUSED

Defines if the pool is paused from any interaction

uint16 constant PAUSED = 0x02

PASSTHROUGH_FUNDS

PASSTHROUGH_FUNDS and REFUNDABLE cannot be set at the same time

Defines if deposits should pass straight to associtated raising wallet upon deposit

uint16 constant PASSTHROUGH_FUNDS = 0x04

REFUNDABLE

PASSTHROUGH_FUNDS and REFUNDABLE cannot be set at the same time

Defines if the pool is open for claiming refunds

uint16 constant REFUNDABLE = 0x08

TIERED

Defines if the pool is having tiers and gating

uint16 constant TIERED = 0x10

CROSS_CHAIN

Defines if the pool is cross-chain enabled, pooling funds across different networks

uint16 constant CROSS_CHAIN = 0x20

DELEGATED

Defines if the pool allows for use of delegated wallets for security

uint16 constant DELEGATED = 0x40

Functions

poolValid

modifier poolValid(string calldata poolName) ;

poolActive

modifier poolActive(string calldata poolName) ;

poolNotPaused

modifier poolNotPaused(string calldata poolName) ;

valid

modifier valid(PoolParameters calldata params) ;

onlyDelegateOrOperator

modifier onlyDelegateOrOperator() ;

onlyDelegate

modifier onlyDelegate() ;

notDelegated

modifier notDelegated() ;

initialize

function initialize(string calldata name, string calldata version, AppMember[] calldata members)
    external
    initializer;

createPool

Creates a new pool with the specified parameters.

Requires the pool to not already exist. Can only be called by a pool operator.

function createPool(string calldata poolName, PoolParameters calldata params, bytes memory sig)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    valid(params);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to create
paramsPoolParametersthe parameters for the new pool
sigbytesthe signature generated for pool creation for client

updatePool

Updates the specified pool with the provided parameters.

Requires the pool to exist. Can only be called by a pool operator.

Requires the updated pool size to be greater than or equal to the total amount collected.

function updatePool(string calldata poolName, PoolParameters calldata params)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    valid(params)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
paramsPoolParametersthe updated parameters for the pool

updatePoolSize

Updates the size of the specified pool.

Requires the pool to exist. Can only be called by a pool operator.

Requires the new pool size to be greater than or equal to the total amount collected.

function updatePoolSize(string calldata poolName, uint256 poolSize)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
poolSizeuint256the updated size of the pool

updatePoolEndTime

Updates the end time of the specified pool.

Requires the pool to exist. Can only be called by a pool operator.

function updatePoolEndTime(string calldata poolName, uint256 endTime)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
endTimeuint256the updated end time for the pool

updatePoolSigner

Updates the signer of the specified pool.

Requires the pool to exist. Can only be called by a pool operator.

function updatePoolSigner(string calldata poolName, address _signer)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
_signeraddressthe updated signer for the pool

updatePoolPaused

Pauses or unpauses the specified pool.

Requires the pool to exist. Can only be called by a pool operator or delegate.

function updatePoolPaused(string calldata poolName, bool pause)
    external
    onlyDelegateOrOperator
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to pause or unpause
pauseboola boolean representing whether to pause or unpause the pool

updatePoolRefundable

Updates whether the specified pool allows refunds or not.

Requires the pool to exist. Can only be called by a pool operator.

Requires that the pool does not have the PASSTHROUGH_FUNDS flag set if enabling refunds.

function updatePoolRefundable(string calldata poolName, bool refundable)
    external
    onlyDelegateOrOperator
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
refundableboola boolean representing whether refunds should be enabled or not

updatePoolPassthroughFunds

Updates whether the specified pool passes funds through to the custodian directly or not.

Requires the pool to exist. Can only be called by a pool operator.

Requires that the pool does not have the REFUNDABLE flag set if enabling passthrough funds.

function updatePoolPassthroughFunds(string calldata poolName, bool passthroughFunds)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to update
passthroughFundsboola boolean representing whether to enable passthrough funds or not

withdrawPoolFunds

Withdraws the total collected amount from the specified pool.

Requires the pool to exist. Can only be called by a pool operator or the delegate if it is set.

function withdrawPoolFunds(string calldata poolName) external onlyDelegateOrOperator poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to withdraw from

withdrawCurrency

Withdraw any token from the contract. This should only be used in emergencies as this can withdraw capital from any pool, be it active or not. Always prefer using withdrawPoolFunds over this function, unless you need clean up the contract by, e.g., burning garbage tokens.

function withdrawCurrency(address receiver, address currency) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
receiveraddressthe address to which the token will be transferred
currencyaddressthe address of the token contract

addDeposit

Adds a deposit of the specified amount to the pool for the designated depositor.

Requires the pool to exist. Can only be called by a pool operator.

function addDeposit(string calldata poolName, address depositor, uint256 amount)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to add the deposit to
depositoraddressthe address of the depositor
amountuint256the amount of the deposit

deductDeposit

Deducts the specified amount from the deposit of the designated depositor in the pool.

Requires the pool to exist. Can only be called by a pool operator.

function deductDeposit(string calldata poolName, address depositor, uint256 amount)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to deduct the deposit from
depositoraddressthe address of the depositor
amountuint256the amount to deduct

moveDeposit

Moves the specified amount from one depositor's deposit to another in the pool.

Requires the pool to exist. Can only be called by a pool operator.

function moveDeposit(string calldata poolName, address from, address to, uint256 amount)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to move the deposit in
fromaddressthe address of the depositor to deduct the deposit from
toaddressthe address of the depositor to add the deposit to
amountuint256the amount to move

batchDeposit

Adds or deducts balances on a per-depositor basis in batches.

Requires the pool to exist. Can only be called by the contract owner.

function batchDeposit(string calldata poolName, Transaction[] calldata transactions)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to move the deposit in
transactionsTransaction[]the set of Transactions to execute on the provided poolName

batchDeposit

Adds or deducts balances on a per-depositor basis in batches.

Requires the pool to exist. Can only be called by the contract owner.

function batchDeposit(string calldata poolName, TransactionWithMetadata[] calldata transactions)
    external
    onlyRole(POOL_OPERATOR_ROLE)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to move the deposit in
transactionsTransactionWithMetadata[]the set of TransactionWithMetadatas to execute on the provided poolName

deposit

Deposits amount of the relevant currency for the pool poolName. This operation assumes that the contract is an approved spender of the depositor. This operation is disabled for delegated pools, use depositFor instead

function deposit(string calldata poolName, DepositArgs calldata depositDetails) external notDelegated;

Parameters

NameTypeDescription
poolNamestringbytes32 representation of the pool name
depositDetailsDepositArgsdetails of the deposit per the DepositArgs struct

refund

Allows a user to refund their deposited amount from the specified pool. This operation is disabled for delegated pools, use refundTo instead.

Requires the pool to exist.

Requires the pool to be not paused and must have the REFUNDABLE flag set.

function refund(string calldata poolName) external notDelegated;

Parameters

NameTypeDescription
poolNamestringthe name of the pool from which to refund

refund

Allows a user to refund their deposited amount from the specified pool. This operation is disabled for delegated pools, use refundTo instead.

Requires the pool to exist.

Requires the pool to be not paused and must have the REFUNDABLE flag set.

function refund(string calldata poolName, bytes calldata data) external notDelegated;

Parameters

NameTypeDescription
poolNamestringthe name of the pool from which to refund
databytesadditional data as contextual data for off-chain validation

refundTo

Allows a refund of the deposited amount from the specified pool.

Requires the pool to exist.

Requires the pool to be not paused and must have the REFUNDABLE flag set.

function refundTo(string calldata poolName, address depositor, uint256 amount) external onlyDelegate;

Parameters

NameTypeDescription
poolNamestringthe name of the pool from which to refund
depositoraddressaddress of the depositor
amountuint256

depositPoolFunds

Deposits the withdrawn pool funds back. This operation assumes that the contract is an approved spender of the depositor.

Transfers the original collected funds back to the pool app

function depositPoolFunds(string calldata poolName, address depositor, uint256 amount) external onlyDelegate;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressthe address of the depositor
amountuint256the amount to be deposited back to the pool

poolState

Retrieves the state of the specified pool.

Requires the pool to exist.

function poolState(string calldata poolName) external view poolValid(poolName) returns (PoolState memory);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the state of

poolMetrics

Retrieves the metrics of the specified pool.

Requires the pool to exist.

function poolMetrics(string calldata poolName) external view poolValid(poolName) returns (PoolMetrics memory);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the metrics of

deposited

Retrieves the amount deposited by the specified depositor in the specified pool.

Requires the pool to exist.

function deposited(string calldata poolName, address depositor)
    external
    view
    poolValid(poolName)
    returns (uint256);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the deposit from
depositoraddressthe address of the depositor

nonce

Retrieves the nonce of the specified depositor in the specified pool.

Requires the pool to exist.

function nonce(string calldata poolName, address depositor) external view poolValid(poolName) returns (uint8);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to retrieve the nonce from
depositoraddressthe address of the depositor

nonce

Retrieves the nonce for create pool signature generation.

function nonce() external view returns (uint24);

poolExists

Checks if the specified pool exists.

function poolExists(string calldata pool) external view returns (bool);

Parameters

NameTypeDescription
poolstringthe name of the pool to check for existence

isPoolActive

Checks if the specified pool is active.

function isPoolActive(string calldata poolName) external view returns (bool);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check if it is active

withdrawableAmount

Checks if the specified pool is active.

function withdrawableAmount(string calldata poolName) external view returns (uint112);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check if it is active

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable, IERC165, AccessControlUpgradeable)
    returns (bool);

_grantRolesToMembers

Grants roles to the members based on their specified roles in the struct.

function _grantRolesToMembers(AppMember[] calldata members) private;

Parameters

NameTypeDescription
membersAppMember[]An array of AppMember structs containing the member's address and their role to be granted.

_deposit

Deposits amount of the relevant currency for the pool poolName. This operation assumes that the contract is an approved spender of the depositor.

function _deposit(string calldata poolName, DepositArgs calldata depositDetails)
    private
    whenNotPaused
    nonReentrant
    poolValid(poolName)
    poolActive(poolName);

Parameters

NameTypeDescription
poolNamestringbytes32 representation of the pool name
depositDetailsDepositArgsthe amount, depositor, payer, permitSig and additional data for the deposit

_refund

Allows a user to refund their deposited amount from the specified pool.

Requires the pool to exist.

Requires the pool to be not paused and must have the REFUNDABLE flag set.

function _refund(string calldata poolName, address depositor, uint256 amount, bytes memory data)
    private
    nonReentrant
    whenNotPaused
    poolNotPaused(poolName)
    poolValid(poolName);

Parameters

NameTypeDescription
poolNamestringthe name of the pool from which to refund
depositoraddressaddress of the depositor to refund from
amountuint256the amount to refund
databytesadditional data as contextual data for off-chain validation

_depositPoolFunds

Deposits the withdrawn pool funds back.

Transfers the original collected funds back to the pool app

function _depositPoolFunds(string calldata poolName, address depositor, uint256 amount) private nonReentrant;

Parameters

NameTypeDescription
poolNamestringname of the pool
depositoraddressthe address of the depositor
amountuint256the amount to be deposited back to the pool

_addDeposit

Adds deposit amount to designated poolName under depositor. As totalCollected is bound by poolSize, overflow is not possible unless poolSize is in a disallowed state to begin with.

function _addDeposit(string calldata poolName, address depositor, uint256 amount, bytes memory data) private;

_unsafeAddDeposit

Adds deposit amount to designated poolName under depositor. Skips pool size check. To be used for manual overrides like moveDeposit and batchDeposit

function _unsafeAddDeposit(string calldata poolName, address depositor, uint256 amount, bytes memory data) private;

_deductDeposit

Deducts deposit amount from designated poolName under depositor. As totalCollected is the cumulative sum of all depositors under poolName, underflow is not possible unless totalCollected is in a disallowed state to begin with.

function _deductDeposit(string calldata poolName, address depositor, uint256 amount, bytes memory data) private;

_transferUpdate

Updates the transfer between two addresses with a specified amount of a given currency.

function _transferUpdate(address from, address to, uint256 amount, address currency) private;

Parameters

NameTypeDescription
fromaddressthe address from which the transfer is initiated
toaddressthe address to which the transfer is made
amountuint256the amount of the currency being transferred
currencyaddressthe address of the currency being transferred

_poolExists

Checks whether a pool with the specified name exists.

function _poolExists(string calldata pool) private view returns (bool);

Parameters

NameTypeDescription
poolstringthe name of the pool being checked

_verifyParams

Verifies the validity of the specified pool parameters.

function _verifyParams(PoolParameters calldata config) private pure;

Parameters

NameTypeDescription
configPoolParametersthe parameters of the pool being verified

_poolComplete

Checks whether the specified pool has been completed.

function _poolComplete(string calldata poolName) private view returns (bool);

Parameters

NameTypeDescription
poolNamestringthe name of the pool being checked

_hashDeposit

Generates a hashed representation of the specified amount and pool name, along with the sender's nonce.

function _hashDeposit(
    uint256 amount,
    string calldata poolName,
    address depositor,
    address caller,
    FeeConfig memory feeConfig,
    bytes memory permitSig
) internal view returns (bytes32);

Parameters

NameTypeDescription
amountuint256the amount of the deposit
poolNamestringthe name of the pool
depositoraddressaddress of the depositor
calleraddress
feeConfigFeeConfig
permitSigbytessignature to permit deposit on behalf of user

_hashCreatePool

Generates a struct hash of the specified pool name and end time, along with the nonce.

function _hashCreatePool(string calldata poolName, uint32 endTime) private view returns (bytes32);

Parameters

NameTypeDescription
poolNamestringthe name of the pool
endTimeuint32the endtime block timestamp for the pool

_verifyPoolSize

Verifies the validity of the pool size for an existing pool.

function _verifyPoolSize(uint112 totalCollected, uint112 newPoolSize) private pure;

Parameters

NameTypeDescription
totalCollecteduint112total collected amount for the pool being updated
newPoolSizeuint112new pool size for the pool being updated

_hasFlag

Checks whether a specific flag is activated within a set of flags.

function _hasFlag(uint16 flags, uint16 flag) private pure returns (bool);

Parameters

NameTypeDescription
flagsuint16the set of flags being checked
flaguint16the flag being checked for activation

_activateFlag

Activates the specified flag within a set of flags.

function _activateFlag(uint16 flags, uint16 flag) private pure returns (uint16);

Parameters

NameTypeDescription
flagsuint16the set of flags being modified
flaguint16the flag being activated

_deactivateFlag

Deactivates the specified flag within a set of flags.

function _deactivateFlag(uint16 flags, uint16 flag) private pure returns (uint16);

Parameters

NameTypeDescription
flagsuint16the set of flags being modified
flaguint16the flag being deactivated

_getDelegateAddress

Retrieves the delegate address from config.

function _getDelegateAddress() private returns (address delegate);

_beforeDeposit

Performs delegate operations before deposit operation.

function _beforeDeposit(
    address delegateAddress,
    string calldata poolName,
    uint256 amount,
    address depositor,
    bytes calldata sig
) private;

Parameters

NameTypeDescription
delegateAddressaddressaddress of the delegate contract
poolNamestringname of the pool
amountuint256deposit amount
depositoraddress
sigbytesdeposit signature

_afterDeposit

Performs delegate operations after deposit operation.

function _afterDeposit(
    address delegateAddress,
    string calldata poolName,
    uint256 amount,
    address depositor,
    bytes calldata sig
) private;

Parameters

NameTypeDescription
delegateAddressaddressaddress of the delegate contract
poolNamestringname of the pool
amountuint256deposit amount
depositoraddress
sigbytesdeposit signature

_beforeRefund

Performs delegate operations before refund operation.

function _beforeRefund(address delegateAddress, string calldata poolName, address depositor) private;

Parameters

NameTypeDescription
delegateAddressaddressaddress of the delegate contract
poolNamestringname of the pool
depositoraddressaddress of the depositor

_afterRefund

Performs delegate operations after refund operation.

function _afterRefund(address delegateAddress, string calldata poolName, address depositor, uint256 amount)
    private;

Parameters

NameTypeDescription
delegateAddressaddressaddress of the delegate contract
poolNamestringname of the pool
depositoraddressaddress of the depositor
amountuint256the refund amount

_consumeDepositorNonce

Increments depositor's nonce for the pool.

function _consumeDepositorNonce(string calldata poolName, address depositor, DepositRecord storage deposit_)
    private;

Parameters

NameTypeDescription
poolNamestring
depositoraddress
deposit_DepositRecordreference to the deposit record

_getStorage

Retrieves the storage for the MurePool contract.

function _getStorage() private pure returns (MurePoolStorage storage $);

_getPoolMetricsStorage

Retrieves the storage for the pool metrics.

function _getPoolMetricsStorage() private pure returns (PoolMetricsStorage storage $);

_verifySignature

function _verifySignature(
    DepositArgs memory depositDetails,
    string calldata poolName,
    address signer,
    bytes calldata depositSig
) private view;

_hashDepositPermit

function _hashDepositPermit(DepositPermit memory permit) internal view returns (bytes32);

_verifyDepositPermit

function _verifyDepositPermit(DepositPermit memory permit, bytes memory permitSig) internal view;

Structs

MurePoolStorage

Note: storage-location: erc7201:mure.MurePool

struct MurePoolStorage {
    mapping(string => PoolState) pools;
    mapping(string => mapping(address => DepositRecord)) deposits;
    uint24 nonce;
}

PoolMetricsStorage

Note: storage-location: erc7201:mure.PoolMetrics

struct PoolMetricsStorage {
    mapping(string => PoolMetrics) poolMetrics;
}

MurePoolFactory

Git Source

Inherits: Ownable, EIP712

Title: MurePoolFactory

Author: Mure

Factory contract for deploying applications as instances of the BeaconProxy contract within the Mure protocol.

Facilitates the secure and efficient deployment of upgradeable app contracts using the beacon proxy pattern. Implements the EIP-712 standard for signature validation and Ownable for access control. The factory contract relies on the MureConfig contract to verify EIP-712 signatures and manage the deployment process. Signatures are added with an expiry to enhance the security of the deployment process by ensuring that the provided signature is only valid within a certain time frame.

State Variables

beaconAddress

address public beaconAddress

config

MureConfig public config

DEPLOY_APP_HASH

Struct hash for validating app deployments keccak256("Deployment(string appName,string version,AppMember[] appMembers,uint256 nonce,uint256 deadline,address caller,string data)AppMember(address member,uint8 role)")

bytes32 private constant DEPLOY_APP_HASH = 0xe78e92e91ab6665af572917421100be08c66583917c23ae7a02b72bed7edc218

nonces

Nonce mapping for signatures to prevent replay

mapping(address => uint256) public nonces

Functions

constructor

constructor(address beaconAddress_, address config_, string memory name_, string memory version_)
    Ownable(msg.sender)
    EIP712(name_, version_);

deployAppProxy

Deploys an instance of the beacon proxy.

Requires signature for authorization.

function deployAppProxy(
    string calldata appName,
    string calldata version,
    AppMember[] calldata appMembers,
    uint256 deadline,
    string calldata data,
    bytes calldata sig
) external returns (address proxy);

Parameters

NameTypeDescription
appNamestringname of the app contract instance
versionstringof the app contract instance
appMembersAppMember[]array of app members and their roles for the app contract instance
deadlineuint256expiration time of the signature
datastringdata to be emitted on creation
sigbytessignature generated for the user

setBeaconAddress

Sets the beacon address for future proxy creation.

Can only be called by the contract owner.

function setBeaconAddress(address beaconAddress_) external onlyOwner;

Parameters

NameTypeDescription
beaconAddress_addressnew beacon address to be set

_hash

Generates a hashed representation of the app name, version, members, deadline, along with the sender's nonce.

function _hash(
    string calldata appName,
    string calldata version,
    AppMember[] calldata appMembers,
    uint256 deadline,
    string calldata data
) private view returns (bytes32);

Parameters

NameTypeDescription
appNamestringname of the app contract
versionstringversion of the app contract
appMembersAppMember[]array of admin addresses and their corresponding roles for the app contract
deadlineuint256expiry of the signature
datastringdata to be emitted on creation

_hashAppMembers

Computes the keccak256 hash of an array of AppMember structs.

function _hashAppMembers(AppMember[] calldata appMembers) private pure returns (bytes32);

Parameters

NameTypeDescription
appMembersAppMember[]The array of AppMember structs to be hashed.

_extractAppRoles

Extracts and categorizes members into admins and operators based on their roles.

function _extractAppRoles(AppMember[] calldata appMembers)
    private
    pure
    returns (address[] memory, address[] memory);

Parameters

NameTypeDescription
appMembersAppMember[]An array of AppMember structs containing the member address and role.

_validateAdminRoleExists

Validates that there is at least one member with the DEFAULT_ADMIN role in the provided appMembers array.

function _validateAdminRoleExists(AppMember[] calldata appMembers) private pure returns (bool);

Parameters

NameTypeDescription
appMembersAppMember[]An array of AppMember structs containing the member address and role.

Events

Deployment

event Deployment(
    string indexed appName, address[] appAdmins, address[] appOperators, address indexed appAddress, string data
);

BeaconUpdate

event BeaconUpdate(address indexed beaconAddress);

TestUsdc

Git Source

Inherits: ERC20

Functions

constructor

constructor() ERC20("TestUsdc", "USDC");

mint

function mint(address account, uint256 amount) external;

burn

function burn(address account, uint256 amount) external;

Ticket

Git Source

Inherits: AccessControl, ERC20, ERC20Permit

Title: Ticket

Author: Mure

ERC-20 token contract for a ticketing system. This token contract is meant to facilitate ticket system. A user can deposit a configurable currency in exchange for this token. A burn mechanism is provided to be used to indicate ticket consumption.

State Variables

FEE_MANAGER

Role allows user to update fee configuration

bytes32 public constant FEE_MANAGER = keccak256("FEE_MANAGER")

TICKET_OPERATOR

Role allows user to operate the ticket contract

bytes32 public constant TICKET_OPERATOR = keccak256("TICKET_OPERATOR")

TRANSFER_ROLE

Role allows user to transfer the token

bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE")

CURRENCY

The address of the exchange currency token contract.

address public CURRENCY

TREASURY

The address of the treasury which will receive the deposited currency.

address public TREASURY

FEE_RECIPIENT

The address of the treasury which will receive the deposited currency.

address public FEE_RECIPIENT

exchangePrice

Exchange rate of a ticket with the configured currency.

uint256 public exchangePrice

feeConfig

Fee configuration for the received funds. Fee splits are in basis points.

FeeConfig private feeConfig

discountConfig

Discount rates based on purchase quantity sorted based on quantity. Percentages are in basis points.

DiscountRate[] private discountConfig

Functions

constructor

Construct a new instance of this TICKET contract configured with the given immutable contract addresses.

constructor(
    address currencyAddress_,
    uint256 exchangePrice_,
    DiscountRate[] memory discountConfig_,
    FeeConfig memory feeConfig_,
    address operator_,
    address feeManager_,
    string memory name_,
    string memory symbol_
) ERC20(name_, symbol_) ERC20Permit(name_);

Parameters

NameTypeDescription
currencyAddress_addressthe address of the ERC-20 currency token contract.
exchangePrice_uint256the initial currency exchange price.
discountConfig_DiscountRate[]the initial discount rates.
feeConfig_FeeConfigthe initial fee recipient configuration.
operator_address
feeManager_address
name_stringname of the token contract.
symbol_stringsymbol of the token contract.

purchaseTicket

Exchange currency for $TICKET.

Transfers deposited currency to TREASURY and mints $TICKET based on price.

function purchaseTicket(uint256 quantity) external;

Parameters

NameTypeDescription
quantityuint256the amount of $TICKET to purchase.

purchaseTicket

Exchange currency for $TICKET.

Transfers deposited currency to TREASURY and mints $TICKET based on price.

function purchaseTicket(uint256 quantity, address to) external;

Parameters

NameTypeDescription
quantityuint256the amount of $TICKET to purchase.
toaddressaddress to send the $TICKET to.

sendTickets

send $TICKET to an address.

Mints $TICKET to the specified address.

function sendTickets(uint256 quantity, address to) external onlyRole(TICKET_OPERATOR);

Parameters

NameTypeDescription
quantityuint256the amount of $TICKET to send.
toaddressaddress to send the $TICKET to.

sendTickets

send $TICKET to multiple address.

Mints $TICKET to the specified addresses.

function sendTickets(TicketRecipient[] calldata recipients) external onlyRole(TICKET_OPERATOR);

Parameters

NameTypeDescription
recipientsTicketRecipient[]array of ticket recipients.

updateExchangePrice

Allow a permitted caller to update the base exchange price.

function updateExchangePrice(uint256 exchangePrice_) external onlyRole(TICKET_OPERATOR);

Parameters

NameTypeDescription
exchangePrice_uint256updated base price.

updateCurrencyAddress

Allow a permitted caller to update the exchange currency address.

function updateCurrencyAddress(address currencyAddress_) external onlyRole(TICKET_OPERATOR);

Parameters

NameTypeDescription
currencyAddress_addressupdated currency address.

getPrice

Returns the price in currency to charge for given $TICKET amount.

function getPrice(uint256 purchaseQuantity) external view returns (uint256);

Parameters

NameTypeDescription
purchaseQuantityuint256the amount of $TICKET to purchase

getDiscountRate

Returns the discount rate for given $TICKET amount.

function getDiscountRate(uint256 purchaseQuantity) external view returns (uint16);

Parameters

NameTypeDescription
purchaseQuantityuint256the amount of $TICKET to purchase

getDiscountConfig

function getDiscountConfig() external view returns (DiscountRate[] memory);

getFeeConfig

function getFeeConfig() external view returns (FeeRecipient[] memory, uint16);

decimals

function decimals() public view virtual override returns (uint8);

setDiscountConfig

Sets discount rates for purchase quantities.

makes sure that the array is sorted based on quantity and the percentages being set are valid.

function setDiscountConfig(DiscountRate[] calldata discountConfig_) public onlyRole(TICKET_OPERATOR);

Parameters

NameTypeDescription
discountConfig_DiscountRate[]discount config with percentages in basis points

setFeeConfig

Sets the fee configuration.

function setFeeConfig(FeeConfig calldata feeConfig_) public onlyRole(FEE_MANAGER);

Parameters

NameTypeDescription
feeConfig_FeeConfigfee configuration with percentages in basis points

burn

Permit callers to burn their $TICKET.

function burn(uint256 quantity) public;

Parameters

NameTypeDescription
quantityuint256The quantity of tickets to burn.

withdrawCurrency

Withdraw any token from the contract. This should only be used in emergencies

function withdrawCurrency(address receiver, address currency) external onlyRole(FEE_MANAGER);

Parameters

NameTypeDescription
receiveraddressthe address to which the token will be transferred
currencyaddressthe address of the token contract

_mintTicket

Mints $TICKET to specified address.

function _mintTicket(TicketRecipient memory ticketRecipient) private;

Parameters

NameTypeDescription
ticketRecipientTicketRecipientticket quantity and recipient configuration

_transferFee

Transfers the fee for $TICKET purchase.

function _transferFee(uint256 amount) private;

Parameters

NameTypeDescription
amountuint256the amount of price being charged

_transferCurrency

Transfers currency from the given address to the given address.

function _transferCurrency(address from, address to, uint256 amount) private;

Parameters

NameTypeDescription
fromaddressthe address from which the transfer is initiated
toaddressthe address to which the currency will be transferred
amountuint256the amount of currency to be transferred

_calculatePrice

Determines the price in currency to charge for given $TICKET amount.

Deducts the discount from base price.

function _calculatePrice(uint256 purchaseQuantity) private view returns (uint256);

Parameters

NameTypeDescription
purchaseQuantityuint256the amount of $TICKET to purchase

_calculateDiscountRate

Determines the discount rate based on quantity being purchased.

function _calculateDiscountRate(uint256 purchaseQuantity) private view returns (uint16);

Parameters

NameTypeDescription
purchaseQuantityuint256the amount of $TICKET to purchase

_setFeeConfig

Sets the fee configuration.

function _setFeeConfig(FeeConfig memory feeConfig_) private;

Parameters

NameTypeDescription
feeConfig_FeeConfigfee configuration with percentages in basis points

_setDiscountConfig

Sets discount rates for purchase quantities.

makes sure that the array is sorted based on quantity and the percentages being set are valid.

function _setDiscountConfig(DiscountRate[] memory discountConfig_) private;

Parameters

NameTypeDescription
discountConfig_DiscountRate[]discount config with percentages in basis points

_update

Override ERC20._update to restrict transfers to whitelisted addresses

function _update(address from, address to, uint256 value) internal virtual override;

Events

DiscountUpdated

event DiscountUpdated(DiscountRate[] indexed discountConfig);

TicketsMinted

event TicketsMinted(address indexed to, uint256 indexed quantity);

TicketsBurned

event TicketsBurned(address indexed from, uint256 indexed quantity);

CurrencyUpdated

event CurrencyUpdated(address indexed currencyAddress);

FeeConfigUpdated

event FeeConfigUpdated(FeeConfig indexed feeConfig);

ExchangePriceUpdated

event ExchangePriceUpdated(uint256 indexed exchangePrice);

Errors

TransferFailure

This error is thrown when transfer of currency fails.

error TransferFailure();

InvalidDiscountRate

This error is thrown when the discount rate being set is invalid.

error InvalidDiscountRate();

InvalidFeeConfig

This error is thrown when the fee configuration being set is invalid.

error InvalidFeeConfig();

UnauthorizedTransfer

This error is thrown when the transfer isn't made from or to a whitelisted address.

error UnauthorizedTransfer();

Structs

DiscountRate

Struct for discount rate configuration

struct DiscountRate {
    uint256 quantity;
    uint16 discount;
}

FeeRecipient

Struct for fee recipient configuration

struct FeeRecipient {
    address recipient;
    uint16 split;
}

TicketRecipient

Struct for ticket recipients

struct TicketRecipient {
    address recipient;
    uint256 quantity;
}

FeeConfig

Struct for fee configuration

struct FeeConfig {
    FeeRecipient[] feeRecipients;
    uint16 burnSplit;
}

TicketConsumer

Git Source

Inherits: EIP712Upgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable, AccessControlUpgradeable

Title: TicketConsumer

Author: Mure

Contract to record commitments and consume Tickets associated with the Ticket and Pool contract

Utilizes the beacon proxy pattern to deploy multiple proxies, each representing a distinct application within the protocol. Implements the EIP-712 standard for signature validation, preventing unauthorized access. Security measures include the OpenZeppelin PausableUpgradeable pattern for emergency pausing, ReentrancyGuardUpgradeable to prevent reentrancy attacks, and role based access control through AccessControlUpgradeable.

State Variables

ADMIN_ROLE

Role allows user to update contract configurations

bytes32 public constant ADMIN_ROLE = keccak256("TICKET_CONSUMER_ADMIN")

TicketConsumerStorageLocation

Hash for storage location keccak256(abi.encode(uint256(keccak256("mure.TicketConsumer")) - 1)) & ~bytes32(uint256(0xff))

bytes32 private constant TicketConsumerStorageLocation =
    0xa517efc6fde9e1a3d05cb7ac467254548b2bee1ce4290b0a81a21700967a6300

COMMIT_TICKET_HASH

Struct hash for validating ticket commitment keccak256("CommitTickets(uint256 quantity,address committer,string pool,uint256 amount)")

bytes32 private constant COMMIT_TICKET_HASH = 0x94ff97a6bb66dc5d656631dfe6b320f3b5cd4350fb456819848e7526cd060f8a

Functions

constructor

constructor() ;

initialize

function initialize(
    ContractConfiguration calldata contractConfig,
    address admin_,
    string calldata name_,
    string calldata version_
) external initializer;

commitTicket

Deposit a ticket to commit to a round.

Burns the deposited ticket and registers commitment.

function commitTicket(string calldata poolName, uint256 quantity, bytes calldata sig) external;

Parameters

NameTypeDescription
poolNamestringname of the pool
quantityuint256the amount of $TICKET to burn.
sigbytesthe signature to authorize commitment.

commitTicketAndDeposit

Deposit a ticket to commit to a round and deposits the committed amount to the pool.

Burns the deposited ticket and registers commitment. Deposits amount to the configured pool.

function commitTicketAndDeposit(
    uint256 quantity,
    string calldata poolName,
    bytes calldata sig,
    DepositArgs calldata depositArgs
) external;

Parameters

NameTypeDescription
quantityuint256the amount of $TICKET to burn.
poolNamestringthe name of the pool.
sigbytesthe signature to authorize commitment.
depositArgsDepositArgsparameters of the deposit as DepositArgs struct.

getPoolConfig

Returns the pool deposit range and total allotment.

function getPoolConfig(string calldata poolName) external view returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
poolNamestringname of the pool

getContractConfig

Returns the ticket address set on the contract.

function getContractConfig() external view returns (ContractConfiguration memory);

getTicketAddress

Returns the ticket address set on the contract.

function getTicketAddress() external view returns (address);

getCommittedTickets

Returns the signer address set on the contract.

function getCommittedTickets(string calldata poolName, address committer) external view returns (uint256);

Parameters

NameTypeDescription
poolNamestringname of the pool
committeraddressaddress of the committer

setPoolConfiguration

Updates the pool configuration for deposits.

function setPoolConfiguration(
    string calldata poolName,
    uint256 minimumDepositAmount,
    uint256 maximumDepositAmount,
    uint256 commitmentStartTime,
    uint256 commitmentEndTime
) external onlyRole(ADMIN_ROLE);

Parameters

NameTypeDescription
poolNamestringname of the pool
minimumDepositAmountuint256minimum base deposit amount for pool per ticket
maximumDepositAmountuint256maximum deposit amount for pool per ticket
commitmentStartTimeuint256epoch timestamp for when commitments should start
commitmentEndTimeuint256epoch timestamp for when commitments should end

setContractConfiguration

Updates the pool configuration for deposits.

function setContractConfiguration(ContractConfiguration calldata contractConfig) external onlyRole(ADMIN_ROLE);

Parameters

NameTypeDescription
contractConfigContractConfigurationbase contract configuration

setCommitmentsPaused

Updates the pool configuration for deposits.

function setCommitmentsPaused(bool paused) external onlyRole(ADMIN_ROLE);

Parameters

NameTypeDescription
pausedboolboolean to define if commitments are paused

_depositFunds

Deposits committed amount into the pool.

function _depositFunds(string calldata poolName, DepositArgs calldata depositParams) private nonReentrant;

_consumeTicket

Consumes tickets.

Burns the deposited tickets and registers commitment.

function _consumeTicket(address from, uint256 quantity, string calldata poolName, uint256 depositedAmount) private;

isPoolCommitmentActive

Checks if commitments for the specified pool are active.

function isPoolCommitmentActive(string calldata poolName) private view returns (bool);

Parameters

NameTypeDescription
poolNamestringthe name of the pool to check if it is active

_getStorage

Retrieves the storage for the TicketConsumer contract.

function _getStorage() private pure returns (TicketConsumerStorage storage $);

_hashCommit

Generates a hashed representation of the specified quantity and committer address.

function _hashCommit(uint256 quantity, address committer, string calldata poolName, uint256 depositAmount)
    private
    view
    returns (bytes32);

Parameters

NameTypeDescription
quantityuint256the quantity to commit
committeraddressaddress of the committer
poolNamestringname of the pool
depositAmountuint256amount being deposited with the commitment

_verifySignature

Verifies the signature for commitment authorization.

function _verifySignature(
    uint256 quantity,
    address committer,
    address signer,
    uint256 depositAmount,
    string calldata poolName,
    bytes calldata sig
) private view;

Parameters

NameTypeDescription
quantityuint256the quantity to commit
committeraddressaddress of the committer
signeraddressaddress of the signer
depositAmountuint256amount being deposited with the commitment
poolNamestringname of the pool
sigbytessignature to verify

Events

TicketsConsumed

event TicketsConsumed(
    address indexed from, string poolName, uint256 ticketQuantity, uint256 indexed depositedAmount
);

Errors

Unauthorized

error Unauthorized();

InvalidDepositAmount

error InvalidDepositAmount();

CommitmentsInactive

error CommitmentsInactive();

Structs

ContractConfiguration

Struct for pool configuration

struct ContractConfiguration {
    address ticketContract;
    address poolContract;
    address signer;
    bool paused;
}

PoolConfiguration

Struct for pool configuration

struct PoolConfiguration {
    uint256 maximumDepositAmount;
    uint256 minimumDepositAmount;
    uint32 commitmentStartTime;
    uint32 commitmentEndTime;
    mapping(address committer => uint256 ticketCount) committedTickets;
}

TicketConsumerStorage

Note: storage-location: erc7201:mure.TicketConsumer

struct TicketConsumerStorage {
    address TICKET;
    address SIGNER;
    address POOL_CONTRACT;
    bool paused;
    mapping(string poolName => PoolConfiguration) poolConfig;
}