diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 68be540..c6623db 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,12 +2,9 @@ ## [0.2.0](https://github.com/sprintertech/sprinter-sdk/compare/docs-v0.1.3...docs-v0.2.0) (2025-05-08) - ### Features -* staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e)) - -## [0.1.3](https://github.com/sprintertech/sprinter-sdk/compare/docs-v0.1.2...docs-v0.1.3) (2025-01-22) +- staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e)) ### Bug Fixes diff --git a/docs/docs/02-Stash/01-utilizing-stash.md b/docs/docs/02-Stash/01-utilizing-stash.md index b67a820..6a35059 100644 --- a/docs/docs/02-Stash/01-utilizing-stash.md +++ b/docs/docs/02-Stash/01-utilizing-stash.md @@ -15,8 +15,8 @@ Sprinter Stash enables solvers to **borrow crosschain credit on-demand** to exec This guide covers: 1. Recap of the [Stash Fill Lifecycle](use-stash#1-stash-solver-fill-lifecycle) -2. Requesting a [Credit Borrow Cost Estimate](use-stash#2-request-a-borrow-cost-estimate-optional) -3. Requesting a [Final Borrow Quote and Credit Authorization](use-stash#3-request-a-final-borrow-quote) +2. Requesting a [Credit Borrow Quote Estimate](use-stash#2-request-a-credit-borrow-quote-estimate-optional) +3. Requesting a [Final Borrow Cost and Credit Authorization](use-stash#3-request-the-final-credit-borrow-cost) 4. Check out the [Fill Optimization Tips](use-stash#4-fill-optimization-tips) ### 1. Stash Fill Lifecycle @@ -25,13 +25,13 @@ This guide covers: ```mermaid flowchart TD - A[Solver Detects User Intent] --> B[2 - Solver Previews estimated borrowing cost of credit /request] - B --> C[Receive Borrow Cost Estimate] + A[Solver Detects User Intent] --> B[2 - Solver Previews estimated borrowing /quote of credit] + B --> C[Receive Borrow Quote Estimate] C --> D{Fill using Stash Credit?} - D -- Yes --> E[3 - Solver Reserves credit and authorize the fill] + D -- Yes --> E[3 - Solver Reserves credit and authorize the fill /cost] D -- No --> F[Abort Fill] E --> G[Solver Borrow Liquidity from Sprinter Stash] - G --> H[Stash Executes Cross-Chain Swap/Bridge Execution /quote] + G --> H[Stash Executes Cross-Chain Swap/Bridge Execution /request] H --> I[Intent Protocol Repays Borrowed Credit + Costs] I --> J[Fill Complete] @@ -45,35 +45,11 @@ style E fill:#FF9B43,stroke:#333,stroke-width:2px,color:#000,font-weight:bold -### 2. Request a Credit Borrow Cost Estimate (Optional) +### 2. Request a Credit Borrow Quote Estimate (Optional) -Call the [**Borrow Cost API**](borrow-cost-api) to preview an estimated borrowing cost for a potential fill before requesting credit. +Call the [**Borrow Quote API**](borrow-quote-api) to preview an estimated borrowing cost for a potential fill before requesting credit. This can be based on input or output amount. -```ts title="Fetch Borrow Cost Estimate Example Payload" -const baseUrl = "https://api.sprinter.tech"; -const destChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum) destChainId must use capid format from our configuration -const protocol = "across"; // "across" or "mayan" -const txHash = "string"; // Source chain deposit TX -const response = await fetch( - `${baseUrl}/liquidity/chain/${destChainId}/protocol/${protocol}/deposit/${txHash}/requests`, - { - method: "GET", - headers: { - "X-Auth-Token": "", - }, - body: { - input: callData, // encoded callData of deposit - caller: "address", // the address that will execute the borrow and fill ond destChainId - }, - }, -); -``` - -### 3. Request a Final Borrow Quote - -If proceeding to fill with Sprinter Stash, call the [**Borrow Quote API**](borrow-quote-api) to request a borrow quote to reserve credit and authorize the fill. This can be based on input or output amount. - -```ts title="Request Final Borrow Quote with type ExactInput (input amount - borrow costs)" +```ts title="Request Borrow Quote Estimate with type ExactInput (input amount - borrow costs)" const baseUrl = "https://api.sprinter.tech"; const sourceChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum). ChainId must use capid format from our configuration const protocol = "across"; // "across" or "mayan" @@ -99,7 +75,7 @@ console.log("Expected amount:", borrowQuote.expectedOutput); console.log("Borrow Cost:", borrowQuote.borrowCost); ``` -```ts title="Request Final Borrow Quote with type ExactOutput (output amount + borrow costs)" +```ts title="Request Final Borrow Quote Estimate with type ExactOutput (output amount + borrow costs)" const baseUrl = "https://api.sprinter.tech"; const sourceChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum). ChainId must use capid format from our configuration const protocol = "across"; // "across" or "mayan" @@ -121,10 +97,35 @@ const response = await fetch( ); const borrowQuote = await response.json(); + console.log("Expected Input:", borrowQuote.requiredInput); console.log("Borrow Cost:", borrowQuote.borrowCost); ``` +### 3. Request the final Credit Borrow Cost + +If proceeding to fill with Sprinter Stash, call the [**Borrow Cost API**](borrow-cost-api) to request the final borrow cost to reserve credit and authorize the fill. + +```ts title="Fetch Borrow Cost Example Payload" +const baseUrl = "https://api.sprinter.tech"; +const destChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum) destChainId must use capid format from our configuration +const protocol = "across"; // "across" or "mayan" +const txHash = "string"; // Source chain deposit TX +const response = await fetch( + `${baseUrl}/liquidity/chain/${destChainId}/protocol/${protocol}/deposit/${txHash}/requests`, + { + method: "GET", + headers: { + "X-Auth-Token": "", + }, + body: { + input: "callData", // encoded callData for destination ( Borrow & Fill) it also contains depositData prams for MPC validation + caller: "address", // the address that will execute the borrow and fill ond destChainId + }, + }, +); +``` + ### 4. Fill Optimization Tips Here are some tips on getting the best performance and profit from your Sprinter Stash integration: diff --git a/docs/docs/02-Stash/03-get-the-borrow-quote-for-a-liquidity-transaction-based-on-the-input-data.api.mdx b/docs/docs/02-Stash/03-get-the-borrow-quote-for-a-liquidity-transaction-based-on-the-input-data.api.mdx new file mode 100644 index 0000000..3c5f357 --- /dev/null +++ b/docs/docs/02-Stash/03-get-the-borrow-quote-for-a-liquidity-transaction-based-on-the-input-data.api.mdx @@ -0,0 +1,154 @@ +--- +id: borrow-quote-api +title: "Get the borrow quote for a liquidity transaction based on the input data" +description: "This endpoint calculates the borrow quote for a liquidity transaction, including the borrow cost, required input/output, and duration." +sidebar_label: "Borrow Quote API" +hide_title: true +hide_table_of_contents: true +api: eJzNVk1v2zgQ/SvEnFKAiYuie9EtaYMiwKLd7WZPQQ60OJbZUqRCDh0bhv77YkjJUR01bbIoUB9smZqP9zjDN9yDxlgH05HxDiq4Xpso0OnOG0eiVrZOVhFGQWsUSx+Cvxd3yROKlQ9CCWvuktGGdoKCclHVHEcK42qbtHHN1K/2kaQIeJdMQC2M6xItfKIukRTKaaFTUOx/BhI6FVSLhCFCdbM/QvlX8ORrb4VTLYoTPGvOpDivg4/xFUgwbNMpWoMEtuB/gwdIGAFARSGhhFivsVVQ7YF2HdtGCsY10PfyOO/fmbmyjQ+G1q1ghzH95VbVdOUymfz8KTP7Dp6c6n9heY+RjMv7JT4i3fvwVVy9Fyc+GygrhcaVSpaiIJ/L4AarVfBtXuDsGEksvd4dcN4lDLsHoIMTzGAzjrDBAH1/W5hgpAuvd2xSe0foiB9V11lTZ6CLL5Gx75/g2csjnuetT46YQ2mjmV3bnsY3/tRvMFiv9Ljes2HsvIsYOdOb16/559vo/6S6xhhXydqdCEjB4Ab1N50O8ufZdMF3GMiUjFrRzGqJ/c5HmuEvYTwEsy9H5rnPnrQo3TfbSZP9u5mimeQ+zvQo7q0c4/rlF6zpUdzMfcaK7d7OVeJC6UND6oRccOM2yppBKYQPojUxsqhMxOHlxcFlama3EEPw4cc7VwKM5t+h+scc1StHGJyyImLYYBAlwm/NpJdAqmEthj9HyWfLcvTuVXAcuIJPHZYWEg1StTiMh8UowIv9+NQvOM1iz9/9ogyVtYqiTZZMZw/ydOE1E5WAW0IXjXdlJHzFHVRHACRslE34S4Gw2rVIa6+hggYpDytaQwXPzQISuLafH6Tzcqvazk5KxaK88qOiqpqbg2thKFsxYQyxtBVXvPORWpXbZRDwD0jPGt5iqSJq4V32KkcvH+YjYZ5o/O9zaxgal3BLi84q43hPUrD50OQi3cAhORfu4VpQTZ6H6VwNv6VYtxLWWbRvYL/nTfo32L7n5TIy8zXFRLW0fKpWykZ8Yst+wfieJV9OycMUH89HbuONCobxPhP7yeehGq/ED25is5CGReV2Uzwj1EMZ8pXnJZheeEt7Adb8tr/tJaxRaQwTXXpXkJ1elxYaXR/pOrMsHud1jR09aTtVng+X1yBhOdy3Wq/ZJah8P1L3BWVppjwk8toerHJNUg3blpD8+Q/91Dyx +sidebar_class_name: "get api-method" +custom_edit_url: null +--- + +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; +import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; + + + + + +A [borrow quote](/Resources/glossary#stash-borrow-quote) is the **preliminary estimated fee** a solver would incur to borrow credit from Sprinter Stash. It is returned off-chain via the Stash API and helps solvers determine if pursuing a fill is profitable. + +Borrow quote includes expected gas, risk premiums, protocol fees, and capital access costs — but it is not a binding or reserved price. + +See the [Request a Credit Borrow Quote Estimate example payload](use-stash#2-request-a-credit-borrow-quote-estimate-optional). + +A [borrow quote](/Resources/glossary#stash-borrow-quote) is the final, **authorized borrowing offer** issued by Sprinter Stash when a solver decides to proceed with a fill. +It reserves credit under specific conditions, allowing solvers to confidently execute the cross-chain transaction. + +See the [Request Final Borrow Quote example payload](/Stash/use-stash#3-request-a-final-borrow-quote). + + + +-eip155:8453(Base),
-eip155:10 (Optimism),
-eip155:42161 (Arbitrum)", + in: "path", + name: "destChainId", + required: true, + schema: { type: "string" }, + }, + { + description: "Protocol name - across, mayan", + in: "path", + name: "protocol", + required: true, + schema: { type: "string" }, + }, + { + description: + "Quote algorithm type:

