@sodax/dapp-kit 0.0.1-rc.17 → 0.0.1-rc.19
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/LICENSE +21 -0
- package/README.md +10 -21
- package/dist/contexts/index.d.ts +2 -0
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/hooks/mm/useReservesData.d.ts.map +1 -1
- package/dist/hooks/mm/useReservesHumanized.d.ts +21 -0
- package/dist/hooks/mm/useReservesHumanized.d.ts.map +1 -0
- package/dist/hooks/mm/useReservesList.d.ts +18 -0
- package/dist/hooks/mm/useReservesList.d.ts.map +1 -0
- package/dist/hooks/mm/useReservesUsdFormat.d.ts +23 -0
- package/dist/hooks/mm/useReservesUsdFormat.d.ts.map +1 -0
- package/dist/hooks/mm/useUserFormattedSummary.d.ts +22 -0
- package/dist/hooks/mm/useUserFormattedSummary.d.ts.map +1 -0
- package/dist/hooks/mm/useUserReservesData.d.ts +19 -1
- package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
- package/dist/hooks/swap/useSwap.d.ts +2 -2
- package/dist/hooks/swap/useSwap.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -44
- package/dist/index.mjs.map +1 -1
- package/dist/providers/SodaxProvider.d.ts +4 -2
- package/dist/providers/SodaxProvider.d.ts.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +3 -4
- package/src/contexts/index.ts +2 -0
- package/src/hooks/mm/useReservesData.ts +1 -8
- package/src/hooks/mm/useReservesHumanized.ts +30 -0
- package/src/hooks/mm/useReservesList.ts +29 -0
- package/src/hooks/mm/useReservesUsdFormat.ts +38 -0
- package/src/hooks/mm/useUserFormattedSummary.ts +57 -0
- package/src/hooks/mm/useUserReservesData.ts +29 -28
- package/src/hooks/provider/useSpokeProvider.ts +23 -14
- package/src/hooks/swap/useSwap.ts +2 -2
- package/src/index.ts +1 -0
- package/src/providers/SodaxProvider.tsx +5 -3
- package/src/types.ts +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2025] [Sodax]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,10 +10,14 @@ dApp Kit is a collection of React components, hooks, and utilities designed to s
|
|
|
10
10
|
- Withdraw tokens from the money market (`useWithdraw`)
|
|
11
11
|
- Borrow tokens from the money market (`useBorrow`)
|
|
12
12
|
- Repay borrowed tokens (`useRepay`)
|
|
13
|
-
- Get user reserves data (`useUserReservesData`)
|
|
14
|
-
- Get reserves data (`useReservesData`)
|
|
15
13
|
- Check token allowance (`useMMAllowance`)
|
|
16
14
|
- Approve token spending (`useMMApprove`)
|
|
15
|
+
- Get user reserves data (`useUserReservesData`)
|
|
16
|
+
- Get reserves data (`useReservesData`)
|
|
17
|
+
- Get humanized reserves data (`useReservesHumanized`)
|
|
18
|
+
- Get list of reserves (`useReservesList`)
|
|
19
|
+
- Get USD formatted reserves data (`useReservesUsdFormat`)
|
|
20
|
+
- Get formatted user portfolio summary (`useUserFormattedSummary`)
|
|
17
21
|
|
|
18
22
|
- Swap/Intent
|
|
19
23
|
- Get quote for an intent order (`useQuote`)
|
|
@@ -42,7 +46,7 @@ pnpm add @sodax/dapp-kit
|
|
|
42
46
|
1. First, install the required dependencies:
|
|
43
47
|
|
|
44
48
|
```bash
|
|
45
|
-
|
|
49
|
+
pnpm install @sodax/dapp-kit @tanstack/react-query @sodax/wallet-sdk
|
|
46
50
|
```
|
|
47
51
|
|
|
48
52
|
2. Set up the providers in your app:
|
|
@@ -51,31 +55,16 @@ npm install @sodax/dapp-kit @tanstack/react-query @sodax/wallet-sdk
|
|
|
51
55
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
52
56
|
import { XWagmiProviders } from '@sodax/wallet-sdk';
|
|
53
57
|
import { SodaxProvider } from '@sodax/dapp-kit';
|
|
54
|
-
import { SONIC_MAINNET_CHAIN_ID } from '@sodax/types';
|
|
55
58
|
|
|
56
59
|
const queryClient = new QueryClient();
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
hubProviderConfig: {
|
|
61
|
-
hubRpcUrl: 'https://rpc.soniclabs.com',
|
|
62
|
-
chainConfig: getHubChainConfig(SONIC_MAINNET_CHAIN_ID),
|
|
63
|
-
},
|
|
64
|
-
moneyMarket: getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID),
|
|
65
|
-
solver: {
|
|
66
|
-
intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
|
|
67
|
-
solverApiEndpoint: 'https://sodax-solver-staging.iconblockchain.xyz',
|
|
68
|
-
partnerFee: {
|
|
69
|
-
address: '0x0Ab764AB3816cD036Ea951bE973098510D8105A6',
|
|
70
|
-
percentage: 100, // 1%
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
relayerApiEndpoint: 'https://xcall-relay.nw.iconblockchain.xyz',
|
|
61
|
+
const rpcConfig = {
|
|
62
|
+
"solana": "private rpc url",
|
|
74
63
|
};
|
|
75
64
|
|
|
76
65
|
function App() {
|
|
77
66
|
return (
|
|
78
|
-
<SodaxProvider testnet={false}
|
|
67
|
+
<SodaxProvider testnet={false} rpcConfig={rpcConfig}>
|
|
79
68
|
<QueryClientProvider client={queryClient}>
|
|
80
69
|
<XWagmiProviders
|
|
81
70
|
config={{
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { EvmHubProvider, Sodax } from '@sodax/sdk';
|
|
2
|
+
import type { RpcConfig } from '@/types';
|
|
2
3
|
export interface SodaxContextType {
|
|
3
4
|
sodax: Sodax;
|
|
4
5
|
testnet: boolean;
|
|
5
6
|
hubProvider: EvmHubProvider | undefined;
|
|
7
|
+
rpcConfig: RpcConfig;
|
|
6
8
|
}
|
|
7
9
|
export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesData.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,eAAe,mKAS9B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReservesDataHumanized } from '@sodax/sdk';
|
|
2
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching humanized reserves data from the Sodax money market.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to the current state of all reserves (humanized format) in the money market protocol,
|
|
7
|
+
* including liquidity, interest rates, and other key metrics. The data is automatically
|
|
8
|
+
* fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const { data: reservesHumanized, isLoading, error } = useReservesHumanized();
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @returns A React Query result object containing:
|
|
16
|
+
* - data: The reserves humanized data when available
|
|
17
|
+
* - isLoading: Loading state indicator
|
|
18
|
+
* - error: Any error that occurred during data fetching
|
|
19
|
+
*/
|
|
20
|
+
export declare function useReservesHumanized(): UseQueryResult<ReservesDataHumanized, Error>;
|
|
21
|
+
//# sourceMappingURL=useReservesHumanized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReservesHumanized.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesHumanized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAAC,qBAAqB,EAAE,KAAK,CAAC,CASnF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for fetching list of reserves from the Sodax money market.
|
|
3
|
+
*
|
|
4
|
+
* This hook provides access to the list of addresses of all reserves in the money market protocol.
|
|
5
|
+
* The data is automatically fetched and cached using React Query.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const { data: reservesList, isLoading, error } = useReservesList();
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @returns A React Query result object containing:
|
|
13
|
+
* - data: The reserves list when available
|
|
14
|
+
* - isLoading: Loading state indicator
|
|
15
|
+
* - error: Any error that occurred during data fetching
|
|
16
|
+
*/
|
|
17
|
+
export declare function useReservesList(): import("@tanstack/react-query").UseQueryResult<readonly `0x${string}`[], Error>;
|
|
18
|
+
//# sourceMappingURL=useReservesList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReservesList.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesList.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,oFAS9B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FormatReserveUSDResponse, ReserveData } from '@sodax/sdk';
|
|
2
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching formatted summary of Sodax user portfolio (holdings, total liquidity,
|
|
5
|
+
* collateral, borrows, liquidation threshold, health factor, available borrowing power, etc..).
|
|
6
|
+
*
|
|
7
|
+
* This hook provides access to the current state of user portfolio in the money market protocol.
|
|
8
|
+
* The data is automatically fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const { data: userFormattedSummary, isLoading, error } = useUserFormattedSummary();
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @returns A React Query result object containing:
|
|
16
|
+
* - data: The formatted summary of Sodax user portfolio when available
|
|
17
|
+
* - isLoading: Loading state indicator
|
|
18
|
+
* - error: Any error that occurred during data fetching
|
|
19
|
+
*/
|
|
20
|
+
export declare function useReservesUsdFormat(): UseQueryResult<(ReserveData & {
|
|
21
|
+
priceInMarketReferenceCurrency: string;
|
|
22
|
+
} & FormatReserveUSDResponse)[], Error>;
|
|
23
|
+
//# sourceMappingURL=useReservesUsdFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReservesUsdFormat.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesUsdFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CACpD,CAAC,WAAW,GAAG;IAAE,8BAA8B,EAAE,MAAM,CAAA;CAAE,GAAG,wBAAwB,CAAC,EAAE,EACvF,KAAK,CACN,CAaA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type FormatUserSummaryResponse, type FormatReserveUSDResponse } from '@sodax/sdk';
|
|
2
|
+
import type { ChainId } from '@sodax/types';
|
|
3
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
4
|
+
/**
|
|
5
|
+
* Hook for fetching formatted summary of Sodax user portfolio (holdings, total liquidity,
|
|
6
|
+
* collateral, borrows, liquidation threshold, health factor, available borrowing power, etc..).
|
|
7
|
+
*
|
|
8
|
+
* This hook provides access to the current state of user portfolio in the money market protocol.
|
|
9
|
+
* The data is automatically fetched and cached using React Query.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const { data: userFormattedSummary, isLoading, error } = useUserFormattedSummary();
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns A React Query result object containing:
|
|
17
|
+
* - data: The formatted summary of Sodax user portfolio when available
|
|
18
|
+
* - isLoading: Loading state indicator
|
|
19
|
+
* - error: Any error that occurred during data fetching
|
|
20
|
+
*/
|
|
21
|
+
export declare function useUserFormattedSummary(spokeChainId: ChainId | undefined, address: string | undefined): UseQueryResult<FormatUserSummaryResponse<FormatReserveUSDResponse> | undefined, Error>;
|
|
22
|
+
//# sourceMappingURL=useUserFormattedSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserFormattedSummary.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserFormattedSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAE,KAAK,wBAAwB,EAA4B,MAAM,YAAY,CAAC;AACrH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAItE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,OAAO,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,cAAc,CAAC,yBAAyB,CAAC,wBAAwB,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC,CA8BxF"}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { type UserReserveData } from '@sodax/sdk';
|
|
1
2
|
import type { ChainId } from '@sodax/types';
|
|
2
|
-
|
|
3
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
4
|
+
/**
|
|
5
|
+
* Hook for fetching user reserves data from the Sodax money market.
|
|
6
|
+
*
|
|
7
|
+
* This hook provides access to the current state of user reserves in the money market protocol.
|
|
8
|
+
* The data is automatically fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const { data: userReservesData, isLoading, error } = useUserReservesData();
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @returns A React Query result object containing:
|
|
16
|
+
* - data: The user reserves data when available
|
|
17
|
+
* - isLoading: Loading state indicator
|
|
18
|
+
* - error: Any error that occurred during data fetching
|
|
19
|
+
*/
|
|
20
|
+
export declare function useUserReservesData(spokeChainId: ChainId | undefined, address: string | undefined, refetchInterval?: number): UseQueryResult<readonly [readonly UserReserveData[], number] | undefined, Error>;
|
|
3
21
|
//# sourceMappingURL=useUserReservesData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAItE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,OAAO,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,eAAe,SAAO,GACrB,cAAc,CAAC,SAAS,CAAC,SAAS,eAAe,EAAE,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC,CAgBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAIb,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,GAC3C,aAAa,GAAG,SAAS,CAoE3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CreateIntentParams, SolverExecutionResponse, Result, IntentErrorCode, Intent, IntentError, SpokeProvider,
|
|
1
|
+
import type { CreateIntentParams, SolverExecutionResponse, Result, IntentErrorCode, Intent, IntentError, SpokeProvider, IntentDeliveryInfo } from '@sodax/sdk';
|
|
2
2
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
type CreateIntentResult = Result<[SolverExecutionResponse, Intent,
|
|
3
|
+
type CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;
|
|
4
4
|
/**
|
|
5
5
|
* Hook for creating and submitting an swap intent order for cross-chain swaps.
|
|
6
6
|
* Uses React Query's useMutation for better state management and caching.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useSwap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,eAAe,EACf,MAAM,EACN,WAAW,EACX,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"useSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useSwap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,eAAe,EACf,MAAM,EACN,WAAW,EACX,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAAC,CAAC,uBAAuB,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CACrB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAclE"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var sdk = require('@sodax/sdk');
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
|
-
var walletSdk = require('@sodax/wallet-sdk');
|
|
7
6
|
var viem = require('viem');
|
|
8
7
|
|
|
9
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -37,57 +36,61 @@ function useHubProvider() {
|
|
|
37
36
|
return hubProvider;
|
|
38
37
|
}
|
|
39
38
|
function useSpokeProvider(spokeChainId, walletProvider) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const _walletProvider = walletProvider ?? walletProvider_;
|
|
39
|
+
const { rpcConfig } = useSodaxContext();
|
|
40
|
+
const xChainType = spokeChainId ? sdk.spokeChainConfig[spokeChainId]?.chain.type : void 0;
|
|
43
41
|
const spokeProvider = React.useMemo(() => {
|
|
44
|
-
if (!
|
|
42
|
+
if (!walletProvider) return void 0;
|
|
45
43
|
if (!spokeChainId) return void 0;
|
|
44
|
+
if (!xChainType) return void 0;
|
|
45
|
+
if (!rpcConfig) return void 0;
|
|
46
46
|
if (xChainType === "EVM") {
|
|
47
47
|
if (spokeChainId === sdk.SONIC_MAINNET_CHAIN_ID) {
|
|
48
48
|
return new sdk.SonicSpokeProvider(
|
|
49
|
-
|
|
49
|
+
walletProvider,
|
|
50
50
|
sdk.spokeChainConfig[spokeChainId]
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
return new sdk.EvmSpokeProvider(
|
|
54
|
-
|
|
54
|
+
walletProvider,
|
|
55
55
|
sdk.spokeChainConfig[spokeChainId]
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
if (xChainType === "SUI") {
|
|
59
59
|
return new sdk.SuiSpokeProvider(
|
|
60
60
|
sdk.spokeChainConfig[spokeChainId],
|
|
61
|
-
|
|
61
|
+
walletProvider
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
if (xChainType === "ICON") {
|
|
65
65
|
return new sdk.IconSpokeProvider(
|
|
66
|
-
|
|
66
|
+
walletProvider,
|
|
67
67
|
sdk.spokeChainConfig[spokeChainId]
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
if (xChainType === "INJECTIVE") {
|
|
71
71
|
return new sdk.InjectiveSpokeProvider(
|
|
72
72
|
sdk.spokeChainConfig[spokeChainId],
|
|
73
|
-
|
|
73
|
+
walletProvider
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
if (xChainType === "STELLAR") {
|
|
77
77
|
const stellarConfig = sdk.spokeChainConfig[spokeChainId];
|
|
78
|
-
return new sdk.StellarSpokeProvider(
|
|
78
|
+
return new sdk.StellarSpokeProvider(walletProvider, stellarConfig, {
|
|
79
79
|
horizonRpcUrl: stellarConfig.horizonRpcUrl,
|
|
80
80
|
sorobanRpcUrl: stellarConfig.sorobanRpcUrl
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
if (xChainType === "SOLANA") {
|
|
84
84
|
return new sdk.SolanaSpokeProvider(
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
walletProvider,
|
|
86
|
+
rpcConfig.solana ? {
|
|
87
|
+
...sdk.spokeChainConfig[spokeChainId],
|
|
88
|
+
rpcUrl: rpcConfig.solana
|
|
89
|
+
} : sdk.spokeChainConfig[spokeChainId]
|
|
87
90
|
);
|
|
88
91
|
}
|
|
89
92
|
return void 0;
|
|
90
|
-
}, [spokeChainId, xChainType,
|
|
93
|
+
}, [spokeChainId, xChainType, walletProvider, rpcConfig]);
|
|
91
94
|
return spokeProvider;
|
|
92
95
|
}
|
|
93
96
|
function useBorrow(spokeToken, spokeProvider) {
|
|
@@ -183,46 +186,27 @@ function useWithdraw(spokeToken, spokeProvider) {
|
|
|
183
186
|
}
|
|
184
187
|
});
|
|
185
188
|
}
|
|
186
|
-
function useUserReservesData(spokeChainId, address) {
|
|
189
|
+
function useUserReservesData(spokeChainId, address, refetchInterval = 5e3) {
|
|
187
190
|
const { sodax } = useSodaxContext();
|
|
188
|
-
const hubChainId = sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? "sonic";
|
|
189
|
-
const hubProvider = useHubProvider();
|
|
190
191
|
const spokeProvider = useSpokeProvider(spokeChainId);
|
|
191
|
-
|
|
192
|
+
return reactQuery.useQuery({
|
|
192
193
|
queryKey: ["userReserves", spokeChainId, address],
|
|
193
194
|
queryFn: async () => {
|
|
194
|
-
if (!
|
|
195
|
-
return;
|
|
195
|
+
if (!spokeProvider || !address) {
|
|
196
|
+
return void 0;
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
-
address,
|
|
199
|
-
spokeProvider,
|
|
200
|
-
hubProvider
|
|
201
|
-
);
|
|
202
|
-
const moneyMarketConfig = sdk.getMoneyMarketConfig(hubChainId);
|
|
203
|
-
const [res] = await sodax.moneyMarket.getUserReservesData(
|
|
204
|
-
hubWalletAddress,
|
|
205
|
-
moneyMarketConfig.uiPoolDataProvider,
|
|
206
|
-
moneyMarketConfig.poolAddressesProvider
|
|
207
|
-
);
|
|
208
|
-
return res;
|
|
198
|
+
return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);
|
|
209
199
|
},
|
|
210
|
-
enabled: !!spokeChainId && !!
|
|
211
|
-
refetchInterval
|
|
200
|
+
enabled: !!spokeChainId && !!address,
|
|
201
|
+
refetchInterval
|
|
212
202
|
});
|
|
213
|
-
return userReserves;
|
|
214
203
|
}
|
|
215
204
|
function useReservesData() {
|
|
216
205
|
const { sodax } = useSodaxContext();
|
|
217
|
-
const hubChainId = sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? "sonic";
|
|
218
206
|
return reactQuery.useQuery({
|
|
219
207
|
queryKey: ["reservesData"],
|
|
220
208
|
queryFn: async () => {
|
|
221
|
-
|
|
222
|
-
return await sodax.moneyMarket.getReservesData(
|
|
223
|
-
moneyMarketConfig.uiPoolDataProvider,
|
|
224
|
-
moneyMarketConfig.poolAddressesProvider
|
|
225
|
-
);
|
|
209
|
+
return await sodax.moneyMarket.data.getReservesData();
|
|
226
210
|
}
|
|
227
211
|
});
|
|
228
212
|
}
|
|
@@ -380,7 +364,7 @@ function useSwapApprove(params, spokeProvider) {
|
|
|
380
364
|
resetError
|
|
381
365
|
};
|
|
382
366
|
}
|
|
383
|
-
var SodaxProvider = ({ children, testnet = false, config }) => {
|
|
367
|
+
var SodaxProvider = ({ children, testnet = false, config, rpcConfig }) => {
|
|
384
368
|
const sodax = new sdk.Sodax(config);
|
|
385
369
|
const hubChainId = config?.hubProviderConfig?.chainConfig.chain.id;
|
|
386
370
|
const hubRpcUrl = config?.hubProviderConfig?.hubRpcUrl;
|
|
@@ -394,7 +378,7 @@ var SodaxProvider = ({ children, testnet = false, config }) => {
|
|
|
394
378
|
}
|
|
395
379
|
return void 0;
|
|
396
380
|
}, [hubChainId, hubRpcUrl]);
|
|
397
|
-
return /* @__PURE__ */ React__default.default.createElement(SodaxContext.Provider, { value: { sodax, testnet, hubProvider } }, children);
|
|
381
|
+
return /* @__PURE__ */ React__default.default.createElement(SodaxContext.Provider, { value: { sodax, testnet, hubProvider, rpcConfig } }, children);
|
|
398
382
|
};
|
|
399
383
|
var getSpokeTokenAddressByVault = (spokeChainId, vault) => {
|
|
400
384
|
const tokens = sdk.hubAssets[spokeChainId];
|