11. Fees and attribution
Nothing is added for you. No builder, search or plan adds a fee, a payout address or a Gibs Finance label unless you pass it. Every fee below is an on-chain setting you read, a charge of a provider that you show, or a fee that you chose.
Bridge fees are a rate per 1e18. Aggregator referral fees are in basis points.
What the recipient receives
The recipient receives the amount after the bridge fee, minus the delivery fee. The bridge fee is amountToBridge * bridgeFee / 1e18. The delivery fee exists only when you buy delivery. A user who claims alone pays no delivery fee.
Before the send. Use bridgeCost and amountAfterBridgeFee, then deliveryFee, then estimatedAmountOut. All are in @gibs/bridge-sdk/settings. plannedRecipientAmount in examples/example-c-delivered-amount.ts joins them. For a search result, the deliveredAmount of an omnibridge hop already holds this figure when you passed delivery and deliveryFeeTermsFor. The helper amountAfterDeliveryFee in @gibs/bridge-sdk/routing does the same subtraction for one QuotedDeliveryFee.
After the transfer completes. Read delivery.amount from the indexer's transfer record. It is what the destination omnibridge released. On a delivered crossing, that value reached the delivery router before the router took its fee. So subtract the fee that the fee director asks for. Call directedDeliveryFee({ settings, limit, multiplier, value }) with value set to delivery.amount. It returns { kind, fee }.
directedDeliveryFee copies the router's rules:
- Settings bit 0 (fixed) wins first. The fee is
limit. - Otherwise, bit 3 (percent) sets the fee to
value * multiplier / 1e18. The limit does not cap a percent fee. - Otherwise the mode is gas tip. The fee is a gas cost that only the delivery transaction knows. So the result has
kind: 'at-most', andfeeis the ceiling (thelimit), not the charge. - Every mode caps the fee at
value.
Settings bit 1 asks the router to unwrap to the native coin. Bit 2 excludes the priority fee, and the SDK always sets it. feeTypeSettings writes all four bits.
A result with kind: 'exact' gives the exact amount for the recipient. A result with kind: 'at-most' gives a lowest amount. Show it as "at least". A crossing that the user released alone pays no router fee, so do not apply directedDeliveryFee to it.
Your attribution. Pass it in one place for the search, and in the same fields of the ConsolidatedQuoteRequest for the live quote:
Each attribution field is either left out (nothing is sent) or your own string. Do not pass anything from @gibs/bridge-sdk/referral. Those values pay Gibs Finance.