@compass-labs/api-sdk 2.1.14 → 2.1.15-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -18
- package/codeSamples_typescript.yaml +8 -2
- package/dist/commonjs/funcs/earnEarnBundle.d.ts +33 -0
- package/dist/commonjs/funcs/earnEarnBundle.d.ts.map +1 -0
- package/dist/commonjs/funcs/earnEarnBundle.js +133 -0
- package/dist/commonjs/funcs/earnEarnBundle.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/earnmanageparams.d.ts +63 -0
- package/dist/commonjs/models/components/earnmanageparams.d.ts.map +1 -0
- package/dist/commonjs/models/components/earnmanageparams.js +74 -0
- package/dist/commonjs/models/components/earnmanageparams.js.map +1 -0
- package/dist/commonjs/models/components/earnmanagerequest.d.ts +25 -13
- package/dist/commonjs/models/components/earnmanagerequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnmanagerequest.js +9 -7
- package/dist/commonjs/models/components/earnmanagerequest.js.map +1 -1
- package/dist/commonjs/models/components/earnswapparams.d.ts +60 -0
- package/dist/commonjs/models/components/earnswapparams.d.ts.map +1 -0
- package/dist/commonjs/models/components/earnswapparams.js +73 -0
- package/dist/commonjs/models/components/earnswapparams.js.map +1 -0
- package/dist/commonjs/models/components/earnswaprequest.d.ts +26 -14
- package/dist/commonjs/models/components/earnswaprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnswaprequest.js +10 -8
- package/dist/commonjs/models/components/earnswaprequest.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +5 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +5 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/useroperation.d.ts +4 -4
- package/dist/commonjs/models/components/useroperation.d.ts.map +1 -1
- package/dist/commonjs/models/components/useroperation.js +5 -5
- package/dist/commonjs/models/components/useroperation.js.map +1 -1
- package/dist/commonjs/models/components/v2bundlerequest.d.ts +43 -0
- package/dist/commonjs/models/components/v2bundlerequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2bundlerequest.js +59 -0
- package/dist/commonjs/models/components/v2bundlerequest.js.map +1 -0
- package/dist/commonjs/models/components/v2bundleresponse.d.ts +31 -0
- package/dist/commonjs/models/components/v2bundleresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2bundleresponse.js +61 -0
- package/dist/commonjs/models/components/v2bundleresponse.js.map +1 -0
- package/dist/commonjs/models/components/v2useroperation.d.ts +23 -0
- package/dist/commonjs/models/components/v2useroperation.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2useroperation.js +60 -0
- package/dist/commonjs/models/components/v2useroperation.js.map +1 -0
- package/dist/commonjs/sdk/earn.d.ts +22 -0
- package/dist/commonjs/sdk/earn.d.ts.map +1 -1
- package/dist/commonjs/sdk/earn.js +25 -0
- package/dist/commonjs/sdk/earn.js.map +1 -1
- package/dist/esm/funcs/earnEarnBundle.d.ts +33 -0
- package/dist/esm/funcs/earnEarnBundle.d.ts.map +1 -0
- package/dist/esm/funcs/earnEarnBundle.js +97 -0
- package/dist/esm/funcs/earnEarnBundle.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/earnmanageparams.d.ts +63 -0
- package/dist/esm/models/components/earnmanageparams.d.ts.map +1 -0
- package/dist/esm/models/components/earnmanageparams.js +36 -0
- package/dist/esm/models/components/earnmanageparams.js.map +1 -0
- package/dist/esm/models/components/earnmanagerequest.d.ts +25 -13
- package/dist/esm/models/components/earnmanagerequest.d.ts.map +1 -1
- package/dist/esm/models/components/earnmanagerequest.js +7 -5
- package/dist/esm/models/components/earnmanagerequest.js.map +1 -1
- package/dist/esm/models/components/earnswapparams.d.ts +60 -0
- package/dist/esm/models/components/earnswapparams.d.ts.map +1 -0
- package/dist/esm/models/components/earnswapparams.js +34 -0
- package/dist/esm/models/components/earnswapparams.js.map +1 -0
- package/dist/esm/models/components/earnswaprequest.d.ts +26 -14
- package/dist/esm/models/components/earnswaprequest.d.ts.map +1 -1
- package/dist/esm/models/components/earnswaprequest.js +8 -6
- package/dist/esm/models/components/earnswaprequest.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +5 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +5 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/useroperation.d.ts +4 -4
- package/dist/esm/models/components/useroperation.d.ts.map +1 -1
- package/dist/esm/models/components/useroperation.js +3 -3
- package/dist/esm/models/components/useroperation.js.map +1 -1
- package/dist/esm/models/components/v2bundlerequest.d.ts +43 -0
- package/dist/esm/models/components/v2bundlerequest.d.ts.map +1 -0
- package/dist/esm/models/components/v2bundlerequest.js +22 -0
- package/dist/esm/models/components/v2bundlerequest.js.map +1 -0
- package/dist/esm/models/components/v2bundleresponse.d.ts +31 -0
- package/dist/esm/models/components/v2bundleresponse.d.ts.map +1 -0
- package/dist/esm/models/components/v2bundleresponse.js +24 -0
- package/dist/esm/models/components/v2bundleresponse.js.map +1 -0
- package/dist/esm/models/components/v2useroperation.d.ts +23 -0
- package/dist/esm/models/components/v2useroperation.d.ts.map +1 -0
- package/dist/esm/models/components/v2useroperation.js +22 -0
- package/dist/esm/models/components/v2useroperation.js.map +1 -0
- package/dist/esm/sdk/earn.d.ts +22 -0
- package/dist/esm/sdk/earn.d.ts.map +1 -1
- package/dist/esm/sdk/earn.js +25 -0
- package/dist/esm/sdk/earn.js.map +1 -1
- package/docs/models/components/earnmanageparams.md +31 -0
- package/docs/models/components/earnmanageparamsaction.md +17 -0
- package/docs/models/components/{venue.md → earnmanageparamsvenue.md} +1 -1
- package/docs/models/components/earnmanagerequest.md +12 -6
- package/docs/models/components/earnmanagerequestvenue.md +25 -0
- package/docs/models/components/earnswapparams.md +29 -0
- package/docs/models/components/earnswapparamsamountin.md +19 -0
- package/docs/models/components/{slippage.md → earnswapparamsslippage.md} +3 -3
- package/docs/models/components/earnswaprequest.md +10 -5
- package/docs/models/components/earnswaprequestslippage.md +19 -0
- package/docs/models/components/useroperation.md +3 -3
- package/docs/models/components/{body.md → useroperationbody.md} +1 -1
- package/docs/models/components/v2bundlerequest.md +52 -0
- package/docs/models/components/v2bundleresponse.md +24 -0
- package/docs/models/components/v2useroperation.md +27 -0
- package/docs/models/components/v2useroperationbody.md +31 -0
- package/docs/sdks/aavev3/README.md +0 -1
- package/docs/sdks/aerodromeslipstream/README.md +0 -1
- package/docs/sdks/bridge/README.md +0 -1
- package/docs/sdks/earn/README.md +150 -11
- package/docs/sdks/erc4626vaults/README.md +1 -2
- package/docs/sdks/ethena/README.md +0 -1
- package/docs/sdks/gassponsorship/README.md +0 -1
- package/docs/sdks/morpho/README.md +0 -1
- package/docs/sdks/pendle/README.md +0 -1
- package/docs/sdks/sky/README.md +0 -1
- package/docs/sdks/smartaccount/README.md +0 -1
- package/docs/sdks/swap/README.md +0 -1
- package/docs/sdks/token/README.md +0 -1
- package/docs/sdks/transactionbundler/README.md +0 -1
- package/docs/sdks/uniswapv3/README.md +0 -1
- package/docs/sdks/universal/README.md +0 -1
- package/docs/sdks/wildcat/README.md +0 -1
- package/package.json +1 -1
- package/src/funcs/earnEarnBundle.ts +184 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/earnmanageparams.ts +118 -0
- package/src/models/components/earnmanagerequest.ts +38 -18
- package/src/models/components/earnswapparams.ts +115 -0
- package/src/models/components/earnswaprequest.ts +38 -20
- package/src/models/components/index.ts +5 -0
- package/src/models/components/useroperation.ts +52 -45
- package/src/models/components/v2bundlerequest.ts +72 -0
- package/src/models/components/v2bundleresponse.ts +67 -0
- package/src/models/components/v2useroperation.ts +67 -0
- package/src/sdk/earn.ts +33 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# V2BundleRequest
|
|
2
|
+
|
|
3
|
+
Request model for bundling multiple V2 earn actions into a single Safe
|
|
4
|
+
transaction.
|
|
5
|
+
|
|
6
|
+
This endpoint allows combining multiple actions (swaps, vault deposits/withdrawals,
|
|
7
|
+
Aave deposits/withdrawals) into a single atomic transaction executed Compass Account.
|
|
8
|
+
|
|
9
|
+
Example use case: Swap USDC to AUSD, then deposit AUSD into a vault - all in one tx.
|
|
10
|
+
|
|
11
|
+
## Example Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { V2BundleRequest } from "@compass-labs/api-sdk/models/components";
|
|
15
|
+
|
|
16
|
+
let value: V2BundleRequest = {
|
|
17
|
+
owner: "0x0B8A11cF0679F163087802c4428F640cA7C89926",
|
|
18
|
+
chain: "base",
|
|
19
|
+
actions: [
|
|
20
|
+
{
|
|
21
|
+
body: {
|
|
22
|
+
actionType: "V2_SWAP",
|
|
23
|
+
tokenIn: "USDC",
|
|
24
|
+
tokenOut: "0xB0fFa8000886e57F86dd5264b9582b2Ad87b2b91",
|
|
25
|
+
amountIn: "100",
|
|
26
|
+
slippage: "0.5",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
body: {
|
|
31
|
+
actionType: "V2_MANAGE",
|
|
32
|
+
venue: {
|
|
33
|
+
type: "VAULT",
|
|
34
|
+
vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
|
|
35
|
+
},
|
|
36
|
+
action: "DEPOSIT",
|
|
37
|
+
amount: "ALL",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
gasSponsorship: false,
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Fields
|
|
46
|
+
|
|
47
|
+
| Field | Type | Required | Description | Example |
|
|
48
|
+
| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
49
|
+
| `owner` | *string* | :heavy_check_mark: | The owner's wallet address that controls the Earn Account (Safe). | |
|
|
50
|
+
| `chain` | [components.Chain](../../models/components/chain.md) | :heavy_check_mark: | The chain to use. | |
|
|
51
|
+
| `actions` | [components.V2UserOperation](../../models/components/v2useroperation.md)[] | :heavy_check_mark: | List of actions to bundle. Actions are executed in order. | |
|
|
52
|
+
| `gasSponsorship` | *boolean* | :heavy_minus_sign: | If true, returns EIP-712 typed data for gas sponsorship. The owner must sign this data and submit to /gas_sponsorship/prepare. | false |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# V2BundleResponse
|
|
2
|
+
|
|
3
|
+
Response model for V2 bundle execution.
|
|
4
|
+
|
|
5
|
+
Returns either an unsigned transaction (for direct execution) or EIP-712 typed data
|
|
6
|
+
(for gas-sponsored execution).
|
|
7
|
+
|
|
8
|
+
## Example Usage
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { V2BundleResponse } from "@compass-labs/api-sdk/models/components";
|
|
12
|
+
|
|
13
|
+
let value: V2BundleResponse = {
|
|
14
|
+
actionsCount: 314088,
|
|
15
|
+
};
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Fields
|
|
19
|
+
|
|
20
|
+
| Field | Type | Required | Description |
|
|
21
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
22
|
+
| `transaction` | [components.UnsignedTransaction](../../models/components/unsignedtransaction.md) | :heavy_minus_sign: | Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false. |
|
|
23
|
+
| `eip712` | [components.BatchedSafeOperationsResponseOutput](../../models/components/batchedsafeoperationsresponseoutput.md) | :heavy_minus_sign: | EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true. Owner must sign and submit to /gas_sponsorship/prepare. |
|
|
24
|
+
| `actionsCount` | *number* | :heavy_check_mark: | Number of individual transactions bundled in this execution. |
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# V2UserOperation
|
|
2
|
+
|
|
3
|
+
A single operation in a V2 bundle.
|
|
4
|
+
|
|
5
|
+
## Example Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { V2UserOperation } from "@compass-labs/api-sdk/models/components";
|
|
9
|
+
|
|
10
|
+
let value: V2UserOperation = {
|
|
11
|
+
body: {
|
|
12
|
+
actionType: "V2_MANAGE",
|
|
13
|
+
venue: {
|
|
14
|
+
type: "VAULT",
|
|
15
|
+
vaultAddress: "<value>",
|
|
16
|
+
},
|
|
17
|
+
action: "WITHDRAW",
|
|
18
|
+
amount: 6398.2,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Fields
|
|
24
|
+
|
|
25
|
+
| Field | Type | Required | Description |
|
|
26
|
+
| -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- |
|
|
27
|
+
| `body` | *components.V2UserOperationBody* | :heavy_check_mark: | N/A |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# V2UserOperationBody
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Supported Types
|
|
5
|
+
|
|
6
|
+
### `components.EarnManageParams`
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
const value: components.EarnManageParams = {
|
|
10
|
+
actionType: "V2_MANAGE",
|
|
11
|
+
venue: {
|
|
12
|
+
type: "VAULT",
|
|
13
|
+
vaultAddress: "<value>",
|
|
14
|
+
},
|
|
15
|
+
action: "WITHDRAW",
|
|
16
|
+
amount: 3994.36,
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### `components.EarnSwapParams`
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const value: components.EarnSwapParams = {
|
|
24
|
+
actionType: "V2_SWAP",
|
|
25
|
+
tokenIn: "<value>",
|
|
26
|
+
tokenOut: "<value>",
|
|
27
|
+
amountIn: 1543.87,
|
|
28
|
+
slippage: "0.5",
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
package/docs/sdks/earn/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# Earn
|
|
2
|
-
(*earn*)
|
|
3
2
|
|
|
4
3
|
## Overview
|
|
5
4
|
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
* [earnTransfer](#earntransfer) - Transfer tokens to/from account
|
|
14
13
|
* [earnManage](#earnmanage) - Manage earn position
|
|
15
14
|
* [earnSwap](#earnswap) - Swap tokens within Earn Account
|
|
15
|
+
* [earnBundle](#earnbundle) - Bundle multiple actions into a single transaction
|
|
16
16
|
|
|
17
17
|
## earnPositions
|
|
18
18
|
|
|
@@ -537,14 +537,15 @@ const compassApiSDK = new CompassApiSDK({
|
|
|
537
537
|
|
|
538
538
|
async function run() {
|
|
539
539
|
const result = await compassApiSDK.earn.earnManage({
|
|
540
|
-
owner: "0xe5310C39a8A8f16E6126ee6B1006bf6eD58B3A49",
|
|
541
|
-
chain: "base",
|
|
542
540
|
venue: {
|
|
543
541
|
type: "VAULT",
|
|
544
542
|
vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
|
|
545
543
|
},
|
|
546
|
-
action: "
|
|
544
|
+
action: "DEPOSIT",
|
|
547
545
|
amount: "0.01",
|
|
546
|
+
owner: "0xe5310C39a8A8f16E6126ee6B1006bf6eD58B3A49",
|
|
547
|
+
chain: "base",
|
|
548
|
+
gasSponsorship: false,
|
|
548
549
|
});
|
|
549
550
|
|
|
550
551
|
console.log(result);
|
|
@@ -569,14 +570,15 @@ const compassApiSDK = new CompassApiSDKCore({
|
|
|
569
570
|
|
|
570
571
|
async function run() {
|
|
571
572
|
const res = await earnEarnManage(compassApiSDK, {
|
|
572
|
-
owner: "0xe5310C39a8A8f16E6126ee6B1006bf6eD58B3A49",
|
|
573
|
-
chain: "base",
|
|
574
573
|
venue: {
|
|
575
574
|
type: "VAULT",
|
|
576
575
|
vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
|
|
577
576
|
},
|
|
578
|
-
action: "
|
|
577
|
+
action: "DEPOSIT",
|
|
579
578
|
amount: "0.01",
|
|
579
|
+
owner: "0xe5310C39a8A8f16E6126ee6B1006bf6eD58B3A49",
|
|
580
|
+
chain: "base",
|
|
581
|
+
gasSponsorship: false,
|
|
580
582
|
});
|
|
581
583
|
if (res.ok) {
|
|
582
584
|
const { value: result } = res;
|
|
@@ -625,12 +627,12 @@ const compassApiSDK = new CompassApiSDK({
|
|
|
625
627
|
|
|
626
628
|
async function run() {
|
|
627
629
|
const result = await compassApiSDK.earn.earnSwap({
|
|
628
|
-
owner: "0xC1be8f91480648De355a45f3E2562811b4e2D3FF",
|
|
629
|
-
chain: "base",
|
|
630
630
|
tokenIn: "USDC",
|
|
631
631
|
tokenOut: "USDT",
|
|
632
632
|
amountIn: "0.01",
|
|
633
633
|
slippage: "0.5",
|
|
634
|
+
owner: "0xC1be8f91480648De355a45f3E2562811b4e2D3FF",
|
|
635
|
+
chain: "base",
|
|
634
636
|
gasSponsorship: false,
|
|
635
637
|
});
|
|
636
638
|
|
|
@@ -656,12 +658,12 @@ const compassApiSDK = new CompassApiSDKCore({
|
|
|
656
658
|
|
|
657
659
|
async function run() {
|
|
658
660
|
const res = await earnEarnSwap(compassApiSDK, {
|
|
659
|
-
owner: "0xC1be8f91480648De355a45f3E2562811b4e2D3FF",
|
|
660
|
-
chain: "base",
|
|
661
661
|
tokenIn: "USDC",
|
|
662
662
|
tokenOut: "USDT",
|
|
663
663
|
amountIn: "0.01",
|
|
664
664
|
slippage: "0.5",
|
|
665
|
+
owner: "0xC1be8f91480648De355a45f3E2562811b4e2D3FF",
|
|
666
|
+
chain: "base",
|
|
665
667
|
gasSponsorship: false,
|
|
666
668
|
});
|
|
667
669
|
if (res.ok) {
|
|
@@ -690,6 +692,143 @@ run();
|
|
|
690
692
|
|
|
691
693
|
### Errors
|
|
692
694
|
|
|
695
|
+
| Error Type | Status Code | Content Type |
|
|
696
|
+
| -------------------------- | -------------------------- | -------------------------- |
|
|
697
|
+
| errors.HTTPValidationError | 422 | application/json |
|
|
698
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
699
|
+
|
|
700
|
+
## earnBundle
|
|
701
|
+
|
|
702
|
+
Bundle multiple earn actions into a single atomic Safe transaction.
|
|
703
|
+
|
|
704
|
+
This endpoint allows combining multiple actions (swaps, vault deposits/withdrawals,
|
|
705
|
+
Aave deposits/withdrawals) into a single atomic transaction executed via the
|
|
706
|
+
owner's Safe smart account (Earn Account).
|
|
707
|
+
|
|
708
|
+
**Example Use Case:** Swap USDC to AUSD, then deposit AUSD into a vault - all in one transaction.
|
|
709
|
+
|
|
710
|
+
Actions are executed in the order they are provided. Each action type has its own parameters:
|
|
711
|
+
|
|
712
|
+
- **V2_SWAP**: Swap between tokens using 1inch aggregator
|
|
713
|
+
- **V2_MANAGE**: Manage positions - deposit/withdraw to ERC-4626 vaults or Aave lending pool
|
|
714
|
+
|
|
715
|
+
The bundled transaction can be gas-sponsored by setting `gas_sponsorship=true`.
|
|
716
|
+
This returns EIP-712 typed data that the owner must sign and submit to
|
|
717
|
+
`/gas_sponsorship/prepare` for execution by a gas sponsor.
|
|
718
|
+
|
|
719
|
+
### Example Usage
|
|
720
|
+
|
|
721
|
+
<!-- UsageSnippet language="typescript" operationID="v2_earn_bundle" method="post" path="/v2/earn/bundle" -->
|
|
722
|
+
```typescript
|
|
723
|
+
import { CompassApiSDK } from "@compass-labs/api-sdk";
|
|
724
|
+
|
|
725
|
+
const compassApiSDK = new CompassApiSDK({
|
|
726
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
async function run() {
|
|
730
|
+
const result = await compassApiSDK.earn.earnBundle({
|
|
731
|
+
owner: "0x0B8A11cF0679F163087802c4428F640cA7C89926",
|
|
732
|
+
chain: "base",
|
|
733
|
+
actions: [
|
|
734
|
+
{
|
|
735
|
+
body: {
|
|
736
|
+
actionType: "V2_SWAP",
|
|
737
|
+
tokenIn: "USDC",
|
|
738
|
+
tokenOut: "0xB0fFa8000886e57F86dd5264b9582b2Ad87b2b91",
|
|
739
|
+
amountIn: "100",
|
|
740
|
+
slippage: "0.5",
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
body: {
|
|
745
|
+
actionType: "V2_MANAGE",
|
|
746
|
+
venue: {
|
|
747
|
+
type: "VAULT",
|
|
748
|
+
vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
|
|
749
|
+
},
|
|
750
|
+
action: "DEPOSIT",
|
|
751
|
+
amount: "ALL",
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
],
|
|
755
|
+
gasSponsorship: false,
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
console.log(result);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
run();
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
### Standalone function
|
|
765
|
+
|
|
766
|
+
The standalone function version of this method:
|
|
767
|
+
|
|
768
|
+
```typescript
|
|
769
|
+
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
|
|
770
|
+
import { earnEarnBundle } from "@compass-labs/api-sdk/funcs/earnEarnBundle.js";
|
|
771
|
+
|
|
772
|
+
// Use `CompassApiSDKCore` for best tree-shaking performance.
|
|
773
|
+
// You can create one instance of it to use across an application.
|
|
774
|
+
const compassApiSDK = new CompassApiSDKCore({
|
|
775
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
async function run() {
|
|
779
|
+
const res = await earnEarnBundle(compassApiSDK, {
|
|
780
|
+
owner: "0x0B8A11cF0679F163087802c4428F640cA7C89926",
|
|
781
|
+
chain: "base",
|
|
782
|
+
actions: [
|
|
783
|
+
{
|
|
784
|
+
body: {
|
|
785
|
+
actionType: "V2_SWAP",
|
|
786
|
+
tokenIn: "USDC",
|
|
787
|
+
tokenOut: "0xB0fFa8000886e57F86dd5264b9582b2Ad87b2b91",
|
|
788
|
+
amountIn: "100",
|
|
789
|
+
slippage: "0.5",
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
body: {
|
|
794
|
+
actionType: "V2_MANAGE",
|
|
795
|
+
venue: {
|
|
796
|
+
type: "VAULT",
|
|
797
|
+
vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
|
|
798
|
+
},
|
|
799
|
+
action: "DEPOSIT",
|
|
800
|
+
amount: "ALL",
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
],
|
|
804
|
+
gasSponsorship: false,
|
|
805
|
+
});
|
|
806
|
+
if (res.ok) {
|
|
807
|
+
const { value: result } = res;
|
|
808
|
+
console.log(result);
|
|
809
|
+
} else {
|
|
810
|
+
console.log("earnEarnBundle failed:", res.error);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
run();
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
### Parameters
|
|
818
|
+
|
|
819
|
+
| Parameter | Type | Required | Description |
|
|
820
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
821
|
+
| `request` | [components.V2BundleRequest](../../models/components/v2bundlerequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
822
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
823
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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. |
|
|
824
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
825
|
+
|
|
826
|
+
### Response
|
|
827
|
+
|
|
828
|
+
**Promise\<[components.V2BundleResponse](../../models/components/v2bundleresponse.md)\>**
|
|
829
|
+
|
|
830
|
+
### Errors
|
|
831
|
+
|
|
693
832
|
| Error Type | Status Code | Content Type |
|
|
694
833
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
695
834
|
| errors.HTTPValidationError | 422 | application/json |
|
package/docs/sdks/sky/README.md
CHANGED
package/docs/sdks/swap/README.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CompassApiSDKCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Bundle multiple actions into a single transaction
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Bundle multiple earn actions into a single atomic Safe transaction.
|
|
33
|
+
*
|
|
34
|
+
* This endpoint allows combining multiple actions (swaps, vault deposits/withdrawals,
|
|
35
|
+
* Aave deposits/withdrawals) into a single atomic transaction executed via the
|
|
36
|
+
* owner's Safe smart account (Earn Account).
|
|
37
|
+
*
|
|
38
|
+
* **Example Use Case:** Swap USDC to AUSD, then deposit AUSD into a vault - all in one transaction.
|
|
39
|
+
*
|
|
40
|
+
* Actions are executed in the order they are provided. Each action type has its own parameters:
|
|
41
|
+
*
|
|
42
|
+
* - **V2_SWAP**: Swap between tokens using 1inch aggregator
|
|
43
|
+
* - **V2_MANAGE**: Manage positions - deposit/withdraw to ERC-4626 vaults or Aave lending pool
|
|
44
|
+
*
|
|
45
|
+
* The bundled transaction can be gas-sponsored by setting `gas_sponsorship=true`.
|
|
46
|
+
* This returns EIP-712 typed data that the owner must sign and submit to
|
|
47
|
+
* `/gas_sponsorship/prepare` for execution by a gas sponsor.
|
|
48
|
+
*/
|
|
49
|
+
export function earnEarnBundle(
|
|
50
|
+
client: CompassApiSDKCore,
|
|
51
|
+
request: components.V2BundleRequest,
|
|
52
|
+
options?: RequestOptions,
|
|
53
|
+
): APIPromise<
|
|
54
|
+
Result<
|
|
55
|
+
components.V2BundleResponse,
|
|
56
|
+
| errors.HTTPValidationError
|
|
57
|
+
| CompassAPISDKError
|
|
58
|
+
| ResponseValidationError
|
|
59
|
+
| ConnectionError
|
|
60
|
+
| RequestAbortedError
|
|
61
|
+
| RequestTimeoutError
|
|
62
|
+
| InvalidRequestError
|
|
63
|
+
| UnexpectedClientError
|
|
64
|
+
| SDKValidationError
|
|
65
|
+
>
|
|
66
|
+
> {
|
|
67
|
+
return new APIPromise($do(
|
|
68
|
+
client,
|
|
69
|
+
request,
|
|
70
|
+
options,
|
|
71
|
+
));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function $do(
|
|
75
|
+
client: CompassApiSDKCore,
|
|
76
|
+
request: components.V2BundleRequest,
|
|
77
|
+
options?: RequestOptions,
|
|
78
|
+
): Promise<
|
|
79
|
+
[
|
|
80
|
+
Result<
|
|
81
|
+
components.V2BundleResponse,
|
|
82
|
+
| errors.HTTPValidationError
|
|
83
|
+
| CompassAPISDKError
|
|
84
|
+
| ResponseValidationError
|
|
85
|
+
| ConnectionError
|
|
86
|
+
| RequestAbortedError
|
|
87
|
+
| RequestTimeoutError
|
|
88
|
+
| InvalidRequestError
|
|
89
|
+
| UnexpectedClientError
|
|
90
|
+
| SDKValidationError
|
|
91
|
+
>,
|
|
92
|
+
APICall,
|
|
93
|
+
]
|
|
94
|
+
> {
|
|
95
|
+
const parsed = safeParse(
|
|
96
|
+
request,
|
|
97
|
+
(value) => components.V2BundleRequest$outboundSchema.parse(value),
|
|
98
|
+
"Input validation failed",
|
|
99
|
+
);
|
|
100
|
+
if (!parsed.ok) {
|
|
101
|
+
return [parsed, { status: "invalid" }];
|
|
102
|
+
}
|
|
103
|
+
const payload = parsed.value;
|
|
104
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
105
|
+
|
|
106
|
+
const path = pathToFunc("/v2/earn/bundle")();
|
|
107
|
+
|
|
108
|
+
const headers = new Headers(compactMap({
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Accept: "application/json",
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
114
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
115
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
116
|
+
|
|
117
|
+
const context = {
|
|
118
|
+
options: client._options,
|
|
119
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
120
|
+
operationID: "v2_earn_bundle",
|
|
121
|
+
oAuth2Scopes: null,
|
|
122
|
+
|
|
123
|
+
resolvedSecurity: requestSecurity,
|
|
124
|
+
|
|
125
|
+
securitySource: client._options.apiKeyAuth,
|
|
126
|
+
retryConfig: options?.retries
|
|
127
|
+
|| client._options.retryConfig
|
|
128
|
+
|| { strategy: "none" },
|
|
129
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const requestRes = client._createRequest(context, {
|
|
133
|
+
security: requestSecurity,
|
|
134
|
+
method: "POST",
|
|
135
|
+
baseURL: options?.serverURL,
|
|
136
|
+
path: path,
|
|
137
|
+
headers: headers,
|
|
138
|
+
body: body,
|
|
139
|
+
userAgent: client._options.userAgent,
|
|
140
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
141
|
+
}, options);
|
|
142
|
+
if (!requestRes.ok) {
|
|
143
|
+
return [requestRes, { status: "invalid" }];
|
|
144
|
+
}
|
|
145
|
+
const req = requestRes.value;
|
|
146
|
+
|
|
147
|
+
const doResult = await client._do(req, {
|
|
148
|
+
context,
|
|
149
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
150
|
+
retryConfig: context.retryConfig,
|
|
151
|
+
retryCodes: context.retryCodes,
|
|
152
|
+
});
|
|
153
|
+
if (!doResult.ok) {
|
|
154
|
+
return [doResult, { status: "request-error", request: req }];
|
|
155
|
+
}
|
|
156
|
+
const response = doResult.value;
|
|
157
|
+
|
|
158
|
+
const responseFields = {
|
|
159
|
+
HttpMeta: { Response: response, Request: req },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const [result] = await M.match<
|
|
163
|
+
components.V2BundleResponse,
|
|
164
|
+
| errors.HTTPValidationError
|
|
165
|
+
| CompassAPISDKError
|
|
166
|
+
| ResponseValidationError
|
|
167
|
+
| ConnectionError
|
|
168
|
+
| RequestAbortedError
|
|
169
|
+
| RequestTimeoutError
|
|
170
|
+
| InvalidRequestError
|
|
171
|
+
| UnexpectedClientError
|
|
172
|
+
| SDKValidationError
|
|
173
|
+
>(
|
|
174
|
+
M.json(200, components.V2BundleResponse$inboundSchema),
|
|
175
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
176
|
+
M.fail("4XX"),
|
|
177
|
+
M.fail("5XX"),
|
|
178
|
+
)(response, req, { extraFields: responseFields });
|
|
179
|
+
if (!result.ok) {
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
184
|
+
}
|