@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
787 lines (767 loc) • 36.6 kB
text/typescript
/**
* Generated by orval v7.21.0 🍺
* Do not edit manually.
* Coinbase Developer Platform APIs
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
* OpenAPI spec version: 2.0.0
*/
import type {
AdjustBorrowPositionRequest,
AdjustBorrowPositionWithEndUserAccountParams,
BlockchainAddress,
BorrowProduct,
BorrowProductId,
CloseBorrowPositionRequest,
CloseBorrowPositionWithEndUserAccountParams,
CreateBorrowPositionRequest,
CreateBorrowPositionWithEndUserAccountParams,
CreateDelegationForEndUserAccount201,
CreateDelegationForEndUserAccountBody,
CreateDelegationForEndUserAccountParams,
CreateEvmEip7702DelegationWithEndUserAccount201,
CreateEvmEip7702DelegationWithEndUserAccountBody,
CreateEvmEip7702DelegationWithEndUserAccountParams,
EvmUserOperation,
GetDelegationForEndUser200,
GetDelegationForEndUserAccount200,
GetDelegationForEndUserAccountParams,
GetDelegationForEndUserParams,
GetEvmBorrowProductParams,
GetUserOperationWithEndUserAccountParams,
ListBorrowPositionsWithEndUserAccount200,
ListBorrowPositionsWithEndUserAccountParams,
ListEvmBorrowProducts200,
ListEvmBorrowProductsParams,
RevokeDelegationForEndUserAccountDeprecatedParams,
RevokeDelegationForEndUserAccountParams,
RevokeDelegationForEndUserDeprecatedParams,
RevokeDelegationForEndUserParams,
RevokeDelegationRequest,
SendEvmAssetWithEndUserAccount200,
SendEvmAssetWithEndUserAccountBody,
SendEvmAssetWithEndUserAccountParams,
SendEvmTransactionWithEndUserAccount200,
SendEvmTransactionWithEndUserAccountBody,
SendEvmTransactionWithEndUserAccountParams,
SendSolanaAssetWithEndUserAccount200,
SendSolanaAssetWithEndUserAccountBody,
SendSolanaAssetWithEndUserAccountParams,
SendSolanaTransactionWithEndUserAccount200,
SendSolanaTransactionWithEndUserAccountBody,
SendSolanaTransactionWithEndUserAccountParams,
SendUserOperationWithEndUserAccountBody,
SendUserOperationWithEndUserAccountParams,
SignEvmMessageWithEndUserAccount200,
SignEvmMessageWithEndUserAccountBody,
SignEvmMessageWithEndUserAccountParams,
SignEvmTransactionWithEndUserAccount200,
SignEvmTransactionWithEndUserAccountBody,
SignEvmTransactionWithEndUserAccountParams,
SignEvmTypedDataWithEndUserAccount200,
SignEvmTypedDataWithEndUserAccountBody,
SignEvmTypedDataWithEndUserAccountParams,
SignSolanaMessageWithEndUserAccount200,
SignSolanaMessageWithEndUserAccountBody,
SignSolanaMessageWithEndUserAccountParams,
SignSolanaTransactionWithEndUserAccount200,
SignSolanaTransactionWithEndUserAccountBody,
SignSolanaTransactionWithEndUserAccountParams,
SignSolanaX402PaymentWithEndUserAccount200,
SignSolanaX402PaymentWithEndUserAccountBody,
SignSolanaX402PaymentWithEndUserAccountParams,
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
import { cdpApiClient } from "../../cdpApiClient.js";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/**
* Lists the borrow products available across all supported networks and protocols. If a network and/or protocol query parameter is supplied, then borrow products are filtered and returned accordingly.
A borrow product is a protocol-native representation of a borrowable market, describing the venue that hosts it, the assets that can be borrowed or posted as collateral, and their collateral and debt capabilities. For example, a Morpho Blue market that lends USDC against cbBTC.
* @summary List borrow products
*/
export const listEvmBorrowProducts = (
params?: ListEvmBorrowProductsParams,
options?: SecondParameter<typeof cdpApiClient<ListEvmBorrowProducts200>>,
) => {
return cdpApiClient<ListEvmBorrowProducts200>(
{ url: `/v2/embedded-wallet-api/evm/borrow-products`, method: "GET", params },
options,
);
};
/**
* Gets a single borrow product by its ID.
The ID is a stable identifier that uniquely identifies a single borrow product based on the product's onchain parameters. A borrow product is a protocol-native representation of a borrowable market, describing the venue that hosts it and the assets that participate in it together with their collateral and debt capabilities.
* @summary Get a borrow product
*/
export const getEvmBorrowProduct = (
borrowProductId: BorrowProductId,
params?: GetEvmBorrowProductParams,
options?: SecondParameter<typeof cdpApiClient<BorrowProduct>>,
) => {
return cdpApiClient<BorrowProduct>(
{
url: `/v2/embedded-wallet-api/evm/borrow-products/${borrowProductId}`,
method: "GET",
params,
},
options,
);
};
/**
* Signs a transaction with the given end user EVM account.
The transaction should be serialized as a hex string using [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/).
The transaction must be an [EIP-1559 dynamic fee transaction](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md). The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.
* @summary Sign transaction via end user EVM account
*/
export const signEvmTransactionWithEndUserAccount = (
userId: string,
signEvmTransactionWithEndUserAccountBody: SignEvmTransactionWithEndUserAccountBody,
params?: SignEvmTransactionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignEvmTransactionWithEndUserAccount200>>,
) => {
return cdpApiClient<SignEvmTransactionWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/sign/transaction`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signEvmTransactionWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs a transaction with the given end user EVM account and sends it to the indicated supported network. This API handles nonce management and gas estimation, leaving the developer to provide only the minimal set of fields necessary to send the transaction. The transaction should be serialized as a hex string using [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/).
The transaction must be an [EIP-1559 dynamic fee transaction](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md).
**Transaction fields and API behavior**
- `to` *(Required)*: The address of the contract or account to send the transaction to.
- `chainId` *(Ignored)*: The value of the `chainId` field in the transaction is ignored.
The transaction will be sent to the network indicated by the `network` field in the request body.
- `nonce` *(Optional)*: The nonce to use for the transaction. If not provided, the API will assign
a nonce to the transaction based on the current state of the account.
- `maxPriorityFeePerGas` *(Optional)*: The maximum priority fee per gas to use for the transaction.
If not provided, the API will estimate a value based on current network conditions.
- `maxFeePerGas` *(Optional)*: The maximum fee per gas to use for the transaction.
If not provided, the API will estimate a value based on current network conditions.
- `gasLimit` *(Optional)*: The gas limit to use for the transaction. If not provided, the API will estimate a value
based on the `to` and `data` fields of the transaction.
- `value` *(Optional)*: The amount of ETH, in wei, to send with the transaction.
- `data` *(Optional)*: The data to send with the transaction; only used for contract calls.
- `accessList` *(Optional)*: The access list to use for the transaction.
* @summary Send transaction via end user EVM account
*/
export const sendEvmTransactionWithEndUserAccount = (
userId: string,
sendEvmTransactionWithEndUserAccountBody: SendEvmTransactionWithEndUserAccountBody,
params?: SendEvmTransactionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SendEvmTransactionWithEndUserAccount200>>,
) => {
return cdpApiClient<SendEvmTransactionWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/send/transaction`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: sendEvmTransactionWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Sends USDC from an end user's EVM account (EOA or Smart Account) to a recipient address on a supported EVM network. This endpoint simplifies USDC transfers by automatically handling contract resolution, decimal conversion, gas estimation, and transaction encoding.
The `amount` field accepts human-readable amounts as decimal strings (e.g., "1.5", "25.50").
* @summary Send USDC on EVM
*/
export const sendEvmAssetWithEndUserAccount = (
userId: string,
address: BlockchainAddress,
asset: "usdc",
sendEvmAssetWithEndUserAccountBody: SendEvmAssetWithEndUserAccountBody,
params?: SendEvmAssetWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SendEvmAssetWithEndUserAccount200>>,
) => {
return cdpApiClient<SendEvmAssetWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/${address}/send/${asset}`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: sendEvmAssetWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) message with the given end user EVM account.
Per the specification, the message in the request body is prepended with `0x19 <0x45 (E)> <thereum Signed Message:\n" + len(message)>` before being signed.
* @summary Sign EIP-191 message via end user EVM account
*/
export const signEvmMessageWithEndUserAccount = (
userId: string,
signEvmMessageWithEndUserAccountBody: SignEvmMessageWithEndUserAccountBody,
params?: SignEvmMessageWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignEvmMessageWithEndUserAccount200>>,
) => {
return cdpApiClient<SignEvmMessageWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/sign/message`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signEvmMessageWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data with the given end user EVM account.
* @summary Sign EIP-712 typed data via end user EVM account
*/
export const signEvmTypedDataWithEndUserAccount = (
userId: string,
signEvmTypedDataWithEndUserAccountBody: SignEvmTypedDataWithEndUserAccountBody,
params?: SignEvmTypedDataWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignEvmTypedDataWithEndUserAccount200>>,
) => {
return cdpApiClient<SignEvmTypedDataWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/sign/typed-data`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signEvmTypedDataWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Returns the active delegation for the specified end user, if one exists. This operation can be performed by the end user themselves or by a developer using their API key.
* @summary Get delegation for end user
*/
export const getDelegationForEndUser = (
userId: string,
params?: GetDelegationForEndUserParams,
options?: SecondParameter<typeof cdpApiClient<GetDelegationForEndUser200>>,
) => {
return cdpApiClient<GetDelegationForEndUser200>(
{ url: `/v2/embedded-wallet-api/end-users/${userId}/delegation`, method: "GET", params },
options,
);
};
/**
* > **Deprecation Notice:** Prefer
> [Revoke delegation for end user](#operation/revokeDelegationForEndUser)
> (`POST /v2/embedded-wallet-api/end-users/{userId}/delegation/revoke`), which takes the
> same request body. This `DELETE` path will be removed on **2026-10-22**.
Revokes all active delegations for the specified end user. This operation
can be performed by the end user themselves or by a developer using their
API key.
* @deprecated
* @summary Revoke delegation for end user (deprecated)
*/
export const revokeDelegationForEndUserDeprecated = (
userId: string,
revokeDelegationRequest: RevokeDelegationRequest,
params?: RevokeDelegationForEndUserDeprecatedParams,
options?: SecondParameter<typeof cdpApiClient<void>>,
) => {
return cdpApiClient<void>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/delegation`,
method: "DELETE",
headers: { "Content-Type": "application/json" },
data: revokeDelegationRequest,
params,
},
options,
);
};
/**
* Revokes all active delegations for the specified end user. This operation can be performed by the end user themselves or by a developer using their API key.
* @summary Revoke delegation for end user
*/
export const revokeDelegationForEndUser = (
userId: string,
revokeDelegationRequest: RevokeDelegationRequest,
params?: RevokeDelegationForEndUserParams,
options?: SecondParameter<typeof cdpApiClient<void>>,
) => {
return cdpApiClient<void>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/delegation/revoke`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: revokeDelegationRequest,
params,
},
options,
);
};
/**
* Creates an account-scoped delegation that allows a developer to sign on behalf of an end user for a single blockchain account (identified by its address) for the specified duration. The end user must be authenticated to authorize this delegation.
Multiple account-scoped delegations may exist concurrently for a single end user (one per canonical account address). Account-scoped and user-scoped delegations cannot coexist for the same user.
When the address corresponds to an EVM Smart Account, the delegation is scoped to the Smart Account's owner EOA rather than the Smart Account address itself. This means `/address/{smartAccountAddress}/delegation` and `/address/{ownerEoaAddress}/delegation` resolve to the same delegation, and the 409 `account_scoped_delegation_active` error may be returned when creating via either address if one already exists for the canonical owner.
* @summary Create account-scoped delegation for end user
*/
export const createDelegationForEndUserAccount = (
userId: string,
address: BlockchainAddress,
createDelegationForEndUserAccountBody: CreateDelegationForEndUserAccountBody,
params?: CreateDelegationForEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<CreateDelegationForEndUserAccount201>>,
) => {
return cdpApiClient<CreateDelegationForEndUserAccount201>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/address/${address}/delegation`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: createDelegationForEndUserAccountBody,
params,
},
options,
);
};
/**
* Returns the active account-scoped delegation for the specified end user account, if one exists. Useful for showing delegation status in a UI.
When the address corresponds to an EVM Smart Account, this returns the delegation for the Smart Account's owner EOA.
* @summary Get account-scoped delegation for end user
*/
export const getDelegationForEndUserAccount = (
userId: string,
address: BlockchainAddress,
params?: GetDelegationForEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<GetDelegationForEndUserAccount200>>,
) => {
return cdpApiClient<GetDelegationForEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/address/${address}/delegation`,
method: "GET",
params,
},
options,
);
};
/**
* > **Deprecation Notice:** Prefer
> [Revoke account-scoped delegation for end user](#operation/revokeDelegationForEndUserAccount)
> (`POST /v2/embedded-wallet-api/end-users/{userId}/address/{address}/delegation/revoke`),
> which takes the same request body. This `DELETE` path will be removed on **2026-10-22**.
Revokes the active account-scoped delegation for the specified end user account.
Other account-scoped delegations for the same user are unaffected. This operation
can be performed by the end user themselves or by a developer using their API key.
When the address corresponds to an EVM Smart Account, this revokes the delegation for the
Smart Account's owner EOA.
* @deprecated
* @summary Revoke account-scoped delegation for end user (deprecated)
*/
export const revokeDelegationForEndUserAccountDeprecated = (
userId: string,
address: BlockchainAddress,
revokeDelegationRequest: RevokeDelegationRequest,
params?: RevokeDelegationForEndUserAccountDeprecatedParams,
options?: SecondParameter<typeof cdpApiClient<void>>,
) => {
return cdpApiClient<void>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/address/${address}/delegation`,
method: "DELETE",
headers: { "Content-Type": "application/json" },
data: revokeDelegationRequest,
params,
},
options,
);
};
/**
* Revokes the active account-scoped delegation for the specified end user account. Other account-scoped delegations for the same user are unaffected. This operation can be performed by the end user themselves or by a developer using their API key.
When the address corresponds to an EVM Smart Account, this revokes the delegation for the Smart Account's owner EOA.
* @summary Revoke account-scoped delegation for end user
*/
export const revokeDelegationForEndUserAccount = (
userId: string,
address: BlockchainAddress,
revokeDelegationRequest: RevokeDelegationRequest,
params?: RevokeDelegationForEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<void>>,
) => {
return cdpApiClient<void>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/address/${address}/delegation/revoke`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: revokeDelegationRequest,
params,
},
options,
);
};
/**
* Creates an EIP-7702 delegation for an end user's EVM EOA account, upgrading it with smart account capabilities.
This endpoint:
- Retrieves delegation artifacts from onchain
- Signs the EIP-7702 authorization for delegation
- Assembles and submits a Type 4 transaction
- Creates an associated smart account object
The delegation allows the EVM EOA to be used as a smart account, which enables batched transactions and gas sponsorship via paymaster.
* @summary Create EIP-7702 delegation for end user EVM account
*/
export const createEvmEip7702DelegationWithEndUserAccount = (
userId: string,
createEvmEip7702DelegationWithEndUserAccountBody: CreateEvmEip7702DelegationWithEndUserAccountBody,
params?: CreateEvmEip7702DelegationWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<CreateEvmEip7702DelegationWithEndUserAccount201>>,
) => {
return cdpApiClient<CreateEvmEip7702DelegationWithEndUserAccount201>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/eip7702/delegation`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: createEvmEip7702DelegationWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Gets a user operation by its hash for an end user's EVM Smart Account.
* @summary Get a user operation for end user EVM Smart Account
*/
export const getUserOperationWithEndUserAccount = (
userId: string,
address: string,
userOpHash: string,
params?: GetUserOperationWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<EvmUserOperation>>,
) => {
return cdpApiClient<EvmUserOperation>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/user-operations/${userOpHash}`,
method: "GET",
params,
},
options,
);
};
/**
* Prepares, signs, and sends a user operation for an end user's Smart Account.
* @summary Send user operation for end user Smart Account
*/
export const sendUserOperationWithEndUserAccount = (
userId: string,
address: string,
sendUserOperationWithEndUserAccountBody: SendUserOperationWithEndUserAccountBody,
params?: SendUserOperationWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<EvmUserOperation>>,
) => {
return cdpApiClient<EvmUserOperation>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/send`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: sendUserOperationWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Lists the borrow positions held by an end user smart account, with the live onchain state of each position read at a point-in-time snapshot.
A borrow position represents collateral posted and a loan borrowed against it in a borrow product, such as a Morpho Blue market that lends USDC against cbBTC. Each position reports its current collateral and debt balances, its health factor, and its health status. Returns an empty list if the smart account has no borrow positions.
* @summary List borrow positions for an end user smart account
*/
export const listBorrowPositionsWithEndUserAccount = (
userId: string,
address: string,
params?: ListBorrowPositionsWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<ListBorrowPositionsWithEndUserAccount200>>,
) => {
return cdpApiClient<ListBorrowPositionsWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/borrow-positions`,
method: "GET",
params,
},
options,
);
};
/**
* Creates a borrow position for a specific borrow product, by posting collateral from an end user smart account and borrowing a loan against it. One position can be opened per borrow product for a given smart account.
A borrow product is a protocol-native representation of a borrowable market, such as a Morpho Blue market that lends USDC against cbBTC. The `borrowProductId` identifies the product to borrow against, and the `collateralAmount` and `loanAmount` specify the collateral to post and the loan to take, both expressed as decimal strings in standard unit denomination of their respective tokens.
A user operation is broadcast to open the position onchain. Poll `getUserOperationWithEndUserAccount` with the returned `userOpHash` until it reaches a terminal state. Once the user operation succeeds onchain, use the borrow positions list endpoint to view the user's active positions.
* @summary Create a borrow position for an end user smart account
*/
export const createBorrowPositionWithEndUserAccount = (
userId: string,
address: string,
createBorrowPositionRequest: CreateBorrowPositionRequest,
params?: CreateBorrowPositionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<EvmUserOperation>>,
) => {
return cdpApiClient<EvmUserOperation>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/borrow-positions`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: createBorrowPositionRequest,
params,
},
options,
);
};
/**
* Adjusts an existing borrow position for a specific borrow product by supplying collateral, withdrawing collateral, repaying debt, and/or borrowing more of the loan asset from an end user smart account.
The `borrowProductId` identifies the product whose position to adjust, and the `addCollateralAmount`, `removeCollateralAmount`, `repayLoanAmount`, and `borrowLoanAmount` fields specify the changes to apply, each expressed as a decimal string in standard unit denomination of the respective token.
A single request must not combine `addCollateralAmount` with `removeCollateralAmount` or `repayLoanAmount`, and must not combine `borrowLoanAmount` with `repayLoanAmount` or `removeCollateralAmount`. Otherwise any subset of the four amount fields may be supplied; at least one is required.
A user operation is broadcast to adjust the position onchain. Poll `getUserOperationWithEndUserAccount` with the returned `userOpHash` until it reaches a terminal state. Once the user operation succeeds onchain, use the borrow positions list endpoint to view the user's adjusted positions.
* @summary Adjust a borrow position for an end user smart account
*/
export const adjustBorrowPositionWithEndUserAccount = (
userId: string,
address: string,
adjustBorrowPositionRequest: AdjustBorrowPositionRequest,
params?: AdjustBorrowPositionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<EvmUserOperation>>,
) => {
return cdpApiClient<EvmUserOperation>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/borrow-positions/adjust`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: adjustBorrowPositionRequest,
params,
},
options,
);
};
/**
* Closes an end user smart account's borrow position by fully repaying its outstanding loan and withdrawing all remaining collateral back to the smart account, in a single user operation.
A borrow position is identified by the smart account `address` and the `borrowProductId` in the request body, since a smart account holds at most one position per borrow product. Closing repays the entire accrued debt and withdraws the full collateral balance; there is no partial close. To adjust a position without closing it, use `adjustBorrowPositionWithEndUserAccount` instead.
A user operation is broadcast to close the position onchain. Poll `getUserOperationWithEndUserAccount` with the returned `userOpHash` until it reaches a terminal state. Once the user operation succeeds onchain, the position is closed and no longer appears in the borrow positions list.
* @summary Close a borrow position for an end user smart account
*/
export const closeBorrowPositionWithEndUserAccount = (
userId: string,
address: string,
closeBorrowPositionRequest: CloseBorrowPositionRequest,
params?: CloseBorrowPositionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<EvmUserOperation>>,
) => {
return cdpApiClient<EvmUserOperation>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/evm/smart-accounts/${address}/borrow-positions/close`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: closeBorrowPositionRequest,
params,
},
options,
);
};
/**
* Signs an arbitrary Base64 encoded message with the given Solana account.
**WARNING:** Never sign a message that you didn't generate as it may put your funds at risk.
* @summary Sign Base64-encoded message
*/
export const signSolanaMessageWithEndUserAccount = (
userId: string,
signSolanaMessageWithEndUserAccountBody: SignSolanaMessageWithEndUserAccountBody,
params?: SignSolanaMessageWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignSolanaMessageWithEndUserAccount200>>,
) => {
return cdpApiClient<SignSolanaMessageWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/solana/sign/message`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signSolanaMessageWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs a transaction with the given end user Solana account.
The unsigned transaction should be serialized into a byte array and then encoded as base64.
**Transaction types**
The following transaction types are supported:
* [Legacy transactions](https://solana-labs.github.io/solana-web3.js/classes/Transaction.html)
* [Versioned transactions](https://solana-labs.github.io/solana-web3.js/classes/VersionedTransaction.html)
The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.
* @summary Sign transaction via end user Solana account
*/
export const signSolanaTransactionWithEndUserAccount = (
userId: string,
signSolanaTransactionWithEndUserAccountBody: SignSolanaTransactionWithEndUserAccountBody,
params?: SignSolanaTransactionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignSolanaTransactionWithEndUserAccount200>>,
) => {
return cdpApiClient<SignSolanaTransactionWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/solana/sign/transaction`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signSolanaTransactionWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs an x402 payment payload using the end user's given Solana account.
Accepts the full x402 payment required response body from a resource server plus an index into the accepts array selecting which payment option to sign. The paymentRequired envelope's x402Version, resource, and extensions are carried through into the signed payment payload; only the selected accept entry becomes paymentPayload.accepted.
Returns a signed payment payload that can be base64-encoded and sent in the PAYMENT-SIGNATURE header of the resource request.
If acceptsIndex is out of range for paymentRequired.accepts, or the selected accept is not a Solana network payment option, the request fails with 422.
* @summary Sign x402 payment via end user Solana account
*/
export const signSolanaX402PaymentWithEndUserAccount = (
userId: string,
signSolanaX402PaymentWithEndUserAccountBody: SignSolanaX402PaymentWithEndUserAccountBody,
params?: SignSolanaX402PaymentWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SignSolanaX402PaymentWithEndUserAccount200>>,
) => {
return cdpApiClient<SignSolanaX402PaymentWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/solana/sign/x402-payment`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: signSolanaX402PaymentWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Signs a transaction with the given end user Solana account and sends it to the indicated supported network.
The API handles recent blockhash management and fee estimation, leaving the developer to provide only the minimal set of fields necessary to send the transaction.
The unsigned transaction should be serialized into a byte array and then encoded as base64.
**Transaction types**
The following transaction types are supported:
* [Legacy transactions](https://solana.com/developers/guides/advanced/versions#current-transaction-versions)
* [Versioned transactions](https://solana.com/developers/guides/advanced/versions)
**Instruction Batching**
To batch multiple operations, include multiple instructions within a single transaction. All instructions within a transaction are executed atomically - if any instruction fails, the entire transaction fails and is rolled back.
**Network Support**
The following Solana networks are supported:
* `solana` - Solana Mainnet
* `solana-devnet` - Solana Devnet
The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.
* @summary Send transaction via end user Solana account
*/
export const sendSolanaTransactionWithEndUserAccount = (
userId: string,
sendSolanaTransactionWithEndUserAccountBody: SendSolanaTransactionWithEndUserAccountBody,
params?: SendSolanaTransactionWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SendSolanaTransactionWithEndUserAccount200>>,
) => {
return cdpApiClient<SendSolanaTransactionWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/solana/send/transaction`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: sendSolanaTransactionWithEndUserAccountBody,
params,
},
options,
);
};
/**
* Sends USDC from an end user's Solana account to a recipient address on the Solana network. This endpoint simplifies USDC transfers by automatically handling mint resolution, Associated Token Account (ATA) creation, decimal conversion, and transaction encoding.
The `amount` field accepts human-readable amounts as decimal strings (e.g., "1.5", "25.50").
Use the optional `createRecipientAta` parameter to control whether the sender pays for creating the recipient's Associated Token Account if it doesn't exist.
* @summary Send USDC on Solana
*/
export const sendSolanaAssetWithEndUserAccount = (
userId: string,
address: BlockchainAddress,
asset: "usdc",
sendSolanaAssetWithEndUserAccountBody: SendSolanaAssetWithEndUserAccountBody,
params?: SendSolanaAssetWithEndUserAccountParams,
options?: SecondParameter<typeof cdpApiClient<SendSolanaAssetWithEndUserAccount200>>,
) => {
return cdpApiClient<SendSolanaAssetWithEndUserAccount200>(
{
url: `/v2/embedded-wallet-api/end-users/${userId}/solana/${address}/send/${asset}`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: sendSolanaAssetWithEndUserAccountBody,
params,
},
options,
);
};
export type ListEvmBorrowProductsResult = NonNullable<
Awaited<ReturnType<typeof listEvmBorrowProducts>>
>;
export type GetEvmBorrowProductResult = NonNullable<
Awaited<ReturnType<typeof getEvmBorrowProduct>>
>;
export type SignEvmTransactionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signEvmTransactionWithEndUserAccount>>
>;
export type SendEvmTransactionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof sendEvmTransactionWithEndUserAccount>>
>;
export type SendEvmAssetWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof sendEvmAssetWithEndUserAccount>>
>;
export type SignEvmMessageWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signEvmMessageWithEndUserAccount>>
>;
export type SignEvmTypedDataWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signEvmTypedDataWithEndUserAccount>>
>;
export type GetDelegationForEndUserResult = NonNullable<
Awaited<ReturnType<typeof getDelegationForEndUser>>
>;
export type RevokeDelegationForEndUserDeprecatedResult = NonNullable<
Awaited<ReturnType<typeof revokeDelegationForEndUserDeprecated>>
>;
export type RevokeDelegationForEndUserResult = NonNullable<
Awaited<ReturnType<typeof revokeDelegationForEndUser>>
>;
export type CreateDelegationForEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof createDelegationForEndUserAccount>>
>;
export type GetDelegationForEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof getDelegationForEndUserAccount>>
>;
export type RevokeDelegationForEndUserAccountDeprecatedResult = NonNullable<
Awaited<ReturnType<typeof revokeDelegationForEndUserAccountDeprecated>>
>;
export type RevokeDelegationForEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof revokeDelegationForEndUserAccount>>
>;
export type CreateEvmEip7702DelegationWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof createEvmEip7702DelegationWithEndUserAccount>>
>;
export type GetUserOperationWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof getUserOperationWithEndUserAccount>>
>;
export type SendUserOperationWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof sendUserOperationWithEndUserAccount>>
>;
export type ListBorrowPositionsWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof listBorrowPositionsWithEndUserAccount>>
>;
export type CreateBorrowPositionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof createBorrowPositionWithEndUserAccount>>
>;
export type AdjustBorrowPositionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof adjustBorrowPositionWithEndUserAccount>>
>;
export type CloseBorrowPositionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof closeBorrowPositionWithEndUserAccount>>
>;
export type SignSolanaMessageWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signSolanaMessageWithEndUserAccount>>
>;
export type SignSolanaTransactionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signSolanaTransactionWithEndUserAccount>>
>;
export type SignSolanaX402PaymentWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof signSolanaX402PaymentWithEndUserAccount>>
>;
export type SendSolanaTransactionWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof sendSolanaTransactionWithEndUserAccount>>
>;
export type SendSolanaAssetWithEndUserAccountResult = NonNullable<
Awaited<ReturnType<typeof sendSolanaAssetWithEndUserAccount>>
>;