@compass-labs/api-sdk 2.2.77-rc.0 → 2.2.77

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 (115) hide show
  1. package/README.md +5 -3
  2. package/codeSamples_typescript.yaml +6 -0
  3. package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts +26 -0
  4. package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts.map +1 -0
  5. package/dist/commonjs/funcs/creditCreditLoopedPositions.js +131 -0
  6. package/dist/commonjs/funcs/creditCreditLoopedPositions.js.map +1 -0
  7. package/dist/commonjs/models/components/creditloopedpositionsresponse.d.ts +26 -0
  8. package/dist/commonjs/models/components/creditloopedpositionsresponse.d.ts.map +1 -0
  9. package/dist/commonjs/models/components/creditloopedpositionsresponse.js +60 -0
  10. package/dist/commonjs/models/components/creditloopedpositionsresponse.js.map +1 -0
  11. package/dist/commonjs/models/components/index.d.ts +6 -0
  12. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  13. package/dist/commonjs/models/components/index.js +6 -0
  14. package/dist/commonjs/models/components/index.js.map +1 -1
  15. package/dist/commonjs/models/components/loopedposition.d.ts +88 -0
  16. package/dist/commonjs/models/components/loopedposition.d.ts.map +1 -0
  17. package/dist/commonjs/models/components/loopedposition.js +85 -0
  18. package/dist/commonjs/models/components/loopedposition.js.map +1 -0
  19. package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts +58 -0
  20. package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts.map +1 -0
  21. package/dist/commonjs/models/components/loopedpositioncurrentstate.js +77 -0
  22. package/dist/commonjs/models/components/loopedpositioncurrentstate.js.map +1 -0
  23. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts +71 -0
  24. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts.map +1 -0
  25. package/dist/commonjs/models/components/loopedpositionhistoryentry.js +85 -0
  26. package/dist/commonjs/models/components/loopedpositionhistoryentry.js.map +1 -0
  27. package/dist/commonjs/models/components/loopedpositiontotals.d.ts +40 -0
  28. package/dist/commonjs/models/components/loopedpositiontotals.d.ts.map +1 -0
  29. package/dist/commonjs/models/components/loopedpositiontotals.js +67 -0
  30. package/dist/commonjs/models/components/loopedpositiontotals.js.map +1 -0
  31. package/dist/commonjs/models/components/swapinfo.d.ts +48 -0
  32. package/dist/commonjs/models/components/swapinfo.d.ts.map +1 -0
  33. package/dist/commonjs/models/components/swapinfo.js +66 -0
  34. package/dist/commonjs/models/components/swapinfo.js.map +1 -0
  35. package/dist/commonjs/models/operations/index.d.ts +1 -0
  36. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  37. package/dist/commonjs/models/operations/index.js +1 -0
  38. package/dist/commonjs/models/operations/index.js.map +1 -1
  39. package/dist/commonjs/models/operations/v2creditloopedpositions.d.ts +28 -0
  40. package/dist/commonjs/models/operations/v2creditloopedpositions.d.ts.map +1 -0
  41. package/dist/commonjs/models/operations/v2creditloopedpositions.js +59 -0
  42. package/dist/commonjs/models/operations/v2creditloopedpositions.js.map +1 -0
  43. package/dist/commonjs/sdk/credit.d.ts +14 -0
  44. package/dist/commonjs/sdk/credit.d.ts.map +1 -1
  45. package/dist/commonjs/sdk/credit.js +17 -0
  46. package/dist/commonjs/sdk/credit.js.map +1 -1
  47. package/dist/esm/funcs/creditCreditLoopedPositions.d.ts +26 -0
  48. package/dist/esm/funcs/creditCreditLoopedPositions.d.ts.map +1 -0
  49. package/dist/esm/funcs/creditCreditLoopedPositions.js +95 -0
  50. package/dist/esm/funcs/creditCreditLoopedPositions.js.map +1 -0
  51. package/dist/esm/models/components/creditloopedpositionsresponse.d.ts +26 -0
  52. package/dist/esm/models/components/creditloopedpositionsresponse.d.ts.map +1 -0
  53. package/dist/esm/models/components/creditloopedpositionsresponse.js +23 -0
  54. package/dist/esm/models/components/creditloopedpositionsresponse.js.map +1 -0
  55. package/dist/esm/models/components/index.d.ts +6 -0
  56. package/dist/esm/models/components/index.d.ts.map +1 -1
  57. package/dist/esm/models/components/index.js +6 -0
  58. package/dist/esm/models/components/index.js.map +1 -1
  59. package/dist/esm/models/components/loopedposition.d.ts +88 -0
  60. package/dist/esm/models/components/loopedposition.d.ts.map +1 -0
  61. package/dist/esm/models/components/loopedposition.js +48 -0
  62. package/dist/esm/models/components/loopedposition.js.map +1 -0
  63. package/dist/esm/models/components/loopedpositioncurrentstate.d.ts +58 -0
  64. package/dist/esm/models/components/loopedpositioncurrentstate.d.ts.map +1 -0
  65. package/dist/esm/models/components/loopedpositioncurrentstate.js +40 -0
  66. package/dist/esm/models/components/loopedpositioncurrentstate.js.map +1 -0
  67. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts +71 -0
  68. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts.map +1 -0
  69. package/dist/esm/models/components/loopedpositionhistoryentry.js +48 -0
  70. package/dist/esm/models/components/loopedpositionhistoryentry.js.map +1 -0
  71. package/dist/esm/models/components/loopedpositiontotals.d.ts +40 -0
  72. package/dist/esm/models/components/loopedpositiontotals.d.ts.map +1 -0
  73. package/dist/esm/models/components/loopedpositiontotals.js +30 -0
  74. package/dist/esm/models/components/loopedpositiontotals.js.map +1 -0
  75. package/dist/esm/models/components/swapinfo.d.ts +48 -0
  76. package/dist/esm/models/components/swapinfo.d.ts.map +1 -0
  77. package/dist/esm/models/components/swapinfo.js +29 -0
  78. package/dist/esm/models/components/swapinfo.js.map +1 -0
  79. package/dist/esm/models/operations/index.d.ts +1 -0
  80. package/dist/esm/models/operations/index.d.ts.map +1 -1
  81. package/dist/esm/models/operations/index.js +1 -0
  82. package/dist/esm/models/operations/index.js.map +1 -1
  83. package/dist/esm/models/operations/v2creditloopedpositions.d.ts +28 -0
  84. package/dist/esm/models/operations/v2creditloopedpositions.d.ts.map +1 -0
  85. package/dist/esm/models/operations/v2creditloopedpositions.js +22 -0
  86. package/dist/esm/models/operations/v2creditloopedpositions.js.map +1 -0
  87. package/dist/esm/sdk/credit.d.ts +14 -0
  88. package/dist/esm/sdk/credit.d.ts.map +1 -1
  89. package/dist/esm/sdk/credit.js +17 -0
  90. package/dist/esm/sdk/credit.js.map +1 -1
  91. package/docs/models/components/classification.md +17 -0
  92. package/docs/models/components/creditloopedpositionsresponse.md +30 -0
  93. package/docs/models/components/healthfactorscope.md +17 -0
  94. package/docs/models/components/loopedposition.md +46 -0
  95. package/docs/models/components/loopedpositioncurrentstate.md +28 -0
  96. package/docs/models/components/loopedpositionhistoryentry.md +33 -0
  97. package/docs/models/components/loopedpositionstatus.md +17 -0
  98. package/docs/models/components/loopedpositiontotals.md +31 -0
  99. package/docs/models/components/swapinfo.md +36 -0
  100. package/docs/models/operations/v2creditloopedpositionschain.md +15 -0
  101. package/docs/models/operations/v2creditloopedpositionsrequest.md +19 -0
  102. package/docs/sdks/credit/README.md +84 -0
  103. package/openapi_prepped_for_speakeasy.json +510 -0
  104. package/package.json +1 -1
  105. package/src/funcs/creditCreditLoopedPositions.ts +185 -0
  106. package/src/models/components/creditloopedpositionsresponse.ts +61 -0
  107. package/src/models/components/index.ts +6 -0
  108. package/src/models/components/loopedposition.ts +149 -0
  109. package/src/models/components/loopedpositioncurrentstate.ts +101 -0
  110. package/src/models/components/loopedpositionhistoryentry.ts +115 -0
  111. package/src/models/components/loopedpositiontotals.ts +78 -0
  112. package/src/models/components/swapinfo.ts +85 -0
  113. package/src/models/operations/index.ts +1 -0
  114. package/src/models/operations/v2creditloopedpositions.ts +56 -0
  115. package/src/sdk/credit.ts +25 -0
