@sodax/dapp-kit 0.0.1-rc.8 → 0.0.1-rc.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.
Files changed (41) hide show
  1. package/README.md +1 -3
  2. package/dist/core/index.d.ts +1 -2
  3. package/dist/core/index.d.ts.map +1 -1
  4. package/dist/hooks/mm/index.d.ts +0 -1
  5. package/dist/hooks/mm/index.d.ts.map +1 -1
  6. package/dist/hooks/mm/useBorrow.d.ts +1 -1
  7. package/dist/hooks/mm/useBorrow.d.ts.map +1 -1
  8. package/dist/hooks/mm/useRepay.d.ts +1 -1
  9. package/dist/hooks/mm/useRepay.d.ts.map +1 -1
  10. package/dist/hooks/mm/useSupply.d.ts +1 -1
  11. package/dist/hooks/mm/useSupply.d.ts.map +1 -1
  12. package/dist/hooks/mm/useUserReservesData.d.ts +1 -7
  13. package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
  14. package/dist/hooks/mm/useWithdraw.d.ts +1 -1
  15. package/dist/hooks/mm/useWithdraw.d.ts.map +1 -1
  16. package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
  17. package/dist/hooks/swap/useCreateIntentOrder.d.ts +3 -3
  18. package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +1 -1
  19. package/dist/hooks/swap/useQuote.d.ts +4 -4
  20. package/dist/hooks/swap/useQuote.d.ts.map +1 -1
  21. package/dist/hooks/swap/useStatus.d.ts +3 -3
  22. package/dist/hooks/swap/useStatus.d.ts.map +1 -1
  23. package/dist/index.js +20 -62
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +22 -62
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +4 -4
  28. package/src/core/index.ts +4 -27
  29. package/src/hooks/mm/index.ts +0 -1
  30. package/src/hooks/mm/useBorrow.ts +2 -2
  31. package/src/hooks/mm/useRepay.ts +2 -2
  32. package/src/hooks/mm/useSupply.ts +2 -2
  33. package/src/hooks/mm/useUserReservesData.ts +1 -7
  34. package/src/hooks/mm/useWithdraw.ts +2 -2
  35. package/src/hooks/provider/useSpokeProvider.ts +13 -5
  36. package/src/hooks/swap/useCreateIntentOrder.ts +5 -5
  37. package/src/hooks/swap/useQuote.ts +5 -5
  38. package/src/hooks/swap/useStatus.ts +3 -3
  39. package/dist/hooks/mm/useHubWalletAddress.d.ts +0 -24
  40. package/dist/hooks/mm/useHubWalletAddress.d.ts.map +0 -1
  41. package/src/hooks/mm/useHubWalletAddress.ts +0 -49
package/README.md CHANGED
@@ -11,7 +11,6 @@ dApp Kit is a collection of React components, hooks, and utilities designed to s
11
11
  - Borrow tokens from the money market (`useBorrow`)
12
12
  - Repay borrowed tokens (`useRepay`)
13
13
  - Get user reserves data (`useUserReservesData`)
14
- - Calculate hub wallet address by using spoke chain id and spoke chain wallet address (`useHubWalletAddress`)
15
14
  - Get reserves data (`useReservesData`)
16
15
  - Check token allowance (`useMMAllowance`)
17
16
  - Approve token spending (`useMMApprove`)
@@ -65,7 +64,7 @@ const sodaxConfig = {
65
64
  moneyMarket: getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID),
