@compass-labs/api-sdk 2.2.114 → 2.2.115

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.
Files changed (46) hide show
  1. package/dist/commonjs/models/components/index.d.ts +1 -0
  2. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  3. package/dist/commonjs/models/components/index.js +1 -0
  4. package/dist/commonjs/models/components/index.js.map +1 -1
  5. package/dist/commonjs/models/components/loopedposition.d.ts +5 -0
  6. package/dist/commonjs/models/components/loopedposition.d.ts.map +1 -1
  7. package/dist/commonjs/models/components/loopedposition.js +2 -0
  8. package/dist/commonjs/models/components/loopedposition.js.map +1 -1
  9. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts +16 -1
  10. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts.map +1 -1
  11. package/dist/commonjs/models/components/loopedpositionhistoryentry.js +12 -1
  12. package/dist/commonjs/models/components/loopedpositionhistoryentry.js.map +1 -1
  13. package/dist/commonjs/models/components/loopedpositionpnl.d.ts +36 -0
  14. package/dist/commonjs/models/components/loopedpositionpnl.d.ts.map +1 -0
  15. package/dist/commonjs/models/components/loopedpositionpnl.js +59 -0
  16. package/dist/commonjs/models/components/loopedpositionpnl.js.map +1 -0
  17. package/dist/commonjs/models/components/swapinfo.d.ts +8 -8
  18. package/dist/esm/models/components/index.d.ts +1 -0
  19. package/dist/esm/models/components/index.d.ts.map +1 -1
  20. package/dist/esm/models/components/index.js +1 -0
  21. package/dist/esm/models/components/index.js.map +1 -1
  22. package/dist/esm/models/components/loopedposition.d.ts +5 -0
  23. package/dist/esm/models/components/loopedposition.d.ts.map +1 -1
  24. package/dist/esm/models/components/loopedposition.js +2 -0
  25. package/dist/esm/models/components/loopedposition.js.map +1 -1
  26. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts +16 -1
  27. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts.map +1 -1
  28. package/dist/esm/models/components/loopedpositionhistoryentry.js +11 -0
  29. package/dist/esm/models/components/loopedpositionhistoryentry.js.map +1 -1
  30. package/dist/esm/models/components/loopedpositionpnl.d.ts +36 -0
  31. package/dist/esm/models/components/loopedpositionpnl.d.ts.map +1 -0
  32. package/dist/esm/models/components/loopedpositionpnl.js +22 -0
  33. package/dist/esm/models/components/loopedpositionpnl.js.map +1 -0
  34. package/dist/esm/models/components/swapinfo.d.ts +8 -8
  35. package/docs/models/components/flowbasis.md +15 -0
  36. package/docs/models/components/loopedposition.md +1 -0
  37. package/docs/models/components/loopedpositionhistoryentry.md +13 -11
  38. package/docs/models/components/loopedpositionpnl.md +27 -0
  39. package/docs/models/components/swapinfo.md +8 -8
  40. package/openapi_prepped_for_speakeasy.json +90 -4
  41. package/package.json +1 -1
  42. package/src/models/components/index.ts +1 -0
  43. package/src/models/components/loopedposition.ts +9 -0
  44. package/src/models/components/loopedpositionhistoryentry.ts +23 -1
  45. package/src/models/components/loopedpositionpnl.ts +66 -0
  46. package/src/models/components/swapinfo.ts +8 -8
@@ -17166,6 +17166,17 @@
17166
17166
  "$ref": "#/components/schemas/LoopedPositionTotals",
17167
17167
  "description": "Lifetime totals across the position's history."
17168
17168
  },
17169
+ "pnl": {
17170
+ "anyOf": [
17171
+ {
17172
+ "$ref": "#/components/schemas/LoopedPositionPnl"
17173
+ },
17174
+ {
17175
+ "type": "null"
17176
+ }
17177
+ ],
17178
+ "description": "Profit or loss since the position opened, for OPEN and CLOSED positions alike. Null when it cannot be stated honestly: the position's recorded history is incomplete (it starts after the opening, or does not add up to what the position holds now), a transaction could not be priced, the position's current value could not be read or separated from another position's, or a transaction's legs cannot be told apart from another position's."
17179
+ },
17169
17180
  "history": {
17170
17181
  "items": {
17171
17182
  "$ref": "#/components/schemas/LoopedPositionHistoryEntry"
@@ -17446,7 +17457,7 @@
17446
17457
  "type": "null"
17447
17458
  }
17448
17459
  ],
