(universal)
- genericPortfolio - List User Portfolio
- genericSupportedChains - List Supported Chains
- genericAllowance - Get Allowance
- genericEns - Resolve ENS
- genericWrapEth - Wrap ETH
- genericUnwrapWeth - Unwrap WETH
- genericAllowanceSet - Set Allowance
Fetch the detailed portfolio of a specific wallet address on a given blockchain.
This includes the total value of the portfolio in USD and a breakdown of token balances, including their respective values and quantities.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericPortfolio({});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericPortfolio } from "@compass-labs/api-sdk/funcs/universalGenericPortfolio.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericPortfolio(compassApiSDK, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericPortfolio failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1GenericPortfolioRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Portfolio>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Get the list of supported chains by the Compass API.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericSupportedChains({});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericSupportedChains } from "@compass-labs/api-sdk/funcs/universalGenericSupportedChains.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericSupportedChains(compassApiSDK, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericSupportedChains failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1GenericSupportedChainsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.SupportedChainInfo>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users must set a token allowance to authorize the protocol to spend a specified amount of their tokens on their behalf.
This is a crucial step before engaging in any transactions or operations within these protocols, ensuring that the protocol has the necessary permissions to manage the user's tokens securely and efficiently.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericAllowance({
contract: "SkyUsdsVault",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericAllowance } from "@compass-labs/api-sdk/funcs/universalGenericAllowance.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericAllowance(compassApiSDK, {
contract: "SkyUsdsVault",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericAllowance failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1GenericAllowanceRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.AllowanceInfoResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
An ENS name is a string ending in .eth.
E.g. vitalik.eth. This endpoint can be used to
query the actual ethereum wallet address behind the ENS name.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericEns({});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericEns } from "@compass-labs/api-sdk/funcs/universalGenericEns.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericEns(compassApiSDK, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericEns failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1GenericEnsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.EnsNameInfoResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Wrapping ETH creates an ERC20 compliant form of ETH that is typically needed for it to be traded on DeFi protocols.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericWrapEth({
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericWrapEth } from "@compass-labs/api-sdk/funcs/universalGenericWrapEth.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericWrapEth(compassApiSDK, {
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericWrapEth failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.WrapEthRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Unwrapping WETH converts the ERC-20 compliant form of ETH back to native ETH that can be used for gas and other native purposes.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericUnwrapWeth({
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericUnwrapWeth } from "@compass-labs/api-sdk/funcs/universalGenericUnwrapWeth.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericUnwrapWeth(compassApiSDK, {
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericUnwrapWeth failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.UnwrapWethRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
This endpoint allows users to modify the token allowance on any ERC-20 token for a specific protocol.
In decentralized finance (DeFi), setting an allowance is a necessary step to authorize a protocol to spend a specified amount of tokens on behalf of the user. This operation is crucial for ensuring that the protocol can manage the user's tokens securely and efficiently, enabling seamless transactions and operations within the DeFi ecosystem.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.universal.genericAllowanceSet({
token: "USDC",
contract: "AaveV3Pool",
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { universalGenericAllowanceSet } from "@compass-labs/api-sdk/funcs/universalGenericAllowanceSet.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await universalGenericAllowanceSet(compassApiSDK, {
token: "USDC",
contract: "AaveV3Pool",
amount: 1.5,
chain: "base",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("universalGenericAllowanceSet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.SetAllowanceRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |