Skip to content

Commit

Permalink
farming + subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
lilchizh committed Aug 18, 2022
1 parent e2a87cc commit e6c0f32
Show file tree
Hide file tree
Showing 29 changed files with 248 additions and 647 deletions.
7 changes: 3 additions & 4 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
overrideExisting: true
schema:
[
'https://api.thegraph.com/subgraphs/name/iliaazhel/info-test',
'https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test',
'https://api.thegraph.com/subgraphs/name/iliaazhel/staker',
'https://api.thegraph.com/subgraphs/name/iliaazhel/ethereum-blocks'
'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-info',
'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-farming',
'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-blocklytics'
]
documents: 'src/**/!(*.d).{ts,tsx}'
generates:
Expand Down
36 changes: 3 additions & 33 deletions src/apollo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const healthClient = new ApolloClient({
})

export const blockClient = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/iliaazhel/ethereum-blocks',
uri: 'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-blocklytics',
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
Expand All @@ -21,22 +21,7 @@ export const blockClient = new ApolloClient({
})

export const client = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/iliaazhel/info-test',
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
watchQuery: {
fetchPolicy: 'no-cache'
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all'
}
}
})

export const stakerClient = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/iliaazhel/staker',
uri: 'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-info',
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
Expand All @@ -51,22 +36,7 @@ export const stakerClient = new ApolloClient({
})

export const farmingClient = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test',
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
watchQuery: {
fetchPolicy: 'no-cache'
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all'
}
}
})

export const oldFarmingClient = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/iliaazhel/algebra-farming-t',
uri: 'https://api-dogechain.algebra.finance/subgraphs/name/quickswap/dogechain-farming',
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
Expand Down
Binary file added src/assets/images/wbtc-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions src/components/CurrencyLogo/SpecialTokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import WdogeLogo from '../../assets/images/doge-logo.png'

import EthLogo from '../../assets/images/ether-logo.png'
import USDTLogo from '../../assets/images/USDT-logo.png'
import USDCLogo from '../../assets/svg/usd-coin-usdc-logo.svg'
import WBTCLogo from '../../assets/images/wbtc-logo.png'

interface SpecialTokensInterface {
[key: string]: {
Expand All @@ -12,5 +15,21 @@ export const specialTokens: SpecialTokensInterface = {
['0xb7ddc6414bf4f5515b52d8bdd69973ae205ff101']: {
name: 'WDOGE',
logo: WdogeLogo
}
},
['0xb44a9b6905af7c801311e8f4e76932ee959c663c']: {
name: 'Ether',
logo: EthLogo
},
['0x765277eebeca2e31912c9946eae1021199b39c61']: {
name: 'USDC',
logo: USDCLogo
},
['0xe3f5a90f9cb311505cd691a46596599aa1a0ad7d']: {
name: 'USDT',
logo: USDTLogo
},
['0xfa9343c3897324496a05fc75abed6bac29f8a40f']: {
name: 'WBTC',
logo: WBTCLogo
},
}
2 changes: 1 addition & 1 deletion src/components/FarmModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export function FarmModal({
<div className="ml-1">
<IsActive el={el} />
<div className={"farm-modal__nft-position__description"}>
<a className={"fs-085 c-w hover-cp"} href={`https://app.algebra.finance/#/pool/${+el.id}`} rel="noopener noreferrer" target="_blank">
<a className={"fs-085 c-w hover-cp"} href={`https://dogechain.quickswap.exchange/#/pool/${+el.id}`} rel="noopener noreferrer" target="_blank">
<Trans>View position</Trans>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FarmingMyFarms/PositionCardBodyHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function PositionCardBodyHeader({ el, farmingType, date, enteredI

return (
<>
<div className={`flex-s-between b ${isTier ? "mb-1" : "mb-3"} fs-125 ${farmingType === FarmingType.ETERNAL ? "farming-card-header ms_fd-c" : ""}`}>
<div className={`flex-s-between b ${isTier ? "mb-1" : "mb-1"} fs-125 ${farmingType === FarmingType.ETERNAL ? "farming-card-header ms_fd-c" : ""}`}>
<span className={"w-100"}>{farmingType === FarmingType.LIMIT ? "Limit " : "Infinite "} Farming</span>
{farmingType === FarmingType.ETERNAL && enteredInEternalFarming && eternalFarming && (
<span className={"fs-085 l w-100 mm_fs-075 ms_ta-l mxs_ta-l ta-r"}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FarmingMyFarms/PositionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function PositionHeader({ el, unstaking, setUnstaking, withdrawHa
<a
style={{ textDecoration: "underline" }}
className={"c-w fs-075"}
href={`https://app.algebra.finance/#/pool/${+el.id}?onFarming=true`}
href={`https://dogechain.quickswap.exchange/#/pool/${+el.id}?onFarming=true`}
rel="noopener noreferrer"
target="_blank"
>
Expand Down
12 changes: 2 additions & 10 deletions src/components/FarmingMyFarms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,6 @@ export function FarmingMyFarms({ data, refreshing, now, fetchHandler }: FarmingM
</div>
) : shallowPositions && shallowPositions.length !== 0 ? (
<>
<div className={"my-farms__ad p-05 br-12 f f-ac f-jc mb-1"}>
<div className={"mr-1"}>
<Trans>✨ Earn even more ALGB</Trans>
</div>
<Link className={"my-farms__ad-link p-05 br-8 hover-cp"} to={"/staking"}>
<Trans>Stake Rewards</Trans>
</Link>
</div>
{farmedNFTs && (
<div>
{farmedNFTs.map((el, i) => {
Expand All @@ -239,7 +231,7 @@ export function FarmingMyFarms({ data, refreshing, now, fetchHandler }: FarmingM
<div className={"my-farms__position-card p-1 br-12 mb-1"} key={i} data-navigatedto={hash == `#${el.id}`}>
<PositionHeader el={el} setUnstaking={setUnfarming} setSendModal={setSendModal} unstaking={unfarming} withdrawHandler={withdrawHandler} />
<div className={"f cg-1 rg-1 mxs_fd-c"}>
<div className={"my-farms__position-card__body w-100 p-1 br-8"}>
{/* <div className={"my-farms__position-card__body w-100 p-1 br-8"}>
<PositionCardBodyHeader el={el} farmingType={FarmingType.LIMIT} date={date} />
{el.limitFarming ? (
<>
Expand Down Expand Up @@ -340,7 +332,7 @@ export function FarmingMyFarms({ data, refreshing, now, fetchHandler }: FarmingM
)}
</div>
)}
</div>
</div> */}
<div className={"my-farms__position-card__body w-100 p-1 br-8"}>
<PositionCardBodyHeader
farmingType={FarmingType.ETERNAL}
Expand Down
12 changes: 12 additions & 0 deletions src/components/Header/NetworkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApplicationModal } from "state/application/actions";
import { useModalOpen, useToggleModal } from "state/application/hooks";
import { switchToNetwork } from "utils/switchToNetwork";
import { CHAIN_INFO, SupportedChainId } from "../../constants/chains";
import DogeLogo from "../../assets/images/doge-logo.png";

export default function NetworkCard() {
const { chainId, library } = useActiveWeb3React();
Expand Down Expand Up @@ -32,5 +33,16 @@ export default function NetworkCard() {
return null;
}

if (chainId == SupportedChainId.DOGECHAIN) {
return (
<div className="f">
<img src={DogeLogo} width="20" />
<div className="ml-05" title={info.label}>
{info.label}
</div>
</div>
);
}

return <div title={info.label}>{info.label}</div>;
}
2 changes: 1 addition & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function Header() {
<NetworkCard />
{(chainId === 2000 && account && userEthBalance) || networkFailed ? (
<BalanceText style={{ flexShrink: 0 }} pl="0.75rem" fontWeight={500}>
{_userEthBalance?.toSignificant(2)} {!isMobile && chainValue}
{_userEthBalance?.toFixed(5)} {!isMobile && chainValue}
</BalanceText>
) : null}
</>
Expand Down
36 changes: 18 additions & 18 deletions src/components/InfoPools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const sortFields = [
title: t`Pool`,
value: "pool",
},
{
title: t`Volume 7D`,
value: "volumeUSDWeek",
},
{
title: t`Volume 1M`,
value: "volumeUSDMonth",
},
// {
// title: t`Volume 7D`,
// value: "volumeUSDWeek",
// },
// {
// title: t`Volume 1M`,
// value: "volumeUSDMonth",
// },
{
title: t`TVL`,
value: "tvlUSD",
Expand Down Expand Up @@ -63,14 +63,14 @@ export function InfoPools({ data, fetchHandler, blocksFetched }: InfoPoolsProps)
title: pool,
value: el.address,
},
{
title: formatDollarAmount(el.volumeUSDWeek),
value: el.volumeUSDWeek,
},
{
title: formatDollarAmount(el.volumeUSDMonth),
value: el.volumeUSDMonth,
},
// {
// title: formatDollarAmount(el.volumeUSDWeek),
// value: el.volumeUSDWeek,
// },
// {
// title: formatDollarAmount(el.volumeUSDMonth),
// value: el.volumeUSDMonth,
// },
{
title: formatDollarAmount(el.totalValueLockedUSD),
value: el.totalValueLockedUSD,
Expand All @@ -95,12 +95,12 @@ export function InfoPools({ data, fetchHandler, blocksFetched }: InfoPoolsProps)
<span className={"table-header__item"}>
<Trans>Pool</Trans>
</span>
<span className={"table-header__item table-header__item--center"}>
{/* <span className={"table-header__item table-header__item--center"}>
<Trans>Volume 7D</Trans>
</span>
<span className={"table-header__item table-header__item--center"}>
<Trans>Volume 1M</Trans>
</span>
</span> */}
<span className={"table-header__item table-header__item--center"}>
<Trans>TVL</Trans>
</span>
Expand Down
20 changes: 17 additions & 3 deletions src/components/PositionListItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { Price, Token } from "@uniswap/sdk-core";
import { formatTickPrice } from "utils/formatTickPrice";
import Loader from "components/Loader";
import { unwrappedToken } from "utils/unwrappedToken";
import { USDC_DOGECHAIN, WMATIC_EXTENDED } from "../../constants/tokens";
import { USDC_DOGECHAIN, USDT_DOGECHAIN, WMATIC_EXTENDED } from "../../constants/tokens";
import { Trans } from "@lingui/macro";
import useIsTickAtLimit from "hooks/useIsTickAtLimit";
import { Bound, setShowNewestPosition } from "state/mint/v3/actions";
import { ArrowRight } from "react-feather";
import usePrevious from "../../hooks/usePrevious";
import { PositionPool } from "../../models/interfaces";
import { NavLink } from "react-router-dom";
Expand Down Expand Up @@ -40,7 +41,7 @@ export function getPriceOrderingFromPositionForUI(position?: Position): {

// if token0 is a dollar-stable asset, set it as the quote token
// const stables = [USDC_BINANCE, USDC_KOVAN]
const stables = [USDC_DOGECHAIN];
const stables = [USDC_DOGECHAIN, USDT_DOGECHAIN];
if (stables.some((stable) => stable.equals(token0))) {
return {
priceLower: position.token0PriceUpper.invert(),
Expand Down Expand Up @@ -92,6 +93,7 @@ export default function PositionListItem({ positionDetails, newestPosition, high
liquidity: _liquidity,
tickLower: _tickLower,
tickUpper: _tickUpper,
onFarming: _onFarming,
} = useMemo(() => {
if (!positionDetails && prevPositionDetails && prevPositionDetails.liquidity) {
return { ...prevPositionDetails };
Expand Down Expand Up @@ -137,7 +139,9 @@ export default function PositionListItem({ positionDetails, newestPosition, high
// check if price is within range
const outOfRange: boolean = _pool ? _pool.tickCurrent < _tickLower || _pool.tickCurrent >= _tickUpper : false;

const positionSummaryLink = `/pool/${positionDetails.tokenId}`;
const positionSummaryLink = `/pool/${positionDetails.tokenId}${_onFarming ? "?onFarming=true" : ""}`;

const farmingLink = `/farming/farms#${positionDetails.tokenId}`;

const isNewest = newestPosition ? newestPosition === +positionDetails.tokenId : undefined;

Expand All @@ -162,6 +166,16 @@ export default function PositionListItem({ positionDetails, newestPosition, high
&nbsp;
</div>
<div className={"position-list-item__header__badges flex-s-between w-100"}>
{_onFarming ? (
<NavLink className={"flex-s-between btn primary fs-085 p-025 br-8"} to={farmingLink}>
<span>
<Trans>Farming</Trans>
</span>
<ArrowRight size={14} color={"white"} style={{ marginLeft: "5px" }} />
</NavLink>
) : (
<div />
)}
<RangeBadge removed={removed} inRange={!outOfRange} />
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/constants/routing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// a list of tokens by chain
import { Currency, Token } from '@uniswap/sdk-core'
import { SupportedChainId } from './chains'
import { ExtendedEther, WMATIC_EXTENDED } from './tokens'
import { ETH_DOGECHAIN, ExtendedEther, USDC_DOGECHAIN, USDT_DOGECHAIN, WBTC_DOGECHAIN, WMATIC_EXTENDED } from './tokens'

type ChainTokenList = {
readonly [chainId: number]: Token[]
Expand Down Expand Up @@ -34,13 +34,17 @@ export const COMMON_BASES: ChainCurrencyList = {
[SupportedChainId.DOGECHAIN]: [
ExtendedEther.onChain(SupportedChainId.DOGECHAIN),
WMATIC_EXTENDED[SupportedChainId.DOGECHAIN],
USDC_DOGECHAIN,
USDT_DOGECHAIN,
WBTC_DOGECHAIN,
ETH_DOGECHAIN
]
}

// used to construct the list of all pairs we consider by default in the frontend
export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
...WETH_ONLY,
[SupportedChainId.DOGECHAIN]: [...WETH_ONLY[SupportedChainId.DOGECHAIN]]
[SupportedChainId.DOGECHAIN]: [...WETH_ONLY[SupportedChainId.DOGECHAIN], USDC_DOGECHAIN, USDT_DOGECHAIN, WBTC_DOGECHAIN, ETH_DOGECHAIN]
}
export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = {
[SupportedChainId.DOGECHAIN]: [
Expand Down
25 changes: 25 additions & 0 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ export const USDC_DOGECHAIN = new Token(
'USDC'
)

export const ETH_DOGECHAIN = new Token(
SupportedChainId.DOGECHAIN,
'0xb44a9b6905af7c801311e8f4e76932ee959c663c',
18,
'ETH',
'Ether'
)

export const USDT_DOGECHAIN = new Token(
SupportedChainId.DOGECHAIN,
'0xE3F5a90F9cb311505cd691a46596599aA1A0AD7D',
18,
'USDT',
'USDT'
)

export const WBTC_DOGECHAIN = new Token(
SupportedChainId.DOGECHAIN,
'0xfA9343C3897324496A05fC75abeD6bAC29f8A40f',
18,
'WBTC',
'Wrapped Bitcoin'
)


export const WMATIC_EXTENDED: { [chainId: number]: Token } = {
...WDOGE
}
Expand Down
Loading

0 comments on commit e6c0f32

Please sign in to comment.