@usdctofiat/offramp 0.1.0
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/README.md +133 -0
- package/dist/chunk-FQEVQAHM.js +660 -0
- package/dist/chunk-FQEVQAHM.js.map +1 -0
- package/dist/index.cjs +674 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +752 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +24 -0
- package/dist/react.d.ts +24 -0
- package/dist/react.js +89 -0
- package/dist/react.js.map +1 -0
- package/dist/types-BHf4ve-4.d.cts +45 -0
- package/dist/types-BHf4ve-4.d.ts +45 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @usdctofiat/offramp
|
|
2
|
+
|
|
3
|
+
USDC-to-fiat offramp SDK for Base. Create and manage delegated deposits in one function call.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @usdctofiat/offramp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Offramp } from "@usdctofiat/offramp";
|
|
15
|
+
|
|
16
|
+
const offramp = new Offramp();
|
|
17
|
+
|
|
18
|
+
const result = await offramp.createDeposit(walletClient, {
|
|
19
|
+
amount: "100",
|
|
20
|
+
platform: "revolut",
|
|
21
|
+
currency: "EUR",
|
|
22
|
+
identifier: "alice",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log(result.depositId, result.txHash);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Deposit Management
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// List deposits
|
|
32
|
+
const deposits = await offramp.getDeposits("0xYourAddress");
|
|
33
|
+
// [{ depositId, status, remainingUsdc, fulfilledIntents, delegated, ... }]
|
|
34
|
+
|
|
35
|
+
// Close and withdraw
|
|
36
|
+
const txHash = await offramp.withdrawDeposit(walletClient, "123");
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## React
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { useOfframp } from "@usdctofiat/offramp/react";
|
|
43
|
+
|
|
44
|
+
function SellButton({ walletClient }) {
|
|
45
|
+
const { createDeposit, step, isLoading, error, getDeposits } = useOfframp();
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<button
|
|
49
|
+
disabled={isLoading}
|
|
50
|
+
onClick={() =>
|
|
51
|
+
createDeposit(walletClient, {
|
|
52
|
+
amount: "100",
|
|
53
|
+
platform: "revolut",
|
|
54
|
+
currency: "EUR",
|
|
55
|
+
identifier: "alice",
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
{step ?? "Sell USDC"}
|
|
60
|
+
</button>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Progress Callbacks
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
await offramp.createDeposit(walletClient, params, (progress) => {
|
|
69
|
+
// progress.step: "approving" | "registering" | "depositing" | "confirming" | "delegating" | "done"
|
|
70
|
+
// progress.txHash: available after "depositing"
|
|
71
|
+
// progress.depositId: available after "confirming"
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Discovery & Validation
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
offramp.getPlatforms();
|
|
79
|
+
// [{ id: "revolut", name: "Revolut", currencies: [...], identifierLabel, identifierPlaceholder, helperText }]
|
|
80
|
+
|
|
81
|
+
offramp.getCurrencies("wise");
|
|
82
|
+
// ["USD", "EUR", "GBP", "AUD", ...]
|
|
83
|
+
|
|
84
|
+
offramp.validateIdentifier("revolut", "@alice");
|
|
85
|
+
// { valid: true, normalized: "alice" }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Supported Platforms
|
|
89
|
+
|
|
90
|
+
| Platform | Currencies | Identifier |
|
|
91
|
+
|----------|-----------|-----------|
|
|
92
|
+
| Revolut | 23 currencies | Revtag |
|
|
93
|
+
| Wise | 30+ currencies | Wisetag |
|
|
94
|
+
| PayPal | 7 currencies | Email |
|
|
95
|
+
| Venmo | USD | Username |
|
|
96
|
+
| Cash App | USD | Cashtag |
|
|
97
|
+
| Zelle | USD | Email |
|
|
98
|
+
| Monzo | GBP | Username |
|
|
99
|
+
| N26 | EUR | IBAN |
|
|
100
|
+
| Chime | USD | ChimeSign |
|
|
101
|
+
| Mercado Pago | ARS | CVU |
|
|
102
|
+
|
|
103
|
+
## Error Handling
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { OfframpError } from "@usdctofiat/offramp";
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
await offramp.createDeposit(walletClient, params);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
if (err instanceof OfframpError) {
|
|
112
|
+
console.log(err.code); // "VALIDATION" | "USER_CANCELLED" | "DEPOSIT_FAILED" | ...
|
|
113
|
+
console.log(err.step); // Which step failed
|
|
114
|
+
console.log(err.txHash); // Available if deposit was created on-chain
|
|
115
|
+
console.log(err.depositId); // Available if deposit was confirmed but delegation failed
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## How It Works
|
|
121
|
+
|
|
122
|
+
Every deposit created through this SDK is automatically:
|
|
123
|
+
|
|
124
|
+
1. **Delegated** to the USDCtoFiat Delegate vault for rate management
|
|
125
|
+
2. **Market-tracking** via oracle-based pricing
|
|
126
|
+
3. **Auto-closing** when fully filled
|
|
127
|
+
4. **Attributed** to Galleon Labs via ERC-8021
|
|
128
|
+
|
|
129
|
+
## Requirements
|
|
130
|
+
|
|
131
|
+
- Base network (chain ID 8453)
|
|
132
|
+
- viem `WalletClient` with an account
|
|
133
|
+
- USDC balance on Base
|