17449
- "description": "The swap leg detected in this transaction, if any."
17460
+ "description": "The swap leg of a loop (debt sold for collateral) or an unwind (collateral sold for debt), when the transaction shows one."
17450
17461
  },
17451
17462
  "events": {
17452
17463
  "items": {
@@ -17456,6 +17467,34 @@
17456
17467
  "title": "Events",
17457
17468
  "description": "The raw lending events that make up this transaction (Morpho supply_collateral maps to 'supply', withdraw_collateral to 'withdraw').",
17458
17469
  "example": []
17470
+ },
17471
+ "equity_flow_quote": {
17472
+ "anyOf": [
17473
+ {
17474
+ "type": "string"
17475
+ },
17476
+ {
17477
+ "type": "null"
17478
+ }
17479
+ ],
17480
+ "title": "Equity Flow Quote",
17481
+ "description": "Equity this transaction put into the position (positive) or took out of it (negative), in the debt token, valued when it landed. 0 for a liquidation, whose loss stays in the position's equity. Null when the transaction could not be valued."
17482
+ },
17483
+ "flow_basis": {
17484
+ "anyOf": [
17485
+ {
17486
+ "type": "string",
17487
+ "enum": [
17488
+ "swap",
17489
+ "oracle"
17490
+ ]
17491
+ },
17492
+ {
17493
+ "type": "null"
17494
+ }
17495
+ ],
17496
+ "title": "Flow Basis",
17497
+ "description": "How equity_flow_quote was measured. 'swap': from this transaction's own swap, so the swap's cost shows up in PnL. 'oracle': from the net amounts at the market price; on a loop or unwind that folds the swap's cost into the flow instead. Null for a liquidation and for a transaction that could not be valued."
17459
17498
  }
17460
17499
  },
17461
17500
  "additionalProperties": false,
@@ -17471,6 +17510,53 @@
17471
17510
  "title": "LoopedPositionHistoryEntry",
17472
17511
  "description": "One transaction in a looped position's lifetime."
17473
17512
  },
