Skip to main content
POST
/
v2
/
credit
/
repay
Python (SDK)
from compass_api_sdk import CompassAPI, models


with CompassAPI(
    api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:

    res = compass_api.credit.credit_repay(owner="0x831Ad0C52C77708DA5D49dc8278C966dfdD4ddA1", chain=models.Chain.BASE, repay_token="WETH", repay_amount=0.01, interest_rate_mode=models.InterestRateMode.VARIABLE, withdraw_token="USDC", withdraw_amount=100, slippage=0.5, gas_sponsorship=False)

    # Handle response
    print(res)
{
  "transaction": {
    "chainId": "0x2105",
    "data": "0x6a761202000000000000000000000000...",
    "from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
    "gas": "0x9eb10",
    "maxFeePerGas": "0x3b9aca00",
    "maxPriorityFeePerGas": "0x5f5e100",
    "nonce": "0x2d",
    "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"
        }
      ]
    }
  },
  "estimated_token_out_amount": "100.5000000000"
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json
owner
string
default:0x831Ad0C52C77708DA5D49dc8278C966dfdD4ddA1
required

The address that owns the Credit Account.

chain
enum<string>
default:base
required

Blockchain network.

Available options:
base,
ethereum,
arbitrum,
hyperevm
repay_token
string
default:WETH
required

The borrowed asset to repay (e.g. WETH). Must match the debt position's token.

Examples:

"WETH"

"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"

repay_amount
default:0.01
required

Amount of repay_token to repay (in token units, not wei).

Required range: x > 0
Example:

0.01

interest_rate_mode
enum<string>
default:variable

The interest rate mode of the debt position being repaid. Must match the mode used when borrowing.

Available options:
stable,
variable
Example:

"variable"

withdraw_token
string | null
default:USDC

A token identifier - either a supported symbol (e.g., USDC, WETH) or a valid Ethereum address (0x...)

Example:

"USDC"

withdraw_amount
default:100

Amount of collateral to withdraw (in token units, not wei). Omit together with withdraw_token for repay-only mode.

Required range: x > 0
Example:

100

token_out
string | null

A token identifier - either a supported symbol (e.g., USDC, WETH) or a valid Ethereum address (0x...)

Example:

"WETH"

slippage
default:0.5

Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%). Only used when a swap is needed.

Required range: 0 <= x <= 100
Example:

0.5

gas_sponsorship
boolean
default:false

If true, returns EIP-712 signature data instead of an unsigned transaction.

permit2_signature
string | null

The EOA owner's signature of the Permit2 PermitTransferFrom typed data. When provided, the repay bundle will first pull repay_token from the owner's EOA into the Credit Account via Permit2. Obtain by calling /v2/credit/transfer and signing the returned EIP-712 data.

permit2_nonce
integer | null

The nonce used in the Permit2 signature (from the signed typed data).

Required range: x >= 0
permit2_deadline
integer | null

The deadline timestamp used in the Permit2 signature (from the signed typed data).

Required range: x >= 0

Response

Successful Response

transaction
UnsignedTransaction · object

Unsigned transaction to execute the repay bundle. Present when gas_sponsorship is false.

Example:
{
"chainId": "0x2105",
"data": "0x6a761202000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0x9eb10",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2d",
"to": "0xaB5801a7D398351b8bE11C439e05C5B3259aeC9B",
"value": "0x0"
}
eip_712
BatchedSafeOperationsResponse · object

EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship is true.

Example:
{
"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" }
]
}
}
estimated_token_out_amount
string | null

Estimated amount of token_out received from swap. Only present when token_out differs from withdraw_token.

Pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
Example:

"100.5000000000"