from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_charge_fee(order_hash="<value>", owner="<value>", fee={
"recipient": "<value>",
"amount": 8619.46,
"denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE,
}, gas_sponsorship=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHashChargeFee({
orderHash: "<value>",
tokenizedAssetsChargeFeeRequest: {
owner: "<value>",
fee: {
recipient: "<value>",
amount: 8619.46,
denomination: "PERCENTAGE",
},
gasSponsorship: false,
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"fee": {
"amount": "1",
"denomination": "PERCENTAGE",
"recipient": "0x1111111111111111111111111111111111111111"
},
"gas_sponsorship": false,
"owner": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fee: {
amount: '1',
denomination: 'PERCENTAGE',
recipient: '0x1111111111111111111111111111111111111111'
},
gas_sponsorship: false,
owner: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
})
};
fetch('https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fee' => [
'amount' => '1',
'denomination' => 'PERCENTAGE',
'recipient' => '0x1111111111111111111111111111111111111111'
],
'gas_sponsorship' => false,
'owner' => '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee"
payload := strings.NewReader("{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}"
response = http.request(request)
puts response.read_body{
"fee_amount": "<string>",
"proceeds": "<string>",
"transaction": {
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
},
"eip_712": {
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
},
{
"name": "operation",
"type": "uint8"
},
{
"name": "safeTxGas",
"type": "uint256"
},
{
"name": "baseGas",
"type": "uint256"
},
{
"name": "gasPrice",
"type": "uint256"
},
{
"name": "gasToken",
"type": "address"
},
{
"name": "refundReceiver",
"type": "address"
},
{
"name": "nonce",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Charge a partner fee
Charge a partner fee on a filled equity sell order’s USDC proceeds.
Equity orders settle off-chain, so fees can’t be bundled into the trade — call
this after a sell fills and it builds a USDC transfer of your fee from the
actual proceeds, executed by the product account (owner signs, or EIP-712 with
gas_sponsorship).
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_charge_fee(order_hash="<value>", owner="<value>", fee={
"recipient": "<value>",
"amount": 8619.46,
"denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE,
}, gas_sponsorship=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHashChargeFee({
orderHash: "<value>",
tokenizedAssetsChargeFeeRequest: {
owner: "<value>",
fee: {
recipient: "<value>",
amount: 8619.46,
denomination: "PERCENTAGE",
},
gasSponsorship: false,
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"fee": {
"amount": "1",
"denomination": "PERCENTAGE",
"recipient": "0x1111111111111111111111111111111111111111"
},
"gas_sponsorship": false,
"owner": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fee: {
amount: '1',
denomination: 'PERCENTAGE',
recipient: '0x1111111111111111111111111111111111111111'
},
gas_sponsorship: false,
owner: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
})
};
fetch('https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fee' => [
'amount' => '1',
'denomination' => 'PERCENTAGE',
'recipient' => '0x1111111111111111111111111111111111111111'
],
'gas_sponsorship' => false,
'owner' => '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee"
payload := strings.NewReader("{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/tokenized_assets/order/{order_hash}/charge_fee")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fee\": {\n \"amount\": \"1\",\n \"denomination\": \"PERCENTAGE\",\n \"recipient\": \"0x1111111111111111111111111111111111111111\"\n },\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\"\n}"
response = http.request(request)
puts response.read_body{
"fee_amount": "<string>",
"proceeds": "<string>",
"transaction": {
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
},
"eip_712": {
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
},
{
"name": "operation",
"type": "uint8"
},
{
"name": "safeTxGas",
"type": "uint256"
},
{
"name": "baseGas",
"type": "uint256"
},
{
"name": "gasPrice",
"type": "uint256"
},
{
"name": "gasToken",
"type": "address"
},
{
"name": "refundReceiver",
"type": "address"
},
{
"name": "nonce",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Path Parameters
Body
Charge a partner fee on the USDC proceeds of a filled sell order.
Equity orders fill off-chain via a third-party venue, so the fee can't
ride inside the trade (unlike Midas/earn/credit). After the sell order
fills, call this with the order hash to build a USDC transfer(recipient, fee) executed by the product account.
The owner's wallet address; the product account is derived from it.
The partner fee to charge on the sell proceeds, taken in USDC and sent to your fee recipient.
Show child attributes
Show child attributes
When true, returns an EIP-712 payload for gas-sponsored execution instead of an unsigned transaction.
Response
Successful Response
Unsigned USDC fee transfer for the owner to sign.
Exactly one of transaction (gas_sponsorship=false) or eip_712
(gas_sponsorship=true) is set.
Fee charged, in USDC.
^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$Filled USDC proceeds the fee was computed on.
^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$Unsigned transaction transferring the fee from the product account.
Show child attributes
Show child attributes
{ "chainId": "0x2105", "data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d", "from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c", "gas": "0x7a120", "maxFeePerGas": "0x59682f00", "maxPriorityFeePerGas": "0x3b9aca00", "nonce": "0x5", "to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67", "value": "0x0" }
EIP-712 payload for gas-sponsored execution.
Show child attributes
Show child attributes
{ "domain": { "chainId": 8453, "verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1" }, "message": { "baseGas": "0", "data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020", "gasPrice": "0", "gasToken": "0x0000000000000000000000000000000000000000", "nonce": "7", "operation": 1, "refundReceiver": "0x0000000000000000000000000000000000000000", "safeTxGas": "0", "to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA", "value": "0" }, "primaryType": "SafeTx", "types": { "EIP712Domain": [ { "name": "chainId", "type": "uint256" }, { "name": "verifyingContract", "type": "address" } ], "SafeTx": [ { "name": "to", "type": "address" }, { "name": "value", "type": "uint256" }, { "name": "data", "type": "bytes" }, { "name": "operation", "type": "uint8" }, { "name": "safeTxGas", "type": "uint256" }, { "name": "baseGas", "type": "uint256" }, { "name": "gasPrice", "type": "uint256" }, { "name": "gasToken", "type": "address" }, { "name": "refundReceiver", "type": "address" }, { "name": "nonce", "type": "uint256" } ] } }
Was this page helpful?