Affiliate fee can be specified by anyone who integrates with DLN API or uses a deSwap widget. The fee is received by the beneficiary at the moment when the market maker unlocks liquidity from the fulfilled trade (usually a few hours after the trade is fulfilled).
Withdrawal
EVM chains
For cross-chain transfers initiated from EVM chains, the affiliate fee is transferred to the beneficiary address automatically in the same transaction where the market maker unlocks liquidity from the fulfilled trade.
Solana
For trades initiated from Solana, the affiliate fee is not transferred automatically and should be claimed by the beneficiary by interacting with the DLN program on Solana. withdrawAffiliateFee the method should be called. Here is how it can be done using DLN Client:
import { Solana } from"@debridge-finance/dln-client"import { Connection, PublicKey, clusterApiUrl } from"@solana/web3.js";functionfindAssociatedTokenAddress(wallet:PublicKey, tokenMint:PublicKey): [PublicKey,number] { return PublicKey.findProgramAddressSync([wallet.toBytes(), new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBytes(), tokenMint.toBytes()], new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
}constsolanaClient=newSolana.DlnClient(newConnection(clusterApiUrl("mainnet-beta")),// better use your own RPCnewPublicKey("src5qyZHqTqecJV4aY6Cb6zDZLMDzrDKKezs22MPHr4"),newPublicKey("dst5MGcFPoBeREFAA5E3tU5ij8m5uVYwkzkSAbsLbNo"),newPublicKey("DEbrdGj3HsRsAzx6uH4MKyREKxVAfBydijLUF3ygsFfh"),newPublicKey("DeSetTwWhjZq6Pz9Kfdo1KoS5NqtsM6G8ERbX4SSCSft"),)typeOrder= { orderId:string; beneficiary:PublicKey; giveToken:PublicKey;}// load order in expected formatconstorder:Order; // order could also be loaded from chain by order creation tx hash// const order = solanaClient.getOrderFromTransaction({ giveChain: ChainId.Solana, txHash: "create tx hash" }, {});// build withdraw txconst tx = await solanaClient.source.withdrawAffiliateFee(order.orderId, order.beneficiary, findAssociatedTokenAddress(order.beneficiary, order.giveToken)[0]);
// send withdraw tx