Functions
Core functions
deposit
Deposit a stablecoin and receive DLRS at 1:1.
function deposit(
address stablecoin,
uint256 amount
) external returns (uint256 dlrsMinted)
| Parameter | Type | Description |
|---|---|---|
stablecoin | address | Supported stablecoin to deposit |
amount | uint256 | Amount to deposit (6 decimals) |
Returns: Amount of DLRS minted (always equals amount)
Effects:
- Transfers
stablecoinfrom caller - Processes queue for that stablecoin (fills waiting positions)
- Adds remainder to reserves
- Mints DLRS to caller
Reverts if:
amountis 0stablecoinnot supported- Transfer fails
withdraw
Burn DLRS and receive a stablecoin at 1:1.
function withdraw(
address stablecoin,
uint256 amount
) external returns (uint256 stablecoinReceived)
| Parameter | Type | Description |
|---|---|---|
stablecoin | address | Stablecoin to withdraw |
amount | uint256 | Amount to withdraw (6 decimals) |
Returns: Amount of stablecoin received (always equals amount)
Reverts if:
amountis 0stablecoinnot 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)
| Parameter | Type | Description |
|---|---|---|
fromStablecoin | address | Input stablecoin |
toStablecoin | address | Output stablecoin |
amount | uint256 | Amount to swap |
queueIfUnavailable | bool | If true, queue unfilled portion; if false, mint DLRS |
Returns:
received: Amount filled instantlypositionId: 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)
| Parameter | Type | Description |
|---|---|---|
toStablecoin | address | Output stablecoin |
dlrsAmount | uint256 | Amount of DLRS to swap |
queueIfUnavailable | bool | If 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)
| Parameter | Type | Description |
|---|---|---|
fromStablecoin | address | Input stablecoin |
toStablecoin | address | Output stablecoin |
amountIn | uint256 | Exact input amount |
minAmountOut | uint256 | Minimum acceptable output (slippage protection) |
recipient | address | Where to send output tokens |
deadline | uint256 | Unix 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)
| Parameter | Type | Description |
|---|---|---|
stablecoin | address | Stablecoin you want to receive |
dlrsAmount | uint256 | Amount 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)