Skip to main content

Functions

Core functions

deposit

Supply a stablecoin to the protocol. The system records DLRS at 1:1.

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

Returns: Amount of DLRS recorded (always equals amount)

Effects:

  • Protocol transfers stablecoin from caller
  • Processes queue for that stablecoin (fills waiting positions)
  • Adds remainder to reserves
  • Records DLRS for caller

Reverts if:

  • amount is 0
  • stablecoin not supported
  • Transfer fails

withdraw

Request a stablecoin from supply. Uses DLRS at 1:1.

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

Returns: Amount of stablecoin received (always equals amount)

Reverts if:

  • amount is 0
  • stablecoin not supported
  • Insufficient supply
  • 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, record DLRS

Returns:

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

swapFromDLRS

Request a stablecoin using DLRS.

function swapFromDLRS(
address toStablecoin,
uint256 dlrsAmount,
bool queueIfUnavailable
) external returns (uint256 received, uint256 positionId)
ParameterTypeDescription
toStablecoinaddressOutput stablecoin
dlrsAmountuint256Amount of DLRS to use
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 supply (no partial fills)
  • Any validation fails

Queue functions

joinQueue

Enter the queue for a stablecoin. Commits DLRS to the protocol.

function joinQueue(
address stablecoin,
uint256 dlrsAmount
) external returns (uint256 positionId)
ParameterTypeDescription
stablecoinaddressStablecoin to wait for
dlrsAmountuint256Amount of DLRS to commit

Returns: Unique position ID

Reverts if:

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

cancelQueue

Cancel a queue position. Protocol returns 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 contract address.

function dlrsToken() external view returns (address)