Skip to content

Commit 0dd2946

Browse files
committed
Release v11.1.1
Origin-SHA: 8dd7759cfc6e11592de1f9058fa2d31ec9a13678
1 parent e393041 commit 0dd2946

5 files changed

Lines changed: 61 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @opensea/sdk
22

3+
## 11.1.1
4+
5+
### Patch Changes
6+
7+
- fix: correct `GetSwapQuoteArgs` to match the swap quote endpoint. `getSwapQuote` now takes `{ fromChain, fromAddress, toChain, toAddress, quantity, address, slippage?, recipient? }`, matching `GET /api/v2/swap/quote` (the previous `{ tokenIn, tokenOut, amount, chain }` shape did not map to the endpoint's query params).
8+
39
## 11.1.0
410

511
### Minor Changes

developerDocs/api-reference.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,27 +1185,32 @@ Get a swap quote for exchanging tokens.
11851185

11861186
```typescript
11871187
const quote = await openseaSDK.api.getSwapQuote({
1188-
token_in: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
1189-
token_out: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
1190-
amount: "1000000000000000000", // 1 WETH in wei
1191-
chain: "ethereum",
1192-
taker_address: "0x...", // Optional
1193-
slippage: 0.5, // Optional: slippage tolerance
1188+
fromChain: "ethereum",
1189+
fromAddress: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
1190+
toChain: "ethereum",
1191+
toAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
1192+
quantity: "1000000000000000000", // 1 WETH in wei
1193+
address: "0x...", // Wallet executing the swap
1194+
slippage: 0.05, // Optional: slippage tolerance (0.0 to 0.5)
11941195
});
11951196
```
11961197

11971198
**Parameters:**
11981199

1199-
| Parameter | Type | Required | Description |
1200-
| --------------- | ------ | -------- | --------------------------- |
1201-
| `token_in` | string | Yes | Address of the input token |
1202-
| `token_out` | string | Yes | Address of the output token |
1203-
| `amount` | string | Yes | Amount of input token |
1204-
| `chain` | string | Yes | Chain for the swap |
1205-
| `taker_address` | string | No | Address of the taker |
1206-
| `slippage` | number | No | Slippage tolerance |
1200+
| Parameter | Type | Required | Description |
1201+
| ------------- | ------ | -------- | ------------------------------------------------- |
1202+
| `fromChain` | string | Yes | Chain of the token to swap from |
1203+
| `fromAddress` | string | Yes | Contract address of the token to swap from |
1204+
| `toChain` | string | Yes | Chain of the token to swap to |
1205+
| `toAddress` | string | Yes | Contract address of the token to swap to |
1206+
| `quantity` | string | Yes | Amount to swap in the token's smallest unit (wei) |
1207+
| `address` | string | Yes | Wallet address executing the swap |
1208+
| `slippage` | number | No | Slippage tolerance, 0.0 to 0.5 (default 0.01) |
1209+
| `recipient` | string | No | Recipient address (defaults to sender) |
1210+
1211+
Set `fromChain` and `toChain` to different chains for cross-chain swaps.
12071212

1208-
**Returns:** `GetSwapQuoteResponse` with swap quote data.
1213+
**Returns:** `GetSwapQuoteResponse` with the swap quote and the transactions to execute.
12091214

12101215
---
12111216

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opensea/sdk",
3-
"version": "11.1.0",
3+
"version": "11.1.1",
44
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs, tokens, and our marketplace data",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/api/types.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,18 +759,22 @@ export interface GetTokensArgs {
759759
* @category API Query Args
760760
*/
761761
export interface GetSwapQuoteArgs {
762-
/** Address of the input token */
763-
tokenIn: string
764-
/** Address of the output token */
765-
tokenOut: string
766-
/** Amount of input token */
767-
amount: string
768-
/** Chain for the swap */
769-
chain: string
770-
/** Address of the taker */
771-
takerAddress?: string
772-
/** Slippage tolerance */
762+
/** Chain of the token to swap from */
763+
fromChain: string
764+
/** Contract address of the token to swap from */
765+
fromAddress: string
766+
/** Chain of the token to swap to */
767+
toChain: string
768+
/** Contract address of the token to swap to */
769+
toAddress: string
770+
/** Amount to swap in the smallest unit of the token (e.g. wei for ETH) */
771+
quantity: string
772+
/** Wallet address executing the swap */
773+
address: string
774+
/** Slippage tolerance, 0.0 to 0.5 (default 0.01) */
773775
slippage?: number
776+
/** Recipient address (defaults to the sender address) */
777+
recipient?: string
774778
}
775779

776780
/**

test/api/tokens.spec.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,12 @@ describe("API: TokensAPI", () => {
202202
mockGet.mockResolvedValue(mockResponse)
203203

204204
const args = {
205-
tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
206-
tokenOut: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
207-
amount: "1000000000000000000",
208-
chain: "ethereum",
205+
fromChain: "ethereum",
206+
fromAddress: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
207+
toChain: "ethereum",
208+
toAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
209+
quantity: "1000000000000000000",
210+
address: "0x1234567890123456789012345678901234567890",
209211
}
210212

211213
const result = await tokensAPI.getSwapQuote(args)
@@ -224,12 +226,14 @@ describe("API: TokensAPI", () => {
224226
mockGet.mockResolvedValue(mockResponse)
225227

226228
const args = {
227-
tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
228-
tokenOut: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
229-
amount: "1000000000000000000",
230-
chain: "ethereum",
231-
takerAddress: "0x1234567890123456789012345678901234567890",
229+
fromChain: "ethereum",
230+
fromAddress: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
231+
toChain: "base",
232+
toAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
233+
quantity: "1000000000000000000",
234+
address: "0x1234567890123456789012345678901234567890",
232235
slippage: 0.5,
236+
recipient: "0x9876543210987654321098765432109876543210",
233237
}
234238

235239
await tokensAPI.getSwapQuote(args)
@@ -242,10 +246,12 @@ describe("API: TokensAPI", () => {
242246

243247
try {
244248
await tokensAPI.getSwapQuote({
245-
tokenIn: "0x123",
246-
tokenOut: "0x456",
247-
amount: "1000",
248-
chain: "ethereum",
249+
fromChain: "ethereum",
250+
fromAddress: "0x123",
251+
toChain: "ethereum",
252+
toAddress: "0x456",
253+
quantity: "1000",
254+
address: "0x789",
249255
})
250256
throw new Error("Expected error to be thrown")
251257
} catch (error) {

0 commit comments

Comments
 (0)