Limits and rounding
The hard limits on order terms, and exactly how partial fills split collateral, interest and fees.
Limits
fill, post and previewFill revert with InvalidTerms when an order breaks these.
| Field | Limit |
|---|---|
principal | 1 to 2⁹⁶ − 1 raw units (uint96). |
repayment | Greater than principal, up to 2⁹⁶ − 1 raw units. |
collateralAmount | Up to 2¹²⁸ − 1 raw units (uint128). |
collateral, loanToken | Two different admitted tokens, in either role. |
duration | 1 second to 2³² − 1 seconds, about 136 years (uint32). |
validUntil | An order can be filled up to and including this second. |
minFill | At most principal. A fill of minFill must get some collateral, some interest, and more than its fee, so minFill is at least 2. |
amount | At least minFill, at most what is left, and leaving either nothing or at least minFill. |
Partial fills
For a fill of amount after offset principal has already been filled, with end = offset + amount:
collateral = floor(collateralAmount × end / principal) − floor(collateralAmount × offset / principal)
interest = floor((repayment − principal) × end / principal) − floor((repayment − principal) × offset / principal)
repayment = amount + interest
fee = ceil(amount × 30 / 10000)- Collateral and interest are split cumulatively, so the totals across all fills equal the signed amounts exactly. One fill can differ from its exact share by less than one raw unit.
- The fee rounds up per fill, so
nfills can cost up ton − 1raw units more than one fill would. SetminFilllarge enough that this is negligible.
Last updated