from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_bundle(owner="<value>", chain=models.CreditBundleRequestChain.HYPEREVM, actions=[
models.CreditUserOperation(
body=models.EarnTransferFromEOAParams(
token="<value>",
amount="709.93",
permit2_signature="<value>",
permit2_nonce=210517,
permit2_deadline=120606,
),
),
], 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.credit.creditBundle({
owner: "<value>",
chain: "hyperevm",
actions: [
{
body: {
actionType: "V2_TRANSFER_FROM_EOA",
token: "<value>",
amount: "709.93",
permit2Signature: "<value>",
permit2Nonce: 210517,
permit2Deadline: 120606,
},
},
],
gasSponsorship: false,
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/credit/bundle \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "<string>",
"actions": [
{
"body": {
"token_in": "<string>",
"token_out": "<string>",
"amount_in": 1.5,
"action_type": "V2_SWAP",
"slippage": 0.5
}
}
],
"gas_sponsorship": false
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '<string>',
actions: [
{
body: JSON.stringify({
token_in: '<string>',
token_out: '<string>',
amount_in: 1.5,
action_type: 'V2_SWAP',
slippage: 0.5
})
}
],
gas_sponsorship: false
})
};
fetch('https://api.compasslabs.ai/v2/credit/bundle', 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/credit/bundle",
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([
'owner' => '<string>',
'actions' => [
[
'body' => [
'token_in' => '<string>',
'token_out' => '<string>',
'amount_in' => 1.5,
'action_type' => 'V2_SWAP',
'slippage' => 0.5
]
]
],
'gas_sponsorship' => false
]),
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/credit/bundle"
payload := strings.NewReader("{\n \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\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/credit/bundle")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/bundle")
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 \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\n}"
response = http.request(request)
puts response.read_body{
"actions_count": 3,
"transaction": {
"chainId": "0x2105",
"data": "0x6a761202000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0xdbba0",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2e",
"to": "0xaB5801a7D398351b8bE11C439e05C5B3259aeC9B",
"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>"
}
]
}Execute multiple credit actions
Compose individual credit operations (supply, withdraw, borrow, repay, swap, transfer) into a single atomic Safe transaction.
The Credit Account must already be created via /v2/credit/create_account.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_bundle(owner="<value>", chain=models.CreditBundleRequestChain.HYPEREVM, actions=[
models.CreditUserOperation(
body=models.EarnTransferFromEOAParams(
token="<value>",
amount="709.93",
permit2_signature="<value>",
permit2_nonce=210517,
permit2_deadline=120606,
),
),
], 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.credit.creditBundle({
owner: "<value>",
chain: "hyperevm",
actions: [
{
body: {
actionType: "V2_TRANSFER_FROM_EOA",
token: "<value>",
amount: "709.93",
permit2Signature: "<value>",
permit2Nonce: 210517,
permit2Deadline: 120606,
},
},
],
gasSponsorship: false,
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/credit/bundle \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "<string>",
"actions": [
{
"body": {
"token_in": "<string>",
"token_out": "<string>",
"amount_in": 1.5,
"action_type": "V2_SWAP",
"slippage": 0.5
}
}
],
"gas_sponsorship": false
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '<string>',
actions: [
{
body: JSON.stringify({
token_in: '<string>',
token_out: '<string>',
amount_in: 1.5,
action_type: 'V2_SWAP',
slippage: 0.5
})
}
],
gas_sponsorship: false
})
};
fetch('https://api.compasslabs.ai/v2/credit/bundle', 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/credit/bundle",
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([
'owner' => '<string>',
'actions' => [
[
'body' => [
'token_in' => '<string>',
'token_out' => '<string>',
'amount_in' => 1.5,
'action_type' => 'V2_SWAP',
'slippage' => 0.5
]
]
],
'gas_sponsorship' => false
]),
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/credit/bundle"
payload := strings.NewReader("{\n \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\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/credit/bundle")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/bundle")
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 \"owner\": \"<string>\",\n \"actions\": [\n {\n \"body\": {\n \"token_in\": \"<string>\",\n \"token_out\": \"<string>\",\n \"amount_in\": 1.5,\n \"action_type\": \"V2_SWAP\",\n \"slippage\": 0.5\n }\n }\n ],\n \"gas_sponsorship\": false\n}"
response = http.request(request)
puts response.read_body{
"actions_count": 3,
"transaction": {
"chainId": "0x2105",
"data": "0x6a761202000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0xdbba0",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2e",
"to": "0xaB5801a7D398351b8bE11C439e05C5B3259aeC9B",
"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>"
}
]
}Body
Request to execute multiple credit actions in a single atomic transaction.
The owner's wallet address that controls the Credit Account.
Target blockchain network where the bundled actions will execute.
arbitrum, base, bsc, ethereum, hyperevm, tempo List of actions to bundle. Actions are executed in order.
1 - 20 elementsShow child attributes
Show child attributes
If true, returns EIP-712 typed data for gas-sponsored execution.
Response
Successful Response
Number of individual transactions bundled in this execution.
3
Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false.
Show child attributes
Show child attributes
{
"chainId": "0x2105",
"data": "0x6a761202000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0xdbba0",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2e",
"to": "0xaB5801a7D398351b8bE11C439e05C5B3259aeC9B",
"value": "0x0"
}
EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true. Owner must sign and submit to /gas_sponsorship/prepare.
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?