BasicRetryOperator
Inherits: ReentrancyGuard, AccessControlEnumerable
A minimal operator contract compatible with Cove's BasketToken. Once approved via BasketToken.setOperator, anyone can call the handler functions to automatically claim a user's fulfilled deposits/redeems (or their fall-backs) and route the resulting assets/shares back to the original user.
State Variables
_retryDisabledFlags
mapping(address user => uint8 flags) private _retryDisabledFlags;
_DEPOSIT_RETRY_DISABLED_FLAG
uint8 private constant _DEPOSIT_RETRY_DISABLED_FLAG = 1 << 0;
_REDEEM_RETRY_DISABLED_FLAG
uint8 private constant _REDEEM_RETRY_DISABLED_FLAG = 1 << 1;
MANAGER_ROLE
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
Functions
constructor
Constructor for the BasicRetryOperator.
constructor(address admin, address manager) payable;
Parameters
Name | Type | Description |
---|---|---|
admin | address | The address of the admin who can grant and revoke roles. |
manager | address | The address of the manager who can change token approvals. |
setDepositRetry
Enable / disable automatic fallback asset claims when deposits cannot be fulfilled.
By default, users are considered opted-in for retry paths.
function setDepositRetry(bool enabled) external;
setRedeemRetry
Enable / disable automatic fallback share claims when redeems cannot be fulfilled.
By default, users are considered opted-in for retry paths.
function setRedeemRetry(bool enabled) external;
isDepositRetryEnabled
Returns whether the deposit retry is enabled for user
.
function isDepositRetryEnabled(address user) public view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the deposit retry is enabled for user , false otherwise. |
isRedeemRetryEnabled
Returns whether the redeem retry is enabled for user
.
function isRedeemRetryEnabled(address user) public view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the redeem retry is enabled for user , false otherwise. |
handleDeposit
Claims a fulfilled deposit for user
. If nothing is fulfilled and the caller opted-in,
attempts to pull fallback assets instead.
function handleDeposit(address user, address basketToken) external nonReentrant;
handleRedeem
Claims a fulfilled redeem for user
. If nothing is fulfilled and the caller opted-in,
attempts to pull fallback shares instead.
function handleRedeem(address user, address basketToken) external nonReentrant;
approveDeposits
Approves the asset of basketToken
to be spent by basketToken
.
This is necessary to allow retrying deposits to work without approving the asset beforehand every time. Call this function after the BasketToken is deployed to approve the asset to be spent by the operator. In case the basket token misbehaves, the manager can revoke the approval to prevent the operator from being used.
function approveDeposits(BasketToken basketToken, uint256 amount) external onlyRole(MANAGER_ROLE);
Events
DepositClaimedForUser
Emitted after successfully claiming a user's fulfilled deposit.
event DepositClaimedForUser(address indexed user, address indexed basketToken, uint256 assets, uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller whose fulfilled deposit is being claimed. |
basketToken | address | The address of the basket token contract the deposit pertains to. |
assets | uint256 | The amount of base assets returned to the user. |
shares | uint256 | The number of basket shares minted to the user. |
RedeemClaimedForUser
Emitted after successfully claiming a user's fulfilled redemption.
event RedeemClaimedForUser(address indexed user, address indexed basketToken, uint256 shares, uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller whose fulfilled redeem is being claimed. |
basketToken | address | The address of the basket token contract the redeem pertains to. |
shares | uint256 | The number of basket shares burned from the user. |
assets | uint256 | The amount of base assets returned to the user. |
FallbackAssetsClaimedForUser
Emitted when fallback assets are claimed for a user without retrying the deposit.
event FallbackAssetsClaimedForUser(address indexed user, address indexed basketToken, uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller receiving the fallback assets. |
basketToken | address | The address of the basket token contract the fallback pertains to. |
assets | uint256 | The amount of base assets sent to the user. |
FallbackAssetsRetriedForUser
Emitted when fallback assets are claimed and immediately retried as a new deposit request on behalf of the user.
event FallbackAssetsRetriedForUser(address indexed user, address indexed basketToken, uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller whose fallback assets are being retried. |
basketToken | address | The address of the basket token contract the fallback pertains to. |
assets | uint256 | The amount of base assets retried for deposit. |
FallbackSharesClaimedForUser
Emitted when fallback shares are claimed for a user without retrying the redeem.
event FallbackSharesClaimedForUser(address indexed user, address indexed basketToken, uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller receiving the fallback shares. |
basketToken | address | The address of the basket token contract the fallback pertains to. |
shares | uint256 | The amount of basket shares sent to the user. |
FallbackSharesRetriedForUser
Emitted when fallback shares are claimed and a new redeem request is submitted on behalf of the user.
event FallbackSharesRetriedForUser(address indexed user, address indexed basketToken, uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
user | address | The controller whose fallback shares are being retried. |
basketToken | address | The address of the basket token contract the fallback pertains to. |
shares | uint256 | The amount of basket shares retried for redemption. |
DepositRetrySet
Emitted when a user updates their preference for automatically retrying failed deposits.
event DepositRetrySet(address indexed user, bool enabled);
Parameters
Name | Type | Description |
---|---|---|
user | address | The user updating the preference. |
enabled | bool | True if automatic retry for deposits is enabled, false otherwise. |
RedeemRetrySet
Emitted when a user updates their preference for automatically retrying failed redeems.
event RedeemRetrySet(address indexed user, bool enabled);
Parameters
Name | Type | Description |
---|---|---|
user | address | The user updating the preference. |
enabled | bool | True if automatic retry for redeems is enabled, false otherwise. |
Errors
ZeroAddress
Reverts when a provided address is the zero address.
error ZeroAddress();
NothingToClaim
Reverts when there is no fulfilled deposit, no fulfilled redeem, and no fallback amount available to claim.
error NothingToClaim();