Skip to main content

Functions

Core functions

deposit

Deposit a stablecoin and receive DLRS at 1:1.

function deposit(
address stablecoin,
uint256 amount
) external returns (uint256 dlrsMinted)
ParameterTypeDescription
stablecoinaddressSupported stablecoin to deposit
amountuint256Amount to deposit (6 decimals)

Returns: Amount of DLRS minted (always equals amount)

Effects:

  • Transfers stablecoin from caller
  • Processes queue for that stablecoin (fills waiting positions)
  • Adds remainder to reserves
  • Mints DLRS to caller

Reverts if:

  • amount is 0
  • stablecoin not supported
  • Transfer fails

withdraw

Burn DLRS and receive a stablecoin at 1:1.

function withdraw(
address stablecoin,
uint256 amount
) external returns (uint256 stablecoinReceived)
ParameterTypeDescription
stablecoinaddressStablecoin to withdraw
amountuint256Amount to withdraw (6 decimals)

Returns: Amount of stablecoin received (always equals amount)

Reverts if:

  • amount is 0
  • stablecoin not supported
  • Insufficient reserves
  • Caller has insufficient DLRS

Swap functions

swap

Swap one stablecoin for another, with optional queue fallback.

function swap(
address fromStablecoin,
address toStablecoin,
uint256 amount,
bool queueIfUnavailable
) external returns (uint256 received, uint256 positionId)
ParameterTypeDescription
fromStablecoinaddressInput stablecoin
toStablecoinaddressOutput stablecoin
amountuint256Amount to swap
queueIfUnavailableboolIf true, queue unfilled portion; if false, mint DLRS

Returns:

  • received: Amount filled instantly
  • positionId: Queue position ID (0 if fully filled or not queued)

swapFromDLRS

Swap DLRS for a stablecoin.

function swapFromDLRS(
address toStablecoin,
uint256 dlrsAmount,
bool queueIfUnavailable
) external returns (uint256 received, uint256 positionId)
ParameterTypeDescription
toStablecoinaddressOutput stablecoin
dlrsAmountuint256Amount of DLRS to swap
queueIfUnavailableboolIf true, queue unfilled portion

swapExactInput

Aggregator-optimized swap. Never queues—either fully executes or reverts.

function swapExactInput(
address fromStablecoin,
address toStablecoin,
uint256 amountIn,
uint256 minAmountOut,
address recipient,
uint256 deadline
) external returns (uint256 amountOut)
ParameterTypeDescription
fromStablecoinaddressInput stablecoin
toStablecoinaddressOutput stablecoin
amountInuint256Exact input amount
minAmountOutuint256Minimum acceptable output (slippage protection)
recipientaddressWhere to send output tokens
deadlineuint256Unix timestamp deadline

Returns: Exact output amount (equals amountIn for 1:1)

Reverts if:

  • Deadline passed
  • Insufficient reserves (no partial fills)
  • Any validation fails

Queue functions

joinQueue

Join the queue for a stablecoin. Burns DLRS as escrow.

function joinQueue(
address stablecoin,
uint256 dlrsAmount
) external returns (uint256 positionId)
ParameterTypeDescription
stablecoinaddressStablecoin you want to receive
dlrsAmountuint256Amount of DLRS to lock

Returns: Unique position ID

Reverts if:

  • Queue is full (150 positions max)
  • Below minimum order size
  • Insufficient DLRS balance

cancelQueue

Cancel a queue position and reclaim DLRS.

function cancelQueue(
uint256 positionId
) external returns (uint256 dlrsReturned)

Returns: DLRS returned (may be less than original if partially filled)

Reverts if:

  • Position doesn't exist
  • Caller doesn't own position

View functions

getSwapQuote

Get expected output for a swap. Used by aggregators to check fillability.

function getSwapQuote(
address fromStablecoin,
address toStablecoin,
uint256 amountIn
) external view returns (uint256 amountOut)

Returns: amountIn if fully fillable, 0 if not. Never returns partial amounts.


getReserves

Get all reserve balances.

function getReserves() external view returns (
address[] memory stablecoins,
uint256[] memory amounts
)

getReserve

Get reserve for a specific stablecoin.

function getReserve(address stablecoin) external view returns (uint256)

getQueueDepth

Get total DLRS waiting in a queue.

function getQueueDepth(address stablecoin) external view returns (uint256)

getQueuePositionCount

Get number of positions in a queue.

function getQueuePositionCount(address stablecoin) external view returns (uint256)

getQueuePosition

Get details of a queue position.

function getQueuePosition(uint256 positionId) external view returns (
address owner,
address stablecoin,
uint256 amount,
uint256 timestamp
)

getUserQueuePositions

Get all position IDs for a user.

function getUserQueuePositions(address user) external view returns (uint256[] memory)

getMinimumOrderSize

Get minimum order size for a queue based on current depth.

function getMinimumOrderSize(address stablecoin) external view returns (uint256)

supportedStablecoins

Get all supported stablecoin addresses.

function supportedStablecoins() external view returns (address[] memory)

isSupported

Check if a stablecoin is supported.

function isSupported(address stablecoin) external view returns (bool)

dlrsToken

Get the DLRS token address.

function dlrsToken() external view returns (address)