Skip to main content

Adding fees to orders

This guide will explain maker and taker fees and how they can be applied through Checkout buy and sell methods.


Maker and Taker fees

Checkout supports the adding of maker fees when listing assets for sale and taker fees when assets are purchased. This allows applications that facilitate order creation and fulfillment to collect a fee. The fees are paid by the buyer when the order is filled.

info

Maker fees and taker fees are always applied in the same currency that the asset is listed in. They are always added to the base amount that the asset is listed for. Maker and taker fees can be applied as a specific amount or as a percentage of the listig price.

To illustrate how the maker and taker fees work consider this scenario:

  1. A user lists an asset for sale for 10 IMX on marketplace A. Marketplace A adds a 0.5 IMX maker fee to the order for facilitating the order creation. At this point the price inclusive of maker fees would be 10.5 IMX.
  2. Another user sees that same listing on marketplace B and wishes to purchase it. Marketplace B adds a taker fee of 1% to the order. The taker fee percentage is calculated on the base price of the order (10 IMX * 1%).
  3. Taking into account the maker and taker fees on the order, the final price shown to the buyer would be 10.6 IMX. 10 + 0.5 + (10 * 1%).

Applying maker fees

The Checkout sell() method accepts a sellOrder and an optional array of maker fees for that order. The following example shows the addition of two maker fees. The first is a 1% fee to recipient 1, the second is a specific amount to be paid to recipient 2.

import { checkout, config } from "@imtbl/sdk";

// maker fee applied as a percentage decimal of the buy token amount
// (price + price * 1%)
const onePercentMakerFee: checkout.OrderFee = {
amount: { percentageDecimal: 0.01 },
recipient: '0xRecipient1WalletAddress'
}

// maker fee applied as a specific amount to add to the buy token amount
// (price + 0.01)
const specificAmountMakerFee: checkout.OrderFee = {
amount: {token: '0.01'},
recipient: '0xRecipient2WalletAddress'
}

const sellOrder: checkout.SellOrder = {
sellToken: {
id: '0',
type: checkout.ItemType.ERC721,
collectionAddress: '0xERC721CollectionAddress'
},
buyToken: {
type: checkout.ItemType.ERC20,
amount: '1',
tokenAddress: '0xERC20TokenAddress'
},
// makerFees are always set in the same currency as the listing currency
makerFees: [
onePercentMakerFee,
specificAmountMakerFee
]
}

async function listItemWithMakerFees() {
const checkoutSDK = new checkout.Checkout({ baseConfig: { environment: config.Environment.SANDBOX }})
const { provider } = await checkoutSDK.createProvider({ walletProviderName: checkout.WalletProviderName.METAMASK });

const sellResult = await checkoutSDK.sell({
provider,
orders: [sellOrder]
})
}

Applying taker fees

The Checkout buy() method accepts an array of taker fees on the buyOrder. The following example shows the addition of two taker fees. The first is a 1% fee to recipient 1, the second is a specific amount to be paid to recipient 2.

import { checkout, config } from "@imtbl/sdk";

async function buyItemWithTakerFees(orderId: string) {
const checkoutSDK = new checkout.Checkout({baseConfig: {environment: config.Environment.SANDBOX}})
const {provider} = await checkoutSDK.createProvider({walletProviderName: checkout.WalletProviderName.METAMASK});

// taker fee applied as a percentage decimal of the order base amount
// (base price + base price * 1%)
const onePercentTakerFee: checkout.OrderFee = {
amount: { percentageDecimal: 0.01 },
recipient: '0xRecipient1WalletAddress'
}

// taker fee applied as a specific amount to add to the order base amount
// (base price + 0.01)
const specificAmountTakerFee: checkout.OrderFee = {
amount: {token: '0.01'},
recipient: '0xRecipient2WalletAddress'
}

const buyOrder: checkout.BuyOrder = {
id: orderId,
// takerFees are always set in the same currency as the listing currency
takerFees: [
onePercentTakerFee,
specificAmountTakerFee
]
}

const buyResult = await checkoutSDK.buy({
provider,
orders: [buyOrder]
})
}