@usdctofiat/offramp 1.0.0 → 1.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 CHANGED
@@ -3,61 +3,55 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@usdctofiat/offramp?color=8fb47d)](https://www.npmjs.com/package/@usdctofiat/offramp)
4
4
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ADWilkinson/galleonlabs-zkp2p/blob/main/packages/offramp-sdk/LICENSE)
5
5
 
6
- USDC-to-fiat offramp SDK for Base. Create and manage delegated deposits in one function call.
6
+ USDC-to-fiat offramp SDK for Base. 6 functions + 2 const objects.
7
7
 
8
8
  ## Install
9
9
 
10
10
  ```bash
11
- npm install @usdctofiat/offramp
11
+ bun add @usdctofiat/offramp
12
12
  ```
13
13
 
14
14
  ## Quick Start
15
15
 
16
16
  ```typescript
17
- import { Offramp, PAYMENT_PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
17
+ import { offramp, PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
18
18
 
19
- const offramp = new Offramp();
20
-
21
- const result = await offramp.createDeposit(walletClient, {
19
+ const result = await offramp(walletClient, {
22
20
  amount: "100",
23
- platform: PAYMENT_PLATFORMS.REVOLUT,
21
+ platform: PLATFORMS.REVOLUT,
24
22
  currency: CURRENCIES.EUR,
25
23
  identifier: "alice",
26
24
  });
27
-
28
- console.log(result.depositId, result.txHash);
25
+ // { depositId: "362", txHash: "0x...", resumed: false }
29
26
  ```
30
27
 
31
28
  ## Deposit Management
32
29
 
33
30
  ```typescript
34
- // List deposits
35
- const deposits = await offramp.getDeposits("0xYourAddress");
36
- // [{ depositId, status, remainingUsdc, fulfilledIntents, delegated, ... }]
31
+ import { deposits, close } from "@usdctofiat/offramp";
37
32
 
38
- // Close and withdraw
39
- const txHash = await offramp.withdrawDeposit(walletClient, "123");
33
+ const list = await deposits("0xYourAddress");
34
+ await close(walletClient, "361");
40
35
  ```
41
36
 
42
37
  ## React
43
38
 
44
39
  ```typescript
45
40
  import { useOfframp } from "@usdctofiat/offramp/react";
41
+ import { PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
46
42
 
47
- function SellButton({ walletClient }) {
48
- const { createDeposit, step, isLoading, error, getDeposits } = useOfframp();
43
+ function SellButton({ walletClient }: { walletClient: WalletClient }) {
44
+ const { offramp, step, isLoading } = useOfframp();
49
45
 
50
46
  return (
51
47
  <button
52
48
  disabled={isLoading}
53
- onClick={() =>
54
- createDeposit(walletClient, {
55
- amount: "100",
56
- platform: "revolut",
57
- currency: "EUR",
58
- identifier: "alice",
59
- })
60
- }
49
+ onClick={() => offramp(walletClient, {
50
+ amount: "100",
51
+ platform: PLATFORMS.REVOLUT,
52
+ currency: CURRENCIES.EUR,
53
+ identifier: "alice",
54
+ })}
61
55
  >
62
56
  {step ?? "Sell USDC"}
63
57
  </button>
@@ -65,55 +59,54 @@ function SellButton({ walletClient }) {
65
59
  }
66
60
  ```
67
61
 
68
- ## Progress Callbacks
62
+ ## Platform & Currency Data
69
63
 
70
64
  ```typescript
71
- await offramp.createDeposit(walletClient, params, (progress) => {
72
- // progress.step: "approving" | "registering" | "depositing" | "confirming" | "delegating" | "done"
73
- // progress.txHash: available after "depositing"
74
- // progress.depositId: available after "confirming"
75
- });
65
+ import { PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
66
+
67
+ PLATFORMS.REVOLUT.name; // "Revolut"
68
+ PLATFORMS.REVOLUT.currencies; // ["USD", "EUR", "GBP", ...]
69
+ PLATFORMS.REVOLUT.identifier.label; // "Revtag"
70
+ PLATFORMS.REVOLUT.identifier.placeholder; // "revtag (no @)"
71
+ PLATFORMS.REVOLUT.identifier.help; // "Revtag without @ (must be public)"
72
+ PLATFORMS.REVOLUT.validate("@alice"); // { valid: true, normalized: "alice" }
73
+
74
+ CURRENCIES.EUR.symbol; // "€"
75
+ CURRENCIES.EUR.name; // "Euro"
76
+ CURRENCIES.EUR.countryCode; // "eu"
76
77
  ```
77
78
 
78
- ## Discovery & Validation
79
+ ## OTC Private Orders
79
80
 