ExactInput - Request will consider the amount as (input amount - borrow costs)

ExactOutput - Request will consider the amount as (output amount + borrow costs) ", + in: "path", + name: "type", + required: true, + schema: { type: "string" }, + }, + { + description: + "Destination Network ID (optional, defaults to the network from the request body)", + in: "query", + name: "network", + schema: { type: "integer" }, + }, + ]} +>
+ + + + diff --git a/docs/docs/02-Stash/04-get-the-borrow-cost-for-a-liquidity-transaction.api.mdx b/docs/docs/02-Stash/04-get-the-borrow-cost-for-a-liquidity-transaction.api.mdx new file mode 100644 index 0000000..711a1a7 --- /dev/null +++ b/docs/docs/02-Stash/04-get-the-borrow-cost-for-a-liquidity-transaction.api.mdx @@ -0,0 +1,135 @@ +--- +id: borrow-cost-api +title: "Get the borrow cost for a credit transaction" +description: "Get the borrow cost for a credit transaction" +sidebar_label: "Borrow Cost API " +hide_title: true +hide_table_of_contents: true +api: eJzNVk2P00AM/Ssjn0CapQjBJTcWIUAggdByqnpwE28ykMxkPc62VZT/jpyPbVrCwu4B0UsnE4/9bL95TgsZxZRdLS54SOAdiZGCzDYwh51JQxRzHdigKd1N4zInByOMPmLan7BQI2NFQhwhWbdn7r5wkJCGEiw4fa5RCrDgsSJ9Or5lumkcUwaJcEMWYlpQhZC0IIdabaOw8zl0nT2PcXWEYwqMRY9Xc8ioDtHJcmzZv8dYPCjyZjCmKJchO6hFGryQF11iXZcuRUWx+h4VWHuPq86eJeF83YjJUNA8YSrx0K+fLuDbX8QX4SLcEpcBs2m/U8NYBx8pasAXz5/r32mQzx/B/j3m07OXM0JE4SaVhsnsnBQGzdblzz54MUw1UyQvlBmMZkzXaqNrYnEDtoFbb0KUhdJYuCPalxDKRQsffEqLb6LLPSqyRebMarmeoziPOUWY+9vYyV/YfqdUtImdhZdLdb7EzIxMMVlDRoJx/hZLl5mhz4FN5WJ0Pjez6/OA3pwWNKNtky/Wg5gD/7kWg4PJ/DepvlpK9YMXYo+licS3xGbw8F9n0lkQzFWt4NPUdrUcLtYO2avjBD7XxD1qk5MkqzuKrCbZWrXTqluNWrNqB13pVlP/C4ymakpxdUnmKB+arwXaC/nogh+08wcdIDnDYeEWy4b+BR4VuIqkCBkkkJP04i4FJPDIYGBBG/71KJpv91jV5ax/qs3XYdJSTJUx2iAnvZWmTxwHrikN6hClwp5Do5A/fGKdMHgm4o9wNbJLaC+rukTnFWPDvWwNtVsftWUQwmniJbP1cVIlJ3NJa7ixUPRSuYa23WKkb1x2nW7fNMQHSNYb5Qg73GrJdAS7qOsMkmssI92T8JOv49V5amaTejGpcRP9YUZJsCNn73Lpx/Nj4v/FFH8ErrGa3aazUBBmxLOL9mbAcXGlLo6Hf9ErzWk48TpNqZZ7bed36N3bK7CwHT8WqpDpEcaddhd3A87Ql6UXv36vhRJ93mCutoNL/f0EE19l6w== +sidebar_class_name: "get api-method" +custom_edit_url: null +--- + +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; +import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; + + + + + +A [borrow cost](/Resources/glossary#stash-borrow-cost) is the final, **authorized borrowing offer** issued by Sprinter Stash when a solver decides to proceed with a fill. +It reserves credit under specific conditions, allowing solvers to confidently execute the cross-chain transaction. + +See the [Request Final Borrow Cost example payload](use-stash#3-request-the-final-credit-borrow-cost). + + + + + + + + diff --git a/docs/docs/02-Stash/index.md b/docs/docs/02-Stash/index.md index ebb46db..3ccd354 100644 --- a/docs/docs/02-Stash/index.md +++ b/docs/docs/02-Stash/index.md @@ -23,8 +23,8 @@ Sprinter's crosschain credit protocol providing liquidity access to solvers and ```mermaid flowchart TD - A[Solver Detects User Intent] --> B[Solver Previews estimated borrowing cost of credit] - B --> C[Receive Borrow Cost Estimate] + A[Solver Detects User Intent] --> B[Solver Previews Estimated Borrowing Quote of Credit] + B --> C[Receive Borrow Quote Estimate] C --> D{Fill using Stash Credit?} D -- Yes --> E[Solver Reserves credit and authorize the fill] D -- No --> F[Abort Fill] diff --git a/docs/docs/09 -Resources/02-glossary.md b/docs/docs/09 -Resources/02-glossary.md index a4c226c..e27c936 100644 --- a/docs/docs/09 -Resources/02-glossary.md +++ b/docs/docs/09 -Resources/02-glossary.md @@ -100,13 +100,13 @@ Automated agents that find and execute the most efficient way to fulfill a user Gets the finalized execution package returned by `/v2/route` which contains all necessary data to execute a transaction. It builds on a quote by including calldata, selected liquidity paths, slippage tolerances, and chain-specific details. Routes are consumed directly by solvers or smart contracts to simulate and execute cross-chain swaps or intent fills. -### Stash Borrow Cost +### Stash Borrow Quote -A borrow cost is the preliminary **estimated fee** a solver would incur to borrow credit from Sprinter Stash. It is returned off-chain via the Stash API and helps solvers determine if pursuing a fill is profitable. Borrow cost includes expected gas, risk premiums, protocol fees, and capital access costs — but it is not a binding or reserved price. +A borrow quote is the preliminary **estimated fee** a solver would incur to borrow credit from Sprinter Stash. It is returned off-chain via the Stash API and helps solvers determine if pursuing a fill is profitable. Borrow quote includes expected gas, risk premiums, protocol fees, and capital access costs — but it is not a binding or reserved price. -### Stash Borrow Quote +### Stash Borrow Cost -A **borrow quote** is the final, **authorized borrowing offer** issued by Sprinter Stash when a solver decides to proceed with a fill. It reserves credit under specific conditions, allowing solvers to confidently execute the crosschain transaction. +A borrow cost is the final, **authorized borrowing offer** issued by Sprinter Stash when a solver decides to proceed with a fill. It reserves credit under specific conditions, allowing solvers to confidently execute the crosschain transaction. ### State Proofs diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index a7b266e..833401f 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -7,7 +7,6 @@ * staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e)) -## [1.2.3](https://github.com/sprintertech/sprinter-sdk/compare/sprinter-react-v1.2.2...sprinter-react-v1.2.3) (2025-01-22) ### Bug Fixes diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index db0dfd3..9e916d0 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -7,7 +7,6 @@ * staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e)) -## [1.2.4](https://github.com/sprintertech/sprinter-sdk/compare/sprinter-sdk-v1.2.3...sprinter-sdk-v1.2.4) (2025-01-29) ### Bug Fixes