Skip to content

Commit 5df07a2

Browse files
committed
feat!: migrate project to 0x v2 & settler
1 parent 53b685a commit 5df07a2

38 files changed

+1768
-11072
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
## Blockchain Support
1010

11-
| <img alt="arbitrum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/arbitrum/info/logo.png" width="23"/> | <img alt="avalanche" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/avalanchec/info/logo.png" width="20"/> | <img alt="base" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/base/info/logo.png" width="20"/> | <img alt="bnb chain" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/binance/info/logo.png" width="21"/> | <img alt="celo" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/celo/info/logo.png" width="20"/> | <img alt="ethereum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/ethereum/info/logo.png" width="21"/> | <img alt="fantom" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/fantom/info/logo.png" width="22"/> | <img alt="optimism" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/optimism/info/logo.png" width="22"/> | <img alt="polygon" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/polygon/info/logo.png" width="22"/> |
12-
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: |
13-
| Arbitrum | Avalanche | Base | BNB Chain | Celo | Ethereum | Fantom | Optimism | Polygon |
11+
| <img alt="arbitrum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/arbitrum/info/logo.png" width="23"/> | <img alt="avalanche" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/avalanchec/info/logo.png" width="20"/> | <img alt="base" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/base/info/logo.png" width="20"/> | <img alt="bnb chain" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/binance/info/logo.png" width="21"/> | <img alt="ethereum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/ethereum/info/logo.png" width="21"/> | <img alt="optimism" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/optimism/info/logo.png" width="22"/> | <img alt="polygon" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/polygon/info/logo.png" width="22"/> |
12+
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: |
13+
| Arbitrum | Avalanche | Base | BNB Chain | Ethereum | Optimism | Polygon |
1414

1515
## Overview
1616

17-
This library is designed for [0x](https://0x.org/docs/introduction/introduction-to-0x) integrators, simplifying the complex task of parsing [0x transactions](https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff) into a format that is both user-friendly and easy to understand. When swapping tokens, one of the challenges is that the trade can experience slippage through Automated Market Makers ([AMMs](https://0x.org/post/what-is-an-automated-market-maker-amm)). This makes the final swap amounts difficult to predict prior to executing the trade. However, this library overcomes that challenge by parsing the transaction receipt and event logs to accurately identify the final swap amounts.
17+
This library is designed for [0x](https://0x.org/docs/introduction/introduction-to-0x) integrators, simplifying the complex task of parsing [0x transactions](https://0x.org/docs/next/introduction/introduction-to-0x#the-0x-ecosystem) into a format that is both user-friendly and easy to understand. When swapping tokens, one of the challenges is that the trade can experience slippage through Automated Market Makers ([AMMs](https://0x.org/post/what-is-an-automated-market-maker-amm)). This makes the final swap amounts difficult to predict prior to executing the trade. However, this library overcomes that challenge by parsing the transaction receipt and event logs to accurately identify the final swap amounts.
1818

1919
### Demo
2020

@@ -46,26 +46,25 @@ npm install @0x/0x-parser
4646

4747
```typescript
4848
import { parseSwap } from "@0x/0x-parser";
49+
import { createPublicClient } from "viem";
4950

5051
async function main() {
51-
const response = await fetch(
52-
"https://raw.githubusercontent.com/0xProject/protocol/development/packages/contract-artifacts/artifacts/IZeroEx.json"
53-
);
52+
const RPC_URL = `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
5453

55-
const data = await response.json();
56-
const exchangeProxyAbi = data.compilerOutput.abi;
54+
// You can pass any transaction hash that you got after submitted a 0x transaction:
55+
// https://etherscan.io/address/0x2fc205711fc933ef6e5bcc0bf6e6a9bfc220b2d8073aea4f41305882f485669d
56+
const transactionHash =
57+
"0x2fc205711fc933ef6e5bcc0bf6e6a9bfc220b2d8073aea4f41305882f485669d";
5758

58-
// You can pass any transaction hash from 0x Exchange Proxy:
59-
// https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff
60-
const transactionHash = "0xd8637124d650268ae7680781809800e103a3a2bee9fec56083028fea6d98140b";
6159

62-
const swap = await parseSwap({
63-
transactionHash,
64-
exchangeProxyAbi,
65-
rpcUrl: "https://eth.llamarpc.com",
60+
const publicClient = const publicClient = createPublicClient({
61+
chain: mainnet,
62+
transport: http(RPC_URL),
6663
});
6764

68-
console.log(swap); // Logs the swap details in the console.
65+
const swap = await parseSwap({ publicClient, transactionHash });
66+
67+
console.log(swap); // Logs the swap details.
6968
}
7069

7170
main();

examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
⚠️ WARNING
2+
3+
These examples need to be migrated from using 0x-parser v1 to v2. PRs welcomed.

0 commit comments

Comments
 (0)