paj_ramp 1.2.7 → 1.2.9

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
@@ -60,9 +60,9 @@ const verified = await verify(
60
60
  **_Get All Rate_**
61
61
 
62
62
  ```typescript
63
- import { getRate } from 'paj_ramp';
63
+ import { getAllRate } from 'paj_ramp';
64
64
 
65
- const rate = await getRate();
65
+ const rate = await getAllRate();
66
66
  /*
67
67
  Response:
68
68
  {
@@ -86,9 +86,9 @@ Response:
86
86
  **_Get Rate by Amount_**
87
87
 
88
88
  ```typescript
89
- import { getRate } from 'paj_ramp';
89
+ import { getRateByAmount } from 'paj_ramp';
90
90
 
91
- const rate = await getRate(50000);
91
+ const rate = await getRateByAmount(50000);
92
92
  /*
93
93
  Response:
94
94
  {
@@ -109,9 +109,9 @@ Response:
109
109
  **_Get Rate by Rate Type_**
110
110
 
111
111
  ```typescript
112
- import { getRate, RateType } from 'paj_ramp';
112
+ import { getRateByType, RateType } from 'paj_ramp';
113
113
 
114
- const rate = await getRate(RateType.offRamp); // or RateType.onRamp
114
+ const rate = await getRateByType(RateType.offRamp); // or RateType.onRamp
115
115
 
116
116
  /*
117
117
  Response:
@@ -127,9 +127,9 @@ Response:
127
127
  **_Get Token Value from Amount and Mint Token_**
128
128
 
129
129
  ```typescript
130
- import { getRate } from 'paj_ramp';
130
+ import { getTokenValue } from 'paj_ramp';
131
131
 
132
- const tokenValue = await getRate(50000, 'token_mint_address');
132
+ const tokenValue = await getTokenValue(50000, 'token_mint_address');
133
133
  /*
134
134
  Response:
135
135
  {
@@ -0,0 +1,27 @@
1
+ type AllRateResponseType = {
2
+ onRampRate: {
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ isActive: boolean;
6
+ rate: number;
7
+ type: string;
8
+ };
9
+ offRampRate: {
10
+ baseCurrency: string;
11
+ targetCurrency: string;
12
+ isActive: boolean;
13
+ rate: number;
14
+ type: string;
15
+ };
16
+ };
17
+ /**
18
+ * This TypeScript function asynchronously fetches all rates from a specified URL and handles any
19
+ * errors that may occur.
20
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
21
+ * function call, which is fetching rate data from the specified URL '/pub/rate'. The function is using
22
+ * async/await syntax to handle asynchronous operations and is catching any errors that occur during
23
+ * the fetch operation. If successful, the function will return the rate data, and if an error occurs,
24
+ * it
25
+ */
26
+ export declare const getAllRate: () => Promise<AllRateResponseType>;
27
+ export {};
@@ -0,0 +1,20 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * This TypeScript function asynchronously fetches all rates from a specified URL and handles any
4
+ * errors that may occur.
5
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
6
+ * function call, which is fetching rate data from the specified URL '/pub/rate'. The function is using
7
+ * async/await syntax to handle asynchronous operations and is catching any errors that occur during
8
+ * the fetch operation. If successful, the function will return the rate data, and if an error occurs,
9
+ * it
10
+ */
11
+ export const getAllRate = async () => {
12
+ const url = '/pub/rate';
13
+ try {
14
+ return await get(url);
15
+ }
16
+ catch (err) {
17
+ console.error('Error fetching Rate:', err);
18
+ throw err;
19
+ }
20
+ };
@@ -54,7 +54,10 @@ export declare enum RateType {
54
54
  * @returns The `getRate` function returns different values based on the conditions inside the
55
55
  * function:
56
56
  */
57
- export declare const getRate: (param: number | RateType, mint_token?: string) => Promise<AllRateResponseType | RateByAmountType | RateByRateTypeType | TokenValueType | undefined>;
57
+ export declare function getRate(): Promise<AllRateResponseType>;
58
+ export declare function getRate(param: number, mint_token: string): Promise<TokenValueType>;
59
+ export declare function getRate(param: number): Promise<RateByAmountType>;
60
+ export declare function getRate(param: RateType): Promise<RateByRateTypeType>;
58
61
  /**
59
62
  * The function `getAllRate` fetches all rates from a specified URL and handles any errors that occur
60
63
  * during the process.
@@ -4,18 +4,7 @@ export var RateType;
4
4
  RateType["onRamp"] = "onRamp";
5
5
  RateType["offRamp"] = "offRamp";
6
6
  })(RateType || (RateType = {}));
7
- /**
8
- * The function `getRate` in TypeScript is an asynchronous function that retrieves rate information
9
- * based on different parameters such as amount, rate type, and mint token.
10
- * @param {number | RateType} param - The `param` parameter in the `getRate` function can be either a
11
- * number or a `RateType`.
12
- * @param {string} [mint_token] - The `mint_token` parameter is an optional string parameter that
13
- * represents a token used for minting. It is used in the `getRate` function to calculate the rate
14
- * based on the specified token value.
15
- * @returns The `getRate` function returns different values based on the conditions inside the
16
- * function:
17
- */
18
- export const getRate = async (param, mint_token) => {
7
+ export async function getRate(param, mint_token) {
19
8
  try {
20
9
  const url = '/pub/rate';
21
10
  if (!param) {
@@ -34,7 +23,7 @@ export const getRate = async (param, mint_token) => {
34
23
  console.error('Error fetching Rate:', err);
35
24
  throw err;
36
25
  }
37
- };
26
+ }
38
27
  /**
39
28
  * The function `getAllRate` fetches all rates from a specified URL and handles any errors that occur
40
29
  * during the process.
@@ -0,0 +1,27 @@
1
+ type RateByAmountType = {
2
+ rate: {
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ rate: number;
6
+ };
7
+ amounts: {
8
+ userTax: number;
9
+ merchantTax: number;
10
+ amountUSD: number;
11
+ userAmountFiat: number;
12
+ };
13
+ };
14
+ /**
15
+ * The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
16
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
17
+ * representing the amount for which you want to retrieve the rate. This function makes an asynchronous
18
+ * request to the `/pub/rate` endpoint with the specified amount to fetch the rate information. If
19
+ * successful, it returns the rate
20
+ * @returns The `getRateByAmount` function is returning a Promise that resolves to the rate for a
21
+ * specific amount. The rate is fetched from the specified URL endpoint `/pub/rate` with the provided
22
+ * amount as a parameter. If the rate is successfully fetched, it will be returned. If there is an
23
+ * error during the fetching process, an error message will be logged to the console and the error will
24
+ * be
25
+ */
26
+ export declare const getRateByAmount: (amount: number) => Promise<RateByAmountType>;
27
+ export {};
@@ -0,0 +1,23 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
4
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
5
+ * representing the amount for which you want to retrieve the rate. This function makes an asynchronous
6
+ * request to the `/pub/rate` endpoint with the specified amount to fetch the rate information. If
7
+ * successful, it returns the rate
8
+ * @returns The `getRateByAmount` function is returning a Promise that resolves to the rate for a
9
+ * specific amount. The rate is fetched from the specified URL endpoint `/pub/rate` with the provided
10
+ * amount as a parameter. If the rate is successfully fetched, it will be returned. If there is an
11
+ * error during the fetching process, an error message will be logged to the console and the error will
12
+ * be
13
+ */
14
+ export const getRateByAmount = async (amount) => {
15
+ const url = '/pub/rate';
16
+ try {
17
+ return await get(`${url}/${amount}`);
18
+ }
19
+ catch (err) {
20
+ console.error('Error fetching Rate by Amount:', err);
21
+ throw err;
22
+ }
23
+ };
@@ -0,0 +1,21 @@
1
+ type RateByType = {
2
+ baseCurrency: string;
3
+ targetCurrency: string;
4
+ isActive: true;
5
+ rate: number;
6
+ type: string;
7
+ };
8
+ export declare enum RateType {
9
+ onRamp = "onRamp",
10
+ offRamp = "offRamp"
11
+ }
12
+ /**
13
+ * This function fetches a rate based on a specified rate type asynchronously.
14
+ * @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
15
+ * such as 'standard', 'premium', 'discount', etc.
16
+ * @returns The `getRateByType` function is returning a Promise that resolves to a `RateByType` object
17
+ * fetched from the specified URL based on the `rateType` parameter. If an error occurs during the
18
+ * fetching process, the function will log an error message and rethrow the error.
19
+ */
20
+ export declare const getRateByType: (rateType: RateType) => Promise<RateByType>;
21
+ export {};
@@ -0,0 +1,24 @@
1
+ import { get } from '../../utils/api.js';
2
+ export var RateType;
3
+ (function (RateType) {
4
+ RateType["onRamp"] = "onRamp";
5
+ RateType["offRamp"] = "offRamp";
6
+ })(RateType || (RateType = {}));
7
+ /**
8
+ * This function fetches a rate based on a specified rate type asynchronously.
9
+ * @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
10
+ * such as 'standard', 'premium', 'discount', etc.
11
+ * @returns The `getRateByType` function is returning a Promise that resolves to a `RateByType` object
12
+ * fetched from the specified URL based on the `rateType` parameter. If an error occurs during the
13
+ * fetching process, the function will log an error message and rethrow the error.
14
+ */
15
+ export const getRateByType = async (rateType) => {
16
+ const url = '/pub/rate';
17
+ try {
18
+ return await get(`${url}/${rateType}`);
19
+ }
20
+ catch (err) {
21
+ console.error('Error fetching Rate by Rate Type:', err);
22
+ throw err;
23
+ }
24
+ };
@@ -0,0 +1,20 @@
1
+ type TokenValueType = {
2
+ amount: number;
3
+ usdcValue: number;
4
+ mint: string;
5
+ };
6
+ /**
7
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the specified
8
+ * amount and token mint.
9
+ * @param {number} amount - The `amount` parameter is a number representing the quantity of tokens for
10
+ * which you want to retrieve the value.
11
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
12
+ * the unique identifier for a specific token. It is used to specify which token you are interested in
13
+ * when fetching its value.
14
+ * @returns The `getTokenValue` function is returning the result of the `get` function call with the
15
+ * URL `/value?amount=&mint=` as its argument. The `get` function is likely
16
+ * making an HTTP request to fetch the token value based on the provided amount and mint token. If
17
+ * successful, the function will return the token value. If there is an error during
18
+ */
19
+ export declare const getTokenValue: (amount: number, mint_token: string) => Promise<TokenValueType>;
20
+ export {};
@@ -0,0 +1,24 @@
1
+ import { get } from '../../utils/api.js';
2
+ /**
3
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the specified
4
+ * amount and token mint.
5
+ * @param {number} amount - The `amount` parameter is a number representing the quantity of tokens for
6
+ * which you want to retrieve the value.
7
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
8
+ * the unique identifier for a specific token. It is used to specify which token you are interested in
9
+ * when fetching its value.
10
+ * @returns The `getTokenValue` function is returning the result of the `get` function call with the
11
+ * URL `/value?amount=&mint=` as its argument. The `get` function is likely
12
+ * making an HTTP request to fetch the token value based on the provided amount and mint token. If
13
+ * successful, the function will return the token value. If there is an error during
14
+ */
15
+ export const getTokenValue = async (amount, mint_token) => {
16
+ const url = '/pub/rate';
17
+ try {
18
+ return await get(`${url}/value?amount=${amount}&mint=${mint_token}`);
19
+ }
20
+ catch (err) {
21
+ console.log('Error fetching Token Value:', err);
22
+ throw err;
23
+ }
24
+ };
@@ -7,5 +7,12 @@ type CreateOrderType = {
7
7
  webhookURL: string;
8
8
  token?: string;
9
9
  };
10
- export declare const createOrder: (options: CreateOrderType) => Promise<CreateOrderType>;
10
+ type CreateOrderResponseType = {
11
+ id: string;
12
+ accountNumber: string;
13
+ accountName: string;
14
+ amount: number;
15
+ bank: string;
16
+ };
17
+ export declare const createOrder: (options: CreateOrderType) => Promise<CreateOrderResponseType>;
11
18
  export {};
@@ -1,20 +1,20 @@
1
- import { post } from "../../utils/api.js";
1
+ import { post } from '../../utils/api.js';
2
2
  export const createOrder = async (options) => {
3
3
  const { fiatAmount, currency, recipient, mint, chain, webhookURL, token } = options;
4
4
  try {
5
- return await post("/pub/onramp", {
5
+ return await post('/pub/onramp', {
6
6
  fiatAmount,
7
7
  currency,
8
8
  recipient,
9
9
  mint,
10
10
  chain,
11
- webhookURL
11
+ webhookURL,
12
12
  }, {
13
13
  Authorization: `Bearer ${token}`,
14
14
  });
15
15
  }
16
16
  catch (err) {
17
- console.error("Error creating order:", err);
17
+ console.error('Error creating order:', err);
18
18
  throw err;
19
19
  }
20
20
  };
package/dist/sdk.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export declare const initializeSDK: (env: "staging" | "production") => void;
2
- export { getRate } from './lib/off_ramp/getRate.js';
2
+ export { getAllRate } from './lib/off_ramp/getAllRate.js';
3
+ export { getRateByAmount } from './lib/off_ramp/getRateByAmount.js';
4
+ export { getRateByType } from './lib/off_ramp/getRateByType.js';
5
+ export { getTokenValue } from './lib/off_ramp/getTokenValue.js';
3
6
  export { initiate } from './lib/off_ramp/initiate.js';
4
7
  export { verify } from './lib/off_ramp/verify.js';
5
- export { getBanks } from "./lib/off_ramp/getBanks.js";
6
- export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
7
- export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
8
- export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
8
+ export { getBanks } from './lib/off_ramp/getBanks.js';
9
+ export { resolveBankAccount } from './lib/off_ramp/resolveBankAccount.js';
10
+ export { addBankAccount } from './lib/off_ramp/addBankAccount.js';
11
+ export { getBankAccounts } from './lib/off_ramp/getBankAccounts.js';
9
12
  export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
10
13
  export { createOrder } from './lib/on_ramp/createOrder.js';
11
- export { observeOrder } from './lib/on_ramp/observeOrder.js';
12
- export { RateType } from './lib/off_ramp/getRate.js';
14
+ export { RateType } from './lib/off_ramp/getRateByType.js';
package/dist/sdk.js CHANGED
@@ -12,15 +12,18 @@ export const initializeSDK = (env) => {
12
12
  // OFF RAMP
13
13
  // Wallet Info
14
14
  // export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
15
- export { getRate } from './lib/off_ramp/getRate.js';
15
+ export { getAllRate } from './lib/off_ramp/getAllRate.js';
16
+ export { getRateByAmount } from './lib/off_ramp/getRateByAmount.js';
17
+ export { getRateByType } from './lib/off_ramp/getRateByType.js';
18
+ export { getTokenValue } from './lib/off_ramp/getTokenValue.js';
16
19
  // Session Management
17
20
  export { initiate } from './lib/off_ramp/initiate.js';
18
21
  export { verify } from './lib/off_ramp/verify.js';
19
22
  // // Banking Operations
20
- export { getBanks } from "./lib/off_ramp/getBanks.js";
21
- export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
22
- export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
23
- export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
23
+ export { getBanks } from './lib/off_ramp/getBanks.js';
24
+ export { resolveBankAccount } from './lib/off_ramp/resolveBankAccount.js';
25
+ export { addBankAccount } from './lib/off_ramp/addBankAccount.js';
26
+ export { getBankAccounts } from './lib/off_ramp/getBankAccounts.js';
24
27
  // Wallet Operations
25
28
  // export { getWallet } from './lib/off_ramp/getWallet.js';
26
29
  // export { addWallet } from './lib/off_ramp/addWallet.js';
@@ -31,6 +34,6 @@ export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
31
34
  // Create Order
32
35
  export { createOrder } from './lib/on_ramp/createOrder.js';
33
36
  // Observe Order Socket.IO
34
- export { observeOrder } from './lib/on_ramp/observeOrder.js';
37
+ // export { observeOrder } from './lib/on_ramp/observeOrder.js';
35
38
  // Types
36
- export { RateType } from './lib/off_ramp/getRate.js';
39
+ export { RateType } from './lib/off_ramp/getRateByType.js';
@@ -0,0 +1,39 @@
1
+ import { get } from '../../utils/api.js';
2
+
3
+ type AllRateResponseType = {
4
+ onRampRate: {
5
+ baseCurrency: string;
6
+ targetCurrency: string;
7
+ isActive: boolean;
8
+ rate: number;
9
+ type: string;
10
+ };
11
+ offRampRate: {
12
+ baseCurrency: string;
13
+ targetCurrency: string;
14
+ isActive: boolean;
15
+ rate: number;
16
+ type: string;
17
+ };
18
+ };
19
+
20
+
21
+ /**
22
+ * This TypeScript function asynchronously fetches all rates from a specified URL and handles any
23
+ * errors that may occur.
24
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
25
+ * function call, which is fetching rate data from the specified URL '/pub/rate'. The function is using
26
+ * async/await syntax to handle asynchronous operations and is catching any errors that occur during
27
+ * the fetch operation. If successful, the function will return the rate data, and if an error occurs,
28
+ * it
29
+ */
30
+ export const getAllRate = async () => {
31
+ const url: string = '/pub/rate';
32
+
33
+ try {
34
+ return await get<AllRateResponseType>(url);
35
+ } catch (err) {
36
+ console.error('Error fetching Rate:', err);
37
+ throw err;
38
+ }
39
+ };
@@ -0,0 +1,38 @@
1
+ import { get } from '../../utils/api.js';
2
+
3
+ type RateByAmountType = {
4
+ rate: {
5
+ baseCurrency: string;
6
+ targetCurrency: string;
7
+ rate: number;
8
+ };
9
+ amounts: {
10
+ userTax: number;
11
+ merchantTax: number;
12
+ amountUSD: number;
13
+ userAmountFiat: number;
14
+ };
15
+ };
16
+
17
+ /**
18
+ * The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
19
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
20
+ * representing the amount for which you want to retrieve the rate. This function makes an asynchronous
21
+ * request to the `/pub/rate` endpoint with the specified amount to fetch the rate information. If
22
+ * successful, it returns the rate
23
+ * @returns The `getRateByAmount` function is returning a Promise that resolves to the rate for a
24
+ * specific amount. The rate is fetched from the specified URL endpoint `/pub/rate` with the provided
25
+ * amount as a parameter. If the rate is successfully fetched, it will be returned. If there is an
26
+ * error during the fetching process, an error message will be logged to the console and the error will
27
+ * be
28
+ */
29
+ export const getRateByAmount = async (amount: number) => {
30
+ const url: string = '/pub/rate';
31
+
32
+ try {
33
+ return await get<RateByAmountType>(`${url}/${amount}`);
34
+ } catch (err) {
35
+ console.error('Error fetching Rate by Amount:', err);
36
+ throw err;
37
+ }
38
+ };
@@ -0,0 +1,33 @@
1
+ import { get } from '../../utils/api.js';
2
+
3
+ type RateByType = {
4
+ baseCurrency: string;
5
+ targetCurrency: string;
6
+ isActive: true;
7
+ rate: number;
8
+ type: string;
9
+ };
10
+
11
+ export enum RateType {
12
+ onRamp = 'onRamp',
13
+ offRamp = 'offRamp',
14
+ }
15
+
16
+ /**
17
+ * This function fetches a rate based on a specified rate type asynchronously.
18
+ * @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
19
+ * such as 'standard', 'premium', 'discount', etc.
20
+ * @returns The `getRateByType` function is returning a Promise that resolves to a `RateByType` object
21
+ * fetched from the specified URL based on the `rateType` parameter. If an error occurs during the
22
+ * fetching process, the function will log an error message and rethrow the error.
23
+ */
24
+ export const getRateByType = async (rateType: RateType) => {
25
+ const url: string = '/pub/rate';
26
+
27
+ try {
28
+ return await get<RateByType>(`${url}/${rateType}`);
29
+ } catch (err) {
30
+ console.error('Error fetching Rate by Rate Type:', err);
31
+ throw err;
32
+ }
33
+ };
@@ -0,0 +1,36 @@
1
+ import { get } from '../../utils/api.js';
2
+
3
+ type TokenValueType = {
4
+ amount: number;
5
+ usdcValue: number;
6
+ mint: string;
7
+ };
8
+
9
+ /**
10
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the specified
11
+ * amount and token mint.
12
+ * @param {number} amount - The `amount` parameter is a number representing the quantity of tokens for
13
+ * which you want to retrieve the value.
14
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
15
+ * the unique identifier for a specific token. It is used to specify which token you are interested in
16
+ * when fetching its value.
17
+ * @returns The `getTokenValue` function is returning the result of the `get` function call with the
18
+ * URL `/value?amount=&mint=` as its argument. The `get` function is likely
19
+ * making an HTTP request to fetch the token value based on the provided amount and mint token. If
20
+ * successful, the function will return the token value. If there is an error during
21
+ */
22
+ export const getTokenValue = async (
23
+ amount: number,
24
+ mint_token: string
25
+ ) => {
26
+ const url: string = '/pub/rate';
27
+
28
+ try {
29
+ return await get<TokenValueType>(
30
+ `${url}/value?amount=${amount}&mint=${mint_token}`
31
+ );
32
+ } catch (err) {
33
+ console.log('Error fetching Token Value:', err);
34
+ throw err;
35
+ }
36
+ };
@@ -1,4 +1,4 @@
1
- import { post } from "../../utils/api.js";
1
+ import { post } from '../../utils/api.js';
2
2
 
3
3
  type CreateOrderType = {
4
4
  fiatAmount: number;
@@ -10,25 +10,34 @@ type CreateOrderType = {
10
10
  token?: string;
11
11
  };
12
12
 
13
+ type CreateOrderResponseType = {
14
+ id: string;
15
+ accountNumber: string;
16
+ accountName: string;
17
+ amount: number;
18
+ bank: string;
19
+ };
20
+
13
21
  export const createOrder = async (options: CreateOrderType) => {
14
- const { fiatAmount, currency, recipient, mint, chain, webhookURL, token } = options;
22
+ const { fiatAmount, currency, recipient, mint, chain, webhookURL, token } =
23
+ options;
15
24
  try {
16
- return await post<CreateOrderType>(
17
- "/pub/onramp",
25
+ return await post<CreateOrderResponseType>(
26
+ '/pub/onramp',
18
27
  {
19
28
  fiatAmount,
20
29
  currency,
21
30
  recipient,
22
31
  mint,
23
32
  chain,
24
- webhookURL
33
+ webhookURL,
25
34
  },
26
35
  {
27
36
  Authorization: `Bearer ${token}`,
28
37
  }
29
38
  );
30
39
  } catch (err) {
31
- console.error("Error creating order:", err);
40
+ console.error('Error creating order:', err);
32
41
  throw err;
33
42
  }
34
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "paj offramp/onramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",
package/sdk.ts CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  // Switch Environment: "staging" | "production"
4
4
  import { setBaseUrl } from './utils/axios.js';
5
+ import { getRateByAmount } from './lib/off_ramp/getRateByAmount';
6
+ import { getRateByRateType } from './dist/lib/off_ramp/getRate';
7
+ import { getTokenValue } from './lib/off_ramp/getTokenValue';
5
8
 
6
9
  export const initializeSDK = (env: 'staging' | 'production') => {
7
10
  if (env === 'staging') {
@@ -15,17 +18,20 @@ export const initializeSDK = (env: 'staging' | 'production') => {
15
18
 
16
19
  // Wallet Info
17
20
  // export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
18
- export { getRate } from './lib/off_ramp/getRate.js';
21
+ export { getAllRate } from './lib/off_ramp/getAllRate.js';
22
+ export { getRateByAmount } from './lib/off_ramp/getRateByAmount.js';
23
+ export { getRateByType } from './lib/off_ramp/getRateByType.js';
24
+ export { getTokenValue } from './lib/off_ramp/getTokenValue.js';
19
25
 
20
26
  // Session Management
21
27
  export { initiate } from './lib/off_ramp/initiate.js';
22
28
  export { verify } from './lib/off_ramp/verify.js';
23
29
 
24
30
  // // Banking Operations
25
- export { getBanks } from "./lib/off_ramp/getBanks.js";
26
- export { resolveBankAccount } from "./lib/off_ramp/resolveBankAccount.js";
27
- export { addBankAccount } from "./lib/off_ramp/addBankAccount.js";
28
- export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
31
+ export { getBanks } from './lib/off_ramp/getBanks.js';
32
+ export { resolveBankAccount } from './lib/off_ramp/resolveBankAccount.js';
33
+ export { addBankAccount } from './lib/off_ramp/addBankAccount.js';
34
+ export { getBankAccounts } from './lib/off_ramp/getBankAccounts.js';
29
35
 
30
36
  // Wallet Operations
31
37
  // export { getWallet } from './lib/off_ramp/getWallet.js';
@@ -35,14 +41,13 @@ export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
35
41
  // DIRECT OFF RAMP
36
42
  export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
37
43
 
38
-
39
44
  // ON RAMP
40
45
 
41
46
  // Create Order
42
47
  export { createOrder } from './lib/on_ramp/createOrder.js';
43
48
 
44
49
  // Observe Order Socket.IO
45
- export { observeOrder } from './lib/on_ramp/observeOrder.js';
50
+ // export { observeOrder } from './lib/on_ramp/observeOrder.js';
46
51
 
47
52
  // Types
48
- export { RateType } from './lib/off_ramp/getRate.js';
53
+ export { RateType } from './lib/off_ramp/getRateByType.js';
@@ -1,169 +0,0 @@
1
- import { get } from '../../utils/api.js';
2
-
3
- type AllRateResponseType = {
4
- onRampRate: {
5
- baseCurrency: string;
6
- targetCurrency: string;
7
- isActive: boolean;
8
- rate: number;
9
- type: string;
10
- };
11
- offRampRate: {
12
- baseCurrency: string;
13
- targetCurrency: string;
14
- isActive: boolean;
15
- rate: number;
16
- type: string;
17
- };
18
- };
19
-
20
- type RateByAmountType = {
21
- rate: {
22
- baseCurrency: string;
23
- targetCurrency: string;
24
- rate: number;
25
- };
26
- amounts: {
27
- userTax: number;
28
- merchantTax: number;
29
- amountUSD: number;
30
- userAmountFiat: number;
31
- };
32
- };
33
-
34
- type RateByRateTypeType = {
35
- baseCurrency: string;
36
- targetCurrency: string;
37
- isActive: true;
38
- rate: number;
39
- type: string;
40
- };
41
-
42
- type TokenValueType = {
43
- amount: number;
44
- usdcValue: number;
45
- mint: string;
46
- };
47
-
48
- export enum RateType {
49
- onRamp = 'onRamp',
50
- offRamp = 'offRamp',
51
- }
52
-
53
- /**
54
- * The function `getRate` in TypeScript is an asynchronous function that retrieves rate information
55
- * based on different parameters such as amount, rate type, and mint token.
56
- * @param {number | RateType} param - The `param` parameter in the `getRate` function can be either a
57
- * number or a `RateType`.
58
- * @param {string} [mint_token] - The `mint_token` parameter is an optional string parameter that
59
- * represents a token used for minting. It is used in the `getRate` function to calculate the rate
60
- * based on the specified token value.
61
- * @returns The `getRate` function returns different values based on the conditions inside the
62
- * function:
63
- */
64
- export const getRate = async (
65
- param: number | RateType,
66
- mint_token?: string
67
- ) => {
68
- try {
69
- const url = '/pub/rate';
70
-
71
- if (!param) {
72
- return getAllRate(url);
73
- } else if (typeof param === 'number') {
74
- if (mint_token) return getTokenValue(url, param, mint_token);
75
- return getRateByAmount(url, param);
76
- } else {
77
- return getRateByRateType(url, param);
78
- }
79
- } catch (err) {
80
- console.error('Error fetching Rate:', err);
81
- throw err;
82
- }
83
- };
84
-
85
- /**
86
- * The function `getAllRate` fetches all rates from a specified URL and handles any errors that occur
87
- * during the process.
88
- * @param {string} url - The `url` parameter in the `getAllRate` function is a string representing the
89
- * URL from which the rate data will be fetched.
90
- * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
91
- * function call, which is fetching rate data from the specified URL. If successful, it will return the
92
- * rate data. If an error occurs during the fetching process, it will log the error message and rethrow
93
- * the error.
94
- */
95
- export const getAllRate = async (url: string) => {
96
- try {
97
- return await get<AllRateResponseType>(url);
98
- } catch (err) {
99
- console.error('Error fetching Rate:', err);
100
- throw err;
101
- }
102
- };
103
-
104
- /**
105
- * The function `getRateByAmount` fetches a rate based on a specified amount from a given URL.
106
- * @param {string} url - The `url` parameter is a string that represents the URL endpoint where the
107
- * rate information is fetched from.
108
- * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
109
- * representing the amount for which you want to fetch the rate. This amount will be used in the URL to
110
- * make a request to the specified endpoint to get the rate information for that specific amount.
111
- * @returns The function `getRateByAmount` is returning a Promise that resolves to a `RateByAmountType`
112
- * object fetched from the specified URL with the provided amount.
113
- */
114
- export const getRateByAmount = async (url: string, amount: number) => {
115
- try {
116
- return await get<RateByAmountType>(`${url}/${amount}`);
117
- } catch (err) {
118
- console.error('Error fetching Rate by Amount:', err);
119
- throw err;
120
- }
121
- };
122
-
123
- /**
124
- * The function `getRateByRateType` fetches a rate based on a specified rate type from a given URL.
125
- * @param {string} url - The `url` parameter is a string representing the base URL used to fetch data.
126
- * @param {RateType} rateType - RateType is a type that represents the different types of rates that
127
- * can be fetched. It is used as a parameter in the getRateByRateType function to specify the type of
128
- * rate to retrieve from the provided URL.
129
- * @returns The `getRateByRateType` function is returning a Promise that resolves to a
130
- * `RateByRateTypeType` object fetched from the specified URL with the provided rate type.
131
- */
132
- export const getRateByRateType = async (url: string, rateType: RateType) => {
133
- try {
134
- return await get<RateByRateTypeType>(`${url}/${rateType}`);
135
- } catch (err) {
136
- console.error('Error fetching Rate by Rate Type:', err);
137
- throw err;
138
- }
139
- };
140
-
141
- /**
142
- * The function `getTokenValue` asynchronously fetches the value of a token based on the provided URL,
143
- * amount, and mint token.
144
- * @param {string} url - The `url` parameter is a string representing the base URL for the API endpoint
145
- * where you can fetch the token value.
146
- * @param {number} amount - The `amount` parameter in the `getTokenValue` function represents the
147
- * quantity or number of tokens for which you want to retrieve the value. It is a numeric value
148
- * (number) indicating the amount of tokens for which you are querying the value.
149
- * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
150
- * the unique identifier for a specific token. It is used to specify which token's value you want to
151
- * retrieve based on the provided `amount`.
152
- * @returns The `getTokenValue` function is returning the result of the `get` function called with the
153
- * URL `/value?amount=&mint=`. The `get` function is likely making an HTTP
154
- * request to that URL to fetch some data. The return value is expected to be of type `TokenValueType`.
155
- * If an error occurs during the fetch operation, an error message will
156
- */
157
- export const getTokenValue = async (
158
- url: string,
159
- amount: number,
160
- mint_token: string
161
- ) => {
162
- try {
163
- return await get<TokenValueType>(
164
- `${url}/value?amount=${amount}&mint=${mint_token}`
165
- );
166
- } catch (err) {
167
- console.log('Error fetching Token Value:', err);
168
- }
169
- };