Quoting a position
Preview a Spot Margin position with the Leaser quote query, including position size, loan amount, loan rate and margin rate, before opening it.
A quote previews the position that a down payment would open right now, giving its size in the position asset, the loan in the pool currency and the two annual interest rates. Because the quote is a read-only query on the protocol's Leaser, it costs nothing and needs no account, which is why apps use it to show the terms before the user signs.
Request a quote
The quote query names the down payment, the asset that the position will hold and, if you want less than the maximum leverage, a cap on the loan:
{
"quote": {
"downpayment": { "amount": "100000000", "ticker": "USDC" },
"lease_asset": "SOL",
"max_ltd": 2000
}
}The query has three fields:
| Field | Meaning |
|---|---|
downpayment | The down payment, as an amount in the smallest unit and a ticker. It can be in the pool currency, in a position asset of the protocol, or in NLS. |
lease_asset | The ticker of the asset the position will hold. For short markets this is USDC. |
max_ltd | Optional. Caps the loan as a multiple of the down payment, in permille, so 2000 borrows at most 2x the down payment. Omit it to quote the maximum leverage. |
To run the query from the command line, send it to the Leaser of the protocol
with nolusd:
nolusd q wasm contract-state smart $LEASER \
'{"quote":{"downpayment":{"amount":"100000000","ticker":"USDC"},"lease_asset":"SOL"}}'Here $LEASER holds the address of the protocol's Leaser, which you can look
up as described in
Find the contract addresses.
The
command leaves out max_ltd, so it quotes the maximum leverage.
Read the response
For a down payment of 100 USDC on a SOL long with no max_ltd, the Leaser
returns a response like the following one:
{
"data": {
"total": { "amount": "4747215219", "ticker": "SOL" },
"borrow": { "amount": "400000000", "ticker": "USDC" },
"annual_interest_rate": 96,
"annual_interest_rate_margin": 45
}
}The following table explains each field of the response and gives its value in the example:
| Field | Meaning | In the example |
|---|---|---|
total | Position size in the position asset, which is the down payment plus the loan, swapped at the current price. | 4.747 SOL at the time of the example |
borrow | The loan, in the pool currency. | 400 USDC, 4x the down payment at an 80% opening LTV |
annual_interest_rate | The loan rate paid to the pool, in permille a year. | 9.6% |
annual_interest_rate_margin | The margin interest added on top, in permille a year. | 4.5% |
The total interest a position pays is the sum of the two rates, because margin interest is charged on top of the loan rate.
A quote is not binding, because the loan rate depends on the pool's utilization and the position size depends on the price, both at the moment the position opens. Once the position is open, its rate is fixed and does not change afterwards.
Limits checked at opening
A quote shows the terms, and the Leaser enforces the protocol's limits when
open_lease runs. It rejects the open unless all of these conditions hold:
- The down payment is at least the minimum transaction.
- The loan is at least the minimum transaction.
- The down payment plus the loan is at least the minimum position.
The
position parameters
give example values for both minimums and the query that returns the live
ones. Before opening, the lending pool can also report whether it can lend a
given amount, and at what rate, through the LPP query
{"quote":{"amount":{"amount":"400000000","ticker":"USDC"}}}, which returns
{"quote_interest_rate":<permille>} or "no_liquidity".
Once a quote looks right, Opening a position
shows how to send open_lease with the down payment.
Spot Margin
How Nolus Spot Margin positions work on Solana, the contracts behind them, the position parameters, and how to find every contract address on chain.
Opening a position
Send open_lease to open a Spot Margin position, see how the fixed loan rate is set, and follow the Lease as it builds its account on Solana.