@debridge-finance/dln-profitability
v1.0.0
Published
Someone who fulfills order in take chain and sends sendUnlock to give chain to receive order.give amount in give chain
Downloads
13
Readme
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
- Pick equivalent tokens
- Calculate preSwap before order creation (if needed)
- Calculate and deduct dln fees
- Deduct taker margin
- Convert equivalent token amount in give chain (accounting fess and margin) into equivalent amount in take chain
- Calculate preSwap before fulfillment (if needed)
- Calculate recommended take amount and zeroBpsTakeAmount - recommended amount with takerMargin set to 0