paj_ramp 1.2.4 → 1.2.5

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
@@ -310,6 +310,25 @@ Response:
310
310
  }*/
311
311
  ```
312
312
 
313
+ ### Get Token Value from Amount and Mint Token
314
+
315
+ ```typescript
316
+ import { getRate } from 'paj_ramp';
317
+
318
+ const tokenValue = await getRate(
319
+ 50000,
320
+ 'token_mint_address'
321
+ );
322
+ /*
323
+ Response:
324
+ {
325
+ amount: number, // requested token amount
326
+ usdcValue: number, // USD value of the token amount
327
+ mint: string // token mint address
328
+ }
329
+ */
330
+ ```
331
+
313
332
  ### Get Rate by Rate Type
314
333
 
315
334
  ```typescript
@@ -15,5 +15,5 @@ type offRampCreateOrderResponse = {
15
15
  status: string;
16
16
  webhookURL: string;
17
17
  };
18
- export declare const offRampCreateOrder: (token: string, bank: string, accountNumber: string, currency: Currency, amount: number, mint: string, webhookURL: string) => Promise<offRampCreateOrderResponse>;
18
+ export declare const offRampCreateOrder: (token: string, bank: string, accountNumber: string, currency: string, amount: number, mint: string, webhookURL: string) => Promise<offRampCreateOrderResponse>;
19
19
  export {};
@@ -1,17 +1,17 @@
1
1
  type AllRateResponseType = {
2
2
  onRampRate: {
3
- baseCurrency: "USD";
4
- targetCurrency: "NGN";
3
+ baseCurrency: 'USD';
4
+ targetCurrency: 'NGN';
5
5
  isActive: true;
6
6
  rate: 1510;
7
- type: "onRamp";
7
+ type: 'onRamp';
8
8
  };
9
9
  offRampRate: {
10
- baseCurrency: "USD";
11
- targetCurrency: "NGN";
10
+ baseCurrency: 'USD';
11
+ targetCurrency: 'NGN';
12
12
  isActive: true;
13
13
  rate: 1525;
14
- type: "offRamp";
14
+ type: 'offRamp';
15
15
  };
16
16
  };
17
17
  type RateByAmountType = {
@@ -28,58 +28,80 @@ type RateByAmountType = {
28
28
  };
29
29
  };
30
30
  type RateByRateTypeType = {
31
- baseCurrency: "USD";
32
- targetCurrency: "NGN";
31
+ baseCurrency: 'USD';
32
+ targetCurrency: 'NGN';
33
33
  isActive: true;
34
34
  rate: 1525;
35
- type: "offRamp";
35
+ type: 'offRamp';
36
+ };
37
+ type TokenValueType = {
38
+ amount: number;
39
+ usdcValue: number;
40
+ mint: string;
36
41
  };
37
42
  export declare enum RateType {
38
43
  onRamp = "onRamp",
39
44
  offRamp = "offRamp"
40
45
  }
41
46
  /**
42
- * Fetches rate information based on the provided parameter, which can be a number or a rate type.
43
- * This function returns all rates, rates by amount, or rates by type depending on the input.
44
- *
45
- * Args:
46
- * param: A number representing the amount or a RateType enum value.
47
- *
48
- * Returns:
49
- * A promise resolving to the rate information relevant to the input parameter.
50
- *
51
- * Raises:
52
- * Throws an error if the rate information cannot be fetched.
47
+ * The function `getRate` in TypeScript is an asynchronous function that retrieves rate information
48
+ * based on different parameters such as amount, rate type, and mint token.
49
+ * @param {number | RateType} param - The `param` parameter in the `getRate` function can be either a
50
+ * number or a `RateType`.
51
+ * @param {string} [mint_token] - The `mint_token` parameter is an optional string parameter that
52
+ * represents a token used for minting. It is used in the `getRate` function to calculate the rate
53
+ * based on the specified token value.
54
+ * @returns The `getRate` function returns different values based on the conditions inside the
55
+ * function:
56
+ */
57
+ export declare const getRate: (param: number | RateType, mint_token?: string) => Promise<AllRateResponseType | RateByAmountType | RateByRateTypeType | TokenValueType | undefined>;
58
+ /**
59
+ * The function `getAllRate` fetches all rates from a specified URL and handles any errors that occur
60
+ * during the process.
61
+ * @param {string} url - The `url` parameter in the `getAllRate` function is a string representing the
62
+ * URL from which the rate data will be fetched.
63
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
64
+ * function call, which is fetching rate data from the specified URL. If successful, it will return the
65
+ * rate data. If an error occurs during the fetching process, it will log the error message and rethrow
66
+ * the error.
53
67
  */
