Skip to content

Latest commit

 

History

History
448 lines (325 loc) · 31.7 KB

File metadata and controls

448 lines (325 loc) · 31.7 KB

Sky

(sky)

Overview

Available Operations

skyPosition

Check the USDS overall position.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.sky.skyPosition({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { skySkyPosition } from "@compass-labs/api-sdk/funcs/skySkyPosition.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 skySkyPosition(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("skySkyPosition failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1SkyPositionRequest ✔️ 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.

Response

Promise<components.SkyCheckPositionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

skyBuy

Buy USDS with DAI or USDC on a 1:1 basis. There are no fees.

If buying with DAI, user will need to set an allowance on the DAI contract for the 'SkyDaiUsdsConverter' contract beforehand.

If buying with USDC, user will need to set an allowance on the USDC contract for the 'SkyUsdcUsdsConverter' contract beforehand. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `SkyUsdcUsdsConverter`
  • SkyDaiUsdsConverter

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.sky.skyBuy({
    tokenIn: "USDC",
    amount: 1.5,
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { skySkyBuy } from "@compass-labs/api-sdk/funcs/skySkyBuy.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 skySkyBuy(compassApiSDK, {
    tokenIn: "USDC",
    amount: 1.5,
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("skySkyBuy failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.SkyBuyRequest ✔️ 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.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

skySell

Sell USDS for DAI or USDC on a 1:1 basis. There are no fees.

If swapping to DAI, user will need to set an allowance on the USDS contract for the 'SkyDaiUsdsConverter' contract beforehand.

If swapping to USDC, user will need to set an allowance on the USDS contract for the 'SkyUsdcUsdsConverter' contract beforehand. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `SkyUsdcUsdsConverter`
  • SkyDaiUsdsConverter

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.sky.skySell({
    tokenOut: "DAI",
    amount: 1.5,
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { skySkySell } from "@compass-labs/api-sdk/funcs/skySkySell.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 skySkySell(compassApiSDK, {
    tokenOut: "DAI",
    amount: 1.5,
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("skySkySell failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.SkySellRequest ✔️ 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.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

skyDeposit

Deposit USDS to earn yield. Deposited USDS is represented as sUSDS.

Allowance must be set on USDS contract for UsdsVault.

There are no fees. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `SkyUsdsVault`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.sky.skyDeposit({
    amount: 1.5,
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { skySkyDeposit } from "@compass-labs/api-sdk/funcs/skySkyDeposit.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 skySkyDeposit(compassApiSDK, {
    amount: 1.5,
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("skySkyDeposit failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.SkyDepositRequest ✔️ 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.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

skyWithdraw

Withdraw USDS. Exchange yield-bearing sUSDS for USDS.

Allowance must be set on USDS contract for UsdsVault.

There are no fees. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `SkyUsdsVault`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.sky.skyWithdraw({
    amount: 4514.13,
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { skySkyWithdraw } from "@compass-labs/api-sdk/funcs/skySkyWithdraw.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 skySkyWithdraw(compassApiSDK, {
    amount: 4514.13,
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("skySkyWithdraw failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.SkyWithdrawRequest ✔️ 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.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*