66
65
  solver: {
67
66
  intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
68
- solverApiEndpoint: 'https://sodax-solver.iconblockchain.xyz',
67
+ solverApiEndpoint: 'https://sodax-solver-staging.iconblockchain.xyz',
69
68
  partnerFee: {
70
69
  address: '0x0Ab764AB3816cD036Ea951bE973098510D8105A6',
71
70
  percentage: 100, // 1%
@@ -211,7 +210,6 @@ function SwapComponent() {
211
210
  - [`useSupply()`](./src/hooks/mm/useSupply.ts) - Supply tokens to the money market
212
211
  - [`useWithdraw()`](./src/hooks/mm/useWithdraw.ts) - Withdraw supplied tokens
213
212
  - [`useUserReservesData()`](./src/hooks/mm/useUserReservesData.ts) - Get user's reserves data(supplied asset and debt)
214
- - [`useHubWalletAddress()`](./src/hooks/mm/useHubWalletAddress.ts) - Get hub wallet address for a spoke chain
215
213
  - [`useReservesData()`](./src/hooks/mm/useReservesData.ts) - Get reserves data
216
214
  - [`useMMAllowance()`](./src/hooks/mm/useMMAllowance.ts) - Check token allowance for a specific amount
217
215
  - [`useMMApprove()`](./src/hooks/mm/useMMApprove.ts) - Approve token spending
@@ -1,4 +1,3 @@
1
- import type { XToken, ChainId } from '@sodax/types';
2
- export declare const allXTokens: XToken[];
1
+ import type { ChainId } from '@sodax/types';
3
2
  export declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string | undefined;
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIpD,eAAO,MAAM,UAAU,EAAE,MAAM,EAAO,CAAC;AAyBvC,eAAO,MAAM,2BAA2B,iBAAkB,OAAO,SAAS,MAAM,uBAK/E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,eAAO,MAAM,2BAA2B,iBAAkB,OAAO,SAAS,MAAM,uBAO/E,CAAC"}
@@ -3,7 +3,6 @@ export * from './useRepay';
3
3
  export * from './useSupply';
4
4
  export * from './useWithdraw';
5
5
  export * from './useUserReservesData';
6
- export * from './useHubWalletAddress';
7
6
  export * from './useReservesData';
8
7
  export * from './useMMAllowance';
9
8
  export * from './useMMApprove';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -3,7 +3,7 @@ import { type UseMutationResult } from '@tanstack/react-query';
3
3
  import type { SpokeProvider } from '@sodax/sdk';
4
4
  interface BorrowResponse {
5
5
  ok: true;
6
- value: [`0x${string}`, `0x${string}`];
6
+ value: [string, string];
7
7
  }
8
8
  /**
9
9
  * Hook for borrowing tokens from the Sodax money market.
@@ -1 +1 @@
1
- {"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
1
+ {"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
@@ -3,7 +3,7 @@ import type { XToken } from '@sodax/types';
3
3
  import { type UseMutationResult } from '@tanstack/react-query';
4
4
  interface RepayResponse {
5
5
  ok: true;
6
- value: [`0x${string}`, `0x${string}`];
6
+ value: [string, string];
7
7
  }
8
8
  /**
9
9
  * Hook for repaying borrowed tokens to the Sodax money market.
@@ -1 +1 @@
1
- {"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BjD"}
1
+ {"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BjD"}
@@ -3,7 +3,7 @@ import type { XToken } from '@sodax/types';
3
3
  import { type UseMutationResult } from '@tanstack/react-query';
4
4
  interface SupplyResponse {
5
5
  ok: true;
6
- value: [`0x${string}`, `0x${string}`];
6
+ value: [string, string];
7
7
  }
8
8
  /**
9
9
  * Hook for supplying tokens to the Sodax money market.
@@ -1 +1 @@
1
- {"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
1
+ {"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
@@ -1,9 +1,3 @@
1
1
  import type { ChainId } from '@sodax/types';
2
- export declare function useUserReservesData(spokeChainId: ChainId, address: string | undefined): {
3
- token: import("@sodax/sdk").XToken | undefined;
4
- underlyingAsset: string;
5
- scaledATokenBalance: bigint;
6
- usageAsCollateralEnabledOnUser: boolean;
7
- scaledVariableDebt: bigint;
8
- }[] | undefined;
2
+ export declare function useUserReservesData(spokeChainId: ChainId, address: string | undefined): readonly import("@sodax/sdk").UserReserveData[] | undefined;
9
3
  //# sourceMappingURL=useUserReservesData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;;;;;;gBAsCrF"}
1
+ {"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,+DAiCrF"}
@@ -3,7 +3,7 @@ import type { XToken } from '@sodax/types';
3
3
  import { type UseMutationResult } from '@tanstack/react-query';
4
4
  interface WithdrawResponse {
5
5
  ok: true;
6
- value: [`0x${string}`, `0x${string}`];
6
+ value: [string, string];
7
7
  }
8
8
  /**
9
9
  * Hook for withdrawing supplied tokens from the Sodax money market.
@@ -1 +1 @@
1
- {"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA2BpD"}
1
+ {"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA2BpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAGb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,GAC3C,aAAa,GAAG,SAAS,CAgD3B"}
1
+ {"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAIb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,GAC3C,aAAa,GAAG,SAAS,CAqD3B"}
@@ -1,10 +1,10 @@
1
- import type { CreateIntentParams, IntentExecutionResponse, Result, IntentSubmitErrorCode, Intent, PacketData, IntentSubmitError, SpokeProvider } from '@sodax/sdk';
1
+ import type { CreateIntentParams, SolverExecutionResponse, Result, IntentErrorCode, Intent, PacketData, IntentError, SpokeProvider } from '@sodax/sdk';
2
2
  import { type UseMutationResult } from '@tanstack/react-query';
3
3
  type CreateIntentResult = Result<[
4
- IntentExecutionResponse,
4
+ SolverExecutionResponse,
5
5
  Intent,
6
6
  PacketData
7
- ], IntentSubmitError<IntentSubmitErrorCode>>;
7
+ ], IntentError<IntentErrorCode>>;
8
8
  /**
9
9
  * Hook for creating and submitting an intent order for cross-chain swaps.
10
10
  * Uses React Query's useMutation for better state management and caching.
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,iBAAiB,CAAC,qBAAqB,CAAC,CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAWlE"}
1
+ {"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,eAAe,EACf,MAAM,EACN,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,WAAW,CAAC,eAAe,CAAC,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAWlE"}
@@ -1,13 +1,13 @@
1
- import type { IntentErrorResponse, IntentQuoteRequest, IntentQuoteResponse, Result } from '@sodax/sdk';
1
+ import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';
2
2
  import { type UseQueryResult } from '@tanstack/react-query';
3
3
  /**
4
4
  * Hook for fetching a quote for an intent-based swap.
5
5
  *
6
6
  * This hook provides real-time quote data for an intent-based swap.
7
7
  *
8
- * @param {IntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
8
+ * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
9
9
  *
10
- * @returns {UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined>} A query result object containing:
10
+ * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:
11
11
  * - data: The quote result from the solver
12
12
  * - isLoading: Boolean indicating if the quote is being fetched
13
13
  * - error: Error object if the quote request failed
@@ -35,5 +35,5 @@ import { type UseQueryResult } from '@tanstack/react-query';
35
35
  * - The query is disabled when payload is undefined
36
36
  * - Uses React Query for efficient caching and state management
37
37
  */
38
- export declare const useQuote: (payload: IntentQuoteRequest | undefined) => UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined>;
38
+ export declare const useQuote: (payload: SolverIntentQuoteRequest | undefined) => UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>;
39
39
  //# sourceMappingURL=useQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEvG,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ,YACV,kBAAkB,GAAG,SAAS,KACtC,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAa7E,CAAC"}
1
+ {"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEnH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ,YACV,wBAAwB,GAAG,SAAS,KAC5C,cAAc,CAAC,MAAM,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAanF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Hex, IntentErrorResponse, IntentStatusResponse, Result } from '@sodax/sdk';
1
+ import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';
2
2
  import { type UseQueryResult } from '@tanstack/react-query';
3
3
  /**
4
4
  * Hook for monitoring the status of an intent-based swap.
@@ -7,7 +7,7 @@ import { type UseQueryResult } from '@tanstack/react-query';
7
7
  *
8
8
  * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain
9
9
  *
10
- * @returns {UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined>} A query result object containing:
10
+ * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:
11
11
  * - data: The status result from the solver
12
12
  * - isLoading: Boolean indicating if the status is being fetched
13
13
  * - error: Error object if the status request failed
@@ -27,5 +27,5 @@ import { type UseQueryResult } from '@tanstack/react-query';
27
27
  * - The status is automatically refreshed every 3 seconds
28
28
  * - Uses React Query for efficient caching and state management
29
29
  */
30
- export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined>;
30
+ export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>;
31
31
  //# sourceMappingURL=useStatus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,SAAS,mBACJ,GAAG,KAClB,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAS9E,CAAC"}
1
+ {"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,SAAS,mBACJ,GAAG,KAClB,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,GAAG,SAAS,CASpF,CAAC"}
package/dist/index.js CHANGED
@@ -58,11 +58,15 @@ function useSpokeProvider(spokeChainId, walletProvider) {
58
58
  }
59
59
  if (xChainType === "STELLAR") {
60
60
  const stellarConfig = sdk.spokeChainConfig[spokeChainId];
61
- return new sdk.StellarSpokeProvider(
61
+ return new sdk.StellarSpokeProvider(_walletProvider, stellarConfig, {
62
+ horizonRpcUrl: stellarConfig.horizonRpcUrl,
63
+ sorobanRpcUrl: stellarConfig.sorobanRpcUrl
64
+ });
65
+ }
66
+ if (xChainType === "SOLANA") {
67
+ return new sdk.SolanaSpokeProvider(
62
68
  _walletProvider,
63
- stellarConfig.addresses.assetManager,
64
- stellarConfig,
65
- stellarConfig.rpc_url
69
+ sdk.spokeChainConfig[spokeChainId]
66
70
  );
67
71
  }
68
72
  return void 0;
@@ -76,7 +80,7 @@ function useBorrow(spokeToken, spokeProvider) {
76
80
  if (!spokeProvider) {
77
81
  throw new Error("spokeProvider is not found");
78
82
  }
79
- const response = await sodax.moneyMarket.borrowAndSubmit(
83
+ const response = await sodax.moneyMarket.borrow(
80
84
  {
81
85
  token: spokeToken.address,
82
86
  amount: viem.parseUnits(amount, 18),
@@ -99,7 +103,7 @@ function useRepay(spokeToken, spokeProvider) {
99
103
  if (!spokeProvider) {
100
104
  throw new Error("spokeProvider is not found");
101
105
  }
102
- const response = await sodax.moneyMarket.repayAndSubmit(
106
+ const response = await sodax.moneyMarket.repay(
103
107
  {
104
108
  token: spokeToken.address,
105
109
  amount: viem.parseUnits(amount, spokeToken.decimals),
@@ -122,7 +126,7 @@ function useSupply(spokeToken, spokeProvider) {
122
126
  if (!spokeProvider) {
123
127
  throw new Error("spokeProvider is not found");
124
128
  }
125
- const response = await sodax.moneyMarket.supplyAndSubmit(
129
+ const response = await sodax.moneyMarket.supply(
126
130
  {
127
131
  token: spokeToken.address,
128
132
  amount: viem.parseUnits(amount, spokeToken.decimals),
@@ -145,7 +149,7 @@ function useWithdraw(spokeToken, spokeProvider) {
145
149
  if (!spokeProvider) {
146
150
  throw new Error("spokeProvider is not found");
147
151
  }
148
- const response = await sodax.moneyMarket.withdrawAndSubmit(
152
+ const response = await sodax.moneyMarket.withdraw(
149
153
  {
150
154
  token: spokeToken.address,
151
155
  // vault token on hub chain decimals is 18
@@ -162,32 +166,6 @@ function useWithdraw(spokeToken, spokeProvider) {
162
166
  }
163
167
  });
164
168
  }
165
- var allXTokens = [];
166
- Object.keys(sdk.hubAssets).forEach((xChainId) => {
167
- const tokens = sdk.hubAssets[xChainId];
168
- Object.keys(tokens).forEach((tokenAddress) => {
169
- const token = tokens[tokenAddress];
170
- allXTokens.push({
171
- xChainId,
172
- symbol: token.symbol,
173
- name: token.name,
174
- decimals: token.decimal,
175
- address: tokenAddress
176
- });
177
- allXTokens.push({
178
- xChainId: "sonic",
179
- symbol: token.symbol,
180
- name: token.name,
181
- decimals: token.decimal,
182
- address: token.vault
183
- });
184
- });
185
- });
186
- var getSpokeTokenAddressByVault = (spokeChainId, vault) => {
187
- const tokens = sdk.hubAssets[spokeChainId];
188
- const address = Object.keys(tokens).find((tokenAddress) => tokens[tokenAddress].vault === vault);
189
- return address;
190
- };
191
169
  function useUserReservesData(spokeChainId, address) {
192
170
  const { sodax } = useSodaxContext();
193
171
  const hubChainId = sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? "sonic";
@@ -210,38 +188,13 @@ function useUserReservesData(spokeChainId, address) {
210
188
  moneyMarketConfig.uiPoolDataProvider,
211
189
  moneyMarketConfig.poolAddressesProvider
212
190
  );
213
- return res?.map((r) => {
214
- return {
215
- ...r,
216
- token: allXTokens.find((t) => t.address === r.underlyingAsset)
217
- };
218
- });
191
+ return res;
219
192
  },
220
193
  enabled: !!spokeChainId && !!hubProvider && !!address,
221
194
  refetchInterval: 5e3
222
195
  });
223
196
  return userReserves;
224
197
  }
225
- function useHubWalletAddress(spokeChainId, address, hubProvider) {
226
- return reactQuery.useQuery({
227
- queryKey: ["hubWallet", spokeChainId, address],
228
- queryFn: async () => {
229
- if (!address) return null;
230
- try {
231
- const hubWalletAddress = await sdk.EvmWalletAbstraction.getUserHubWalletAddress(
232
- spokeChainId,
233
- address,
234
- hubProvider
235
- );
236
- return hubWalletAddress;
237
- } catch (error) {
238
- console.log("error", error);
239
- return null;
240
- }
241
- },
242
- enabled: !!address && !!hubProvider
243
- });
244
- }
245
198
  function useReservesData() {
246
199
  const { sodax } = useSodaxContext();
247
200
  const hubChainId = sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? "sonic";
@@ -421,14 +374,19 @@ var SodaxProvider = ({ children, testnet = false, config }) => {
421
374
  }, [hubChainId, hubRpcUrl]);
422
375
  return /* @__PURE__ */ React__default.default.createElement(SodaxContext.Provider, { value: { sodax, testnet, hubProvider } }, children);
423
376
  };
377
+ var getSpokeTokenAddressByVault = (spokeChainId, vault) => {
378
+ const tokens = sdk.hubAssets[spokeChainId];
379
+ const address = Object.keys(tokens).find(
380
+ (tokenAddress) => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase()
381
+ );
382
+ return address;
383
+ };
424
384
 
425
385
  exports.SodaxProvider = SodaxProvider;
426
- exports.allXTokens = allXTokens;
427
386
  exports.getSpokeTokenAddressByVault = getSpokeTokenAddressByVault;
428
387
  exports.useBorrow = useBorrow;
429
388
  exports.useCreateIntentOrder = useCreateIntentOrder;
430
389
  exports.useHubProvider = useHubProvider;
431
- exports.useHubWalletAddress = useHubWalletAddress;
432
390
  exports.useMMAllowance = useMMAllowance;
433
391
  exports.useMMApprove = useMMApprove;
434
392
  exports.useQuote = useQuote;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/core/index.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useHubWalletAddress.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useCreateIntentOrder.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/providers/SodaxProvider.tsx"],"names":["createContext","useContext","getXChainType","useWalletProvider","useMemo","EvmSpokeProvider","spokeChainConfig","SuiSpokeProvider","IconSpokeProvider","CWSpokeProvider","StellarSpokeProvider","useMutation","parseUnits","hubAssets","useQuery","encodeAddress","EvmWalletAbstraction","getMoneyMarketConfig","useQueryClient","Sodax","getHubChainConfig","EvmHubProvider","React"],"mappings":";;;;;;;;;;;;;AASO,IAAM,YAAA,GAAeA,oBAAuC,IAAI,CAAA;ACAhE,IAAM,kBAAkB,MAAwB;AACrD,EAAM,MAAA,OAAA,GAAUC,iBAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAEvE,EAAO,OAAA,OAAA;AACT;;;ACZO,SAAS,cAA6C,GAAA;AAC3D,EAAM,MAAA,EAAE,WAAY,EAAA,GAAI,eAAgB,EAAA;AAExC,EAAO,OAAA,WAAA;AACT;ACiCO,SAAS,gBAAA,CACd,cACA,cAC2B,EAAA;AAC3B,EAAM,MAAA,UAAA,GAAaC,wBAAc,YAAY,CAAA;AAC7C,EAAM,MAAA,eAAA,GAAkBC,4BAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,kBAAkB,cAAkB,IAAA,eAAA;AAE1C,EAAM,MAAA,aAAA,GAAgBC,cAAQ,MAAM;AAClC,IAAI,IA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E1B,EAAO,uBAAAC,sBAAA,CAAA,aAAA,CAAC,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAO,EAAA,OAAA,EAAS,WAAY,EAAA,EAAA,EAAI,QAAS,CAAA;AAClF","file":"index.js","sourcesContent":["import { createContext } from 'react';\nimport type { EvmHubProvider, Sodax } from '@sodax/sdk';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n hubProvider: EvmHubProvider | undefined;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider | undefined {\n const { hubProvider } = useSodaxContext();\n\n return hubProvider;\n}\n","import {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n CWSpokeProvider,\n type CosmosSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n} from '@sodax/types';\nimport { getXChainType, useWalletProvider } from '@sodax/wallet-sdk';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const xChainType = getXChainType(spokeChainId);\n const walletProvider_ = useWalletProvider(spokeChainId);\n const _walletProvider = walletProvider ?? walletProvider_;\n\n const spokeProvider = useMemo(() => {\n if (!_walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n\n if (xChainType === 'EVM') {\n return new EvmSpokeProvider(\n _walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n _walletProvider as ISuiWalletProvider,\n );\n }\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n _walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n if (xChainType === 'INJECTIVE') {\n return new CWSpokeProvider(\n spokeChainConfig[spokeChainId] as CosmosSpokeChainConfig,\n _walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n _walletProvider as IStellarWalletProvider,\n stellarConfig.addresses.assetManager,\n stellarConfig,\n stellarConfig.rpc_url,\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, _walletProvider]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [`0x${string}`, `0x${string}`];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrowAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [`0x${string}`, `0x${string}`];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repayAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [`0x${string}`, `0x${string}`];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supplyAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [`0x${string}`, `0x${string}`];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdrawAndSubmit(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { XToken, ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const allXTokens: XToken[] = [];\n\nObject.keys(hubAssets).forEach(xChainId => {\n const tokens = hubAssets[xChainId];\n\n Object.keys(tokens).forEach(tokenAddress => {\n const token = tokens[tokenAddress];\n allXTokens.push({\n xChainId: xChainId as ChainId,\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: tokenAddress,\n });\n\n allXTokens.push({\n xChainId: 'sonic',\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: token.vault,\n });\n });\n});\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(tokenAddress => tokens[tokenAddress].vault === vault);\n\n return address;\n};\n","import { allXTokens } from '@/core';\nimport { encodeAddress, EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';\nimport type { HubChainId, SpokeChainId } from '@sodax/types';\nimport type { ChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useHubProvider } from '../provider/useHubProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useUserReservesData(spokeChainId: ChainId, address: string | undefined) {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n const hubProvider = useHubProvider();\n\n const { data: userReserves } = useQuery({\n queryKey: ['userReserves', spokeChainId, address],\n queryFn: async () => {\n if (!hubProvider || !address) {\n return;\n }\n\n const addressBytes = encodeAddress(spokeChainId, address);\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId as SpokeChainId,\n addressBytes,\n hubProvider as EvmHubProvider,\n );\n\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n const [res] = await sodax.moneyMarket.getUserReservesData(\n hubWalletAddress as `0x${string}`,\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n\n return res?.map(r => {\n return {\n ...r,\n token: allXTokens.find(t => t.address === r.underlyingAsset),\n };\n });\n },\n enabled: !!spokeChainId && !!hubProvider && !!address,\n refetchInterval: 5000,\n });\n\n return userReserves;\n}\n","import { type EvmHubProvider, EvmWalletAbstraction, type SpokeChainId } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for retrieving the hub wallet address for a given spoke chain and address.\n *\n * This hook fetches the hub wallet address associated with a user's address on a specific spoke chain.\n * It uses the EvmWalletAbstraction to query the hub wallet address from the hub provider.\n *\n * @param spokeChainId - The chain ID of the spoke chain\n * @param address - The user's address on the spoke chain\n * @param hubProvider - The hub provider instance\n *\n * @returns {UseQueryResult<string | null>} A query result object containing:\n * - data: The hub wallet address or null if not found\n * - isLoading: Boolean indicating if the query is in progress\n * - error: Error object if the query failed, null otherwise\n *\n * @example\n * ```typescript\n * const { data: hubWalletAddress, isLoading, error } = useHubWalletAddress(spokeChainId, address, hubProvider);\n * ```\n */\n\nexport function useHubWalletAddress(\n spokeChainId: SpokeChainId,\n address: string | undefined,\n hubProvider: EvmHubProvider,\n): UseQueryResult<string | null> {\n return useQuery({\n queryKey: ['hubWallet', spokeChainId, address],\n queryFn: async () => {\n if (!address) return null;\n\n try {\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId,\n address as `0x${string}`,\n hubProvider,\n );\n return hubWalletAddress;\n } catch (error) {\n console.log('error', error);\n return null;\n }\n },\n enabled: !!address && !!hubProvider,\n });\n}\n","import { getMoneyMarketConfig } from '@sodax/sdk';\nimport type { HubChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n return await sodax.moneyMarket.getReservesData(\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { IntentErrorResponse, IntentQuoteRequest, IntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {IntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: IntentQuoteRequest | undefined,\n): UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n IntentExecutionResponse,\n Result,\n IntentSubmitErrorCode,\n Intent,\n PacketData,\n IntentSubmitError,\n SpokeProvider,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<\n [IntentExecutionResponse, Intent, PacketData],\n IntentSubmitError<IntentSubmitErrorCode>\n>;\n\n/**\n * Hook for creating and submitting an intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await createIntent({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useCreateIntentOrder(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.createAndSubmitIntent(params, spokeProvider);\n },\n });\n}\n","import type { Hex, IntentErrorResponse, IntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid(params, spokeProvider);\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Token } from '@sodax/types';\nimport { type Address, parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount }: { amount: string }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(token: Token | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount }: { amount: string }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!token) {\n throw new Error('Token not found');\n }\n\n const allowance = await sodax.solver.approve(\n token.address as Address,\n parseUnits(amount, token.decimals),\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token?.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport { EvmHubProvider, getHubChainConfig, Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport React, { useMemo } from 'react';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config: SodaxConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n const hubChainId = config?.hubProviderConfig?.chainConfig.chain.id;\n const hubRpcUrl = config?.hubProviderConfig?.hubRpcUrl;\n\n const hubProvider = useMemo(() => {\n if (hubChainId && hubRpcUrl) {\n const hubChainCfg = getHubChainConfig(hubChainId);\n\n return new EvmHubProvider({\n hubRpcUrl: hubRpcUrl,\n chainConfig: hubChainCfg,\n });\n }\n return undefined;\n }, [hubChainId, hubRpcUrl]);\n\n return <SodaxContext.Provider value={{ sodax, testnet, hubProvider }}>{children}</SodaxContext.Provider>;\n};\n"]}
1
+ {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useCreateIntentOrder.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["createContext","useContext","getXChainType","useWalletProvider","useMemo","EvmSpokeProvider","spokeChainConfig","SuiSpokeProvider","IconSpokeProvider","CWSpokeProvider","StellarSpokeProvider","SolanaSpokeProvider","useMutation","parseUnits","useQuery","encodeAddress","EvmWalletAbstraction","getMoneyMarketConfig","useQueryClient","Sodax","getHubChainConfig","EvmHubProvider","React","hubAssets"],"mappings":";;;;;;;;;;;;;AASO,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AA,OAAO,IAAIC,kBAAe,CAAA;AAAA,QACxB,SAAA;AAAA,QACA,WAAa,EAAA;AAAA,OACd,CAAA;AAAA;AAEH,IAAO,OAAA,MAAA;AAAA,GACN,EAAA,CAAC,UAAY,EAAA,SAAS,CAAC,CAAA;AAE1B,EAAO,uBAAAC,sBAAA,CAAA,aAAA,CAAC,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAO,EAAA,OAAA,EAAS,WAAY,EAAA,EAAA,EAAI,QAAS,CAAA;AAClF;AC1Ba,IAAA,2BAAA,GAA8B,CAAC,YAAA,EAAuB,KAAkB,KAAA;AACnF,EAAM,MAAA,MAAA,GAASC,cAAU,YAAY,CAAA;AACrC,EAAA,MAAM,OAAU,GAAA,MAAA,CAAO,IAAK,CAAA,MAAM,CAAE,CAAA,IAAA;AAAA,IAClC,CAAA,YAAA,KAAgB,OAAO,YAAY,CAAA,CAAE,MAAM,WAAY,EAAA,KAAM,MAAM,WAAY;AAAA,GACjF;AAEA,EAAO,OAAA,OAAA;AACT","file":"index.js","sourcesContent":["import { createContext } from 'react';\nimport type { EvmHubProvider, Sodax } from '@sodax/sdk';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n hubProvider: EvmHubProvider | undefined;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider | undefined {\n const { hubProvider } = useSodaxContext();\n\n return hubProvider;\n}\n","import {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n CWSpokeProvider,\n type CosmosSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { getXChainType, useWalletProvider } from '@sodax/wallet-sdk';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const xChainType = getXChainType(spokeChainId);\n const walletProvider_ = useWalletProvider(spokeChainId);\n const _walletProvider = walletProvider ?? walletProvider_;\n\n const spokeProvider = useMemo(() => {\n if (!_walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n\n if (xChainType === 'EVM') {\n return new EvmSpokeProvider(\n _walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n _walletProvider as ISuiWalletProvider,\n );\n }\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n _walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n if (xChainType === 'INJECTIVE') {\n return new CWSpokeProvider(\n spokeChainConfig[spokeChainId] as CosmosSpokeChainConfig,\n _walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(_walletProvider as IStellarWalletProvider, stellarConfig, {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n });\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n _walletProvider as ISolanaWalletProvider,\n spokeChainConfig[spokeChainId] as SolanaChainConfig,\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, _walletProvider]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import { encodeAddress, EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';\nimport type { HubChainId, SpokeChainId } from '@sodax/types';\nimport type { ChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useHubProvider } from '../provider/useHubProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useUserReservesData(spokeChainId: ChainId, address: string | undefined) {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n const hubProvider = useHubProvider();\n\n const { data: userReserves } = useQuery({\n queryKey: ['userReserves', spokeChainId, address],\n queryFn: async () => {\n if (!hubProvider || !address) {\n return;\n }\n\n const addressBytes = encodeAddress(spokeChainId, address);\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId as SpokeChainId,\n addressBytes,\n hubProvider as EvmHubProvider,\n );\n\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n const [res] = await sodax.moneyMarket.getUserReservesData(\n hubWalletAddress as `0x${string}`,\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n\n return res;\n },\n enabled: !!spokeChainId && !!hubProvider && !!address,\n refetchInterval: 5000,\n });\n\n return userReserves;\n}\n","import { getMoneyMarketConfig } from '@sodax/sdk';\nimport type { HubChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n return await sodax.moneyMarket.getReservesData(\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n PacketData,\n IntentError,\n SpokeProvider,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<\n [SolverExecutionResponse, Intent, PacketData],\n IntentError<IntentErrorCode>\n>;\n\n/**\n * Hook for creating and submitting an intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await createIntent({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useCreateIntentOrder(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.createAndSubmitIntent(params, spokeProvider);\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid(params, spokeProvider);\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Token } from '@sodax/types';\nimport { type Address, parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount }: { amount: string }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(token: Token | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount }: { amount: string }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!token) {\n throw new Error('Token not found');\n }\n\n const allowance = await sodax.solver.approve(\n token.address as Address,\n parseUnits(amount, token.decimals),\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token?.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport { EvmHubProvider, getHubChainConfig, Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport React, { useMemo } from 'react';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config: SodaxConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n const hubChainId = config?.hubProviderConfig?.chainConfig.chain.id;\n const hubRpcUrl = config?.hubProviderConfig?.hubRpcUrl;\n\n const hubProvider = useMemo(() => {\n if (hubChainId && hubRpcUrl) {\n const hubChainCfg = getHubChainConfig(hubChainId);\n\n return new EvmHubProvider({\n hubRpcUrl: hubRpcUrl,\n chainConfig: hubChainCfg,\n });\n }\n return undefined;\n }, [hubChainId, hubRpcUrl]);\n\n return <SodaxContext.Provider value={{ sodax, testnet, hubProvider }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}