54
- export declare const getRate: (param: number | RateType) => Promise<AllRateResponseType | RateByAmountType | RateByRateTypeType>;
68
+ export declare const getAllRate: (url: string) => Promise<AllRateResponseType>;
55
69
  /**
56
- * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
57
- * This function returns a promise that resolves to the rate and associated amounts for the given value.
58
- *
59
- * Args:
60
- * url: The endpoint URL to fetch rate information from.
61
- * amount: The amount for which the rate information is requested.
62
- *
63
- * Returns:
64
- * A promise resolving to the rate and amount details for the specified value.
65
- *
66
- * Raises:
67
- * Throws an error if the rate information cannot be fetched.
70
+ * The function `getRateByAmount` fetches a rate based on a specified amount from a given URL.
71
+ * @param {string} url - The `url` parameter is a string that represents the URL endpoint where the
72
+ * rate information is fetched from.
73
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
74
+ * representing the amount for which you want to fetch the rate. This amount will be used in the URL to
75
+ * make a request to the specified endpoint to get the rate information for that specific amount.
76
+ * @returns The function `getRateByAmount` is returning a Promise that resolves to a `RateByAmountType`
77
+ * object fetched from the specified URL with the provided amount.
68
78
  */
69
79
  export declare const getRateByAmount: (url: string, amount: number) => Promise<RateByAmountType>;
70
80
  /**
71
- * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
72
- * This function returns a promise that resolves to the rate details for the given rate type.
73
- *
74
- * Args:
75
- * url: The endpoint URL to fetch rate information from.
76
- * rateType: The type of rate to retrieve, specified as a RateType enum value.
77
- *
78
- * Returns:
79
- * A promise resolving to the rate details for the specified rate type.
80
- *
81
- * Raises:
82
- * Throws an error if the rate information cannot be fetched.
81
+ * The function `getRateByRateType` fetches a rate based on a specified rate type from a given URL.
82
+ * @param {string} url - The `url` parameter is a string representing the base URL used to fetch data.
83
+ * @param {RateType} rateType - RateType is a type that represents the different types of rates that
84
+ * can be fetched. It is used as a parameter in the getRateByRateType function to specify the type of
85
+ * rate to retrieve from the provided URL.
86
+ * @returns The `getRateByRateType` function is returning a Promise that resolves to a
87
+ * `RateByRateTypeType` object fetched from the specified URL with the provided rate type.
83
88
  */
84
89
  export declare const getRateByRateType: (url: string, rateType: RateType) => Promise<RateByRateTypeType>;
90
+ /**
91
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the provided URL,
92
+ * amount, and mint token.
93
+ * @param {string} url - The `url` parameter is a string representing the base URL for the API endpoint
94
+ * where you can fetch the token value.
95
+ * @param {number} amount - The `amount` parameter in the `getTokenValue` function represents the
96
+ * quantity or number of tokens for which you want to retrieve the value. It is a numeric value
97
+ * (number) indicating the amount of tokens for which you are querying the value.
98
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
99
+ * the unique identifier for a specific token. It is used to specify which token's value you want to
100
+ * retrieve based on the provided `amount`.
101
+ * @returns The `getTokenValue` function is returning the result of the `get` function called with the
102
+ * URL `/value?amount=&mint=`. The `get` function is likely making an HTTP
103
+ * request to that URL to fetch some data. The return value is expected to be of type `TokenValueType`.
104
+ * If an error occurs during the fetch operation, an error message will
105
+ */
106
+ export declare const getTokenValue: (url: string, amount: number, mint_token: string) => Promise<TokenValueType | undefined>;
85
107
  export {};
@@ -1,29 +1,29 @@
1
- import { get } from "../../utils/api.js";
1
+ import { get } from '../../utils/api.js';
2
2
  export var RateType;
3
3
  (function (RateType) {
4
4
  RateType["onRamp"] = "onRamp";
5
5
  RateType["offRamp"] = "offRamp";
6
6
  })(RateType || (RateType = {}));
