Garden allows partners to charge an affiliate fee for each swap initiated through their SDK or API integration. This fee must be specified when requesting a quote and is charged in addition to protocol and solver fees.

Fees are expressed in basis points (bps), where 1 bps = 0.01%. For example, a 30 bps fee equals 0.3% of the source asset value.

Affiliates can earn rewards in USDC or cbBTC on supported chains. Fees can be sent entirely to a single address in one asset, or split across multiple addresses and assets.

For example, a 30 bps fee could be split by sending 10 bps in USDC to an Ethereum address, and 20 bps in cbBTC to a Base address.

The amount of each asset the affiliate will receive is calculated based on prices at the time of the quote and is also stored in the order data. All affiliate fees collected during the week are distributed to the specified addresses at the end of the week.

Implementation

To apply an affiliate fee via API, include the affiliate_fee parameter when requesting a quote:

curl -X 'GET' \
    'https://testnet.api.garden.finance/v2/quote?from=bitcoin_testnet:btc&to=base_sepolia:wbtc&from_amount=100000&affiliate_fee=30' \
    -H 'accept: application/json'

In this example, we’ve added a 30 bps affiliate fee.

To include affiliate fees, add the affiliate_fees field when creating an order.

Here’s a sample create order request:

curl --location 'http://testnet.api.garden.finance/v2/orders' \
    --header 'garden-app-id: f242ea49332293424c96c562a6ef575a819908c878134dcb4fce424dc84ec796' \
    --header 'Content-Type: application/json' \
    --data '{
        "source": {
            "asset": "bitcoin_testnet:btc",
            "owner": "tb1p4pr78swsn60y4ushe05v28mqpqppxxkfkxu2wun5jw6duc8unj3sjrh4gd",
            "amount": "50000"
        },
        "destination": {
            "asset": "base_sepolia:wbtc",
            "owner": "0x004Cc75ACF4132Fc08cB6a252E767804F303F729",
            "amount": "49850"
        },
        "affiliate_fees": [{
            "asset": "base_sepolia:wbtc",
            "address": "0x7A3d05c70581bD345fe117c06e45f9669205384f",
            "fee": 30
        }]
    }'

Check out the full SDK implementation for React or NodeJS here.