@compass-labs/api-sdk 2.1.35 → 2.1.36-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/dist/commonjs/models/components/aaveposition.d.ts +27 -7
- package/dist/commonjs/models/components/aaveposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/aaveposition.js +9 -8
- package/dist/commonjs/models/components/aaveposition.js.map +1 -1
- package/dist/commonjs/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.d.ts +20 -7
- package/dist/commonjs/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.js +7 -4
- package/dist/commonjs/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.js.map +1 -1
- package/dist/commonjs/models/components/depositevent.d.ts +17 -14
- package/dist/commonjs/models/components/depositevent.d.ts.map +1 -1
- package/dist/commonjs/models/components/depositevent.js +8 -10
- package/dist/commonjs/models/components/depositevent.js.map +1 -1
- package/dist/commonjs/models/components/earnpositionsresponse.d.ts +18 -6
- package/dist/commonjs/models/components/earnpositionsresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnpositionsresponse.js +5 -17
- package/dist/commonjs/models/components/earnpositionsresponse.js.map +1 -1
- package/dist/commonjs/models/components/pendleptposition.d.ts +16 -10
- package/dist/commonjs/models/components/pendleptposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/pendleptposition.js +6 -4
- package/dist/commonjs/models/components/pendleptposition.js.map +1 -1
- package/dist/commonjs/models/components/positionpnl.d.ts +12 -21
- package/dist/commonjs/models/components/positionpnl.d.ts.map +1 -1
- package/dist/commonjs/models/components/positionpnl.js +6 -12
- package/dist/commonjs/models/components/positionpnl.js.map +1 -1
- package/dist/commonjs/models/components/withdrawalevent.d.ts +17 -10
- package/dist/commonjs/models/components/withdrawalevent.d.ts.map +1 -1
- package/dist/commonjs/models/components/withdrawalevent.js +8 -8
- package/dist/commonjs/models/components/withdrawalevent.js.map +1 -1
- package/dist/esm/models/components/aaveposition.d.ts +27 -7
- package/dist/esm/models/components/aaveposition.d.ts.map +1 -1
- package/dist/esm/models/components/aaveposition.js +9 -8
- package/dist/esm/models/components/aaveposition.js.map +1 -1
- package/dist/esm/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.d.ts +20 -7
- package/dist/esm/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.d.ts.map +1 -1
- package/dist/esm/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.js +7 -4
- package/dist/esm/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.js.map +1 -1
- package/dist/esm/models/components/depositevent.d.ts +17 -14
- package/dist/esm/models/components/depositevent.d.ts.map +1 -1
- package/dist/esm/models/components/depositevent.js +8 -10
- package/dist/esm/models/components/depositevent.js.map +1 -1
- package/dist/esm/models/components/earnpositionsresponse.d.ts +18 -6
- package/dist/esm/models/components/earnpositionsresponse.d.ts.map +1 -1
- package/dist/esm/models/components/earnpositionsresponse.js +4 -15
- package/dist/esm/models/components/earnpositionsresponse.js.map +1 -1
- package/dist/esm/models/components/pendleptposition.d.ts +16 -10
- package/dist/esm/models/components/pendleptposition.d.ts.map +1 -1
- package/dist/esm/models/components/pendleptposition.js +6 -4
- package/dist/esm/models/components/pendleptposition.js.map +1 -1
- package/dist/esm/models/components/positionpnl.d.ts +12 -21
- package/dist/esm/models/components/positionpnl.d.ts.map +1 -1
- package/dist/esm/models/components/positionpnl.js +6 -12
- package/dist/esm/models/components/positionpnl.js.map +1 -1
- package/dist/esm/models/components/withdrawalevent.d.ts +17 -10
- package/dist/esm/models/components/withdrawalevent.d.ts.map +1 -1
- package/dist/esm/models/components/withdrawalevent.js +8 -8
- package/dist/esm/models/components/withdrawalevent.js.map +1 -1
- package/docs/models/components/aaveposition.md +19 -10
- package/docs/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.md +16 -10
- package/docs/models/components/depositevent.md +18 -12
- package/docs/models/components/earnpositionsresponse.md +13 -4
- package/docs/models/components/pendleptposition.md +16 -14
- package/docs/models/components/positionpnl.md +15 -16
- package/docs/models/components/withdrawalevent.md +18 -13
- package/package.json +1 -1
- package/src/models/components/aaveposition.ts +37 -15
- package/src/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.ts +28 -11
- package/src/models/components/depositevent.ts +25 -24
- package/src/models/components/earnpositionsresponse.ts +26 -40
- package/src/models/components/pendleptposition.ts +23 -14
- package/src/models/components/positionpnl.ts +18 -34
- package/src/models/components/withdrawalevent.ts +25 -18
- package/docs/models/components/userposition.md +0 -42
|
@@ -7,27 +7,50 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import { DepositEvent, DepositEvent$inboundSchema } from "./depositevent.js";
|
|
10
11
|
import { PositionPnL, PositionPnL$inboundSchema } from "./positionpnl.js";
|
|
12
|
+
import {
|
|
13
|
+
WithdrawalEvent,
|
|
14
|
+
WithdrawalEvent$inboundSchema,
|
|
15
|
+
} from "./withdrawalevent.js";
|
|
11
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Aave V3 lending position.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* Note: Unlike the old model, this no longer has vault_address/vault_name fields
|
|
23
|
+
* as they were nonsensical for Aave positions.
|
|
24
|
+
*/
|
|
12
25
|
export type AavePosition = {
|
|
13
26
|
/**
|
|
14
27
|
* The market type discriminator.
|
|
15
28
|
*/
|
|
16
29
|
type: "AAVE";
|
|
17
|
-
vaultAddress?: "None" | undefined;
|
|
18
30
|
/**
|
|
19
|
-
* The
|
|
31
|
+
* The reserve (underlying token) address.
|
|
32
|
+
*/
|
|
33
|
+
reserveAddress: string;
|
|
34
|
+
/**
|
|
35
|
+
* Symbol of the reserve asset (e.g., USDC).
|
|
20
36
|
*/
|
|
21
|
-
|
|
37
|
+
reserveSymbol: string;
|
|
22
38
|
/**
|
|
23
|
-
*
|
|
39
|
+
* The user's position value (aToken balance).
|
|
24
40
|
*/
|
|
25
|
-
|
|
26
|
-
vaultName?: "None" | undefined;
|
|
41
|
+
balance: string;
|
|
27
42
|
/**
|
|
28
|
-
* PnL
|
|
43
|
+
* PnL metrics for this position.
|
|
29
44
|
*/
|
|
30
45
|
pnl?: PositionPnL | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* All deposit events for this position.
|
|
48
|
+
*/
|
|
49
|
+
deposits?: Array<DepositEvent> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* All withdrawal events for this position.
|
|
52
|
+
*/
|
|
53
|
+
withdrawals?: Array<WithdrawalEvent> | undefined;
|
|
31
54
|
};
|
|
32
55
|
|
|
33
56
|
/** @internal */
|
|
@@ -37,17 +60,16 @@ export const AavePosition$inboundSchema: z.ZodType<
|
|
|
37
60
|
unknown
|
|
38
61
|
> = z.object({
|
|
39
62
|
type: z.literal("AAVE"),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
vault_name: z.literal("None").optional(),
|
|
63
|
+
reserve_address: z.string(),
|
|
64
|
+
reserve_symbol: z.string(),
|
|
65
|
+
balance: z.string(),
|
|
44
66
|
pnl: z.nullable(PositionPnL$inboundSchema).optional(),
|
|
67
|
+
deposits: z.array(DepositEvent$inboundSchema).optional(),
|
|
68
|
+
withdrawals: z.array(WithdrawalEvent$inboundSchema).optional(),
|
|
45
69
|
}).transform((v) => {
|
|
46
70
|
return remap$(v, {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"token_name": "tokenName",
|
|
50
|
-
"vault_name": "vaultName",
|
|
71
|
+
"reserve_address": "reserveAddress",
|
|
72
|
+
"reserve_symbol": "reserveSymbol",
|
|
51
73
|
});
|
|
52
74
|
});
|
|
53
75
|
|
package/src/models/components/compassapibackendv2modelsearnreadresponsepositionsvaultposition.ts
CHANGED
|
@@ -7,33 +7,49 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import { DepositEvent, DepositEvent$inboundSchema } from "./depositevent.js";
|
|
10
11
|
import { PositionPnL, PositionPnL$inboundSchema } from "./positionpnl.js";
|
|
12
|
+
import {
|
|
13
|
+
WithdrawalEvent,
|
|
14
|
+
WithdrawalEvent$inboundSchema,
|
|
15
|
+
} from "./withdrawalevent.js";
|
|
11
16
|
|
|
17
|
+
/**
|
|
18
|
+
* ERC-4626 vault position.
|
|
19
|
+
*/
|
|
12
20
|
export type CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition = {
|
|
13
21
|
/**
|
|
14
22
|
* The market type discriminator.
|
|
15
23
|
*/
|
|
16
24
|
type: "VAULT";
|
|
17
25
|
/**
|
|
18
|
-
* The vault address
|
|
26
|
+
* The vault address.
|
|
19
27
|
*/
|
|
20
28
|
vaultAddress: string;
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Name of the vault token (share token).
|
|
23
31
|
*/
|
|
24
|
-
|
|
32
|
+
vaultName: string;
|
|
25
33
|
/**
|
|
26
34
|
* Symbol of the underlying token (e.g., USDC).
|
|
27
35
|
*/
|
|
28
|
-
|
|
36
|
+
underlyingSymbol: string;
|
|
29
37
|
/**
|
|
30
|
-
*
|
|
38
|
+
* The user's position value in underlying token.
|
|
31
39
|
*/
|
|
32
|
-
|
|
40
|
+
balance: string;
|
|
33
41
|
/**
|
|
34
|
-
* PnL
|
|
42
|
+
* PnL metrics for this position.
|
|
35
43
|
*/
|
|
36
44
|
pnl?: PositionPnL | null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* All deposit events for this position.
|
|
47
|
+
*/
|
|
48
|
+
deposits?: Array<DepositEvent> | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* All withdrawal events for this position.
|
|
51
|
+
*/
|
|
52
|
+
withdrawals?: Array<WithdrawalEvent> | undefined;
|
|
37
53
|
};
|
|
38
54
|
|
|
39
55
|
/** @internal */
|
|
@@ -45,16 +61,17 @@ export const CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inb
|
|
|
45
61
|
> = z.object({
|
|
46
62
|
type: z.literal("VAULT"),
|
|
47
63
|
vault_address: z.string(),
|
|
48
|
-
amount_in_underlying_token: z.string(),
|
|
49
|
-
token_name: z.string(),
|
|
50
64
|
vault_name: z.string(),
|
|
65
|
+
underlying_symbol: z.string(),
|
|
66
|
+
balance: z.string(),
|
|
51
67
|
pnl: z.nullable(PositionPnL$inboundSchema).optional(),
|
|
68
|
+
deposits: z.array(DepositEvent$inboundSchema).optional(),
|
|
69
|
+
withdrawals: z.array(WithdrawalEvent$inboundSchema).optional(),
|
|
52
70
|
}).transform((v) => {
|
|
53
71
|
return remap$(v, {
|
|
54
72
|
"vault_address": "vaultAddress",
|
|
55
|
-
"amount_in_underlying_token": "amountInUnderlyingToken",
|
|
56
|
-
"token_name": "tokenName",
|
|
57
73
|
"vault_name": "vaultName",
|
|
74
|
+
"underlying_symbol": "underlyingSymbol",
|
|
58
75
|
});
|
|
59
76
|
});
|
|
60
77
|
|
|
@@ -10,6 +10,13 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Historical deposit event for position transparency.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
16
|
+
* Uses generic input/output format that works across all protocols:
|
|
17
|
+
* - Vault: input=underlying, output=shares
|
|
18
|
+
* - Aave: input=underlying, output=aTokens
|
|
19
|
+
* - Pendle: input=token (varies), output=PT
|
|
13
20
|
*/
|
|
14
21
|
export type DepositEvent = {
|
|
15
22
|
/**
|
|
@@ -21,29 +28,25 @@ export type DepositEvent = {
|
|
|
21
28
|
*/
|
|
22
29
|
transactionHash: string;
|
|
23
30
|
/**
|
|
24
|
-
* Amount
|
|
31
|
+
* Amount deposited (underlying asset or swap token)
|
|
25
32
|
*/
|
|
26
|
-
|
|
33
|
+
inputAmount: string;
|
|
27
34
|
/**
|
|
28
|
-
*
|
|
35
|
+
* Symbol of token deposited
|
|
29
36
|
*/
|
|
30
|
-
|
|
37
|
+
inputSymbol: string;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
costPerUnit: string;
|
|
35
|
-
/**
|
|
36
|
-
* Address of token used for deposit (for Pendle swaps)
|
|
39
|
+
* Units received (shares, aTokens, or PT)
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
outputAmount: string;
|
|
39
42
|
/**
|
|
40
|
-
* Symbol of
|
|
43
|
+
* Symbol of units received
|
|
41
44
|
*/
|
|
42
|
-
|
|
45
|
+
outputSymbol: string;
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
47
|
+
* Cost basis per unit at time of deposit
|
|
45
48
|
*/
|
|
46
|
-
|
|
49
|
+
costPerUnit: string;
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
/** @internal */
|
|
@@ -54,22 +57,20 @@ export const DepositEvent$inboundSchema: z.ZodType<
|
|
|
54
57
|
> = z.object({
|
|
55
58
|
block_number: z.number().int(),
|
|
56
59
|
transaction_hash: z.string(),
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
input_amount: z.string(),
|
|
61
|
+
input_symbol: z.string(),
|
|
62
|
+
output_amount: z.string(),
|
|
63
|
+
output_symbol: z.string(),
|
|
59
64
|
cost_per_unit: z.string(),
|
|
60
|
-
token_address: z.nullable(z.string()).optional(),
|
|
61
|
-
token_symbol: z.nullable(z.string()).optional(),
|
|
62
|
-
token_amount: z.nullable(z.string()).optional(),
|
|
63
65
|
}).transform((v) => {
|
|
64
66
|
return remap$(v, {
|
|
65
67
|
"block_number": "blockNumber",
|
|
66
68
|
"transaction_hash": "transactionHash",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
+
"input_amount": "inputAmount",
|
|
70
|
+
"input_symbol": "inputSymbol",
|
|
71
|
+
"output_amount": "outputAmount",
|
|
72
|
+
"output_symbol": "outputSymbol",
|
|
69
73
|
"cost_per_unit": "costPerUnit",
|
|
70
|
-
"token_address": "tokenAddress",
|
|
71
|
-
"token_symbol": "tokenSymbol",
|
|
72
|
-
"token_amount": "tokenAmount",
|
|
73
74
|
});
|
|
74
75
|
});
|
|
75
76
|
|
|
@@ -17,59 +17,45 @@ import {
|
|
|
17
17
|
PendlePTPosition$inboundSchema,
|
|
18
18
|
} from "./pendleptposition.js";
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Grouped positions by protocol.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
*
|
|
25
|
+
* This new structure groups positions by protocol type for better organization and
|
|
26
|
+
* removes the need for a discriminated union in SDK consumers.
|
|
27
|
+
*/
|
|
25
28
|
export type EarnPositionsResponse = {
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
30
|
+
* Aave V3 lending positions.
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
aave?: Array<AavePosition> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* ERC-4626 vault positions.
|
|
35
|
+
*/
|
|
36
|
+
vaults?:
|
|
37
|
+
| Array<CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition>
|
|
38
|
+
| undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Pendle Principal Token positions.
|
|
41
|
+
*/
|
|
42
|
+
pendlePt?: Array<PendlePTPosition> | undefined;
|
|
34
43
|
};
|
|
35
44
|
|
|
36
|
-
/** @internal */
|
|
37
|
-
export const UserPosition$inboundSchema: z.ZodType<
|
|
38
|
-
UserPosition,
|
|
39
|
-
z.ZodTypeDef,
|
|
40
|
-
unknown
|
|
41
|
-
> = z.union([
|
|
42
|
-
AavePosition$inboundSchema,
|
|
43
|
-
PendlePTPosition$inboundSchema,
|
|
44
|
-
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema,
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
|
-
export function userPositionFromJSON(
|
|
48
|
-
jsonString: string,
|
|
49
|
-
): SafeParseResult<UserPosition, SDKValidationError> {
|
|
50
|
-
return safeParse(
|
|
51
|
-
jsonString,
|
|
52
|
-
(x) => UserPosition$inboundSchema.parse(JSON.parse(x)),
|
|
53
|
-
`Failed to parse 'UserPosition' from JSON`,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
45
|
/** @internal */
|
|
58
46
|
export const EarnPositionsResponse$inboundSchema: z.ZodType<
|
|
59
47
|
EarnPositionsResponse,
|
|
60
48
|
z.ZodTypeDef,
|
|
61
49
|
unknown
|
|
62
50
|
> = z.object({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
]),
|
|
69
|
-
),
|
|
51
|
+
aave: z.array(AavePosition$inboundSchema).optional(),
|
|
52
|
+
vaults: z.array(
|
|
53
|
+
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema,
|
|
54
|
+
).optional(),
|
|
55
|
+
pendle_pt: z.array(PendlePTPosition$inboundSchema).optional(),
|
|
70
56
|
}).transform((v) => {
|
|
71
57
|
return remap$(v, {
|
|
72
|
-
"
|
|
58
|
+
"pendle_pt": "pendlePt",
|
|
73
59
|
});
|
|
74
60
|
});
|
|
75
61
|
|
|
@@ -7,10 +7,15 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import { DepositEvent, DepositEvent$inboundSchema } from "./depositevent.js";
|
|
10
11
|
import { PositionPnL, PositionPnL$inboundSchema } from "./positionpnl.js";
|
|
12
|
+
import {
|
|
13
|
+
WithdrawalEvent,
|
|
14
|
+
WithdrawalEvent$inboundSchema,
|
|
15
|
+
} from "./withdrawalevent.js";
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
|
-
*
|
|
18
|
+
* Pendle Principal Token position.
|
|
14
19
|
*/
|
|
15
20
|
export type PendlePTPosition = {
|
|
16
21
|
/**
|
|
@@ -25,26 +30,30 @@ export type PendlePTPosition = {
|
|
|
25
30
|
* The PT (Principal Token) contract address.
|
|
26
31
|
*/
|
|
27
32
|
ptAddress: string;
|
|
28
|
-
/**
|
|
29
|
-
* The user's PT token balance.
|
|
30
|
-
*/
|
|
31
|
-
amountInPt: string;
|
|
32
|
-
/**
|
|
33
|
-
* The underlying asset address.
|
|
34
|
-
*/
|
|
35
|
-
underlyingAsset: string;
|
|
36
33
|
/**
|
|
37
34
|
* Symbol of the underlying asset (e.g., rsETH, weETH).
|
|
38
35
|
*/
|
|
39
36
|
underlyingSymbol: string;
|
|
37
|
+
/**
|
|
38
|
+
* The user's PT token balance.
|
|
39
|
+
*/
|
|
40
|
+
ptBalance: string;
|
|
40
41
|
/**
|
|
41
42
|
* Market expiry timestamp (Unix seconds).
|
|
42
43
|
*/
|
|
43
44
|
expiry: number;
|
|
44
45
|
/**
|
|
45
|
-
* PnL
|
|
46
|
+
* PnL metrics (in SY terms) for this position.
|
|
46
47
|
*/
|
|
47
48
|
pnl?: PositionPnL | null | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* All buy PT events for this position.
|
|
51
|
+
*/
|
|
52
|
+
deposits?: Array<DepositEvent> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* All sell/redeem PT events for this position.
|
|
55
|
+
*/
|
|
56
|
+
withdrawals?: Array<WithdrawalEvent> | undefined;
|
|
48
57
|
};
|
|
49
58
|
|
|
50
59
|
/** @internal */
|
|
@@ -56,18 +65,18 @@ export const PendlePTPosition$inboundSchema: z.ZodType<
|
|
|
56
65
|
type: z.literal("PENDLE_PT"),
|
|
57
66
|
market_address: z.string(),
|
|
58
67
|
pt_address: z.string(),
|
|
59
|
-
amount_in_pt: z.string(),
|
|
60
|
-
underlying_asset: z.string(),
|
|
61
68
|
underlying_symbol: z.string(),
|
|
69
|
+
pt_balance: z.string(),
|
|
62
70
|
expiry: z.number().int(),
|
|
63
71
|
pnl: z.nullable(PositionPnL$inboundSchema).optional(),
|
|
72
|
+
deposits: z.array(DepositEvent$inboundSchema).optional(),
|
|
73
|
+
withdrawals: z.array(WithdrawalEvent$inboundSchema).optional(),
|
|
64
74
|
}).transform((v) => {
|
|
65
75
|
return remap$(v, {
|
|
66
76
|
"market_address": "marketAddress",
|
|
67
77
|
"pt_address": "ptAddress",
|
|
68
|
-
"amount_in_pt": "amountInPt",
|
|
69
|
-
"underlying_asset": "underlyingAsset",
|
|
70
78
|
"underlying_symbol": "underlyingSymbol",
|
|
79
|
+
"pt_balance": "ptBalance",
|
|
71
80
|
});
|
|
72
81
|
});
|
|
73
82
|
|
|
@@ -7,14 +7,14 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
-
import { DepositEvent, DepositEvent$inboundSchema } from "./depositevent.js";
|
|
11
|
-
import {
|
|
12
|
-
WithdrawalEvent,
|
|
13
|
-
WithdrawalEvent$inboundSchema,
|
|
14
|
-
} from "./withdrawalevent.js";
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
|
-
* PnL
|
|
12
|
+
* Simplified PnL metrics for API response.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
16
|
+
* Historical events (deposits/withdrawals) are now at the position level, not inside
|
|
17
|
+
* PnL.
|
|
18
18
|
*/
|
|
19
19
|
export type PositionPnL = {
|
|
20
20
|
/**
|
|
@@ -22,15 +22,11 @@ export type PositionPnL = {
|
|
|
22
22
|
*/
|
|
23
23
|
totalDeposited: string;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Current position value in underlying
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
currentValue: string;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
costBasis: string;
|
|
32
|
-
/**
|
|
33
|
-
* current_value - cost_basis
|
|
29
|
+
* current_value - cost_basis_remaining
|
|
34
30
|
*/
|
|
35
31
|
unrealizedPnl: string;
|
|
36
32
|
/**
|
|
@@ -40,19 +36,11 @@ export type PositionPnL = {
|
|
|
40
36
|
/**
|
|
41
37
|
* unrealized_pnl + realized_pnl
|
|
42
38
|
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Sum of performance fees paid
|
|
46
|
-
*/
|
|
47
|
-
totalFeesPaid: string;
|
|
48
|
-
/**
|
|
49
|
-
* All deposit events for this position
|
|
50
|
-
*/
|
|
51
|
-
deposits?: Array<DepositEvent> | undefined;
|
|
39
|
+
totalPnl: string;
|
|
52
40
|
/**
|
|
53
|
-
*
|
|
41
|
+
* (total_pnl / total_deposited) * 100
|
|
54
42
|
*/
|
|
55
|
-
|
|
43
|
+
totalPnlPercent: string;
|
|
56
44
|
};
|
|
57
45
|
|
|
58
46
|
/** @internal */
|
|
@@ -62,23 +50,19 @@ export const PositionPnL$inboundSchema: z.ZodType<
|
|
|
62
50
|
unknown
|
|
63
51
|
> = z.object({
|
|
64
52
|
total_deposited: z.string(),
|
|
65
|
-
|
|
66
|
-
cost_basis: z.string(),
|
|
53
|
+
current_value: z.string(),
|
|
67
54
|
unrealized_pnl: z.string(),
|
|
68
55
|
realized_pnl: z.string(),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
deposits: z.array(DepositEvent$inboundSchema).optional(),
|
|
72
|
-
withdrawals: z.array(WithdrawalEvent$inboundSchema).optional(),
|
|
56
|
+
total_pnl: z.string(),
|
|
57
|
+
total_pnl_percent: z.string(),
|
|
73
58
|
}).transform((v) => {
|
|
74
59
|
return remap$(v, {
|
|
75
60
|
"total_deposited": "totalDeposited",
|
|
76
|
-
"
|
|
77
|
-
"cost_basis": "costBasis",
|
|
61
|
+
"current_value": "currentValue",
|
|
78
62
|
"unrealized_pnl": "unrealizedPnl",
|
|
79
63
|
"realized_pnl": "realizedPnl",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
64
|
+
"total_pnl": "totalPnl",
|
|
65
|
+
"total_pnl_percent": "totalPnlPercent",
|
|
82
66
|
});
|
|
83
67
|
});
|
|
84
68
|
|
|
@@ -10,6 +10,13 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Historical withdrawal event with realized PnL.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
16
|
+
* Uses generic input/output format:
|
|
17
|
+
* - Vault: input=shares, output=underlying
|
|
18
|
+
* - Aave: input=aTokens, output=underlying
|
|
19
|
+
* - Pendle: input=PT, output=token (varies)
|
|
13
20
|
*/
|
|
14
21
|
export type WithdrawalEvent = {
|
|
15
22
|
/**
|
|
@@ -21,25 +28,25 @@ export type WithdrawalEvent = {
|
|
|
21
28
|
*/
|
|
22
29
|
transactionHash: string;
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
31
|
+
* Units withdrawn (shares, aTokens, PT)
|
|
25
32
|
*/
|
|
26
|
-
|
|
33
|
+
inputAmount: string;
|
|
27
34
|
/**
|
|
28
|
-
*
|
|
35
|
+
* Symbol of units withdrawn
|
|
29
36
|
*/
|
|
30
|
-
|
|
37
|
+
inputSymbol: string;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Amount received (underlying or token)
|
|
33
40
|
*/
|
|
34
|
-
|
|
41
|
+
outputAmount: string;
|
|
35
42
|
/**
|
|
36
|
-
*
|
|
43
|
+
* Symbol of token received
|
|
37
44
|
*/
|
|
38
|
-
|
|
45
|
+
outputSymbol: string;
|
|
39
46
|
/**
|
|
40
|
-
*
|
|
47
|
+
* Profit/loss: output value - cost basis consumed
|
|
41
48
|
*/
|
|
42
|
-
|
|
49
|
+
realizedPnl: string;
|
|
43
50
|
};
|
|
44
51
|
|
|
45
52
|
/** @internal */
|
|
@@ -50,20 +57,20 @@ export const WithdrawalEvent$inboundSchema: z.ZodType<
|
|
|
50
57
|
> = z.object({
|
|
51
58
|
block_number: z.number().int(),
|
|
52
59
|
transaction_hash: z.string(),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
input_amount: z.string(),
|
|
61
|
+
input_symbol: z.string(),
|
|
62
|
+
output_amount: z.string(),
|
|
63
|
+
output_symbol: z.string(),
|
|
56
64
|
realized_pnl: z.string(),
|
|
57
|
-
fee_charged: z.string(),
|
|
58
65
|
}).transform((v) => {
|
|
59
66
|
return remap$(v, {
|
|
60
67
|
"block_number": "blockNumber",
|
|
61
68
|
"transaction_hash": "transactionHash",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
69
|
+
"input_amount": "inputAmount",
|
|
70
|
+
"input_symbol": "inputSymbol",
|
|
71
|
+
"output_amount": "outputAmount",
|
|
72
|
+
"output_symbol": "outputSymbol",
|
|
65
73
|
"realized_pnl": "realizedPnl",
|
|
66
|
-
"fee_charged": "feeCharged",
|
|
67
74
|
});
|
|
68
75
|
});
|
|
69
76
|
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# UserPosition
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
## Supported Types
|
|
5
|
-
|
|
6
|
-
### `components.AavePosition`
|
|
7
|
-
|
|
8
|
-
```typescript
|
|
9
|
-
const value: components.AavePosition = {
|
|
10
|
-
type: "AAVE",
|
|
11
|
-
amountInUnderlyingToken: "<value>",
|
|
12
|
-
tokenName: "<value>",
|
|
13
|
-
};
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### `components.PendlePTPosition`
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
const value: components.PendlePTPosition = {
|
|
20
|
-
type: "PENDLE_PT",
|
|
21
|
-
marketAddress: "<value>",
|
|
22
|
-
ptAddress: "<value>",
|
|
23
|
-
amountInPt: "<value>",
|
|
24
|
-
underlyingAsset: "<value>",
|
|
25
|
-
underlyingSymbol: "<value>",
|
|
26
|
-
expiry: 858301,
|
|
27
|
-
};
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### `components.CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition`
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
const value:
|
|
34
|
-
components.CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition = {
|
|
35
|
-
type: "VAULT",
|
|
36
|
-
vaultAddress: "<value>",
|
|
37
|
-
amountInUnderlyingToken: "<value>",
|
|
38
|
-
tokenName: "<value>",
|
|
39
|
-
vaultName: "<value>",
|
|
40
|
-
};
|
|
41
|
-
```
|
|
42
|
-
|