@@ -0,0 +1,78 @@
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
+ * Lifetime totals across all of a looped position's transactions.
13
+ */
14
+ export type LoopedPositionTotals = {
15
+ /**
16
+ * Total collateral added over the position's lifetime.
17
+ */
18
+ totalCollateralAdded: string;
19
+ /**
20
+ * Total collateral removed over the position's lifetime.
21
+ */
22
+ totalCollateralRemoved: string;
23
+ /**
24
+ * Total debt borrowed over the position's lifetime.
25
+ */
26
+ totalDebtAdded: string;
27
+ /**
28
+ * Total debt repaid over the position's lifetime.
29
+ */
30
+ totalDebtRemoved: string;
31
+ /**
32
+ * Number of loop_open + loop_increase transactions.
33
+ */
34
+ loopTxCount: number;
35
+ /**
36
+ * Number of unwind transactions.
37
+ */
38
+ unwindTxCount: number;
39
+ /**
40
+ * Number of liquidation events.
41
+ */
42
+ liquidationCount: number;
43
+ };
44
+
45
+ /** @internal */
46
+ export const LoopedPositionTotals$inboundSchema: z.ZodType<
47
+ LoopedPositionTotals,
48
+ z.ZodTypeDef,
49
+ unknown
50
+ > = z.object({
51
+ total_collateral_added: z.string(),
52
+ total_collateral_removed: z.string(),
53
+ total_debt_added: z.string(),
54
+ total_debt_removed: z.string(),
55
+ loop_tx_count: z.number().int(),
56
+ unwind_tx_count: z.number().int(),
57
+ liquidation_count: z.number().int(),
58
+ }).transform((v) => {
59
+ return remap$(v, {
60
+ "total_collateral_added": "totalCollateralAdded",
61
+ "total_collateral_removed": "totalCollateralRemoved",
62
+ "total_debt_added": "totalDebtAdded",
63
+ "total_debt_removed": "totalDebtRemoved",
64
+ "loop_tx_count": "loopTxCount",
65
+ "unwind_tx_count": "unwindTxCount",
66
+ "liquidation_count": "liquidationCount",
67
+ });
68
+ });
69
+
70
+ export function loopedPositionTotalsFromJSON(
71
+ jsonString: string,
72
+ ): SafeParseResult<LoopedPositionTotals, SDKValidationError> {
73
+ return safeParse(
74
+ jsonString,
75
+ (x) => LoopedPositionTotals$inboundSchema.parse(JSON.parse(x)),
76
+ `Failed to parse 'LoopedPositionTotals' from JSON`,
77
+ );
78
+ }
@@ -0,0 +1,85 @@
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
+ * The DEX swap leg detected inside a loop transaction.
13
+ *
14
+ * @remarks
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. 1inch 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.
21
+ */
22
+ export type SwapInfo = {
23
+ /**
24
+ * Token sold in the swap (the borrowed/debt token).
25
+ */
26
+ soldToken: string;
27
+ /**
28
+ * Symbol of the sold token.
29
+ */
30
+ soldSymbol: string;
31
+ /**
32
+ * Amount of the sold token.
33
+ */
34
+ soldAmount: string;
35
+ /**
36
+ * Token bought in the swap (the collateral token).
37
+ */
38
+ boughtToken: string;
39
+ /**
40
+ * Symbol of the bought token.
41
+ */
42
+ boughtSymbol: string;
43
+ /**
44
+ * Amount of the bought token.
45
+ */
46
+ boughtAmount: string;
47
+ /**
48
+ * The outbound counterparty when it is the 1inch aggregation router. Null when the swap settled from an executor contract (informational only — never required to detect the swap).
49
+ */
50
+ router?: string | null | undefined;
51
+ };
52
+
53
+ /** @internal */
54
+ export const SwapInfo$inboundSchema: z.ZodType<
55
+ SwapInfo,
56
+ z.ZodTypeDef,
57
+ unknown
58
+ > = z.object({
59
+ sold_token: z.string(),
60
+ sold_symbol: z.string(),
61
+ sold_amount: z.string(),
62
+ bought_token: z.string(),
63
+ bought_symbol: z.string(),
64
+ bought_amount: z.string(),
65
+ router: z.nullable(z.string()).optional(),
66
+ }).transform((v) => {
67
+ return remap$(v, {
68
+ "sold_token": "soldToken",
69
+ "sold_symbol": "soldSymbol",
70
+ "sold_amount": "soldAmount",
71
+ "bought_token": "boughtToken",
72
+ "bought_symbol": "boughtSymbol",
73
+ "bought_amount": "boughtAmount",
74
+ });
75
+ });
76
+
77
+ export function swapInfoFromJSON(
78
+ jsonString: string,
79
+ ): SafeParseResult<SwapInfo, SDKValidationError> {
80
+ return safeParse(
81
+ jsonString,
82
+ (x) => SwapInfo$inboundSchema.parse(JSON.parse(x)),
83
+ `Failed to parse 'SwapInfo' from JSON`,
84
+ );
85
+ }
@@ -43,6 +43,7 @@ export * from "./v1wildcatmarket.js";
43
43
  export * from "./v2cctpmint.js";
