Skip to content

Commit 1cd2503

Browse files
damir-bajramovicgitbook-bot
authored andcommitted
GITBOOK-406: Damir's May 21 changes
1 parent 37206df commit 1cd2503

File tree

25 files changed

+210
-143
lines changed

25 files changed

+210
-143
lines changed

docs/SUMMARY.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,12 @@
5353
* [Authentication](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/authentication.md)
5454
* [Creating an Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/README.md)
5555
* [Quick Start](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/quick-start.md)
56-
* [Reserve Assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/reserve-assets.md)
57-
* [Bridging Reserve Assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/bridging-reserve-assets.md)
58-
* [Bridging non-reserve assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/bridging-non-reserve-assets.md)
5956
* [API Parameters](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/api-parameters/README.md)
6057
* [Estimation-Only](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/api-parameters/estimation-only.md)
6158
* [prependOperatingExpenses](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/api-parameters/prependoperatingexpenses.md)
6259
* [API Response](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/api-response/README.md)
6360
* [JSON Example](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/api-response/json-example.md)
6461
* [Refreshing Estimates](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/refreshing-estimates.md)
65-
* [Fees and operating expenses](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/fees-and-operating-expenses.md)
66-
* [Order Fulfillment](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/order-fulfillment/README.md)
67-
* [Detecting the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/order-fulfillment/detecting-the-order.md)
68-
* [Fulfilling the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/order-fulfillment/fulfilling-the-order/README.md)
69-
* [Pre-Fill-Swap](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/order-fulfillment/fulfilling-the-order/pre-fill-swap.md)
70-
* [Claiming the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/order-fulfillment/claiming-the-order.md)
7162
* [Tracking Order Status](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/tracking-order-status/README.md)
7263
* [Order States](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/tracking-order-status/order-states.md)
7364
* [Requesting Order Creation Transaction](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/requesting-order-creation-transaction.md)
@@ -76,12 +67,22 @@
7667
* [Submitting an Order Creation Transaction](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/submitting-an-order-creation-transaction.md)
7768
* [Tracking a Status of the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/tracking-a-status-of-the-order.md)
7869
* [Cancelling the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/cancelling-the-order.md)
79-
* [Affiliate fees](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/affiliate-fees.md)
8070
* [deBridge Widget](dln-the-debridge-liquidity-network-protocol/integration-guidelines/debridge-widget.md)
8171
* [Interacting with smart contracts](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-smart-contracts/README.md)
8272
* [Placing orders](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-smart-contracts/placing-orders.md)
8373
* [Filling orders](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-smart-contracts/filling-orders.md)
84-
* [Withdrawing Affiliate Fees](dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-smart-contracts/withdrawing-affiliate-fees.md)
74+
* [Under the Hood](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/README.md)
75+
* [Reserve Assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/reserve-assets.md)
76+
* [Bridging Reserve Assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/bridging-reserve-assets.md)
77+
* [Bridging Non-Reserve Assets](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/bridging-non-reserve-assets.md)
78+
* [Order Fulfillment](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/order-fulfillment/README.md)
79+
* [Detecting the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/order-fulfillment/detecting-the-order.md)
80+
* [Fulfilling the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/order-fulfillment/fulfilling-the-order/README.md)
81+
* [Pre-Fill-Swap](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/order-fulfillment/fulfilling-the-order/pre-fill-swap.md)
82+
* [Claiming the Order](dln-the-debridge-liquidity-network-protocol/integration-guidelines/under-the-hood/order-fulfillment/claiming-the-order.md)
83+
* [Affiliate fees](dln-the-debridge-liquidity-network-protocol/integration-guidelines/affiliate-fees/README.md)
84+
* [Withdrawing Affiliate Fees](dln-the-debridge-liquidity-network-protocol/integration-guidelines/affiliate-fees/withdrawing-affiliate-fees.md)
85+
* [Fees and operating expenses](dln-the-debridge-liquidity-network-protocol/integration-guidelines/fees-and-operating-expenses.md)
8586
* [Interacting with the deBridge App](dln-the-debridge-liquidity-network-protocol/interacting-with-the-debridge-app/README.md)
8687
* [Custom Linking](dln-the-debridge-liquidity-network-protocol/interacting-with-the-debridge-app/custom-linking.md)
8788
* [Protocol specs](dln-the-debridge-liquidity-network-protocol/protocol-specs/README.md)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
description: >-
3+
Describes how to configure and receive affiliate fees for both cross-chain and
4+
same-chain swaps. Includes platform-specific handling for EVM and Solana.
5+
---
6+
7+
# Affiliate fees
8+
9+
### Affiliate Fees
10+
11+
Affiliate fees can be earned through both cross-chain and same-chain swaps by including the appropriate parameters in the request. This allows integrators to monetize swap activity within their applications.
12+
13+
### Cross-Chain Affiliate Fees <a href="#cross-chain-affiliate-fees" id="cross-chain-affiliate-fees"></a>
14+
15+
To enable affiliate fees for cross-chain swaps, the following [parameters](../interacting-with-the-api/creating-an-order/api-parameters/#affiliate-fee-parameters) must be included when creating an order:
16+
17+
* **`affiliateFeePercent`**: The percentage of the _order input amount_ allocated as the affiliate fee.
18+
* **`affiliateFeeRecipient`**: The address or public key of the affiliate fee beneficiary. This must be:
19+
* A public key on **Solana**
20+
* A wallet address on **EVM chains**
21+
22+
Affiliate fees become available once an order reaches the `ClaimedUnlock` [state](../interacting-with-the-api/tracking-order-status/order-states.md).&#x20;
23+
24+
* On **EVM chains**, the affiliate fee is [automatically transferred to the specified recipient when a solver claims the order](../under-the-hood/order-fulfillment/claiming-the-order.md)
25+
* On **Solana**, the fee must be withdrawn manually. Further details on withdrawing affiliate fees are provided [here](withdrawing-affiliate-fees.md).
26+
27+
### Same-Chain Affiliate Fees <a href="#single-chain-affiliate-fees" id="single-chain-affiliate-fees"></a>
28+
29+
The deBridge Widget also supports affiliate fee collection for same-chain swaps. These swaps use the same `affiliateFeePercent` and `affiliateFeeRecipient` [parameters](../interacting-with-the-api/creating-an-order/api-parameters/#affiliate-fee-parameters), with **Solana** requiring additional configuration.
30+
31+
#### Solana
32+
33+
For same-chain swaps on Solana:
34+
35+
* The `affiliateFeeRecipient` must be a **Jupiter referral key**.
36+
* Referral keys can be generated at [https://referral.jup.ag/dashboard](https://referral.jup.ag/dashboard).
37+
* Earned fees can be claimed via the [Jupiter Referral Dashboard](https://referral.jup.ag/dashboard).
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Withdrawing Affiliate Fees
2+
3+
Affiliate fees can be specified by any integration using the [DLN API ](../interacting-with-the-api/)or the [deBridge Widget](../debridge-widget.md). The fees are free to be distributed to the designated beneficiary once [liquidity is unlocked by a solver from a fulfilled order](../under-the-hood/order-fulfillment/claiming-the-order.md)—typically within a few hours after the order execution.
4+
5+
**EVM chains**
6+
7+
On EVM chains, affiliate fees are automatically transferred to the specified beneficiary address as part of the transaction in which the solver unlocks liquidity. No additional action is required.
8+
9+
**Solana**
10+
11+
On Solana, affiliate fees must be claimed manually by the beneficiary. This is done by invoking the `withdrawAffiliateFee` method of the DLN program. A complete working example for claiming affiliate fees in bulk is available [here](https://github.com/debridge-finance/api-integrator-example/blob/master/src/scripts/affiliates/sol-batch-withdraw.ts).&#x20;
12+
13+
Simplified example snippet:
14+
15+
```typescript
16+
import { Solana } from "@debridge-finance/dln-client"
17+
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
18+
19+
function findAssociatedTokenAddress(wallet: PublicKey, tokenMint: PublicKey)
20+
: [PublicKey, number] {
21+
return PublicKey.findProgramAddressSync(
22+
[wallet.toBytes(),
23+
new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBytes(),
24+
tokenMint.toBytes()],
25+
new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")
26+
);
27+
}
28+
29+
const solanaClient = new Solana.DlnClient(
30+
// Replace with dedicated RPC for production
31+
new Connection(clusterApiUrl("mainnet-beta")),
32+
new PublicKey("src5qyZHqTqecJV4aY6Cb6zDZLMDzrDKKezs22MPHr4"),
33+
new PublicKey("dst5MGcFPoBeREFAA5E3tU5ij8m5uVYwkzkSAbsLbNo"),
34+
new PublicKey("DEbrdGj3HsRsAzx6uH4MKyREKxVAfBydijLUF3ygsFfh"),
35+
new PublicKey("DeSetTwWhjZq6Pz9Kfdo1KoS5NqtsM6G8ERbX4SSCSft"),
36+
)
37+
38+
type Order = {
39+
orderId: string;
40+
beneficiary: PublicKey;
41+
giveToken: PublicKey;
42+
}
43+
44+
// Load the order using known data or fetch via transaction hash
45+
// const order = await solanaClient.getOrderFromTransaction(
46+
// { giveChain: ChainId.Solana, txHash: "CREATE_TX_HASH" }
47+
// );
48+
const order: Order = { /* order data */ };
49+
50+
// Build and send the withdraw transaction
51+
const [associatedTokenAddress] = findAssociatedTokenAddress(
52+
order.beneficiary,
53+
order.giveToken
54+
);
55+
const tx = await solanaClient.source.withdrawAffiliateFee(
56+
order.orderId,
57+
order.beneficiary,
58+
associatedTokenAddress
59+
);
60+
// Send the transaction...
61+
```

docs/dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/creating-an-order/fees-and-operating-expenses.md renamed to docs/dln-the-debridge-liquidity-network-protocol/integration-guidelines/fees-and-operating-expenses.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The spread between the give-offer (i.e., the assets being sold) and the take-offer (i.e., the assets being purchased) must be large enough to incentivize solvers to fulfill the order. In addition to aligning with current market rates, the spread should be sufficient to cover all associated fees and operational expenses, including:
44

5-
* [Affiliate fee](../affiliate-fees.md) (optional)
6-
* [DLN protocol fee](../../../../the-debridge-messaging-protocol/fees-and-supported-chains.md)
5+
* [Affiliate fee](affiliate-fees/) (optional)
6+
* [DLN protocol fee](../../the-debridge-messaging-protocol/fees-and-supported-chains.md)
77
* **Taker’s margin fee** – a small percentage markup over the market rate, serving as the solver’s direct profit for assuming market risk and committing capital
8-
* **Operating costs incurred by the solver** – including gas fees for executing [the swap on the destination chain](order-fulfillment/fulfilling-the-order/pre-fill-swap.md) and for [claiming the locked assets on the source chain](order-fulfillment/fulfilling-the-order/)
8+
* **Operating costs incurred by the solver** – including gas fees for executing [the swap on the destination chain](under-the-hood/order-fulfillment/fulfilling-the-order/pre-fill-swap.md) and for [claiming the locked assets on the source chain](under-the-hood/order-fulfillment/fulfilling-the-order/)

docs/dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-smart-contracts/withdrawing-affiliate-fees.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

docs/dln-the-debridge-liquidity-network-protocol/integration-guidelines/interacting-with-the-api/affiliate-fees.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)