paj_ramp 1.4.2 → 1.4.4

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.
@@ -0,0 +1,12 @@
1
+ # User credentials
2
+ USER_EMAIL=example@gmail.com
3
+
4
+ # Business API key
5
+ BUSINESS_API_KEY=your-business-api-key
6
+
7
+ # OTP received via email (add this after initiating session)
8
+ OTP=
9
+
10
+ # Token and currency details
11
+ TOKEN_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
12
+ CURRENCY=NGN
@@ -0,0 +1,145 @@
1
+ # PAJ Ramp - Utility Functions Example
2
+
3
+ This example demonstrates how to use the PAJ Ramp SDK's utility functions for converting between token amounts and fiat values.
4
+
5
+ ## Features
6
+
7
+ - **getTokenValue**: Convert token amounts to their fiat equivalent
8
+ - **getFiatValue**: Convert fiat amounts to their token equivalent
9
+ - Authentication flow (initiate & verify)
10
+
11
+ ## Prerequisites
12
+
13
+ - Node.js (v16 or higher)
14
+ - A valid PAJ Ramp business API key
15
+ - A registered email address
16
+
17
+ ## Setup
18
+
19
+ 1. **Install dependencies**:
20
+
21
+ ```bash
22
+ npm install
23
+ ```
24
+
25
+ 2. **Configure environment variables**:
26
+
27
+ ```bash
28
+ cp .env.example .env
29
+ ```
30
+
31
+ 3. **Edit `.env` file** with your credentials:
32
+ ```env
33
+ USER_EMAIL=your-email@example.com
34
+ BUSINESS_API_KEY=your-business-api-key
35
+ TOKEN_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
36
+ CURRENCY=NGN
37
+ ```
38
+
39
+ ## Running the Example
40
+
41
+ 1. **Start the example**:
42
+
43
+ ```bash
44
+ npm start
45
+ ```
46
+
47
+ 2. **Follow the prompts**:
48
+
49
+ - An OTP will be sent to your email
50
+ - Add the OTP to your `.env` file: `OTP=123456`
51
+ - Run the script again
52
+
53
+ 3. **View the results**:
54
+ - The script will display token-to-fiat conversions
55
+ - And fiat-to-token conversions
56
+
57
+ ## What This Example Does
58
+
59
+ 1. **Initializes** the PAJ Ramp SDK
60
+ 2. **Authenticates** using email and OTP verification
61
+ 3. **Fetches token value** - converts 100 tokens to fiat currency
62
+ 4. **Fetches fiat value** - converts 1000 currency units to token amount
63
+ 5. **Displays** both conversion results
64
+
65
+ ## Functions Used
66
+
67
+ ### getTokenValue
68
+
69
+ ```typescript
70
+ const tokenValueResult = await getTokenValue(
71
+ {
72
+ amount: tokenAmount,
73
+ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
74
+ currency: Currency.NGN,
75
+ },
76
+ sessionToken
77
+ );
78
+ ```
79
+
80
+ ### getFiatValue
81
+
82
+ ```typescript
83
+ const fiatValueResult = await getFiatValue(
84
+ {
85
+ amount: fiatAmount,
86
+ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
87
+ currency: Currency.NGN,
88
+ },
89
+ sessionToken
90
+ );
91
+ ```
92
+
93
+ ## Expected Output
94
+
95
+ ```
96
+ 🚀 Initializing PAJ Ramp SDK...
97
+
98
+ 📧 Initiating session...
99
+ Email: your-email@example.com
100
+ ✅ OTP sent to: your-email@example.com
101
+
102
+ 🔐 Verifying session with OTP...
103
+ ✅ Session verified successfully!
104
+
105
+ 💰 Getting token value...
106
+
107
+ ✅ Token value fetched successfully!
108
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
109
+ 📋 Token Value Details:
110
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
111
+ Token Amount: 100
112
+ Mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
113
+ Currency: NGN
114
+ Fiat Value: 150000 NGN
115
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
116
+
117
+ 💵 Getting fiat value...
118
+
119
+ ✅ Fiat value fetched successfully!
120
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
121
+ 📋 Fiat Value Details:
122
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
123
+ Fiat Amount: 1000
124
+ Mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
125
+ Currency: NGN
126
+ Fiat Value: 1000 NGN
127
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
128
+
129
+ ✨ Summary:
130
+ • 100 tokens = 150000 NGN
131
+ • 1000 NGN = 1000 (fiat equivalent)
132
+ ```
133
+
134
+ ## Troubleshooting
135
+
136
+ - **OTP not received**: Check your spam folder or contact support
137
+ - **Invalid API key**: Verify your business API key is correct
138
+ - **Connection errors**: Ensure you have internet connectivity
139
+ - **Token mint issues**: Verify the token mint address is valid on Solana
140
+
141
+ ## Next Steps
142
+
143
+ - Integrate these utility functions into your application
144
+ - Use them for price quotes before creating orders
145
+ - Display real-time conversion rates to your users
@@ -0,0 +1,125 @@
1
+ import {
2
+ initializeSDK,
3
+ initiate,
4
+ verify,
5
+ getTokenValue,
6
+ getFiatValue,
7
+ Environment,
8
+ Currency,
9
+ } from "paj_ramp";
10
+ import dotenv from "dotenv";
11
+
12
+ dotenv.config();
13
+
14
+ async function main() {
15
+ // Step 1: Initialize SDK
16
+ console.log("🚀 Initializing PAJ Ramp SDK...");
17
+ initializeSDK(Environment.Local);
18
+
19
+ const email = process.env.USER_EMAIL!;
20
+ const apiKey = process.env.BUSINESS_API_KEY!;
21
+ const mint = process.env.TOKEN_MINT!;
22
+ const currency = process.env.CURRENCY as Currency;
23
+
24
+ try {
25
+ // Step 2: Initiate session
26
+ console.log("\n📧 Initiating session...");
27
+ console.log("Email:", email);
28
+ const initiated = await initiate(email, apiKey);
29
+ console.log("✅ OTP sent to:", initiated.email || initiated.phone);
30
+
31
+ console.log(
32
+ "\n⏳ Please check your email for the OTP and add it to your .env file"
33
+ );
34
+
35
+ const otp = process.env.OTP;
36
+ if (!otp) {
37
+ console.error(
38
+ "❌ OTP not found in .env file. Please add OTP=your_otp to .env"
39
+ );
40
+ process.exit(1);
41
+ }
42
+
43
+ // Step 3: Verify session
44
+ console.log("\n🔐 Verifying session with OTP...");
45
+ const verified = await verify(
46
+ email,
47
+ otp,
48
+ {
49
+ uuid: "example-device-uuid-" + Date.now(),
50
+ device: "Desktop",
51
+ os: "MacOS",
52
+ browser: "Chrome",
53
+ },
54
+ apiKey
55
+ );
56
+ console.log("✅ Session verified successfully!");
57
+
58
+ const sessionToken = verified.token;
59
+
60
+ // Step 4: Get Token Value (convert fiat to token amount)
61
+ console.log("\n💰 Getting token value...");
62
+ const tokenAmount = 1010; // Example: 100 tokens
63
+ const tokenValueResult = await getTokenValue(
64
+ {
65
+ amount: tokenAmount,
66
+ mint,
67
+ currency,
68
+ },
69
+ sessionToken
70
+ );
71
+
72
+ console.log("\n✅ Token value fetched successfully!");
73
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
74
+ console.log("📋 Token Value Details:");
75
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
76
+ console.log("Token Amount:", tokenValueResult.amount);
77
+ console.log("Mint:", tokenValueResult.mint);
78
+ console.log("Currency:", tokenValueResult.currency);
79
+ console.log(
80
+ `Token Value: ${tokenValueResult.tokenAmount} ${tokenValueResult.currency}`
81
+ );
82
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
83
+
84
+ // Step 5: Get Fiat Value (convert token amount to fiat)
85
+ console.log("\n💵 Getting fiat value...");
86
+ const fiatAmount = 1000; // Example: 1000 NGN/USD
87
+ const fiatValueResult = await getFiatValue(
88
+ {
89
+ amount: fiatAmount,
90
+ mint,
91
+ currency,
92
+ },
93
+ sessionToken
94
+ );
95
+
96
+ console.log("\n✅ Fiat value fetched successfully!");
97
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
98
+ console.log("📋 Fiat Value Details:");
99
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
100
+ console.log("Token Amount:", fiatValueResult.amount);
101
+ console.log("Mint:", fiatValueResult.mint);
102
+ console.log("Currency:", fiatValueResult.currency);
103
+ console.log(`Fiat Value: ${fiatValueResult.fiatAmount} ${currency}`);
104
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
105
+
106
+ console.log("\n✨ Summary:");
107
+ console.log(
108
+ `• ${tokenAmount} ${currency} = ${tokenValueResult.tokenAmount} USDC`
109
+ );
110
+ console.log(
111
+ `• ${fiatAmount} USDC = ${fiatValueResult.fiatAmount} ${currency}`
112
+ );
113
+ } catch (error) {
114
+ console.error(
115
+ "\n❌ Error:",
116
+ error instanceof Error ? error.message : String(error)
117
+ );
118
+ if (error && typeof error === "object" && "response" in error) {
119
+ console.error("Response data:", (error as any).response.data);
120
+ }
121
+ process.exit(1);
122
+ }
123
+ }
124
+
125
+ main();
@@ -0,0 +1,605 @@
1
+ {
2
+ "name": "paj-utility-example",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "paj-utility-example",
9
+ "version": "1.0.0",
10
+ "dependencies": {
11
+ "dotenv": "^16.0.3"
12
+ },
13
+ "devDependencies": {
14
+ "@types/node": "^20.0.0",
15
+ "tsx": "^4.7.0",
16
+ "typescript": "^5.0.0"
17
+ }
18
+ },
19
+ "node_modules/@esbuild/aix-ppc64": {
20
+ "version": "0.27.1",
21
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.1.tgz",
22
+ "integrity": "sha512-HHB50pdsBX6k47S4u5g/CaLjqS3qwaOVE5ILsq64jyzgMhLuCuZ8rGzM9yhsAjfjkbgUPMzZEPa7DAp7yz6vuA==",
23
+ "cpu": [
24
+ "ppc64"
25
+ ],
26
+ "dev": true,
27
+ "license": "MIT",
28
+ "optional": true,
29
+ "os": [
30
+ "aix"
31
+ ],
32
+ "engines": {
33
+ "node": ">=18"
34
+ }
35
+ },
36
+ "node_modules/@esbuild/android-arm": {
37
+ "version": "0.27.1",
38
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.1.tgz",
39
+ "integrity": "sha512-kFqa6/UcaTbGm/NncN9kzVOODjhZW8e+FRdSeypWe6j33gzclHtwlANs26JrupOntlcWmB0u8+8HZo8s7thHvg==",
40
+ "cpu": [
41
+ "arm"
42
+ ],
43
+ "dev": true,
44
+ "license": "MIT",
45
+ "optional": true,
46
+ "os": [
47
+ "android"
48
+ ],
49
+ "engines": {
50
+ "node": ">=18"
51
+ }
52
+ },
53
+ "node_modules/@esbuild/android-arm64": {
54
+ "version": "0.27.1",
55
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.1.tgz",
56
+ "integrity": "sha512-45fuKmAJpxnQWixOGCrS+ro4Uvb4Re9+UTieUY2f8AEc+t7d4AaZ6eUJ3Hva7dtrxAAWHtlEFsXFMAgNnGU9uQ==",
57
+ "cpu": [
58
+ "arm64"
59
+ ],
60
+ "dev": true,
61
+ "license": "MIT",
62
+ "optional": true,
63
+ "os": [
64
+ "android"
65
+ ],
66
+ "engines": {
67
+ "node": ">=18"
68
+ }
69
+ },
70
+ "node_modules/@esbuild/android-x64": {
71
+ "version": "0.27.1",
72
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.1.tgz",
73
+ "integrity": "sha512-LBEpOz0BsgMEeHgenf5aqmn/lLNTFXVfoWMUox8CtWWYK9X4jmQzWjoGoNb8lmAYml/tQ/Ysvm8q7szu7BoxRQ==",
74
+ "cpu": [
75
+ "x64"
76
+ ],
77
+ "dev": true,
78
+ "license": "MIT",
79
+ "optional": true,
80
+ "os": [
81
+ "android"
82
+ ],
83
+ "engines": {
84
+ "node": ">=18"
85
+ }
86
+ },
87
+ "node_modules/@esbuild/darwin-arm64": {
88
+ "version": "0.27.1",
89
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.1.tgz",
90
+ "integrity": "sha512-veg7fL8eMSCVKL7IW4pxb54QERtedFDfY/ASrumK/SbFsXnRazxY4YykN/THYqFnFwJ0aVjiUrVG2PwcdAEqQQ==",
91
+ "cpu": [
92
+ "arm64"
93
+ ],
94
+ "dev": true,
95
+ "license": "MIT",
96
+ "optional": true,
97
+ "os": [
98
+ "darwin"
99
+ ],
100
+ "engines": {
101
+ "node": ">=18"
102
+ }
103
+ },
104
+ "node_modules/@esbuild/darwin-x64": {
105
+ "version": "0.27.1",
106
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.1.tgz",
107
+ "integrity": "sha512-+3ELd+nTzhfWb07Vol7EZ+5PTbJ/u74nC6iv4/lwIU99Ip5uuY6QoIf0Hn4m2HoV0qcnRivN3KSqc+FyCHjoVQ==",
108
+ "cpu": [
109
+ "x64"
110
+ ],
111
+ "dev": true,
112
+ "license": "MIT",
113
+ "optional": true,
114
+ "os": [
115
+ "darwin"
116
+ ],
117
+ "engines": {
118
+ "node": ">=18"
119
+ }
120
+ },
121
+ "node_modules/@esbuild/freebsd-arm64": {
122
+ "version": "0.27.1",
123
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.1.tgz",
124
+ "integrity": "sha512-/8Rfgns4XD9XOSXlzUDepG8PX+AVWHliYlUkFI3K3GB6tqbdjYqdhcb4BKRd7C0BhZSoaCxhv8kTcBrcZWP+xg==",
125
+ "cpu": [
126
+ "arm64"
127
+ ],
128
+ "dev": true,
129
+ "license": "MIT",
130
+ "optional": true,
131
+ "os": [
132
+ "freebsd"
133
+ ],
134
+ "engines": {
135
+ "node": ">=18"
136
+ }
137
+ },
138
+ "node_modules/@esbuild/freebsd-x64": {
139
+ "version": "0.27.1",
140
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.1.tgz",
141
+ "integrity": "sha512-GITpD8dK9C+r+5yRT/UKVT36h/DQLOHdwGVwwoHidlnA168oD3uxA878XloXebK4Ul3gDBBIvEdL7go9gCUFzQ==",
142
+ "cpu": [
143
+ "x64"
144
+ ],
145
+ "dev": true,
146
+ "license": "MIT",
147
+ "optional": true,
148
+ "os": [
149
+ "freebsd"
150
+ ],
151
+ "engines": {
152
+ "node": ">=18"
153
+ }
154
+ },
155
+ "node_modules/@esbuild/linux-arm": {
156
+ "version": "0.27.1",
157
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.1.tgz",
158
+ "integrity": "sha512-ieMID0JRZY/ZeCrsFQ3Y3NlHNCqIhTprJfDgSB3/lv5jJZ8FX3hqPyXWhe+gvS5ARMBJ242PM+VNz/ctNj//eA==",
159
+ "cpu": [
160
+ "arm"
161
+ ],
162
+ "dev": true,
163
+ "license": "MIT",
164
+ "optional": true,
165
+ "os": [
166
+ "linux"
167
+ ],
168
+ "engines": {
169
+ "node": ">=18"
170
+ }
171
+ },
172
+ "node_modules/@esbuild/linux-arm64": {
173
+ "version": "0.27.1",
174
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.1.tgz",
175
+ "integrity": "sha512-W9//kCrh/6in9rWIBdKaMtuTTzNj6jSeG/haWBADqLLa9P8O5YSRDzgD5y9QBok4AYlzS6ARHifAb75V6G670Q==",
176
+ "cpu": [
177
+ "arm64"
178
+ ],
179
+ "dev": true,
180
+ "license": "MIT",
181
+ "optional": true,
182
+ "os": [
183
+ "linux"
184
+ ],
185
+ "engines": {
186
+ "node": ">=18"
187
+ }
188
+ },
189
+ "node_modules/@esbuild/linux-ia32": {
190
+ "version": "0.27.1",
191
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.1.tgz",
192
+ "integrity": "sha512-VIUV4z8GD8rtSVMfAj1aXFahsi/+tcoXXNYmXgzISL+KB381vbSTNdeZHHHIYqFyXcoEhu9n5cT+05tRv13rlw==",
193
+ "cpu": [
194
+ "ia32"
195
+ ],
196
+ "dev": true,
197
+ "license": "MIT",
198
+ "optional": true,
199
+ "os": [
200
+ "linux"
201
+ ],
202
+ "engines": {
203
+ "node": ">=18"
204
+ }
205
+ },
206
+ "node_modules/@esbuild/linux-loong64": {
207
+ "version": "0.27.1",
208
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.1.tgz",
209
+ "integrity": "sha512-l4rfiiJRN7sTNI//ff65zJ9z8U+k6zcCg0LALU5iEWzY+a1mVZ8iWC1k5EsNKThZ7XCQ6YWtsZ8EWYm7r1UEsg==",
210
+ "cpu": [
211
+ "loong64"
212
+ ],
213
+ "dev": true,
214
+ "license": "MIT",
215
+ "optional": true,
216
+ "os": [
217
+ "linux"
218
+ ],
219
+ "engines": {
220
+ "node": ">=18"
221
+ }
222
+ },
223
+ "node_modules/@esbuild/linux-mips64el": {
224
+ "version": "0.27.1",
225
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.1.tgz",
226
+ "integrity": "sha512-U0bEuAOLvO/DWFdygTHWY8C067FXz+UbzKgxYhXC0fDieFa0kDIra1FAhsAARRJbvEyso8aAqvPdNxzWuStBnA==",
227
+ "cpu": [
228
+ "mips64el"
229
+ ],
230
+ "dev": true,
231
+ "license": "MIT",
232
+ "optional": true,
233
+ "os": [
234
+ "linux"
235
+ ],
236
+ "engines": {
237
+ "node": ">=18"
238
+ }
239
+ },
240
+ "node_modules/@esbuild/linux-ppc64": {
241
+ "version": "0.27.1",
242
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.1.tgz",
243
+ "integrity": "sha512-NzdQ/Xwu6vPSf/GkdmRNsOfIeSGnh7muundsWItmBsVpMoNPVpM61qNzAVY3pZ1glzzAxLR40UyYM23eaDDbYQ==",
244
+ "cpu": [
245
+ "ppc64"
246
+ ],
247
+ "dev": true,
248
+ "license": "MIT",
249
+ "optional": true,
250
+ "os": [
251
+ "linux"
252
+ ],
253
+ "engines": {
254
+ "node": ">=18"
255
+ }
256
+ },
257
+ "node_modules/@esbuild/linux-riscv64": {
258
+ "version": "0.27.1",
259
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.1.tgz",
260
+ "integrity": "sha512-7zlw8p3IApcsN7mFw0O1Z1PyEk6PlKMu18roImfl3iQHTnr/yAfYv6s4hXPidbDoI2Q0pW+5xeoM4eTCC0UdrQ==",
261
+ "cpu": [
262
+ "riscv64"
263
+ ],
264
+ "dev": true,
265
+ "license": "MIT",
266
+ "optional": true,
267
+ "os": [
268
+ "linux"
269
+ ],
270
+ "engines": {
271
+ "node": ">=18"
272
+ }
273
+ },
274
+ "node_modules/@esbuild/linux-s390x": {
275
+ "version": "0.27.1",
276
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.1.tgz",
277
+ "integrity": "sha512-cGj5wli+G+nkVQdZo3+7FDKC25Uh4ZVwOAK6A06Hsvgr8WqBBuOy/1s+PUEd/6Je+vjfm6stX0kmib5b/O2Ykw==",
278
+ "cpu": [
279
+ "s390x"
280
+ ],
281
+ "dev": true,
282
+ "license": "MIT",
283
+ "optional": true,
284
+ "os": [
285
+ "linux"
286
+ ],
287
+ "engines": {
288
+ "node": ">=18"
289
+ }
290
+ },
291
+ "node_modules/@esbuild/linux-x64": {
292
+ "version": "0.27.1",
293
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.1.tgz",
294
+ "integrity": "sha512-z3H/HYI9MM0HTv3hQZ81f+AKb+yEoCRlUby1F80vbQ5XdzEMyY/9iNlAmhqiBKw4MJXwfgsh7ERGEOhrM1niMA==",
295
+ "cpu": [
296
+ "x64"
297
+ ],
298
+ "dev": true,
299
+ "license": "MIT",
300
+ "optional": true,
301
+ "os": [
302
+ "linux"
303
+ ],
304
+ "engines": {
305
+ "node": ">=18"
306
+ }
307
+ },
308
+ "node_modules/@esbuild/netbsd-arm64": {
309
+ "version": "0.27.1",
310
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.1.tgz",
311
+ "integrity": "sha512-wzC24DxAvk8Em01YmVXyjl96Mr+ecTPyOuADAvjGg+fyBpGmxmcr2E5ttf7Im8D0sXZihpxzO1isus8MdjMCXQ==",
312
+ "cpu": [
313
+ "arm64"
314
+ ],
315
+ "dev": true,
316
+ "license": "MIT",
317
+ "optional": true,
318
+ "os": [
319
+ "netbsd"
320
+ ],
321
+ "engines": {
322
+ "node": ">=18"
323
+ }
324
+ },
325
+ "node_modules/@esbuild/netbsd-x64": {
326
+ "version": "0.27.1",
327
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.1.tgz",
328
+ "integrity": "sha512-1YQ8ybGi2yIXswu6eNzJsrYIGFpnlzEWRl6iR5gMgmsrR0FcNoV1m9k9sc3PuP5rUBLshOZylc9nqSgymI+TYg==",
329
+ "cpu": [
330
+ "x64"
331
+ ],
332
+ "dev": true,
333
+ "license": "MIT",
334
+ "optional": true,
335
+ "os": [
336
+ "netbsd"
337
+ ],
338
+ "engines": {
339
+ "node": ">=18"
340
+ }
341
+ },
342
+ "node_modules/@esbuild/openbsd-arm64": {
343
+ "version": "0.27.1",
344
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.1.tgz",
345
+ "integrity": "sha512-5Z+DzLCrq5wmU7RDaMDe2DVXMRm2tTDvX2KU14JJVBN2CT/qov7XVix85QoJqHltpvAOZUAc3ndU56HSMWrv8g==",
346
+ "cpu": [
347
+ "arm64"
348
+ ],
349
+ "dev": true,
350
+ "license": "MIT",
351
+ "optional": true,
352
+ "os": [
353
+ "openbsd"
354
+ ],
355
+ "engines": {
356
+ "node": ">=18"
357
+ }
358
+ },
359
+ "node_modules/@esbuild/openbsd-x64": {
360
+ "version": "0.27.1",
361
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.1.tgz",
362
+ "integrity": "sha512-Q73ENzIdPF5jap4wqLtsfh8YbYSZ8Q0wnxplOlZUOyZy7B4ZKW8DXGWgTCZmF8VWD7Tciwv5F4NsRf6vYlZtqg==",
363
+ "cpu": [
364
+ "x64"
365
+ ],
366
+ "dev": true,
367
+ "license": "MIT",
368
+ "optional": true,
369
+ "os": [
370
+ "openbsd"
371
+ ],
372
+ "engines": {
373
+ "node": ">=18"
374
+ }
375
+ },
376
+ "node_modules/@esbuild/openharmony-arm64": {
377
+ "version": "0.27.1",
378
+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.1.tgz",
379
+ "integrity": "sha512-ajbHrGM/XiK+sXM0JzEbJAen+0E+JMQZ2l4RR4VFwvV9JEERx+oxtgkpoKv1SevhjavK2z2ReHk32pjzktWbGg==",
380
+ "cpu": [
381
+ "arm64"
382
+ ],
383
+ "dev": true,
384
+ "license": "MIT",
385
+ "optional": true,
386
+ "os": [
387
+ "openharmony"
388
+ ],
389
+ "engines": {
390
+ "node": ">=18"
391
+ }
392
+ },
393
+ "node_modules/@esbuild/sunos-x64": {
394
+ "version": "0.27.1",
395
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.1.tgz",
396
+ "integrity": "sha512-IPUW+y4VIjuDVn+OMzHc5FV4GubIwPnsz6ubkvN8cuhEqH81NovB53IUlrlBkPMEPxvNnf79MGBoz8rZ2iW8HA==",
397
+ "cpu": [
398
+ "x64"
399
+ ],
400
+ "dev": true,
401
+ "license": "MIT",
402
+ "optional": true,
403
+ "os": [
404
+ "sunos"
405
+ ],
406
+ "engines": {
407
+ "node": ">=18"
408
+ }
409
+ },
410
+ "node_modules/@esbuild/win32-arm64": {
411
+ "version": "0.27.1",
412
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.1.tgz",
413
+ "integrity": "sha512-RIVRWiljWA6CdVu8zkWcRmGP7iRRIIwvhDKem8UMBjPql2TXM5PkDVvvrzMtj1V+WFPB4K7zkIGM7VzRtFkjdg==",
414
+ "cpu": [
415
+ "arm64"
416
+ ],
417
+ "dev": true,
418
+ "license": "MIT",
419
+ "optional": true,
420
+ "os": [
421
+ "win32"
422
+ ],
423
+ "engines": {
424
+ "node": ">=18"
425
+ }
426
+ },
427
+ "node_modules/@esbuild/win32-ia32": {
428
+ "version": "0.27.1",
429
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.1.tgz",
430
+ "integrity": "sha512-2BR5M8CPbptC1AK5JbJT1fWrHLvejwZidKx3UMSF0ecHMa+smhi16drIrCEggkgviBwLYd5nwrFLSl5Kho96RQ==",
431
+ "cpu": [
432
+ "ia32"
433
+ ],
434
+ "dev": true,
435
+ "license": "MIT",
436
+ "optional": true,
437
+ "os": [
438
+ "win32"
439
+ ],
440
+ "engines": {
441
+ "node": ">=18"
442
+ }
443
+ },
444
+ "node_modules/@esbuild/win32-x64": {
445
+ "version": "0.27.1",
446
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.1.tgz",
447
+ "integrity": "sha512-d5X6RMYv6taIymSk8JBP+nxv8DQAMY6A51GPgusqLdK9wBz5wWIXy1KjTck6HnjE9hqJzJRdk+1p/t5soSbCtw==",
448
+ "cpu": [
449
+ "x64"
450
+ ],
451
+ "dev": true,
452
+ "license": "MIT",
453
+ "optional": true,
454
+ "os": [
455
+ "win32"
456
+ ],
457
+ "engines": {
458
+ "node": ">=18"
459
+ }
460
+ },
461
+ "node_modules/@types/node": {
462
+ "version": "20.19.25",
463
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
464
+ "integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
465
+ "dev": true,
466
+ "license": "MIT",
467
+ "dependencies": {
468
+ "undici-types": "~6.21.0"
469
+ }
470
+ },
471
+ "node_modules/dotenv": {
472
+ "version": "16.6.1",
473
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
474
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
475
+ "license": "BSD-2-Clause",
476
+ "engines": {
477
+ "node": ">=12"
478
+ },
479
+ "funding": {
480
+ "url": "https://dotenvx.com"
481
+ }
482
+ },
483
+ "node_modules/esbuild": {
484
+ "version": "0.27.1",
485
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.1.tgz",
486
+ "integrity": "sha512-yY35KZckJJuVVPXpvjgxiCuVEJT67F6zDeVTv4rizyPrfGBUpZQsvmxnN+C371c2esD/hNMjj4tpBhuueLN7aA==",
487
+ "dev": true,
488
+ "hasInstallScript": true,
489
+ "license": "MIT",
490
+ "bin": {
491
+ "esbuild": "bin/esbuild"
492
+ },
493
+ "engines": {
494
+ "node": ">=18"
495
+ },
496
+ "optionalDependencies": {
497
+ "@esbuild/aix-ppc64": "0.27.1",
498
+ "@esbuild/android-arm": "0.27.1",
499
+ "@esbuild/android-arm64": "0.27.1",
500
+ "@esbuild/android-x64": "0.27.1",
501
+ "@esbuild/darwin-arm64": "0.27.1",
502
+ "@esbuild/darwin-x64": "0.27.1",
503
+ "@esbuild/freebsd-arm64": "0.27.1",
504
+ "@esbuild/freebsd-x64": "0.27.1",
505
+ "@esbuild/linux-arm": "0.27.1",
506
+ "@esbuild/linux-arm64": "0.27.1",
507
+ "@esbuild/linux-ia32": "0.27.1",
508
+ "@esbuild/linux-loong64": "0.27.1",
509
+ "@esbuild/linux-mips64el": "0.27.1",
510
+ "@esbuild/linux-ppc64": "0.27.1",
511
+ "@esbuild/linux-riscv64": "0.27.1",
512
+ "@esbuild/linux-s390x": "0.27.1",
513
+ "@esbuild/linux-x64": "0.27.1",
514
+ "@esbuild/netbsd-arm64": "0.27.1",
515
+ "@esbuild/netbsd-x64": "0.27.1",
516
+ "@esbuild/openbsd-arm64": "0.27.1",
517
+ "@esbuild/openbsd-x64": "0.27.1",
518
+ "@esbuild/openharmony-arm64": "0.27.1",
519
+ "@esbuild/sunos-x64": "0.27.1",
520
+ "@esbuild/win32-arm64": "0.27.1",
521
+ "@esbuild/win32-ia32": "0.27.1",
522
+ "@esbuild/win32-x64": "0.27.1"
523
+ }
524
+ },
525
+ "node_modules/fsevents": {
526
+ "version": "2.3.3",
527
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
528
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
529
+ "dev": true,
530
+ "hasInstallScript": true,
531
+ "license": "MIT",
532
+ "optional": true,
533
+ "os": [
534
+ "darwin"
535
+ ],
536
+ "engines": {
537
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
538
+ }
539
+ },
540
+ "node_modules/get-tsconfig": {
541
+ "version": "4.13.0",
542
+ "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz",
543
+ "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==",
544
+ "dev": true,
545
+ "license": "MIT",
546
+ "dependencies": {
547
+ "resolve-pkg-maps": "^1.0.0"
548
+ },
549
+ "funding": {
550
+ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
551
+ }
552
+ },
553
+ "node_modules/resolve-pkg-maps": {
554
+ "version": "1.0.0",
555
+ "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
556
+ "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
557
+ "dev": true,
558
+ "license": "MIT",
559
+ "funding": {
560
+ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
561
+ }
562
+ },
563
+ "node_modules/tsx": {
564
+ "version": "4.21.0",
565
+ "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz",
566
+ "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==",
567
+ "dev": true,
568
+ "license": "MIT",
569
+ "dependencies": {
570
+ "esbuild": "~0.27.0",
571
+ "get-tsconfig": "^4.7.5"
572
+ },
573
+ "bin": {
574
+ "tsx": "dist/cli.mjs"
575
+ },
576
+ "engines": {
577
+ "node": ">=18.0.0"
578
+ },
579
+ "optionalDependencies": {
580
+ "fsevents": "~2.3.3"
581
+ }
582
+ },
583
+ "node_modules/typescript": {
584
+ "version": "5.9.3",
585
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
586
+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
587
+ "dev": true,
588
+ "license": "Apache-2.0",
589
+ "bin": {
590
+ "tsc": "bin/tsc",
591
+ "tsserver": "bin/tsserver"
592
+ },
593
+ "engines": {
594
+ "node": ">=14.17"
595
+ }
596
+ },
597
+ "node_modules/undici-types": {
598
+ "version": "6.21.0",
599
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
600
+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
601
+ "dev": true,
602
+ "license": "MIT"
603
+ }
604
+ }
605
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "paj-utility-example",
3
+ "version": "1.0.0",
4
+ "description": "Example demonstrating PAJ Ramp utility functions for value conversion",
5
+ "main": "index.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "tsx index.ts",
9
+ "dev": "tsx watch index.ts"
10
+ },
11
+ "keywords": [
12
+ "paj",
13
+ "ramp",
14
+ "utility",
15
+ "value",
16
+ "conversion"
17
+ ],
18
+ "dependencies": {
19
+ "dotenv": "^16.0.3"
20
+ },
21
+ "devDependencies": {
22
+ "tsx": "^4.7.0",
23
+ "@types/node": "^20.0.0",
24
+ "typescript": "^5.0.0"
25
+ }
26
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "esModuleInterop": true,
7
+ "skipLibCheck": true,
8
+ "strict": true,
9
+ "resolveJsonModule": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "forceConsistentCasingInFileNames": true
12
+ },
13
+ "include": ["index.ts"],
14
+ "exclude": ["node_modules"]
15
+ }
@@ -0,0 +1,22 @@
1
+ import { get } from "../../../utils/api";
2
+ import { Currency } from "../../../utils/enums";
3
+
4
+ interface ValueQuery {
5
+ amount: number;
6
+ mint: string;
7
+ currency: Currency;
8
+ }
9
+
10
+ export interface FiatValue extends ValueQuery {
11
+ fiatAmount: number;
12
+ }
13
+
14
+ export async function getFiatValue(query: ValueQuery, sessionToken: string) {
15
+ try {
16
+ return await get<FiatValue>("/pub/rates/fiat-value", query, {
17
+ Authorization: `Bearer ${sessionToken}`,
18
+ });
19
+ } catch (err) {
20
+ throw err;
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ import { get } from "../../../utils/api";
2
+ import { Currency } from "../../../utils/enums";
3
+
4
+ interface ValueQuery {
5
+ amount: number;
6
+ mint: string;
7
+ currency: Currency;
8
+ }
9
+
10
+ export interface TokenValue extends ValueQuery {
11
+ tokenAmount: number;
12
+ }
13
+
14
+ export async function getTokenValue(query: ValueQuery, sessionToken: string) {
15
+ try {
16
+ return await get<TokenValue>("/pub/rates/token-value", query, {
17
+ Authorization: `Bearer ${sessionToken}`,
18
+ });
19
+ } catch (err) {
20
+ throw err;
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "paj offramp/onramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",
package/sdk.ts CHANGED
@@ -24,7 +24,11 @@ export { verify } from "./lib/utility/session/verify.js";
24
24
  export { getAllRate } from "./lib/utility/rate/getAllRate.js";
25
25
  export { getRateByAmount } from "./lib/utility/rate/getRateByAmount.js";
26
26
  export { getRateByType } from "./lib/utility/rate/getRateByType.js";
27
- export { getTokenValue } from "./lib/utility/rate/getTokenValue.js";
27
+ export {
28
+ getTokenValue,
29
+ TokenValue,
30
+ } from "./lib/utility/value/getTokenValue.js";
31
+ export { getFiatValue, FiatValue } from "./lib/utility/value/getFiatValue.js";
28
32
 
29
33
  // Banking Operations
30
34
  export { getBanks } from "./lib/utility/bank/getBanks.js";