Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
69 changes: 35 additions & 34 deletions docs/docs/02-Stash/01-utilizing-stash.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]

Expand All @@ -45,35 +45,11 @@ style E fill:#FF9B43,stroke:#333,stroke-width:2px,color:#000,font-weight:bold

</div>

### 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": "<your_api_key>",
},
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"
Expand All @@ -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"
Expand All @@ -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": "<your_api_key>",
},
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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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8Yst+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";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Preview an estimated borrowing cost before requesting credit."}
></Heading>

<MethodEndpoint
method={"get"}
path={"/liquidity/chain/{sourceChainId}/protocol/{protocol}/type/{type}/quote"}
context={"endpoint"}
></MethodEndpoint>

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).

<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
></Heading>

<ParamsDetails
parameters={[
{
description:
"destChainID must use capid format from our configuration <br />-eip155:8453(Base),<br />-eip155:10 (Optimism),<br />-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: <br /><br /> ExactInput - Request will consider the amount as (input amount - borrow costs) <br /><br /> 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" },
},
]}
></ParamsDetails>

<RequestSchema
title={"Body"}
body={{
content: { "application/json": { schema: { type: "string" } } },
description: "Amount to borrow",
required: true,
"x-s2o-overloaded": true,
}}
></RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{
"200": {
description: "Successfully retrieved borrow quote",
content: {
"application/json": {
schema: {
properties: {
data: {
properties: {
borrowCost: { type: "string" },
duration: { type: "string" },
requiredInput: { type: "string" },
requiredOutput: { type: "string" },
},
required: ["borrowCost", "duration", "requiredInput", "requiredOutput"],
type: "object",
},
},
required: ["data"],
type: "object",
},
},
},
},
"400": {
description: "Bad request due to invalid input or missing parameters",
content: {
"application/json": {
schema: {
properties: {
debug: { type: "string" },
error: { type: "string" },
},
required: ["debug", "error"],
type: "object",
},
},
},
},
"500": {
description: "Internal server error",
content: {
"application/json": {
schema: {
properties: {
debug: { type: "string" },
error: { type: "string" },
},
required: ["debug", "error"],
type: "object",
},
},
},
},
}}
></StatusCodes>
Loading