@7kprotocol/sdk-ts 1.3.1 → 1.3.3

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.
@@ -24,7 +24,7 @@ const DEFAULT_SOURCES = [
24
24
  ];
25
25
  function getQuote(_a) {
26
26
  return __awaiter(this, arguments, void 0, function* ({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
27
- const response = yield fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${(0, token_1.normalizeTokenType)(tokenIn)}&to=${(0, token_1.normalizeTokenType)(tokenOut)}&sources=${sources.join(",")}`);
27
+ const response = yield fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${(0, token_1.normalizeTokenType)(tokenIn)}&to=${(0, token_1.normalizeTokenType)(tokenOut)}&sources=${sources}`);
28
28
  if (!response.ok) {
29
29
  throw new Error("Failed to fetch aggregator quote");
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../../src/utils/price.ts"],"names":[],"mappings":"AAIA,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
1
+ {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../../src/utils/price.ts"],"names":[],"mappings":"AASA,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
@@ -14,10 +14,11 @@ const tokens_1 = require("../constants/tokens");
14
14
  const PRICES_API = "https://prices.7k.ag";
15
15
  function getTokenPrice(id_1) {
16
16
  return __awaiter(this, arguments, void 0, function* (id, vsCoin = tokens_1.USDC_TOKEN_TYPE) {
17
+ var _a;
17
18
  try {
18
19
  const response = yield fetch(`${PRICES_API}/price?ids=${id}&vsCoin=${vsCoin}`);
19
20
  const prices = (yield response.json());
20
- return (prices === null || prices === void 0 ? void 0 : prices[id]) || 0;
21
+ return ((_a = prices === null || prices === void 0 ? void 0 : prices[id]) === null || _a === void 0 ? void 0 : _a.price) || 0;
21
22
  }
22
23
  catch (error) {
23
24
  return 0;
@@ -11,7 +11,7 @@ const DEFAULT_SOURCES = [
11
11
  "flowx",
12
12
  ];
13
13
  export async function getQuote({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
14
- const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}&sources=${sources.join(",")}`);
14
+ const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}&sources=${sources}`);
15
15
  if (!response.ok) {
16
16
  throw new Error("Failed to fetch aggregator quote");
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../../src/utils/price.ts"],"names":[],"mappings":"AAIA,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
1
+ {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../../src/utils/price.ts"],"names":[],"mappings":"AASA,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
@@ -4,7 +4,7 @@ export async function getTokenPrice(id, vsCoin = USDC_TOKEN_TYPE) {
4
4
  try {
5
5
  const response = await fetch(`${PRICES_API}/price?ids=${id}&vsCoin=${vsCoin}`);
6
6
  const prices = (await response.json());
7
- return prices?.[id] || 0;
7
+ return prices?.[id]?.price || 0;
8
8
  }
9
9
  catch (error) {
10
10
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7kprotocol/sdk-ts",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {