dln-client
by deBridge
A client SDK that facilitates interaction deSwap Liquidity Network (DLN) contracts on Solana and EVM blockchains. DLN is built on top of the deBridge cross-chain messaging protocol.
A note on calculating execution fees and take cost
Consider looking at https://github.com/debridge-finance/dln-ts-client/pull/63 for definitions
DLN order creation and expenses
Main flow:
Order creation -> Fulfill / Cancel -> Send unlock -> Claim
After order creation you need to send fulfill, unlock transactions.
Also, if order has calldata you need to store and execute it.
Solana to EVM
Transactions order:
- Order creation (Solana)
- Fulfill (EVM) / Cancel (EVM)
- Send unlock (EVM)
- Claim (Solana)
- Execution calldata (Solana)
Order creation
Transaction example.
This transaction contains the following expenses and returns:
CreateOrderWithNonce | rent | giveOrderState | 176 | -2115840 | |
| rent | giveOrderWallet | 165 | -2039280 | |
| rent | nonceMaster | 16 | -1002240 | Is added when dln nonce account doesn't exists |
| tx fee | | | -5000 | |
| priority fee | | | | |
Claim
Claim transaction follows after fulfill/cancel and send unlock transactions in source chain.
Transaction example.
This transaction contains the following expenses and returns:
Claim | rent | claimToWallet | 165 | -2039280 | Should be returned after claim |
| rent | submission | 194 | -2241120 | Should be returned after claim |
| rent return | confirmationStorage | | +5909040 | |
| tx fee | | | -5000 | |
| priority fee | | | | |
Execution calldata
Before calldata execution you need to fulfill order.
Transaction example.
This transaction contains the following expenses and returns:
ExecuteExternalCall | rent return | externalCallStorage | | +13906080 | |
| rent return | externalCallMeta | | +1085760 | |
| rent return | submissionWallet | | +2039280 | |
| tx fee | | | -5000 | |
| priority fee | | | | |
EVM to Solana
Transactions order:
- Order creation (EVM)
- Fulfill (Solana) / Cancel (Solana)
- Send unlock (Solana)
- Claim (EVM)
- Execution calldata (EVM)
Fulfill
Creates accounts for on-chain data storing which contains order state and additional accounts for calldata.
Transaction example.
This transaction contains the following expenses and returns:
FulfillOrder | rent | takeOrderState | 106 | -1628640 | |
InitializeExtcallMeta | rent | externalCallMeta | 200 | -2282880 | Creates if order contains calldata |
| rent | executeWallet | 165 | -2039280 | Adds if take order token on Solana is SPL and calldata exists |
| tx fee | | | -5000 | |
| priority fee | | | | |
Send unlock
For availability to claim order in destination chain.
Transaction example.
This transaction contains the following expenses and returns:
PrepareSend | transfer | sendFrom | | | = externalCallStorage + externalCallMeta + debridge fix fee (transferred to debridge feeBeneficiary) |
| transfer | sendFromWallet | | | = execution fee |
SendUnlock / SendBatchUnlock | rent | nonceStorage | 16 | -1002240 | Is added when debridge nonce account doesn't exist |
| rent | externalCallStorage | 76 | -1419840 | If batch unlock it would be 108 + (32 * n), where n - amount of orders in batch |
| rent | externalCallMeta | 28 | -1085760 | |
| protocol fee | | | -30000000 | Transfers to feeBeneficiary (prod value, hanoi value is 100000) |
| execution fee | | | -57823 | Depends from give chain, transfers to stakingWallet |
| tx fee | | | -5000 | |
| priority fee | | | | |
Cancel
Calls instead of fulfill if you want to cancel an order.
Transaction example.
This transaction contains the following expenses:
CancelOrder | rent | takeOrderState | 106 | -1628640 | |
PrepareSend | transfer | sendFrom | | | = externalCallStorage + externalCallMeta + debridge fix fee (transferred to debridge feeBeneficiary) |
| transfer | sendFromWallet | | | = execution fee |
SendUnlock | rent | nonceStorage | 16 | -1002240 | Is added when debridge nonce account doesn't exist |
| rent | externalCallStorage | 76 | -1419840 | |
| rent | externalCallMeta | 28 | -1085760 | |
| protocol fee | | | -30000000 | Transfers to feeBeneficiary (prod value, hanoi value is 100000) |
| execution fee | | | -364728 | Depends from give chain, transfers to stakingWallet |
| tx fee | | | -5000 | |
| priority fee | | | | |