This repository was archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jordan Frankfurt <[email protected]>
- Loading branch information
1 parent
59164f8
commit 32e679c
Showing
12 changed files
with
163 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ChainId } from '@uniswap/sdk' | ||
|
||
export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: { [chainId in ChainId | 1337]: string } = { | ||
[ChainId.MAINNET]: '', | ||
[ChainId.ROPSTEN]: '', | ||
[ChainId.RINKEBY]: '', | ||
[ChainId.GÖRLI]: '', | ||
[ChainId.KOVAN]: '', | ||
[1337]: '0xee9e30637f84Bbf929042A9118c6E20023dab833', | ||
} | ||
|
||
export const NONFUNGIBLE_TOKEN_POSITION_DESCRIPTOR_ADDRESSES: { [chainId in ChainId | 1337]: string } = { | ||
[ChainId.MAINNET]: '', | ||
[ChainId.ROPSTEN]: '', | ||
[ChainId.RINKEBY]: '', | ||
[ChainId.GÖRLI]: '', | ||
[ChainId.KOVAN]: '', | ||
[1337]: '0x3431b9Ed12e3204bC6f7039e1c576417B70fdD67', | ||
} | ||
|
||
export const SWAP_ROUTER_ADDRESSES: { [chainId in ChainId | 1337]: string } = { | ||
[ChainId.MAINNET]: '', | ||
[ChainId.ROPSTEN]: '', | ||
[ChainId.RINKEBY]: '', | ||
[ChainId.GÖRLI]: '', | ||
[ChainId.KOVAN]: '', | ||
[1337]: '0xa0588c89Fe967e66533aB1A0504C30989f90156f', | ||
} |
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,63 @@ | ||
import { OptionalMethodInputs, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks' | ||
import { Position } from 'types/v3' | ||
import { useV3NFTPositionManagerContract } from './useContract' | ||
|
||
interface UseV3PositionsResults { | ||
error?: (string | boolean) | (string | boolean)[] | ||
loading: boolean | ||
positions: Position[] | ||
} | ||
export function useV3Positions(account: string | null | undefined): UseV3PositionsResults { | ||
const positionManager = useV3NFTPositionManagerContract() | ||
let loading = false | ||
let error: any | ||
const { | ||
error: balanceOfError, | ||
loading: balanceOfLoading, | ||
result: balanceOfResult, | ||
} = useSingleCallResult(positionManager, 'balanceOf', [account || undefined]) | ||
|
||
loading = balanceOfLoading | ||
error = balanceOfError | ||
|
||
const tokenOfOwnerByIndexArgs: OptionalMethodInputs[] = balanceOfResult | ||
? balanceOfResult.filter((x) => Boolean(x)).map((index) => [account, index]) | ||
: [] | ||
const tokensCallResults = useSingleContractMultipleData( | ||
positionManager, | ||
'tokenOfOwnerByIndex', | ||
tokenOfOwnerByIndexArgs | ||
) | ||
|
||
const callData: any[] = [] | ||
tokensCallResults.forEach(({ error: e, loading: l, result: data }) => { | ||
if (e && !error) { | ||
error = e | ||
} | ||
loading = loading || l | ||
if (data) { | ||
callData.push([account, data]) | ||
} | ||
}) | ||
|
||
const positionsCallResults = useSingleContractMultipleData(positionManager, 'positions', callData) | ||
|
||
const positions: any[] = [] | ||
positionsCallResults.forEach(({ error: e, loading: l, result: data }) => { | ||
if (e) { | ||
if (!error) { | ||
error = e | ||
} | ||
if (error && Array.isArray(error)) { | ||
error = [...error, error] | ||
} | ||
} | ||
loading = loading || l | ||
|
||
if (data) { | ||
positions.push(data) | ||
} | ||
}) | ||
|
||
return { error, loading, positions } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Contract } from '@ethersproject/contracts' | ||
|
||
export interface NonfungiblePositionManager extends Contract { | ||
balanceOf(address: string): Promise<BigNumber> | ||
tokenOfOwnerByIndex(address: string, index: BigNumber): Promise<BigNumber> | ||
} |
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,17 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber' | ||
import { basisPointsToPercent } from 'utils' | ||
|
||
const FEE_BIPS = { | ||
FIVE: basisPointsToPercent(5), | ||
THIRTY: basisPointsToPercent(30), | ||
ONE_HUNDRED: basisPointsToPercent(100), | ||
} | ||
|
||
export interface Position { | ||
feesEarned: Record<string, BigNumberish> | ||
feeLevel: FEE_BIPS | ||
tokenAmount0: TokenAmount | ||
tokenAmount1: TokenAmount | ||
tickLower: BigNumberish | ||
tickUpper: BigNumberish | ||
} |
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 |
---|---|---|
|
@@ -2257,6 +2257,11 @@ | |
mkdirp "^1.0.4" | ||
rimraf "^3.0.2" | ||
|
||
"@openzeppelin/[email protected]": | ||
version "3.4.1-solc-0.7-2" | ||
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1-solc-0.7-2.tgz#371c67ebffe50f551c3146a9eec5fe6ffe862e92" | ||
integrity sha512-tAG9LWg8+M2CMu7hIsqHPaTyG4uDzjr6mhvH96LvOpLZZj6tgzTluBt+LsCf1/QaYrlis6pITvpIaIhE+iZB+Q== | ||
|
||
"@pedrouid/iso-crypto@^1.0.0": | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/@pedrouid/iso-crypto/-/iso-crypto-1.0.0.tgz#cf06b40ef3da3d7ca7363bd7a521ed59fa2fd13d" | ||
|
@@ -3984,6 +3989,19 @@ | |
"@uniswap/lib" "1.1.1" | ||
"@uniswap/v2-core" "1.0.0" | ||
|
||
"@uniswap/v3-core@^1.0.0-beta.10": | ||
version "1.0.0-beta.10" | ||
resolved "https://registry.yarnpkg.com/@uniswap/v3-core/-/v3-core-1.0.0-beta.10.tgz#c0fa1169e4a7fd0e5b33efb827c95c9bd05be071" | ||
integrity sha512-Z23ikJr3sWIYQrvsRMrzDCeDXfQtRQMIyGsgHtfx4UAXc4jjUzNfDxNdAcBcgFH0u0ekt1RJ0gXUVcH0NjPfKQ== | ||
|
||
"@uniswap/v3-periphery@^1.0.0-beta.7": | ||
version "1.0.0-beta.7" | ||
resolved "https://registry.yarnpkg.com/@uniswap/v3-periphery/-/v3-periphery-1.0.0-beta.7.tgz#d110308f8f8d0d645ad541ebe0f62721ade0dbd8" | ||
integrity sha512-tvOYdjVgrYzIuxIjUHCyYv8C0UYwa0PFkn0xM0FALU2TNYy7BP4ITrozu6KmUBqEVZf9hAs2HlmomhMoSa/WtA== | ||
dependencies: | ||
"@openzeppelin/contracts" "3.4.1-solc-0.7-2" | ||
"@uniswap/v3-core" "^1.0.0-beta.10" | ||
|
||
"@walletconnect/client@^1.1.1-alpha.0": | ||
version "1.3.6" | ||
resolved "https://registry.yarnpkg.com/@walletconnect/client/-/client-1.3.6.tgz#537b7af6bf87a906fcf171fd5bc4e56a2a3d1908" | ||
|