@provable-games/ekubo-sdk 0.1.9 → 0.1.11

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/dist/react.d.cts CHANGED
@@ -12,13 +12,16 @@ interface EkuboProviderProps {
12
12
  /**
13
13
  * Provider component for EkuboClient
14
14
  *
15
+ * Defaults to mainnet if no config is provided. Chain can also be
16
+ * specified per-hook via the `config` option.
17
+ *
15
18
  * @example
16
19
  * ```tsx
17
20
  * import { EkuboProvider } from '@provable-games/ekubo-sdk/react';
18
21
  *
19
22
  * function App() {
20
23
  * return (
21
- * <EkuboProvider config={{ chain: 'mainnet' }}>
24
+ * <EkuboProvider>
22
25
  * <YourApp />
23
26
  * </EkuboProvider>
24
27
  * );
package/dist/react.d.ts CHANGED
@@ -12,13 +12,16 @@ interface EkuboProviderProps {
12
12
  /**
13
13
  * Provider component for EkuboClient
14
14
  *
15
+ * Defaults to mainnet if no config is provided. Chain can also be
16
+ * specified per-hook via the `config` option.
17
+ *
15
18
  * @example
16
19
  * ```tsx
17
20
  * import { EkuboProvider } from '@provable-games/ekubo-sdk/react';
18
21
  *
19
22
  * function App() {
20
23
  * return (
21
- * <EkuboProvider config={{ chain: 'mainnet' }}>
24
+ * <EkuboProvider>
22
25
  * <YourApp />
23
26
  * </EkuboProvider>
24
27
  * );
package/dist/react.js CHANGED
@@ -216,10 +216,10 @@ async function fetchSwapQuote(params) {
216
216
  } = params;
217
217
  const config = { ...DEFAULT_FETCH_CONFIG, ...fetchConfig };
218
218
  const fetchFn = config.fetch;
219
- const receivedAmount = `-${amount.toString()}`;
220
219
  const normalizedTokenFrom = normalizeAddress(tokenFrom);
221
220
  const normalizedTokenTo = normalizeAddress(tokenTo);
222
- const url = `${API_URLS.QUOTER}/${chainId}/${receivedAmount}/${normalizedTokenFrom}/${normalizedTokenTo}`;
221
+ const isExactOutput = amount < 0n;
222
+ const url = isExactOutput ? `${API_URLS.QUOTER}/${chainId}/${amount.toString()}/${normalizedTokenTo}/${normalizedTokenFrom}` : `${API_URLS.QUOTER}/${chainId}/${amount.toString()}/${normalizedTokenFrom}/${normalizedTokenTo}`;
223
223
  let lastError = null;
224
224
  for (let attempt = 0; attempt < config.maxRetries; attempt++) {
225
225
  if (signal?.aborted) {
@@ -2029,12 +2029,13 @@ function useEkuboQuotes({
2029
2029
  }
2030
2030
  return updated;
2031
2031
  });
2032
+ const exactOutputAmount = amount > 0n ? -amount : amount;
2032
2033
  const fetchPromises = sellTokens.filter((sellToken) => sellToken.toLowerCase() !== buyToken.toLowerCase()).map(async (sellToken) => {
2033
2034
  const abortController = new AbortController();
2034
2035
  abortControllersRef.current.set(sellToken, abortController);
2035
2036
  try {
2036
2037
  const quote = await client.getQuote({
2037
- amount,
2038
+ amount: exactOutputAmount,
2038
2039
  tokenFrom: sellToken,
2039
2040
  tokenTo: buyToken,
2040
2041
  signal: abortController.signal