Solver Request

HOT Request

Solvers send a request through the Valantis HOT API.

A Solver's request is structured such that it is meant to ask for a replacement for an existing route or source of liquidity.

{
  "authorized_recipient": "string",
  "authorized_sender": "string",
  "chain_id": 0,
  "token_in": "string",
  "token_out": "string",
  "expected_gas_price": "30",
  "expected_gas_units": "200000",
  "amount_in": "string",
  "amount_out_requested": "string",
  "request_expiry": 0,
  "quote_expiry": 0
}

Example

A solver is trying to replace a USDC -> WETH swap in their original path with a Valantis HOT quote.

  • amount_in is a fixed value of 1000 USDC. This is the amount that the solver wants to swap.

  • The current price of the Uniswap V3 pool is 3000, so the expected WETH from the UniV3 pool is 0.33 WETH.

  • ( This step is optional ) The gas cost of the UniV3 swap is 200,000 gas units. And the estimated gas price is 30 gwei. In case the solver wants to skip these calculations, they can just leave the gas fields empty.

  • The swap is on mainnet, and the solver is confident they can execute it in the next 2 blocks.

Solver Request

  • amount_in = 1000e6 ( token decimals of USDC is 6 )

  • amount_out_requested = 0.33e18 ( token decimals of WETH is 18 )

  • expected_gas_price = "30" gwei

  • expected_gas_units = "200000"

  • quote_expiry = block.timestamp + 24 ( in seconds )

Liquidity Manager ( Signer )

The Liquidity Manager has to calculate 3 important price fields to return a signed quote.

  1. sqrtSpotPriceX96New: This is the liquidity manager's view of the true spot price of the pair. When the HOT quote lands, the AMM spot price will be updated to this value.

  2. sqrtHotPriceX96Discounted: This is the discounted price given to solvers who cause the AMM spot price update. To get the discounted price, the swap needs to fulfil 2 important conditions: - The AMM spot price should not have been updated in the current block.

    - The spot price in the quote should be more current than the previous HOT quote. recorded on chain.

  3. sqrtHotPriceX96Base: This is the base price that a non-discounted HOT quote gets.

Note: To promise complete determinism, liquidity managers can set the base HOT price equal to the discounted HOT price.

The liquidity manager ensures that the sqrtHotPriceX96Discounted is always equal to or better than the price that the solver requested using amount_in and amount_out_requested. Gas compensation If the liquidity manager estimates that swapping through the HOT Pool costs more gas than the alternate venue, it can adjust the amount_out_requested as follows:

amount_out_requested += gas_compensation

gas_compensation = max((gas_used_hot - expected_gas_units) * (expected_gas_price * 1e9) * eth_to_token_out_conversion, 0)

Since token_out is WETH, eth_to_token_out_conversion = 1 in this example.

In the example mentioned above, If the expected gas cost of the HOT swap is 200_500. Then the liquidity manager updates the final amount_out_requested for the solver as such:

The Solver is given a Quote which can execute up to 1000 USDC of volume at the price of HotPriceDiscounted or HotPriceBase depending on how quickly the Quote is submitted. Liquidity Managers should be explicit in their strategy of distributing Quotes to give Solver's soft guarantees that the Discounted price is achievable in a window of a few blocks after distribution.

Expiry

A Solver's request includes the field request_expiry to allow a Solver to request a timely response. This encourages liquidity managers to respond quickly to requests which may be time-sensitive. The solver's request includes a quote_expiry field, enabling solvers to specify a deadline for executing the signed quote on-chain. Note that the quote_expiry field is not binding for liquidity managers. The signed quote provided may have a shorter expiry than requested. However, liquidity managers are strongly encouraged to sign quotes only if they can adhere to the requested quote_expiry.

Last updated