@debridge-finance/dln-client
TypeScript icon, indicating that this package has built-in type declarations

17.6.2 • Public • Published

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:

  1. Order creation (Solana)
  2. Fulfill (EVM) / Cancel (EVM)
  3. Send unlock (EVM)
  4. Claim (Solana)
  5. Execution calldata (Solana)

Order creation

Transaction example. This transaction contains the following expenses and returns:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
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:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
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:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
ExecuteExternalCall rent return externalCallStorage +13906080
rent return externalCallMeta +1085760
rent return submissionWallet +2039280
tx fee -5000
priority fee

EVM to Solana

Transactions order:

  1. Order creation (EVM)
  2. Fulfill (Solana) / Cancel (Solana)
  3. Send unlock (Solana)
  4. Claim (EVM)
  5. 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:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
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:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
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:

Instruction Spend type Account name Bytes (for alloc) Lamports Comment
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

Package Sidebar

Install

npm i @debridge-finance/dln-client

Weekly Downloads

195

Version

17.6.2

License

GPL-3.0-only

Unpacked Size

4.42 MB

Total Files

506

Last publish

Collaborators

  • scrobot.debridge
  • de_totoro
  • alexsmirnov
  • artyukh
  • alexeychr