80
- ```typescript
81
- import { PAYMENT_PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
81
+ Restrict a deposit to a single taker wallet. Pass `otcTaker` and the deposit is created, delegated, and restricted in one call:
82
82
 
83
- // Platforms with currencies, labels, and format requirements
84
- offramp.getPlatforms();
85
- // [{ id: "revolut", name: "Revolut", currencies: ["USD","EUR",...], identifierLabel: "Revtag", helperText: "Revtag without @", ... }]
83
+ ```typescript
84
+ import { offramp, PLATFORMS, CURRENCIES } from "@usdctofiat/offramp";
86
85
 
87
- // Currencies for a platform
88
- offramp.getCurrencies(PAYMENT_PLATFORMS.WISE);
89
- // ["USD", "EUR", "GBP", "AUD", ...]
86
+ const { depositId, otcLink } = await offramp(walletClient, {
87
+ amount: "100",
88
+ platform: PLATFORMS.REVOLUT,
89
+ currency: CURRENCIES.EUR,
90
+ identifier: "alice",
91
+ otcTaker: "0xBuyerAddress",
92
+ });
93
+ // otcLink = "https://usdctofiat.xyz/deposit/0x.../362"
94
+ // Share otcLink with the buyer — they open it, connect their wallet, and fill the order.
95
+ ```
90
96
 
91
- // Currency metadata for UI rendering
92
- offramp.getCurrencyInfo(CURRENCIES.EUR);
93
- // { code: "EUR", name: "Euro", symbol: "€", countryCode: "eu" }
97
+ Toggle OTC on existing deposits:
94
98
 
95
- offramp.getAllCurrencies();
96
- // [{ code: "AED", name: "UAE Dirham", symbol: "د.إ", countryCode: "ae" }, ...]
99
+ ```typescript
100
+ import { enableOtc, disableOtc, getOtcLink } from "@usdctofiat/offramp";
97
101
 
98
- // Validate and normalize identifiers (strips @, $, validates format)
99
- offramp.validateIdentifier(PAYMENT_PLATFORMS.REVOLUT, "@alice");
100
- // { valid: true, normalized: "alice" }
102
+ await enableOtc(walletClient, "362", "0xBuyerAddress");
103
+ await disableOtc(walletClient, "362"); // make public again
104
+ getOtcLink("362"); // just the URL, no tx
101
105
  ```
102
106
 
103
- ## Supported Platforms
104
-
105
- | Platform | Currencies | Identifier |
106
- |----------|-----------|-----------|
107
- | Revolut | 23 currencies | Revtag |
108
- | Wise | 30+ currencies | Wisetag |
109
- | PayPal | 7 currencies | Email |
110
- | Venmo | USD | Username |
111
- | Cash App | USD | Cashtag |
112
- | Zelle | USD | Email |
113
- | Monzo | GBP | Username |
114
- | N26 | EUR | IBAN |
115
- | Chime | USD | ChimeSign |
116
- | Mercado Pago | ARS | CVU |
107
+ ## Resumable
108
+
109
+ `offramp()` is idempotent. If an undelegated deposit exists for the wallet, it skips straight to delegation. Handles browser crashes, failed delegation, and retries automatically. Just call `offramp()` again.
117
110
 
118
111
  ## Error Handling
119
112
 
@@ -121,31 +114,18 @@ offramp.validateIdentifier(PAYMENT_PLATFORMS.REVOLUT, "@alice");
121
114
  import { OfframpError } from "@usdctofiat/offramp";
122
115
 
123
116
  try {
124
- await offramp.createDeposit(walletClient, params);
117
+ await offramp(walletClient, params);
125
118
  } catch (err) {
126
119
  if (err instanceof OfframpError) {
127
- console.log(err.code); // "VALIDATION" | "USER_CANCELLED" | "DEPOSIT_FAILED" | ...
128
- console.log(err.step); // Which step failed
129
- console.log(err.txHash); // Available if deposit was created on-chain
130
- console.log(err.depositId); // Available if deposit was confirmed but delegation failed
120
+ if (err.code === "USER_CANCELLED") return;
121
+ // For any failure: call offramp() again to resume
131
122
  }
132
123
  }
133
124
  ```
134
125
 
135
126
  ## How It Works
136
127
 
137
- Every deposit created through this SDK is automatically:
138
-
139
- 1. **Delegated** to the USDCtoFiat Delegate vault for rate management
140
- 2. **Market-tracking** via oracle-based pricing
141
- 3. **Auto-closing** when fully filled
142
- 4. **Attributed** to Galleon Labs via ERC-8021
143
-
144
- ## Requirements
145
-
146
- - Base network (chain ID 8453)
147
- - viem `WalletClient` with an account
148
- - USDC balance on Base
128
+ Every deposit is automatically delegated to the Delegate vault for oracle-based rate management, auto-closes when filled, and is attributed to Galleon Labs via ERC-8021.
149
129
 
150
130
  ## Links
151
131