Skip to content

[api] Loan Quotes

Ursa (9R) requested to merge ursa/loan-quotes into develop

This adds quote endpoints for loan open and close. The affiliate functionality does not currently work since it is not properly handled during loan open - this will be fixed on both the handler and quote in a separate change. Additionally there is no support for DEX aggregation on the quotes, which will be deferred for simplicity until a point where a UI requires it.

Earmark Fee Structure Change

Currently quote endpoints return affiliate and outbound fees in a separate fees section of the quote, and then slip is returned in basis points.

{
  "fees": {
      "affiliate": "12345",
      "asset": "THOR.RUNE",
      "outbound": "2000000"
  },
  "slippage_bps": 1653,
  ...
}

If there are multiple swaps involved (double swap, add, withdraw) the slip is the sum of swap slips, which isn't perfect but the heuristic is close. This breaks down for loans because slippage at each stage is dependent on CR. Instead I propose consolidating around nominal liquidity fee in the target asset along with a total_bps field that is relative to the outbound amount:

{
  "fees": {
      "affiliate": "12345",
      "asset": "THOR.RUNE",
      "outbound": "2000000",
      "liquidity": "67890",
      "total_bps": "330"
  },
  ...
}

This change returns the new fee structure for loan quotes, and a future change will add these to existing quotes and mark the current slippage_bps for deprecation.

Edited by Ursa (9R)

Merge request reports