Skip to main content

LenderQueue

Git Source

Inherits: Context, ERC165, AccessControl, ILenderQueue, ReentrancyGuard

Title: LenderQueue

Author: @SocksNFlops

Queue for withdrawing assets from the Consol contract.

State Variables

consol

Get the Consol contract.

address public immutable override consol

asset

Get the asset of the LenderQueue.

address public immutable override asset

withdrawalGasFee

Get the gas fee for a withdrawal.

uint256 public override withdrawalGasFee

withdrawalQueueHead

Get the head of the withdrawal queue. The index of the request at the front of the queue.

uint256 public override withdrawalQueueHead

withdrawalRequests

The withdrawal queue (in mapping form)

mapping(uint256 => WithdrawalRequest) internal withdrawalRequests

withdrawalQueueLength

Get the length of the withdrawal queue (number of requests in withdrawalRequests that have not been processed yet)

uint256 public override withdrawalQueueLength

minimumWithdrawalAmount

Get the minimum amount of tokens that can be withdrawn.

uint256 public override minimumWithdrawalAmount

paused

Get the paused state of the contract

bool public paused

Functions

whenNotPaused

Modifier to check if the contract is paused

modifier whenNotPaused() ;

constructor

Constructor

constructor(address asset_, address consol_, address admin_) ;

Parameters

NameTypeDescription
asset_addressThe address of the asset to withdraw
consol_addressThe address of the Consol contract
admin_addressThe address of the admin

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[ERC section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, ERC165) returns (bool);

setWithdrawalGasFee

Set the gas fee for a withdrawal.

function setWithdrawalGasFee(uint256 gasFee) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
gasFeeuint256The gas fee for a withdrawal

withdrawNativeGas

Withdraws accumulated native gas fees. Only callable by the admin.

function withdrawNativeGas(uint256 amount) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE) nonReentrant;

Parameters

NameTypeDescription
amountuint256The amount of native gas fees to withdraw

setMinimumWithdrawalAmount

Set the minimum amount of tokens that can be withdrawn.

function setMinimumWithdrawalAmount(uint256 newMinimumWithdrawalAmount)
external
override
onlyRole(Roles.DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
newMinimumWithdrawalAmountuint256The new minimum amount of tokens that can be withdrawn

requestWithdrawal

Request a withdrawal of tokens from the LenderQueue contract.

function requestWithdrawal(uint256 amount) external payable override;

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw

withdrawalQueue

Get the withdrawal request at a given index. The index is absolute, not relative to the withdrawal queue head.

function withdrawalQueue(uint256 index) external view override returns (WithdrawalRequest memory);

Parameters

NameTypeDescription
indexuint256The index of the withdrawal request

Returns

NameTypeDescription
<none>WithdrawalRequestwithdrawalRequest The withdrawal request at the given index

processWithdrawalRequests

Process the requests from the front of the USDX withdrawal queue. Callable by anyone by contracts with the PROCESSOR_ROLE.

function processWithdrawalRequests(uint256 iterations, address receiver) external virtual override;

Parameters

NameTypeDescription
iterationsuint256The number of iterations to process. Each iteration returns collected gas fees.
receiveraddressThe address to receive the gas fees

cancelWithdrawal

Cancel a withdrawal request. Only callable by owner of the request. Does not refund the gas fee.

function cancelWithdrawal(uint256 index) external override;

Parameters

NameTypeDescription
indexuint256The index of the withdrawal request to cancel

setPaused

Pause or unpause the contract

function setPaused(bool pause) external override onlyRole(Roles.PAUSE_ROLE);

Parameters

NameTypeDescription
pauseboolThe new paused state