deBridge 백서

deBridge

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 31쪽 중 2쪽

ure they get the 25% referring bonus. Here’s how you do it: * Go to [https://app.debridge.com/refer](https://app.debridge.com/refer) * Pick Polygon and click generate - it is the cheapest option and covers all of the supported chains, including Solana. * Pass `referralCode` parameter to all DLN API queries, or specify it for all deBridge smart contract calls * Go to the [statistics page](https://app.debridge.com/statistic) and see your stats live <Tip> Please share the code with us if you haven’t already. </Tip> # Where to see your deBridge points You will be able to see your deBridge points by visiting this website and connecting the wallet address you used to generate the referral link: [https://explorer.debridge.com/statistic/](https://explorer.debridge.com/statistic/) # FAQ ### How to check your points You can check your current points here: [https://explorer.debridge.com/statistic/](https://explorer.debridge.com/statistic/) ### I forgot to add a tracking/referral code to the backend. What can I do? It’s crucial that you add your code as soon as possible for your users and you to get points. Otherwise, they will not be accounted for. See the step-by-step guide above for what needs to be done. ### What’s the future purpose of deBridge points? For projects, it’s a primary way of getting a say in future governance and value-creation within the deBridge ecosystem. ### How long will the points program last for? More details on this will be shared after the points program is live, but we can say that it will not be for an extensive period. # Using Referral Codes in Integrations Source: https://docs.debridge.com/dln-details/affiliates/referral-code Learn how to use referral codes in deBridge integrations to track orders and unlock advanced features. # Referral Codes for Integrators When integrating deBridge into a product, the **referral code** can be attached to every order. This is more than just a way to track traffic — it’s a powerful identifier that allows: * **Tracking all orders created through an integration** * **Measure performance and usage** of an integration in real time * **Enable or disable certain features** on a per-integrator basis *** ## Why referral codes matter For integrators, the referral code acts as a unique ID in the deBridge ecosystem. Every order sent with the referral code is linked back to the integration, giving both the integrator and deBridge: * **Analytics visibility** — see how many orders are being processed from an integration platform, along with the volumes * **Feature toggles** — activate or deactivate specific features for a specific integration, like [auto-cancellations](/dln-details/affiliates/auto-cancellations) * **Custom support** — faster debugging and troubleshooting when the referral code is provided *** ## Adding the referral code When creating an order via the API, include the `referralCode` [parameter](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/api-parameters#referral-code) in the request. If integrating via the [Widget](/dln-details/widget/deBridge-widget), the referral code is set via `r=xxxxx` parameter. ## Tracking orders via `referralCode` Tracking the orders via a referral code is simple, the examples can be seen [here](/dln-details/integration-guidelines/order-creation/order-tracking-api/tracking-orders#by-referralcode) or on [GitHub](https://github.com/debridge-finance/api-integrator-example/blob/master/src/scripts/orders/queries/get-orders-by-referral-code.ts). # Referrers Overview Source: https://docs.debridge.com/dln-details/affiliates/referrers Overview of the deBridge Points program and how individual referrers earn and track rewards. # What is the Points Program? The points program is an exciting ecosystem initiative we have launched for all our stakeholders, partners, integrators, users, and others to gain points based on the value and fees they have provided to the deBridge ecosystem. # How does the referral and tracking process work? The deBridge referral and tracking process is straightforward and intuitive for integrators, users, and other stakeholders to start tracking the activity (volume, fees, and transactions) they drive with their specific referral code. It’s fully on-chain — all the activity that a unique referral code generates can be fully tracked via our [statistics page](https://app.debridge.com/statistic) after connecting the wallet that has generated the referral/tracking code. # Individual referrals If you’ve referred users to deBridge apps, you will get 25% of the points generated by any new users you’ve brought to deBridge. A new user is one who hasn’t visited our apps before and came to our app for the first time via your unique referral code. In addition, we want to prevent the possibility for users to do sybiling via self-referrals to get rewards and benefits as that doesn’t have a positive impact on the deBridge protocol and ecosystem. # Why does it matter? We believe anyone who has used deBridge and our applications and/or helped drive activity and volume towards the protocol deserves a share in our collective and future success. The referring component is an important possibility for anyone to start sharing their links with their follower base, network, and/or friends, and get some rewards by doing so. With the points program, we will be granting deBridge points to referrers proportionally to the fees that are being generated for the protocol. Once again, referrers get 25% of all points from the users they refer. # Getting started as an individual referrer Go to [https://app.debridge.com/refer](https://app.debridge.com/refer) and pick Polygon. It is the cheapest option and covers all the supported chains, including Solana. Click "generate" and your referral code will be displayed on the screen. Share your referral link publicly and start driving activity towards the deBridge protocol. Check your accumulated points at [https://explorer.debridge.com/statistic/](https://explorer.debridge.com/statistic/) and follow us on X to stay updated on the latest announcements from deBridge. Welcome to deBridge Points, and thanks for helping us spread the word! # Withdrawing Affiliate Fees Source: https://docs.debridge.com/dln-details/affiliates/withdrawing-affiliate-fees Withdrawing Cross-Chain Affiliate Fees and Same-Chain Affiliate Fees # Cross-Chain Affiliate Fees Affiliate fees can be specified by any integration using the [DLN API](/dln-details/integration-guidelines/order-creation/authentication) or the [deBridge Widget](/dln-details/widget/deBridge-widget). The fees are free to be distributed to the designated beneficiary once [liquidity is unlocked by a solver](/dln-details/dln-specifics/order-fulfillment/claiming-order) from a fulfilled order—typically within a few hours after the order execution. ### EVM chains 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. An additional consideration is that gas costs for **affiliate fee transfers are capped at 2300 gas**. If the `affiliateFeeRecipient` is a contract that requires more gas to process the transfer, the affiliate fees will not be sent, but the order will still be processed normally. In those cases, affiliate fees have to be claimed manually by calling `DlnSource.withdrawUnclaimedAffiliateFees(...)`. The caller can be anyone, but the specified beneficiary must be the `affiliateFeeRecipient` set in the request. ### Solana 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). <Accordion title="Simplified Example Snippet"> ```typescript theme={null} import { Solana } from "@debridge-finance/dln-client" import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js"; function findAssociatedTokenAddress(wallet: PublicKey, tokenMint: PublicKey) : [PublicKey, number] { return PublicKey.findProgramAddressSync( [wallet.toBytes(), new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBytes(), tokenMint.toBytes()], new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL") ); } const solanaClient = new Solana.DlnClient( // Replace with dedicated RPC for production new Connection(clusterApiUrl("mainnet-beta")), new PublicKey("src5qyZHqTqecJV4aY6Cb6zDZLMDzrDKKezs22MPHr4"), new PublicKey("dst5MGcFPoBeREFAA5E3tU5ij8m5uVYwkzkSAbsLbNo"), new PublicKey("DEbrdGj3HsRsAzx6uH4MKyREKxVAfBydijLUF3ygsFfh"), new PublicKey("DeSetTwWhjZq6Pz9Kfdo1KoS5NqtsM6G8ERbX4SSCSft"), ) type Order = { orderId: string; beneficiary: PublicKey; giveToken: PublicKey; } // Load the order using known data or fetch via transaction hash // const order = await solanaClient.getOrderFromTransaction( // { giveChain: ChainId.Solana, txHash: "CREATE_TX_HASH" } // ); const order: Order = { /* order data */ }; // Build and send the withdraw transaction const [associatedTokenAddress] = findAssociatedTokenAddress( order.beneficiary, order.giveToken ); const tx = await solanaClient.source.withdrawAffiliateFee( order.orderId, order.beneficiary, associatedTokenAddress ); // Send the transaction... ``` </Accordion> # Same-Chain Affiliate Fees Same-Chain Swaps also support affiliate fees using the same `affiliateFeePercent` and `affiliateFeeRecipient` parameters as cross-chain swaps. ### EVM Chains Affiliate fees for same-chain swaps on EVM chains are handled automatically during the swap transaction execution. No additional configuration is required. ### Solana Earned fees can be claimed via the [Jupiter Referral Dashboard](https://referral.jup.ag/dashboard), as specified in the [affiliate fees article](/dln-details/affiliates/affiliate-fees#solana). # Bridging Non-Reserve Assets Source: https://docs.debridge.com/dln-details/dln-specifics/bridging-non-reserve-assets Bridging Non-Reserve Assets: Overview and Pre-Order-Swap. # Overview The [deBridge Liquidity Network (DLN)](/dln-details/overview/introduction) protocol supports bridging any liquid token from the source chain to the destination chain, not just [reserve assets](/dln-details/dln-specifics/reserve-assets). While the actions taken by the system are similar to those used when [bridging reserve assets](/dln-details/dln-specifics/bridging-reserve-assets), the internal flow differs and introduces considerations that must be communicated clearly for a seamless end-user experience. ```mermaid theme={null} sequenceDiagram actor User participant CreateTx participant Aggregators participant ERC20_Contract participant dln as DlnContracts rect rgba(230, 230, 255, .15) Note right of User: Get Transaction <br/> and Estimate User ->> CreateTx : get(...) activate CreateTx CreateTx ->> Aggregators : simulate(...) activate Aggregators Aggregators -->> CreateTx : simulation response deactivate Aggregators CreateTx -->> User : response deactivate CreateTx end opt inputAssetType == ERC20 User ->> ERC20_Contract : approve(actorAddr, tx.to, amount) ERC20_Contract -->> User : approve tx receipt end User ->> User : sign response.tx rect rgba(240, 240, 240, .15) Note right of User: Create Order <br/> Transaction Note right of User: Atomic User ->> dln : submit signed response.tx activate dln opt inputAssetType == ERC20 dln ->> ERC20_Contract : transferFrom(actorAddr, dlnAddr, amount) end dln ->> Aggregators: swap() dln ->> dln : finishCreatingOrder() deactivate dln dln -->> User : transaction receipt end ``` ### Pre-Order-Swap Cross-chain settlements are executed in [reserve assets](/dln-details/dln-specifics/reserve-assets) to simplify operations for solvers. As a result, whenever a non-reserve asset is bridged, it must first be swapped into a reserve asset before the order is created—a process referred to as the **Pre-Order-Swap**. The `create-tx` API automatically handles this swap step. It queries DeFi aggregators in the background to simulate the swap and produce `response.tx.calldata` (see step 1a in the diagram). The API is optimized to select the best available rate. Once a user signs and submits `response.tx`, the DLN smart contracts initiate the process by transferring the approved non-reserve assets to themselves (step 3a). The actual **Pre-Order-Swap** is executed via an Automated Market Maker (AMM) (step 3b). Given the potential for price slippage, **the destination chain estimate is based on the minimum amount a user would receive from the swap**. <Tip> If integrators prefer to manage the swap path manually, they can perform the conversion to [reserve assets](/dln-details/dln-specifics/reserve-assets) themselves before calling the `create-tx` endpoint -- ensuring complete control over the swap route. </Tip> This design—basing estimates on the minimum outcome of the **Pre-Order-Swap** -- helps shield users from market volatility and reduces the likelihood of orders being ignored due to insufficient profitability from a solver's perspective. Once the swap completes, the [reserve assets](/dln-details/dln-specifics/reserve-assets) are locked within the protocol until the order is either [fulfilled or cancelled](/dln-details/integration-guidelines/order-creation/order-tracking-api/order-states). <Tip> If the order is [cancelled](/dln-details/integration-guidelines/order-creation/cancelling-order), the locked [reserve assets](/dln-details/dln-specifics/reserve-assets) are returned to the user. It is important to note that the user will receive reserve assets back \-- not the original non-reserve assets used at the start of the process. </Tip> # Bridging Reserve Assets Source: https://docs.debridge.com/dln-details/dln-specifics/bridging-reserve-assets Order creation flow and asset handling when bridging reserve assets. This page outlines the behavior of input assets during order creation and provides a visual representation of the process for creating an order using reserve assets. When interacting with the `create-tx` API, the [response]() includes a `tx` field. To create an order, it is sufficient to sign the transaction and submit it to the network. The `data` field within `tx` contains all necessary instructions for creating an order on the source chain. The simplest scenario occurs when bridging [reserve assets](/dln-details/dln-specifics/reserve-assets) from the source chain to the destination chain. In this case, the order creation process on the initiator’s side consists of three distinct steps: * Step 1: Call `create-tx` API with the required [parameters](). * Step 2: After receiving the [response](), call `approve` on the ERC-20 contract of the [reserve assets](/dln-details/dln-specifics/reserve-assets). The spender should be set to `response.tx.to` value, and the approved amount should match the value specified in the transaction, with [caveats](). * Note: This step is required only for ERC-20 assets. * Step 3: Sign response.tx and submit the transaction. This action locks the specified amount of [reserve assets](/dln-details/dln-specifics/reserve-assets) on the source chain until the order is either [claimed by a solver]() or [cancelled by an authorized entity](). ```mermaid theme={null} sequenceDiagram actor User participant CreateTx participant Aggregators participant ERC20_Contract participant dln as DlnContracts rect rgba(230, 230, 255, .15) Note right of User: Get Transaction <br/> and Estimate User ->> CreateTx : get(...) activate CreateTx CreateTx ->> Aggregators : simulate(...) activate Aggregators Aggregators -->> CreateTx : simulation response deactivate Aggregators CreateTx -->> User : response deactivate CreateTx end opt inputAssetType == ERC20 User ->> ERC20_Contract : approve(actorAddr, tx.to, amount) ERC20_Contract -->> User : approve tx receipt end User ->> User : sign response.tx rect rgba(240, 240, 240, .15) Note right of User: Create Order <br/> Transaction Note right of User: Atomic User ->> dln : submit signed response.tx activate dln opt inputAssetType == ERC20 dln ->> ERC20_Contract : transferFrom(actorAddr, dlnAddr, amount) end dln ->> dln : finishCreatingOrder() deactivate dln dln -->> User : transaction receipt end ``` Once these steps are completed, the bridging process from the user's perspective is finished. The next actions involve either [monitoring the order’s status]() or [initiating cancellation](). Additional details on how solvers fulfill the order on the destination chain are available [here](/dln-details/dln-specifics/order-fulfillment/order-fulfillment). # Claiming an Order Source: https://docs.debridge.com/dln-details/dln-specifics/order-fulfillment/claiming-order Claim flow for unlocking source-chain assets after fulfillment. Each `orderId` is deterministic and uniquely identifies an order. To successfully fulfill the order, the solver must use the same parameters that were specified when the order was originally created. After successful fulfillment, the solver creates another transaction to trigger a cross-chain message via the deBridge Messaging Protocol (DMP) to the source chain changing the [order state](/dln-details/integration-guidelines/order-creation/order-tracking-api/order-states) to `SentUnlock`. This message unlocks the input reserve assets, allowing the solver to claim them. If any parameters, such as the token amount or beneficiary, differ from the original order, the resulting `orderId` will not match. In such cases, the solver’s deposit cannot be matched to a valid order on the source chain, rendering the fulfillment ineffective and ensuring the input funds remain locked and secure on the source chain. ```mermaid theme={null} sequenceDiagram actor Solver participant DlnSource participant DMP rect rgba(240, 240, 240, .15) note right of Solver: Send Unlock Solver ->> DMP : sendCrossChainMessage(orderId) activate DMP DMP -->> Solver : ack DMP ->> DlnSource : unlockOrder deactivate DMP end rect rgba(230, 230, 255, .15) note right of Solver: Claim Input Assets Solver ->> DlnSource : claimOrder(...) activate DlnSource DlnSource -->> Solver : claimReceipt deactivate DlnSource end ``` To finalize the process, the solver calls the `DlnSource.claimUnlock(...)` method on the source chain. This updates the order status to `ClaimedUnlock`, and the initially locked order input reserve assets are transferred to the solver. At this point, the order is considered claimed and fulfilled and its state is `ClaimedUnlock`. Affiliate fees are also automatically paid out on EVM chains, and they are ready for withdrawal on Solana. # Detecting an Order Source: https://docs.debridge.com/dln-details/dln-specifics/order-fulfillment/detecting-order How solvers detect newly created orders and begin fulfillment. The sequence diagram below demonstrates how the fulfillment process begins. After a beneficiary successfully creates an order in `DlnSource` smart contract, a solver will be listening to emitted events. ```mermaid theme={null} sequenceDiagram actor Solver participant DlnSource participant SimulateService actor Beneficiary Beneficiary ->> DlnSource : CreateOrder() rect rgba(240, 240, 240, .15) note right of Solver: Simulate Order DlnSource ->> Solver : CreatedOrder(orderId) Solver ->> SimulateService : simulateOrder(orderId) activate SimulateService SimulateService -->> Solver : simulationResult deactivate SimulateService end ``` Solvers will detect the `CreatedOrder` event: ```solidity theme={null} event CreatedOrder( Order order, bytes32 orderId, bytes affiliateFee, uint256 nativeFixFee, uint256 perc
프로젝트로 돌아가기