44
44
  export * from "./v2creditbalances.js";
45
45
  export * from "./v2crediteulermarkets.js";
46
+ export * from "./v2creditloopedpositions.js";
46
47
  export * from "./v2creditmorphomarkets.js";
47
48
  export * from "./v2creditpositions.js";
48
49
  export * from "./v2earnaavemarkets.js";
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { ClosedEnum } from "../../types/enums.js";
7
+
8
+ export const V2CreditLoopedPositionsChain = {
9
+ Arbitrum: "arbitrum",
10
+ Base: "base",
11
+ Bsc: "bsc",
12
+ Ethereum: "ethereum",
13
+ Tempo: "tempo",
14
+ } as const;
15
+ export type V2CreditLoopedPositionsChain = ClosedEnum<
16
+ typeof V2CreditLoopedPositionsChain
17
+ >;
18
+
19
+ export type V2CreditLoopedPositionsRequest = {
20
+ chain: V2CreditLoopedPositionsChain;
21
+ /**
22
+ * The address of the owner of the credit account to get looped positions for.
23
+ */
24
+ owner: string;
25
+ };
26
+
27
+ /** @internal */
28
+ export const V2CreditLoopedPositionsChain$outboundSchema: z.ZodNativeEnum<
29
+ typeof V2CreditLoopedPositionsChain
30
+ > = z.nativeEnum(V2CreditLoopedPositionsChain);
31
+
32
+ /** @internal */
33
+ export type V2CreditLoopedPositionsRequest$Outbound = {
34
+ chain: string;
35
+ owner: string;
36
+ };
37
+
38
+ /** @internal */
39
+ export const V2CreditLoopedPositionsRequest$outboundSchema: z.ZodType<
40
+ V2CreditLoopedPositionsRequest$Outbound,
41
+ z.ZodTypeDef,
42
+ V2CreditLoopedPositionsRequest
43
+ > = z.object({
44
+ chain: V2CreditLoopedPositionsChain$outboundSchema,
45
+ owner: z.string(),
46
+ });
47
+
48
+ export function v2CreditLoopedPositionsRequestToJSON(
49
+ v2CreditLoopedPositionsRequest: V2CreditLoopedPositionsRequest,
50
+ ): string {
51
+ return JSON.stringify(
52
+ V2CreditLoopedPositionsRequest$outboundSchema.parse(
53
+ v2CreditLoopedPositionsRequest,
54
+ ),
55
+ );
56
+ }
package/src/sdk/credit.ts CHANGED
@@ -8,6 +8,7 @@ import { creditCreditBundle } from "../funcs/creditCreditBundle.js";
8
8
  import { creditCreditCreateAccount } from "../funcs/creditCreditCreateAccount.js";