17513
+ "LoopedPositionPnl": {
17514
+ "properties": {
17515
+ "total_pnl_quote": {
17516
+ "anyOf": [
17517
+ {
17518
+ "type": "string"
17519
+ },
17520
+ {
17521
+ "type": "null"
17522
+ }
17523
+ ],
17524
+ "title": "Total Pnl Quote",
17525
+ "description": "Profit or loss since the position opened, in the position's debt token: what the position is worth now, plus everything taken out, minus everything put in, each valued when it happened. It includes the entry and exit swap costs, the carry (what the collateral earned minus the interest paid) and the collateral's price move against the debt token. Realized once the position is closed, unrealized while it is open. Where a loop or unwind's own swap could not be used (its history entry has flow_basis 'oracle'), that swap's cost is not counted and the figure reads higher by roughly that amount.\n\nMeasured in the debt token, not USD: on a correlated loop (wstHYPE against WHYPE, wstETH against WETH) a positive figure here can still be a USD loss when the debt token itself falls. total_pnl_usd carries that."
17526
+ },
17527
+ "total_pnl_percent": {
17528
+ "anyOf": [
17529
+ {
17530
+ "type": "string"
17531
+ },
17532
+ {
17533
+ "type": "null"
17534
+ }
17535
+ ],
17536
+ "title": "Total Pnl Percent",
17537
+ "description": "total_pnl_quote as a percentage of the equity put in (e.g. 4.2 = 4.2%): the return on the capital contributed, not annualized."
17538
+ },
17539
+ "total_pnl_usd": {
17540
+ "anyOf": [
17541
+ {
17542
+ "type": "string"
17543
+ },
17544
+ {
17545
+ "type": "null"
17546
+ }
17547
+ ],
17548
+ "title": "Total Pnl Usd",
17549
+ "description": "Profit or loss since the position opened, in USD: each flow at the debt token's USD price when it happened, the position's current value at its price now. Unlike total_pnl_quote it includes the debt token's own USD move. Null when any of those prices is unavailable."
17550
+ }
17551
+ },
17552
+ "additionalProperties": false,
17553
+ "type": "object",
17554
+ "required": [
17555
+ "total_pnl_quote"
17556
+ ],
17557
+ "title": "LoopedPositionPnl",
17558
+ "description": "What a looped position has made or lost since it opened.\n\nMeasured in the position's debt token (the quote), with USD alongside.\nEvery transaction is an equity flow valued when it landed: a loop's\nprincipal goes in, an unwind's proceeds come out. PnL is what the position\nis worth now plus everything taken out, minus everything put in; each\nhistory entry carries its own flow in equity_flow_quote."
17559
+ },
17474
17560
  "LoopedPositionTotals": {
17475
17561
  "properties": {
17476
17562
  "total_collateral_added": {
@@ -25157,7 +25243,7 @@
25157
25243
  "sold_token": {
25158
25244
  "type": "string",
25159
25245
  "title": "Sold Token",
25160
- "description": "Token sold in the swap (the borrowed/debt token)."
25246
+ "description": "The token leaving the account: the debt token on a loop, the collateral token on an unwind."
25161
25247
  },
25162
25248
  "sold_symbol": {
25163
25249
  "type": "string",
@@ -25172,7 +25258,7 @@
25172
25258
  "bought_token": {
25173
25259
  "type": "string",
25174
25260
  "title": "Bought Token",
25175
- "description": "Token bought in the swap (the collateral token)."
25261
+ "description": "The token arriving in the account: the collateral token on a loop, the debt token on an unwind."
25176
25262
  },
25177
25263
  "bought_symbol": {
25178
25264
  "type": "string",
@@ -25208,7 +25294,7 @@
25208
25294
  "bought_amount"
25209
25295
  ],
25210
25296
  "title": "SwapInfo",
25211
- "description": "The DEX swap leg detected inside a loop transaction.\n\nEvidence is token-filtered and executor-proof: the sold (debt) token left the\naccount to a non-protocol counterparty and the bought (collateral) token\narrived from a non-protocol counterparty. Aggregator fills often settle from an\nexecutor contract, so the router is recorded only when it happens to be the\noutbound counterparty \u2014 it is never required for detection."
25297
+ "description": "The swap leg detected inside a loop or unwind transaction.\n\nEvidence is token-filtered and executor-proof: the sold token left the\naccount to a non-protocol counterparty and the bought token arrived from a\nnon-protocol counterparty. Aggregator fills often settle from an executor\ncontract, so the router is recorded only when it happens to be the outbound\ncounterparty \u2014 it is never required for detection."
25212
25298
  },
25213
25299
  "SyPosition": {
25214
25300
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compass-labs/api-sdk",
3
- "version": "2.2.114",
3
+ "version": "2.2.115",
4
4
  "author": "royalnine",
5
5
  "type": "module",
6
6
  "tshy": {
@@ -168,6 +168,7 @@ export * from "./listaavemarketsresponse.js";
168
168
  export * from "./loopedposition.js";
169
169
  export * from "./loopedpositioncurrentstate.js";
170
170
  export * from "./loopedpositionhistoryentry.js";
171
+ export * from "./loopedpositionpnl.js";
171
172
  export * from "./loopedpositiontotals.js";
172
173
  export * from "./looplegpreview.js";
173
174
  export * from "./lpbalance.js";
@@ -20,6 +20,10 @@ import {
20
20
  LoopedPositionHistoryEntry,
21
21
  LoopedPositionHistoryEntry$inboundSchema,
22
22
  } from "./loopedpositionhistoryentry.js";
23
+ import {
24
+ LoopedPositionPnl,
25
+ LoopedPositionPnl$inboundSchema,
26
+ } from "./loopedpositionpnl.js";
23
27
  import {
24
28
  LoopedPositionTotals,
25
29
  LoopedPositionTotals$inboundSchema,
@@ -114,6 +118,10 @@ export type LoopedPosition = {
114
118
  * Lifetime totals across all of a looped position's transactions.
115
119
  */
116
120
  totals: LoopedPositionTotals;
121
+ /**
122
+ * Profit or loss since the position opened, for OPEN and CLOSED positions alike. Null when it cannot be stated honestly: the position's recorded history is incomplete (it starts after the opening, or does not add up to what the position holds now), a transaction could not be priced, the position's current value could not be read or separated from another position's, or a transaction's legs cannot be told apart from another position's.
123
+ */
124
+ pnl?: LoopedPositionPnl | null | undefined;
117
125
  /**
118
126
  * All transactions for this position, chronological.
119
127
  */
@@ -147,6 +155,7 @@ export const LoopedPosition$inboundSchema: z.ZodType<
147
155
  ).optional(),
148
156
  current: z.nullable(LoopedPositionCurrentState$inboundSchema).optional(),
149
157
  totals: LoopedPositionTotals$inboundSchema,
158
+ pnl: z.nullable(LoopedPositionPnl$inboundSchema).optional(),
150
159
  history: z.array(LoopedPositionHistoryEntry$inboundSchema).optional(),
151
160
  }).transform((v) => {
152
161
  return remap$(v, {
@@ -30,6 +30,12 @@ export const Classification = {
30
30
  */
31
31
  export type Classification = ClosedEnum<typeof Classification>;
32
32
 
33
+ export const FlowBasis = {
34
+ Swap: "swap",
35
+ Oracle: "oracle",
36
+ } as const;
37
+ export type FlowBasis = ClosedEnum<typeof FlowBasis>;
38
+
33
39
  /**
34
40
  * One transaction in a looped position's lifetime.
35
41
  */
@@ -63,13 +69,21 @@ export type LoopedPositionHistoryEntry = {
63
69
  */
64
70
  debtDelta: string;
65
71
  /**
66
- * The swap leg detected in this transaction, if any.
72
+ * The swap leg of a loop (debt sold for collateral) or an unwind (collateral sold for debt), when the transaction shows one.
67
73
  */
68
74
  swap?: SwapInfo | null | undefined;
69
75
  /**
70
76
  * The raw lending events that make up this transaction (Morpho supply_collateral maps to 'supply', withdraw_collateral to 'withdraw').
71
77
  */
72
78
  events?: Array<CreditEvent> | undefined;
79
+ /**
80
+ * Equity this transaction put into the position (positive) or took out of it (negative), in the debt token, valued when it landed. 0 for a liquidation, whose loss stays in the position's equity. Null when the transaction could not be valued.
81
+ */
82
+ equityFlowQuote?: string | null | undefined;
83
+ /**
84
+ * How equity_flow_quote was measured. 'swap': from this transaction's own swap, so the swap's cost shows up in PnL. 'oracle': from the net amounts at the market price; on a loop or unwind that folds the swap's cost into the flow instead. Null for a liquidation and for a transaction that could not be valued.
85
+ */
86
+ flowBasis?: FlowBasis | null | undefined;
73
87
  };
74
88
 
75
89
  /** @internal */
@@ -77,6 +91,10 @@ export const Classification$inboundSchema: z.ZodNativeEnum<
77
91
  typeof Classification
78
92
  > = z.nativeEnum(Classification);
79
93
 
94
+ /** @internal */
95
+ export const FlowBasis$inboundSchema: z.ZodNativeEnum<typeof FlowBasis> = z
96
+ .nativeEnum(FlowBasis);
97
+
80
98
  /** @internal */
81
99
  export const LoopedPositionHistoryEntry$inboundSchema: z.ZodType<
82
100
  LoopedPositionHistoryEntry,
@@ -94,6 +112,8 @@ export const LoopedPositionHistoryEntry$inboundSchema: z.ZodType<
94
112
  debt_delta: z.string(),
95
113
  swap: z.nullable(SwapInfo$inboundSchema).optional(),
96
114
  events: z.array(CreditEvent$inboundSchema).optional(),
115
+ equity_flow_quote: z.nullable(z.string()).optional(),
116
+ flow_basis: z.nullable(FlowBasis$inboundSchema).optional(),
97
117
  }).transform((v) => {
98
118
  return remap$(v, {
99
119
  "transaction_hash": "transactionHash",
@@ -101,6 +121,8 @@ export const LoopedPositionHistoryEntry$inboundSchema: z.ZodType<
101
121
  "block_timestamp": "blockTimestamp",
102
122
  "collateral_delta": "collateralDelta",
103
123
  "debt_delta": "debtDelta",
124
+ "equity_flow_quote": "equityFlowQuote",
125
+ "flow_basis": "flowBasis",
104
126
  });
105
127
  });
106
128
 
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ /**
12
+ * What a looped position has made or lost since it opened.
13
+ *
14
+ * @remarks
15
+ *
16
+ * Measured in the position's debt token (the quote), with USD alongside.
17
+ * Every transaction is an equity flow valued when it landed: a loop's
18
+ * principal goes in, an unwind's proceeds come out. PnL is what the position
19
+ * is worth now plus everything taken out, minus everything put in; each
20
+ * history entry carries its own flow in equity_flow_quote.
21
+ */
22
+ export type LoopedPositionPnl = {
23
+ /**
24
+ * Profit or loss since the position opened, in the position's debt token: what the position is worth now, plus everything taken out, minus everything put in, each valued when it happened. It includes the entry and exit swap costs, the carry (what the collateral earned minus the interest paid) and the collateral's price move against the debt token. Realized once the position is closed, unrealized while it is open. Where a loop or unwind's own swap could not be used (its history entry has flow_basis 'oracle'), that swap's cost is not counted and the figure reads higher by roughly that amount.
25
+ *
26
+ * @remarks
27
+ *
28
+ * Measured in the debt token, not USD: on a correlated loop (wstHYPE against WHYPE, wstETH against WETH) a positive figure here can still be a USD loss when the debt token itself falls. total_pnl_usd carries that.
29
+ */
30
+ totalPnlQuote: string | null;
31
+ /**
32
+ * total_pnl_quote as a percentage of the equity put in (e.g. 4.2 = 4.2%): the return on the capital contributed, not annualized.
33
+ */
34
+ totalPnlPercent?: string | null | undefined;
35
+ /**
36
+ * Profit or loss since the position opened, in USD: each flow at the debt token's USD price when it happened, the position's current value at its price now. Unlike total_pnl_quote it includes the debt token's own USD move. Null when any of those prices is unavailable.
37
+ */
38
+ totalPnlUsd?: string | null | undefined;
39
+ };
40
+
41
+ /** @internal */
42
+ export const LoopedPositionPnl$inboundSchema: z.ZodType<
43
+ LoopedPositionPnl,
44
+ z.ZodTypeDef,
45
+ unknown
46
+ > = z.object({
47
+ total_pnl_quote: z.nullable(z.string()),
48
+ total_pnl_percent: z.nullable(z.string()).optional(),
49
+ total_pnl_usd: z.nullable(z.string()).optional(),
50
+ }).transform((v) => {
51
+ return remap$(v, {
52
+ "total_pnl_quote": "totalPnlQuote",
53
+ "total_pnl_percent": "totalPnlPercent",
54
+ "total_pnl_usd": "totalPnlUsd",
55
+ });
56
+ });
57
+
58
+ export function loopedPositionPnlFromJSON(
59
+ jsonString: string,
60
+ ): SafeParseResult<LoopedPositionPnl, SDKValidationError> {
61
+ return safeParse(
62
+ jsonString,
63
+ (x) => LoopedPositionPnl$inboundSchema.parse(JSON.parse(x)),
64
+ `Failed to parse 'LoopedPositionPnl' from JSON`,
65
+ );
66
+ }
@@ -9,19 +9,19 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
10
 
11
11
  /**
12
- * The DEX swap leg detected inside a loop transaction.
12
+ * The swap leg detected inside a loop or unwind transaction.
13
13
  *
14
14
  * @remarks
15
15
  *
16
- * Evidence is token-filtered and executor-proof: the sold (debt) token left the
17
- * account to a non-protocol counterparty and the bought (collateral) token
18
- * arrived from a non-protocol counterparty. Aggregator fills often settle from an
19
- * executor contract, so the router is recorded only when it happens to be the
20
- * outbound counterparty — it is never required for detection.
16
+ * Evidence is token-filtered and executor-proof: the sold token left the
17
+ * account to a non-protocol counterparty and the bought token arrived from a
18
+ * non-protocol counterparty. Aggregator fills often settle from an executor
19
+ * contract, so the router is recorded only when it happens to be the outbound
20
+ * counterparty — it is never required for detection.
21
21
  */
22
22
  export type SwapInfo = {
23
23
  /**
24
- * Token sold in the swap (the borrowed/debt token).
24
+ * The token leaving the account: the debt token on a loop, the collateral token on an unwind.
25
25
  */
26
26
  soldToken: string;
27
27
  /**
@@ -33,7 +33,7 @@ export type SwapInfo = {
33
33
  */
34
34
  soldAmount: string;
35
35
  /**
36
- * Token bought in the swap (the collateral token).
36
+ * The token arriving in the account: the collateral token on a loop, the debt token on an unwind.
37
37
  */
38
38
  boughtToken: string;
39
39
  /**