@bitzy-app/bitzy-sdk 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +13 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ A comprehensive SDK for fetching swap routes and executing swaps on Bitzy's dece
|
|
|
15
15
|
### **Installation**
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @bitzy/
|
|
18
|
+
npm install @bitzy-app/bitzy-sdk
|
|
19
19
|
# or
|
|
20
|
-
yarn add @bitzy/
|
|
20
|
+
yarn add @bitzy-app/bitzy-sdk
|
|
21
21
|
# or
|
|
22
|
-
pnpm add @bitzy/
|
|
22
|
+
pnpm add @bitzy-app/bitzy-sdk
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## **1. Using Functions**
|
|
@@ -27,7 +27,7 @@ pnpm add @bitzy/swap-sdk
|
|
|
27
27
|
### **1.1 `fetchSwapRoute()` - Main Route Finding Function**
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import { fetchSwapRoute } from '@bitzy/
|
|
30
|
+
import { fetchSwapRoute } from '@bitzy-app/bitzy-sdk';
|
|
31
31
|
|
|
32
32
|
// Basic usage with defaults
|
|
33
33
|
const result = await fetchSwapRoute({
|
|
@@ -57,7 +57,7 @@ console.log('Distributions:', result.distributions);
|
|
|
57
57
|
### **1.2 `fetchBatchSwapRoutes()` - Multiple Routes at Once**
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
|
-
import { fetchBatchSwapRoutes } from '@bitzy/
|
|
60
|
+
import { fetchBatchSwapRoutes } from '@bitzy-app/bitzy-sdk';
|
|
61
61
|
|
|
62
62
|
// Fetch multiple routes simultaneously
|
|
63
63
|
const results = await fetchBatchSwapRoutes([
|
|
@@ -94,7 +94,7 @@ results.forEach((result, index) => {
|
|
|
94
94
|
### **1.3 `getSwapQuote()` - Simple Price Quote**
|
|
95
95
|
|
|
96
96
|
```typescript
|
|
97
|
-
import { getSwapQuote } from '@bitzy/
|
|
97
|
+
import { getSwapQuote } from '@bitzy-app/bitzy-sdk';
|
|
98
98
|
|
|
99
99
|
// Get a simple quote without full routing details
|
|
100
100
|
const quote = await getSwapQuote(
|
|
@@ -112,7 +112,7 @@ console.log('Route count:', quote.routes);
|
|
|
112
112
|
### **1.4 `fetchSwapRouteSimple()` - Minimal Configuration**
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
|
-
import { fetchSwapRouteSimple } from '@bitzy/
|
|
115
|
+
import { fetchSwapRouteSimple } from '@bitzy-app/bitzy-sdk';
|
|
116
116
|
|
|
117
117
|
// Simplified function with minimal parameters
|
|
118
118
|
const result = await fetchSwapRouteSimple(
|
|
@@ -131,7 +131,7 @@ console.log('Best route:', result.routes[0]);
|
|
|
131
131
|
### **2.1 `useSwapV3Routes()` - Main React Hook**
|
|
132
132
|
|
|
133
133
|
```tsx
|
|
134
|
-
import { useSwapV3Routes } from '@bitzy/
|
|
134
|
+
import { useSwapV3Routes } from '@bitzy-app/bitzy-sdk';
|
|
135
135
|
|
|
136
136
|
function SwapComponent() {
|
|
137
137
|
const [srcToken, setSrcToken] = useState(btcToken);
|
|
@@ -221,7 +221,7 @@ Here are generic examples showing how to execute swaps using direct contract cal
|
|
|
221
221
|
#### **Example 1: Using Viem with BitzyAggregator Contract**
|
|
222
222
|
|
|
223
223
|
```tsx
|
|
224
|
-
import { useSwapV3Routes } from '@bitzy/
|
|
224
|
+
import { useSwapV3Routes } from '@bitzy-app/bitzy-sdk';
|
|
225
225
|
import { useWriteContract, useAccount } from 'wagmi';
|
|
226
226
|
import { parseUnits, formatUnits } from 'viem';
|
|
227
227
|
|
|
@@ -401,7 +401,7 @@ function SwapComponent() {
|
|
|
401
401
|
#### **Example 2: Using Ethers.js**
|
|
402
402
|
|
|
403
403
|
```typescript
|
|
404
|
-
import { useSwapV3Routes } from '@bitzy/
|
|
404
|
+
import { useSwapV3Routes } from '@bitzy-app/bitzy-sdk';
|
|
405
405
|
import { ethers } from 'ethers';
|
|
406
406
|
|
|
407
407
|
function SwapWithEthers() {
|
|
@@ -484,7 +484,7 @@ function SwapWithEthers() {
|
|
|
484
484
|
#### **Example 3: Using Web3.js**
|
|
485
485
|
|
|
486
486
|
```typescript
|
|
487
|
-
import { useSwapV3Routes } from '@bitzy/
|
|
487
|
+
import { useSwapV3Routes } from '@bitzy-app/bitzy-sdk';
|
|
488
488
|
import Web3 from 'web3';
|
|
489
489
|
|
|
490
490
|
function SwapWithWeb3() {
|
|
@@ -776,7 +776,7 @@ interface Token {
|
|
|
776
776
|
### **Backend Usage (Node.js)**
|
|
777
777
|
|
|
778
778
|
```typescript
|
|
779
|
-
import { fetchSwapRoute, fetchBatchSwapRoutes } from '@bitzy/
|
|
779
|
+
import { fetchSwapRoute, fetchBatchSwapRoutes } from '@bitzy-app/bitzy-sdk';
|
|
780
780
|
|
|
781
781
|
// Express.js endpoint
|
|
782
782
|
app.post('/api/swap/routes', async (req, res) => {
|
|
@@ -822,7 +822,7 @@ import {
|
|
|
822
822
|
getPartCountWithFallback,
|
|
823
823
|
clearMinimumAmountsCache,
|
|
824
824
|
APIClient
|
|
825
|
-
} from '@bitzy/
|
|
825
|
+
} from '@bitzy-app/bitzy-sdk';
|
|
826
826
|
|
|
827
827
|
// Check if token is high-value (requires chainId)
|
|
828
828
|
const isHighValue = isHighValueToken(token, 3637);
|