Skip to content

Commit f19c411

Browse files
feat(docs): add improved Stash API Quick Start (#153)
Updates to Stash API Quick Start payload examples. --------- Authored by [email protected]
1 parent 80515f4 commit f19c411

File tree

8 files changed

+331
-46
lines changed

8 files changed

+331
-46
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
## [0.2.0](https://github.com/sprintertech/sprinter-sdk/compare/docs-v0.1.3...docs-v0.2.0) (2025-05-08)
44

5-
65
### Features
76

8-
* staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e))
9-
10-
## [0.1.3](https://github.com/sprintertech/sprinter-sdk/compare/docs-v0.1.2...docs-v0.1.3) (2025-01-22)
7+
- staging changes to docs ([#146](https://github.com/sprintertech/sprinter-sdk/issues/146)) ([217be20](https://github.com/sprintertech/sprinter-sdk/commit/217be201118073cf5e01afedd5e6c213d10a5b5e))
118

129
### Bug Fixes
1310

docs/docs/02-Stash/01-utilizing-stash.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Sprinter Stash enables solvers to **borrow crosschain credit on-demand** to exec
1515
This guide covers:
1616

1717
1. Recap of the [Stash Fill Lifecycle](use-stash#1-stash-solver-fill-lifecycle)
18-
2. Requesting a [Credit Borrow Cost Estimate](use-stash#2-request-a-borrow-cost-estimate-optional)
19-
3. Requesting a [Final Borrow Quote and Credit Authorization](use-stash#3-request-a-final-borrow-quote)
18+
2. Requesting a [Credit Borrow Quote Estimate](use-stash#2-request-a-credit-borrow-quote-estimate-optional)
19+
3. Requesting a [Final Borrow Cost and Credit Authorization](use-stash#3-request-the-final-credit-borrow-cost)
2020
4. Check out the [Fill Optimization Tips](use-stash#4-fill-optimization-tips)
2121

2222
### 1. Stash Fill Lifecycle
@@ -25,13 +25,13 @@ This guide covers:
2525

2626
```mermaid
2727
flowchart TD
28-
A[Solver Detects User Intent] --> B[2 - Solver Previews estimated borrowing cost of credit /request]
29-
B --> C[Receive Borrow Cost Estimate]
28+
A[Solver Detects User Intent] --> B[2 - Solver Previews estimated borrowing /quote of credit]
29+
B --> C[Receive Borrow Quote Estimate]
3030
C --> D{Fill using Stash Credit?}
31-
D -- Yes --> E[3 - Solver Reserves credit and authorize the fill]
31+
D -- Yes --> E[3 - Solver Reserves credit and authorize the fill /cost]
3232
D -- No --> F[Abort Fill]
3333
E --> G[Solver Borrow Liquidity from Sprinter Stash]
34-
G --> H[Stash Executes Cross-Chain Swap/Bridge Execution /quote]
34+
G --> H[Stash Executes Cross-Chain Swap/Bridge Execution /request]
3535
H --> I[Intent Protocol Repays Borrowed Credit + Costs]
3636
I --> J[Fill Complete]
3737
@@ -45,35 +45,11 @@ style E fill:#FF9B43,stroke:#333,stroke-width:2px,color:#000,font-weight:bold
4545

4646
</div>
4747

48-
### 2. Request a Credit Borrow Cost Estimate (Optional)
48+
### 2. Request a Credit Borrow Quote Estimate (Optional)
4949

50-
Call the [**Borrow Cost API**](borrow-cost-api) to preview an estimated borrowing cost for a potential fill before requesting credit.
50+
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.
5151

52-
```ts title="Fetch Borrow Cost Estimate Example Payload"
53-
const baseUrl = "https://api.sprinter.tech";
54-
const destChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum) destChainId must use capid format from our configuration
55-
const protocol = "across"; // "across" or "mayan"
56-
const txHash = "string"; // Source chain deposit TX
57-
const response = await fetch(
58-
`${baseUrl}/liquidity/chain/${destChainId}/protocol/${protocol}/deposit/${txHash}/requests`,
59-
{
60-
method: "GET",
61-
headers: {
62-
"X-Auth-Token": "<your_api_key>",
63-
},
64-
body: {
65-
input: callData, // encoded callData of deposit
66-
caller: "address", // the address that will execute the borrow and fill ond destChainId
67-
},
68-
},
69-
);
70-
```
71-
72-
### 3. Request a Final Borrow Quote
73-
74-
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.
75-
76-
```ts title="Request Final Borrow Quote with type ExactInput (input amount - borrow costs)"
52+
```ts title="Request Borrow Quote Estimate with type ExactInput (input amount - borrow costs)"
7753
const baseUrl = "https://api.sprinter.tech";
7854
const sourceChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum). ChainId must use capid format from our configuration
7955
const protocol = "across"; // "across" or "mayan"
@@ -99,7 +75,7 @@ console.log("Expected amount:", borrowQuote.expectedOutput);
9975
console.log("Borrow Cost:", borrowQuote.borrowCost);
10076
```
10177

102-
```ts title="Request Final Borrow Quote with type ExactOutput (output amount + borrow costs)"
78+
```ts title="Request Final Borrow Quote Estimate with type ExactOutput (output amount + borrow costs)"
10379
const baseUrl = "https://api.sprinter.tech";
10480
const sourceChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum). ChainId must use capid format from our configuration
10581
const protocol = "across"; // "across" or "mayan"
@@ -121,10 +97,35 @@ const response = await fetch(
12197
);
12298

12399
const borrowQuote = await response.json();
100+
124101
console.log("Expected Input:", borrowQuote.requiredInput);
125102
console.log("Borrow Cost:", borrowQuote.borrowCost);
126103
```
127104

105+
### 3. Request the final Credit Borrow Cost
106+
107+
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.
108+
109+
```ts title="Fetch Borrow Cost Example Payload"
110+
const baseUrl = "https://api.sprinter.tech";
111+
const destChainId = "eip155:8453"; // eip155:8453(Base), eip155:10 (Optimism), eip155:42161 (Arbitrum) destChainId must use capid format from our configuration
112+
const protocol = "across"; // "across" or "mayan"
113+
const txHash = "string"; // Source chain deposit TX
114+
const response = await fetch(
115+
`${baseUrl}/liquidity/chain/${destChainId}/protocol/${protocol}/deposit/${txHash}/requests`,
116+
{
117+
method: "GET",
118+
headers: {
119+
"X-Auth-Token": "<your_api_key>",
120+
},
121+
body: {
122+
input: "callData", // encoded callData for destination ( Borrow & Fill) it also contains depositData prams for MPC validation
123+
caller: "address", // the address that will execute the borrow and fill ond destChainId
124+
},
125+
},
126+
);
127+
```
128+
128129
### 4. Fill Optimization Tips
129130

130131
Here are some tips on getting the best performance and profit from your Sprinter Stash integration:
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
id: borrow-quote-api
3+
title: "Get the borrow quote for a liquidity transaction based on the input data"
4+
description: "This endpoint calculates the borrow quote for a liquidity transaction, including the borrow cost, required input/output, and duration."
5+
sidebar_label: "Borrow Quote API"
6+
hide_title: true
7+
hide_table_of_contents: true
8+
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
9+
sidebar_class_name: "get api-method"
10+
custom_edit_url: null
11+
---
12+
13+
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
14+
import ParamsDetails from "@theme/ParamsDetails";
15+
import RequestSchema from "@theme/RequestSchema";
16+
import StatusCodes from "@theme/StatusCodes";
17+
import OperationTabs from "@theme/OperationTabs";
18+
import TabItem from "@theme/TabItem";
19+
import Heading from "@theme/Heading";
20+
21+
<Heading
22+
as={"h1"}
23+
className={"openapi__heading"}
24+
children={"Preview an estimated borrowing cost before requesting credit."}
25+
></Heading>
26+
27+
<MethodEndpoint
28+
method={"get"}
29+
path={"/liquidity/chain/{sourceChainId}/protocol/{protocol}/type/{type}/quote"}
30+
context={"endpoint"}
31+
></MethodEndpoint>
32+
33+
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.
34+
35+
Borrow quote includes expected gas, risk premiums, protocol fees, and capital access costs — but it is not a binding or reserved price.
36+
37+
See the [Request a Credit Borrow Quote Estimate example payload](use-stash#2-request-a-credit-borrow-quote-estimate-optional).
38+
39+
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.
40+
It reserves credit under specific conditions, allowing solvers to confidently execute the cross-chain transaction.
41+
42+
See the [Request Final Borrow Quote example payload](/Stash/use-stash#3-request-a-final-borrow-quote).
43+
44+
<Heading
45+
id={"request"}
46+
as={"h2"}
47+
className={"openapi-tabs__heading"}
48+
children={"Request"}
49+
></Heading>
50+
51+
<ParamsDetails
52+
parameters={[
53+
{
54+
description:
55+
"destChainID must use capid format from our configuration <br />-eip155:8453(Base),<br />-eip155:10 (Optimism),<br />-eip155:42161 (Arbitrum)",
56+
in: "path",
57+
name: "destChainId",
58+
required: true,
59+
schema: { type: "string" },
60+
},
61+
{
62+
description: "Protocol name - across, mayan",
63+
in: "path",
64+
name: "protocol",
65+
required: true,
66+
schema: { type: "string" },
67+
},
68+
{
69+
description:
70+
"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) ",
71+
in: "path",
72+
name: "type",
73+
required: true,
74+
schema: { type: "string" },
75+
},
76+
{
77+
description:
78+
"Destination Network ID (optional, defaults to the network from the request body)",
79+
in: "query",
80+
name: "network",
81+
schema: { type: "integer" },
82+
},
83+
]}
84+
></ParamsDetails>
85+
86+
<RequestSchema
87+
title={"Body"}
88+
body={{
89+
content: { "application/json": { schema: { type: "string" } } },
90+
description: "Amount to borrow",
91+
required: true,
92+
"x-s2o-overloaded": true,
93+
}}
94+
></RequestSchema>
95+
96+
<StatusCodes
97+
id={undefined}
98+
label={undefined}
99+
responses={{
100+
"200": {
101+
description: "Successfully retrieved borrow quote",
102+
content: {
103+
"application/json": {
104+
schema: {
105+
properties: {
106+
data: {
107+
properties: {
108+
borrowCost: { type: "string" },
109+
duration: { type: "string" },
110+
requiredInput: { type: "string" },
111+
requiredOutput: { type: "string" },
112+
},
113+
required: ["borrowCost", "duration", "requiredInput", "requiredOutput"],
114+
type: "object",
115+
},
116+
},
117+
required: ["data"],
118+
type: "object",
119+
},
120+
},
121+
},
122+
},
123+
"400": {
124+
description: "Bad request due to invalid input or missing parameters",
125+
content: {
126+
"application/json": {
127+
schema: {
128+
properties: {
129+
debug: { type: "string" },
130+
error: { type: "string" },
131+
},
132+
required: ["debug", "error"],
133+
type: "object",
134+
},
135+
},
136+
},
137+
},
138+
"500": {
139+
description: "Internal server error",
140+
content: {
141+
"application/json": {
142+
schema: {
143+
properties: {
144+
debug: { type: "string" },
145+
error: { type: "string" },
146+
},
147+
required: ["debug", "error"],
148+
type: "object",
149+
},
150+
},
151+
},
152+
},
153+
}}
154+
></StatusCodes>

0 commit comments

Comments
 (0)