@compass-labs/api-sdk 2.2.76-rc.1 → 2.2.76-rc.3
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 +5 -3
- package/codeSamples_typescript.yaml +6 -0
- package/dist/commonjs/funcs/creditCreditLoop.d.ts +31 -0
- package/dist/commonjs/funcs/creditCreditLoop.d.ts.map +1 -0
- package/dist/commonjs/funcs/creditCreditLoop.js +132 -0
- package/dist/commonjs/funcs/creditCreditLoop.js.map +1 -0
- package/dist/commonjs/models/components/aavelooprequest.d.ts +16 -16
- package/dist/commonjs/models/components/aavelooprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/aavelooprequest.js +17 -17
- package/dist/commonjs/models/components/aavelooprequest.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.d.ts +5 -0
- package/dist/commonjs/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.js +2 -0
- package/dist/commonjs/models/components/creditborrowparams.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.d.ts +5 -0
- package/dist/commonjs/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.js +2 -0
- package/dist/commonjs/models/components/creditborrowrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditlooppreview.d.ts +45 -0
- package/dist/commonjs/models/components/creditlooppreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditlooppreview.js +68 -0
- package/dist/commonjs/models/components/creditlooppreview.js.map +1 -0
- package/dist/commonjs/models/components/creditlooprequest.d.ts +125 -0
- package/dist/commonjs/models/components/creditlooprequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditlooprequest.js +98 -0
- package/dist/commonjs/models/components/creditlooprequest.js.map +1 -0
- package/dist/commonjs/models/components/creditloopresponse.d.ts +27 -0
- package/dist/commonjs/models/components/creditloopresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditloopresponse.js +61 -0
- package/dist/commonjs/models/components/creditloopresponse.js.map +1 -0
- package/dist/commonjs/models/components/creditrepayparams.d.ts +5 -0
- package/dist/commonjs/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayparams.js +2 -0
- package/dist/commonjs/models/components/creditrepayparams.js.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.d.ts +5 -0
- package/dist/commonjs/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.js +2 -0
- package/dist/commonjs/models/components/creditrepayrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.d.ts +5 -0
- package/dist/commonjs/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.js +2 -0
- package/dist/commonjs/models/components/creditsupplyparams.js.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts +5 -0
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.js +2 -0
- package/dist/commonjs/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +4 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +4 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/looplegpreview.d.ts +24 -0
- package/dist/commonjs/models/components/looplegpreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/looplegpreview.js +59 -0
- package/dist/commonjs/models/components/looplegpreview.js.map +1 -0
- package/dist/commonjs/sdk/credit.d.ts +20 -0
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +23 -0
- package/dist/commonjs/sdk/credit.js.map +1 -1
- package/dist/esm/funcs/creditCreditLoop.d.ts +31 -0
- package/dist/esm/funcs/creditCreditLoop.d.ts.map +1 -0
- package/dist/esm/funcs/creditCreditLoop.js +96 -0
- package/dist/esm/funcs/creditCreditLoop.js.map +1 -0
- package/dist/esm/models/components/aavelooprequest.d.ts +16 -16
- package/dist/esm/models/components/aavelooprequest.d.ts.map +1 -1
- package/dist/esm/models/components/aavelooprequest.js +12 -12
- package/dist/esm/models/components/aavelooprequest.js.map +1 -1
- package/dist/esm/models/components/creditborrowparams.d.ts +5 -0
- package/dist/esm/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowparams.js +2 -0
- package/dist/esm/models/components/creditborrowparams.js.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.d.ts +5 -0
- package/dist/esm/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.js +2 -0
- package/dist/esm/models/components/creditborrowrequest.js.map +1 -1
- package/dist/esm/models/components/creditlooppreview.d.ts +45 -0
- package/dist/esm/models/components/creditlooppreview.d.ts.map +1 -0
- package/dist/esm/models/components/creditlooppreview.js +31 -0
- package/dist/esm/models/components/creditlooppreview.js.map +1 -0
- package/dist/esm/models/components/creditlooprequest.d.ts +125 -0
- package/dist/esm/models/components/creditlooprequest.d.ts.map +1 -0
- package/dist/esm/models/components/creditlooprequest.js +57 -0
- package/dist/esm/models/components/creditlooprequest.js.map +1 -0
- package/dist/esm/models/components/creditloopresponse.d.ts +27 -0
- package/dist/esm/models/components/creditloopresponse.d.ts.map +1 -0
- package/dist/esm/models/components/creditloopresponse.js +24 -0
- package/dist/esm/models/components/creditloopresponse.js.map +1 -0
- package/dist/esm/models/components/creditrepayparams.d.ts +5 -0
- package/dist/esm/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayparams.js +2 -0
- package/dist/esm/models/components/creditrepayparams.js.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.d.ts +5 -0
- package/dist/esm/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.js +2 -0
- package/dist/esm/models/components/creditrepayrequest.js.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.d.ts +5 -0
- package/dist/esm/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.js +2 -0
- package/dist/esm/models/components/creditsupplyparams.js.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.d.ts +5 -0
- package/dist/esm/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.js +2 -0
- package/dist/esm/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +4 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +4 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/looplegpreview.d.ts +24 -0
- package/dist/esm/models/components/looplegpreview.d.ts.map +1 -0
- package/dist/esm/models/components/looplegpreview.js +22 -0
- package/dist/esm/models/components/looplegpreview.js.map +1 -0
- package/dist/esm/sdk/credit.d.ts +20 -0
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +23 -0
- package/dist/esm/sdk/credit.js.map +1 -1
- package/docs/models/components/aavelooprequest.md +4 -4
- package/docs/models/components/{initialcollateralamount.md → aavelooprequestinitialcollateralamount.md} +1 -1
- package/docs/models/components/{loantovalue.md → aavelooprequestloantovalue.md} +1 -1
- package/docs/models/components/{maxslippagepercent.md → aavelooprequestmaxslippagepercent.md} +1 -1
- package/docs/models/components/{multiplier.md → aavelooprequestmultiplier.md} +1 -1
- package/docs/models/components/creditborrowparams.md +2 -1
- package/docs/models/components/creditborrowrequest.md +1 -0
- package/docs/models/components/creditlooppreview.md +33 -0
- package/docs/models/components/creditlooprequest.md +41 -0
- package/docs/models/components/creditlooprequestinitialcollateralamount.md +19 -0
- package/docs/models/components/creditlooprequestloantovalue.md +19 -0
- package/docs/models/components/creditlooprequestmaxslippagepercent.md +19 -0
- package/docs/models/components/creditlooprequestmultiplier.md +19 -0
- package/docs/models/components/creditloopresponse.md +30 -0
- package/docs/models/components/creditrepayparams.md +2 -1
- package/docs/models/components/creditrepayrequest.md +1 -0
- package/docs/models/components/creditsupplyparams.md +2 -1
- package/docs/models/components/creditwithdrawparams.md +2 -1
- package/docs/models/components/looplegpreview.md +21 -0
- package/docs/sdks/credit/README.md +106 -0
- package/openapi_prepped_for_speakeasy.json +408 -0
- package/package.json +1 -1
- package/src/funcs/creditCreditLoop.ts +184 -0
- package/src/models/components/aavelooprequest.ts +43 -30
- package/src/models/components/creditborrowparams.ts +7 -0
- package/src/models/components/creditborrowrequest.ts +7 -0
- package/src/models/components/creditlooppreview.ts +86 -0
- package/src/models/components/creditlooprequest.ts +235 -0
- package/src/models/components/creditloopresponse.ts +65 -0
- package/src/models/components/creditrepayparams.ts +7 -0
- package/src/models/components/creditrepayrequest.ts +7 -0
- package/src/models/components/creditsupplyparams.ts +7 -0
- package/src/models/components/creditwithdrawparams.ts +7 -0
- package/src/models/components/index.ts +4 -0
- package/src/models/components/looplegpreview.ts +54 -0
- package/src/sdk/credit.ts +31 -0
|
@@ -6195,6 +6195,49 @@
|
|
|
6195
6195
|
"x-speakeasy-name-override": "credit_borrow"
|
|
6196
6196
|
}
|
|
6197
6197
|
},
|
|
6198
|
+
"/v2/credit/loop": {
|
|
6199
|
+
"post": {
|
|
6200
|
+
"tags": [
|
|
6201
|
+
"Credit"
|
|
6202
|
+
],
|
|
6203
|
+
"summary": "Open a leveraged loop",
|
|
6204
|
+
"description": "Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.\n\nRepeatedly supplies collateral, borrows at the requested loan-to-value, and\nswaps the borrow back to collateral. Each iteration's supply uses the swap's\nGUARANTEED minimum output (enforced on-chain), so a fill anywhere within the\nslippage tolerance can never break a later step; any positive surplus stays\nin the Credit Account (the preview reports the bound as estimated_max_dust).\nVery large loops relative to pool depth can still exceed the slippage\ntolerance through their own cumulative price impact \u2014 size accordingly or\nraise max_slippage_percent.\n\nThe Credit Account must already hold initial_collateral_amount of\ncollateral_token. For protocol=MORPHO pass a market_id from\n/v2/credit/morpho_markets.",
|
|
6205
|
+
"operationId": "v2_credit_loop",
|
|
6206
|
+
"requestBody": {
|
|
6207
|
+
"content": {
|
|
6208
|
+
"application/json": {
|
|
6209
|
+
"schema": {
|
|
6210
|
+
"$ref": "#/components/schemas/CreditLoopRequest"
|
|
6211
|
+
}
|
|
6212
|
+
}
|
|
6213
|
+
},
|
|
6214
|
+
"required": true
|
|
6215
|
+
},
|
|
6216
|
+
"responses": {
|
|
6217
|
+
"200": {
|
|
6218
|
+
"description": "Successful Response",
|
|
6219
|
+
"content": {
|
|
6220
|
+
"application/json": {
|
|
6221
|
+
"schema": {
|
|
6222
|
+
"$ref": "#/components/schemas/CreditLoopResponse"
|
|
6223
|
+
}
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
},
|
|
6227
|
+
"422": {
|
|
6228
|
+
"description": "Validation Error",
|
|
6229
|
+
"content": {
|
|
6230
|
+
"application/json": {
|
|
6231
|
+
"schema": {
|
|
6232
|
+
"$ref": "#/components/schemas/HTTPValidationError"
|
|
6233
|
+
}
|
|
6234
|
+
}
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
},
|
|
6238
|
+
"x-speakeasy-name-override": "credit_loop"
|
|
6239
|
+
}
|
|
6240
|
+
},
|
|
6198
6241
|
"/v2/credit/transfer": {
|
|
6199
6242
|
"post": {
|
|
6200
6243
|
"tags": [
|
|
@@ -12190,6 +12233,18 @@
|
|
|
12190
12233
|
],
|
|
12191
12234
|
"title": "Borrow Vault",
|
|
12192
12235
|
"description": "Euler only: the EVK vault to borrow from. Required when protocol=EULER."
|
|
12236
|
+
},
|
|
12237
|
+
"market_id": {
|
|
12238
|
+
"anyOf": [
|
|
12239
|
+
{
|
|
12240
|
+
"type": "string"
|
|
12241
|
+
},
|
|
12242
|
+
{
|
|
12243
|
+
"type": "null"
|
|
12244
|
+
}
|
|
12245
|
+
],
|
|
12246
|
+
"title": "Market Id",
|
|
12247
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
12193
12248
|
}
|
|
12194
12249
|
},
|
|
12195
12250
|
"type": "object",
|
|
@@ -12242,6 +12297,18 @@
|
|
|
12242
12297
|
"title": "Borrow Vault",
|
|
12243
12298
|
"description": "Euler only: the EVK vault to borrow from. Required when protocol=EULER."
|
|
12244
12299
|
},
|
|
12300
|
+
"market_id": {
|
|
12301
|
+
"anyOf": [
|
|
12302
|
+
{
|
|
12303
|
+
"type": "string"
|
|
12304
|
+
},
|
|
12305
|
+
{
|
|
12306
|
+
"type": "null"
|
|
12307
|
+
}
|
|
12308
|
+
],
|
|
12309
|
+
"title": "Market Id",
|
|
12310
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
12311
|
+
},
|
|
12245
12312
|
"token_in": {
|
|
12246
12313
|
"anyOf": [
|
|
12247
12314
|
{
|
|
@@ -12670,6 +12737,252 @@
|
|
|
12670
12737
|
"title": "CreditFee",
|
|
12671
12738
|
"description": "Fee configuration for credit-product actions.\n\nSame shape as `Fee`, but narrows `denomination` to the values supported by\ncredit borrows. PERFORMANCE is not supported because realized-profit fees\nare not meaningful for debt positions."
|
|
12672
12739
|
},
|
|
12740
|
+
"CreditLoopPreview": {
|
|
12741
|
+
"properties": {
|
|
12742
|
+
"iterations": {
|
|
12743
|
+
"type": "integer",
|
|
12744
|
+
"title": "Iterations",
|
|
12745
|
+
"description": "Number of loop iterations bundled."
|
|
12746
|
+
},
|
|
12747
|
+
"total_collateral_supplied": {
|
|
12748
|
+
"type": "string",
|
|
12749
|
+
"title": "Total Collateral Supplied",
|
|
12750
|
+
"description": "Guaranteed minimum total collateral supplied (token units); actual can only be higher (swap fills above the floor become dust)."
|
|
12751
|
+
},
|
|
12752
|
+
"total_borrowed": {
|
|
12753
|
+
"type": "string",
|
|
12754
|
+
"title": "Total Borrowed",
|
|
12755
|
+
"description": "Total loan tokens borrowed across iterations."
|
|
12756
|
+
},
|
|
12757
|
+
"achieved_multiplier": {
|
|
12758
|
+
"type": "string",
|
|
12759
|
+
"title": "Achieved Multiplier",
|
|
12760
|
+
"description": "Guaranteed leverage floor: total_collateral_supplied / initial_collateral_amount."
|
|
12761
|
+
},
|
|
12762
|
+
"projected_ltv": {
|
|
12763
|
+
"type": "string",
|
|
12764
|
+
"title": "Projected Ltv",
|
|
12765
|
+
"description": "Projected end loan-to-value in percent, at the sizing oracle prices."
|
|
12766
|
+
},
|
|
12767
|
+
"projected_health_factor": {
|
|
12768
|
+
"type": "string",
|
|
12769
|
+
"title": "Projected Health Factor",
|
|
12770
|
+
"description": "Projected health factor (liquidation threshold / projected LTV). Below 1 would be liquidatable \u2014 the request is rejected long before that."
|
|
12771
|
+
},
|
|
12772
|
+
"estimated_max_dust": {
|
|
12773
|
+
"type": "string",
|
|
12774
|
+
"title": "Estimated Max Dust",
|
|
12775
|
+
"description": "Upper bound of collateral-token surplus the swaps can leave in the Credit Account (sum of quote \u2212 guaranteed floor per swap). It is bounded by max_slippage_percent per iteration, stays in the account, and is never lost."
|
|
12776
|
+
},
|
|
12777
|
+
"legs": {
|
|
12778
|
+
"items": {
|
|
12779
|
+
"$ref": "#/components/schemas/LoopLegPreview"
|
|
12780
|
+
},
|
|
12781
|
+
"type": "array",
|
|
12782
|
+
"title": "Legs",
|
|
12783
|
+
"description": "Per-iteration breakdown.",
|
|
12784
|
+
"example": []
|
|
12785
|
+
}
|
|
12786
|
+
},
|
|
12787
|
+
"additionalProperties": false,
|
|
12788
|
+
"type": "object",
|
|
12789
|
+
"required": [
|
|
12790
|
+
"iterations",
|
|
12791
|
+
"total_collateral_supplied",
|
|
12792
|
+
"total_borrowed",
|
|
12793
|
+
"achieved_multiplier",
|
|
12794
|
+
"projected_ltv",
|
|
12795
|
+
"projected_health_factor",
|
|
12796
|
+
"estimated_max_dust"
|
|
12797
|
+
],
|
|
12798
|
+
"title": "CreditLoopPreview",
|
|
12799
|
+
"description": "Projected end state of the loop, computed on GUARANTEED swap floors."
|
|
12800
|
+
},
|
|
12801
|
+
"CreditLoopRequest": {
|
|
12802
|
+
"properties": {
|
|
12803
|
+
"owner": {
|
|
12804
|
+
"type": "string",
|
|
12805
|
+
"title": "Owner",
|
|
12806
|
+
"description": "The address that owns the Credit Account.",
|
|
12807
|
+
"example": "0x5e5b00ed886A6879C2B934612D2312975427fcAf"
|
|
12808
|
+
},
|
|
12809
|
+
"chain": {
|
|
12810
|
+
"$ref": "#/components/schemas/Chain",
|
|
12811
|
+
"description": "Blockchain network.",
|
|
12812
|
+
"example": "ethereum"
|
|
12813
|
+
},
|
|
12814
|
+
"protocol": {
|
|
12815
|
+
"$ref": "#/components/schemas/CreditProtocol",
|
|
12816
|
+
"description": "Lending protocol to loop into: AAVE or MORPHO. EULER looping is not available yet.",
|
|
12817
|
+
"example": "AAVE"
|
|
12818
|
+
},
|
|
12819
|
+
"market_id": {
|
|
12820
|
+
"anyOf": [
|
|
12821
|
+
{
|
|
12822
|
+
"type": "string"
|
|
12823
|
+
},
|
|
12824
|
+
{
|
|
12825
|
+
"type": "null"
|
|
12826
|
+
}
|
|
12827
|
+
],
|
|
12828
|
+
"title": "Market Id",
|
|
12829
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
12830
|
+
},
|
|
12831
|
+
"collateral_token": {
|
|
12832
|
+
"type": "string",
|
|
12833
|
+
"title": "Token",
|
|
12834
|
+
"description": "Token supplied as collateral each iteration. Must already be in the Credit Account for the initial amount. For MORPHO it must be the market's collateral token.",
|
|
12835
|
+
"example": "WETH"
|
|
12836
|
+
},
|
|
12837
|
+
"borrow_token": {
|
|
12838
|
+
"type": "string",
|
|
12839
|
+
"title": "Token",
|
|
12840
|
+
"description": "Token borrowed each iteration and swapped back to the collateral token. For MORPHO it must be the market's loan token.",
|
|
12841
|
+
"example": "USDC"
|
|
12842
|
+
},
|
|
12843
|
+
"initial_collateral_amount": {
|
|
12844
|
+
"anyOf": [
|
|
12845
|
+
{
|
|
12846
|
+
"type": "number",
|
|
12847
|
+
"exclusiveMinimum": 0.0
|
|
12848
|
+
},
|
|
12849
|
+
{
|
|
12850
|
+
"type": "string",
|
|
12851
|
+
"pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
|
|
12852
|
+
}
|
|
12853
|
+
],
|
|
12854
|
+
"title": "Initial Collateral Amount",
|
|
12855
|
+
"description": "Collateral (in token units) already held in the Credit Account to seed the loop.",
|
|
12856
|
+
"example": 1
|
|
12857
|
+
},
|
|
12858
|
+
"multiplier": {
|
|
12859
|
+
"anyOf": [
|
|
12860
|
+
{
|
|
12861
|
+
"type": "number",
|
|
12862
|
+
"exclusiveMinimum": 1.0
|
|
12863
|
+
},
|
|
12864
|
+
{
|
|
12865
|
+
"type": "string",
|
|
12866
|
+
"pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
|
|
12867
|
+
}
|
|
12868
|
+
],
|
|
12869
|
+
"title": "Multiplier",
|
|
12870
|
+
"description": "Target leverage: total collateral exposure = multiplier \u00d7 initial_collateral_amount. Must be achievable at the requested loan_to_value (max \u2248 0.9 / (1 \u2212 LTV)).",
|
|
12871
|
+
"example": 2
|
|
12872
|
+
},
|
|
12873
|
+
"loan_to_value": {
|
|
12874
|
+
"anyOf": [
|
|
12875
|
+
{
|
|
12876
|
+
"type": "number",
|
|
12877
|
+
"maximum": 100.0,
|
|
12878
|
+
"exclusiveMinimum": 0.0
|
|
12879
|
+
},
|
|
12880
|
+
{
|
|
12881
|
+
"type": "string",
|
|
12882
|
+
"pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
|
|
12883
|
+
}
|
|
12884
|
+
],
|
|
12885
|
+
"title": "Loan To Value",
|
|
12886
|
+
"description": "Per-iteration borrow LTV in percent. Must not exceed the protocol's maximum for the market (Aave reserve/e-mode LTV; Morpho LLTV with a safety margin); borrows are sized slightly inside the requested value so no leg sits on the protocol's revert boundary.",
|
|
12887
|
+
"example": 70
|
|
12888
|
+
},
|
|
12889
|
+
"max_slippage_percent": {
|
|
12890
|
+
"anyOf": [
|
|
12891
|
+
{
|
|
12892
|
+
"type": "number",
|
|
12893
|
+
"maximum": 10.0,
|
|
12894
|
+
"exclusiveMinimum": 0.0
|
|
12895
|
+
},
|
|
12896
|
+
{
|
|
12897
|
+
"type": "string",
|
|
12898
|
+
"pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
|
|
12899
|
+
}
|
|
12900
|
+
],
|
|
12901
|
+
"title": "Max Slippage Percent",
|
|
12902
|
+
"description": "Per-swap slippage tolerance in percent. Loop dust is bounded by this per iteration, so tighter slippage means less dust.",
|
|
12903
|
+
"example": "0.5"
|
|
12904
|
+
},
|
|
12905
|
+
"emode_category": {
|
|
12906
|
+
"anyOf": [
|
|
12907
|
+
{
|
|
12908
|
+
"type": "integer",
|
|
12909
|
+
"minimum": 0.0
|
|
12910
|
+
},
|
|
12911
|
+
{
|
|
12912
|
+
"type": "null"
|
|
12913
|
+
}
|
|
12914
|
+
],
|
|
12915
|
+
"title": "Emode Category",
|
|
12916
|
+
"description": "Aave only: e-mode category to enable before looping (higher LTV for correlated pairs, e.g. ETH-correlated)."
|
|
12917
|
+
},
|
|
12918
|
+
"gas_sponsorship": {
|
|
12919
|
+
"type": "boolean",
|
|
12920
|
+
"title": "Gas Sponsorship",
|
|
12921
|
+
"description": "If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.",
|
|
12922
|
+
"example": false
|
|
12923
|
+
}
|
|
12924
|
+
},
|
|
12925
|
+
"type": "object",
|
|
12926
|
+
"required": [
|
|
12927
|
+
"owner",
|
|
12928
|
+
"chain",
|
|
12929
|
+
"collateral_token",
|
|
12930
|
+
"borrow_token",
|
|
12931
|
+
"initial_collateral_amount",
|
|
12932
|
+
"multiplier",
|
|
12933
|
+
"loan_to_value"
|
|
12934
|
+
],
|
|
12935
|
+
"title": "CreditLoopRequest",
|
|
12936
|
+
"description": "Open a leveraged loop: repeatedly supply collateral, borrow, and swap the\nborrow back to collateral \u2014 all in ONE atomic transaction from the Credit\nAccount.",
|
|
12937
|
+
"example": {
|
|
12938
|
+
"owner": "0x5e5b00ed886A6879C2B934612D2312975427fcAf",
|
|
12939
|
+
"chain": "ethereum",
|
|
12940
|
+
"protocol": "AAVE",
|
|
12941
|
+
"collateral_token": "WETH",
|
|
12942
|
+
"borrow_token": "USDC",
|
|
12943
|
+
"initial_collateral_amount": 1,
|
|
12944
|
+
"multiplier": 2,
|
|
12945
|
+
"loan_to_value": 70,
|
|
12946
|
+
"max_slippage_percent": 0.5,
|
|
12947
|
+
"gas_sponsorship": false
|
|
12948
|
+
}
|
|
12949
|
+
},
|
|
12950
|
+
"CreditLoopResponse": {
|
|
12951
|
+
"properties": {
|
|
12952
|
+
"transaction": {
|
|
12953
|
+
"anyOf": [
|
|
12954
|
+
{
|
|
12955
|
+
"$ref": "#/components/schemas/UnsignedTransaction"
|
|
12956
|
+
},
|
|
12957
|
+
{
|
|
12958
|
+
"type": "null"
|
|
12959
|
+
}
|
|
12960
|
+
],
|
|
12961
|
+
"description": "Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false."
|
|
12962
|
+
},
|
|
12963
|
+
"eip_712": {
|
|
12964
|
+
"anyOf": [
|
|
12965
|
+
{
|
|
12966
|
+
"$ref": "#/components/schemas/BatchedSafeOperationsResponse-Output"
|
|
12967
|
+
},
|
|
12968
|
+
{
|
|
12969
|
+
"type": "null"
|
|
12970
|
+
}
|
|
12971
|
+
],
|
|
12972
|
+
"description": "EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true."
|
|
12973
|
+
},
|
|
12974
|
+
"preview": {
|
|
12975
|
+
"$ref": "#/components/schemas/CreditLoopPreview",
|
|
12976
|
+
"description": "Projected end state, computed on guaranteed swap floors."
|
|
12977
|
+
}
|
|
12978
|
+
},
|
|
12979
|
+
"type": "object",
|
|
12980
|
+
"required": [
|
|
12981
|
+
"preview"
|
|
12982
|
+
],
|
|
12983
|
+
"title": "CreditLoopResponse",
|
|
12984
|
+
"description": "The atomic loop transaction plus its guaranteed-floor preview."
|
|
12985
|
+
},
|
|
12673
12986
|
"CreditPositionsResponse": {
|
|
12674
12987
|
"properties": {
|
|
12675
12988
|
"collateral_positions": {
|
|
@@ -12801,6 +13114,18 @@
|
|
|
12801
13114
|
],
|
|
12802
13115
|
"title": "Borrow Vault",
|
|
12803
13116
|
"description": "Euler only: the EVK vault the debt is owed to. Required when protocol=EULER."
|
|
13117
|
+
},
|
|
13118
|
+
"market_id": {
|
|
13119
|
+
"anyOf": [
|
|
13120
|
+
{
|
|
13121
|
+
"type": "string"
|
|
13122
|
+
},
|
|
13123
|
+
{
|
|
13124
|
+
"type": "null"
|
|
13125
|
+
}
|
|
13126
|
+
],
|
|
13127
|
+
"title": "Market Id",
|
|
13128
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
12804
13129
|
}
|
|
12805
13130
|
},
|
|
12806
13131
|
"type": "object",
|
|
@@ -12841,6 +13166,18 @@
|
|
|
12841
13166
|
"title": "Borrow Vault",
|
|
12842
13167
|
"description": "Euler only: the EVK vault the debt is owed to (repay target). Required when protocol=EULER."
|
|
12843
13168
|
},
|
|
13169
|
+
"market_id": {
|
|
13170
|
+
"anyOf": [
|
|
13171
|
+
{
|
|
13172
|
+
"type": "string"
|
|
13173
|
+
},
|
|
13174
|
+
{
|
|
13175
|
+
"type": "null"
|
|
13176
|
+
}
|
|
13177
|
+
],
|
|
13178
|
+
"title": "Market Id",
|
|
13179
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
13180
|
+
},
|
|
12844
13181
|
"collateral_vault": {
|
|
12845
13182
|
"anyOf": [
|
|
12846
13183
|
{
|
|
@@ -13091,6 +13428,18 @@
|
|
|
13091
13428
|
],
|
|
13092
13429
|
"title": "Collateral Vault",
|
|
13093
13430
|
"description": "Euler only: the EVK collateral vault to supply into. Required when protocol=EULER."
|
|
13431
|
+
},
|
|
13432
|
+
"market_id": {
|
|
13433
|
+
"anyOf": [
|
|
13434
|
+
{
|
|
13435
|
+
"type": "string"
|
|
13436
|
+
},
|
|
13437
|
+
{
|
|
13438
|
+
"type": "null"
|
|
13439
|
+
}
|
|
13440
|
+
],
|
|
13441
|
+
"title": "Market Id",
|
|
13442
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
13094
13443
|
}
|
|
13095
13444
|
},
|
|
13096
13445
|
"type": "object",
|
|
@@ -13351,6 +13700,18 @@
|
|
|
13351
13700
|
],
|
|
13352
13701
|
"title": "Collateral Vault",
|
|
13353
13702
|
"description": "Euler only: the EVK collateral vault to withdraw from. Required when protocol=EULER."
|
|
13703
|
+
},
|
|
13704
|
+
"market_id": {
|
|
13705
|
+
"anyOf": [
|
|
13706
|
+
{
|
|
13707
|
+
"type": "string"
|
|
13708
|
+
},
|
|
13709
|
+
{
|
|
13710
|
+
"type": "null"
|
|
13711
|
+
}
|
|
13712
|
+
],
|
|
13713
|
+
"title": "Market Id",
|
|
13714
|
+
"description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
|
|
13354
13715
|
}
|
|
13355
13716
|
},
|
|
13356
13717
|
"type": "object",
|
|
@@ -16637,6 +16998,53 @@
|
|
|
16637
16998
|
"title": "ListAaveMarketsResponse",
|
|
16638
16999
|
"description": "Response containing Aave market rates organized by token symbol."
|
|
16639
17000
|
},
|
|
17001
|
+
"LoopLegPreview": {
|
|
17002
|
+
"properties": {
|
|
17003
|
+
"supply_amount": {
|
|
17004
|
+
"anyOf": [
|
|
17005
|
+
{
|
|
17006
|
+
"type": "string"
|
|
17007
|
+
},
|
|
17008
|
+
{
|
|
17009
|
+
"type": "null"
|
|
17010
|
+
}
|
|
17011
|
+
],
|
|
17012
|
+
"title": "Supply Amount",
|
|
17013
|
+
"description": "Collateral supplied this iteration (token units)."
|
|
17014
|
+
},
|
|
17015
|
+
"borrow_amount": {
|
|
17016
|
+
"anyOf": [
|
|
17017
|
+
{
|
|
17018
|
+
"type": "string"
|
|
17019
|
+
},
|
|
17020
|
+
{
|
|
17021
|
+
"type": "null"
|
|
17022
|
+
}
|
|
17023
|
+
],
|
|
17024
|
+
"title": "Borrow Amount",
|
|
17025
|
+
"description": "Loan borrowed this iteration; null on the final supply-only iteration."
|
|
17026
|
+
},
|
|
17027
|
+
"min_swap_out": {
|
|
17028
|
+
"anyOf": [
|
|
17029
|
+
{
|
|
17030
|
+
"type": "string"
|
|
17031
|
+
},
|
|
17032
|
+
{
|
|
17033
|
+
"type": "null"
|
|
17034
|
+
}
|
|
17035
|
+
],
|
|
17036
|
+
"title": "Min Swap Out",
|
|
17037
|
+
"description": "Guaranteed swap output (collateral units) \u2014 the next iteration's supply. Enforced on-chain by the swap's minimum-return."
|
|
17038
|
+
}
|
|
17039
|
+
},
|
|
17040
|
+
"additionalProperties": false,
|
|
17041
|
+
"type": "object",
|
|
17042
|
+
"required": [
|
|
17043
|
+
"supply_amount"
|
|
17044
|
+
],
|
|
17045
|
+
"title": "LoopLegPreview",
|
|
17046
|
+
"description": "One planned loop iteration."
|
|
17047
|
+
},
|
|
16640
17048
|
"LpBalance": {
|
|
16641
17049
|
"properties": {
|
|
16642
17050
|
"valuation": {
|
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 { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import * as components from "../models/components/index.js";
|
|
15
|
+
import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
|
|
16
|
+
import {
|
|
17
|
+
ConnectionError,
|
|
18
|
+
InvalidRequestError,
|
|
19
|
+
RequestAbortedError,
|
|
20
|
+
RequestTimeoutError,
|
|
21
|
+
UnexpectedClientError,
|
|
22
|
+
} from "../models/errors/httpclienterrors.js";
|
|
23
|
+
import * as errors from "../models/errors/index.js";
|
|
24
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
25
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Open a leveraged loop
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.
|
|
34
|
+
*
|
|
35
|
+
* Repeatedly supplies collateral, borrows at the requested loan-to-value, and
|
|
36
|
+
* swaps the borrow back to collateral. Each iteration's supply uses the swap's
|
|
37
|
+
* GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the
|
|
38
|
+
* slippage tolerance can never break a later step; any positive surplus stays
|
|
39
|
+
* in the Credit Account (the preview reports the bound as estimated_max_dust).
|
|
40
|
+
* Very large loops relative to pool depth can still exceed the slippage
|
|
41
|
+
* tolerance through their own cumulative price impact — size accordingly or
|
|
42
|
+
* raise max_slippage_percent.
|
|
43
|
+
*
|
|
44
|
+
* The Credit Account must already hold initial_collateral_amount of
|
|
45
|
+
* collateral_token. For protocol=MORPHO pass a market_id from
|
|
46
|
+
* /v2/credit/morpho_markets.
|
|
47
|
+
*/
|
|
48
|
+
export function creditCreditLoop(
|
|
49
|
+
client: CompassApiSDKCore,
|
|
50
|
+
request: components.CreditLoopRequest,
|
|
51
|
+
options?: RequestOptions,
|
|
52
|
+
): APIPromise<
|
|
53
|
+
Result<
|
|
54
|
+
components.CreditLoopResponse,
|
|
55
|
+
| errors.HTTPValidationError
|
|
56
|
+
| CompassAPISDKError
|
|
57
|
+
| ResponseValidationError
|
|
58
|
+
| ConnectionError
|
|
59
|
+
| RequestAbortedError
|
|
60
|
+
| RequestTimeoutError
|
|
61
|
+
| InvalidRequestError
|
|
62
|
+
| UnexpectedClientError
|
|
63
|
+
| SDKValidationError
|
|
64
|
+
>
|
|
65
|
+
> {
|
|
66
|
+
return new APIPromise($do(
|
|
67
|
+
client,
|
|
68
|
+
request,
|
|
69
|
+
options,
|
|
70
|
+
));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function $do(
|
|
74
|
+
client: CompassApiSDKCore,
|
|
75
|
+
request: components.CreditLoopRequest,
|
|
76
|
+
options?: RequestOptions,
|
|
77
|
+
): Promise<
|
|
78
|
+
[
|
|
79
|
+
Result<
|
|
80
|
+
components.CreditLoopResponse,
|
|
81
|
+
| errors.HTTPValidationError
|
|
82
|
+
| CompassAPISDKError
|
|
83
|
+
| ResponseValidationError
|
|
84
|
+
| ConnectionError
|
|
85
|
+
| RequestAbortedError
|
|
86
|
+
| RequestTimeoutError
|
|
87
|
+
| InvalidRequestError
|
|
88
|
+
| UnexpectedClientError
|
|
89
|
+
| SDKValidationError
|
|
90
|
+
>,
|
|
91
|
+
APICall,
|
|
92
|
+
]
|
|
93
|
+
> {
|
|
94
|
+
const parsed = safeParse(
|
|
95
|
+
request,
|
|
96
|
+
(value) => components.CreditLoopRequest$outboundSchema.parse(value),
|
|
97
|
+
"Input validation failed",
|
|
98
|
+
);
|
|
99
|
+
if (!parsed.ok) {
|
|
100
|
+
return [parsed, { status: "invalid" }];
|
|
101
|
+
}
|
|
102
|
+
const payload = parsed.value;
|
|
103
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
104
|
+
|
|
105
|
+
const path = pathToFunc("/v2/credit/loop")();
|
|
106
|
+
|
|
107
|
+
const headers = new Headers(compactMap({
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
113
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
114
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
115
|
+
|
|
116
|
+
const context = {
|
|
117
|
+
options: client._options,
|
|
118
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
119
|
+
operationID: "v2_credit_loop",
|
|
120
|
+
oAuth2Scopes: null,
|
|
121
|
+
|
|
122
|
+
resolvedSecurity: requestSecurity,
|
|
123
|
+
|
|
124
|
+
securitySource: client._options.apiKeyAuth,
|
|
125
|
+
retryConfig: options?.retries
|
|
126
|
+
|| client._options.retryConfig
|
|
127
|
+
|| { strategy: "none" },
|
|
128
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const requestRes = client._createRequest(context, {
|
|
132
|
+
security: requestSecurity,
|
|
133
|
+
method: "POST",
|
|
134
|
+
baseURL: options?.serverURL,
|
|
135
|
+
path: path,
|
|
136
|
+
headers: headers,
|
|
137
|
+
body: body,
|
|
138
|
+
userAgent: client._options.userAgent,
|
|
139
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
140
|
+
}, options);
|
|
141
|
+
if (!requestRes.ok) {
|
|
142
|
+
return [requestRes, { status: "invalid" }];
|
|
143
|
+
}
|
|
144
|
+
const req = requestRes.value;
|
|
145
|
+
|
|
146
|
+
const doResult = await client._do(req, {
|
|
147
|
+
context,
|
|
148
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
149
|
+
matchStatusCode({ status: statusCode } as Response, ["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.CreditLoopResponse,
|
|
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.CreditLoopResponse$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
|
+
}
|