1.0.0 • Published 12 months ago

@debridge-finance/dln-profitability v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Entities

Taker

Someone who fulfills order in take chain and sends sendUnlock to give chain to receive order.give amount in give chain

Equivalent tokens

Tokens which are considered having the same value across different chains and hence be equal one to another. For example, USDC tokens issued by the same emitent (Circle Inc) are considered having the same value on any supported blockchain, so we can simply assume that X USDC on Ethereum has the same value as X USDC on Solana. This approach allows finding the cheapest (fee-free) exchange path across supported blockchains. The only important thing to consider is their decimals.

TokensBucket

A token bucket is a basket of tokens whose value we consider to be equivalent. In this case, we configure equivalent tokens in them for different chains. This makes it easier for us to calculate profitability and reduce the number of requests to price providers

DLN fees

Fees collected by dln protocol

  • fix fee - taken in give chain during order creation
  • transferFee - taken in give chain equivalent token during order creation = bpsToAmount(equivalentTokenGiveAmount, transferFeeBps)
  • affiliateFee - optional affiliate fee, taken during order creation in equivalent token

TakerFlow

Description of how funds will be converted during swaps, order creation/fulfillment/unlock

Flow

  1. Pick equivalent tokens
  2. Calculate preSwap before order creation (if needed)
  3. Calculate and deduct dln fees
  4. Deduct taker margin
  5. Convert equivalent token amount in give chain (accounting fess and margin) into equivalent amount in take chain
  6. Calculate preSwap before fulfillment (if needed)
  7. Calculate recommended take amount and zeroBpsTakeAmount - recommended amount with takerMargin set to 0