9
9
  import { creditCreditEulerMarkets } from "../funcs/creditCreditEulerMarkets.js";
10
10
  import { creditCreditLoop } from "../funcs/creditCreditLoop.js";
11
+ import { creditCreditLoopedPositions } from "../funcs/creditCreditLoopedPositions.js";
11
12
  import { creditCreditMorphoMarkets } from "../funcs/creditCreditMorphoMarkets.js";
12
13
  import { creditCreditPositions } from "../funcs/creditCreditPositions.js";
13
14
  import { creditCreditRepay } from "../funcs/creditCreditRepay.js";
@@ -58,6 +59,30 @@ export class Credit extends ClientSDK {
58
59
  ));
59
60
  }
60
61
 
62
+ /**
63
+ * List looped (leveraged) credit positions
64
+ *
65
+ * @remarks
66
+ * List looped (leveraged) positions for a credit account owner.
67
+ *
68
+ * Detects loops from the account's on-chain history: a transaction containing
69
+ * lending + borrowing + swap legs is a loop transaction. Returns one position
70
+ * per Morpho market / Aave collateral+debt reserve pair, each with its complete
71
+ * per-transaction history, lifetime totals, and live on-chain state (health
72
+ * factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho
73
+ * Blue.
74
+ */
75
+ async creditLoopedPositions(
76
+ request: operations.V2CreditLoopedPositionsRequest,
77
+ options?: RequestOptions,
78
+ ): Promise<components.CreditLoopedPositionsResponse> {
79
+ return unwrapAsync(creditCreditLoopedPositions(
80
+ this,
81
+ request,
82
+ options,
83
+ ));
84
+ }
85
+
61
86
  /**
62
87
  * List curated Euler markets
63
88
  *