7
7
  /**
8
- * Fetches rate information based on the provided parameter, which can be a number or a rate type.
9
- * This function returns all rates, rates by amount, or rates by type depending on the input.
10
- *
11
- * Args:
12
- * param: A number representing the amount or a RateType enum value.
13
- *
14
- * Returns:
15
- * A promise resolving to the rate information relevant to the input parameter.
16
- *
17
- * Raises:
18
- * Throws an error if the rate information cannot be fetched.
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:
19
17
  */
20
- export const getRate = async (param) => {
18
+ export const getRate = async (param, mint_token) => {
21
19
  try {
22
- const url = "/pub/rate";
20
+ const url = '/pub/rate';
23
21
  if (!param) {
24
22
  return getAllRate(url);
25
23
  }
26
- else if (typeof param === "number") {
24
+ else if (typeof param === 'number') {
25
+ if (mint_token)
26
+ return getTokenValue(url, param, mint_token);
27
27
  return getRateByAmount(url, param);
28
28
  }
29
29
  else {
@@ -31,75 +31,87 @@ export const getRate = async (param) => {
31
31
  }
32
32
  }
33
33
  catch (err) {
34
- console.error("Error fetching Rate:", err);
34
+ console.error('Error fetching Rate:', err);
35
35
  throw err;
36
36
  }
37
37
  };
38
38
  /**
39
- * Retrieves all available rate information for on-ramp and off-ramp transactions.
40
- * This function returns a promise that resolves to the complete set of rate data.
41
- *
42
- * Args:
43
- * url: The endpoint URL to fetch rate information from.
44
- *
45
- * Returns:
46
- * A promise resolving to the full rate response data.
47
- *
48
- * Raises:
49
- * Throws an error if the rate information cannot be fetched.
39
+ * The function `getAllRate` fetches all rates from a specified URL and handles any errors that occur
40
+ * during the process.
41
+ * @param {string} url - The `url` parameter in the `getAllRate` function is a string representing the
42
+ * URL from which the rate data will be fetched.
43
+ * @returns The `getAllRate` function is returning the result of the `get<AllRateResponseType>(url)`
44
+ * function call, which is fetching rate data from the specified URL. If successful, it will return the
45
+ * rate data. If an error occurs during the fetching process, it will log the error message and rethrow
46
+ * the error.
50
47
  */
51
- const getAllRate = async (url) => {
48
+ export const getAllRate = async (url) => {
52
49
  try {
53
50
  return await get(url);
54
51
  }
55
52
  catch (err) {
56
- console.error("Error fetching Rate:", err);
53
+ console.error('Error fetching Rate:', err);
57
54
  throw err;
58
55
  }
59
56
  };
60
57
  /**
61
- * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
62
- * This function returns a promise that resolves to the rate and associated amounts for the given value.
63
- *
64
- * Args:
65
- * url: The endpoint URL to fetch rate information from.
66
- * amount: The amount for which the rate information is requested.
67
- *
68
- * Returns:
69
- * A promise resolving to the rate and amount details for the specified value.
70
- *
71
- * Raises:
72
- * Throws an error if the rate information cannot be fetched.
58
+ * The function `getRateByAmount` fetches a rate based on a specified amount from a given URL.
59
+ * @param {string} url - The `url` parameter is a string that represents the URL endpoint where the
60
+ * rate information is fetched from.
61
+ * @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
62
+ * representing the amount for which you want to fetch the rate. This amount will be used in the URL to
63
+ * make a request to the specified endpoint to get the rate information for that specific amount.
64
+ * @returns The function `getRateByAmount` is returning a Promise that resolves to a `RateByAmountType`
65
+ * object fetched from the specified URL with the provided amount.
73
66
  */
74
67
  export const getRateByAmount = async (url, amount) => {
75
68
  try {
76
- return await get(`/pub/rate/${amount}`);
69
+ return await get(`${url}/${amount}`);
77
70
  }
78
71
  catch (err) {
79
- console.error("Error fetching Rate by Amount:", err);
72
+ console.error('Error fetching Rate by Amount:', err);
80
73
  throw err;
81
74
  }
82
75
  };
83
76
  /**
84
- * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
85
- * This function returns a promise that resolves to the rate details for the given rate type.
86
- *
87
- * Args:
88
- * url: The endpoint URL to fetch rate information from.
89
- * rateType: The type of rate to retrieve, specified as a RateType enum value.
90
- *
91
- * Returns:
92
- * A promise resolving to the rate details for the specified rate type.
93
- *
94
- * Raises:
95
- * Throws an error if the rate information cannot be fetched.
77
+ * The function `getRateByRateType` fetches a rate based on a specified rate type from a given URL.
78
+ * @param {string} url - The `url` parameter is a string representing the base URL used to fetch data.
79
+ * @param {RateType} rateType - RateType is a type that represents the different types of rates that
80
+ * can be fetched. It is used as a parameter in the getRateByRateType function to specify the type of
81
+ * rate to retrieve from the provided URL.
82
+ * @returns The `getRateByRateType` function is returning a Promise that resolves to a
83
+ * `RateByRateTypeType` object fetched from the specified URL with the provided rate type.
96
84
  */
97
85
  export const getRateByRateType = async (url, rateType) => {
98
86
  try {
99
- return await get(`/pub/rate/${rateType}`);
87
+ return await get(`${url}/${rateType}`);
100
88
  }
101
89
  catch (err) {
102
- console.error("Error fetching Rate by Rate Type:", err);
90
+ console.error('Error fetching Rate by Rate Type:', err);
103
91
  throw err;
104
92
  }
105
93
  };
94
+ /**
95
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the provided URL,
96
+ * amount, and mint token.
97
+ * @param {string} url - The `url` parameter is a string representing the base URL for the API endpoint
98
+ * where you can fetch the token value.
99
+ * @param {number} amount - The `amount` parameter in the `getTokenValue` function represents the
100
+ * quantity or number of tokens for which you want to retrieve the value. It is a numeric value
101
+ * (number) indicating the amount of tokens for which you are querying the value.
102
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
103
+ * the unique identifier for a specific token. It is used to specify which token's value you want to
104
+ * retrieve based on the provided `amount`.
105
+ * @returns The `getTokenValue` function is returning the result of the `get` function called with the
106
+ * URL `/value?amount=&mint=`. The `get` function is likely making an HTTP
107
+ * request to that URL to fetch some data. The return value is expected to be of type `TokenValueType`.
108
+ * If an error occurs during the fetch operation, an error message will
109
+ */
110
+ export const getTokenValue = async (url, amount, mint_token) => {
111
+ try {
112
+ return await get(`${url}/value?amount=${amount}&mint=${mint_token}`);
113
+ }
114
+ catch (err) {
115
+ console.log('Error fetching Token Value:', err);
116
+ }
117
+ };
package/dist/sdk.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare const initializeSDK: (env: "staging" | "production") => void;
2
- export { getRate, RateType } from './lib/off_ramp/getRate.js';
2
+ export { getRate } from './lib/off_ramp/getRate.js';
3
3
  export { initiate } from './lib/off_ramp/initiate.js';
4
4
  export { verify } from './lib/off_ramp/verify.js';
5
5
  export { getBanks } from "./lib/off_ramp/getBanks.js";
@@ -9,3 +9,4 @@ export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
9
9
  export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
10
10
  export { createOrder } from './lib/on_ramp/createOrder.js';
11
11
  export { observeOrder } from './lib/on_ramp/observeOrder.js';
12
+ export { RateType } from './lib/off_ramp/getRate.js';
package/dist/sdk.js CHANGED
@@ -12,7 +12,7 @@ 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, RateType } from './lib/off_ramp/getRate.js';
15
+ export { getRate } from './lib/off_ramp/getRate.js';
16
16
  // Session Management
17
17
  export { initiate } from './lib/off_ramp/initiate.js';
18
18
  export { verify } from './lib/off_ramp/verify.js';
@@ -32,3 +32,5 @@ export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
32
32
  export { createOrder } from './lib/on_ramp/createOrder.js';
33
33
  // Observe Order Socket.IO
34
34
  export { observeOrder } from './lib/on_ramp/observeOrder.js';
35
+ // Types
36
+ export { RateType } from './lib/off_ramp/getRate.js';
@@ -33,7 +33,7 @@ export const offRampCreateOrder = async (
33
33
  token: string,
34
34
  bank: string,
35
35
  accountNumber: string,
36
- currency: Currency,
36
+ currency: string,
37
37
  amount: number,
38
38
  mint: string,
39
39
  webhookURL: string
@@ -1,19 +1,19 @@
1
- import { get } from "../../utils/api.js";
1
+ import { get } from '../../utils/api.js';
2
2
 
3
3
  type AllRateResponseType = {
4
4
  onRampRate: {
5
- baseCurrency: "USD";
6
- targetCurrency: "NGN";
5
+ baseCurrency: 'USD';
6
+ targetCurrency: 'NGN';
7
7
  isActive: true;
8
8
  rate: 1510;
9
- type: "onRamp";
9
+ type: 'onRamp';
10
10
  };
11
11
  offRampRate: {
12
- baseCurrency: "USD";
13
- targetCurrency: "NGN";
12
+ baseCurrency: 'USD';
13
+ targetCurrency: 'NGN';
14
14
  isActive: true;
15
15
  rate: 1525;
16
- type: "offRamp";
16
+ type: 'offRamp';
17
17
  };
18
18
  };
19
19
 
@@ -32,112 +32,139 @@ type RateByAmountType = {
32
32
  };
33
33
 
34
34
  type RateByRateTypeType = {
35
- baseCurrency: "USD";
36
- targetCurrency: "NGN";
35
+ baseCurrency: 'USD';
36
+ targetCurrency: 'NGN';
37
37
  isActive: true;
38
38
  rate: 1525;
39
- type: "offRamp";
39
+ type: 'offRamp';
40
+ };
41
+
42
+ type TokenValueType = {
43
+ amount: number;
44
+ usdcValue: number;
45
+ mint: string;
40
46
  };
41
47
 
42
48
  export enum RateType {
43
- onRamp = "onRamp",
44
- offRamp = "offRamp",
49
+ onRamp = 'onRamp',
50
+ offRamp = 'offRamp',
45
51
  }
46
52
 
47
53
  /**
48
- * Fetches rate information based on the provided parameter, which can be a number or a rate type.
49
- * This function returns all rates, rates by amount, or rates by type depending on the input.
50
- *
51
- * Args:
52
- * param: A number representing the amount or a RateType enum value.
53
- *
54
- * Returns:
55
- * A promise resolving to the rate information relevant to the input parameter.
56
- *
57
- * Raises:
58
- * Throws an error if the rate information cannot be fetched.
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:
59
63
  */
60
- export const getRate = async (param: number | RateType) => {
64
+ export const getRate = async (
65
+ param: number | RateType,
66
+ mint_token?: string
67
+ ) => {
61
68
  try {
62
- const url = "/pub/rate";
69
+ const url = '/pub/rate';
63
70
 
64
71
  if (!param) {
65
72
  return getAllRate(url);
66
- } else if (typeof param === "number") {
73
+ } else if (typeof param === 'number') {
74
+ if (mint_token) return getTokenValue(url, param, mint_token);
67
75
  return getRateByAmount(url, param);
68
76
  } else {
69
77
  return getRateByRateType(url, param);
70
78
  }
71
79
  } catch (err) {
72
- console.error("Error fetching Rate:", err);
80
+ console.error('Error fetching Rate:', err);
73
81
  throw err;
74
82
  }
75
83
  };
76
84
 
77
85
  /**
78
- * Retrieves all available rate information for on-ramp and off-ramp transactions.
79
- * This function returns a promise that resolves to the complete set of rate data.
80
- *
81
- * Args:
82
- * url: The endpoint URL to fetch rate information from.
83
- *
84
- * Returns:
85
- * A promise resolving to the full rate response data.
86
- *
87
- * Raises:
88
- * Throws an error if the rate information cannot be fetched.
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.
89
94
  */
90
- const getAllRate = async (url: string) => {
95
+ export const getAllRate = async (url: string) => {
91
96
  try {
92
97
  return await get<AllRateResponseType>(url);
93
98
  } catch (err) {
94
- console.error("Error fetching Rate:", err);
99
+ console.error('Error fetching Rate:', err);
95
100
  throw err;
96
101
  }
97
102
  };
98
103
 
99
104
  /**
100
- * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
101
- * This function returns a promise that resolves to the rate and associated amounts for the given value.
102
- *
103
- * Args:
104
- * url: The endpoint URL to fetch rate information from.
105
- * amount: The amount for which the rate information is requested.
106
- *
107
- * Returns:
108
- * A promise resolving to the rate and amount details for the specified value.
109
- *
110
- * Raises:
111
- * Throws an error if the rate information cannot be fetched.
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.
112
113
  */
113
114
  export const getRateByAmount = async (url: string, amount: number) => {
114
115
  try {
115
- return await get<RateByAmountType>(`/pub/rate/${amount}`);
116
+ return await get<RateByAmountType>(`${url}/${amount}`);
116
117
  } catch (err) {
117
- console.error("Error fetching Rate by Amount:", err);
118
+ console.error('Error fetching Rate by Amount:', err);
118
119
  throw err;
119
120
  }
120
121
  };
121
122
 
123
+
122
124
  /**
123
- * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
124
- * This function returns a promise that resolves to the rate details for the given rate type.
125
- *
126
- * Args:
127
- * url: The endpoint URL to fetch rate information from.
128
- * rateType: The type of rate to retrieve, specified as a RateType enum value.
129
- *
130
- * Returns:
131
- * A promise resolving to the rate details for the specified rate type.
132
- *
133
- * Raises:
134
- * Throws an error if the rate information cannot be fetched.
125
+ * The function `getRateByRateType` fetches a rate based on a specified rate type from a given URL.
126
+ * @param {string} url - The `url` parameter is a string representing the base URL used to fetch data.
127
+ * @param {RateType} rateType - RateType is a type that represents the different types of rates that
128
+ * can be fetched. It is used as a parameter in the getRateByRateType function to specify the type of
129
+ * rate to retrieve from the provided URL.
130
+ * @returns The `getRateByRateType` function is returning a Promise that resolves to a
131
+ * `RateByRateTypeType` object fetched from the specified URL with the provided rate type.
135
132
  */
136
133
  export const getRateByRateType = async (url: string, rateType: RateType) => {
137
134
  try {
138
- return await get<RateByRateTypeType>(`/pub/rate/${rateType}`);
135
+ return await get<RateByRateTypeType>(`${url}/${rateType}`);
139
136
  } catch (err) {
140
- console.error("Error fetching Rate by Rate Type:", err);
137
+ console.error('Error fetching Rate by Rate Type:', err);
141
138
  throw err;
142
139
  }
143
140
  };
141
+
142
+ /**
143
+ * The function `getTokenValue` asynchronously fetches the value of a token based on the provided URL,
144
+ * amount, and mint token.
145
+ * @param {string} url - The `url` parameter is a string representing the base URL for the API endpoint
146
+ * where you can fetch the token value.
147
+ * @param {number} amount - The `amount` parameter in the `getTokenValue` function represents the
148
+ * quantity or number of tokens for which you want to retrieve the value. It is a numeric value
149
+ * (number) indicating the amount of tokens for which you are querying the value.
150
+ * @param {string} mint_token - The `mint_token` parameter in the `getTokenValue` function represents
151
+ * the unique identifier for a specific token. It is used to specify which token's value you want to
152
+ * retrieve based on the provided `amount`.
153
+ * @returns The `getTokenValue` function is returning the result of the `get` function called with the
154
+ * URL `/value?amount=&mint=`. The `get` function is likely making an HTTP
155
+ * request to that URL to fetch some data. The return value is expected to be of type `TokenValueType`.
156
+ * If an error occurs during the fetch operation, an error message will
157
+ */
158
+ export const getTokenValue = async (
159
+ url: string,
160
+ amount: number,
161
+ mint_token: string
162
+ ) => {
163
+ try {
164
+ return await get<TokenValueType>(
165
+ `${url}/value?amount=${amount}&mint=${mint_token}`
166
+ );
167
+ } catch (err) {
168
+ console.log('Error fetching Token Value:', err);
169
+ }
170
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "paj offramp/onramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",
package/sdk.ts CHANGED
@@ -15,7 +15,7 @@ export const initializeSDK = (env: 'staging' | 'production') => {
15
15
 
16
16
  // Wallet Info
17
17
  // export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
18
- export { getRate, RateType } from './lib/off_ramp/getRate.js';
18
+ export { getRate } from './lib/off_ramp/getRate.js';
19
19
 
20
20
  // Session Management
21
21
  export { initiate } from './lib/off_ramp/initiate.js';
@@ -35,6 +35,7 @@ export { getBankAccounts } from "./lib/off_ramp/getBankAccounts.js";
35
35
  // DIRECT OFF RAMP
36
36
  export { offRampCreateOrder } from './lib/direct_off_ramp/directCreateOrder.js';
37
37
 
38
+
38
39
  // ON RAMP
39
40
 
40
41
  // Create Order
@@ -42,3 +43,6 @@ export { createOrder } from './lib/on_ramp/createOrder.js';
42
43
 
43
44
  // Observe Order Socket.IO
44
45
  export { observeOrder } from './lib/on_ramp/observeOrder.js';
46
+
47
+ // Types
48
+ export { RateType } from './lib/off_ramp/getRate.js';