-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove signer from contract hooks (#34)
* JSON importers must only return JSON without wrapping into ethers.Contract (also future react-sdk compatibility) * Update all the code to use new address-abi-only contracts and create ethers.Contract on the fly * Fix rogue SpotMarket.getWrapper * Deps * Move importers again * Update useClosePosition * Collocate all contract importer hooks and unify the structure
- Loading branch information
Showing
168 changed files
with
992 additions
and
1,111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
liquidity/lib/contracts/useAccountProxy/useAccountProxy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importAccountProxy } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useAccountProxy(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'AccountProxy'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw new Error('OMFG'); | ||
return importAccountProxy(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
liquidity/lib/contracts/useClosePosition/useClosePosition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importClosePosition } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useClosePosition(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'ClosePosition'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw 'OMFG'; | ||
return importClosePosition(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importCoreProxy } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useCoreProxy(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'CoreProxy'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw 'OMFG'; | ||
return importCoreProxy(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
liquidity/lib/contracts/useLegacyMarket/useLegacyMarket.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importLegacyMarket } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useLegacyMarket(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'LegacyMarket'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw new Error('OMFG'); | ||
return importLegacyMarket(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importMulticall3 } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useMulticall3(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'Multicall3'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw new Error('OMFG'); | ||
return importMulticall3(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
liquidity/lib/contracts/useOracleManagerProxy/useOracleManagerProxy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importOracleManagerProxy } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useOracleManagerProxy(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'OracleManagerProxy'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) throw new Error('OMFG'); | ||
return importOracleManagerProxy(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
16 changes: 6 additions & 10 deletions
16
...rdsDistributors/useRewardsDistributors.ts → ...rdsDistributors/useRewardsDistributors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
import { importRewardsDistributors } from '@snx-v3/contracts'; | ||
import { Network, useNetwork } from '@snx-v3/useBlockchain'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { importRewardsDistributors } from '@snx-v3/contracts'; | ||
|
||
export function useRewardsDistributors(customNetwork?: Network) { | ||
const { network } = useNetwork(); | ||
const targetNetwork = customNetwork || network; | ||
|
||
return useQuery({ | ||
enabled: Boolean(targetNetwork), | ||
queryKey: [`${targetNetwork?.id}-${targetNetwork?.preset}`, 'RewardsDistributors'], | ||
enabled: Boolean(targetNetwork), | ||
queryFn: async function () { | ||
if (!targetNetwork) { | ||
throw new Error('OMG'); | ||
} | ||
const rewardDistributors = await importRewardsDistributors( | ||
targetNetwork?.id, | ||
targetNetwork?.preset | ||
); | ||
return rewardDistributors; | ||
if (!targetNetwork) throw new Error('OMFG'); | ||
return importRewardsDistributors(targetNetwork.id, targetNetwork.preset); | ||
}, | ||
staleTime: Infinity, | ||
// On some chains this is not available, and that is expected | ||
throwOnError: false, | ||
}); | ||
} |
File renamed without changes.
Oops, something went wrong.