-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8465c11
commit a61db52
Showing
24 changed files
with
667 additions
and
928 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
apps/cow-amm-deployer/src/app/amms/[id]/(components)/BalancerPriceInformation.tsx
This file was deleted.
Oops, something went wrong.
103 changes: 0 additions & 103 deletions
103
apps/cow-amm-deployer/src/app/amms/[id]/(components)/ChainlinkPriceInformation.tsx
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
apps/cow-amm-deployer/src/app/amms/[id]/(components)/CustomPriceInformation.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
apps/cow-amm-deployer/src/app/amms/[id]/(components)/PoolCompositionTable.tsx
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
70 changes: 36 additions & 34 deletions
70
apps/cow-amm-deployer/src/app/amms/[id]/(components)/PriceInformation.tsx
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,42 +1,44 @@ | ||
import { Address } from "@bleu/utils"; | ||
import { useSafeAppsSDK } from "@gnosis.pm/safe-apps-react-sdk"; | ||
import { ResultOf } from "gql.tada"; | ||
"use client"; | ||
|
||
import { useDecodedPriceOracleData } from "#/hooks/useDecodedPriceOracleData"; | ||
import { AMM_QUERY } from "#/hooks/useStandaloneAmm"; | ||
import { PRICE_ORACLES } from "#/lib/types"; | ||
import { ChainId } from "#/utils/chainsPublicClients"; | ||
import { ArrowTopRightIcon } from "@radix-ui/react-icons"; | ||
import Link from "next/link"; | ||
|
||
import { BalancerPriceInformation } from "./BalancerPriceInformation"; | ||
import { ChainlinkPriceInformation } from "./ChainlinkPriceInformation"; | ||
import { CustomPriceInformation } from "./CustomPriceInformation"; | ||
import { SushiV2PriceInformation } from "./SushiV2PriceInformation"; | ||
import { UniswapV2PriceInformation } from "./UniswapV2PriceInformation"; | ||
import { ICowAmm } from "#/lib/fetchAmmData"; | ||
import { PRICE_ORACLES } from "#/lib/types"; | ||
|
||
export function PriceInformation({ | ||
cowAmm, | ||
function PriceInformationComponent({ | ||
label, | ||
urls, | ||
}: { | ||
cowAmm: ResultOf<typeof AMM_QUERY>; | ||
label: string; | ||
urls: string[]; | ||
}) { | ||
const { safe } = useSafeAppsSDK(); | ||
const { isLoading, decodedData } = useDecodedPriceOracleData({ | ||
priceOracleAddress: cowAmm.constantProductData?.priceOracle as Address, | ||
priceOracleData: cowAmm.constantProductData?.priceOracleData as Address, | ||
chainId: safe.chainId as ChainId, | ||
}); | ||
return ( | ||
<div className="flex flex-row gap-x-1 items-center hover:text-foreground/90"> | ||
<span>{label}</span> | ||
{urls.map((url, index) => ( | ||
<Link key={index} href={url} target="_blank"> | ||
<ArrowTopRightIcon /> | ||
</Link> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export function PriceInformation({ cowAmm }: { cowAmm: ICowAmm }) { | ||
const { decodedPriceOracleData, priceFeedLinks } = cowAmm; | ||
|
||
const labels = { | ||
[PRICE_ORACLES.UNI]: "Using price information from Uniswap V2", | ||
[PRICE_ORACLES.BALANCER]: "Using price information from Balancer V2", | ||
[PRICE_ORACLES.SUSHI]: "Using price information from Sushi V2", | ||
[PRICE_ORACLES.CHAINLINK]: "Using price information from Chainlink", | ||
default: "Using price information from custom contract", | ||
} as const; | ||
|
||
if (isLoading || !decodedData) return <>Loading...</>; | ||
const priceOracle = decodedPriceOracleData[0]; | ||
// @ts-ignore | ||
const label = labels[priceOracle] || labels.default; | ||
|
||
switch (decodedData[0]) { | ||
case PRICE_ORACLES.UNI: | ||
return <UniswapV2PriceInformation cowAmm={cowAmm} />; | ||
case PRICE_ORACLES.BALANCER: | ||
return <BalancerPriceInformation cowAmm={cowAmm} />; | ||
case PRICE_ORACLES.SUSHI: | ||
return <SushiV2PriceInformation cowAmm={cowAmm} />; | ||
case PRICE_ORACLES.CHAINLINK: | ||
return <ChainlinkPriceInformation cowAmm={cowAmm} />; | ||
default: | ||
return <CustomPriceInformation cowAmm={cowAmm} />; | ||
} | ||
return <PriceInformationComponent label={label} urls={priceFeedLinks} />; | ||
} |
38 changes: 0 additions & 38 deletions
38
apps/cow-amm-deployer/src/app/amms/[id]/(components)/SushiV2PriceInformation.tsx
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
apps/cow-amm-deployer/src/app/amms/[id]/(components)/UniswapV2PriceInformation.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.