Skip to content

Commit 925ec2a

Browse files
authored
docs: restructure top-level readme (#35)
* docs: restructure top-level readme * docs: add basic example to top-level
1 parent 790c7b9 commit 925ec2a

File tree

2 files changed

+165
-65
lines changed

2 files changed

+165
-65
lines changed

README.md

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,54 @@
33
<p align="center">
44
<a href="https://across.to">
55
<picture>
6-
<source media="(prefers-color-scheme: dark)" srcset="./.github/across-logo-dark.png">
7-
<img alt="across logo" src="./.github/across-logo-light.png" width="auto" height="60">
6+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/across-protocol/toolkit/refs/heads/master/.github/across-logo-dark.png">
7+
<img alt="across logo" src="https://raw.githubusercontent.com/across-protocol/toolkit/refs/heads/master/.github/across-logo-light.png" width="auto" height="60">
88
</picture>
99
</a>
1010
</p>
1111

1212
<p align="center">
13-
Toolkit for building on top of the <a href="https://across.to">Across Protocol</a> 🛠️
13+
Toolkit 🛠️ for building on top of the <a href="https://across.to">Across Protocol</a>
1414
<p>
15+
<p align="center">
16+
Fastest and lowest-cost bridging for end-users. Streamlined interoperability for developers.
17+
</p>
1518

1619
<p align="center">
17-
<a href="https://www.npmjs.com/package/@across-protocol/integrator-sdk">
18-
<picture>
19-
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/@across-protocol/integrator-sdk?colorA=21262d&colorB=21262d&style=flat">
20-
<img src="https://img.shields.io/npm/v/@across-protocol/integrator-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
21-
</picture>
20+
<a href="https://discord.across.to" target="_blank" rel="noreferrer">
21+
<img src="https://img.shields.io/badge/Chat%20on-Discord-%235766f2" />
2222
</a>
23-
<a href="https://github.com//@across-protocol/integrator/blob/master/LICENSE">
23+
<a href="https://github.com/across-protocol/toolkit/blob/master/LICENSE">
2424
<picture>
2525
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/license-AGPL-21262d?style=flat">
2626
<img src="https://img.shields.io/badge/license-AGPL-f6f8fa?style=flat" alt="MIT License">
2727
</picture>
2828
</a>
29+
<a href="https://twitter.com/AcrossProtocol/" target="_blank" rel="noreferrer">
30+
<img src="https://img.shields.io/twitter/follow/AcrossProtocol?style=social"/>
31+
</a>
2932
</p>
3033

3134
<br>
3235

33-
# Getting Started
34-
35-
The `@across-protocol/integrator-sdk` provides useful abstractions on top of Across' Smart Contracts and Quotes API.
36-
37-
To learn more visit our [docs](https://docs.across.to/).
38-
39-
## Installation
36+
## Overview
4037

41-
To get started, install the integrator sdk and its peer dependency [viem](https://viem.sh/).
42-
43-
```bash
44-
pnpm i @across-protocol/integrator-sdk viem
45-
```
46-
47-
## Quick Start
48-
49-
### 1. Set up the `AcrossClient`
50-
51-
Firstly, you need to set up the `AcrossClient` and configure the chains you want to support.
38+
Quickly integrate with a few lines of code. See [here](./packages/sdk/README.md) for more details.
5239

5340
```ts
5441
import { createAcrossClient } from "@across-protocol/integrator-sdk";
5542
import { mainnet, optimism, arbitrum } from "viem/chains";
43+
import { useWalletClient } from "wagmi";
44+
45+
const wallet = useWalletClient();
5646

47+
// 1. Create client
5748
const client = createAcrossClient({
58-
integratorId: "YOUR_INTEGRATOR_ID",
49+
integratorId: "0xdead", // 2-byte hex string
5950
chains: [mainnet, optimism, arbitrum],
6051
});
61-
```
62-
63-
### 2. Retrieve a quote
6452

65-
Now, you can retrieve a quote for a given route.
66-
67-
```ts
68-
// USDC from Optimism -> Arbitrum
53+
// 2. Retrieve quote for USDC from Optimism -> Arbitrum
6954
const route = {
7055
originChainId: optimism.chainId
7156
destinationChainId: arbitrum.chainId,
@@ -76,46 +61,33 @@ const quote = await client.getQuote({
7661
route,
7762
inputAmount: parseUnit("1000", 6) // USDC decimals
7863
})
79-
```
80-
81-
Note that we provide additional utilities for retrieving available routes, chain details, and token infos.
82-
See [SDK reference](./packages/sdk/README.md).
83-
84-
### 3. Execute a quote
85-
86-
After retrieving a quote, you are ready to execute it.
87-
88-
```ts
89-
import { useWalletClient } from "wagmi";
90-
91-
const wallet = useWalletClient();
9264

65+
// 3. Execute quote
9366
await client.executeQuote({
9467
walletClient: wallet,
95-
deposit: quote.deposit, // returned by `getQuote`
68+
deposit: quote.deposit,
9669
onProgress: (progress) => {
9770
// handle progress
9871
},
9972
});
10073
```
10174

102-
The method will execute a quote by:
103-
104-
1. Approving the SpokePool contract if necessary
105-
2. Depositing the input token on the origin chain
106-
3. Waiting for the deposit to be filled on the destination chain
107-
108-
You can use the `onProgress` callback to act on different stages of the execution.
109-
Have a look at our [example app](./apps/example/) for a more detailed usage of this method.
110-
111-
## Cross-chain message handling
75+
## Tools
11276

113-
TODO
77+
| Package | Description |
78+
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
79+
| [`@across-protocol/integrator-sdk`](./packages/sdk/README.md) | TypeScript package for building on top of Across Protocol's Smart Contracts and Quotes API |
11480

115-
## Error handling and debugging
81+
## Examples
11682

117-
TODO
83+
| App | Description |
84+
| ---------------------------------- | ------------------------------------ |
85+
| [using viem](./apps/example/app) | Example Next.js app using [viem]() |
86+
| [using ethers](./apps/example/app) | Example Next.js app using [ethers]() |
11887

119-
## Route, chain and token details
88+
## Links
12089

121-
TODO
90+
- Website: <https://across.to>
91+
- App: <https://app.across.to>
92+
- Docs: <https://docs.across.to>
93+
- Medium: <https://medium.com/across-protocol>

packages/sdk/README.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,133 @@
1+
<br/>
2+
3+
<p align="center">
4+
<a href="https://across.to">
5+
<picture>
6+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/across-protocol/toolkit/refs/heads/master/.github/across-logo-dark.png">
7+
<img alt="across logo" src="https://raw.githubusercontent.com/across-protocol/toolkit/refs/heads/master/.github/across-logo-light.png" width="auto" height="60">
8+
</picture>
9+
</a>
10+
</p>
11+
12+
<p align="center">
13+
TypeScript package for building on top of the <a href="https://across.to">Across Protocol</a>
14+
<p>
15+
16+
<p align="center">
17+
<a href="https://www.npmjs.com/package/@across-protocol/integrator-sdk">
18+
<picture>
19+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/@across-protocol/integrator-sdk?colorA=21262d&colorB=21262d&style=flat">
20+
<img src="https://img.shields.io/npm/v/@across-protocol/integrator-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
21+
</picture>
22+
</a>
23+
<a href="https://github.com/across-protocol/toolkit/blob/master/LICENSE">
24+
<picture>
25+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/license-AGPL-21262d?style=flat">
26+
<img src="https://img.shields.io/badge/license-AGPL-f6f8fa?style=flat" alt="MIT License">
27+
</picture>
28+
</a>
29+
</p>
30+
31+
<br>
32+
33+
# Getting Started
34+
35+
The `@across-protocol/integrator-sdk` provides useful abstractions on top of Across' Smart Contracts and Quotes API.
36+
37+
To learn more visit our [docs](https://docs.across.to/).
38+
39+
## Installation
40+
41+
To get started, install the integrator sdk and its peer dependency [viem](https://viem.sh/).
42+
43+
```bash
44+
pnpm i @across-protocol/integrator-sdk viem
45+
```
46+
47+
## Quick Start
48+
49+
### 1. Set up the `AcrossClient`
50+
51+
Firstly, you need to set up the `AcrossClient` and configure the chains you want to support.
52+
53+
```ts
54+
import { createAcrossClient } from "@across-protocol/integrator-sdk";
55+
import { mainnet, optimism, arbitrum } from "viem/chains";
56+
57+
const client = createAcrossClient({
58+
integratorId: "0xdead", // 2-byte hex string
59+
chains: [mainnet, optimism, arbitrum],
60+
});
61+
```
62+
63+
### 2. Retrieve a quote
64+
65+
Now, you can retrieve a quote for a given route.
66+
67+
```ts
68+
// USDC from Optimism -> Arbitrum
69+
const route = {
70+
originChainId: optimism.chainId
71+
destinationChainId: arbitrum.chainId,
72+
inputToken: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
73+
outputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
74+
};
75+
const quote = await client.getQuote({
76+
route,
77+
inputAmount: parseUnit("1000", 6) // USDC decimals
78+
})
79+
```
80+
81+
Note that we provide additional utilities for retrieving available routes, chain details, and token infos.
82+
See [here](#chains-and-routes).
83+
84+
### 3. Execute a quote
85+
86+
After retrieving a quote, you are ready to execute it.
87+
88+
```ts
89+
import { useWalletClient } from "wagmi";
90+
91+
const wallet = useWalletClient();
92+
93+
await client.executeQuote({
94+
walletClient: wallet,
95+
deposit: quote.deposit, // returned by `getQuote`
96+
onProgress: (progress) => {
97+
// handle progress
98+
},
99+
});
100+
```
101+
102+
The method will execute a quote by:
103+
104+
1. Approving the SpokePool contract if necessary
105+
2. Depositing the input token on the origin chain
106+
3. Waiting for the deposit to be filled on the destination chain
107+
108+
You can use the `onProgress` callback to act on different stages of the execution.
109+
Have a look at our [example app](../../apps/example) for a more detailed usage of this method.
110+
111+
## Deposit details
112+
113+
TODO
114+
115+
## Cross-chain message handling
116+
117+
TODO
118+
119+
## Error handling and debugging
120+
121+
TODO
122+
123+
## Route, chain and token details
124+
125+
TODO
126+
1127
# `@across-protocol/integrator-sdk` Reference
2128

129+
For the full detailed reference see [here](./docs/README.md).
130+
3131
## `AcrossClient`
4132

5133
### Set Up
@@ -10,7 +138,7 @@
10138
### Chains and Routes
11139

12140
- [`getSupportedChains`](./docs/classes/AcrossClient.md#getsupportedchains)
13-
- [`getAvailableRoutes`](./docs/classes/AcrossClient.md#getquote)
141+
- [`getAvailableRoutes`](./docs/classes/AcrossClient.md#getavailableroutes)
14142

15143
### Quotes, Fees and Limits
16144

0 commit comments

Comments
 (0)