diff --git a/apis/tokens/api/v1/[chainId]/[address].ts b/apis/tokens/api/v1/[chainId]/[address].ts index c1f1fdc30d..39634c2e1b 100644 --- a/apis/tokens/api/v1/[chainId]/[address].ts +++ b/apis/tokens/api/v1/[chainId]/[address].ts @@ -21,8 +21,6 @@ const handler = async (request: VercelRequest, response: VercelResponse) => { const tokenList = await fetchTokensFromLists(chainId) - // const result = await fetch(`https://tokens.sushi.com/v1/${chainId}`) - // const tokenList = (await result.json()) as TokenInfo[] const json = tokenList.find( (t) => t.address.toLowerCase() === address.toLowerCase(), ) diff --git a/apps/web/package.json b/apps/web/package.json index 4f1c90279a..079d4c8cbd 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -41,9 +41,6 @@ "@rise-wallet/wallet-adapter": "^0.1.2", "@sentry/nextjs": "8.30.0", "@snapshot-labs/snapshot.js": "^0.9.8", - "@sushiswap/bonds-sdk": "workspace:*", - "@sushiswap/client": "workspace:*", - "@sushiswap/database": "workspace:*", "@sushiswap/graph-client": "workspace:*", "@sushiswap/hooks": "workspace:*", "@sushiswap/nextjs-config": "workspace:*", diff --git a/apps/web/src/app/(cms)/academy/components/academy-search-provider.tsx b/apps/web/src/app/(cms)/academy/components/academy-search-provider.tsx index a9042b1501..5eb3fb684d 100644 --- a/apps/web/src/app/(cms)/academy/components/academy-search-provider.tsx +++ b/apps/web/src/app/(cms)/academy/components/academy-search-provider.tsx @@ -1,6 +1,5 @@ 'use client' -import { parseArgs } from '@sushiswap/client' import { useRouter } from 'next/navigation' import { Dispatch, @@ -13,6 +12,7 @@ import { } from 'react' import { z } from 'zod' +import { parseArgs } from 'src/lib/functions' import { useTypedSearchParams } from 'src/lib/hooks' type FilterContext = z.TypeOf diff --git a/apps/web/src/app/(cms)/blog/components/blog-search-provider.tsx b/apps/web/src/app/(cms)/blog/components/blog-search-provider.tsx index e2a1747d3c..c792f57992 100644 --- a/apps/web/src/app/(cms)/blog/components/blog-search-provider.tsx +++ b/apps/web/src/app/(cms)/blog/components/blog-search-provider.tsx @@ -1,6 +1,5 @@ 'use client' -import { parseArgs } from '@sushiswap/client' import { useRouter } from 'next/navigation' import { Dispatch, @@ -13,6 +12,7 @@ import { } from 'react' import { z } from 'zod' +import { parseArgs } from 'src/lib/functions' import { useTypedSearchParams } from 'src/lib/hooks' type FilterContext = z.TypeOf diff --git a/apps/web/src/app/(evm)/api/balance/v0/[chainId]/[address]/route.ts b/apps/web/src/app/(evm)/api/balance/v0/[chainId]/[address]/route.ts deleted file mode 100644 index ea600cb592..0000000000 --- a/apps/web/src/app/(evm)/api/balance/v0/[chainId]/[address]/route.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { createConfig, getBalance, readContracts } from '@wagmi/core' -import zip from 'lodash.zip' -import { type ChainId } from 'sushi/chain' -import { Address, erc20Abi } from 'viem' -import { z } from 'zod' -import { publicWagmiConfig } from '../../../../../../../lib/wagmi/config/public' - -const config = createConfig(publicWagmiConfig) - -const querySchema = z.object({ - chainId: z.coerce - .number() - .int() - .gte(0) - .lte(2 ** 256) - .transform((value) => value as ChainId), - address: z.coerce.string(), - tokens: z.array(z.coerce.string()).optional(), -}) - -const tokensSchema = z.array(z.coerce.string()) - -export const revalidate = 10 - -export async function GET( - _req: Request, - { - params, - }: { params: { chainId: string; address: string; tokens?: string[] } }, -) { - console.log('request', _req) - const { chainId, address } = querySchema.parse(params) - - const res = await fetch(`https://tokens.sushi.com/v0/${chainId}/addresses`, { - next: { revalidate: 3600 }, - }) - const data = await res.json() - const tokens = tokensSchema.parse(data) - - const balance = await getBalance(config, { - chainId, - address: address as Address, - }) - - const balances = await readContracts(config, { - allowFailure: true, - contracts: tokens.map( - (token) => - ({ - chainId, - address: token as Address, - abi: erc20Abi, - args: [address as Address], - functionName: 'balanceOf', - }) as const, - ), - }) - - const zipped = zip( - tokens, - balances.map((balance) => balance?.result || 0n), - ) - - const body = { - '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': balance.value.toString(), - ...Object.fromEntries( - zipped - .filter(([, balance]) => balance !== 0n) - .map(([token, balance]) => [token, balance?.toString()]), - ), - } - return Response.json(body, { - headers: { - 'Cache-Control': 's-maxage=1, stale-while-revalidate=59', - }, - }) -} diff --git a/apps/web/src/app/(evm)/api/stable/v1/pool-list/route.ts b/apps/web/src/app/(evm)/api/stable/v1/pool-list/route.ts index dc4de8a5e5..ec61a8e6ea 100644 --- a/apps/web/src/app/(evm)/api/stable/v1/pool-list/route.ts +++ b/apps/web/src/app/(evm)/api/stable/v1/pool-list/route.ts @@ -1,38 +1,39 @@ -import { Protocol } from '@sushiswap/client' -import { createClient } from '@sushiswap/database' +import { + PoolChainId, + getPoolAddresses, + isPoolChainId, +} from '@sushiswap/graph-client/data-api' import { Ratelimit } from '@upstash/ratelimit' import { NextRequest, NextResponse } from 'next/server' import { rateLimit } from 'src/lib/rate-limit' +import { SushiSwapProtocol } from 'sushi' import { ChainId } from 'sushi/chain' -import { isBentoBoxChainId } from 'sushi/config' -import { isSushiSwapV2ChainId, isSushiSwapV3ChainId } from 'sushi/config' import { z } from 'zod' import { CORS } from '../../cors' const schema = z.object({ chainId: z.coerce .number() - .refine( - (chainId) => - isSushiSwapV2ChainId(chainId as ChainId) || - isSushiSwapV3ChainId(chainId as ChainId) || - isBentoBoxChainId(chainId as ChainId), - { message: 'Invalid chainId' }, - ) + .refine((chainId) => isPoolChainId(chainId as ChainId), { + message: 'Invalid chainId', + }) .transform((chainId) => { - return chainId as ChainId + return chainId as PoolChainId }), protocol: z .string() .refine( - (protocol) => Object.values(Protocol).includes(protocol as Protocol), + (protocol) => + Object.values(SushiSwapProtocol).includes( + protocol as SushiSwapProtocol, + ), { message: `Invalid protocol, valid values are: ${Object.values( - Protocol, + SushiSwapProtocol, ).join(', ')}`, }, ) - .transform((protocol) => protocol as Protocol), + .transform((protocol) => protocol as SushiSwapProtocol), isApproved: z.coerce .string() .default('true') @@ -44,7 +45,7 @@ const schema = z.object({ }) export const revalidate = 300 -export const maxDuration = 10 +export const maxDuration = 30 export async function GET(request: NextRequest) { const ratelimit = rateLimit(Ratelimit.slidingWindow(200, '1 h')) @@ -64,27 +65,10 @@ export async function GET(request: NextRequest) { const args = result.data - const approval = args.isApproved - ? ({ - token0: { status: 'APPROVED' }, - token1: { status: 'APPROVED' }, - } as const) - : {} - - const client = await createClient() - const data = await client.sushiPool - .findMany({ - select: { - address: true, - }, - where: { - chainId: args.chainId, - protocol: args.protocol, - ...approval, - }, - }) - .then((pools) => pools.map((pool) => pool.address)) - await client.$disconnect() + const data = await getPoolAddresses({ + chainId: args.chainId, + protocols: [args.protocol], + }) return NextResponse.json(data, { headers: CORS }) } diff --git a/apps/web/src/app/(evm)/api/stable/v1/position-info/route.ts b/apps/web/src/app/(evm)/api/stable/v1/position-info/route.ts index eaf42f23c5..c2e6ded3c3 100644 --- a/apps/web/src/app/(evm)/api/stable/v1/position-info/route.ts +++ b/apps/web/src/app/(evm)/api/stable/v1/position-info/route.ts @@ -1,6 +1,6 @@ +import { getTokenList } from '@sushiswap/graph-client/data-api' import { Ratelimit } from '@upstash/ratelimit' import { NextRequest, NextResponse } from 'next/server' -import { getToken } from 'src/lib/db' import { rateLimit } from 'src/lib/rate-limit' import { Position, formatPercent } from 'sushi' import { ChainId } from 'sushi/chain' @@ -70,16 +70,16 @@ export async function GET(request: NextRequest) { tokenId: args.positionId, }) - const [token0, token1] = await Promise.all([ - getToken(args.chainId, position.token0), - getToken(args.chainId, position.token1), + const [[token0], [token1]] = await Promise.all([ + getTokenList({ chainId: args.chainId, search: position.token0 }), + getTokenList({ chainId: args.chainId, search: position.token1 }), ]) const [{ pool, poolAddress }, prices] = await Promise.all([ getPool({ chainId: args.chainId, - token0: new Token({ chainId: args.chainId, ...token0 }), - token1: new Token({ chainId: args.chainId, ...token1 }), + token0: new Token(token0), + token1: new Token(token1), feeAmount: position.fee as SushiSwapV3FeeAmount, }), getPrices({ chainId: args.chainId }), diff --git a/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/layout.tsx b/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/layout.tsx deleted file mode 100644 index eddb0402b7..0000000000 --- a/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { BondsFiltersProvider } from 'src/ui/bonds/bonds-table/bonds-table-filters/bonds-filters-provider' - -export default function BondsLayout({ - children, -}: { children: React.ReactNode }) { - return {children} -} diff --git a/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/page.tsx b/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/page.tsx deleted file mode 100644 index 7fd2e7014f..0000000000 --- a/apps/web/src/app/(evm)/bonds/(landing)/(bonds)/page.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Container } from '@sushiswap/ui' -import React from 'react' -import { - BondsFiltersProvider, - BondsTable, - TableFiltersAuctionType, - TableFiltersNetwork, - TableFiltersOpenOnly, - TableFiltersPositiveDiscountOnly, - TableFiltersResetButton, -} from 'src/ui/bonds' - -export default async function BondsPage() { - return ( - - -
- - - - - -
- -
-
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/(landing)/layout.tsx b/apps/web/src/app/(evm)/bonds/(landing)/layout.tsx deleted file mode 100644 index e32dff09ab..0000000000 --- a/apps/web/src/app/(evm)/bonds/(landing)/layout.tsx +++ /dev/null @@ -1,58 +0,0 @@ -'use client' - -import { Container, LinkInternal } from '@sushiswap/ui' -import { useSearchParams } from 'next/navigation' - -import { PathnameButton } from 'src/ui/pool' -import { Hero } from '../hero' - -export default function TabsLayout({ - children, -}: { children: React.ReactNode }) { - const searchParams = useSearchParams() - - return ( - <> - - - - -
- - - All Markets - - - - - My Bonds - - -
-
-
-
- {children} -
-
- - ) -} diff --git a/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/layout.tsx b/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/layout.tsx deleted file mode 100644 index 1a061667f9..0000000000 --- a/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/layout.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { BondsPositionsFiltersProvider } from 'src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/bonds-positions-filters-provider' - -export default function MyBondsLayout({ - children, -}: { children: React.ReactNode }) { - return ( - {children} - ) -} diff --git a/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/page.tsx b/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/page.tsx deleted file mode 100644 index c20b899eba..0000000000 --- a/apps/web/src/app/(evm)/bonds/(landing)/my-bonds/page.tsx +++ /dev/null @@ -1,27 +0,0 @@ -'use client' - -import { Container } from '@sushiswap/ui' -import React from 'react' -import { BondsPositionsTable } from 'src/ui/bonds' -import { useBondPositionsFilters } from 'src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/bonds-positions-filters-provider' -import { PositionsTableFiltersNetwork } from 'src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks' -import { PositionsTableFiltersResetButton } from 'src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-reset-button' -import { TableFiltersUnclaimedBondsOnly } from 'src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-unclaimed-bonds-only' - -export default function MyBondsPage() { - const { chainIds, onlyUnclaimedBonds } = useBondPositionsFilters() - - return ( - -
- - - -
- -
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/[id]/layout.tsx b/apps/web/src/app/(evm)/bonds/[id]/layout.tsx deleted file mode 100644 index f5a5e26bf2..0000000000 --- a/apps/web/src/app/(evm)/bonds/[id]/layout.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { - MarketId, - getChainIdAuctioneerMarketFromMarketId, -} from '@sushiswap/bonds-sdk' -import { Breadcrumb, Container } from '@sushiswap/ui' -import { BondsMarketPageHeader } from 'src/ui/bonds/bonds-market-page-header/bonds-market-page-header' -import { unsanitize } from 'sushi/format' - -export const metadata = { - title: 'Bonds 📝', -} - -export default async function Layout({ - children, - params: { id }, -}: { children: React.ReactNode; params: { id: MarketId } }) { - const marketId = unsanitize(id) as MarketId - - // Will throw an error if the market id is invalid - getChainIdAuctioneerMarketFromMarketId(marketId) - - return ( - <> - - - - - - -
-
- {children} -
-
- - ) -} diff --git a/apps/web/src/app/(evm)/bonds/[id]/page.tsx b/apps/web/src/app/(evm)/bonds/[id]/page.tsx deleted file mode 100644 index 8b8de24492..0000000000 --- a/apps/web/src/app/(evm)/bonds/[id]/page.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { - MarketId, - getChainIdAuctioneerMarketFromMarketId, -} from '@sushiswap/bonds-sdk' -import { getBond } from '@sushiswap/client' -import { Container, Separator } from '@sushiswap/ui' -import { notFound } from 'next/navigation' -import { - BondsMarketDetails, - BondsPositionsTable, - BondsWidget, -} from 'src/ui/bonds' -import { unsanitize } from 'sushi' - -export const revalidate = 60 - -export default async function BondPage({ - params: { id }, -}: { params: { id: MarketId } }) { - const marketId = unsanitize(id) as MarketId - - // Will throw an error if the market id is invalid - getChainIdAuctioneerMarketFromMarketId(marketId) - - const bond = await getBond({ marketId }) - - if (!bond) { - notFound() - } - - return ( - -
-
-
- -
-
- -
-
-
- -
- -
-
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/api/cors.ts b/apps/web/src/app/(evm)/bonds/api/cors.ts deleted file mode 100644 index c4603e7685..0000000000 --- a/apps/web/src/app/(evm)/bonds/api/cors.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const CORS = { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type, Authorization', -} diff --git a/apps/web/src/app/(evm)/bonds/api/v1/bonds/[marketId]/route.ts b/apps/web/src/app/(evm)/bonds/api/v1/bonds/[marketId]/route.ts deleted file mode 100644 index 20192515e8..0000000000 --- a/apps/web/src/app/(evm)/bonds/api/v1/bonds/[marketId]/route.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BondApiSchema, getBondFromSubgraph } from '@sushiswap/client/api' -import { NextResponse } from 'next/server.js' -import { CORS } from '../../../cors' - -export const revalidate = 3 - -export async function GET( - _request: Request, - { params }: { params: { marketId: string } }, -) { - const result = BondApiSchema.safeParse({ - marketId: params.marketId, - }) - - if (!result.success) { - return NextResponse.json(result.error.format(), { status: 400 }) - } - - try { - const bond = await getBondFromSubgraph(result.data) - - if (!bond) { - return NextResponse.json({ error: 'Bond not found' }, { status: 404 }) - } - - return NextResponse.json(bond, { - headers: CORS, - }) - } catch (e) { - return NextResponse.json(e, { headers: CORS }) - } -} diff --git a/apps/web/src/app/(evm)/bonds/api/v1/bonds/route.ts b/apps/web/src/app/(evm)/bonds/api/v1/bonds/route.ts deleted file mode 100644 index 35bbce3288..0000000000 --- a/apps/web/src/app/(evm)/bonds/api/v1/bonds/route.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { BondsApiSchema, getBondsFromSubgraph } from '@sushiswap/client/api' -import { NextResponse } from 'next/server.js' -import { CORS } from '../../cors' - -export const revalidate = 3 - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const result = BondsApiSchema.safeParse(Object.fromEntries(searchParams)) - - if (!result.success) { - return NextResponse.json(result.error.format(), { status: 400 }) - } - - try { - const bonds = await getBondsFromSubgraph(result.data) - - return NextResponse.json(bonds, { - status: 200, - headers: CORS, - }) - } catch (e) { - return NextResponse.json(e, { headers: CORS }) - } -} diff --git a/apps/web/src/app/(evm)/bonds/api/v1/positions/route.ts b/apps/web/src/app/(evm)/bonds/api/v1/positions/route.ts deleted file mode 100644 index c184078fbe..0000000000 --- a/apps/web/src/app/(evm)/bonds/api/v1/positions/route.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - BondsPositionsApiSchema, - getBondPositionsFromSubgraph, -} from '@sushiswap/client/api' -import { NextResponse } from 'next/server.js' -import { CORS } from '../../cors' - -export const revalidate = 3 - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const result = BondsPositionsApiSchema.safeParse( - Object.fromEntries(searchParams), - ) - - if (!result.success) { - return NextResponse.json(result.error.format(), { status: 400 }) - } - - try { - const positions = await getBondPositionsFromSubgraph(result.data) - - return NextResponse.json(positions, { - headers: CORS, - }) - } catch (e) { - return NextResponse.json(e, { headers: CORS }) - } -} diff --git a/apps/web/src/app/(evm)/bonds/error.tsx b/apps/web/src/app/(evm)/bonds/error.tsx deleted file mode 100644 index 3d442b8007..0000000000 --- a/apps/web/src/app/(evm)/bonds/error.tsx +++ /dev/null @@ -1,49 +0,0 @@ -'use client' - -import { ChevronRightIcon } from '@heroicons/react/20/solid' -import * as Sentry from '@sentry/nextjs' -import { Button, LinkInternal, typographyVariants } from '@sushiswap/ui' -import { useEffect } from 'react' - -export default function ErrorPage({ - error, -}: { error: Error & { digest?: string }; reset: () => void }) { - useEffect(() => { - // Log the error to sentry - Sentry.captureException(error) - }, [error]) - return ( -
-
-

- Something went wrong! -

-
- - -
-
-
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/header.tsx b/apps/web/src/app/(evm)/bonds/header.tsx deleted file mode 100644 index a29d66cb5b..0000000000 --- a/apps/web/src/app/(evm)/bonds/header.tsx +++ /dev/null @@ -1,18 +0,0 @@ -'use client' - -import { Navigation } from '@sushiswap/ui' -import React, { FC } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' -import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' -import { useChainId } from 'wagmi' -import { headerElements } from '../_common/header-elements' - -export const Header: FC = () => { - const chainId = useChainId() - return ( - } - /> - ) -} diff --git a/apps/web/src/app/(evm)/bonds/hero.tsx b/apps/web/src/app/(evm)/bonds/hero.tsx deleted file mode 100644 index b1610b21d6..0000000000 --- a/apps/web/src/app/(evm)/bonds/hero.tsx +++ /dev/null @@ -1,68 +0,0 @@ -'use client' - -import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline' -import { LinkExternal, LinkInternal, typographyVariants } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui' -import { DiscordIcon } from '@sushiswap/ui/icons/DiscordIcon' -import { FC } from 'react' - -export const Hero: FC = () => { - return ( -
-
-
-

Sushi Bonds

-

- Acquire digital assets through a permissionless auction format. - Asset listings may reflect market conditions, and terms apply. Sushi - does not issue any assets. -

-
-
- - - -
-
-
-
- - Looking for a partnership with Sushi? - - -
-
- Need Help? - -
-
-
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/layout.tsx b/apps/web/src/app/(evm)/bonds/layout.tsx deleted file mode 100644 index 3c03c675cf..0000000000 --- a/apps/web/src/app/(evm)/bonds/layout.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Header } from './header' -import { Providers } from './providers' - -export const metadata = { - title: 'Bonds 📝', -} - -export default function BondsLayout({ - children, -}: { children: React.ReactNode }) { - return ( - <> - -
-
{children}
- - - ) -} diff --git a/apps/web/src/app/(evm)/bonds/loading.tsx b/apps/web/src/app/(evm)/bonds/loading.tsx deleted file mode 100644 index 75da76e366..0000000000 --- a/apps/web/src/app/(evm)/bonds/loading.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { Splash } from '@sushiswap/ui' -import React from 'react' - -export default function Loading() { - return -} diff --git a/apps/web/src/app/(evm)/bonds/not-found.tsx b/apps/web/src/app/(evm)/bonds/not-found.tsx deleted file mode 100644 index f0b52bf960..0000000000 --- a/apps/web/src/app/(evm)/bonds/not-found.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { ChevronRightIcon } from '@heroicons/react/20/solid' -import { Button, LinkInternal, typographyVariants } from '@sushiswap/ui' - -export default function NotFound() { - return ( -
-
-

- Not Found -

-
- - -
-
-
- ) -} diff --git a/apps/web/src/app/(evm)/bonds/providers.tsx b/apps/web/src/app/(evm)/bonds/providers.tsx deleted file mode 100644 index f35d19144e..0000000000 --- a/apps/web/src/app/(evm)/bonds/providers.tsx +++ /dev/null @@ -1,7 +0,0 @@ -'use client' - -import { SplashController } from '@sushiswap/ui' - -export function Providers({ children }: { children: React.ReactNode }) { - return {children} -} diff --git a/apps/web/src/app/_common/header-elements.ts b/apps/web/src/app/_common/header-elements.ts index 26e6c3da1a..a8fc74c042 100644 --- a/apps/web/src/app/_common/header-elements.ts +++ b/apps/web/src/app/_common/header-elements.ts @@ -33,11 +33,6 @@ export const EXPLORE_NAVIGATION_LINKS = ( }, ] as const) : []), - // { - // title: 'Bonds', - // href: '/bonds', - // description: 'Earn interest by locking up your assets.', - // }, { title: 'Stake', href: '/stake', diff --git a/apps/web/src/lib/analytics/use-furo-tokens.ts b/apps/web/src/lib/analytics/use-furo-tokens.ts deleted file mode 100644 index bb33d92e54..0000000000 --- a/apps/web/src/lib/analytics/use-furo-tokens.ts +++ /dev/null @@ -1,79 +0,0 @@ -'use client' - -import { GetApiInputFromOutput, parseArgs } from '@sushiswap/client' -import { useMemo } from 'react' -import { useAllPrices } from 'src/lib/hooks/react-query' -import { Amount, Token } from 'sushi/currency' -import useSWR from 'swr' - -import { FuroTokens } from '@sushiswap/graph-client/furo' -import { furoTokensSchema } from '../schema' - -export type GetFuroTokenArgs = GetApiInputFromOutput< - (typeof furoTokensSchema)['_input'], - (typeof furoTokensSchema)['_output'] -> - -export type FuroToken = NonNullable< - ReturnType['data'] ->[number] - -export const getFuroTokensUrl = (args: GetFuroTokenArgs) => - `/analytics/api/furoTokens${parseArgs(args)}` - -export function useFuroTokens(args: GetFuroTokenArgs) { - const { data: furoTokens, isValidating } = useSWR( - getFuroTokensUrl(args), - (url) => fetch(url).then((data) => data.json()), - ) - - const { data: prices, isLoading } = useAllPrices() - - return { - data: useMemo( - () => - prices && - furoTokens?.map((furoToken) => { - const token = new Token({ - chainId: furoToken.chainId, - decimals: furoToken.decimals, - address: furoToken.id.split(':')[1], - symbol: furoToken.symbol, - name: furoToken.name, - }) - - let liquidityElastic = 0n - - if (BigInt(furoToken.rebase.base) !== 0n) { - liquidityElastic = - (BigInt(furoToken.liquidityShares) * - BigInt(furoToken.rebase.elastic)) / - BigInt(furoToken.rebase.base) - } - - const priceUSD = - Number( - prices - ?.get(furoToken.chainId) - ?.get(token.address) - ?.toSignificant(4), - ) || 0 - const liquidity = Number( - Amount.fromRawAmount(token, liquidityElastic).toSignificant(4), - ) - - return { - id: token.id, - token, - priceUSD: priceUSD, - liquidityBase: BigInt(furoToken.liquidityShares), - liquidityElastic, - liquidity, - liquidityUSD: liquidity * priceUSD, - } - }), - [furoTokens, prices], - ), - isLoading: isLoading || isValidating, - } -} diff --git a/apps/web/src/lib/constants.ts b/apps/web/src/lib/constants.ts index 744dbca7f8..d335dd77e1 100644 --- a/apps/web/src/lib/constants.ts +++ b/apps/web/src/lib/constants.ts @@ -1,58 +1,10 @@ -import type { GetPoolsArgs } from '@sushiswap/client' -import { Protocol } from '@sushiswap/database' +import { SushiSwapProtocol } from 'sushi' -import { AMM_SUPPORTED_CHAIN_IDS } from '../config' - -export const L2_DEADLINE_FROM_NOW = BigInt(60) * BigInt(5) - -// export const POOL_VERSION_MAP: Record = { -// LEGACY: 'Legacy', -// TRIDENT: 'Trident', -// V3: 'V3', -// } - -// export const AVAILABLE_VERSION_MAP: Partial = { -// LEGACY: 'Legacy', -// TRIDENT: 'Trident', -// V3: 'V3', -// } - -// export const POOL_TYPE_MAP: Record = { -// CONSTANT_PRODUCT_POOL: 'Classic Pool', -// CONCENTRATED_LIQUIDITY_POOL: 'Concentrated Liquidity Pool', -// STABLE_POOL: 'Stable Pool', -// } - -// export const AVAILABLE_POOL_TYPE_MAP: Partial = { -// CONSTANT_PRODUCT_POOL: 'Classic Pool', -// STABLE_POOL: 'Stable Pool', -// CONCENTRATED_LIQUIDITY_POOL: 'Concentrated Pool', -// } - -export const PROTOCOL_MAP: Record = { +export const PROTOCOL_MAP: Record = { SUSHISWAP_V3: 'SushiSwap V3', SUSHISWAP_V2: 'SushiSwap V2', - BENTOBOX_STABLE: 'Trident Stable', - BENTOBOX_CLASSIC: 'Trident Classic', } as const -export const AVAILABLE_PROTOCOL_MAP: Partial = { - SUSHISWAP_V3: 'SushiSwap V3', - SUSHISWAP_V2: 'SushiSwap V2', - BENTOBOX_STABLE: 'Trident Stable', - BENTOBOX_CLASSIC: 'Trident Classic', -} as const - -// ! Has to be kept up to date with default filters -// Else prefetching won't work -export const defaultPoolsArgs: GetPoolsArgs = { - chainIds: AMM_SUPPORTED_CHAIN_IDS, - orderBy: 'liquidityUSD', - orderDir: 'desc', - protocols: Object.values(Protocol), - isWhitelisted: true, -} - export enum Bound { LOWER = 'LOWER', UPPER = 'UPPER', @@ -74,4 +26,5 @@ export const APPROVE_TAG_MIGRATE = 'APPROVE_TAG_MIGRATE' export const APPROVE_TAG_XSWAP = 'APPROVE_TAG_XSWAP' export const APPROVE_TAG_SWAP = 'APPROVE_TAG_SWAP' export const APPROVE_TAG_STEER = 'APPROVE_TAG_STEER' -export const APPROVE_TAG_BONDS = 'APPROVE_TAG_BONDS' + +export const NativeAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' diff --git a/apps/web/src/lib/db.ts b/apps/web/src/lib/db.ts deleted file mode 100644 index ea5ab024bb..0000000000 --- a/apps/web/src/lib/db.ts +++ /dev/null @@ -1,239 +0,0 @@ -import { createClient } from '@sushiswap/database' -import { createConfig } from '@wagmi/core' -import { getToken as getTokenFromContract } from '@wagmi/core/actions' -import { ChainId } from 'sushi/chain' -import { Address } from 'viem' -import { publicWagmiConfig } from './wagmi/config/public' -// import * as defaultTokenList from '@sushiswap/default-token-list' assert { type: 'json' } - -const config = createConfig(publicWagmiConfig) - -export async function getToken(chainId: number, address: string) { - // TODO: example to include default list token - // const tokenFromList = defaultTokenList.tokens.find((token) => token.chainId === chainId && token.address === address) - // if (tokenFromList) { - // return { - // id: `${chainId}:${tokenFromList.address}`, - // address: tokenFromList.address, - // name: tokenFromList.name, - // symbol: tokenFromList.symbol, - // decimals: tokenFromList.decimals, - // } - // } - - const client = await createClient() - try { - const token = await client.token.findFirstOrThrow({ - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - status: true, - }, - where: { - chainId, - address, - }, - }) - await client.$disconnect() - return token - } catch { - await client.$disconnect() - const tokenFromContract = await getTokenFromContract(config, { - chainId: chainId as ChainId, - address: address as Address, - }).catch(() => { - return undefined - }) - if (tokenFromContract) { - return { - id: `${chainId}:${tokenFromContract.address}`, - address: tokenFromContract.address, - name: tokenFromContract.name, - symbol: tokenFromContract.symbol, - decimals: tokenFromContract.decimals, - } - } else { - throw new Error('Token not found') - } - } -} - -export async function getTokenIdsByChainId(chainId: number) { - const client = await createClient() - const ids = await client.token.findMany({ - select: { - id: true, - }, - where: { - AND: { - chainId, - status: 'APPROVED', - }, - }, - }) - await client.$disconnect() - return ids ? ids : [] -} - -export async function getTokenAddressesByChainId(chainId: number) { - const client = await createClient() - const addresses = await client.token.findMany({ - select: { - address: true, - }, - where: { - AND: { - chainId, - status: 'APPROVED', - }, - }, - }) - await client.$disconnect() - return addresses ? addresses : [] -} - -export async function getTokensByChainId(chainId: number) { - const client = await createClient() - const tokens = await client.token.findMany({ - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - where: { - AND: { - chainId, - status: 'APPROVED', - }, - }, - }) - await client.$disconnect() - return tokens ? tokens : [] -} - -export async function getTokens() { - const client = await createClient() - const tokens = await client.token.findMany({ - select: { - id: true, - address: true, - chainId: true, - name: true, - symbol: true, - decimals: true, - }, - where: { - AND: { - status: 'APPROVED', - }, - }, - }) - await client.$disconnect() - return tokens ? tokens : [] -} - -export async function getPopularTokens(chainId: number) { - const client = await createClient() - - const approvedTokens = await client.token.findMany({ - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - pools0: { - select: { - liquidityUSD: true, - }, - where: { - isWhitelisted: true, - liquidityUSD: { - gt: 50, - }, - }, - }, - pools1: { - select: { - liquidityUSD: true, - }, - where: { - isWhitelisted: true, - liquidityUSD: { - gt: 50, - }, - }, - }, - }, - where: { - chainId, - status: 'APPROVED', - }, - }) - - const filteredTokens = approvedTokens - .map((token) => { - const liquidity = - token.pools0.reduce((a, b) => a + Number(b.liquidityUSD) / 2, 0) + - token.pools1.reduce((a, b) => a + Number(b.liquidityUSD) / 2, 0) - return { - id: token.id, - address: token.address, - name: token.name, - symbol: token.symbol, - decimals: token.decimals, - liquidityUSD: Number(liquidity.toFixed(0)), - } - }) - .sort((a, b) => b.liquidityUSD - a.liquidityUSD) - .slice(0, 10) - - await client.$disconnect() - return filteredTokens ? filteredTokens : [] -} - -export async function getCommonTokens(chainId: number) { - const client = await createClient() - const tokens = await client.token.findMany({ - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - where: { - chainId, - status: 'APPROVED', - }, - }) - - await client.$disconnect() - return tokens ? tokens : [] -} - -export async function getTokensByAddress(address: string) { - const client = await createClient() - const tokens = await client.token.findMany({ - select: { - id: true, - chainId: true, - address: true, - name: true, - symbol: true, - decimals: true, - status: true, - }, - where: { - address, - }, - }) - - await client.$disconnect() - return tokens ? tokens : [] -} diff --git a/apps/web/src/lib/functions.ts b/apps/web/src/lib/functions.ts index a70de43241..72d4b7b6fe 100644 --- a/apps/web/src/lib/functions.ts +++ b/apps/web/src/lib/functions.ts @@ -267,3 +267,19 @@ export const rewardPerDay = ({ const days = (end - start) / 3600 / 24 return tryParseAmount((amount / days).toFixed(8), token) } + +export function parseArgs(args?: Partial) { + if (!args) return '' + return Object.entries(args) + .sort(([key1], [key2]) => key1.localeCompare(key2)) + .reduce((acc, [key, value]) => { + if (value === undefined || value === null) return acc + if (Array.isArray(value) && value.length === 0) return acc + const param = `${key}=${Array.isArray(value) ? value.join(',') : value}` + if (acc === '?') { + return `${acc}${param}` + } else { + return `${acc}&${param}` + } + }, '?') +} diff --git a/apps/web/src/lib/hooks/api/useCrossChainTrade.ts b/apps/web/src/lib/hooks/api/useCrossChainTrade.ts index 502bc0a066..94b368fffc 100644 --- a/apps/web/src/lib/hooks/api/useCrossChainTrade.ts +++ b/apps/web/src/lib/hooks/api/useCrossChainTrade.ts @@ -1,5 +1,6 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query' -import { NativeAddress, apiAdapter02To01 } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' +import { apiAdapter02To01 } from 'src/lib/hooks/react-query' import { CrossChainTradeSchema, GetCrossChainTradeParams, diff --git a/apps/web/src/lib/hooks/react-query/index.ts b/apps/web/src/lib/hooks/react-query/index.ts index 2573c99f2a..80de98a612 100644 --- a/apps/web/src/lib/hooks/react-query/index.ts +++ b/apps/web/src/lib/hooks/react-query/index.ts @@ -5,5 +5,3 @@ export * from './strapi' export * from './tokenlist' export * from './tokens' export * from './trade' -export * from './useBalances' -export * from './useBalancesRefetch' diff --git a/apps/web/src/lib/hooks/react-query/tokenlist/index.ts b/apps/web/src/lib/hooks/react-query/tokenlist/index.ts index 83df1c1a94..128116dc84 100644 --- a/apps/web/src/lib/hooks/react-query/tokenlist/index.ts +++ b/apps/web/src/lib/hooks/react-query/tokenlist/index.ts @@ -1,4 +1,3 @@ export * from './types' export * from './useApplyForTokenList' export * from './useOtherTokenLists' -export * from './useTokenList' diff --git a/apps/web/src/lib/hooks/react-query/tokenlist/useTokenList.ts b/apps/web/src/lib/hooks/react-query/tokenlist/useTokenList.ts deleted file mode 100644 index 3006cc1bd4..0000000000 --- a/apps/web/src/lib/hooks/react-query/tokenlist/useTokenList.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { keepPreviousData, useQuery } from '@tanstack/react-query' -import { useCallback } from 'react' -import { Token } from 'sushi/currency' -import { getAddress } from 'viem' - -import type { UseTokenListQuerySelect } from './types' -import { tokenListValidator } from './validator' - -export const useTokenListQuery = (select: UseTokenListQuerySelect) => - useQuery({ - queryKey: ['https://tokens.sushi.com/v0'], - queryFn: async () => { - const res = await (await fetch('https://tokens.sushi.com/v0')).json() - return tokenListValidator.parse(res) - }, - select, - placeholderData: keepPreviousData, - staleTime: 900000, // 15 mins - gcTime: 86400000, // 24hs - }) - -export const useTokenList = (filter?: 'showNone' | string[]) => { - const select: UseTokenListQuerySelect = useCallback( - (data) => { - if (filter === 'showNone') return {} - - const _filter = filter - ? filter.filter((el) => el.length > 2).map((el) => el.toLowerCase()) - : undefined - return data.reduce>( - (acc, { chainId, name, symbol, address, decimals }) => { - if ( - filter === undefined || - (_filter && - (_filter.findIndex((el) => name.toLowerCase().includes(el)) >= - 0 || - _filter.findIndex((el) => address.toLowerCase().includes(el)) >= - 0 || - _filter.findIndex((el) => symbol.toLowerCase().includes(el)) >= - 0)) - ) { - acc[`${chainId}:${getAddress(address)}`] = new Token({ - chainId, - name, - symbol, - decimals, - address, - }) - } - - return acc - }, - {}, - ) - }, - [filter], - ) - - return useTokenListQuery(select) -} diff --git a/apps/web/src/lib/hooks/react-query/tokens/index.ts b/apps/web/src/lib/hooks/react-query/tokens/index.ts index d5705461e4..91c7af4800 100644 --- a/apps/web/src/lib/hooks/react-query/tokens/index.ts +++ b/apps/web/src/lib/hooks/react-query/tokens/index.ts @@ -1,3 +1,2 @@ -export * from './useToken' export * from './useTokens' export * from './useTokenSecurity' diff --git a/apps/web/src/lib/hooks/react-query/tokens/useToken.ts b/apps/web/src/lib/hooks/react-query/tokens/useToken.ts deleted file mode 100644 index d974228a74..0000000000 --- a/apps/web/src/lib/hooks/react-query/tokens/useToken.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { keepPreviousData, useQuery } from '@tanstack/react-query' -import { useCallback } from 'react' -import { ChainId } from 'sushi/chain' -import { Token } from 'sushi/currency' -import { isAddress } from 'viem' - -interface UseTokenParams { - chainId: ChainId | undefined - address: string | undefined - withStatus?: T - enabled?: boolean -} - -type UseTokenReturn = T extends true - ? { token: Token; status: 'UNKNOWN' | 'APPROVED' | 'DISAPPROVED' } - : Token - -type Data = { - id: string - address: string - name: string - symbol: string - decimals: number - status: 'UNKNOWN' | 'APPROVED' | 'DISAPPROVED' -} - -const hydrate = ( - chainId: ChainId | undefined, - data: Data, - withStatus: T | undefined, -): UseTokenReturn | undefined => { - if (data && chainId) { - const { address, name, symbol, decimals } = data - const token = new Token({ - chainId, - name, - decimals, - symbol, - address, - }) - - if (withStatus) { - return { - token, - status: data.status, - } as UseTokenReturn - } - - return token as UseTokenReturn - } - - return undefined -} - -/** - * @deprecated use lib/wagmi/useTokenWithCache - */ -export const useToken = ({ - chainId, - address, - withStatus, - enabled = true, -}: UseTokenParams) => { - const select = useCallback( - (data: Data) => hydrate(chainId, data, withStatus), - [chainId, withStatus], - ) - - return useQuery({ - queryKey: ['token', { chainId, address }], - queryFn: async () => { - // Fallback to api - const resp = await fetch( - `https://tokens.sushi.com/v0/${chainId}/${address}`, - ) - if (resp.status === 200) { - const { address, name, symbol, decimals, status, id }: Data = - await resp.json() - - return { address, name, symbol, decimals, status, id } - } else { - throw Error( - `https://tokens.sushi.com/v0/${chainId}/${address}: Token not found`, - ) - } - }, - enabled: Boolean(enabled && chainId && address && isAddress(address)), - select, - placeholderData: keepPreviousData, - refetchOnWindowFocus: false, - retry: false, - staleTime: 900000, // 15 mins - gcTime: 86400000, // 24hs - }) -} diff --git a/apps/web/src/lib/hooks/react-query/useBalances.ts b/apps/web/src/lib/hooks/react-query/useBalances.ts deleted file mode 100644 index c2d021ad93..0000000000 --- a/apps/web/src/lib/hooks/react-query/useBalances.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { useQuery } from '@tanstack/react-query' -import { useCallback } from 'react' -import { Amount, Native, type Type } from 'sushi/currency' -import { getAddress } from 'viem' - -import ms from 'ms' -import { useTokens } from './tokens' - -export const NativeAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' - -type UseBalancesQuerySelect = ( - data: Record, -) => Record> - -interface UseBalances { - account: string | undefined - chainId: number - enabled?: boolean -} - -// const queryKey = ({ chainId, account }): { account: string; chainId: number } => [ -// `/api/balance/v0/${chainId}/${account}`, -// ] - -export const useBalancesQuery = ( - { chainId, account, enabled = true }: UseBalances, - select: UseBalancesQuerySelect, -) => { - return useQuery({ - queryKey: [`/api/balance/v0/${chainId}/${account}`], - queryFn: () => { - return fetch(`/api/balance/v0/${chainId}/${account}`).then((response) => - response.json(), - ) - }, - staleTime: ms('15m'), // 15 mins - gcTime: ms('1h'), // 1hr - enabled: Boolean(chainId && account && enabled), - select, - }) -} - -export const useBalances = (variables: UseBalances) => { - const { chainId } = variables - const { data: tokens } = useTokens({ chainId }) - const select: UseBalancesQuerySelect = useCallback( - (data) => { - if (!tokens) return {} - - return Object.entries(data).reduce>>( - (acc, [address, amount]) => { - // console.log({ tokens, address, amount }) - if (address.toLowerCase() === NativeAddress) { - acc[address] = Amount.fromRawAmount(Native.onChain(chainId), amount) - } else { - const _address = getAddress(address) - const _token = tokens[_address] - if (typeof _token !== 'undefined') { - acc[_address] = Amount.fromRawAmount(_token, amount) - } - } - return acc - }, - {}, - ) - }, - [chainId, tokens], - ) - - return useBalancesQuery(variables, select) -} diff --git a/apps/web/src/lib/hooks/react-query/useBalancesRefetch.ts b/apps/web/src/lib/hooks/react-query/useBalancesRefetch.ts deleted file mode 100644 index 9af8b73a49..0000000000 --- a/apps/web/src/lib/hooks/react-query/useBalancesRefetch.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { useQueryClient } from '@tanstack/react-query' -import { useCallback } from 'react' - -interface UseBalances { - account: string | undefined - chainId: number -} - -export const useBalancesRefetch = ({ chainId, account }: UseBalances) => { - const queryClient = useQueryClient() - return useCallback(async () => { - return await queryClient.refetchQueries({ - queryKey: [`/api/balance/v0/${chainId}/${account}`], - type: 'active', - }) - }, [queryClient, chainId, account]) -} diff --git a/apps/web/src/lib/swap/cross-chain/actions/getSquidCrossChainTrade.ts b/apps/web/src/lib/swap/cross-chain/actions/getSquidCrossChainTrade.ts index a2d2e06b9d..1a7274a260 100644 --- a/apps/web/src/lib/swap/cross-chain/actions/getSquidCrossChainTrade.ts +++ b/apps/web/src/lib/swap/cross-chain/actions/getSquidCrossChainTrade.ts @@ -5,7 +5,7 @@ import { RouteRequest, SquidCallType, } from '@0xsquid/squid-types' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { routeProcessor4Abi_processRoute, squidRouterAbi } from 'sushi/abi' import { ROUTE_PROCESSOR_4_ADDRESS, diff --git a/apps/web/src/lib/swap/cross-chain/actions/getStargateCrossChainTrade.ts b/apps/web/src/lib/swap/cross-chain/actions/getStargateCrossChainTrade.ts index c75e9adcc8..7e3fb7185f 100644 --- a/apps/web/src/lib/swap/cross-chain/actions/getStargateCrossChainTrade.ts +++ b/apps/web/src/lib/swap/cross-chain/actions/getStargateCrossChainTrade.ts @@ -1,4 +1,4 @@ -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { stargateAdapterAbi_getFee } from 'sushi/abi' import { STARGATE_ADAPTER_ADDRESS, diff --git a/apps/web/src/lib/swap/cross-chain/lib/StargateAdapter.ts b/apps/web/src/lib/swap/cross-chain/lib/StargateAdapter.ts index e6b125c097..76fe5e2f0d 100644 --- a/apps/web/src/lib/swap/cross-chain/lib/StargateAdapter.ts +++ b/apps/web/src/lib/swap/cross-chain/lib/StargateAdapter.ts @@ -1,4 +1,4 @@ -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { STARGATE_CHAIN_ID, STARGATE_CHAIN_PATHS, diff --git a/apps/web/src/lib/wagmi/components/token-selector/hooks/use-my-tokens.ts b/apps/web/src/lib/wagmi/components/token-selector/hooks/use-my-tokens.ts index 1f406a1068..6fd871c9f1 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/hooks/use-my-tokens.ts +++ b/apps/web/src/lib/wagmi/components/token-selector/hooks/use-my-tokens.ts @@ -5,7 +5,7 @@ import { import { useCustomTokens } from '@sushiswap/hooks' import { useQuery } from '@tanstack/react-query' import { useMemo } from 'react' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { Amount, Native, Token, Type } from 'sushi/currency' import type { Address } from 'viem' diff --git a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-currency-list.tsx b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-currency-list.tsx index 78817a720a..cfe3208873 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-currency-list.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-currency-list.tsx @@ -1,5 +1,5 @@ import React, { FC, memo, useMemo } from 'react' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { ChainId } from 'sushi/chain' import { Amount, Native, Type } from 'sushi/currency' import { useAccount } from 'wagmi' diff --git a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-row.tsx b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-row.tsx index b9a1862d07..564b56b8a8 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-row.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-row.tsx @@ -22,7 +22,7 @@ import { import { Badge } from '@sushiswap/ui' import { Currency } from '@sushiswap/ui' import React, { CSSProperties, FC, memo, useCallback } from 'react' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { Chain } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { Fraction, ZERO } from 'sushi/math' diff --git a/apps/web/src/lib/wagmi/components/token-selector/token-lists/token-selector-chip-bar.tsx b/apps/web/src/lib/wagmi/components/token-selector/token-lists/token-selector-chip-bar.tsx index f9d5d77aef..5c80766abf 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/token-lists/token-selector-chip-bar.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/token-lists/token-selector-chip-bar.tsx @@ -7,7 +7,7 @@ import { TraceEvent, } from '@sushiswap/telemetry' import { Button, Currency, IconButton, buttonIconVariants } from '@sushiswap/ui' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import type { ChainId } from 'sushi/chain' import { Type } from 'sushi/currency' import { useChipTokens } from '../hooks/use-chip-tokens' diff --git a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-discount.ts b/apps/web/src/lib/wagmi/hooks/bonds/use-bond-discount.ts deleted file mode 100644 index 2d1f566412..0000000000 --- a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-discount.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { - MarketId, - getBondDiscount, - getChainIdAuctioneerMarketFromMarketId, -} from '@sushiswap/bonds-sdk' -import { useMemo } from 'react' -import { usePrices } from 'src/app/(evm)/_common/ui/price-provider/price-provider/use-prices' -import { Address } from 'viem' -import { useBondMarketPrices } from './use-bond-market-price' - -interface UseBondsDiscount { - marketId: MarketId - marketScale: bigint - quoteToken: { - address: Address - decimals: number - } - payoutToken: { - address: Address - decimals: number - } - enabled?: boolean -} - -export const useBondDiscount = ({ - marketId, - marketScale, - payoutToken, - quoteToken, - enabled = true, -}: UseBondsDiscount) => { - const { chainId } = getChainIdAuctioneerMarketFromMarketId(marketId) - - const { data: prices, isLoading: isPricesLoading } = usePrices({ - chainId: enabled ? chainId : undefined, - }) - const { data: marketPrice, isLoading: isMarketPriceLoading } = - useBondMarketPrices({ - marketIds: [marketId], - enabled, - }) - - const discount = useMemo(() => { - if (!marketPrice || !prices) return undefined - - const quoteTokenPriceUSD = prices.get(quoteToken.address) - const payoutTokenPriceUSD = prices.get(payoutToken.address) - - return getBondDiscount({ - marketPrice: marketPrice[0], - marketScale: marketScale, - payoutToken: { - decimals: payoutToken.decimals, - priceUSD: +(payoutTokenPriceUSD?.toFixed(10) || 0), - }, - quoteToken: { - decimals: quoteToken.decimals, - priceUSD: +(quoteTokenPriceUSD?.toFixed(10) || 0), - }, - }) - }, [prices, marketPrice, marketScale, payoutToken, quoteToken]) - - return { - ...discount, - isLoading: isPricesLoading || isMarketPriceLoading, - } -} diff --git a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-details.ts b/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-details.ts deleted file mode 100644 index b46b26e1c3..0000000000 --- a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-details.ts +++ /dev/null @@ -1,263 +0,0 @@ -import { - REFERRER_ADDRESS, - getBondDiscount, - getMarketInfosContracts, - getMarketPricesContracts, - getMaxAmountsAcceptedContracts, - getRemainingCapacitiesContracts, -} from '@sushiswap/bonds-sdk' -import { Bond } from '@sushiswap/client' -import { - getTotalSuppliesContracts, - getVaultsReservesContracts, -} from '@sushiswap/steer-sdk' -import { useQueryClient } from '@tanstack/react-query' -import { useEffect, useMemo } from 'react' -import { - PriceMap, - usePrices, -} from 'src/app/(evm)/_common/ui/price-provider/price-provider/use-prices' -import { - uniswapV2PairAbi_getReserves, - uniswapV2PairAbi_totalSupply, -} from 'sushi/abi' -import { Amount, Token } from 'sushi/currency' -import { Address } from 'viem' -import { useBlockNumber, useReadContracts } from 'wagmi' - -interface UseBondMarketDetails { - bond: Bond - enabled?: boolean -} - -function getTokenPrice(prices: PriceMap, token: Address) { - const tokenPriceFraction = prices.get(token) - if (!tokenPriceFraction) return undefined - return Number(tokenPriceFraction.toFixed(10)) -} - -function useQuoteTokenPriceUSD(bond: Bond, enabled = true) { - const { data: prices } = usePrices({ - chainId: enabled ? bond.chainId : undefined, - }) - - const { data: poolData } = useReadContracts({ - allowFailure: false, - contracts: [ - { - abi: uniswapV2PairAbi_getReserves, - functionName: 'getReserves', - chainId: bond.chainId, - address: bond.quoteToken.address, - }, - { - abi: uniswapV2PairAbi_totalSupply, - functionName: 'totalSupply', - chainId: bond.chainId, - address: bond.quoteToken.address, - }, - ], - query: { - enabled: Boolean(enabled && bond.quoteToken.pool), - }, - }) - - const vaultContracts = useMemo(() => { - return [ - getVaultsReservesContracts({ vaultIds: [bond.quoteToken.id] })[0], - getTotalSuppliesContracts({ vaultIds: [bond.quoteToken.id] })[0], - ] as const - }, [bond.quoteToken.id]) - - const { data: vaultData } = useReadContracts({ - allowFailure: false, - contracts: vaultContracts, - query: { enabled: Boolean(enabled && bond.quoteToken.vault) }, - }) - - return useMemo(() => { - if (!prices) { - return undefined - } - - if (bond.quoteToken.pool) { - if (!poolData) { - return undefined - } - - const pool = bond.quoteToken.pool - - const token0PriceUSD = getTokenPrice(prices, pool.token0.address) - const token1PriceUSD = getTokenPrice(prices, pool.token1.address) - - if (!token0PriceUSD || !token1PriceUSD) return undefined - - const [[reserve0, reserve1], totalSupply] = poolData - - const reserve0USD = - (Number(reserve0) / 10 ** pool.token0.decimals) * token0PriceUSD - const reserve1USD = - (Number(reserve1) / 10 ** pool.token1.decimals) * token1PriceUSD - - const lpTokenPriceUSD = - (reserve0USD + reserve1USD) / - (Number(totalSupply) / 10 ** bond.quoteToken.decimals) - - return lpTokenPriceUSD - } - - if (bond.quoteToken.vault) { - if (!vaultData) { - return undefined - } - - const vault = bond.quoteToken.vault - - const token0PriceUSD = getTokenPrice(prices, vault.token0.address) - const token1PriceUSD = getTokenPrice(prices, vault.token1.address) - - if (!token0PriceUSD || !token1PriceUSD) return undefined - - const [{ amountToken0: reserve0, amountToken1: reserve1 }, totalSupply] = - vaultData - - const reserve0USD = - (Number(reserve0) / 10 ** vault.token0.decimals) * token0PriceUSD - const reserve1USD = - (Number(reserve1) / 10 ** vault.token1.decimals) * token1PriceUSD - - const reserveUSD = reserve0USD + reserve1USD - - return reserveUSD / (Number(totalSupply) / 10 ** bond.quoteToken.decimals) - } - - return getTokenPrice(prices, bond.quoteToken.address) - }, [prices, bond, poolData, vaultData]) -} - -export const useBondMarketDetails = ({ - bond, - enabled = true, -}: UseBondMarketDetails) => { - const { data: prices } = usePrices({ - chainId: enabled ? bond.chainId : undefined, - }) - - const contracts = useMemo(() => { - const marketPrice = getMarketPricesContracts({ marketIds: [bond.id] })[0] - const remainingCapacity = getRemainingCapacitiesContracts({ - marketIds: [bond.id], - })[0] - const marketInfo = getMarketInfosContracts({ marketIds: [bond.id] })[0] - const maxAmountAccepted = getMaxAmountsAcceptedContracts({ - marketIds: [bond.id], - referrer: REFERRER_ADDRESS[bond.chainId], - })[0] - - return [ - marketPrice, - remainingCapacity, - marketInfo, - maxAmountAccepted, - ] as const - }, [bond.id, bond.chainId]) - - const queryClient = useQueryClient() - const { data, queryKey } = useReadContracts({ - allowFailure: false, - contracts, - query: { - enabled: Boolean(enabled), - }, - }) - - const { data: blockNumber } = useBlockNumber({ - chainId: bond.chainId, - watch: true, - }) - - useEffect(() => { - if (blockNumber) { - queryClient.invalidateQueries({ queryKey }, { cancelRefetch: false }) - } - }, [blockNumber, queryClient, queryKey]) - - const [marketPrice, remainingCapacityBI, marketInfo, maxAmountAcceptedBI] = - useMemo(() => data || [], [data]) - - const quoteTokenPriceUSD = useQuoteTokenPriceUSD(bond, enabled) - const payoutTokenPriceUSD = useMemo(() => { - return Number((prices?.get(bond.payoutToken.address) || 0)?.toFixed(10)) - }, [prices, bond]) - - const discount = useMemo(() => { - if (!marketPrice || !quoteTokenPriceUSD || !payoutTokenPriceUSD) - return undefined - - return getBondDiscount({ - marketPrice: marketPrice, - marketScale: BigInt(bond.marketScale), - payoutToken: { - decimals: bond.payoutToken.decimals, - priceUSD: payoutTokenPriceUSD, - }, - quoteToken: { - decimals: bond.quoteToken.decimals, - priceUSD: quoteTokenPriceUSD, - }, - }) - }, [quoteTokenPriceUSD, payoutTokenPriceUSD, marketPrice, bond]) - - const [availableCapacity, availableCapacityUSD] = useMemo(() => { - if (!marketInfo) return [] - - const amount = Amount.fromRawAmount( - new Token(bond.payoutToken), - marketInfo[5], - ) - - if (!payoutTokenPriceUSD) return [amount] - - const amountUSD = Number(amount.toSignificant(18)) * payoutTokenPriceUSD - - return [amount, amountUSD] - }, [bond, marketInfo, payoutTokenPriceUSD]) - - const [remainingCapacity, remainingCapacityUSD] = useMemo(() => { - if (!remainingCapacityBI) return [] - - const amount = Amount.fromRawAmount( - new Token(bond.capacityInQuote ? bond.quoteToken : bond.payoutToken), - remainingCapacityBI, - ) - - if (!quoteTokenPriceUSD || !payoutTokenPriceUSD) return [amount] - - const amountUSD = - Number(amount.toSignificant(18)) * - (bond.capacityInQuote ? quoteTokenPriceUSD : payoutTokenPriceUSD) - - return [amount, amountUSD] - }, [bond, remainingCapacityBI, quoteTokenPriceUSD, payoutTokenPriceUSD]) - - const maxAmountAccepted = useMemo(() => { - if (!maxAmountAcceptedBI) return undefined - - // https://dev.bondprotocol.finance/developers/market-calculations#capacity-payout-and-allowances - const mAAreduced = maxAmountAcceptedBI // - (maxAmountAcceptedBI / 1000n) * 5n - - return Amount.fromRawAmount(new Token(bond.quoteToken), mAAreduced) - }, [bond, maxAmountAcceptedBI]) - - return { - ...discount, - quoteTokenPriceUSD, - payoutTokenPriceUSD, - marketPrice, - maxAmountAccepted, - availableCapacity, - availableCapacityUSD, - remainingCapacity, - remainingCapacityUSD, - } -} diff --git a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-price.ts b/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-price.ts deleted file mode 100644 index 97eb91b629..0000000000 --- a/apps/web/src/lib/wagmi/hooks/bonds/use-bond-market-price.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MarketId, getMarketPricesContracts } from '@sushiswap/bonds-sdk' -import { useReadContracts } from 'wagmi' - -interface UseBondMarketPrices { - marketIds: MarketId[] | undefined - enabled?: boolean -} - -export const useBondMarketPrices = ({ - marketIds: _marketIds, - enabled, -}: UseBondMarketPrices) => { - const marketIds = _marketIds || [] - - return useReadContracts({ - allowFailure: false, - contracts: getMarketPricesContracts({ marketIds: marketIds }), - query: { enabled: Boolean(marketIds && enabled) }, - }) -} diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts index 2fdbdc1dbb..b605c3d593 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts @@ -1,8 +1,8 @@ 'use client' -import { ChefType } from '@sushiswap/client' import { UseQueryOptions, useQuery } from '@tanstack/react-query' import { useMemo } from 'react' +import { ChefType } from 'sushi' import { chainShortName } from 'sushi/chain' import { Token } from 'sushi/currency' import { PoolType } from '../pools/types' diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts index 22e7d8c58a..05025a648f 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts @@ -1,7 +1,7 @@ 'use client' -import { ChefType } from '@sushiswap/client' import { useMemo } from 'react' +import { ChefType } from 'sushi' import { ChainId } from 'sushi/chain' import { MASTERCHEF_ADDRESS, diff --git a/apps/web/src/ui/bonds/bonds-buy-review-modal.tsx b/apps/web/src/ui/bonds/bonds-buy-review-modal.tsx deleted file mode 100644 index 1f865535a2..0000000000 --- a/apps/web/src/ui/bonds/bonds-buy-review-modal.tsx +++ /dev/null @@ -1,336 +0,0 @@ -import { RefreshIcon } from '@heroicons/react-v1/solid' -import { REFERRER_ADDRESS, getCliffTimestamp } from '@sushiswap/bonds-sdk' -import { bondFixedTermTellerAbi } from '@sushiswap/bonds-sdk/abi' -import { Bond } from '@sushiswap/client' -import { createErrorToast, createToast } from '@sushiswap/notifications' -import { - Button, - DialogConfirm, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogProvider, - DialogReview, - DialogTitle, - Dots, - List, - SkeletonText, - classNames, -} from '@sushiswap/ui' -import { SendTransactionReturnType } from '@wagmi/core' -import format from 'date-fns/format' -import formatDistance from 'date-fns/formatDistance' -import { FC, ReactNode, useCallback, useMemo } from 'react' -import { APPROVE_TAG_BONDS } from 'src/lib/constants' -import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' -import { - Percent, - formatPercent, - formatUSD, - shortenAddress, - slippageAmount, -} from 'sushi' -import { Chain } from 'sushi/chain' -import { Amount, Token } from 'sushi/currency' -import { UserRejectedRequestError } from 'viem' -import { - UseSimulateContractParameters, - useAccount, - useSimulateContract, - useWaitForTransactionReceipt, - useWriteContract, -} from 'wagmi' -import { usePublicClient } from 'wagmi' - -interface BondsBuyReviewModal { - bond: Bond - discount: number | undefined - quoteAmount: Amount - payoutAmount: Amount - onSuccess: () => void - successLink?: string - children: ReactNode -} - -export const BondsBuyReviewModal: FC = ({ - bond, - discount, - quoteAmount, - payoutAmount, - onSuccess: _onSuccess, - successLink, - children, -}) => { - const { address, chain } = useAccount() - const client = usePublicClient() - - const { approved } = useApproved(APPROVE_TAG_BONDS) - - const cliffTimestamp = - getCliffTimestamp({ - vestingLength: bond.vesting, - vestingType: bond.vestingType, - }) * 1000 - - const isNegativeDiscount = discount && discount < 0 - const buttonVariant = isNegativeDiscount ? 'destructive' : 'default' - const buttonText = isNegativeDiscount ? 'Bond Anyways' : 'Bond' - - const slippagePercent = useMemo(() => { - return new Percent(5, 1000) - }, []) - - const onSuccess = useCallback( - (hash: SendTransactionReturnType) => { - _onSuccess() - - const ts = new Date().getTime() - void createToast({ - account: address, - type: 'mint', - chainId: bond.chainId, - txHash: hash, - promise: client.waitForTransactionReceipt({ hash: hash }), - summary: { - pending: `Purchasing bond (${payoutAmount.toSignificant(6)} ${ - payoutAmount.currency.symbol - }) with ${quoteAmount.toSignificant(6)} ${ - quoteAmount.currency.symbol - }`, - completed: `Purchased bond (${payoutAmount.toSignificant(6)} ${ - payoutAmount.currency.symbol - }) with ${quoteAmount.toSignificant(6)} ${ - quoteAmount.currency.symbol - }`, - failed: `Failed to purchase bond (${payoutAmount.toSignificant(6)} ${ - payoutAmount.currency.symbol - }) with ${quoteAmount.toSignificant(6)} ${ - quoteAmount.currency.symbol - }`, - }, - timestamp: ts, - groupTimestamp: ts, - }) - }, - [client, address, bond.chainId, payoutAmount, quoteAmount, _onSuccess], - ) - - const onError = useCallback((e: Error) => { - if (!(e.cause instanceof UserRejectedRequestError)) { - createErrorToast(e?.message, true) - } - }, []) - - const prepare = useMemo(() => { - if (!discount || !address) return undefined - - return { - address: bond.tellerAddress, - abi: bondFixedTermTellerAbi, - functionName: 'purchase', - args: [ - address, - REFERRER_ADDRESS[bond.chainId], - BigInt(bond.marketId), - quoteAmount.quotient, - slippageAmount(payoutAmount, slippagePercent)[0], - ], - } as const satisfies UseSimulateContractParameters - }, [ - address, - bond.chainId, - bond.tellerAddress, - bond.marketId, - discount, - quoteAmount, - payoutAmount, - slippagePercent, - ]) - - const { data: simulation, isError } = useSimulateContract({ - ...prepare, - chainId: bond.chainId, - query: { - enabled: Boolean(bond.chainId === chain?.id && address && approved), - }, - }) - - const { - writeContractAsync, - isPending: isWritePending, - data, - } = useWriteContract({ - mutation: { - onSuccess, - onError, - }, - }) - - const write = useMemo(() => { - if (!simulation || !address) return undefined - - return async (confirm: () => void) => { - try { - await writeContractAsync(simulation.request) - confirm() - } catch {} - } - }, [address, writeContractAsync, simulation]) - - const { status } = useWaitForTransactionReceipt({ - chainId: bond.chainId, - hash: data, - }) - - return ( - - - {({ confirm }) => ( - <> - {children} - - - - Purchase bond ({payoutAmount.toSignificant(6)}{' '} - {payoutAmount.currency.symbol}) - - - With {quoteAmount.toSignificant(6)}{' '} - {quoteAmount.currency.symbol} - - - {isNegativeDiscount && ( -
- -
- )} -
- -
- Price quote is refreshed automatically every - 4 - seconds. -
-
- - - - {Chain.from(bond.chainId)?.name} - - - {discount !== undefined ? ( - - {formatPercent(discount)} - - ) : ( - - )} - - - {formatDistance(cliffTimestamp, Date.now())} - - - {format(cliffTimestamp, 'MMM dd, yyyy')} -
- {format(cliffTimestamp, 'HH:mm')} -
- -
- - {quoteAmount.toSignificant(4)}{' '} - {quoteAmount.currency.symbol} - - - {formatUSD('0')} - -
-
- -
- - {payoutAmount.toSignificant(4)}{' '} - {payoutAmount.currency.symbol} - - - {formatUSD('0')} - -
-
-
- - - {address ? ( - shortenAddress(address) - ) : ( - - )} - - -
- - - -
- - )} -
- -
- ) -} diff --git a/apps/web/src/ui/bonds/bonds-market-details.tsx b/apps/web/src/ui/bonds/bonds-market-details.tsx deleted file mode 100644 index c6072ac09c..0000000000 --- a/apps/web/src/ui/bonds/bonds-market-details.tsx +++ /dev/null @@ -1,238 +0,0 @@ -'use client' - -import { Bond } from '@sushiswap/client' -import { useIsMounted } from '@sushiswap/hooks' -import { - Card, - CardContent, - CardDescription, - CardGroup, - CardHeader, - CardItem, - CardLabel, - CardTitle, - Currency, - Explainer, - SkeletonText, - Toggle, -} from '@sushiswap/ui' -import { FC, useMemo, useState } from 'react' -import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' -import { Token } from 'sushi/currency' -import { formatNumber, formatPercent, formatUSD } from 'sushi/format' - -interface BondsMarketDetails { - bond: Bond -} - -export const BondsMarketDetails: FC = ({ - bond: staleBond, -}) => { - const isMounted = useIsMounted() - - const [quoteToken, payoutToken] = useMemo(() => { - return [new Token(staleBond.quoteToken), new Token(staleBond.payoutToken)] - }, [staleBond.quoteToken, staleBond.payoutToken]) - - const [invert, setInvert] = useState(false) - - const { - discount, - discountedPrice, - payoutTokenPriceUSD, - quoteTokenPriceUSD, - availableCapacity, - availableCapacityUSD, - remainingCapacity, - remainingCapacityUSD, - } = useBondMarketDetails({ - bond: staleBond, - }) - - const price = - payoutTokenPriceUSD && quoteTokenPriceUSD - ? invert - ? payoutTokenPriceUSD / quoteTokenPriceUSD - : quoteTokenPriceUSD / payoutTokenPriceUSD - : undefined - - return ( - - - Market Details - - {quoteTokenPriceUSD ? ( - <> - Total Bonded Value:{' '} - {formatUSD(staleBond.totalBondedAmount * quoteTokenPriceUSD)} - - ) : ( - - )} - - - - - Tokens - - Market Price - Token price at current market spot price - - } - > - {typeof payoutTokenPriceUSD === 'number' ? ( - formatUSD(payoutTokenPriceUSD, '$0.000a') - ) : ( - - )} - - - Bond Price - Token price after bond discount - - } - > - {typeof discountedPrice === 'number' ? ( - formatUSD(discountedPrice, '$0.000a') - ) : ( - - )} - - - Discount - - Percentage of the current spot price and bond market price - difference - - - } - > - {discount && payoutTokenPriceUSD && discountedPrice ? ( - 0 ? 'text-green' : discount < 0 ? 'text-red' : '' - } - > - {formatUSD(payoutTokenPriceUSD - discountedPrice)} ( - {formatPercent(discount)}) - - ) : ( - - )} - - - - Market Payout - setInvert(!invert)} - title={ - price !== undefined ? ( - `1 ${ - invert ? payoutToken.symbol : quoteToken.symbol - } = ${formatNumber(price)} ${ - invert ? quoteToken.symbol : payoutToken.symbol - }` - ) : ( - - ) - } - > -
- setInvert(false)} - size="xs" - variant="outline" - > - {quoteToken.symbol} - - setInvert(true)} - size="xs" - variant="outline" - > - {payoutToken.symbol} - -
-
-
-
-
-
-
- Available Capacity{' '} - - The maximum amount of tokens that is currently available. - -
-
-
- {availableCapacity && availableCapacityUSD && isMounted ? ( -
-
- -
-
-
- {availableCapacity?.toSignificant(6)} {payoutToken.symbol} -
-
- {formatUSD(availableCapacityUSD)} -
-
-
- ) : ( - - )} -
-
-
-
-
- Remaining Capacity - - The total remaining capacity of the bond, in tokens. - -
-
-
- {remainingCapacity && remainingCapacityUSD && isMounted ? ( -
-
- -
-
-
- {remainingCapacity?.toSignificant(6)}{' '} - {remainingCapacity?.currency.symbol} -
-
- {formatUSD(remainingCapacityUSD)} -
-
-
- ) : ( - - )} -
-
-
-
-
- ) -} diff --git a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-description.tsx b/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-description.tsx deleted file mode 100644 index d08bbcf5b2..0000000000 --- a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-description.tsx +++ /dev/null @@ -1,49 +0,0 @@ -'use client' - -import { Bond } from '@sushiswap/client' -import { useMemo, useState } from 'react' - -export const BondsMarketPageHeaderDescription = ({ bond }: { bond: Bond }) => { - if (!bond.description) { - return null - } - - if (bond.description.length < 200) { - return ( -
- - {bond.description} - -
- ) - } - - return -} - -const BondsMarketPageHeaderDescriptionLong = ({ - description, -}: { description: string }) => { - const [showAll, setShowAll] = useState(false) - - const text = useMemo(() => { - if (showAll) return description - - const shortened = description.slice(0, 200) - - return `${shortened}...` - }, [description, showAll]) - - return ( -
- {text} - -
- ) -} diff --git a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx b/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx deleted file mode 100644 index 64e5055e44..0000000000 --- a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx +++ /dev/null @@ -1,27 +0,0 @@ -'use client' - -import { Bond } from '@sushiswap/client' -import { SkeletonText, classNames } from '@sushiswap/ui' -import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' -import { formatPercent } from 'sushi/format' - -export const BondsMarketPageHeaderDiscount = ({ bond }: { bond: Bond }) => { - const { discount } = useBondMarketDetails({ bond }) - - const isNegativeDiscount = Boolean(discount !== undefined && discount < 0) - - return ( -
- Discount - {discount !== undefined ? ( - - {formatPercent(discount)} - - ) : ( - - )} -
- ) -} diff --git a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header.tsx b/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header.tsx deleted file mode 100644 index 2159e36b11..0000000000 --- a/apps/web/src/ui/bonds/bonds-market-page-header/bonds-market-page-header.tsx +++ /dev/null @@ -1,231 +0,0 @@ -import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline' -import { AuctionType, MarketId, getCliffTimestamp } from '@sushiswap/bonds-sdk' -import { Bond, getBond } from '@sushiswap/client' -import { Currency, LinkInternal } from '@sushiswap/ui' -import { classNames } from '@sushiswap/ui' -import { Button, LinkExternal, typographyVariants } from '@sushiswap/ui' -import formatDistance from 'date-fns/formatDistance' -import Link from 'next/link' -import { shortenAddress } from 'sushi' -import { Chain } from 'sushi/chain' -import { Token } from 'sushi/currency' -import { BondsMarketPageHeaderDescription } from './bonds-market-page-header-description' -import { BondsMarketPageHeaderDiscount } from './bonds-market-page-header-discount' - -const VestingTerm = ({ bond }: { bond: Bond }) => ( -
- Vesting Term - {bond.vesting - ? formatDistance( - getCliffTimestamp({ - vestingLength: bond.vesting, - vestingType: bond.vestingType, - }) * 1000, - Date.now(), - ) - : 'Immediate'} -
-) - -const QuoteToken = ({ bond }: { bond: Bond }) => { - const quoteToken = new Token(bond.quoteToken) - - if (bond.quoteToken.pool || bond.quoteToken.vault) { - const token0 = new Token( - bond.quoteToken.pool?.token0 || bond.quoteToken.vault!.token0, - ) - const token1 = new Token( - bond.quoteToken.pool?.token1 || bond.quoteToken.vault!.token1, - ) - - let link: string | undefined = '' - - if (bond.quoteToken.pool) { - link = `/pool/${bond.quoteToken.pool.poolId}` - } else if (bond.quoteToken.vault) { - link = `/pool/${bond.quoteToken.vault.poolId}/smart/${bond.quoteToken.vault.id}` - } - - return ( - <> - - - - - - - - - ) - } - - return ( - <> - - - - - - - - ) -} - -export const BondsMarketPageHeader = async ({ id }: { id: MarketId }) => { - const bond = await getBond({ - marketId: id, - }) - - const quoteToken = new Token(bond.quoteToken) - const payoutToken = new Token(bond.payoutToken) - - return ( -
-
- - ← Bonds - -
- - - - - -
- {bond.auctionType === AuctionType.Dynamic ? 'Dynamic' : 'Static'} -
-
-
- -
-
- - -
- - {bond.end * 1000 < Date.now() ? 'Ended' : 'Ends'} - - {formatDistance(bond.end * 1000, new Date(), { addSuffix: true })} -
-
-
-
- Network - - {Chain.from(bond.chainId)?.name} - -
-
- - {payoutToken.symbol} - - - - -
-
- - {quoteToken.symbol} - - - - -
- {/*
- Issuer - {bond.issuer ? ( - - - - ) : ( -
Unknown
- )} -
*/} -
-
-
- ) -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx deleted file mode 100644 index a70a8019dc..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx +++ /dev/null @@ -1,307 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ - -import { bondFixedTermTellerAbi } from '@sushiswap/bonds-sdk/abi' -import { BondPosition } from '@sushiswap/client' -import { useIsMounted } from '@sushiswap/hooks' -import { createErrorToast, createToast } from '@sushiswap/notifications' -import { - Badge, - Button, - Currency, - Dots, - SkeletonText, - classNames, -} from '@sushiswap/ui' -import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' -import { ColumnDef } from '@tanstack/react-table' -import format from 'date-fns/format' -import formatDistance from 'date-fns/formatDistance' -import { useCallback, useMemo, useState } from 'react' -import { Checker } from 'src/lib/wagmi/systems/Checker' -import { Amount, Token } from 'sushi/currency' -import { formatUSD } from 'sushi/format' -import { - Address, - SendTransactionReturnType, - UserRejectedRequestError, -} from 'viem' -import { - type UseSimulateContractParameters, - useAccount, - usePublicClient, - useSimulateContract, - useWriteContract, -} from 'wagmi' - -export const PAYOUT_ASSET_COLUMN: ColumnDef = { - id: 'payout-asset', - header: 'Payout Asset', - cell: (props) => { - const token = new Token(props.row.original.payoutToken) - - return ( -
-
- - } - > - - - - -
-
- - {token.symbol} -
- -
-
- ) - }, - meta: { - skeleton: , - headerDescription: - 'Purchased bonds awaiting for you to claim when the bond matures', - }, -} - -export const PAYOUT_AMOUNT_COLUMN: ColumnDef = { - id: 'payout-amount', - header: 'Payout Amount', - accessorFn: (row) => row.balanceUSD, - cell: (props) => { - const position = props.row.original - - const token = new Token(position.payoutToken) - const balance = Amount.fromRawAmount(token, props.row.original.balance) - - return ( -
- - {balance.toSignificant(6)} {token.symbol} - - - {formatUSD(position.balanceUSD)} - -
- ) - }, - meta: { - skeleton: , - headerDescription: - 'Purchased bond amount available for you to claim when the bond matures', - }, -} - -export const MATURITY_COLUMN: ColumnDef = { - id: 'maturity', - header: 'Maturity', - accessorFn: (row) => row.maturity, - cell: (props) => { - const isMounted = useIsMounted() - - const position = props.row.original - - return ( -
- {format(position.maturity * 1000, 'MMM dd, yyyy HH:mm')} - - {isMounted - ? formatDistance(position.maturity * 1000, new Date(), { - addSuffix: true, - }) - : ''} - -
- ) - }, - meta: { - skeleton: , - headerDescription: 'The fully vested date at which you can claim your bond', - }, -} - -const CLAIM_CELL = ({ position }: { position: BondPosition }) => { - const isMounted = useIsMounted() - - const [claimed, setClaimed] = useState(BigInt(position.balance) === 0n) - const notMature = position.maturity * 1000 > Date.now() - const claimable = !claimed && !notMature - - const token = new Token(position.payoutToken) - const balance = Amount.fromRawAmount(token, position.balance) - - const { address, chain } = useAccount() - const client = usePublicClient() - - const onSuccess = useCallback( - (hash: SendTransactionReturnType) => { - setClaimed(true) - - const ts = new Date().getTime() - void createToast({ - account: address, - type: 'mint', - chainId: position.chainId, - txHash: hash, - promise: client.waitForTransactionReceipt({ hash }), - summary: { - pending: `Claiming bond (${balance.toSignificant(6)} ${ - balance.currency.symbol - })`, - completed: `Claimed bond (${balance.toSignificant(6)} ${ - balance.currency.symbol - })`, - failed: `Failed to claim bond (${balance.toSignificant(6)} ${ - balance.currency.symbol - })`, - }, - timestamp: ts, - groupTimestamp: ts, - }) - }, - [client, address, balance, position.chainId], - ) - - const onError = useCallback((e: Error) => { - if (!(e.cause instanceof UserRejectedRequestError)) { - createErrorToast(e.message, true) - } - }, []) - - const prepare = useMemo(() => { - if (!address || chain?.id !== position.chainId || !claimable) return {} - - return { - address: position.tellerAddress as Address, - abi: bondFixedTermTellerAbi, - chainId: position.chainId, - functionName: 'redeem', - args: [BigInt(position.bondTokenId), BigInt(position.balance)], - } as const satisfies UseSimulateContractParameters - }, [ - address, - chain?.id, - position.balance, - position.bondTokenId, - position.chainId, - position.tellerAddress, - claimable, - ]) - - // const { data: estimatedGas } = useEstimateGas({ - // ...prepare, - // query: { - // enabled: Boolean(address && chain?.id === position.chainId && claimable), - // }, - // }) - - // const adjustedGas = estimatedGas ? gasMargin(estimatedGas) : undefined - - const { data: simulation, isError } = useSimulateContract({ - ...prepare, - query: { - enabled: Boolean(address && chain?.id === position.chainId && claimable), - }, - }) - - const { writeContractAsync, isPending: isWritePending } = useWriteContract({ - mutation: { - onSuccess, - onError, - }, - }) - - const write = useMemo(() => { - if (!simulation /* || !adjustedGas*/) return undefined - - return async (confirm: () => void) => { - try { - await writeContractAsync({ - ...simulation.request, - // gas: adjustedGas, - }) - - confirm() - } catch {} - } - }, [simulation, writeContractAsync /*, adjustedGas/*/]) - - return ( -
- {isMounted ? ( - - - - - - - - ) : ( - - )} -
- ) -} - -export const CLAIM_COLUMN: ColumnDef = { - id: 'claim', - header: 'Claim', - size: 130, - cell: (props) => ( - - ), - meta: { - skeleton: , - }, -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/bonds-positions-filters-provider.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/bonds-positions-filters-provider.tsx deleted file mode 100644 index cfe4b3a8f5..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/bonds-positions-filters-provider.tsx +++ /dev/null @@ -1,82 +0,0 @@ -'use client' - -import { parseArgs } from '@sushiswap/client' -import { BondsPositionsApiSchema } from '@sushiswap/client/api' -import { useRouter } from 'next/navigation' -import { - Dispatch, - FC, - ReactNode, - SetStateAction, - createContext, - useContext, - useMemo, -} from 'react' - -import { useTypedSearchParams } from '../../../../lib/hooks' - -type FilterContext = Partial< - Pick< - typeof BondsPositionsApiSchema._output, - 'chainIds' | 'onlyUnclaimedBonds' - > -> - -const FilterContext = createContext(undefined) - -export type BondFilters = Omit - -interface BondsFiltersProvider { - children?: ReactNode - passedFilters?: Partial -} - -export const BondsPositionsFiltersProvider: FC = ({ - children, -}) => { - const urlFilters = useTypedSearchParams(BondsPositionsApiSchema.partial()) - const { chainIds, onlyUnclaimedBonds } = urlFilters - - return ( - ({ - chainIds: chainIds ? chainIds : undefined, - onlyUnclaimedBonds: onlyUnclaimedBonds, - // payoutAssets: payoutAssets ? payoutAssets : [], - }), - [ - chainIds, - onlyUnclaimedBonds, - // bondAssets, - ], - )} - > - {children} - - ) -} - -export const useBondPositionsFilters = () => { - const context = useContext(FilterContext) - if (!context) { - throw new Error('Hook can only be used inside Filter Context') - } - - return context -} - -export const useSetBondPositionsFilters = () => { - const { push } = useRouter() - const urlFilters = useTypedSearchParams(BondsPositionsApiSchema.partial()) - - const setFilters: Dispatch> = (filters) => { - if (typeof filters === 'function') { - void push(parseArgs(filters(urlFilters))) - } else { - void push(parseArgs(filters)) - } - } - - return { setFilters } -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx deleted file mode 100644 index d93475a6aa..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx +++ /dev/null @@ -1,149 +0,0 @@ -'use client' - -import { PlusCircleIcon } from '@heroicons/react/24/outline' -import { BondChainId } from '@sushiswap/bonds-sdk' -import { BONDS_ENABLED_CHAIN_IDS } from '@sushiswap/bonds-sdk' -import { - Chip, - Popover, - PopoverContent, - PopoverTrigger, - Separator, -} from '@sushiswap/ui' -import { Button } from '@sushiswap/ui' -import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' -import { CheckIcon } from '@sushiswap/ui/icons/CheckIcon' -import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' -import React, { - FC, - useCallback, - useEffect, - useState, - useTransition, -} from 'react' -import { Chain } from 'sushi/chain' -import { - useBondPositionsFilters, - useSetBondPositionsFilters, -} from './bonds-positions-filters-provider' - -const isAllThenNone = (chainIds: BondChainId[] | undefined) => - !chainIds || chainIds.length === BONDS_ENABLED_CHAIN_IDS.length - ? [] - : chainIds - -export const PositionsTableFiltersNetwork: FC = () => { - const [pending, startTransition] = useTransition() - const [open, setOpen] = useState(false) - const { chainIds } = useBondPositionsFilters() - const { setFilters } = useSetBondPositionsFilters() - const [localValue, setValues] = useState( - isAllThenNone(chainIds), - ) - - const values = pending ? localValue : isAllThenNone(chainIds) - - const onClick = useCallback( - (chainId: BondChainId) => { - let _newValues: BondChainId[] - if (localValue.includes(chainId)) { - _newValues = localValue.filter((el) => el !== chainId) - } else { - _newValues = [...(localValue ?? []), chainId] - } - _newValues = isAllThenNone(_newValues) - - setValues(_newValues) - - startTransition(() => { - setFilters((prev) => { - if (prev.chainIds?.includes(chainId)) { - return { ...prev, chainIds: _newValues } - } else { - return { ...prev, chainIds: _newValues } - } - }) - }) - }, - [setFilters, localValue], - ) - - useEffect(() => { - setValues(isAllThenNone(chainIds)) - }, [chainIds]) - - return ( - - - - - - - - {BONDS_ENABLED_CHAIN_IDS.map((chainId) => ( - - onClick(+currentValue as BondChainId) - } - className="py-2 pl-8 pr-2" - > - {values.includes(chainId) ? ( - - - - ) : null} - - {Chain.from(chainId)?.name} - - ))} - - - - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-reset-button.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-reset-button.tsx deleted file mode 100644 index 046ff2eaa3..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-reset-button.tsx +++ /dev/null @@ -1,67 +0,0 @@ -'use client' - -import { XMarkIcon } from '@heroicons/react/24/solid' -import { Button } from '@sushiswap/ui' -import React, { FC, useCallback, useMemo, useState, useTransition } from 'react' - -import { BONDS_ENABLED_CHAIN_IDS } from '@sushiswap/bonds-sdk' -import { - useBondPositionsFilters, - useSetBondPositionsFilters, -} from './bonds-positions-filters-provider' - -export const PositionsTableFiltersResetButton: FC = () => { - const [isPending, startTransition] = useTransition() - const { - chainIds, - onlyUnclaimedBonds, - // payoutAssets, - } = useBondPositionsFilters() - const { setFilters } = useSetBondPositionsFilters() - - const networks = useMemo( - () => (BONDS_ENABLED_CHAIN_IDS.length === chainIds?.length ? [] : chainIds), - [chainIds], - ) - - const [show, setShow] = useState( - (networks?.length ?? 0) || // + - // (payoutAssets?.length ?? 0) > - // 0 || - onlyUnclaimedBonds === false, - ) - - const reset = useCallback(() => { - setShow(false) - startTransition(() => { - setFilters({ - chainIds: undefined, - // payoutAssets: undefined, - onlyUnclaimedBonds: undefined, - }) - }) - }, [setFilters]) - - if ( - isPending - ? show - : (networks?.length ?? 0) || // + - // (payoutAssets?.length ?? 0) > - // 0 || - onlyUnclaimedBonds === false - ) { - return ( - - ) - } - - return null -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-unclaimed-bonds-only.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-unclaimed-bonds-only.tsx deleted file mode 100644 index e9b19a2cf9..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-unclaimed-bonds-only.tsx +++ /dev/null @@ -1,41 +0,0 @@ -'use client' - -import { Toggle } from '@sushiswap/ui' -import React, { FC, useCallback, useState, useTransition } from 'react' - -import { - useBondPositionsFilters, - useSetBondPositionsFilters, -} from './bonds-positions-filters-provider' - -export const TableFiltersUnclaimedBondsOnly: FC = () => { - const [isPending, startTransition] = useTransition() - const { onlyUnclaimedBonds } = useBondPositionsFilters() - const { setFilters } = useSetBondPositionsFilters() - const [checked, setChecked] = useState(onlyUnclaimedBonds) - - const toggle = useCallback( - (checked: boolean) => { - setChecked(checked) - startTransition(() => { - setFilters((prev) => ({ - ...prev, - onlyUnclaimedBonds: - prev.onlyUnclaimedBonds === undefined ? false : undefined, - })) - }) - }, - [setFilters], - ) - - return ( - - Unclaimed Bonds Only - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx b/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx deleted file mode 100644 index 25deef0247..0000000000 --- a/apps/web/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx +++ /dev/null @@ -1,95 +0,0 @@ -'use client' - -import { BondChainId } from '@sushiswap/bonds-sdk' -import { - BondPosition, - GetBondsPositionsArgs, - getBondsPositions, - getBondsPositionsUrl, -} from '@sushiswap/client' -import { useIsMounted } from '@sushiswap/hooks' -import { Card, CardHeader, CardTitle, DataTable } from '@sushiswap/ui' -import { useQuery } from '@tanstack/react-query' -import { ColumnDef, PaginationState, SortingState } from '@tanstack/react-table' -import React, { FC, useMemo, useState } from 'react' -import { useAccount } from 'wagmi' -import { - CLAIM_COLUMN, - MATURITY_COLUMN, - PAYOUT_AMOUNT_COLUMN, - PAYOUT_ASSET_COLUMN, -} from './bonds-positions-table-columns' - -const COLUMNS = [ - PAYOUT_ASSET_COLUMN, - PAYOUT_AMOUNT_COLUMN, - MATURITY_COLUMN, - CLAIM_COLUMN, -] satisfies ColumnDef[] - -interface PositionsTableProps { - chainIds?: BondChainId[] - payoutTokenId?: string // `${BondChainId}:0x${string}` - onlyUnclaimedBonds?: boolean -} - -export const BondsPositionsTable: FC = ({ - chainIds, - payoutTokenId, - onlyUnclaimedBonds, -}) => { - const isMounted = useIsMounted() - const { address } = useAccount() - - const args = useMemo(() => { - if (!address) return undefined - - return { - userAddress: address, - chainIds, - onlyUnclaimedBonds, - payoutTokenId, - } - }, [address, chainIds, onlyUnclaimedBonds, payoutTokenId]) - - const { data = [], isInitialLoading } = useQuery({ - queryKey: [getBondsPositionsUrl(args)], - queryFn: () => getBondsPositions(args), - refetchInterval: 15 * 1000, - enabled: Boolean(args), - }) - - const [sortingState, setSortingState] = useState([ - { id: 'maturity', desc: false }, - ]) - - const [paginationState, setPaginationState] = useState({ - pageIndex: 0, - pageSize: 10, - }) - - return ( - - - - My Bonds{' '} - - ({data.length}) - - - - - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-columns.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-columns.tsx deleted file mode 100644 index b87d8522ff..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-columns.tsx +++ /dev/null @@ -1,233 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ - -import { AuctionType } from '@sushiswap/bonds-sdk' -import { Bond } from '@sushiswap/client' -import { - Badge, - Currency, - SkeletonText, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, - classNames, -} from '@sushiswap/ui' -// import { useIsMounted } from '@sushiswap/hooks' -import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' -import { ColumnDef } from '@tanstack/react-table' -import formatDistance from 'date-fns/formatDistance' -import { formatPercent, formatUSD } from 'sushi' -import { Token } from 'sushi/currency' - -const AUCTION_TYPE_BADGE: Record = { - [AuctionType.Dynamic]: ( -
- Dynamic -
- ), - [AuctionType.Static]: ( -
- Static -
- ), -} - -export const PAYOUT_ASSET_COLUMN: ColumnDef = { - id: 'payout-asset', - header: 'Payout Asset', - cell: (props) => { - const token = new Token(props.row.original.payoutToken) - - return ( -
-
- - } - > - - - - -
-
- - {token.symbol} -
- -
- - - - {AUCTION_TYPE_BADGE[props.row.original.auctionType]} - - -

Market Type

-
-
-
-
-
-
- ) - }, - meta: { - skeleton: , - headerDescription: 'Token available for purchase', - }, -} - -export const PRICE_COLUMN: ColumnDef = { - id: 'price', - header: 'Price', - accessorFn: (row) => row.payoutToken.discountedPriceUSD, - cell: ({ row: { original } }) => ( -
-
- {formatUSD(original.payoutToken.discountedPriceUSD, '$0.000a')} -
-
- {formatUSD(original.payoutToken.priceUSD, '$0.000a')} Market -
-
- ), - meta: { - skeleton: , - headerDescription: 'Token price after bond discount', - }, -} - -export const DISCOUNT_COLUMN: ColumnDef = { - id: 'discount', - header: 'Discount', - accessorFn: (row) => row.discount, - cell: (props) => { - const discount = props.row.original.discount - - if (discount <= 0) - return {formatPercent(discount)} - - return {formatPercent(discount)} - }, - meta: { - skeleton: , - headerDescription: 'Percentage off current spot price', - }, -} - -export const BOND_ASSET_COLUMN: ColumnDef = { - id: 'bond-asset', - header: 'Bond Asset', - cell: (props) => { - const row = props.row.original - - if (row.quoteToken.pool || row.quoteToken.vault) { - let token0: Token - let token1: Token - - if (row.quoteToken.pool) { - token0 = new Token(row.quoteToken.pool.token0) - token1 = new Token(row.quoteToken.pool.token1) - } else { - token0 = new Token(row.quoteToken.vault.token0) - token1 = new Token(row.quoteToken.vault.token1) - } - - return ( -
- - - - -
- - {token0.symbol}/{token1.symbol} - - - {row.quoteToken.name} - -
-
- ) - } - - const token = new Token(row.quoteToken) - - return ( -
- - - -
- - {token.symbol} - -
-
- ) - }, - meta: { - skeleton: , - headerDescription: 'Asset used to purchase the bond', - }, -} - -export const VESTING_COLUMN: ColumnDef = { - id: 'vesting', - header: 'Vesting', - accessorFn: (row) => row.vesting, - cell: (props) => { - if (!props.row.original.vesting) return <>- - - switch (props.row.original.vestingType) { - case 'Fixed-Term': - return formatDistance(props.row.original.vesting * 1000, 0) - } - }, - meta: { - skeleton: , - headerDescription: - 'How long until bought tokens are claimable from the moment they are purchased', - }, -} - -export const ISSUER_COLUMN: ColumnDef = { - id: 'issuer', - header: 'Issuer', - cell: (props) => { - const bond = props.row.original - - if (!bond.issuer) return <>Unknown - - return ( - // Cannot use because of some weird SSR behavior -
{ - e.preventDefault() - window.open(bond.issuer!.link, '_blank') - }} - onClick={(e) => { - e.preventDefault() - window.open(bond.issuer!.link, '_blank') - }} - className="cursor-pointer text-blue hover:underline" - > - {bond.issuer.name} -
- ) - }, - meta: { - skeleton: , - }, -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/bonds-filters-provider.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/bonds-filters-provider.tsx deleted file mode 100644 index 0418bd6b1e..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/bonds-filters-provider.tsx +++ /dev/null @@ -1,88 +0,0 @@ -'use client' - -import { parseArgs } from '@sushiswap/client' -import { BondsApiSchema } from '@sushiswap/client/api' -import { useRouter } from 'next/navigation' -import { - Dispatch, - FC, - ReactNode, - SetStateAction, - createContext, - useContext, - useMemo, -} from 'react' - -import { useTypedSearchParams } from '../../../../lib/hooks' - -type FilterContext = Partial< - Pick< - typeof BondsApiSchema._output, - 'auctionTypes' | 'chainIds' | 'onlyDiscounted' | 'onlyOpen' - > -> - -const FilterContext = createContext(undefined) - -export type BondFilters = Omit - -interface BondsFiltersProvider { - children?: ReactNode - passedFilters?: Partial -} - -export const BondsFiltersProvider: FC = ({ - children, -}) => { - const urlFilters = useTypedSearchParams(BondsApiSchema.partial()) - const { auctionTypes, chainIds, onlyDiscounted, onlyOpen } = urlFilters - - return ( - ({ - auctionTypes: auctionTypes ? auctionTypes : [], - chainIds: chainIds ? chainIds : undefined, - onlyDiscounted: !!onlyDiscounted, - onlyOpen: onlyOpen, - // payoutAssets: payoutAssets ? payoutAssets : [], - // bondAssets: bondAssets ? bondAssets : [], - }), - [ - auctionTypes, - chainIds, - onlyDiscounted, - onlyOpen, - // payoutAssets, - // bondAssets, - ], - )} - > - {children} - - ) -} - -export const useBondFilters = () => { - const context = useContext(FilterContext) - if (!context) { - throw new Error('Hook can only be used inside Filter Context') - } - - return context -} - -export const useSetBondFilters = () => { - const { push } = useRouter() - const urlFilters = useTypedSearchParams(BondsApiSchema.partial()) - - const setFilters: Dispatch> = (filters) => { - if (typeof filters === 'function') { - void push(parseArgs(filters(urlFilters))) - } else { - void push(parseArgs(filters)) - } - } - - return { setFilters } -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx deleted file mode 100644 index da796d6e05..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx +++ /dev/null @@ -1,194 +0,0 @@ -'use client' - -import { PlusCircleIcon } from '@heroicons/react/24/outline' -import { AuctionType, AuctionTypes } from '@sushiswap/bonds-sdk' -import { useMutationObserver } from '@sushiswap/hooks' -import { - Chip, - CommandList, - HoverCard, - HoverCardContent, - HoverCardTrigger, - Label, - Popover, - PopoverContent, - PopoverPrimitive, - PopoverTrigger, - Separator, -} from '@sushiswap/ui' -import { Button } from '@sushiswap/ui' -import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' -import { CheckIcon } from '@sushiswap/ui/icons/CheckIcon' -import React, { FC, useCallback, useState, useTransition } from 'react' -import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' - -const AUCTIONTYPE_DESCRIPTIONS: Record = { - [AuctionType.Static]: - 'A fixed-price auction type that enabled issuers to set a fixed price that bonders must pay to obtain payout tokens.', - [AuctionType.Dynamic]: - 'A dynamic-price auction type using a Sequential Dutch Auction (SDA) mechanism that enables issuers to set a starting price which dynamically adjusts based on the supply and demand, bonders pay a dynamic price to obtain payout tokens.', -} - -const isAllThenNone = (auctionTypes: AuctionType[] | undefined) => - !auctionTypes || auctionTypes.length === AuctionTypes.length - ? [] - : auctionTypes - -export const TableFiltersAuctionType: FC = () => { - const [pending, startTransition] = useTransition() - const [open, setOpen] = useState(false) - const { auctionTypes } = useBondFilters() - const { setFilters } = useSetBondFilters() - const [peekedAuctionType, setPeekedAuctionType] = React.useState( - AuctionType.Static, - ) - const [localValue, setValues] = useState( - isAllThenNone(auctionTypes), - ) - - const values = pending ? localValue : isAllThenNone(auctionTypes) - - const auctionTypeHandler = useCallback( - (item: AuctionType) => { - let _newValues: AuctionType[] - if (values?.includes(item)) { - _newValues = values.filter((el) => el !== item) - } else { - _newValues = [...(values ?? []), item] - } - _newValues = isAllThenNone(_newValues) - - setValues(_newValues) - - startTransition(() => { - setFilters((prev) => { - if (prev.auctionTypes?.includes(item)) { - return { ...prev, auctionTypes: _newValues } - } else { - return { ...prev, auctionTypes: _newValues } - } - }) - }) - }, - [setFilters, values], - ) - - return ( - - - - - - - - -
- -
- {AUCTIONTYPE_DESCRIPTIONS[peekedAuctionType]} -
-
-
-
- - - - - {AuctionTypes.map((el) => ( - setPeekedAuctionType(auctionType)} - onSelect={() => auctionTypeHandler(el)} - /> - ))} - - - -
-
-
- ) -} - -interface AuctionTypeItemProps { - auctionType: AuctionType - onSelect: () => void - selected: AuctionType[] - onPeek: (model: AuctionType) => void -} - -const AuctionTypeItem: FC = ({ - selected, - auctionType, - onSelect, - onPeek, -}) => { - const ref = React.useRef(null) - - useMutationObserver(ref, () => { - if (ref.current?.ariaSelected) { - onPeek(auctionType) - } - }) - - return ( - - {selected.includes(auctionType) ? ( - - - - ) : null} - {AuctionType[auctionType]} - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx deleted file mode 100644 index 5980bc10e3..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx +++ /dev/null @@ -1,146 +0,0 @@ -'use client' - -import { PlusCircleIcon } from '@heroicons/react/24/outline' -import { BondChainId } from '@sushiswap/bonds-sdk' -import { BONDS_ENABLED_CHAIN_IDS } from '@sushiswap/bonds-sdk' -import { - Chip, - Popover, - PopoverContent, - PopoverTrigger, - Separator, -} from '@sushiswap/ui' -import { Button } from '@sushiswap/ui' -import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' -import { CheckIcon } from '@sushiswap/ui/icons/CheckIcon' -import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' -import React, { - FC, - useCallback, - useEffect, - useState, - useTransition, -} from 'react' -import { Chain } from 'sushi/chain' -import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' - -const isAllThenNone = (chainIds: BondChainId[] | undefined) => - !chainIds || chainIds.length === BONDS_ENABLED_CHAIN_IDS.length - ? [] - : chainIds - -export const TableFiltersNetwork: FC = () => { - const [pending, startTransition] = useTransition() - const [open, setOpen] = useState(false) - const { chainIds } = useBondFilters() - const { setFilters } = useSetBondFilters() - const [localValue, setValues] = useState( - isAllThenNone(chainIds), - ) - - const values = pending ? localValue : isAllThenNone(chainIds) - - const onClick = useCallback( - (chainId: BondChainId) => { - let _newValues: BondChainId[] - if (localValue.includes(chainId)) { - _newValues = localValue.filter((el) => el !== chainId) - } else { - _newValues = [...(localValue ?? []), chainId] - } - _newValues = isAllThenNone(_newValues) - - setValues(_newValues) - - startTransition(() => { - setFilters((prev) => { - if (prev.chainIds?.includes(chainId)) { - return { ...prev, chainIds: _newValues } - } else { - return { ...prev, chainIds: _newValues } - } - }) - }) - }, - [setFilters, localValue], - ) - - useEffect(() => { - setValues(isAllThenNone(chainIds)) - }, [chainIds]) - - return ( - - - - - - - - {BONDS_ENABLED_CHAIN_IDS.map((chainId) => ( - - onClick(+currentValue as BondChainId) - } - className="py-2 pl-8 pr-2" - > - {values.includes(chainId) ? ( - - - - ) : null} - - {Chain.from(chainId)?.name} - - ))} - - - - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-open-only.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-open-only.tsx deleted file mode 100644 index c2bfd1262f..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-open-only.tsx +++ /dev/null @@ -1,37 +0,0 @@ -'use client' - -import { Toggle } from '@sushiswap/ui' -import React, { FC, useCallback, useState, useTransition } from 'react' - -import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' - -export const TableFiltersOpenOnly: FC = () => { - const [isPending, startTransition] = useTransition() - const { onlyOpen } = useBondFilters() - const { setFilters } = useSetBondFilters() - const [checked, setChecked] = useState(onlyOpen) - - const toggle = useCallback( - (checked: boolean) => { - setChecked(checked) - startTransition(() => { - setFilters((prev) => ({ - ...prev, - onlyOpen: prev.onlyOpen === undefined ? false : undefined, - })) - }) - }, - [setFilters], - ) - - return ( - - Open Markets Only - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-positive-discount-only.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-positive-discount-only.tsx deleted file mode 100644 index fcabef2aa7..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-positive-discount-only.tsx +++ /dev/null @@ -1,37 +0,0 @@ -'use client' - -import { Toggle } from '@sushiswap/ui' -import React, { FC, useCallback, useState, useTransition } from 'react' - -import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' - -export const TableFiltersPositiveDiscountOnly: FC = () => { - const [isPending, startTransition] = useTransition() - const { onlyDiscounted } = useBondFilters() - const { setFilters } = useSetBondFilters() - const [checked, setChecked] = useState(onlyDiscounted) - - const toggle = useCallback( - (checked: boolean) => { - setChecked(checked) - startTransition(() => { - setFilters((prev) => ({ - ...prev, - onlyDiscounted: !prev.onlyDiscounted ? true : undefined, - })) - }) - }, - [setFilters], - ) - - return ( - - Positive Discount Only - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-reset-button.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-reset-button.tsx deleted file mode 100644 index 2d2ba2698f..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-reset-button.tsx +++ /dev/null @@ -1,79 +0,0 @@ -'use client' - -import { XMarkIcon } from '@heroicons/react/24/solid' -import { Button } from '@sushiswap/ui' -import React, { FC, useCallback, useMemo, useState, useTransition } from 'react' - -import { AuctionTypes, BONDS_ENABLED_CHAIN_IDS } from '@sushiswap/bonds-sdk' -import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' - -export const TableFiltersResetButton: FC = () => { - const [isPending, startTransition] = useTransition() - const { - auctionTypes, - chainIds, - onlyDiscounted, - onlyOpen, - // payoutAssets, - // bondAssets, - } = useBondFilters() - const { setFilters } = useSetBondFilters() - - const networks = useMemo( - () => (BONDS_ENABLED_CHAIN_IDS.length === chainIds?.length ? [] : chainIds), - [chainIds], - ) - - const types = useMemo( - () => (auctionTypes?.length === AuctionTypes.length ? [] : auctionTypes), - [auctionTypes], - ) - - const [show, setShow] = useState( - (types?.length ?? 0) + (networks?.length ?? 0) || // + - // (payoutAssets?.length ?? 0) > - // 0 || - // (bondAssets?.length ?? 0) > 0 || - onlyDiscounted || - onlyOpen === false, - ) - - const reset = useCallback(() => { - setShow(false) - startTransition(() => { - setFilters({ - auctionTypes: undefined, - chainIds: undefined, - // payoutAssets: undefined, - // bondAssets: undefined, - onlyDiscounted: undefined, - onlyOpen: undefined, - }) - }) - }, [setFilters]) - - if ( - isPending - ? show - : (types?.length ?? 0) + (networks?.length ?? 0) || // + - // (payoutAssets?.length ?? 0) > - // 0 || - // (bondAssets?.length ?? 0) > 0 || - onlyDiscounted || - onlyOpen === false - ) { - return ( - - ) - } - - return null -} diff --git a/apps/web/src/ui/bonds/bonds-table/bonds-table.tsx b/apps/web/src/ui/bonds/bonds-table/bonds-table.tsx deleted file mode 100644 index 07504e22aa..0000000000 --- a/apps/web/src/ui/bonds/bonds-table/bonds-table.tsx +++ /dev/null @@ -1,79 +0,0 @@ -'use client' - -import { Bond, getBonds, getBondsUrl } from '@sushiswap/client' -import { BondsApiSchema } from '@sushiswap/client/api' -import { Card, CardHeader, CardTitle, DataTable } from '@sushiswap/ui' -import { useQuery } from '@tanstack/react-query' -import { ColumnDef, PaginationState, SortingState } from '@tanstack/react-table' -import { useSearchParams } from 'next/navigation' -import React, { FC, useMemo, useState } from 'react' -import { - BOND_ASSET_COLUMN, - DISCOUNT_COLUMN, - // ISSUER_COLUMN, - PAYOUT_ASSET_COLUMN, - PRICE_COLUMN, - VESTING_COLUMN, -} from './bonds-table-columns' - -const COLUMNS = [ - PAYOUT_ASSET_COLUMN, - PRICE_COLUMN, - DISCOUNT_COLUMN, - BOND_ASSET_COLUMN, - VESTING_COLUMN, - // ISSUER_COLUMN, -] satisfies ColumnDef[] - -const emptyArray: any[] = [] - -export const BondsTable: FC = () => { - const searchParams = useSearchParams() - - const args = useMemo(() => { - return BondsApiSchema.parse(Object.fromEntries(searchParams)) - }, [searchParams]) - - const { data, isLoading } = useQuery({ - queryKey: [getBondsUrl(args)], - queryFn: () => getBonds(args), - gcTime: 0, - }) - - const [sortingState, setSortingState] = useState([ - { id: 'discount', desc: true }, - ]) - - const [paginationState, setPaginationState] = useState({ - pageIndex: 0, - pageSize: 10, - }) - - return ( - - - - Bonds{' '} - {data && ( - - ({data.length}) - - )} - - - `/bonds/${row.id}`} - pagination={true} - onPaginationChange={setPaginationState} - onSortingChange={setSortingState} - state={{ - sorting: sortingState, - pagination: paginationState, - }} - /> - - ) -} diff --git a/apps/web/src/ui/bonds/bonds-widget.tsx b/apps/web/src/ui/bonds/bonds-widget.tsx deleted file mode 100644 index ff321ac226..0000000000 --- a/apps/web/src/ui/bonds/bonds-widget.tsx +++ /dev/null @@ -1,402 +0,0 @@ -'use client' - -import { ArrowDownIcon } from '@heroicons/react/24/solid' -import { getCliffTimestamp } from '@sushiswap/bonds-sdk' -import { Bond } from '@sushiswap/client' -import { useIsMounted } from '@sushiswap/hooks' -import { - Button, - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - Collapsible, - DialogTrigger, - Explainer, - LinkInternal, - SkeletonText, - classNames, -} from '@sushiswap/ui' -import format from 'date-fns/format' -import formatDistance from 'date-fns/formatDistance' -import React, { useCallback, useEffect, useMemo, useState } from 'react' -import { APPROVE_TAG_BONDS } from 'src/lib/constants' -import { Web3Input } from 'src/lib/wagmi/components/web3-input' -import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' -import { Checker } from 'src/lib/wagmi/systems/Checker' -import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' -import { Amount, Token, tryParseAmount } from 'sushi/currency' -import { formatPercent } from 'sushi/format' -import { useChainId } from 'wagmi' -import { BondsBuyReviewModal } from './bonds-buy-review-modal' - -const GetTokens = ({ bond }: { bond: Bond }) => { - if (!bond.quoteToken.pool && !bond.quoteToken.vault) return null - - let text = '' - let link: React.JSX.Element = <> - - if (bond.quoteToken.pool) { - const pool = bond.quoteToken.pool - text = `Get ${pool.token0.symbol}/${pool.token1.symbol} SLP tokens` - link = ( - - Go to pool - - ) - } else if (bond.quoteToken.vault) { - const vault = bond.quoteToken.vault - - text = `Get ${vault.token0.symbol}/${vault.token1.symbol} LP tokens` - link = ( - - Go to Smart Pool - - ) - } - - return ( -
-
-
- {text} - - Liquidity Provider (LP) tokens represent proportional ownership of - the liquidity pool when you provide liquidity to the corresponding - pool on Sushi, they are redeemable for the originally deposited - assets and accrued trading fee. By spending your LP tokens to - acquire the bond, you will be trading them with the vested tokens at - a discount instead. - -
-
{link}
-
-
- ) -} - -export const BondsWidget = ({ bond: staleBond }: { bond: Bond }) => { - const [quoteToken, payoutToken] = useMemo(() => { - return [new Token(staleBond.quoteToken), new Token(staleBond.payoutToken)] - }, [staleBond.quoteToken, staleBond.payoutToken]) - - const chainId = useChainId() - - const { maxAmountAccepted, availableCapacity, marketPrice, discount } = - useBondMarketDetails({ - bond: staleBond, - }) - - // Amount handling - const [independentField, setIndependentField] = useState<'quote' | 'payout'>( - 'quote', - ) - - const [quoteInputField, setQuoteInput] = useState('') - const [payoutInputField, setPayoutInput] = useState('') - - const [quoteAmount, setQuoteAmount] = useState( - Amount.fromRawAmount(quoteToken, 0), - ) - const [payoutAmount, setPayoutAmount] = useState( - Amount.fromRawAmount(payoutToken, 0), - ) - - const onQuoteInput = useCallback( - (value: string) => { - if (!maxAmountAccepted || !marketPrice) { - return - } - - let quoteAmount = tryParseAmount(value, quoteToken) - - if (quoteAmount === undefined) { - quoteAmount = Amount.fromRawAmount(quoteToken, 0) - } - - if (quoteAmount.greaterThan(maxAmountAccepted)) { - quoteAmount = maxAmountAccepted - value = quoteAmount.toSignificant(8) - } - - setIndependentField('quote') - setQuoteInput(value) - setQuoteAmount(quoteAmount) - - let payoutAmount = quoteAmount - .multiply(staleBond.marketScale) - .divide(marketPrice) - payoutAmount = Amount.fromFractionalAmount( - payoutToken, - payoutAmount.numerator, - payoutAmount.denominator, - ) - - setPayoutAmount(payoutAmount) - setPayoutInput(value === '' ? '' : payoutAmount.toSignificant(8)) - }, - [ - maxAmountAccepted, - marketPrice, - quoteToken, - staleBond.marketScale, - payoutToken, - ], - ) - - const onPayoutInput = useCallback( - (value: string) => { - if (!availableCapacity || !marketPrice) { - return - } - - let payoutAmount = tryParseAmount(value, payoutToken) - - if (payoutAmount === undefined) { - payoutAmount = Amount.fromRawAmount(payoutToken, 0) - } - - if (payoutAmount.greaterThan(availableCapacity)) { - payoutAmount = availableCapacity - value = payoutAmount.toSignificant(8) - } - - setIndependentField('payout') - setPayoutInput(value) - setPayoutAmount(payoutAmount) - - let quoteAmount = payoutAmount - .multiply(marketPrice) - .divide(staleBond.marketScale) - quoteAmount = Amount.fromFractionalAmount( - quoteToken, - quoteAmount.numerator, - quoteAmount.denominator, - ) - - setQuoteAmount(quoteAmount) - setQuoteInput(value === '' ? '' : quoteAmount.toSignificant(8)) - }, - [ - availableCapacity, - marketPrice, - payoutToken, - quoteToken, - staleBond.marketScale, - ], - ) - - // biome-ignore lint/correctness/useExhaustiveDependencies: need to update quote/payout input fields when market price changes - useEffect(() => { - if (independentField === 'quote') { - onQuoteInput(quoteInputField) - } else { - onPayoutInput(payoutInputField) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [marketPrice]) - - // Negative discount warning - const [noDiscountConfirmed, setNoDiscountConfirmed] = useState(false) - - const isMounted = useIsMounted() - - const hasEnded = staleBond.end * 1000 < Date.now() || staleBond.isClosed - const isNegativeDiscount = Boolean(discount && discount < 0) - const buttonVariant = isNegativeDiscount ? 'destructive' : 'default' - const buttonText = isNegativeDiscount ? 'Bond Anyways' : 'Bond' - - return ( - - - - Bond - -
- Acquire vested tokens at a discount using the widget below. -
-
-
- - -
- -
-
- -
-
- -
-
- -
- {isMounted ? ( - - - - - - - - onQuoteInput('')} - > - - - - - - - - - - - - ) : ( - - )} - - {isNegativeDiscount && ( -
- setNoDiscountConfirmed(e.target.checked)} - className="cursor-pointer mr-1 w-5 h-5 mt-0.5 text-red-500 !ring-red-600 bg-white border-red rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 scale-75" - /> - -
- )} - -
-
- - Discount - - {discount !== undefined ? ( - - {formatPercent(discount)} - - ) : ( - - )} -
-
- - Cliff - - - {isMounted && - formatDistance( - getCliffTimestamp({ - vestingLength: staleBond.vesting, - vestingType: staleBond.vestingType, - }) * 1000, - Date.now(), - )} - -
-
- - Claimable Date - - - {isMounted && - format( - getCliffTimestamp({ - vestingLength: staleBond.vesting, - vestingType: staleBond.vestingType, - }) * 1000, - 'MMM dd, yyyy HH:mm', - )} - -
-
-
-
-
-
-
- ) -} diff --git a/apps/web/src/ui/bonds/index.ts b/apps/web/src/ui/bonds/index.ts deleted file mode 100644 index b129a66655..0000000000 --- a/apps/web/src/ui/bonds/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './bonds-table/bonds-table-filters/bonds-filters-provider' -export * from './bonds-table/bonds-table-filters/table-filters-auction-type' -export * from './bonds-table/bonds-table-filters/table-filters-networks' -export * from './bonds-table/bonds-table-filters/table-filters-open-only' -export * from './bonds-table/bonds-table-filters/table-filters-positive-discount-only' -export * from './bonds-table/bonds-table' -export * from './bonds-table/bonds-table-filters/table-filters-reset-button' -export * from './bonds-positions-table/bonds-positions-table' -export * from './bonds-widget' -export * from './bonds-market-details' diff --git a/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx b/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx index 4acc160810..b1a62d6de8 100644 --- a/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx +++ b/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx @@ -26,8 +26,8 @@ import { } from '@sushiswap/ui' import React, { FC, ReactNode, useCallback, useMemo } from 'react' import { Bound } from 'src/lib/constants' +import { NativeAddress } from 'src/lib/constants' import { useTokenAmountDollarValues } from 'src/lib/hooks' -import { NativeAddress } from 'src/lib/hooks/react-query' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' import { getDefaultTTL, diff --git a/apps/web/src/ui/pool/AddSectionReviewModalLegacy.tsx b/apps/web/src/ui/pool/AddSectionReviewModalLegacy.tsx index 1e24fe69c1..b0efdb0c17 100644 --- a/apps/web/src/ui/pool/AddSectionReviewModalLegacy.tsx +++ b/apps/web/src/ui/pool/AddSectionReviewModalLegacy.tsx @@ -25,7 +25,7 @@ import { Button } from '@sushiswap/ui' import { Dots } from '@sushiswap/ui' import { FC, ReactNode, useCallback, useMemo } from 'react' import { APPROVE_TAG_ADD_LEGACY } from 'src/lib/constants' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' import { getSushiSwapRouterContractConfig } from 'src/lib/wagmi/hooks/contracts/useSushiSwapRouter' import { SushiSwapV2PoolState } from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' diff --git a/apps/web/src/ui/pool/PoolsFiltersProvider.tsx b/apps/web/src/ui/pool/PoolsFiltersProvider.tsx index 665bd6c499..9aef4e40ae 100644 --- a/apps/web/src/ui/pool/PoolsFiltersProvider.tsx +++ b/apps/web/src/ui/pool/PoolsFiltersProvider.tsx @@ -1,6 +1,5 @@ 'use client' -import { parseArgs } from '@sushiswap/client' import { useRouter } from 'next/navigation' import { Dispatch, @@ -14,6 +13,7 @@ import { import { SushiSwapProtocol } from 'sushi' import { z } from 'zod' +import { parseArgs } from 'src/lib/functions' import { useTypedSearchParams } from '../../lib/hooks' import { POOL_TYPES } from './TableFiltersPoolType' diff --git a/apps/web/test/helpers/pool.ts b/apps/web/test/helpers/pool.ts index 5d2623d972..ad512f3727 100644 --- a/apps/web/test/helpers/pool.ts +++ b/apps/web/test/helpers/pool.ts @@ -1,6 +1,6 @@ import { Page, expect } from '@playwright/test' import { NextFixture } from 'next/experimental/testmode/playwright' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { SUSHISWAP_V2_FACTORY_ADDRESS, SUSHISWAP_V3_FACTORY_ADDRESS, diff --git a/apps/web/test/helpers/swap.ts b/apps/web/test/helpers/swap.ts index e7854af14a..d31f739c9e 100644 --- a/apps/web/test/helpers/swap.ts +++ b/apps/web/test/helpers/swap.ts @@ -1,5 +1,5 @@ import { Page, expect } from '@playwright/test' -import { NativeAddress } from 'src/lib/hooks/react-query' +import { NativeAddress } from 'src/lib/constants' import { API_BASE_URL } from 'sushi/config' import { Amount, Native, Type } from 'sushi/currency' import { BaseActions } from './base' // Adjust the import path as necessary diff --git a/apps/web/test/swap/simple.test.ts b/apps/web/test/swap/simple.test.ts index 1e63d35bb1..46d8f20b46 100644 --- a/apps/web/test/swap/simple.test.ts +++ b/apps/web/test/swap/simple.test.ts @@ -32,26 +32,6 @@ test.beforeEach(async ({ page, next }) => { await route.fulfill({ json: { maintenance: false } }) }) - // await page.route( - // 'http://localhost:3000/api/balance/v0/**/*', - // async (route) => { - // await route.fulfill({ json: {} }) - // }, - // ) - - // await page.route('http://tokens.sushi.com/v0', async (route) => { - // await route.fulfill({ - // json: [wnative, usdc, usdt, wbtc].map((token) => ({ - // id: token.id, - // chainId: token.chainId, - // address: token.address.toLowerCase(), - // name: token.name, - // symbol: token.symbol, - // decimals: token.decimals, - // })), - // }) - // }) - try { await interceptAnvil(page, next) } catch (_e) { diff --git a/config/nextjs/index.js b/config/nextjs/index.js index bdf43a9316..21076e4cce 100644 --- a/config/nextjs/index.js +++ b/config/nextjs/index.js @@ -12,8 +12,6 @@ const defaultNextConfig = { optimizePackageImports: [ '@heroicons/react-v1/solid', '@heroicons/react-v1/outline', - '@sushiswap/client', - '@sushiswap/database', '@sushiswap/graph-client', '@sushiswap/hooks', '@sushiswap/router', diff --git a/packages/bonds-sdk/README.md b/packages/bonds-sdk/README.md deleted file mode 100644 index 122aa33e28..0000000000 --- a/packages/bonds-sdk/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# V3 SDK - -V3 SDK library diff --git a/packages/bonds-sdk/package.json b/packages/bonds-sdk/package.json deleted file mode 100644 index 7d3d8f0dae..0000000000 --- a/packages/bonds-sdk/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "@sushiswap/bonds-sdk", - "version": "0.0.0", - "private": true, - "description": "Sushi Bonds SDK", - "keywords": [ - "sushiswap", - "bonds", - "sdk" - ], - "repository": { - "type": "git", - "url": "https://github.com/sushiswap/sushiswap.git", - "directory": "packages/bonds-sdk" - }, - "license": "MIT", - "author": "Lufy ", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "default": "./dist/index.js" - }, - "./abi": { - "types": "./dist/abi/index.d.ts", - "import": "./dist/abi/index.js", - "default": "./dist/abi/index.js" - }, - "./package.json": "./package.json" - }, - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "typesVersions": { - "*": { - "*": [ - "src/index" - ], - "abi": [ - "src/abi/index" - ] - } - }, - "files": [ - "dist/**" - ], - "scripts": { - "build": "tsc", - "check": "tsc --pretty --noEmit", - "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", - "dev": "tsc -w", - "prepublishOnly": "pnpm build" - }, - "dependencies": { - "sushi": "4.0.2" - }, - "devDependencies": { - "@tsconfig/esm": "1.0.4", - "@tsconfig/strictest": "2.0.2", - "@types/node": "20", - "typescript": "5.5.4", - "viem": "2.21.4" - }, - "peerDependencies": { - "react": "18.2.0", - "react-dom": "18.2.0" - }, - "peerDependenciesMeta": { - "react": { - "optional": true - }, - "react-dom": { - "optional": true - } - }, - "optionalDependencies": { - "next": "14.2.11" - } -} diff --git a/packages/bonds-sdk/src/abi/bondFixedTermSDA.ts b/packages/bonds-sdk/src/abi/bondFixedTermSDA.ts deleted file mode 100644 index a180ba2f5f..0000000000 --- a/packages/bonds-sdk/src/abi/bondFixedTermSDA.ts +++ /dev/null @@ -1,522 +0,0 @@ -export const bondFixedTermSDAAbi = [ - { - inputs: [ - { - internalType: 'contract IBondTeller', - name: 'teller_', - type: 'address', - }, - { - internalType: 'contract IBondAggregator', - name: 'aggregator_', - type: 'address', - }, - { internalType: 'address', name: 'guardian_', type: 'address' }, - { - internalType: 'contract Authority', - name: 'authority_', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { inputs: [], name: 'Auctioneer_AmountLessThanMinimum', type: 'error' }, - { inputs: [], name: 'Auctioneer_BadExpiry', type: 'error' }, - { inputs: [], name: 'Auctioneer_InitialPriceLessThanMin', type: 'error' }, - { inputs: [], name: 'Auctioneer_InvalidCallback', type: 'error' }, - { inputs: [], name: 'Auctioneer_InvalidParams', type: 'error' }, - { - inputs: [{ internalType: 'uint256', name: 'conclusion_', type: 'uint256' }], - name: 'Auctioneer_MarketConcluded', - type: 'error', - }, - { inputs: [], name: 'Auctioneer_MaxPayoutExceeded', type: 'error' }, - { inputs: [], name: 'Auctioneer_NewMarketsNotAllowed', type: 'error' }, - { inputs: [], name: 'Auctioneer_NotAuthorized', type: 'error' }, - { inputs: [], name: 'Auctioneer_NotEnoughCapacity', type: 'error' }, - { inputs: [], name: 'Auctioneer_OnlyMarketOwner', type: 'error' }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { - indexed: true, - internalType: 'contract Authority', - name: 'newAuthority', - type: 'address', - }, - ], - name: 'AuthorityUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint32', - name: 'defaultTuneInterval', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'defaultTuneAdjustment', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'minDebtDecayInterval', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'minDepositInterval', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'minMarketDuration', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'minDebtBuffer', - type: 'uint32', - }, - ], - name: 'DefaultsUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' }, - ], - name: 'MarketClosed', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' }, - { - indexed: true, - internalType: 'address', - name: 'payoutToken', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'quoteToken', - type: 'address', - }, - { - indexed: false, - internalType: 'uint48', - name: 'vesting', - type: 'uint48', - }, - { - indexed: false, - internalType: 'uint256', - name: 'initialPrice', - type: 'uint256', - }, - ], - name: 'MarketCreated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnerUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' }, - { - indexed: false, - internalType: 'uint256', - name: 'oldControlVariable', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'newControlVariable', - type: 'uint256', - }, - ], - name: 'Tuned', - type: 'event', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'adjustments', - outputs: [ - { internalType: 'uint256', name: 'change', type: 'uint256' }, - { internalType: 'uint48', name: 'lastAdjustment', type: 'uint48' }, - { internalType: 'uint48', name: 'timeToAdjusted', type: 'uint48' }, - { internalType: 'bool', name: 'active', type: 'bool' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'allowNewMarkets', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'authority', - outputs: [ - { internalType: 'contract Authority', name: '', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: '', type: 'address' }], - name: 'callbackAuthorized', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'closeMarket', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes', name: 'params_', type: 'bytes' }], - name: 'createMarket', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'currentCapacity', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'currentControlVariable', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'currentDebt', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'defaultTuneAdjustment', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'defaultTuneInterval', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getAggregator', - outputs: [ - { internalType: 'contract IBondAggregator', name: '', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'getMarketInfoForPurchase', - outputs: [ - { internalType: 'address', name: 'owner', type: 'address' }, - { internalType: 'address', name: 'callbackAddr', type: 'address' }, - { internalType: 'contract ERC20', name: 'payoutToken', type: 'address' }, - { internalType: 'contract ERC20', name: 'quoteToken', type: 'address' }, - { internalType: 'uint48', name: 'vesting', type: 'uint48' }, - { internalType: 'uint256', name: 'maxPayout', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getTeller', - outputs: [ - { internalType: 'contract IBondTeller', name: '', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'isInstantSwap', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'isLive', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'marketPrice', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'marketScale', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'markets', - outputs: [ - { internalType: 'address', name: 'owner', type: 'address' }, - { internalType: 'contract ERC20', name: 'payoutToken', type: 'address' }, - { internalType: 'contract ERC20', name: 'quoteToken', type: 'address' }, - { internalType: 'address', name: 'callbackAddr', type: 'address' }, - { internalType: 'bool', name: 'capacityInQuote', type: 'bool' }, - { internalType: 'uint256', name: 'capacity', type: 'uint256' }, - { internalType: 'uint256', name: 'totalDebt', type: 'uint256' }, - { internalType: 'uint256', name: 'minPrice', type: 'uint256' }, - { internalType: 'uint256', name: 'maxPayout', type: 'uint256' }, - { internalType: 'uint256', name: 'sold', type: 'uint256' }, - { internalType: 'uint256', name: 'purchased', type: 'uint256' }, - { internalType: 'uint256', name: 'scale', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'address', name: 'referrer_', type: 'address' }, - ], - name: 'maxAmountAccepted', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'metadata', - outputs: [ - { internalType: 'uint48', name: 'lastTune', type: 'uint48' }, - { internalType: 'uint48', name: 'lastDecay', type: 'uint48' }, - { internalType: 'uint32', name: 'length', type: 'uint32' }, - { internalType: 'uint32', name: 'depositInterval', type: 'uint32' }, - { internalType: 'uint32', name: 'tuneInterval', type: 'uint32' }, - { internalType: 'uint32', name: 'tuneAdjustmentDelay', type: 'uint32' }, - { internalType: 'uint32', name: 'debtDecayInterval', type: 'uint32' }, - { - internalType: 'uint256', - name: 'tuneIntervalCapacity', - type: 'uint256', - }, - { internalType: 'uint256', name: 'tuneBelowCapacity', type: 'uint256' }, - { internalType: 'uint256', name: 'lastTuneDebt', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'minDebtBuffer', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'minDebtDecayInterval', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'minDepositInterval', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'minMarketDuration', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'newOwners', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'owner', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'ownerOf', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'amount_', type: 'uint256' }, - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'address', name: 'referrer_', type: 'address' }, - ], - name: 'payoutFor', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'id_', type: 'uint256' }], - name: 'pullOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'uint256', name: 'amount_', type: 'uint256' }, - { internalType: 'uint256', name: 'minAmountOut_', type: 'uint256' }, - ], - name: 'purchaseBond', - outputs: [{ internalType: 'uint256', name: 'payout', type: 'uint256' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'address', name: 'newOwner_', type: 'address' }, - ], - name: 'pushOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'bool', name: 'status_', type: 'bool' }], - name: 'setAllowNewMarkets', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'contract Authority', - name: 'newAuthority', - type: 'address', - }, - ], - name: 'setAuthority', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'creator_', type: 'address' }, - { internalType: 'bool', name: 'status_', type: 'bool' }, - ], - name: 'setCallbackAuthStatus', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint32[6]', name: 'defaults_', type: 'uint32[6]' }, - ], - name: 'setDefaults', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'uint32[3]', name: 'intervals_', type: 'uint32[3]' }, - ], - name: 'setIntervals', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], - name: 'setOwner', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'terms', - outputs: [ - { internalType: 'uint256', name: 'controlVariable', type: 'uint256' }, - { internalType: 'uint256', name: 'maxDebt', type: 'uint256' }, - { internalType: 'uint48', name: 'vesting', type: 'uint48' }, - { internalType: 'uint48', name: 'conclusion', type: 'uint48' }, - ], - stateMutability: 'view', - type: 'function', - }, -] as const diff --git a/packages/bonds-sdk/src/abi/bondFixedTermTeller.ts b/packages/bonds-sdk/src/abi/bondFixedTermTeller.ts deleted file mode 100644 index eec0a91aad..0000000000 --- a/packages/bonds-sdk/src/abi/bondFixedTermTeller.ts +++ /dev/null @@ -1,460 +0,0 @@ -export const bondFixedTermTellerAbi = [ - { - inputs: [ - { internalType: 'address', name: 'protocol_', type: 'address' }, - { - internalType: 'contract IBondAggregator', - name: 'aggregator_', - type: 'address', - }, - { internalType: 'address', name: 'guardian_', type: 'address' }, - { - internalType: 'contract Authority', - name: 'authority_', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { inputs: [], name: 'Teller_InvalidCallback', type: 'error' }, - { inputs: [], name: 'Teller_InvalidParams', type: 'error' }, - { inputs: [], name: 'Teller_NotAuthorized', type: 'error' }, - { - inputs: [ - { internalType: 'contract ERC20', name: 'underlying', type: 'address' }, - { internalType: 'uint48', name: 'expiry', type: 'uint48' }, - ], - name: 'Teller_TokenDoesNotExist', - type: 'error', - }, - { - inputs: [{ internalType: 'uint48', name: 'maturesOn', type: 'uint48' }], - name: 'Teller_TokenNotMatured', - type: 'error', - }, - { inputs: [], name: 'Teller_UnsupportedToken', type: 'error' }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'operator', - type: 'address', - }, - { indexed: false, internalType: 'bool', name: 'approved', type: 'bool' }, - ], - name: 'ApprovalForAll', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { - indexed: true, - internalType: 'contract Authority', - name: 'newAuthority', - type: 'address', - }, - ], - name: 'AuthorityUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' }, - { - indexed: true, - internalType: 'address', - name: 'referrer', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'payout', - type: 'uint256', - }, - ], - name: 'Bonded', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - indexed: true, - internalType: 'contract ERC20', - name: 'underlying', - type: 'address', - }, - { indexed: true, internalType: 'uint48', name: 'expiry', type: 'uint48' }, - ], - name: 'ERC1155BondTokenCreated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnerUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'operator', - type: 'address', - }, - { indexed: true, internalType: 'address', name: 'from', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - { - indexed: false, - internalType: 'uint256[]', - name: 'ids', - type: 'uint256[]', - }, - { - indexed: false, - internalType: 'uint256[]', - name: 'amounts', - type: 'uint256[]', - }, - ], - name: 'TransferBatch', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'operator', - type: 'address', - }, - { indexed: true, internalType: 'address', name: 'from', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'id', type: 'uint256' }, - { - indexed: false, - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'TransferSingle', - type: 'event', - }, - { - inputs: [], - name: 'FEE_DECIMALS', - outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'authority', - outputs: [ - { internalType: 'contract Authority', name: '', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: '', type: 'address' }, - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - name: 'balanceOf', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address[]', name: 'owners', type: 'address[]' }, - { internalType: 'uint256[]', name: 'ids', type: 'uint256[]' }, - ], - name: 'balanceOfBatch', - outputs: [ - { internalType: 'uint256[]', name: 'balances', type: 'uint256[]' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256[]', name: 'tokenIds_', type: 'uint256[]' }, - { internalType: 'uint256[]', name: 'amounts_', type: 'uint256[]' }, - ], - name: 'batchRedeem', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'contract ERC20[]', name: 'tokens_', type: 'address[]' }, - { internalType: 'address', name: 'to_', type: 'address' }, - ], - name: 'claimFees', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'contract ERC20', name: 'underlying_', type: 'address' }, - { internalType: 'uint48', name: 'expiry_', type: 'uint48' }, - { internalType: 'uint256', name: 'amount_', type: 'uint256' }, - ], - name: 'create', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'createFeeDiscount', - outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'contract ERC20', name: 'underlying_', type: 'address' }, - { internalType: 'uint48', name: 'expiry_', type: 'uint48' }, - ], - name: 'deploy', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: 'referrer_', type: 'address' }], - name: 'getFee', - outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'contract ERC20', name: 'underlying_', type: 'address' }, - { internalType: 'uint48', name: 'expiry_', type: 'uint48' }, - ], - name: 'getTokenId', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'pure', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: 'tokenId_', type: 'uint256' }], - name: 'getTokenNameAndSymbol', - outputs: [ - { internalType: 'string', name: '', type: 'string' }, - { internalType: 'string', name: '', type: 'string' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: '', type: 'address' }, - { internalType: 'address', name: '', type: 'address' }, - ], - name: 'isApprovedForAll', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'owner', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'protocolFee', - outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'recipient_', type: 'address' }, - { internalType: 'address', name: 'referrer_', type: 'address' }, - { internalType: 'uint256', name: 'id_', type: 'uint256' }, - { internalType: 'uint256', name: 'amount_', type: 'uint256' }, - { internalType: 'uint256', name: 'minAmountOut_', type: 'uint256' }, - ], - name: 'purchase', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - { internalType: 'uint48', name: '', type: 'uint48' }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'tokenId_', type: 'uint256' }, - { internalType: 'uint256', name: 'amount_', type: 'uint256' }, - ], - name: 'redeem', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: '', type: 'address' }], - name: 'referrerFees', - outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: '', type: 'address' }, - { internalType: 'contract ERC20', name: '', type: 'address' }, - ], - name: 'rewards', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'from', type: 'address' }, - { internalType: 'address', name: 'to', type: 'address' }, - { internalType: 'uint256[]', name: 'ids', type: 'uint256[]' }, - { internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, - ], - name: 'safeBatchTransferFrom', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'from', type: 'address' }, - { internalType: 'address', name: 'to', type: 'address' }, - { internalType: 'uint256', name: 'id', type: 'uint256' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, - ], - name: 'safeTransferFrom', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'operator', type: 'address' }, - { internalType: 'bool', name: 'approved', type: 'bool' }, - ], - name: 'setApprovalForAll', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'contract Authority', - name: 'newAuthority', - type: 'address', - }, - ], - name: 'setAuthority', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'uint48', name: 'discount_', type: 'uint48' }], - name: 'setCreateFeeDiscount', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], - name: 'setOwner', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'uint48', name: 'fee_', type: 'uint48' }], - name: 'setProtocolFee', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'uint48', name: 'fee_', type: 'uint48' }], - name: 'setReferrerFee', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }], - name: 'supportsInterface', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - name: 'tokenMetadata', - outputs: [ - { internalType: 'bool', name: 'active', type: 'bool' }, - { internalType: 'contract ERC20', name: 'underlying', type: 'address' }, - { internalType: 'uint8', name: 'decimals', type: 'uint8' }, - { internalType: 'uint48', name: 'expiry', type: 'uint48' }, - { internalType: 'uint256', name: 'supply', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, -] as const diff --git a/packages/bonds-sdk/src/abi/index.ts b/packages/bonds-sdk/src/abi/index.ts deleted file mode 100644 index d2d089e5ba..0000000000 --- a/packages/bonds-sdk/src/abi/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './bondFixedTermTeller' -export * from './bondFixedTermSDA' diff --git a/packages/bonds-sdk/src/calc/cliff.ts b/packages/bonds-sdk/src/calc/cliff.ts deleted file mode 100644 index 21ef2a10ca..0000000000 --- a/packages/bonds-sdk/src/calc/cliff.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { VestingType } from '..' - -interface GetCliffTimestamp { - vestingLength: number - vestingType: VestingType -} - -/** - * - * @param vestingType type of vesting - * @param vestingLength length of vesting - * - * @returns cliff timestamp in seconds - */ -export function getCliffTimestamp({ - vestingType, - vestingLength, -}: GetCliffTimestamp) { - switch (vestingType) { - case VestingType['Fixed-Term']: { - return vestingLength + Math.floor(Date.now() / 1000) - } - } -} diff --git a/packages/bonds-sdk/src/calc/discount.ts b/packages/bonds-sdk/src/calc/discount.ts deleted file mode 100644 index 20a882bb48..0000000000 --- a/packages/bonds-sdk/src/calc/discount.ts +++ /dev/null @@ -1,39 +0,0 @@ -interface GetBondDiscount { - marketPrice: bigint - marketScale: bigint - payoutToken: { - decimals: number - priceUSD: number - } - quoteToken: { - decimals: number - priceUSD: number - } - fee?: number -} - -/** - * @see https://dev.bondprotocol.finance/developers/market-calculations - */ -export function getBondDiscount({ - payoutToken, - quoteToken, - marketScale, - marketPrice, -}: GetBondDiscount) { - const baseScale = - 10n ** BigInt(36 + payoutToken.decimals - quoteToken.decimals) - - const shift = Number(baseScale) / Number(marketScale) - const price = Number(marketPrice) * shift - const quoteTokensPerPayoutToken = price / 10 ** 36 - - const discountedPrice = quoteTokensPerPayoutToken * quoteToken.priceUSD - const discount = -1 * (discountedPrice / payoutToken.priceUSD - 1) - - return { - discount, - quoteTokensPerPayoutToken, - discountedPrice, - } -} diff --git a/packages/bonds-sdk/src/calc/index.ts b/packages/bonds-sdk/src/calc/index.ts deleted file mode 100644 index 5e2054af0e..0000000000 --- a/packages/bonds-sdk/src/calc/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './discount' -export * from './cliff' diff --git a/packages/bonds-sdk/src/constants.ts b/packages/bonds-sdk/src/constants.ts deleted file mode 100644 index 1f320d712c..0000000000 --- a/packages/bonds-sdk/src/constants.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { ChainId } from 'sushi/chain' -import { type Address } from 'viem' - -export const FEE_DECIMALS = 100000 - -export const AuctionType = { - Static: 'Static', - Dynamic: 'Dynamic', -} as const - -export const AuctionTypes = [AuctionType.Static, AuctionType.Dynamic] as const - -export type AuctionType = (typeof AuctionType)[keyof typeof AuctionType] - -export const VestingType = { - 'Fixed-Term': 'Fixed-Term', -} as const - -export const VestingTypes = [VestingType['Fixed-Term']] as const - -export type VestingType = (typeof VestingType)[keyof typeof VestingType] - -export const BONDS_ENABLED_CHAIN_IDS = [ - ChainId.ETHEREUM, - ChainId.BSC, - ChainId.ARBITRUM, - ChainId.OPTIMISM, - ChainId.POLYGON, -] as const satisfies Readonly - -export type BondChainId = (typeof BONDS_ENABLED_CHAIN_IDS)[number] - -export const BONDS_SUBGRAPH_URL: Record = { - [ChainId.ETHEREUM]: - 'api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-mainnet', - [ChainId.BSC]: - 'api.goldsky.com/api/public/project_clu16lu24lqh201x9f0qh135t/subgraphs/bond-protocol-bsc/0.0.1/gn', - [ChainId.ARBITRUM]: - 'api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-arbitrum-mainnet', - [ChainId.OPTIMISM]: - 'api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-optimism-mainnet', - [ChainId.POLYGON]: - 'api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-polygon-mainnet', -} - -export const isBondChainId = (chainId: ChainId): chainId is BondChainId => - BONDS_ENABLED_CHAIN_IDS.includes(chainId as BondChainId) - -export const REFERRER_ADDRESS: Record = { - [ChainId.ETHEREUM]: '0x19B3Eb3Af5D93b77a5619b047De0EED7115A19e7', - [ChainId.BSC]: '0xc6fD91aD4919Fd91e2c84077ba648092cB499638', - [ChainId.ARBITRUM]: '0x978982772b8e4055B921bf9295c0d74eB36Bc54e', - [ChainId.OPTIMISM]: '0x1219Bfa3A499548507b4917E33F17439b67A2177', - [ChainId.POLYGON]: '0x850a57630A2012B2494779fBc86bBc24F2a7baeF', -} diff --git a/packages/bonds-sdk/src/fetchers/getMarketInfo.ts b/packages/bonds-sdk/src/fetchers/getMarketInfo.ts deleted file mode 100644 index 873ff5e198..0000000000 --- a/packages/bonds-sdk/src/fetchers/getMarketInfo.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type { PublicClient } from 'viem' -import { type MarketId, getChainIdAuctioneerMarketFromMarketId } from '..' -import { bondFixedTermSDAAbi } from '../abi' - -export function getMarketInfosContracts({ - marketIds, -}: { marketIds: MarketId[] }) { - return marketIds.map((marketId) => { - const { chainId, auctioneerAddress, marketNumber } = - getChainIdAuctioneerMarketFromMarketId(marketId) - - return { - abi: bondFixedTermSDAAbi, - chainId, - address: auctioneerAddress, - functionName: 'getMarketInfoForPurchase' as const, - args: [marketNumber] as const, - } - }) -} - -interface GetMarketInfos { - client: PublicClient - marketIds: MarketId[] -} - -export async function getMarketInfos({ client, marketIds }: GetMarketInfos) { - const result = await client.multicall({ - allowFailure: true, - contracts: getMarketInfosContracts({ marketIds }), - }) - - return result.flatMap((r, i) => - r.result - ? { - marketId: marketIds[i]!, - owner: r.result[0], - callbackAddress: r.result[1], - payoutToken: r.result[2], - quoteToken: r.result[3], - vesting: r.result[4], - maxPayout: r.result[5], - } - : [], - ) -} - -interface GetMarketInfo { - client: PublicClient - marketId: MarketId -} - -export async function getMarketInfo({ client, marketId }: GetMarketInfo) { - return (await getMarketInfos({ client, marketIds: [marketId] }))[0] -} diff --git a/packages/bonds-sdk/src/fetchers/getMarketPrice.ts b/packages/bonds-sdk/src/fetchers/getMarketPrice.ts deleted file mode 100644 index 31227b9f10..0000000000 --- a/packages/bonds-sdk/src/fetchers/getMarketPrice.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { PublicClient } from 'viem' -import { type MarketId, getChainIdAuctioneerMarketFromMarketId } from '..' -import { bondFixedTermSDAAbi } from '../abi' - -interface GetMarketsPrices { - client: PublicClient - marketIds: MarketId[] -} - -export function getMarketPricesContracts({ - marketIds, -}: { marketIds: MarketId[] }) { - return marketIds.map((marketId) => { - const { chainId, auctioneerAddress, marketNumber } = - getChainIdAuctioneerMarketFromMarketId(marketId) - - return { - abi: bondFixedTermSDAAbi, - chainId, - address: auctioneerAddress, - functionName: 'marketPrice' as const, - args: [marketNumber] as const, - } - }) -} - -export async function getMarketsPrices({ - client, - marketIds, -}: GetMarketsPrices) { - const result = await client.multicall({ - allowFailure: true, - contracts: getMarketPricesContracts({ marketIds }), - }) - - return result.flatMap((r, i) => - r.result - ? { - marketId: marketIds[i]!, - marketPrice: r.result, - } - : [], - ) -} - -interface GetMarketPrice { - client: PublicClient - marketId: MarketId -} - -export async function getMarketPrice({ client, marketId }: GetMarketPrice) { - return (await getMarketsPrices({ client, marketIds: [marketId] }))[0] -} diff --git a/packages/bonds-sdk/src/fetchers/getMaxAmountAccepted.ts b/packages/bonds-sdk/src/fetchers/getMaxAmountAccepted.ts deleted file mode 100644 index c56fe659eb..0000000000 --- a/packages/bonds-sdk/src/fetchers/getMaxAmountAccepted.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type { Address, PublicClient } from 'viem' -import { type MarketId, getChainIdAuctioneerMarketFromMarketId } from '..' -import { bondFixedTermSDAAbi } from '../abi' - -interface GetMaxAmountsAccepted { - client: PublicClient - marketIds: MarketId[] - referrer: Address -} - -export function getMaxAmountsAcceptedContracts({ - marketIds, - referrer, -}: Omit) { - return marketIds.map((marketId) => { - const { chainId, auctioneerAddress, marketNumber } = - getChainIdAuctioneerMarketFromMarketId(marketId) - - return { - abi: bondFixedTermSDAAbi, - chainId, - address: auctioneerAddress, - functionName: 'maxAmountAccepted' as const, - args: [marketNumber, referrer] as const, - } - }) -} - -export async function GetMaxAmountsAccepted({ - client, - marketIds, - referrer, -}: GetMaxAmountsAccepted) { - const result = await client.multicall({ - allowFailure: true, - contracts: getMaxAmountsAcceptedContracts({ marketIds, referrer }), - }) - - return result.flatMap((r, i) => - r.result - ? { - marketId: marketIds[i]!, - maxAmountAccepted: r.result, - } - : [], - ) -} - -interface GetMaxAmountAccepted { - client: PublicClient - marketId: MarketId - referrer: Address -} - -export async function getMaxAmountAccepted({ - client, - marketId, - referrer, -}: GetMaxAmountAccepted) { - return ( - await GetMaxAmountsAccepted({ client, marketIds: [marketId], referrer }) - )[0] -} diff --git a/packages/bonds-sdk/src/fetchers/getProtocolFees.ts b/packages/bonds-sdk/src/fetchers/getProtocolFees.ts deleted file mode 100644 index 6b56816f2d..0000000000 --- a/packages/bonds-sdk/src/fetchers/getProtocolFees.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { getChainIdAddressFromId } from 'sushi' -import type { PublicClient } from 'viem' -import { bondFixedTermTellerAbi } from '../abi' - -export function getProtocolFeesContracts({ - tellerIds, -}: { tellerIds: string[] }) { - return tellerIds.map((tellerId) => { - const { chainId, address } = getChainIdAddressFromId(tellerId) - - return { - abi: bondFixedTermTellerAbi, - chainId, - address: address, - functionName: 'protocolFee' as const, - } - }) -} - -interface GetProtocolFees { - client: PublicClient - tellerIds: string[] -} - -export async function getProtocolFees({ client, tellerIds }: GetProtocolFees) { - const result = await client.multicall({ - allowFailure: true, - contracts: getProtocolFeesContracts({ tellerIds }), - }) - - return result.flatMap((r, i) => - r.result - ? { - tellerId: tellerIds[i]!, - protocolFee: r.result, - } - : [], - ) -} - -interface GetProtocolFee { - client: PublicClient - tellerId: string -} - -export async function getProtocolFee({ client, tellerId }: GetProtocolFee) { - return (await getProtocolFees({ client, tellerIds: [tellerId] }))[0] -} diff --git a/packages/bonds-sdk/src/fetchers/getReferrerFees.ts b/packages/bonds-sdk/src/fetchers/getReferrerFees.ts deleted file mode 100644 index e6487d01f5..0000000000 --- a/packages/bonds-sdk/src/fetchers/getReferrerFees.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { getChainIdAddressFromId } from 'sushi' -import type { PublicClient } from 'viem' -import { bondFixedTermTellerAbi } from '../abi' - -type Args = { - referrerId: string - tellerId: string -} - -export function getReferrerFeesContracts({ args }: { args: Args[] }) { - return args.map(({ referrerId, tellerId }) => { - const { chainId, address: referrerAddress } = - getChainIdAddressFromId(referrerId) - const { address: tellerAddress } = getChainIdAddressFromId(tellerId) - - return { - abi: bondFixedTermTellerAbi, - chainId, - address: tellerAddress, - functionName: 'referrerFees' as const, - args: [referrerAddress] as const, - } - }) -} - -interface GetReferrerFees { - client: PublicClient - args: Args[] -} - -export async function getReferrerFees({ client, args }: GetReferrerFees) { - const result = await client.multicall({ - allowFailure: true, - contracts: getReferrerFeesContracts({ args }), - }) - - return result.flatMap((r, i) => - r.result - ? { - referrerId: args[i]!.referrerId, - tellerId: args[i]!.tellerId, - referrerFee: r.result, - } - : [], - ) -} - -interface GetReferrerFee { - client: PublicClient - arg: Args -} - -export async function getReferrerFee({ client, arg }: GetReferrerFee) { - return (await getReferrerFees({ client, args: [arg] }))[0] -} diff --git a/packages/bonds-sdk/src/fetchers/getRemainingCapacity.ts b/packages/bonds-sdk/src/fetchers/getRemainingCapacity.ts deleted file mode 100644 index 9db1c817fd..0000000000 --- a/packages/bonds-sdk/src/fetchers/getRemainingCapacity.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { PublicClient } from 'viem' -import { type MarketId, getChainIdAuctioneerMarketFromMarketId } from '..' -import { bondFixedTermSDAAbi } from '../abi' - -interface GetRemainingCapacities { - client: PublicClient - marketIds: MarketId[] -} - -export function getRemainingCapacitiesContracts({ - marketIds, -}: { marketIds: MarketId[] }) { - return marketIds.map((marketId) => { - const { chainId, auctioneerAddress, marketNumber } = - getChainIdAuctioneerMarketFromMarketId(marketId) - - return { - abi: bondFixedTermSDAAbi, - chainId, - address: auctioneerAddress, - functionName: 'currentCapacity' as const, - args: [marketNumber] as const, - } - }) -} - -export async function getRemainingCapacities({ - client, - marketIds, -}: GetRemainingCapacities) { - const result = await client.multicall({ - allowFailure: true, - contracts: getRemainingCapacitiesContracts({ marketIds }), - }) - - return result.flatMap((r, i) => - r.result - ? { - marketId: marketIds[i]!, - remainingCapacity: r.result, - } - : [], - ) -} - -interface GetRemainingCapacity { - client: PublicClient - marketId: MarketId -} - -export async function getRemainingCapacity({ - client, - marketId, -}: GetRemainingCapacity) { - return (await getRemainingCapacities({ client, marketIds: [marketId] }))[0] -} diff --git a/packages/bonds-sdk/src/fetchers/index.ts b/packages/bonds-sdk/src/fetchers/index.ts deleted file mode 100644 index 00222f7f5f..0000000000 --- a/packages/bonds-sdk/src/fetchers/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './getMarketPrice' -export * from './getRemainingCapacity' -export * from './getMarketInfo' -export * from './getMaxAmountAccepted' -export * from './getReferrerFees' -export * from './getProtocolFees' diff --git a/packages/bonds-sdk/src/index.ts b/packages/bonds-sdk/src/index.ts deleted file mode 100644 index f4ec8b6048..0000000000 --- a/packages/bonds-sdk/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './constants' -export * from './calc' -export * from './utils' -export * from './fetchers' diff --git a/packages/bonds-sdk/src/utils/index.ts b/packages/bonds-sdk/src/utils/index.ts deleted file mode 100644 index 13c67e31b4..0000000000 --- a/packages/bonds-sdk/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './marketId' diff --git a/packages/bonds-sdk/src/utils/marketId.ts b/packages/bonds-sdk/src/utils/marketId.ts deleted file mode 100644 index 031fa8a167..0000000000 --- a/packages/bonds-sdk/src/utils/marketId.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { unsanitize } from 'sushi/format' -import type { Address } from 'viem' -import type { BondChainId } from '..' - -export const getMarketIdFromChainIdAuctioneerMarket = ({ - chainId, - auctioneerAddress, - marketNumber, -}: { - chainId: BondChainId - auctioneerAddress: Address - marketNumber: bigint | number -}) => { - return `${chainId}:${auctioneerAddress}:${marketNumber}` as const -} - -export type MarketId = ReturnType - -export const getChainIdAuctioneerMarketFromMarketId = (marketId: string) => { - const [chainId, auctioneerAddress, marketNumber] = unsanitize(marketId).split( - ':', - ) as [string, Address, string] - - if (!chainId || !auctioneerAddress || !marketNumber) - throw new Error(`Invalid id: ${marketId}`) - - return { - chainId: Number(chainId) as BondChainId, - auctioneerAddress, - marketNumber: BigInt(marketNumber), - } -} diff --git a/packages/bonds-sdk/tsconfig.json b/packages/bonds-sdk/tsconfig.json deleted file mode 100644 index 6aedd25126..0000000000 --- a/packages/bonds-sdk/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/esm/tsconfig"], - "include": ["src"], - "exclude": ["node_modules", "dist", ".turbo"], - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src", - "declaration": true, - "resolveJsonModule": true, - "target": "ES2020" - } -} diff --git a/packages/client/package.json b/packages/client/package.json deleted file mode 100644 index 07012fbb3b..0000000000 --- a/packages/client/package.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "name": "@sushiswap/client", - "version": "0.0.0", - "private": true, - "description": "Sushi Client", - "keywords": [ - "sushi", - "client" - ], - "repository": { - "type": "git", - "url": "https://github.com/sushiswap/sushiswap.git", - "directory": "packages/client" - }, - "license": "MIT", - "author": "LufyCZ ", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "default": "./dist/index.js" - }, - "./hooks": { - "types": "./dist/hooks/index.d.ts", - "import": "./dist/hooks/index.js", - "default": "./dist/hooks/index.js" - }, - "./api": { - "types": "./dist/api/index.d.ts", - "import": "./dist/api/index.js", - "default": "./dist/api/index.js" - }, - "./package.json": "./package.json" - }, - "module": "./dist/index.js", - "source": "src/index.ts", - "types": "./dist/index.d.ts", - "typesVersions": { - "*": { - ".": [ - "src/index" - ], - "hooks": [ - "src/hooks/index" - ], - "api": [ - "src/api/index" - ] - } - }, - "typings": "dist/index.d.ts", - "files": [ - "dist/**" - ], - "scripts": { - "build": "tsc", - "check": "tsc --pretty --noEmit", - "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", - "dev": "tsc --watch", - "prepublishOnly": "pnpm build" - }, - "dependencies": { - "@sushiswap/bonds-sdk": "workspace:*", - "@sushiswap/database": "workspace:*", - "@sushiswap/graph-client": "workspace:*", - "@sushiswap/steer-sdk": "workspace:*", - "@whatwg-node/fetch": "0.8.4", - "deepmerge-ts": "^4.3.0", - "sushi": "4.0.5", - "tslib": "latest", - "viem": "2.21.4", - "zod": "3.23.8" - }, - "devDependencies": { - "@sushiswap/tokens-api": "workspace:*", - "@sushiswap/typescript-config": "workspace:*", - "@tsconfig/esm": "1.0.4", - "@tsconfig/strictest": "2.0.2", - "@types/node": "20", - "react": "18.2.0", - "swr": "2.1.5", - "tsup": "7.2.0", - "typescript": "5.5.4" - }, - "peerDependencies": { - "react": "*", - "sushi": "*", - "swr": "*" - }, - "peerDependenciesMeta": { - "react": { - "optional": true - }, - "sushi": { - "optional": true - }, - "swr": { - "optional": true - } - } -} diff --git a/packages/client/src/api/bonds/bond/index.ts b/packages/client/src/api/bonds/bond/index.ts deleted file mode 100644 index f83f834955..0000000000 --- a/packages/client/src/api/bonds/bond/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { getMarketIdFromChainIdAuctioneerMarket } from '@sushiswap/bonds-sdk' -import { getBondsFromSubgraph } from '..' -import { type BondApiSchema } from '../../../pure/bonds/bond/schema' -import { BondsApiSchema } from '../../../pure/bonds/bonds/schema' - -export async function getBondFromSubgraph(args: typeof BondApiSchema._output) { - const bondsArgs = BondsApiSchema.parse({ - ids: getMarketIdFromChainIdAuctioneerMarket(args.marketId), - chainIds: String(args.marketId.chainId), - anyIssuer: 'true', - onlyOpen: 'false', - }) - - const bond = (await getBondsFromSubgraph(bondsArgs))[0] - - return bond -} diff --git a/packages/client/src/api/bonds/bonds/index.ts b/packages/client/src/api/bonds/bonds/index.ts deleted file mode 100644 index 27f4f8180c..0000000000 --- a/packages/client/src/api/bonds/bonds/index.ts +++ /dev/null @@ -1,494 +0,0 @@ -import { - type BondChainId, - getBondDiscount, - getMarketIdFromChainIdAuctioneerMarket, - getMarketsPrices, -} from '@sushiswap/bonds-sdk' -import { createClient } from '@sushiswap/database' -import { - type GetBondMarkets, - getBondMarkets, -} from '@sushiswap/graph-client/bonds' -import { getTotalSupply, getVaultReserves } from '@sushiswap/steer-sdk' -import { - getChainIdAddressFromId, - getIdFromChainIdAddress, - isPromiseFulfilled, -} from 'sushi' -import { publicClientConfig } from 'sushi/config' -import { type Address, createPublicClient, getAddress } from 'viem' -import { type BondsApiSchema } from '../../../pure/bonds/bonds/schema' -import { type Pools, getPools } from '../../../pure/pools/pools/pools' -import { - type SteerVaults, - getSteerVaults, -} from '../../../pure/steer-vault/vaults/vaults' -import { convertAuctionTypes } from '../common' -import { getTokenPricesChainV2 } from '../price' -import { BondSchema } from '../schema' - -const isOpen = (start: bigint | null, end: bigint | null) => - (!start || Date.now() / 1000 > start) && end && Date.now() / 1000 < end - -async function getQuoteToken({ - bond, - prices, - pools, - vaults, -}: { - bond: (typeof BondSchema)['_output'] - prices: Awaited> - pools: Pools - vaults: SteerVaults -}) { - const quotePool = pools.find( - (p) => p.address === bond.quoteToken.address.toLowerCase(), - ) - - const base = { - ...bond.quoteToken, - id: getIdFromChainIdAddress(bond.chainId, bond.quoteToken.address), - decimals: Number(bond.quoteToken.decimals), - chainId: bond.chainId, - pool: undefined, - vault: undefined, - } - - if (quotePool) { - const priceUSD = - Number(quotePool.liquidityUSD) / - (Number(quotePool.liquidity) / 10 ** Number(bond.quoteToken.decimals)) - - return { - ...base, - priceUSD, - pool: { - poolId: quotePool.id, - token0: { - ...quotePool.token0, - address: quotePool.token0.address as Address, - chainId: bond.chainId, - }, - token1: { - ...quotePool.token1, - address: quotePool.token1.address as Address, - chainId: bond.chainId, - }, - liquidity: quotePool.liquidity, - liquidityUSD: Number(quotePool.liquidityUSD), - protocol: quotePool.protocol, - }, - } - } - - const quoteVault = vaults.find( - (v) => v.address === bond.quoteToken.address.toLowerCase(), - ) - - if (quoteVault) { - const client = createPublicClient( - publicClientConfig[bond.chainId as BondChainId], - ) - const vaultId = getIdFromChainIdAddress( - bond.chainId, - quoteVault.address as Address, - ) - - const [{ reserve0, reserve1 }, totalSupply] = await Promise.all([ - getVaultReserves({ client, vaultId }), - getTotalSupply({ client, vaultId }), - ]) - - const token0PriceUSD = prices[getAddress(quoteVault.token0.address)] - const token1PriceUSD = prices[getAddress(quoteVault.token1.address)] - - if (!token0PriceUSD || !token1PriceUSD) - throw new Error( - `Missing token prices for vaultId: ${vaultId} (${quoteVault.token0.address}, ${quoteVault.token1.address})`, - ) - - const reserve0USD = - (Number(reserve0) / 10 ** quoteVault.token0.decimals) * token0PriceUSD - const reserve1USD = - (Number(reserve1) / 10 ** quoteVault.token1.decimals) * token1PriceUSD - - const reserveUSD = reserve0USD + reserve1USD - - const priceUSD = reserveUSD / (Number(totalSupply) / 10 ** base.decimals) - - return { - ...base, - name: 'Smart Pool LP', - symbol: `${quoteVault.token0.symbol}/${quoteVault.token1.symbol}`, - priceUSD, - vault: { - id: vaultId, - poolId: quoteVault.pool.id, - token0: { - ...quoteVault.token0, - address: quoteVault.token0.address as Address, - chainId: bond.chainId, - priceUSD: token0PriceUSD, - }, - token1: { - ...quoteVault.token1, - address: quoteVault.token1.address as Address, - chainId: bond.chainId, - priceUSD: token1PriceUSD, - }, - }, - } - } - - const priceUSD = prices[getAddress(bond.quoteToken.address)] - - return { - ...base, - priceUSD, - } -} - -export async function getBondsFromSubgraph( - args: typeof BondsApiSchema._output, -) { - const auctioneers = - args.ids?.map(({ auctioneerAddress }) => auctioneerAddress) || null - const marketIdFilter = - args.ids?.map(({ marketNumber }) => String(marketNumber)) || null - - const auctionTypes = convertAuctionTypes(args.auctionTypes) - - const where: GetBondMarkets['where'] = { - type_in: auctionTypes, - } - - if (auctioneers) { - where.auctioneer_in = auctioneers - } - - if (marketIdFilter) { - where.marketId_in = marketIdFilter - } - - if (args.onlyOpen) { - where.hasClosed = false - } - - const client = await createClient() - const issuersP = client.bondIssuer - .findMany({ - select: { - name: true, - link: true, - ids: { - select: { - id: true, - }, - }, - }, - where: { - isApproved: true, - }, - cacheStrategy: { - swr: 900, - ttl: 300, - }, - }) - .then((d) => - d.map((issuer) => ({ ...issuer, ids: issuer.ids.map(({ id }) => id) })), - ) - - const bondDescriptionsP = client.bondMarket.findMany({ - select: { - id: true, - description: true, - }, - cacheStrategy: { - swr: 900, - ttl: 300, - }, - }) - - const bonds = await Promise.allSettled( - args.chainIds.map(async (chainId) => { - const [bonds, prices, issuers, bondDescriptions] = await Promise.all([ - getBondMarkets({ - chainId, - first: args.take, - where, - }), - getTokenPricesChainV2({ chainId }), - issuersP, - bondDescriptionsP, - ]) - - // Validate and parse the bonds - const bondsParsed = bonds - .map((bond) => BondSchema.safeParse(bond)) - .flatMap((bond) => { - if (!bond.success) { - console.error(bond.error) - return [] - } - return bond.data - }) - - // Filter the bonds based on the arguments - const bondsFiltered = bondsParsed.filter((bond) => { - if ( - !args.anyIssuer && - !issuers.some((issuer) => - issuer.ids.some((id) => { - const { chainId, address } = getChainIdAddressFromId(id) - return ( - chainId === bond.chainId && - address.toLowerCase() === bond.owner.toLowerCase() - ) - }), - ) - ) { - return false - } - - if (auctioneers && !auctioneers?.includes(bond.auctioneer)) { - return false - } - - if ( - marketIdFilter && - !marketIdFilter?.includes(String(bond.marketId)) - ) { - return false - } - - if (args.onlyOpen && !isOpen(bond.start, bond.conclusion)) { - return false - } - - return true - }) - - const marketIds = bondsFiltered.map((bond) => - getMarketIdFromChainIdAuctioneerMarket({ - chainId, - auctioneerAddress: bond.auctioneer, - marketNumber: bond.marketId, - }), - ) - - // const tellerIds = bondsFiltered.map((bond) => - // getIdFromChainIdAddress(chainId, bond.teller), - // ) - - const [poolsP, vaultsP] = (() => { - const quoteTokenIds = bondsFiltered.map((bond) => - getIdFromChainIdAddress(chainId, bond.quoteToken.address), - ) - - // No need to fetch if there are no bonds - if (quoteTokenIds.length === 0) return [[], []] - - return [ - getPools({ - chainIds: [chainId], - ids: quoteTokenIds, - }), - getSteerVaults({ - chainIds: [chainId], - ids: quoteTokenIds, - }), - ] - })() - - const [ - marketPricesS, - /*referrerFeesS, protocolFeesS, */ poolsS, - vaultsS, - ] = await Promise.allSettled([ - getMarketsPrices({ - client: createPublicClient( - publicClientConfig[chainId as BondChainId], - ), - marketIds, - }), - // getReferrerFees({ - // client: createPublicClient(config[chainId]), - // args: tellerIds.map((tellerId) => ({ - // referrerId: getIdFromChainIdAddress( - // chainId, - // REFERRER_ADDRESS[chainId], - // ), - // tellerId, - // })), - // }), - // getProtocolFees({ - // client: createPublicClient(config[chainId]), - // tellerIds, - // }), - poolsP, - vaultsP, - ]) - - if (!isPromiseFulfilled(marketPricesS)) - throw new Error(`Failed to fetch marketPrices on ${chainId}`) - - // if (!isPromiseFulfilled(referrerFeesS)) - // throw new Error(`Failed to fetch referrerFees on ${chainId}`) - - // if (!isPromiseFulfilled(protocolFeesS)) - // throw new Error(`Failed to fetch protocolFees on ${chainId}`) - - const marketPrices = marketPricesS.value - // const referrerFees = referrerFeesS.value - // const protocolFees = protocolFeesS.value - const pools = isPromiseFulfilled(poolsS) ? poolsS.value : [] - const vaults = isPromiseFulfilled(vaultsS) ? vaultsS.value : [] - - const processed = Promise.allSettled( - bondsFiltered.flatMap(async (bond, i) => { - const quoteToken = await getQuoteToken({ - bond, - prices, - pools, - vaults, - }) - - const payoutTokenPriceUSD = - prices[getAddress(bond.payoutToken.address)] - - const marketId = marketIds[i]! - const marketPrice = marketPrices.find( - (el) => el.marketId === marketId, - )?.marketPrice - - // const referrerFee = referrerFees.find( - // (el) => - // getChainIdAddressFromId(el.tellerId).address.toLowerCase() === - // bond.teller.toLowerCase(), - // ) - - // const protocolFee = protocolFees.find( - // (el) => - // getChainIdAddressFromId(el.tellerId).address.toLowerCase() === - // bond.teller.toLowerCase(), - // ) - - const description = - bondDescriptions.find((el) => el.id === marketId)?.description || - undefined - - const issuer = issuers.find((issuer) => - issuer.ids.some((id) => { - const { chainId, address } = getChainIdAddressFromId(id) - return ( - chainId === bond.chainId && - address.toLowerCase() === bond.owner.toLowerCase() - ) - }), - ) - - if ( - !quoteToken.priceUSD || - !payoutTokenPriceUSD || - !marketPrice || - !bond.scale /*|| - !referrerFee || - !protocolFee*/ - ) - return [] - - // const totalFee = - // (referrerFee.referrerFee + protocolFee.protocolFee) / FEE_DECIMALS - - const { discount, discountedPrice, quoteTokensPerPayoutToken } = - getBondDiscount({ - marketScale: bond.scale, - marketPrice: marketPrice, - payoutToken: { - priceUSD: payoutTokenPriceUSD, - decimals: Number(bond.payoutToken.decimals), - }, - quoteToken: { - priceUSD: quoteToken.priceUSD, - decimals: Number(bond.quoteToken.decimals), - }, - }) - - return { - id: marketId, - chainId, - - description, - - marketId: Number(bond.marketId), - auctionType: bond.type, - - tellerAddress: bond.teller, - auctioneerAddress: bond.auctioneer, - - isClosed: bond.hasClosed || !isOpen(bond.start, bond.conclusion), - start: Number(bond.start), - end: Number(bond.conclusion), - - marketScale: String(bond.scale), - discount, - - price: marketPrice ? String(marketPrice) : null, - minPrice: bond.minPrice ? String(bond.minPrice) : null, - - // totalFee, - - capacity: - Number(bond.capacity) / 10 ** Number(bond.payoutToken.decimals), - capacityInQuote: bond.capacityInQuote, - - vesting: Number(bond.vesting), - vestingType: bond.vestingType, - - issuerAddress: bond.owner, - issuer, - - quoteToken, - - payoutToken: { - ...bond.payoutToken, - id: getIdFromChainIdAddress(chainId, bond.payoutToken.address), - decimals: Number(bond.payoutToken.decimals), - chainId, - priceUSD: payoutTokenPriceUSD, - discountedPriceUSD: discountedPrice, - }, - - quoteTokensPerPayoutToken, - - totalBondedAmount: bond.totalBondedAmount, - totalPayoutAmount: bond.totalPayoutAmount, - } - }), - ) - - const processedAwaited = (await processed).flatMap((bond) => { - if (isPromiseFulfilled(bond)) return bond.value - console.error(bond.reason) - return [] - }) - - return processedAwaited.filter((bond) => { - if (typeof args.onlyDiscounted !== 'undefined') { - return args.onlyDiscounted ? bond.discount > 0 : true - } - - return true - }) - }), - ) - - await client.$disconnect() - - return bonds.flatMap((bond) => { - if (isPromiseFulfilled(bond)) return bond.value - - console.error(bond.reason) - return [] - }) -} diff --git a/packages/client/src/api/bonds/common.ts b/packages/client/src/api/bonds/common.ts deleted file mode 100644 index 434d1a6aed..0000000000 --- a/packages/client/src/api/bonds/common.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { AuctionType } from '@sushiswap/bonds-sdk' - -export const convertAuctionTypes = (auctionTypes: AuctionType[]) => { - const map = { - [AuctionType.Dynamic]: 'dynamic', - [AuctionType.Static]: 'static', - } as const - - return auctionTypes.map((type) => map[type]) -} diff --git a/packages/client/src/api/bonds/index.ts b/packages/client/src/api/bonds/index.ts deleted file mode 100644 index 6ae836d069..0000000000 --- a/packages/client/src/api/bonds/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './bond/index' -export * from './bonds/index' -export * from './positions/index' - -export { BondsApiSchema } from '../../pure/bonds/bonds/schema' -export { BondApiSchema } from '../../pure/bonds/bond/schema' -export { BondsPositionsApiSchema } from '../../pure/bonds/positions/schema' diff --git a/packages/client/src/api/bonds/positions/index.ts b/packages/client/src/api/bonds/positions/index.ts deleted file mode 100644 index c6d3b229cc..0000000000 --- a/packages/client/src/api/bonds/positions/index.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { type BondChainId, isBondChainId } from '@sushiswap/bonds-sdk' -import { - type GetBondUserPositions, - getBondUserPositions, -} from '@sushiswap/graph-client/bonds' -import { getChainIdAddressFromId, isPromiseFulfilled } from 'sushi' -import { getAddress } from 'viem' -import { type BondsPositionsApiSchema } from '../../../pure/bonds/positions/schema' -import { getTokenPricesChainV2 } from '../price' -import { BondPositionSchema } from '../schema' - -export async function getBondPositionsFromSubgraph( - args: typeof BondsPositionsApiSchema._output, -) { - let chainIds = args.chainIds - - let payoutTokenAddress = null - if (args.payoutTokenId) { - const { chainId, address } = getChainIdAddressFromId(args.payoutTokenId) - if (!isBondChainId(chainId)) throw new Error('Invalid payout token chain') - chainIds = [chainId] - payoutTokenAddress = address - } - - const where: GetBondUserPositions['where'] = { - owner_contains_nocase: args.userAddress, - } - - if (args.onlyUnclaimedBonds) { - where.balance_gt = '0' - } - - if (payoutTokenAddress) { - where.bondToken_ = { - underlying_contains_nocase: payoutTokenAddress, - } - } - - Object.entries(where!).map(([key, value]) => { - if (value === null) delete where[key as keyof typeof where] - }) - - const positions = await Promise.allSettled( - chainIds.map(async (chainId) => { - const positions = await getBondUserPositions({ - chainId, - where, - }) - const prices = await getTokenPricesChainV2({ chainId }) - - const positionsParsed = positions - .map((position) => BondPositionSchema.safeParse(position)) - .flatMap((position) => { - if (!position.success) { - console.log(position.error) - return [] - } - - return position.data - }) - - return positionsParsed.map((position) => { - const payoutTokenPriceUSD = - prices[getAddress(position.bondToken.underlying.address)] || 0 - const payoutToken = { - id: `${chainId}:${position.bondToken.underlying.address}`, - chainId, - ...position.bondToken.underlying, - decimals: Number(position.bondToken.underlying.decimals), - priceUSD: payoutTokenPriceUSD, - } - - return { - owner: position.owner, - chainId: position.chainId as BondChainId, - - balance: String(position.balance), - balanceUSD: - (Number(position.balance) / 10 ** payoutToken.decimals) * - payoutTokenPriceUSD, - - maturity: Number(position.bondToken.expiry), - tellerAddress: position.bondToken.teller, - - bondTokenId: position.bondToken.id, - - payoutToken, - } - }) - }), - ) - - return positions.filter(isPromiseFulfilled).flatMap((p) => p.value) -} diff --git a/packages/client/src/api/bonds/price.ts b/packages/client/src/api/bonds/price.ts deleted file mode 100644 index d75d4595ec..0000000000 --- a/packages/client/src/api/bonds/price.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ChainId } from 'sushi/chain' -import { EVM_APP_BASE_URL } from '../../constants' - -export async function getTokenPricesChainV1({ - chainId, -}: { - chainId: ChainId -}): Promise> { - return fetch(`${EVM_APP_BASE_URL}/api/price/v1/${chainId}`).then((res) => - res.json(), - ) -} - -export async function getTokenPricesChainV2({ - chainId, -}: { - chainId: ChainId -}): Promise> { - return fetch(`https://api.sushi.com/price/v1/${chainId}`) - .then((res) => res.json()) - .catch((e) => { - console.error('Error fetching token prices', chainId, e) - throw e - }) -} diff --git a/packages/client/src/api/bonds/schema.ts b/packages/client/src/api/bonds/schema.ts deleted file mode 100644 index d581a3ebfb..0000000000 --- a/packages/client/src/api/bonds/schema.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { AuctionType, VestingType } from '@sushiswap/bonds-sdk' -import { type Address, isAddress } from 'viem' -import { z } from 'zod' - -// Stolen from @sushiswap/rockset-client on the flair branch, TODO: move to a better place? -const chainId = () => z.coerce.number().int() - -const address = () => - z.string().transform((address) => { - if (!isAddress(address)) throw new Error('Invalid address') - - return address.toLowerCase() as Address - }) - -const bigint = () => z.string().transform((val) => BigInt(val)) - -const token = () => - z.object({ - address: address(), - name: z.string(), - symbol: z.string(), - decimals: bigint(), - }) - -const auctionTypes: Record = { - dynamic: AuctionType['Dynamic'], - static: AuctionType['Static'], - 'oracle-static': AuctionType['Static'], -} - -const vestingTypes: Record = { - 'fixed-term': VestingType['Fixed-Term'], -} - -// Graph object validation -export const BondSchema = z.object({ - id: z.string(), - chainId: chainId(), - type: z.string().transform((val) => { - if (!Object.keys(auctionTypes).includes(val)) - throw new Error('Invalid auction type') - - return auctionTypes[val]! - }), - auctioneer: address(), - teller: address(), - marketId: bigint(), - owner: address(), - capacity: bigint(), - capacityInQuote: z.boolean(), - hasClosed: z.boolean(), - start: bigint().nullable(), - conclusion: bigint().nullable(), - vesting: bigint(), - vestingType: z.string().transform((val) => { - if (!Object.keys(vestingTypes).includes(val)) - throw new Error('Invalid vesting type') - - return vestingTypes[val]! - }), - quoteToken: token(), - totalBondedAmount: z.coerce.number(), - payoutToken: token(), - totalPayoutAmount: z.coerce.number(), - minPrice: bigint().nullable(), - scale: bigint().nullable(), - averageBondPrice: z.coerce.number(), - bondsIssued: bigint(), -}) - -export const BondPositionSchema = z.object({ - owner: address(), - chainId: chainId(), - - balance: bigint(), - - bondToken: z.object({ - id: z.string(), - expiry: bigint(), - type: z.string(), - teller: z.string(), - underlying: token(), - }), -}) diff --git a/packages/client/src/api/index.ts b/packages/client/src/api/index.ts deleted file mode 100644 index 9cdf466534..0000000000 --- a/packages/client/src/api/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './bonds' -export * from './pools' -export * from './steer-vault' diff --git a/packages/client/src/api/pools/count.ts b/packages/client/src/api/pools/count.ts deleted file mode 100644 index 289eebebec..0000000000 --- a/packages/client/src/api/pools/count.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { type Prisma, createClient } from '@sushiswap/database' -import { type PoolCountApiSchema } from '../../pure/pools/count/schema' -import { parsePoolArgs } from './parse' - -export async function getPoolCountFromDB( - args: typeof PoolCountApiSchema._output, -) { - const where: Prisma.SushiPoolWhereInput = parsePoolArgs(args) - - const client = await createClient() - const count = await client.sushiPool.count({ - where, - }) - - await client.$disconnect() - return { count } -} diff --git a/packages/client/src/api/pools/index.ts b/packages/client/src/api/pools/index.ts deleted file mode 100644 index dcfd2629ea..0000000000 --- a/packages/client/src/api/pools/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './count' -export * from './pool' -export * from './pools/index' - -export { PoolCountApiSchema } from '../../pure/pools/count/schema' -export { PoolApiSchema } from '../../pure/pools/pool/schema' -export { PoolsApiSchema } from '../../pure/pools/pools/schema' diff --git a/packages/client/src/api/pools/parse.ts b/packages/client/src/api/pools/parse.ts deleted file mode 100644 index 51372b9c78..0000000000 --- a/packages/client/src/api/pools/parse.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { type Prisma } from '@sushiswap/database' -import { deepmergeInto } from 'deepmerge-ts' -import { type PoolCountApiSchema } from '../../pure/pools/count/schema' -import { type PoolsApiSchema } from '../../pure/pools/pools/schema' - -export function parsePoolArgs( - args: typeof PoolsApiSchema._output | typeof PoolCountApiSchema._output, -) { - const where: NonNullable = {} - - const addFilter = (filter: typeof where) => deepmergeInto(where, filter) - - if ('ids' in args && args.ids !== undefined) { - addFilter({ - id: { - in: args.ids, - }, - }) - } - - if ('chainIds' in args && args.chainIds !== undefined) { - addFilter({ - chainId: { in: args.chainIds }, - }) - } - - if ('protocols' in args && args.protocols !== undefined) { - addFilter({ protocol: { in: args.protocols } }) - } - - if ( - 'isIncentivized' in args && - args.isIncentivized !== undefined && - args.isIncentivized - ) { - addFilter({ - isIncentivized: args.isIncentivized, - }) - } - - if ( - 'isWhitelisted' in args && - args.isWhitelisted !== undefined && - args.isWhitelisted - ) { - addFilter({ - token0: { - status: 'APPROVED', - }, - token1: { - status: 'APPROVED', - }, - }) - } - - if ( - 'isWhitelisted' in args && - args.isWhitelisted !== undefined && - !args.isWhitelisted - ) { - addFilter({ - OR: [ - { - token0: { - status: 'UNKNOWN', - }, - token1: { - status: 'UNKNOWN', - }, - }, - - { - token0: { - status: 'UNKNOWN', - }, - token1: { - status: 'APPROVED', - }, - }, - { - token0: { - status: 'APPROVED', - }, - token1: { - status: 'UNKNOWN', - }, - }, - ], - }) - } - - if ( - 'hasEnabledSteerVault' in args && - args.hasEnabledSteerVault !== undefined - ) { - addFilter({ - hasEnabledSteerVault: args.hasEnabledSteerVault, - }) - } - - if ('tokenSymbols' in args && Array.isArray(args.tokenSymbols)) { - if (args.tokenSymbols.length === 1) { - addFilter({ - OR: [ - { token0: { symbol: { contains: args.tokenSymbols[0] as string } } }, - { token1: { symbol: { contains: args.tokenSymbols[0] as string } } }, - ], - }) - } else { - // Create every possible set of two - const sets = args.tokenSymbols.flatMap((token0, i, arr) => - arr.slice(i + 1).map((token1) => [token0, token1] as const), - ) - addFilter({ - AND: [ - { - OR: sets.flatMap((set) => [ - { - token0: { symbol: { contains: set[0] } }, - token1: { symbol: { contains: set[1] } }, - }, - { - token0: { symbol: { contains: set[1] } }, - token1: { symbol: { contains: set[0] } }, - }, - ]), - }, - ], - }) - } - } - - return where -} diff --git a/packages/client/src/api/pools/pool.ts b/packages/client/src/api/pools/pool.ts deleted file mode 100644 index 5b7e6c0874..0000000000 --- a/packages/client/src/api/pools/pool.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type * as _ from '@prisma/client' - -import type { ID } from 'sushi/types' -import { type PoolApiSchema } from '../../pure/pools/pool/schema' -import { getPoolsFromDB } from './pools' -import { getUnindexedPool } from './unindexedPool' - -export async function getPoolFromDB(args: typeof PoolApiSchema._output) { - const id = `${args.chainId}:${args.address.toLowerCase()}` as ID - - let pool: Awaited>[0] | undefined = - undefined - - // Need to specify take, orderBy and orderDir to make TS happy - try { - const res = await getPoolsFromDB({ - ids: [id], - take: 1, - orderBy: 'liquidityUSD', - orderDir: 'desc', - }) - - if (res[0]) { - pool = res[0] - } - } catch (e) { - console.error(e) - } - - if (!pool) { - pool = (await getUnindexedPool(id)) as any - } - - if (!pool) { - throw new Error('Failed to fetch pool') - } - - return pool -} diff --git a/packages/client/src/api/pools/pools/index.ts b/packages/client/src/api/pools/pools/index.ts deleted file mode 100644 index 250e4a0857..0000000000 --- a/packages/client/src/api/pools/pools/index.ts +++ /dev/null @@ -1,218 +0,0 @@ -import { - type DecimalToString, - type Incentive as DbIncentive, - type Prisma, - Protocol, - createClient, -} from '@sushiswap/database' -import { isPromiseFulfilled } from 'sushi/validate' - -import type { PoolWithSteerVaults, SteerChainId } from '@sushiswap/steer-sdk' -import { withoutScientificNotation } from 'sushi' -import type { ChainId } from 'sushi/chain' -import { - type Address, - ChefType, - type ID, - type PoolBase, - type PoolHistory, - type PoolWithAprs, - type PoolWithIncentives, - RewarderType, - SushiSwapProtocol, -} from 'sushi/types' -import { type PoolsApiSchema } from '../../../pure/pools/pools/schema' -import { parsePoolArgs } from '../parse' -import { SushiPoolSelect } from './select' - -type Pools = PoolWithSteerVaults< - PoolWithAprs>> ->[] - -function translateProtocol(protocol: Protocol): SushiSwapProtocol { - switch (protocol) { - case Protocol.SUSHISWAP_V2: - return SushiSwapProtocol.SUSHISWAP_V2 - case Protocol.SUSHISWAP_V3: - return SushiSwapProtocol.SUSHISWAP_V3 - default: - throw new Error(`Unknown protocol: ${protocol}`) - } -} - -function translateRewarderType(type: DbIncentive['rewarderType']) { - switch (type) { - case 'Primary': - return RewarderType.Primary - case 'Secondary': - return RewarderType.Secondary - default: - throw new Error(`Unknown rewarder type: ${type}`) - } -} - -function translateChefType(type: DbIncentive['chefType']) { - switch (type) { - case 'MasterChefV1': - return ChefType.MasterChefV1 - case 'MasterChefV2': - return ChefType.MasterChefV2 - case 'MiniChef': - return ChefType.MiniChef - case 'Merkl': - return ChefType.Merkl - default: - throw new Error(`Unknown chef type: ${type}`) - } -} - -export async function getPoolsFromDB( - args: typeof PoolsApiSchema._output, -): Promise { - const take = args.take - const orderBy: Prisma.SushiPoolOrderByWithRelationInput = { - [args.orderBy]: args.orderDir, - } - const where: Prisma.SushiPoolWhereInput = parsePoolArgs(args) - - let skip = 0 - let cursor: { cursor: Prisma.SushiPoolWhereUniqueInput } | object = {} - - if (args.cursor) { - skip = 1 - cursor = { cursor: { id: args.cursor } } - } - - const client = await createClient() - const pools = await client.sushiPool.findMany({ - take, - skip, - ...cursor, - where, - orderBy, - select: SushiPoolSelect, - }) - - const poolsRetyped = pools as unknown as DecimalToString - const poolsTransformed = poolsRetyped.map((pool) => { - return { - id: pool.id as ID, - address: pool.address as Address, - chainId: pool.chainId as ChainId, - name: pool.name, - - swapFee: Number(pool.swapFee), - - token0: { - ...pool.token0, - id: pool.token0.id as ID, - address: pool.token0.address as Address, - chainId: pool.chainId as ChainId, - }, - token1: { - ...pool.token1, - id: pool.token1.id as ID, - address: pool.token1.address as Address, - chainId: pool.chainId as ChainId, - }, - - txCount: 0, - txCount1d: 0, - txCount1dChange: 0, - txCount1w: 0, - txCount1wChange: 0, - txCount1m: 0, - txCount1mChange: 0, - - feesUSD: Number(pool.feesUSD), - feesUSD1d: Number(pool.fees1d), - feesUSD1dChange: pool.feesChange1d, - feesUSD1w: Number(pool.fees1w), - feesUSD1wChange: pool.feesChange1w, - feesUSD1m: Number(pool.fees1m), - feesUSD1mChange: pool.feesChange1m, - - volumeUSD: Number(pool.volumeUSD), - volumeUSD1d: Number(pool.volume1d), - volumeUSD1dChange: pool.volumeChange1d, - volumeUSD1w: Number(pool.volume1w), - volumeUSD1wChange: pool.volumeChange1w, - volumeUSD1m: Number(pool.volume1m), - volumeUSD1mChange: pool.volumeChange1m, - - reserve0: BigInt(withoutScientificNotation(pool.reserve0)!), - reserve1: BigInt(withoutScientificNotation(pool.reserve1)!), - liquidity: BigInt(withoutScientificNotation(pool.totalSupply)!), - - liquidityUSD: Number(pool.liquidityUSD), - liquidityUSD1d: - Number(pool.liquidityUSD) + - pool.liquidityUSDChange1d * Number(pool.liquidityUSD), - liquidityUSD1dChange: pool.liquidityUSDChange1d, - liquidityUSD1wChange: pool.liquidityUSDChange1w, - liquidityUSD1mChange: pool.liquidityUSDChange1m, - - protocol: translateProtocol(pool.protocol), - - incentiveApr: pool.incentiveApr, - incentives: pool.incentives.map((incentive) => ({ - ...incentive, - id: incentive.id as ID, - rewarderAddress: incentive.rewarderAddress as Address, - rewarderType: translateRewarderType(incentive.rewarderType), - chefType: translateChefType(incentive.chefType), - chainId: pool.chainId as ChainId, - rewardToken: { - ...incentive.rewardToken, - id: incentive.rewardToken.id as ID, - address: incentive.rewardToken.address as Address, - chainId: pool.chainId as ChainId, - }, - })), - isIncentivized: pool.isIncentivized, - wasIncentivized: pool.wasIncentivized, - - hasEnabledSteerVault: pool.hasEnabledSteerVault, - hadEnabledSteerVault: pool.hadEnabledSteerVault, - steerVaults: pool.steerVaults.map((steerVault) => ({ - ...steerVault, - id: steerVault.id as ID, - address: steerVault.address as Address, - chainId: pool.chainId as SteerChainId, - })), - - feeApr1h: pool.feeApr1h, - feeApr1d: pool.feeApr1d, - feeApr1w: pool.feeApr1w, - feeApr1m: pool.feeApr1m, - - totalApr1h: pool.totalApr1h, - totalApr1d: pool.totalApr1d, - totalApr1w: pool.totalApr1w, - totalApr1m: pool.totalApr1m, - token0Price: Number(pool.token0Price), - token1Price: Number(pool.token1Price), - } - }) - - if (args.ids && args.ids.length > poolsTransformed.length) { - const fetchedPoolIds = poolsTransformed.map((pool) => pool.id) - const unfetchedPoolIds = args.ids.filter( - (id) => !fetchedPoolIds.includes(id), - ) - - const { getUnindexedPool } = await import('../unindexedPool') - - const unindexedPoolsResults = await Promise.allSettled( - unfetchedPoolIds.map((id) => getUnindexedPool(id)), - ) - const unindexedPools = unindexedPoolsResults.flatMap((res) => - isPromiseFulfilled(res) ? [res.value] : [], - ) - - poolsTransformed.push(...unindexedPools) - } - - await client.$disconnect() - return poolsTransformed -} diff --git a/packages/client/src/api/pools/pools/select.ts b/packages/client/src/api/pools/pools/select.ts deleted file mode 100644 index 86c05b6989..0000000000 --- a/packages/client/src/api/pools/pools/select.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { Prisma } from '@sushiswap/database' - -export const SushiPoolSelect = { - id: true, - address: true, - name: true, - chainId: true, - protocol: true, - swapFee: true, - totalSupply: true, - liquidityUSD: true, - reserve0: true, - reserve1: true, - token0Price: true, - token1Price: true, - volumeUSD: true, - feeApr1h: true, - feeApr1d: true, - feeApr1w: true, - feeApr1m: true, - totalApr1h: true, - totalApr1d: true, - totalApr1w: true, - totalApr1m: true, - incentiveApr: true, - isIncentivized: true, - wasIncentivized: true, - feesUSD: true, - fees1h: true, - fees1d: true, - fees1w: true, - fees1m: true, - feesChange1h: true, - feesChange1d: true, - feesChange1w: true, - feesChange1m: true, - volume1h: true, - volume1d: true, - volume1w: true, - volume1m: true, - volumeChange1h: true, - volumeChange1d: true, - volumeChange1w: true, - volumeChange1m: true, - liquidityUSDChange1h: true, - liquidityUSDChange1d: true, - liquidityUSDChange1w: true, - liquidityUSDChange1m: true, - isBlacklisted: true, - token0: { - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - }, - token1: { - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - }, - incentives: { - select: { - id: true, - pid: true, - chainId: true, - chefType: true, - apr: true, - rewarderAddress: true, - rewarderType: true, - rewardPerDay: true, - rewardToken: { - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - }, - }, - }, - hadEnabledSteerVault: true, - hasEnabledSteerVault: true, - steerVaults: { - select: { - id: true, - address: true, - chainId: true, - }, - }, -} as const satisfies Prisma.SushiPoolSelect diff --git a/packages/client/src/api/pools/unindexedPool.ts b/packages/client/src/api/pools/unindexedPool.ts deleted file mode 100644 index e0d7b1d9cb..0000000000 --- a/packages/client/src/api/pools/unindexedPool.ts +++ /dev/null @@ -1,262 +0,0 @@ -import { Protocol } from '@sushiswap/database' -import { publicClientConfig } from 'sushi/config' -import { type Address, type PublicClient, createPublicClient } from 'viem' - -import { - erc20Abi_decimals, - erc20Abi_name, - erc20Abi_symbol, - uniswapV2PairAbi_token0, - uniswapV2PairAbi_token1, - uniswapV2PairAbi_totalSupply, - v3baseAbi_fee, - v3baseAbi_liquidity, - v3baseAbi_token0, - v3baseAbi_token1, -} from 'sushi/abi' -import { getChainIdAddressFromId } from 'sushi/format' -import { type ID, SushiSwapProtocol } from 'sushi/types' -import type { getPoolFromDB } from './pool' - -interface GetPoolArgs { - client: PublicClient - address: Address - protocol?: Protocol -} - -interface Pool { - tokens: Address[] - totalSupply: string - swapFee: number - twapEnabled: boolean - protocol: Protocol -} - -async function getTokenInfo({ client, address }: GetPoolArgs) { - const [name, symbol, decimals] = await client.multicall({ - allowFailure: false, - contracts: [ - { - address: address, - abi: erc20Abi_name, - functionName: 'name', - }, - { - address: address, - abi: erc20Abi_symbol, - functionName: 'symbol', - }, - { - address: address, - abi: erc20Abi_decimals, - functionName: 'decimals', - }, - ], - }) - - return { address, name, symbol, decimals } -} - -async function getV2Pool({ client, address }: GetPoolArgs): Promise { - const [token0, token1, totalSupply] = await client.multicall({ - allowFailure: false, - contracts: [ - { - address: address, - abi: uniswapV2PairAbi_token0, - functionName: 'token0', - }, - { - address: address, - abi: uniswapV2PairAbi_token1, - functionName: 'token1', - }, - { - address: address, - abi: uniswapV2PairAbi_totalSupply, - functionName: 'totalSupply', - }, - ], - }) - - return { - tokens: [token0, token1], - totalSupply: totalSupply.toString(), - swapFee: 0.003, - twapEnabled: true, - protocol: Protocol.SUSHISWAP_V2, - } -} - -async function getV3Pool({ client, address }: GetPoolArgs): Promise { - const [token0, token1, liquidity, fee] = await client.multicall({ - allowFailure: false, - contracts: [ - { - address: address, - abi: v3baseAbi_token0, - functionName: 'token0', - }, - { - address: address, - abi: v3baseAbi_token1, - functionName: 'token1', - }, - { - address: address, - abi: v3baseAbi_liquidity, - functionName: 'liquidity', - }, - { - address: address, - abi: v3baseAbi_fee, - functionName: 'fee', - }, - ], - }) - return { - tokens: [token0, token1], - totalSupply: liquidity.toString(), - // 500 is 0.05%. divide it by 1M to get the 0.0005 format - swapFee: fee / 1_000_000, - twapEnabled: true, - protocol: Protocol.SUSHISWAP_V3, - } -} - -// Thought ReturnType would be enough, needed to wrap it to make TS happy -export async function getUnindexedPool( - poolId: ID, -): Promise>> { - const { chainId, address } = getChainIdAddressFromId(poolId) - - if (chainId in publicClientConfig === false) - throw new Error('Invalid chain id.') - - const cfg = publicClientConfig[chainId as keyof typeof publicClientConfig] - - const client = createPublicClient({ - chain: cfg.chain, - transport: cfg.transport, - }) as PublicClient - - if (!(await client.getBytecode({ address }))) { - throw new Error('Invalid pool address.') - } - - let lpTokenName: string - try { - const { name } = await getTokenInfo({ client, address }) - lpTokenName = name - } catch (_e) { - lpTokenName = 'V3' - } - - let poolFetcher: (args: GetPoolArgs) => Promise - switch (lpTokenName) { - case 'SushiSwap LP Token': - poolFetcher = getV2Pool - break - default: - poolFetcher = getV3Pool - } - - const pool = await poolFetcher({ client, address }) - - const tokens = await Promise.all( - pool.tokens.map((token) => getTokenInfo({ client, address: token })), - ) - - const poolName = tokens.map(({ symbol }) => symbol).join('-') - - const [token0, token1] = tokens as [ - (typeof tokens)[number], - (typeof tokens)[number], - ] - - return { - id: poolId, - address, - chainId, - name: poolName, - - swapFee: pool.swapFee, - - token0: { - id: `${chainId}:${token0.address.toLowerCase()}` as ID, - address: token0.address.toLowerCase() as Address, - chainId, - symbol: token0.symbol, - name: token0.name, - decimals: token0.decimals, - }, - token1: { - id: `${chainId}:${token1.address.toLowerCase()}` as ID, - address: token1.address.toLowerCase() as Address, - chainId, - symbol: token1.symbol, - name: token1.name, - decimals: token1.decimals, - }, - - txCount: 0, - txCount1d: 0, - txCount1dChange: 0, - txCount1w: 0, - txCount1wChange: 0, - txCount1m: 0, - txCount1mChange: 0, - - feesUSD: 0, - feesUSD1d: 0, - feesUSD1dChange: 0, - feesUSD1w: 0, - feesUSD1wChange: 0, - feesUSD1m: 0, - feesUSD1mChange: 0, - - volumeUSD: 0, - volumeUSD1d: 0, - volumeUSD1dChange: 0, - volumeUSD1w: 0, - volumeUSD1wChange: 0, - volumeUSD1m: 0, - volumeUSD1mChange: 0, - - reserve0: BigInt(0), - reserve1: BigInt(0), - liquidity: BigInt(pool.totalSupply), - - liquidityUSD: 0, - liquidityUSD1d: 0, - liquidityUSD1dChange: 0, - liquidityUSD1wChange: 0, - liquidityUSD1mChange: 0, - - protocol: - pool.protocol === 'SUSHISWAP_V2' - ? SushiSwapProtocol.SUSHISWAP_V2 - : SushiSwapProtocol.SUSHISWAP_V3, - - incentiveApr: 0, - incentives: [], - isIncentivized: false, - wasIncentivized: false, - - hasEnabledSteerVault: false, - hadEnabledSteerVault: false, - steerVaults: [], - - feeApr1h: 0, - feeApr1d: 0, - feeApr1w: 0, - feeApr1m: 0, - - totalApr1h: 0, - totalApr1d: 0, - totalApr1w: 0, - totalApr1m: 0, - token0Price: 0, - token1Price: 0, - } as Awaited> -} diff --git a/packages/client/src/api/steer-vault/count.ts b/packages/client/src/api/steer-vault/count.ts deleted file mode 100644 index ee6975c5a0..0000000000 --- a/packages/client/src/api/steer-vault/count.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { type Prisma, createClient } from '@sushiswap/database' -import { type SteerVaultCountApiSchema } from '../../pure/steer-vault/count/schema' -import { parseSteerArgs } from './parse' - -export async function getSteerVaultCountFromDB( - args: typeof SteerVaultCountApiSchema._output, -) { - const where: Prisma.SteerVaultWhereInput = parseSteerArgs(args) - - const client = await createClient() - const count = await client.steerVault.count({ - where, - }) - - await client.$disconnect() - return { count } -} diff --git a/packages/client/src/api/steer-vault/index.ts b/packages/client/src/api/steer-vault/index.ts deleted file mode 100644 index 87cbcba32f..0000000000 --- a/packages/client/src/api/steer-vault/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './count' -export * from './vault' -export * from './vaults' - -export * from '../../pure/steer-vault/count/schema' -export * from '../../pure/steer-vault/vault/schema' -export * from '../../pure/steer-vault/vaults/schema' diff --git a/packages/client/src/api/steer-vault/parse.ts b/packages/client/src/api/steer-vault/parse.ts deleted file mode 100644 index d8181e735c..0000000000 --- a/packages/client/src/api/steer-vault/parse.ts +++ /dev/null @@ -1,76 +0,0 @@ -import type { Prisma } from '@sushiswap/database' -import { deepmergeInto } from 'deepmerge-ts' -import { type SteerVaultCountApiSchema } from '../../pure/steer-vault/count/schema' -import { type SteerVaultsApiSchema } from '../../pure/steer-vault/vaults/schema' - -export function parseSteerArgs( - args: - | typeof SteerVaultsApiSchema._output - | typeof SteerVaultCountApiSchema._output, -) { - const where: NonNullable = {} - - const addFilter = (filter: typeof where) => deepmergeInto(where, filter) - - if ('ids' in args && args.ids !== undefined) { - addFilter({ - id: { - in: args.ids, - }, - }) - } - - if ('chainIds' in args && args.chainIds !== undefined) { - addFilter({ - chainId: { in: args.chainIds }, - }) - } - - if ('onlyEnabled' in args && args.onlyEnabled === true) { - addFilter({ - isEnabled: true, - }) - } - - if ('tokenSymbols' in args && Array.isArray(args.tokenSymbols)) { - if (args.tokenSymbols.length === 1) { - addFilter({ - OR: [ - { token0: { symbol: { contains: args.tokenSymbols[0] as string } } }, - { token1: { symbol: { contains: args.tokenSymbols[0] as string } } }, - ], - }) - } else { - // Create every possible set of two - const sets = args.tokenSymbols.flatMap((token0, i, arr) => - arr.slice(i + 1).map((token1) => [token0, token1] as const), - ) - addFilter({ - AND: [ - { - OR: sets.flatMap((set) => [ - { - token0: { symbol: { contains: set[0] } }, - token1: { symbol: { contains: set[1] } }, - }, - { - token0: { symbol: { contains: set[1] } }, - token1: { symbol: { contains: set[0] } }, - }, - ]), - }, - ], - }) - } - } - - if ('poolId' in args && args.poolId !== undefined) { - addFilter({ - pool: { - id: args.poolId, - }, - }) - } - - return where -} diff --git a/packages/client/src/api/steer-vault/vault.ts b/packages/client/src/api/steer-vault/vault.ts deleted file mode 100644 index c2f15d8c52..0000000000 --- a/packages/client/src/api/steer-vault/vault.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type * as _ from '@prisma/client' - -import type { ID } from 'sushi/types' -import { type SteerVaultApiSchema } from '../../pure/steer-vault/vault/schema' -import { getSteerVaultsFromDB } from './vaults' - -export async function getSteerVaultFromDB( - args: typeof SteerVaultApiSchema._output, -) { - const id = `${args.chainId}:${args.address.toLowerCase()}` as ID - - // Need to specify take, orderBy and orderDir to make TS happy - const [vault]: Awaited> = - await getSteerVaultsFromDB({ - ids: [id], - take: 1, - orderBy: 'reserveUSD', - orderDir: 'desc', - }) - - if (!vault) throw new Error('Vault not found.') - - return vault -} diff --git a/packages/client/src/api/steer-vault/vaults.ts b/packages/client/src/api/steer-vault/vaults.ts deleted file mode 100644 index 0110305171..0000000000 --- a/packages/client/src/api/steer-vault/vaults.ts +++ /dev/null @@ -1,269 +0,0 @@ -import { - type DecimalToString, - type Prisma, - createClient, -} from '@sushiswap/database' -import type { - SteerChainId, - SteerVault, - SteerVaultWithPool, -} from '@sushiswap/steer-sdk' -import type { SushiSwapV3ChainId } from 'sushi/config' -import type { - Address, - ID, - PoolBase, - PoolHistory1D, - PoolId, - PoolIfIncentivized, - PoolSwapFee, - PoolWithAprs, - SushiSwapV3Protocol, -} from 'sushi/types' -import { type SteerVaultsApiSchema } from '../../pure/steer-vault/vaults/schema' -import { parseSteerArgs } from './parse' - -type Vaults = SteerVaultWithPool< - SteerVault, - PoolWithAprs< - PoolHistory1D< - PoolSwapFee>> - > - > ->[] - -export async function getSteerVaultsFromDB( - args: typeof SteerVaultsApiSchema._output, -): Promise { - let take = 9999 - if ('take' in args) { - take = args.take - } - - let orderBy: Prisma.SteerVaultOrderByWithRelationInput = {} - - if ('orderBy' in args) { - orderBy = { [args.orderBy]: args.orderDir } - } - - const where: Prisma.SteerVaultWhereInput = parseSteerArgs(args) - - let skip = 0 - let cursor: { cursor: Prisma.SteerVaultWhereUniqueInput } | object = {} - - if ('cursor' in args) { - skip = 1 - cursor = { cursor: { id: args.cursor } } - } - - const client = await createClient() - const vaults = await client.steerVault.findMany({ - take, - skip, - ...cursor, - where, - orderBy, - select: { - id: true, - address: true, - chainId: true, - - pool: { - select: { - id: true, - address: true, - chainId: true, - protocol: true, - - swapFee: true, - - liquidityUSD: true, - - liquidityUSDChange1d: true, - volume1d: true, - volumeChange1d: true, - fees1d: true, - feesChange1d: true, - - incentiveApr: true, - isIncentivized: true, - wasIncentivized: true, - - feeApr1h: true, - feeApr1d: true, - feeApr1w: true, - feeApr1m: true, - - totalApr1h: true, - totalApr1d: true, - totalApr1w: true, - totalApr1m: true, - }, - }, - feeTier: true, - - apr: true, - apr1d: true, - apr1w: true, - // apr1m: true, - // apr1y: true, - - token0: { - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - }, - reserve0: true, - reserve0USD: true, - fees0: true, - fees0USD: true, - - token1: { - select: { - id: true, - address: true, - name: true, - symbol: true, - decimals: true, - }, - }, - reserve1: true, - reserve1USD: true, - fees1: true, - fees1USD: true, - - reserveUSD: true, - feesUSD: true, - - strategy: true, - payloadHash: true, - // description: true, - // state: true - - performanceFee: true, - - lowerTick: true, - upperTick: true, - - adjustmentFrequency: true, - lastAdjustmentTimestamp: true, - - isEnabled: true, - wasEnabled: true, - isDeprecated: true, - - creator: true, - admin: true, - manager: true, - }, - }) - - const vaultsRetyped = vaults as unknown as DecimalToString - const vaultsTransformed = vaultsRetyped.map((vault) => ({ - id: vault.id as ID, - address: vault.address as Address, - chainId: vault.chainId as SteerChainId, - - pool: { - id: vault.pool.id as ID, - address: vault.pool.address as Address, - chainId: vault.pool.chainId as SushiSwapV3ChainId, - protocol: vault.pool.protocol as SushiSwapV3Protocol, - - liquidityUSD: Number(vault.pool.liquidityUSD), - - liquidityUSD1dChange: vault.pool.liquidityUSDChange1d, - - volumeUSD1d: Number(vault.pool.volume1d), - volumeUSD1dChange: vault.pool.volumeChange1d, - - feesUSD1d: Number(vault.pool.fees1d), - feesUSD1dChange: vault.pool.feesChange1d, - - txCount1d: 0, - txCount1dChange: 0, - - incentiveApr: vault.pool.incentiveApr, - isIncentivized: vault.pool.isIncentivized, - wasIncentivized: vault.pool.wasIncentivized, - - feeApr1h: vault.pool.feeApr1h, - feeApr1d: vault.pool.feeApr1d, - feeApr1w: vault.pool.feeApr1w, - feeApr1m: vault.pool.feeApr1m, - - totalApr1h: vault.pool.totalApr1h, - totalApr1d: vault.pool.totalApr1d, - totalApr1w: vault.pool.totalApr1w, - totalApr1m: vault.pool.totalApr1m, - - swapFee: Number(vault.pool.swapFee), - }, - - feeTier: vault.feeTier, - - apr: Number(vault.apr), - apr1d: Number(vault.apr1d), - apr1w: Number(vault.apr1w), - // apr1m: Number(vault.apr1m), - // apr1y: Number(vault.apr1y), - - token0: { - id: vault.token0.id as ID, - address: vault.token0.address as Address, - chainId: vault.pool.chainId as SushiSwapV3ChainId, - name: vault.token0.name, - symbol: vault.token0.symbol, - decimals: vault.token0.decimals, - }, - reserve0: BigInt(vault.reserve0), - reserve0USD: Number(vault.reserve0USD), - fees0: BigInt(vault.fees0), - fees0USD: Number(vault.fees0USD), - - token1: { - id: vault.token1.id as ID, - address: vault.token1.address as Address, - chainId: vault.pool.chainId as SushiSwapV3ChainId, - name: vault.token1.name, - symbol: vault.token1.symbol, - decimals: vault.token1.decimals, - }, - reserve1: BigInt(vault.reserve1), - reserve1USD: Number(vault.reserve1USD), - fees1: BigInt(vault.fees1), - fees1USD: Number(vault.fees1USD), - - reserveUSD: Number(vault.reserveUSD), - feesUSD: Number(vault.feesUSD), - - strategy: vault.strategy as any, - description: '', - payloadHash: vault.payloadHash, - // description: vault.description, - // state: vault.state - - performanceFee: vault.performanceFee, - - lowerTick: vault.lowerTick, - upperTick: vault.upperTick, - - adjustmentFrequency: vault.adjustmentFrequency, - lastAdjustmentTimestamp: vault.lastAdjustmentTimestamp, - - isEnabled: vault.isEnabled, - wasEnabled: vault.wasEnabled, - isDeprecated: vault.isDeprecated, - - creator: vault.creator, - admin: vault.admin, - manager: vault.manager, - })) - - await client.$disconnect() - return vaultsTransformed -} diff --git a/packages/client/src/constants.ts b/packages/client/src/constants.ts deleted file mode 100644 index 1129e5b837..0000000000 --- a/packages/client/src/constants.ts +++ /dev/null @@ -1,15 +0,0 @@ -export const EVM_APP_BASE_URL = - process.env['NEXT_PUBLIC_EVM_APP_BASE_URL'] || - (process.env['NEXT_PUBLIC_VERCEL_URL'] - ? `https://${process.env['NEXT_PUBLIC_VERCEL_URL']}` - : 'http://localhost:3000') - -export const TOKEN_PRICE_API = - process.env['TOKEN_PRICES_API_V0_BASE_URL'] || - process.env['NEXT_PUBLIC_TOKEN_PRICES_API_V0_BASE_URL'] || - '/api/price' - -export const TOKENS_API = - process.env['TOKENS_API_V0_BASE_URL'] || - process.env['NEXT_PUBLIC_TOKENS_API_V0_BASE_URL'] || - 'https://tokens.sushi.com' diff --git a/packages/client/src/functions.ts b/packages/client/src/functions.ts deleted file mode 100644 index b80d48a7d0..0000000000 --- a/packages/client/src/functions.ts +++ /dev/null @@ -1,36 +0,0 @@ -export function parseArgs(args?: Partial) { - if (!args) return '' - return Object.entries(args) - .sort(([key1], [key2]) => key1.localeCompare(key2)) - .reduce((acc, [key, value]) => { - if (value === undefined || value === null) return acc - if (Array.isArray(value) && value.length === 0) return acc - const param = `${key}=${Array.isArray(value) ? value.join(',') : value}` - if (acc === '?') { - return `${acc}${param}` - } else { - return `${acc}&${param}` - } - }, '?') -} - -function jsonParse(text: string): T { - return JSON.parse(text, (_key: string, value: any) => { - if (value && typeof value === 'object' && value.__type === 'bigint') { - value = BigInt(value.value) - } - return value - }) -} - -export async function get(url: string): Promise { - const res = await fetch(url) - - if (!res.ok) { - throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`) - } - - const text = await res.text() - - return jsonParse(text) -} diff --git a/packages/client/src/hooks/bonds/bond.ts b/packages/client/src/hooks/bonds/bond.ts deleted file mode 100644 index 61b6668f51..0000000000 --- a/packages/client/src/hooks/bonds/bond.ts +++ /dev/null @@ -1,15 +0,0 @@ -import useSWR from 'swr' - -import { - type Bond, - type GetBondArgs, - getBondUrl, -} from '../../pure/bonds/bond/bond' -import { type SWRHookConfig } from '../../types' - -export const useBond = ({ args, shouldFetch }: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getBondUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/bonds/bonds.ts b/packages/client/src/hooks/bonds/bonds.ts deleted file mode 100644 index ae13adcfc9..0000000000 --- a/packages/client/src/hooks/bonds/bonds.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type Bonds, - type GetBondsArgs, - getBondsUrl, -} from '../../pure/bonds/bonds/bonds' -import { type SWRHookConfig } from '../../types' - -export const useBonds = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getBondsUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/bonds/index.ts b/packages/client/src/hooks/bonds/index.ts deleted file mode 100644 index 821e2d8d5f..0000000000 --- a/packages/client/src/hooks/bonds/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './bond' -export * from './bonds' diff --git a/packages/client/src/hooks/index.ts b/packages/client/src/hooks/index.ts deleted file mode 100644 index 2a6c894b60..0000000000 --- a/packages/client/src/hooks/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -'use client' - -export * from './bonds/index.js' -export * from './pools/index.js' -export * from './steer-vault/index.js' -export * from './tokens/index.js' diff --git a/packages/client/src/hooks/pools/count.ts b/packages/client/src/hooks/pools/count.ts deleted file mode 100644 index 64a4d5b763..0000000000 --- a/packages/client/src/hooks/pools/count.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { default as useSWR } from 'swr' - -import { - type GetPoolCountArgs, - type PoolCount, - getPoolCountUrl, -} from '../../pure/pools/count/count' -import { type SWRHookConfig } from '../../types.js' - -export const usePoolCount = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getPoolCountUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/pools/index.ts b/packages/client/src/hooks/pools/index.ts deleted file mode 100644 index 8639e24824..0000000000 --- a/packages/client/src/hooks/pools/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './count' -export * from './pool' -export * from './pools' -export { ChefType, Protocol, RewarderType } from '@sushiswap/database' diff --git a/packages/client/src/hooks/pools/pool.ts b/packages/client/src/hooks/pools/pool.ts deleted file mode 100644 index 3ef734cadb..0000000000 --- a/packages/client/src/hooks/pools/pool.ts +++ /dev/null @@ -1,15 +0,0 @@ -import useSWR from 'swr' - -import { - type GetPoolArgs, - type Pool, - getPoolUrl, -} from '../../pure/pools/pool/pool' -import { type SWRHookConfig } from '../../types' - -export const usePool = ({ args, shouldFetch }: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getPoolUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/pools/pools.ts b/packages/client/src/hooks/pools/pools.ts deleted file mode 100644 index fea46056a5..0000000000 --- a/packages/client/src/hooks/pools/pools.ts +++ /dev/null @@ -1,39 +0,0 @@ -import useSWR from 'swr' -import useSWRInfinite from 'swr/infinite' - -import { - type GetPoolsArgs, - type Pools, - getPoolsUrl, -} from '../../pure/pools/pools/pools' -import { type InfiniteSWRHookConfig, type SWRHookConfig } from '../../types' - -export const usePools = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getPoolsUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} -export const usePoolsInfinite = ({ - args, - shouldFetch, -}: InfiniteSWRHookConfig) => { - return useSWRInfinite( - (pageIndex, previousData) => { - if (shouldFetch === false) return null - - // first page, we don't have `previousPageData` - if (pageIndex === 0) return getPoolsUrl(args) - - // add the cursor to the API endpoint - return getPoolsUrl({ - ...args, - cursor: previousData?.[previousData.length - 1]?.id, - }) - }, - (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/steer-vault/count.ts b/packages/client/src/hooks/steer-vault/count.ts deleted file mode 100644 index c2c4c5dc9a..0000000000 --- a/packages/client/src/hooks/steer-vault/count.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetSteerVaultCountArgs, - type SteerVaultCount, - getSteerVaultCountUrl, -} from '../../pure/steer-vault/count/count' -import { type SWRHookConfig } from '../../types' - -export const useSteerVaultCount = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getSteerVaultCountUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/steer-vault/index.ts b/packages/client/src/hooks/steer-vault/index.ts deleted file mode 100644 index f390259b92..0000000000 --- a/packages/client/src/hooks/steer-vault/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './count' -export * from './vault' -export * from './vaults' diff --git a/packages/client/src/hooks/steer-vault/vault.ts b/packages/client/src/hooks/steer-vault/vault.ts deleted file mode 100644 index f98d6a847d..0000000000 --- a/packages/client/src/hooks/steer-vault/vault.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetSteerVaultArgs, - type SteerVault, - getSteerVaultUrl, -} from '../../pure/steer-vault/vault/vault' -import { type SWRHookConfig } from '../../types' - -export const useSteerVault = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getSteerVaultUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/steer-vault/vaults.ts b/packages/client/src/hooks/steer-vault/vaults.ts deleted file mode 100644 index e26731330c..0000000000 --- a/packages/client/src/hooks/steer-vault/vaults.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetSteerVaultsArgs, - type SteerVaults, - getSteerVaultsUrl, -} from '../../pure/steer-vault/vaults/vaults' -import { type SWRHookConfig } from '../../types' - -export const useSteerVaults = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getSteerVaultsUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/chainId/address.ts b/packages/client/src/hooks/tokens/chainId/address.ts deleted file mode 100644 index fae803db44..0000000000 --- a/packages/client/src/hooks/tokens/chainId/address.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetTokenArgs, - type Token, - getTokenUrl, -} from '../../../pure/tokens/chainId/address.js' -import { type SWRHookConfig } from '../../../types.js' - -export const useToken = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getTokenUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/chainId/addresses.ts b/packages/client/src/hooks/tokens/chainId/addresses.ts deleted file mode 100644 index 5a8cefc8fe..0000000000 --- a/packages/client/src/hooks/tokens/chainId/addresses.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetTokenAddressesArgs, - type TokenAddress, - getTokenAddressesUrl, -} from '../../../pure/tokens/chainId/addresses.js' -import { type SWRHookConfig } from '../../../types.js' - -export const useTokenAddresses = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getTokenAddressesUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/chainId/common.ts b/packages/client/src/hooks/tokens/chainId/common.ts deleted file mode 100644 index a5e41389ba..0000000000 --- a/packages/client/src/hooks/tokens/chainId/common.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type CommonToken, - type GetCommonTokensArgs, - getCommonTokensUrl, -} from '../../../pure/tokens/chainId/common.js' -import { type SWRHookConfig } from '../../../types.js' - -export const useCommonTokens = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getCommonTokensUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/chainId/ids.ts b/packages/client/src/hooks/tokens/chainId/ids.ts deleted file mode 100644 index cecaaf2654..0000000000 --- a/packages/client/src/hooks/tokens/chainId/ids.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetTokenIdsArgs, - type TokenId, - getTokenIdsUrl, -} from '../../../pure/tokens/chainId/ids.js' -import { type SWRHookConfig } from '../../../types.js' - -export const useTokenIds = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getTokenIdsUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/chainId/index.ts b/packages/client/src/hooks/tokens/chainId/index.ts deleted file mode 100644 index ff2531fa71..0000000000 --- a/packages/client/src/hooks/tokens/chainId/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './address.js' -export * from './addresses.js' -export * from './common.js' -export * from './ids.js' -export * from './popular.js' diff --git a/packages/client/src/hooks/tokens/chainId/popular.ts b/packages/client/src/hooks/tokens/chainId/popular.ts deleted file mode 100644 index d0025321e1..0000000000 --- a/packages/client/src/hooks/tokens/chainId/popular.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetPopularTokensArgs, - type PopularToken, - getPopularTokensUrl, -} from '../../../pure/tokens/chainId/popular.js' -import { type SWRHookConfig } from '../../../types.js' - -export const usePopularTokens = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getPopularTokensUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/index.ts b/packages/client/src/hooks/tokens/index.ts deleted file mode 100644 index b069f7d142..0000000000 --- a/packages/client/src/hooks/tokens/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import useSWR from 'swr' - -import { - type GetTokensArgs, - type Token, - getTokensUrl, -} from '../../pure/tokens/index.js' -import { type SWRHookConfig } from '../../types.js' - -export const useTokens = ({ - /*args,*/ shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getTokensUrl(/*args*/) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} - -export * from './chainId/index.js' -export * from './search/index.js' diff --git a/packages/client/src/hooks/tokens/search/address.ts b/packages/client/src/hooks/tokens/search/address.ts deleted file mode 100644 index dd59d2c087..0000000000 --- a/packages/client/src/hooks/tokens/search/address.ts +++ /dev/null @@ -1,18 +0,0 @@ -import useSWR from 'swr' - -import { - type GetTokenSearchsArgs, - type TokenSearch, - getSearchTokensUrl, -} from '../../../pure/tokens/search/address.js' -import { type SWRHookConfig } from '../../../types.js' - -export const useSearchTokens = ({ - args, - shouldFetch, -}: SWRHookConfig) => { - return useSWR( - shouldFetch !== false ? getSearchTokensUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) -} diff --git a/packages/client/src/hooks/tokens/search/index.ts b/packages/client/src/hooks/tokens/search/index.ts deleted file mode 100644 index 1451c145f1..0000000000 --- a/packages/client/src/hooks/tokens/search/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './address.js' diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts deleted file mode 100644 index 9d8e4ace54..0000000000 --- a/packages/client/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './constants.js' -export * from './functions.js' -export * from './pure/index.js' -export type * from './types.js' diff --git a/packages/client/src/pure/bonds/bond/bond.ts b/packages/client/src/pure/bonds/bond/bond.ts deleted file mode 100644 index 48a1952312..0000000000 --- a/packages/client/src/pure/bonds/bond/bond.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { MarketId } from '@sushiswap/bonds-sdk' -import { type getBondFromSubgraph } from '../../../api/bonds/bond' -import { EVM_APP_BASE_URL } from '../../../constants' -import { get } from '../../../functions' -import { type BondApiSchema } from './schema' - -export { type BondApiSchema } -export type Bond = NonNullable>> -export type GetBondArgs = { marketId: MarketId } - -export const getBondUrl = (args: GetBondArgs) => { - return `${EVM_APP_BASE_URL}/bonds/api/v1/bonds/${args.marketId}` -} - -export const getBond = async (args: GetBondArgs): Promise => { - return get(getBondUrl(args)) -} diff --git a/packages/client/src/pure/bonds/bond/schema.ts b/packages/client/src/pure/bonds/bond/schema.ts deleted file mode 100644 index 4a60a7f0a3..0000000000 --- a/packages/client/src/pure/bonds/bond/schema.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { getChainIdAuctioneerMarketFromMarketId } from '@sushiswap/bonds-sdk' -import { z } from 'zod' - -export const BondApiSchema = z.object({ - marketId: z.string().transform(getChainIdAuctioneerMarketFromMarketId), -}) diff --git a/packages/client/src/pure/bonds/bonds/bonds.ts b/packages/client/src/pure/bonds/bonds/bonds.ts deleted file mode 100644 index 9225a861e7..0000000000 --- a/packages/client/src/pure/bonds/bonds/bonds.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { type getBondsFromSubgraph } from '../../../api/bonds/bonds/' -import { EVM_APP_BASE_URL } from '../../../constants' -import { get, parseArgs } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type BondsApiSchema } from './schema' - -export { type BondsApiSchema } -export type Bonds = Awaited> -export type GetBondsArgs = - | GetApiInputFromOutput< - (typeof BondsApiSchema)['_input'], - (typeof BondsApiSchema)['_output'] - > - | undefined - -export const getBondsUrl = (args?: GetBondsArgs) => { - return `${EVM_APP_BASE_URL}/bonds/api/v1/bonds${parseArgs(args)}` -} - -export const getBonds = async (args?: GetBondsArgs): Promise => { - return get(getBondsUrl(args)) -} diff --git a/packages/client/src/pure/bonds/bonds/schema.ts b/packages/client/src/pure/bonds/bonds/schema.ts deleted file mode 100644 index d5d20940b1..0000000000 --- a/packages/client/src/pure/bonds/bonds/schema.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { - AuctionType, - AuctionTypes, - BONDS_ENABLED_CHAIN_IDS, - getChainIdAuctioneerMarketFromMarketId, - isBondChainId, -} from '@sushiswap/bonds-sdk' -import type { ChainId } from 'sushi/chain' -import { z } from 'zod' - -export const BondsApiSchema = z.object({ - take: z.coerce.number().int().lte(1000).default(1000), - ids: z - .string() - .transform((ids) => - ids - ?.split(',') - .map((id) => getChainIdAuctioneerMarketFromMarketId(id.toLowerCase())), - ) - .optional(), - chainIds: z - .string() - .optional() - .default(BONDS_ENABLED_CHAIN_IDS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) - .transform((chainIds) => chainIds.filter(isBondChainId)), - issuerNames: z - .string() - .transform((names) => names?.split(',')) - .optional(), - anyIssuer: z.coerce - .string() - .optional() - .default('false') - .refine((val) => ['true', 'false'].includes(val), { - message: 'anyIssuer must true or false', - }) - .transform((val) => val === 'true'), - onlyOpen: z.coerce - .string() - .optional() - .default('true') - .refine((val) => ['true', 'false'].includes(val), { - message: 'onlyOpen must true or false', - }) - .transform((val) => val === 'true'), - onlyDiscounted: z.coerce - .string() - .optional() - .default('false') - .refine((val) => ['true', 'false'].includes(val), { - message: 'onlyDiscounted must true or false', - }) - .transform((val) => val === 'true'), - auctionTypes: z - .string() - .optional() - .default(AuctionTypes.join(',')) - .transform((types) => types?.split(',')) - .refine( - (types) => - types.every((type) => AuctionTypes.includes(type as AuctionType)), - { - message: `Invalid auction types, valid options are: ${AuctionTypes.join( - ', ', - )}`, - }, - ) - .transform((types) => types as AuctionType[]), - orderBy: z.string().default('discount'), - orderDir: z.enum(['asc', 'desc']).default('desc'), -}) diff --git a/packages/client/src/pure/bonds/index.ts b/packages/client/src/pure/bonds/index.ts deleted file mode 100644 index a6c8e520f9..0000000000 --- a/packages/client/src/pure/bonds/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './bond/bond' -export * from './bonds/bonds' -export * from './positions/positions' diff --git a/packages/client/src/pure/bonds/positions/positions.ts b/packages/client/src/pure/bonds/positions/positions.ts deleted file mode 100644 index 4dc69219b1..0000000000 --- a/packages/client/src/pure/bonds/positions/positions.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { type getBondPositionsFromSubgraph } from '../../../api' -import { EVM_APP_BASE_URL } from '../../../constants' -import { get, parseArgs } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type BondsPositionsApiSchema } from './schema' - -export { type BondsPositionsApiSchema } -export type BondPosition = BondsPositions[number] -export type BondsPositions = Awaited< - ReturnType -> -export type GetBondsPositionsArgs = - | GetApiInputFromOutput< - (typeof BondsPositionsApiSchema)['_input'], - (typeof BondsPositionsApiSchema)['_output'] - > - | undefined - -export const getBondsPositionsUrl = (args?: GetBondsPositionsArgs) => { - return `${EVM_APP_BASE_URL}/bonds/api/v1/positions${parseArgs(args)}` -} - -export const getBondsPositions = async ( - args?: GetBondsPositionsArgs, -): Promise => { - return get(getBondsPositionsUrl(args)) -} diff --git a/packages/client/src/pure/bonds/positions/schema.ts b/packages/client/src/pure/bonds/positions/schema.ts deleted file mode 100644 index 367e602a2c..0000000000 --- a/packages/client/src/pure/bonds/positions/schema.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { BONDS_ENABLED_CHAIN_IDS, isBondChainId } from '@sushiswap/bonds-sdk' -import type { ChainId } from 'sushi/chain' -import { z } from 'zod' - -export const BondsPositionsApiSchema = z.object({ - userAddress: z.string().transform((address) => address.toLowerCase()), - onlyUnclaimedBonds: z.coerce - .string() - .optional() - .default('true') - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('onlyUnclaimedBonds must true or false') - } - }), - payoutTokenId: z - .string() - .transform((id) => id.toLowerCase()) - .optional(), - chainIds: z - .string() - .optional() - .default(BONDS_ENABLED_CHAIN_IDS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) - .transform((chainIds) => chainIds.filter(isBondChainId)), -}) diff --git a/packages/client/src/pure/index.ts b/packages/client/src/pure/index.ts deleted file mode 100644 index 82a2665523..0000000000 --- a/packages/client/src/pure/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './bonds/index.js' -export * from './pools/index.js' -export * from './steer-vault/index.js' -export * from './tokens/index.js' diff --git a/packages/client/src/pure/pools/count/count.ts b/packages/client/src/pure/pools/count/count.ts deleted file mode 100644 index 785e3a8111..0000000000 --- a/packages/client/src/pure/pools/count/count.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { type getPoolCountFromDB } from '../../../api/pools/count' -import { EVM_APP_BASE_URL } from '../../../constants' -import { parseArgs } from '../../../functions' -import { get } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type PoolCountApiSchema } from './schema' - -export { type PoolCountApiSchema } -export type PoolCount = Awaited> -export type GetPoolCountArgs = - | GetApiInputFromOutput< - (typeof PoolCountApiSchema)['_input'], - (typeof PoolCountApiSchema)['_output'] - > - | undefined - -export const getPoolCountUrl = (args: GetPoolCountArgs) => { - return `${EVM_APP_BASE_URL}/pool/api/pools/count${parseArgs(args)}` -} - -export const getPoolCount = async ( - args: GetPoolCountArgs, -): Promise => { - return get(getPoolCountUrl(args)) -} diff --git a/packages/client/src/pure/pools/count/schema.ts b/packages/client/src/pure/pools/count/schema.ts deleted file mode 100644 index 4f2fab63fb..0000000000 --- a/packages/client/src/pure/pools/count/schema.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { type Protocol } from '@sushiswap/database' // Unused as a regular import, but type is being used for casting -import { z } from 'zod' - -export const PoolCountApiSchema = z.object({ - chainIds: z - .string() - .transform((val) => val.split(',').map((v) => parseInt(v))) - .optional(), - isIncentivized: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('isIncentivized must true or false') - } - }) - .optional(), - isWhitelisted: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('isWhitelisted must true or false') - } - }) - .optional(), - hasEnabledSteerVault: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('hasEnabledSteerVault must true or false') - } - }) - .optional(), - tokenSymbols: z - .string() - .transform((tokenSymbols) => tokenSymbols?.split(',')) - .refine((tokenSymbols) => tokenSymbols.length <= 3, { - message: 'Can only use up to 3 tokenSymbols.', - }) - .optional(), - protocols: z - .string() - .optional() - .transform((protocols) => protocols?.split(',') as Protocol[]), -}) diff --git a/packages/client/src/pure/pools/index.ts b/packages/client/src/pure/pools/index.ts deleted file mode 100644 index efce62a0a7..0000000000 --- a/packages/client/src/pure/pools/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './count/count' -export * from './pool/pool' -export * from './pools/pools' -export { ChefType, Protocol, RewarderType } from '@sushiswap/database' diff --git a/packages/client/src/pure/pools/pool/pool.ts b/packages/client/src/pure/pools/pool/pool.ts deleted file mode 100644 index 06e520bbb6..0000000000 --- a/packages/client/src/pure/pools/pool/pool.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { getChainIdAddressFromId } from 'sushi' -import { type getPoolFromDB } from '../../../api/pools/pool' -import { EVM_APP_BASE_URL } from '../../../constants' -import { get } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type PoolApiSchema } from './schema' - -export { type PoolApiSchema } -export type Pool = Awaited> -// Slightly opinionated, adding string to support the chainId:address format -export type GetPoolArgs = - | GetApiInputFromOutput< - (typeof PoolApiSchema)['_input'], - (typeof PoolApiSchema)['_output'] - > - | string - -export const getPoolUrl = (args: GetPoolArgs) => { - let chainId - let address - if (typeof args === 'string') { - ;({ chainId, address } = getChainIdAddressFromId(args)) - } else { - ;[chainId, address] = [args.chainId, args.address] - } - - return `${EVM_APP_BASE_URL}/pool/api/pools/${chainId}/${address}` -} - -export const getPool = async (args: GetPoolArgs): Promise => { - return get(getPoolUrl(args)) -} diff --git a/packages/client/src/pure/pools/pool/schema.ts b/packages/client/src/pure/pools/pool/schema.ts deleted file mode 100644 index 3a8679b7ce..0000000000 --- a/packages/client/src/pure/pools/pool/schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { z } from 'zod' - -export const PoolApiSchema = z.object({ - chainId: z.coerce - .number() - .int() - .gte(0) - .lte(2 ** 256), - address: z.coerce.string(), -}) diff --git a/packages/client/src/pure/pools/pools/pools.ts b/packages/client/src/pure/pools/pools/pools.ts deleted file mode 100644 index e24051ef5d..0000000000 --- a/packages/client/src/pure/pools/pools/pools.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { getPoolsFromDB } from '../../../api/pools/pools/index' -import { EVM_APP_BASE_URL } from '../../../constants' -import { parseArgs } from '../../../functions' -import { get } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type PoolsApiSchema } from './schema' - -export { type PoolsApiSchema } -export type Pools = Awaited> -export type GetPoolsArgs = - | GetApiInputFromOutput< - (typeof PoolsApiSchema)['_input'], - (typeof PoolsApiSchema)['_output'] - > - | undefined - -export const getPoolsUrl = (args: GetPoolsArgs) => { - return `${EVM_APP_BASE_URL}/pool/api/pools${parseArgs(args)}` -} - -export const getPools = async (args: GetPoolsArgs): Promise => { - return get(getPoolsUrl(args)) -} diff --git a/packages/client/src/pure/pools/pools/schema.ts b/packages/client/src/pure/pools/pools/schema.ts deleted file mode 100644 index 3c9dc676ee..0000000000 --- a/packages/client/src/pure/pools/pools/schema.ts +++ /dev/null @@ -1,65 +0,0 @@ -import type { Protocol } from '@sushiswap/database' // Unused as a regular import, but type is being used for casting -import type { ID } from 'sushi/types' -import { z } from 'zod' - -export const PoolsApiSchema = z.object({ - take: z.coerce.number().int().lte(1000).default(20), - ids: z - .string() - .transform((ids) => ids?.split(',').map((id) => id.toLowerCase() as ID)) - .optional(), - chainIds: z - .string() - .transform((val) => val.split(',').map((v) => parseInt(v))) - .optional(), - isIncentivized: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('isIncentivized must true or false') - } - }) - .optional(), - isWhitelisted: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('isWhitelisted must true or false') - } - }) - .optional(), - hasEnabledSteerVault: z.coerce - .string() - .transform((val) => { - if (val === 'true') { - return true - } else if (val === 'false') { - return false - } else { - throw new Error('hasEnabledSteerVault must true or false') - } - }) - .optional(), - tokenSymbols: z - .string() - .transform((tokenSymbols) => tokenSymbols?.split(',')) - .refine((tokenSymbols) => tokenSymbols.length <= 3, { - message: 'Can only use up to 3 tokenSymbols.', - }) - .optional(), - protocols: z - .string() - .transform((protocols) => protocols?.split(',') as Protocol[]) - .optional(), - cursor: z.string().optional(), - orderBy: z.string().default('liquidityUSD'), - orderDir: z.enum(['asc', 'desc']).default('desc'), -}) diff --git a/packages/client/src/pure/steer-vault/count/count.ts b/packages/client/src/pure/steer-vault/count/count.ts deleted file mode 100644 index e6a992e9b1..0000000000 --- a/packages/client/src/pure/steer-vault/count/count.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { type getSteerVaultCountFromDB } from '../../../api/steer-vault/count' -import { EVM_APP_BASE_URL } from '../../../constants' -import { parseArgs } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type SteerVaultCountApiSchema } from './schema' - -export { type SteerVaultCountApiSchema } -export type SteerVaultCount = Awaited< - ReturnType -> -export type GetSteerVaultCountArgs = - | GetApiInputFromOutput< - (typeof SteerVaultCountApiSchema)['_input'], - (typeof SteerVaultCountApiSchema)['_output'] - > - | undefined - -export const getSteerVaultCountUrl = (args: GetSteerVaultCountArgs) => { - return `${EVM_APP_BASE_URL}/pool/api/steer-vault/count${parseArgs(args)}` -} - -export const getSteerVaultCount = async ( - args: GetSteerVaultCountArgs, -): Promise => { - return fetch(getSteerVaultCountUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/steer-vault/count/schema.ts b/packages/client/src/pure/steer-vault/count/schema.ts deleted file mode 100644 index 881a59a6e4..0000000000 --- a/packages/client/src/pure/steer-vault/count/schema.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { z } from 'zod' - -export const SteerVaultCountApiSchema = z.object({ - chainIds: z - .string() - .transform((val) => val.split(',').map((v) => parseInt(v))) - .optional(), - onlyEnabled: z.coerce - .string() - .transform((val) => { - switch (val) { - case 'true': - return true - case 'false': - return false - default: - throw new Error('onlyEnabled must true or false') - } - }) - .optional(), -}) diff --git a/packages/client/src/pure/steer-vault/index.ts b/packages/client/src/pure/steer-vault/index.ts deleted file mode 100644 index 61e5d9b441..0000000000 --- a/packages/client/src/pure/steer-vault/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './count/count' -export * from './vault/vault' -export * from './vaults/vaults' diff --git a/packages/client/src/pure/steer-vault/vault/schema.ts b/packages/client/src/pure/steer-vault/vault/schema.ts deleted file mode 100644 index 4e5d43e97f..0000000000 --- a/packages/client/src/pure/steer-vault/vault/schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { z } from 'zod' - -export const SteerVaultApiSchema = z.object({ - chainId: z.coerce - .number() - .int() - .gte(0) - .lte(2 ** 256), - address: z.coerce.string(), -}) diff --git a/packages/client/src/pure/steer-vault/vault/vault.ts b/packages/client/src/pure/steer-vault/vault/vault.ts deleted file mode 100644 index a0eaca2fe9..0000000000 --- a/packages/client/src/pure/steer-vault/vault/vault.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { ChainId } from 'sushi/chain' -import { getChainIdAddressFromId } from 'sushi/format' -import type { Address } from 'viem' -import { type getSteerVaultFromDB } from '../../../api/steer-vault/vault' -import { EVM_APP_BASE_URL } from '../../../constants' -import { type GetApiInputFromOutput } from '../../../types' -import { type SteerVaultApiSchema } from './schema' - -export { type SteerVaultApiSchema } -export type SteerVault = Awaited> -// Slightly opinionated, adding string to support the chainId:address format -export type GetSteerVaultArgs = - | GetApiInputFromOutput< - (typeof SteerVaultApiSchema)['_input'], - (typeof SteerVaultApiSchema)['_output'] - > - | string - -export const getSteerVaultUrl = (args: GetSteerVaultArgs) => { - let chainId: ReturnType['chainId'] - let address: ReturnType['address'] - - if (typeof args === 'string') { - ;({ chainId, address } = getChainIdAddressFromId(args)) - } else { - ;[chainId, address] = [args.chainId as ChainId, args.address as Address] - } - - return `${EVM_APP_BASE_URL}/pool/api/steer-vault/${chainId}/${address}` -} - -export const getSteerVault = async ( - args: GetSteerVaultArgs, -): Promise => { - return fetch(getSteerVaultUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/steer-vault/vaults/schema.ts b/packages/client/src/pure/steer-vault/vaults/schema.ts deleted file mode 100644 index d779b6ddc6..0000000000 --- a/packages/client/src/pure/steer-vault/vaults/schema.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { getChainIdAddressFromId } from 'sushi/format' -import type { ID } from 'sushi/types' -import { z } from 'zod' - -export const SteerVaultsApiSchema = z.object({ - take: z.coerce.number().int().lte(1000).default(1000), - ids: z - .string() - .transform((ids) => ids?.split(',').map((id) => id.toLowerCase())) - .optional(), - chainIds: z - .string() - .transform((val) => val.split(',').map((v) => parseInt(v))) - .optional(), - onlyEnabled: z.coerce - .string() - .transform((val) => { - switch (val) { - case 'true': - return true - case 'false': - return false - default: - throw new Error('onlyEnabled must true or false') - } - }) - .optional(), - tokenSymbols: z - .string() - .transform((tokenSymbols) => tokenSymbols?.split(',')) - .refine((tokenSymbols) => tokenSymbols.length <= 3, { - message: 'Can only use up to 3 tokenSymbols.', - }) - .optional(), - poolId: z - .string() - .refine(getChainIdAddressFromId) - .transform((id) => id.toLowerCase() as ID) - .optional(), - cursor: z.string().optional(), - orderBy: z.string().default('reserveUSD'), - orderDir: z.enum(['asc', 'desc']).default('desc'), -}) diff --git a/packages/client/src/pure/steer-vault/vaults/vaults.ts b/packages/client/src/pure/steer-vault/vaults/vaults.ts deleted file mode 100644 index 58b0fe1c5d..0000000000 --- a/packages/client/src/pure/steer-vault/vaults/vaults.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { type getSteerVaultsFromDB } from '../../../api/steer-vault/vaults' -import { EVM_APP_BASE_URL } from '../../../constants' -import { parseArgs } from '../../../functions' -import { type GetApiInputFromOutput } from '../../../types' -import { type SteerVaultsApiSchema } from './schema' - -export { type SteerVaultsApiSchema } -export type SteerVaults = Awaited> -export type GetSteerVaultsArgs = - | GetApiInputFromOutput< - (typeof SteerVaultsApiSchema)['_input'], - (typeof SteerVaultsApiSchema)['_output'] - > - | undefined - -export const getSteerVaultsUrl = (args: GetSteerVaultsArgs) => { - return `${EVM_APP_BASE_URL}/pool/api/steer-vault${parseArgs( - args, - )}` -} - -export const getSteerVaults = async ( - args: GetSteerVaultsArgs, -): Promise => { - return fetch(getSteerVaultsUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/chainId/address.ts b/packages/client/src/pure/tokens/chainId/address.ts deleted file mode 100644 index 8626e3cb20..0000000000 --- a/packages/client/src/pure/tokens/chainId/address.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { getToken as _getToken } from '@sushiswap/tokens-api/lib/api' -import { TokenApiSchema } from '@sushiswap/tokens-api/lib/schemas/chainId/address' -import type { ChainId } from 'sushi/chain' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { TokenApiSchema } -export type Token = Awaited> -// Slightly opinionated, adding string to support the chainId:address format -export type GetTokenArgs = - | GetApiInputFromOutput< - (typeof TokenApiSchema)['_input'], - (typeof TokenApiSchema)['_output'] - > - | string - -export const getTokenUrl = (args: GetTokenArgs) => { - let chainId - let address - if (typeof args === 'string') { - ;[chainId, address] = args.split(':') as [ChainId, string] - } else { - ;[chainId, address] = [args.chainId, args.address] - } - - return `${TOKENS_API}/api/v0/${chainId}/${address}` -} - -export const getToken = async (args: GetTokenArgs): Promise => { - return fetch(getTokenUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/chainId/addresses.ts b/packages/client/src/pure/tokens/chainId/addresses.ts deleted file mode 100644 index deaca21f5e..0000000000 --- a/packages/client/src/pure/tokens/chainId/addresses.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { getTokenAddressesByChainId } from '@sushiswap/tokens-api/lib/api' -import { TokenAddressesApiSchema } from '@sushiswap/tokens-api/lib/schemas/chainId/addresses' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { TokenAddressesApiSchema } -export type TokenAddress = Awaited< - ReturnType -> -export type GetTokenAddressesArgs = GetApiInputFromOutput< - (typeof TokenAddressesApiSchema)['_input'], - (typeof TokenAddressesApiSchema)['_output'] -> - -export const getTokenAddressesUrl = (args: GetTokenAddressesArgs) => { - return `${TOKENS_API}/api/v0/${args.chainId}/addresses` -} - -export const getTokenAddresses = async ( - args: GetTokenAddressesArgs, -): Promise => { - return fetch(getTokenAddressesUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/chainId/common.ts b/packages/client/src/pure/tokens/chainId/common.ts deleted file mode 100644 index b05e824961..0000000000 --- a/packages/client/src/pure/tokens/chainId/common.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { getCommonTokens as _getCommonTokens } from '@sushiswap/tokens-api/lib/api' -import { CommonTokensApiSchema } from '@sushiswap/tokens-api/lib/schemas/chainId/common' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { CommonTokensApiSchema } -export type CommonToken = Awaited> -export type GetCommonTokensArgs = GetApiInputFromOutput< - (typeof CommonTokensApiSchema)['_input'], - (typeof CommonTokensApiSchema)['_output'] -> - -export const getCommonTokensUrl = (args: GetCommonTokensArgs) => { - return `${TOKENS_API}/api/v0/${args.chainId}/common` -} - -export const getCommonTokens = async ( - args: GetCommonTokensArgs, -): Promise => { - return fetch(getCommonTokensUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/chainId/ids.ts b/packages/client/src/pure/tokens/chainId/ids.ts deleted file mode 100644 index 6c48cb9b46..0000000000 --- a/packages/client/src/pure/tokens/chainId/ids.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { getTokenIdsByChainId } from '@sushiswap/tokens-api/lib/api' -import { TokenIdsApiSchema } from '@sushiswap/tokens-api/lib/schemas/chainId/ids' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { TokenIdsApiSchema } -export type TokenId = Awaited> -export type GetTokenIdsArgs = GetApiInputFromOutput< - (typeof TokenIdsApiSchema)['_input'], - (typeof TokenIdsApiSchema)['_output'] -> - -export const getTokenIdsUrl = (args: GetTokenIdsArgs) => { - return `${TOKENS_API}/api/v0/${args.chainId}/ids` -} - -export const getTokenIds = async (args: GetTokenIdsArgs): Promise => { - return fetch(getTokenIdsUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/chainId/index.ts b/packages/client/src/pure/tokens/chainId/index.ts deleted file mode 100644 index ff2531fa71..0000000000 --- a/packages/client/src/pure/tokens/chainId/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './address.js' -export * from './addresses.js' -export * from './common.js' -export * from './ids.js' -export * from './popular.js' diff --git a/packages/client/src/pure/tokens/chainId/popular.ts b/packages/client/src/pure/tokens/chainId/popular.ts deleted file mode 100644 index eb6bd33124..0000000000 --- a/packages/client/src/pure/tokens/chainId/popular.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { getPopularTokens as _getPopularTokens } from '@sushiswap/tokens-api/lib/api' -import { PopularTokensApiSchema } from '@sushiswap/tokens-api/lib/schemas/chainId/popular' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { PopularTokensApiSchema } -export type PopularToken = Awaited> -export type GetPopularTokensArgs = GetApiInputFromOutput< - (typeof PopularTokensApiSchema)['_input'], - (typeof PopularTokensApiSchema)['_output'] -> - -export const getPopularTokensUrl = (args: GetPopularTokensArgs) => { - return `${TOKENS_API}/api/v0/${args.chainId}/popular` -} - -export const getPopularTokens = async ( - args: GetPopularTokensArgs, -): Promise => { - return fetch(getPopularTokensUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/index.ts b/packages/client/src/pure/tokens/index.ts deleted file mode 100644 index 38f506a55e..0000000000 --- a/packages/client/src/pure/tokens/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { getTokens as _getTokens } from '@sushiswap/tokens-api/lib/api' -import { TokensApiSchema } from '@sushiswap/tokens-api/lib/schemas/index' - -import { TOKENS_API } from '../../constants.js' -import type { GetApiInputFromOutput } from '../../types.js' - -export { TokensApiSchema } -export type Token = Awaited> -export type GetTokensArgs = GetApiInputFromOutput< - (typeof TokensApiSchema)['_input'], - (typeof TokensApiSchema)['_output'] -> - -export const getTokensUrl = (/*args: GetTokensArgs*/) => { - return `${TOKENS_API}/api/v0` -} - -export const getTokens = async (/*args: GetTokensArgs*/): Promise => { - return fetch(getTokensUrl(/*args*/)).then((data) => data.json()) -} - -export * from './chainId/index.js' -export * from './search/index.js' diff --git a/packages/client/src/pure/tokens/search/address.ts b/packages/client/src/pure/tokens/search/address.ts deleted file mode 100644 index f4e30db046..0000000000 --- a/packages/client/src/pure/tokens/search/address.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { getTokensByAddress } from '@sushiswap/tokens-api/lib/api' -import { SearchTokenApiSchema } from '@sushiswap/tokens-api/lib/schemas/search/address' - -import { TOKENS_API } from '../../../constants.js' -import type { GetApiInputFromOutput } from '../../../types.js' - -export { SearchTokenApiSchema } -export type TokenSearch = Awaited> -export type GetTokenSearchsArgs = GetApiInputFromOutput< - (typeof SearchTokenApiSchema)['_input'], - (typeof SearchTokenApiSchema)['_output'] -> - -export const getSearchTokensUrl = (args: GetTokenSearchsArgs) => { - return `${TOKENS_API}/api/v0/search/${args.address}` -} - -export const getSearchTokens = async ( - args: GetTokenSearchsArgs, -): Promise => { - return fetch(getSearchTokensUrl(args)).then((data) => data.json()) -} diff --git a/packages/client/src/pure/tokens/search/index.ts b/packages/client/src/pure/tokens/search/index.ts deleted file mode 100644 index 1451c145f1..0000000000 --- a/packages/client/src/pure/tokens/search/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './address.js' diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts deleted file mode 100644 index 64bdefce84..0000000000 --- a/packages/client/src/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { SWRConfiguration } from 'swr' -import type { SWRInfiniteConfiguration } from 'swr/infinite' - -/** - * API is called with strings as arguments, need to convert those into their respective types. - * ALso need to consider zod.defaults, which is why we can't use the output type directly. - */ -export type GetApiInputFromOutput< - I extends object, - O extends Partial>, -> = { - [K in keyof I]: (I[K] extends undefined ? undefined : unknown) & O[K] -} - -export interface SWRHookConfig { - args: T - swrConfig?: SWRConfiguration - shouldFetch?: boolean -} - -export interface InfiniteSWRHookConfig { - args: T - swrConfig?: SWRInfiniteConfiguration - shouldFetch?: boolean -} diff --git a/packages/client/tsconfig.json b/packages/client/tsconfig.json deleted file mode 100644 index 708b0fa526..0000000000 --- a/packages/client/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/esm/tsconfig"], - "include": ["src"], - "exclude": ["node_modules"], - "compilerOptions": { - "baseUrl": ".", - "outDir": "./dist", - "rootDir": "./src", - "declaration": true, - "declarationMap": true, - "sourceMap": true, - "moduleResolution": "Bundler" - } -} \ No newline at end of file diff --git a/packages/graph-client/package.json b/packages/graph-client/package.json index ae5bf0a688..f88a2048f3 100644 --- a/packages/graph-client/package.json +++ b/packages/graph-client/package.json @@ -64,7 +64,6 @@ "update-schemas": "tsx scripts/update-schemas.ts" }, "dependencies": { - "@sushiswap/bonds-sdk": "workspace:*", "@sushiswap/steer-sdk": "workspace:*", "gql.tada": "^1.7.5", "graphql": "16.6.0", @@ -75,7 +74,6 @@ }, "devDependencies": { "@0no-co/graphqlsp": "^1.12.3", - "@sushiswap/database": "workspace:*", "@tsconfig/esm": "1.0.4", "@tsconfig/strictest": "2.0.2", "@types/json-bigint": "^1.0.4", diff --git a/packages/graph-client/scripts/update-schemas.ts b/packages/graph-client/scripts/update-schemas.ts index a95858e887..fb41bf549a 100644 --- a/packages/graph-client/scripts/update-schemas.ts +++ b/packages/graph-client/scripts/update-schemas.ts @@ -6,7 +6,7 @@ const schemas = { bentobox: 'api.studio.thegraph.com/query/32073/bentobox-ethereum/v0.0.1', strapi: 'sushi-strapi-cms.herokuapp.com/graphql', furo: 'api.studio.thegraph.com/query/32073/furo-ethereum/v0.0.1', - 'data-api': 'data-api-staging.up.railway.app/graphql', + 'data-api': 'production.data-gcp.sushi.com/graphql', } as const satisfies Record async function updateSchema(schema: keyof typeof schemas) { diff --git a/packages/graph-client/src/subgraphs/bonds/graphql.ts b/packages/graph-client/src/subgraphs/bonds/graphql.ts deleted file mode 100644 index bd75c7dd0e..0000000000 --- a/packages/graph-client/src/subgraphs/bonds/graphql.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { initGraphQLTada } from 'gql.tada' -import type { Scalars } from 'src/lib/types/scalars.js' -import type { introspection } from './bonds-env.js' - -export const graphql = initGraphQLTada<{ - introspection: introspection - scalars: Scalars -}>() diff --git a/packages/graph-client/src/subgraphs/bonds/index.ts b/packages/graph-client/src/subgraphs/bonds/index.ts deleted file mode 100644 index cdf4b947d4..0000000000 --- a/packages/graph-client/src/subgraphs/bonds/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './queries/markets' -export * from './queries/positions' diff --git a/packages/graph-client/src/subgraphs/bonds/queries/markets.ts b/packages/graph-client/src/subgraphs/bonds/queries/markets.ts deleted file mode 100644 index 736ed12478..0000000000 --- a/packages/graph-client/src/subgraphs/bonds/queries/markets.ts +++ /dev/null @@ -1,99 +0,0 @@ -import type { VariablesOf } from 'gql.tada' - -import { BONDS_SUBGRAPH_URL, type BondChainId } from '@sushiswap/bonds-sdk' -import { addChainId } from 'src/lib/modifiers/add-chain-id' -import { convertIdToMultichainId } from 'src/lib/modifiers/convert-id-to-multichain-id' -import { copyIdToAddress } from 'src/lib/modifiers/copy-id-to-address' -import type { RequestOptions } from 'src/lib/request' -import { requestPaged } from 'src/lib/request-paged' -import type { ChainIdVariable } from 'src/lib/types/chainId' -import type { Hex } from 'src/lib/types/hex' -import { graphql } from '../graphql' - -export const BondMarketsQuery = graphql( - ` - query Markets($first: Int = 1000, $skip: Int = 0, $block: Block_height, $orderBy: Market_orderBy, $orderDirection: OrderDirection, $where: Market_filter) { - markets(first: $first, skip: $skip, block: $block, orderBy: $orderBy, orderDirection: $orderDirection, where: $where) { - id - chainId - type - auctioneer - teller - marketId - owner - capacity - capacityInQuote - minPrice - scale - start - conclusion - payoutToken { - id: address - symbol - decimals - name - } - quoteToken { - id: address - symbol - decimals - name - } - vesting - vestingType - isInstantSwap - hasClosed - totalBondedAmount - totalPayoutAmount - averageBondPrice - bondsIssued - } - } -`, -) - -export type GetBondMarkets = VariablesOf & - ChainIdVariable - -export async function getBondMarkets( - { chainId, ...variables }: GetBondMarkets, - options?: RequestOptions, -) { - const url = `https://${BONDS_SUBGRAPH_URL[chainId]}` - - const result = await requestPaged({ - chainId, - url, - query: BondMarketsQuery, - variables, - options, - }) - - return result.markets.map((market) => { - const quoteToken = convertIdToMultichainId( - copyIdToAddress( - addChainId( - chainId, - market.quoteToken as typeof market.quoteToken & { id: Hex }, - ), - ), - ) - - const payoutToken = convertIdToMultichainId( - copyIdToAddress( - addChainId( - chainId, - market.payoutToken as typeof market.payoutToken & { id: Hex }, - ), - ), - ) - - return { - ...market, - quoteToken, - payoutToken, - } - }) -} - -export type BondMarkets = Awaited> diff --git a/packages/graph-client/src/subgraphs/bonds/queries/positions.ts b/packages/graph-client/src/subgraphs/bonds/queries/positions.ts deleted file mode 100644 index f4ff445fee..0000000000 --- a/packages/graph-client/src/subgraphs/bonds/queries/positions.ts +++ /dev/null @@ -1,79 +0,0 @@ -import type { VariablesOf } from 'gql.tada' - -import { BONDS_SUBGRAPH_URL, type BondChainId } from '@sushiswap/bonds-sdk' -import { addChainId } from 'src/lib/modifiers/add-chain-id' -import { convertIdToMultichainId } from 'src/lib/modifiers/convert-id-to-multichain-id' -import { copyIdToAddress } from 'src/lib/modifiers/copy-id-to-address' -import type { RequestOptions } from 'src/lib/request' -import { requestPaged } from 'src/lib/request-paged' -import type { ChainIdVariable } from 'src/lib/types/chainId' -import type { Hex } from 'src/lib/types/hex' -import { graphql } from '../graphql' - -export const BondUserPositionsQuery = graphql( - ` - query UserPositions($first: Int = 1000, $skip: Int = 0, $block: Block_height, $orderBy: OwnerBalance_orderBy, $orderDirection: OrderDirection, $where: OwnerBalance_filter) { - ownerBalances(first: $first, skip: $skip, block: $block, orderBy: $orderBy, orderDirection: $orderDirection, where: $where) { - id - owner - balance - bondToken { - id - expiry - type - teller - underlying { - id: address - symbol - decimals - name - } - } - } - } -`, -) - -export type GetBondUserPositions = VariablesOf & - ChainIdVariable - -export async function getBondUserPositions( - { chainId, ...variables }: GetBondUserPositions, - options?: RequestOptions, -) { - const url = `https://${BONDS_SUBGRAPH_URL[chainId]}` - - const result = await requestPaged({ - chainId, - url, - query: BondUserPositionsQuery, - variables, - options, - }) - - return result.ownerBalances.map((position) => { - const bondTokenUnderlying = position.bondToken - ? convertIdToMultichainId( - copyIdToAddress( - addChainId( - chainId, - position.bondToken - .underlying as typeof position.bondToken.underlying & { - id: Hex - }, - ), - ), - ) - : null - - return addChainId(chainId, { - ...position, - bondToken: { - ...position.bondToken, - underlying: bondTokenUnderlying, - }, - }) - }) -} - -export type BondUserPositions = Awaited> diff --git a/packages/graph-client/src/subgraphs/bonds/schema.graphql b/packages/graph-client/src/subgraphs/bonds/schema.graphql deleted file mode 100644 index 03488419a4..0000000000 --- a/packages/graph-client/src/subgraphs/bonds/schema.graphql +++ /dev/null @@ -1,3808 +0,0 @@ -""" -Marks the GraphQL type as indexable entity. Each type that should be an entity is required to be annotated with this directive. -""" -directive @entity on OBJECT - -"""Defined a Subgraph ID for an object type""" -directive @subgraphId(id: String!) on OBJECT - -""" -creates a virtual field on the entity that may be queried but cannot be set manually through the mappings API. -""" -directive @derivedFrom(field: String!) on FIELD_DEFINITION - -enum Aggregation_interval { - hour - day -} - -"The BalancerWeightedPool entity contains the details of a BalancerWeightedPool Token.\n" -type BalancerWeightedPool { - "Unique ID for the BalancerWeightedPool entity, in the format:\n[chain Id]_[pool address]\n" - id: String! - - "The pool's vault address.\n" - vaultAddress: String! - - "The pool's ID, for use in calls to vault functions.\n" - poolId: String! - - "A list of the Tokens which make up the vault.\n" - constituentTokens(skip: Int = 0, first: Int = 100, orderBy: Token_orderBy, orderDirection: OrderDirection, where: Token_filter): [Token!]! -} - -input BalancerWeightedPool_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - vaultAddress: String - vaultAddress_not: String - vaultAddress_gt: String - vaultAddress_lt: String - vaultAddress_gte: String - vaultAddress_lte: String - vaultAddress_in: [String!] - vaultAddress_not_in: [String!] - vaultAddress_contains: String - vaultAddress_contains_nocase: String - vaultAddress_not_contains: String - vaultAddress_not_contains_nocase: String - vaultAddress_starts_with: String - vaultAddress_starts_with_nocase: String - vaultAddress_not_starts_with: String - vaultAddress_not_starts_with_nocase: String - vaultAddress_ends_with: String - vaultAddress_ends_with_nocase: String - vaultAddress_not_ends_with: String - vaultAddress_not_ends_with_nocase: String - poolId: String - poolId_not: String - poolId_gt: String - poolId_lt: String - poolId_gte: String - poolId_lte: String - poolId_in: [String!] - poolId_not_in: [String!] - poolId_contains: String - poolId_contains_nocase: String - poolId_not_contains: String - poolId_not_contains_nocase: String - poolId_starts_with: String - poolId_starts_with_nocase: String - poolId_not_starts_with: String - poolId_not_starts_with_nocase: String - poolId_ends_with: String - poolId_ends_with_nocase: String - poolId_not_ends_with: String - poolId_not_ends_with_nocase: String - constituentTokens: [String!] - constituentTokens_not: [String!] - constituentTokens_contains: [String!] - constituentTokens_contains_nocase: [String!] - constituentTokens_not_contains: [String!] - constituentTokens_not_contains_nocase: [String!] - constituentTokens_: Token_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [BalancerWeightedPool_filter] - or: [BalancerWeightedPool_filter] -} - -enum BalancerWeightedPool_orderBy { - id - vaultAddress - poolId - constituentTokens -} - -scalar BigDecimal - -scalar BigInt - -input BlockChangedFilter { - number_gte: Int! -} - -input Block_height { - hash: Bytes - number: Int - number_gte: Int -} - -"The BondPurchase entity tracks individual bond purchases.\n" -type BondPurchase { - "The transaction hash is used as the BondPurchase ID.\n" - id: String! - - "The ID of the Market from which the bond was purchased.\n" - market: Market! - - "The owner address of the Market from which the bond was purchased.\n" - owner: String! - - "The amount of quote tokens paid.\n" - amount: BigDecimal! - - "The amount of payout tokens purchased.\n" - payout: BigDecimal! - - "The purchaser's address.\n" - recipient: String! - - "The frontend referrer address.\n" - referrer: String! - - "The time of the purchase.\n" - timestamp: BigInt! - - "The address of the relevant Teller contract.\n" - teller: String! - - "The address of the relevant Auctioneer contract.\n" - auctioneer: String! - - "A reference to the payout Token record.\n" - payoutToken: Token! - - "A reference to the quote Token record.\n" - quoteToken: Token! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The price at which the bond was purchased.\n**NOTE** this is quoteToken amount / payoutToken amount, it is NOT a USD price.\n" - purchasePrice: BigDecimal! - - "The new bond price, updated after the purchase.\n**NOTE** this is the Auctioneer contract's marketPrice adjusted for marketScale, it is NOT a USD price.\n" - postPurchasePrice: BigDecimal! - - "A reference to the OwnerTokenTbv record for this chain/owner/token combination.\n" - ownerTokenTbv: OwnerTokenTbv - - "A reference to the PayoutTokenTbv record for this chain/owner/token combination.\n" - payoutTokenTbv: PayoutTokenTbv -} - -input BondPurchase_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - market: String - market_not: String - market_gt: String - market_lt: String - market_gte: String - market_lte: String - market_in: [String!] - market_not_in: [String!] - market_contains: String - market_contains_nocase: String - market_not_contains: String - market_not_contains_nocase: String - market_starts_with: String - market_starts_with_nocase: String - market_not_starts_with: String - market_not_starts_with_nocase: String - market_ends_with: String - market_ends_with_nocase: String - market_not_ends_with: String - market_not_ends_with_nocase: String - market_: Market_filter - owner: String - owner_not: String - owner_gt: String - owner_lt: String - owner_gte: String - owner_lte: String - owner_in: [String!] - owner_not_in: [String!] - owner_contains: String - owner_contains_nocase: String - owner_not_contains: String - owner_not_contains_nocase: String - owner_starts_with: String - owner_starts_with_nocase: String - owner_not_starts_with: String - owner_not_starts_with_nocase: String - owner_ends_with: String - owner_ends_with_nocase: String - owner_not_ends_with: String - owner_not_ends_with_nocase: String - amount: BigDecimal - amount_not: BigDecimal - amount_gt: BigDecimal - amount_lt: BigDecimal - amount_gte: BigDecimal - amount_lte: BigDecimal - amount_in: [BigDecimal!] - amount_not_in: [BigDecimal!] - payout: BigDecimal - payout_not: BigDecimal - payout_gt: BigDecimal - payout_lt: BigDecimal - payout_gte: BigDecimal - payout_lte: BigDecimal - payout_in: [BigDecimal!] - payout_not_in: [BigDecimal!] - recipient: String - recipient_not: String - recipient_gt: String - recipient_lt: String - recipient_gte: String - recipient_lte: String - recipient_in: [String!] - recipient_not_in: [String!] - recipient_contains: String - recipient_contains_nocase: String - recipient_not_contains: String - recipient_not_contains_nocase: String - recipient_starts_with: String - recipient_starts_with_nocase: String - recipient_not_starts_with: String - recipient_not_starts_with_nocase: String - recipient_ends_with: String - recipient_ends_with_nocase: String - recipient_not_ends_with: String - recipient_not_ends_with_nocase: String - referrer: String - referrer_not: String - referrer_gt: String - referrer_lt: String - referrer_gte: String - referrer_lte: String - referrer_in: [String!] - referrer_not_in: [String!] - referrer_contains: String - referrer_contains_nocase: String - referrer_not_contains: String - referrer_not_contains_nocase: String - referrer_starts_with: String - referrer_starts_with_nocase: String - referrer_not_starts_with: String - referrer_not_starts_with_nocase: String - referrer_ends_with: String - referrer_ends_with_nocase: String - referrer_not_ends_with: String - referrer_not_ends_with_nocase: String - timestamp: BigInt - timestamp_not: BigInt - timestamp_gt: BigInt - timestamp_lt: BigInt - timestamp_gte: BigInt - timestamp_lte: BigInt - timestamp_in: [BigInt!] - timestamp_not_in: [BigInt!] - teller: String - teller_not: String - teller_gt: String - teller_lt: String - teller_gte: String - teller_lte: String - teller_in: [String!] - teller_not_in: [String!] - teller_contains: String - teller_contains_nocase: String - teller_not_contains: String - teller_not_contains_nocase: String - teller_starts_with: String - teller_starts_with_nocase: String - teller_not_starts_with: String - teller_not_starts_with_nocase: String - teller_ends_with: String - teller_ends_with_nocase: String - teller_not_ends_with: String - teller_not_ends_with_nocase: String - auctioneer: String - auctioneer_not: String - auctioneer_gt: String - auctioneer_lt: String - auctioneer_gte: String - auctioneer_lte: String - auctioneer_in: [String!] - auctioneer_not_in: [String!] - auctioneer_contains: String - auctioneer_contains_nocase: String - auctioneer_not_contains: String - auctioneer_not_contains_nocase: String - auctioneer_starts_with: String - auctioneer_starts_with_nocase: String - auctioneer_not_starts_with: String - auctioneer_not_starts_with_nocase: String - auctioneer_ends_with: String - auctioneer_ends_with_nocase: String - auctioneer_not_ends_with: String - auctioneer_not_ends_with_nocase: String - payoutToken: String - payoutToken_not: String - payoutToken_gt: String - payoutToken_lt: String - payoutToken_gte: String - payoutToken_lte: String - payoutToken_in: [String!] - payoutToken_not_in: [String!] - payoutToken_contains: String - payoutToken_contains_nocase: String - payoutToken_not_contains: String - payoutToken_not_contains_nocase: String - payoutToken_starts_with: String - payoutToken_starts_with_nocase: String - payoutToken_not_starts_with: String - payoutToken_not_starts_with_nocase: String - payoutToken_ends_with: String - payoutToken_ends_with_nocase: String - payoutToken_not_ends_with: String - payoutToken_not_ends_with_nocase: String - payoutToken_: Token_filter - quoteToken: String - quoteToken_not: String - quoteToken_gt: String - quoteToken_lt: String - quoteToken_gte: String - quoteToken_lte: String - quoteToken_in: [String!] - quoteToken_not_in: [String!] - quoteToken_contains: String - quoteToken_contains_nocase: String - quoteToken_not_contains: String - quoteToken_not_contains_nocase: String - quoteToken_starts_with: String - quoteToken_starts_with_nocase: String - quoteToken_not_starts_with: String - quoteToken_not_starts_with_nocase: String - quoteToken_ends_with: String - quoteToken_ends_with_nocase: String - quoteToken_not_ends_with: String - quoteToken_not_ends_with_nocase: String - quoteToken_: Token_filter - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - purchasePrice: BigDecimal - purchasePrice_not: BigDecimal - purchasePrice_gt: BigDecimal - purchasePrice_lt: BigDecimal - purchasePrice_gte: BigDecimal - purchasePrice_lte: BigDecimal - purchasePrice_in: [BigDecimal!] - purchasePrice_not_in: [BigDecimal!] - postPurchasePrice: BigDecimal - postPurchasePrice_not: BigDecimal - postPurchasePrice_gt: BigDecimal - postPurchasePrice_lt: BigDecimal - postPurchasePrice_gte: BigDecimal - postPurchasePrice_lte: BigDecimal - postPurchasePrice_in: [BigDecimal!] - postPurchasePrice_not_in: [BigDecimal!] - ownerTokenTbv: String - ownerTokenTbv_not: String - ownerTokenTbv_gt: String - ownerTokenTbv_lt: String - ownerTokenTbv_gte: String - ownerTokenTbv_lte: String - ownerTokenTbv_in: [String!] - ownerTokenTbv_not_in: [String!] - ownerTokenTbv_contains: String - ownerTokenTbv_contains_nocase: String - ownerTokenTbv_not_contains: String - ownerTokenTbv_not_contains_nocase: String - ownerTokenTbv_starts_with: String - ownerTokenTbv_starts_with_nocase: String - ownerTokenTbv_not_starts_with: String - ownerTokenTbv_not_starts_with_nocase: String - ownerTokenTbv_ends_with: String - ownerTokenTbv_ends_with_nocase: String - ownerTokenTbv_not_ends_with: String - ownerTokenTbv_not_ends_with_nocase: String - ownerTokenTbv_: OwnerTokenTbv_filter - payoutTokenTbv: String - payoutTokenTbv_not: String - payoutTokenTbv_gt: String - payoutTokenTbv_lt: String - payoutTokenTbv_gte: String - payoutTokenTbv_lte: String - payoutTokenTbv_in: [String!] - payoutTokenTbv_not_in: [String!] - payoutTokenTbv_contains: String - payoutTokenTbv_contains_nocase: String - payoutTokenTbv_not_contains: String - payoutTokenTbv_not_contains_nocase: String - payoutTokenTbv_starts_with: String - payoutTokenTbv_starts_with_nocase: String - payoutTokenTbv_not_starts_with: String - payoutTokenTbv_not_starts_with_nocase: String - payoutTokenTbv_ends_with: String - payoutTokenTbv_ends_with_nocase: String - payoutTokenTbv_not_ends_with: String - payoutTokenTbv_not_ends_with_nocase: String - payoutTokenTbv_: PayoutTokenTbv_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [BondPurchase_filter] - or: [BondPurchase_filter] -} - -enum BondPurchase_orderBy { - id - market - market__id - market__name - market__type - market__network - market__chainId - market__auctioneer - market__teller - market__marketId - market__owner - market__vesting - market__start - market__conclusion - market__vestingType - market__isInstantSwap - market__hasClosed - market__totalBondedAmount - market__totalPayoutAmount - market__creationBlockTimestamp - market__callbackAddress - market__capacity - market__capacityInQuote - market__minPrice - market__price - market__scale - market__averageBondPrice - market__bondsIssued - owner - amount - payout - recipient - referrer - timestamp - teller - auctioneer - payoutToken - payoutToken__id - payoutToken__network - payoutToken__chainId - payoutToken__address - payoutToken__decimals - payoutToken__symbol - payoutToken__name - payoutToken__typeName - payoutToken__usedAsPayout - payoutToken__usedAsQuote - payoutToken__totalPayoutAmount - payoutToken__purchaseCount - quoteToken - quoteToken__id - quoteToken__network - quoteToken__chainId - quoteToken__address - quoteToken__decimals - quoteToken__symbol - quoteToken__name - quoteToken__typeName - quoteToken__usedAsPayout - quoteToken__usedAsQuote - quoteToken__totalPayoutAmount - quoteToken__purchaseCount - network - chainId - purchasePrice - postPurchasePrice - ownerTokenTbv - ownerTokenTbv__id - ownerTokenTbv__owner - ownerTokenTbv__token - ownerTokenTbv__network - ownerTokenTbv__chainId - ownerTokenTbv__tbv - payoutTokenTbv - payoutTokenTbv__id - payoutTokenTbv__network - payoutTokenTbv__chainId - payoutTokenTbv__tbv -} - -"A BondToken record is created to track vesting tokens, both ERC-20 and ERC-1155, created by our contracts.\n" -type BondToken { - "Unique ID for the BondToken entity. In the case of an ERC-20 token, this will be the token's address. In the case of an ERC-1155 token, it will be the token's ID.\n" - id: String! - - "The number of decimals if an ERC-20, null if an ERC-1155.\n" - decimals: BigInt - - "The token symbol if an ERC-20, null if an ERC-1155.\n" - symbol: String - - "A reference to the Token which will be paid out upon vesting.\n" - underlying: Token! - - "Timestamp at which vesting completes.\n" - expiry: BigInt! - - "The address of the relevant Teller contract.\n" - teller: String! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The type of bond, either \"fixed-term\" or \"fixed-expiration\".\n" - type: String! -} - -input BondToken_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - decimals: BigInt - decimals_not: BigInt - decimals_gt: BigInt - decimals_lt: BigInt - decimals_gte: BigInt - decimals_lte: BigInt - decimals_in: [BigInt!] - decimals_not_in: [BigInt!] - symbol: String - symbol_not: String - symbol_gt: String - symbol_lt: String - symbol_gte: String - symbol_lte: String - symbol_in: [String!] - symbol_not_in: [String!] - symbol_contains: String - symbol_contains_nocase: String - symbol_not_contains: String - symbol_not_contains_nocase: String - symbol_starts_with: String - symbol_starts_with_nocase: String - symbol_not_starts_with: String - symbol_not_starts_with_nocase: String - symbol_ends_with: String - symbol_ends_with_nocase: String - symbol_not_ends_with: String - symbol_not_ends_with_nocase: String - underlying: String - underlying_not: String - underlying_gt: String - underlying_lt: String - underlying_gte: String - underlying_lte: String - underlying_in: [String!] - underlying_not_in: [String!] - underlying_contains: String - underlying_contains_nocase: String - underlying_not_contains: String - underlying_not_contains_nocase: String - underlying_starts_with: String - underlying_starts_with_nocase: String - underlying_not_starts_with: String - underlying_not_starts_with_nocase: String - underlying_ends_with: String - underlying_ends_with_nocase: String - underlying_not_ends_with: String - underlying_not_ends_with_nocase: String - underlying_: Token_filter - expiry: BigInt - expiry_not: BigInt - expiry_gt: BigInt - expiry_lt: BigInt - expiry_gte: BigInt - expiry_lte: BigInt - expiry_in: [BigInt!] - expiry_not_in: [BigInt!] - teller: String - teller_not: String - teller_gt: String - teller_lt: String - teller_gte: String - teller_lte: String - teller_in: [String!] - teller_not_in: [String!] - teller_contains: String - teller_contains_nocase: String - teller_not_contains: String - teller_not_contains_nocase: String - teller_starts_with: String - teller_starts_with_nocase: String - teller_not_starts_with: String - teller_not_starts_with_nocase: String - teller_ends_with: String - teller_ends_with_nocase: String - teller_not_ends_with: String - teller_not_ends_with_nocase: String - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - type: String - type_not: String - type_gt: String - type_lt: String - type_gte: String - type_lte: String - type_in: [String!] - type_not_in: [String!] - type_contains: String - type_contains_nocase: String - type_not_contains: String - type_not_contains_nocase: String - type_starts_with: String - type_starts_with_nocase: String - type_not_starts_with: String - type_not_starts_with_nocase: String - type_ends_with: String - type_ends_with_nocase: String - type_not_ends_with: String - type_not_ends_with_nocase: String - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [BondToken_filter] - or: [BondToken_filter] -} - -enum BondToken_orderBy { - id - decimals - symbol - underlying - underlying__id - underlying__network - underlying__chainId - underlying__address - underlying__decimals - underlying__symbol - underlying__name - underlying__typeName - underlying__usedAsPayout - underlying__usedAsQuote - underlying__totalPayoutAmount - underlying__purchaseCount - expiry - teller - network - chainId - type -} - -scalar Bytes - -"8 bytes signed integer\n" -scalar Int8 - -"The Market entity tracks all bond markets which have been created, whether currently open or closed.\n" -type Market { - "Unique ID for the Market entity, in the format:\n[chainId]_[auctioneer contract name]_[market id]\n**NOTE** At the time of writing, contract name will be either 'BondFixedTermCDA' or BondFixedExpCDA. More will be added in the future as different auctioneer types become available.\n" - id: String! - - "The Auctioneer contract name.\n" - name: String! - - "The type of Market.\n" - type: String! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The address of the Market's Auctioneer contract.\n" - auctioneer: String! - - "The address of the Market's Teller contract.\n" - teller: String! - - "The Market's ID for use with the Auctioneer.\n" - marketId: BigInt! - - "The address of the Market owner.\n" - owner: String! - - "A reference to the payout Token record.\n" - payoutToken: Token! - - "A reference to the quote Token record.\n" - quoteToken: Token! - - "The Market's vesting time. In the case of fixed expiry markets, this will be a timestamp. In the case of fixed term markets, it will be the vesting duration in seconds.\n" - vesting: BigInt! - - "The Market's start time (for supported Market types)\n" - start: BigInt - - "The Market's conclusion time\n" - conclusion: BigInt - - "The type of vesting for the market. At the time of writing, this will be either \"fixed-term\" or \"fixed-expiration\". More options may be added in the future if new vesting types become available.\n" - vestingType: String! - - "Whether or not the Market is an instant swap market.\n" - isInstantSwap: Boolean! - - "Whether or not the Market has been closed.\n" - hasClosed: Boolean! - - "The total amount of quote tokens bonded for this market.\n**NOTE** This is the number of quote tokens, NOT their USD value.\n" - totalBondedAmount: BigDecimal! - - "The total amount of payout tokens purchased through this market.\n**NOTE** This is the number of payout tokens, NOT their USD value.\n" - totalPayoutAmount: BigDecimal! - - "The timestamp of the block in which the Market was created.\n" - creationBlockTimestamp: BigInt! - - "The address of the Market callback contract, if specified. 0x0000000000000000000000000000000000000000 if there is no callback contract.\n" - callbackAddress: String! - - "The current capacity of the Market. This can be in either the quote or payout Token, according to the value of the capacityInQuote field.\n" - capacity: BigInt! - - "Whether the Market capacity is measured in the quote (true) or payout (false) Token.\n" - capacityInQuote: Boolean! - - "The minimum price at which a bond can be purchased.\n**NOTE** This is a minimum return value for the Auctioneer marketPrice function, NOT a USD price.\n" - minPrice: BigInt - - "The price at which a bond can be purchased.\n**NOTE** This is a minimum return value for the Auctioneer marketPrice function, NOT a USD price.\n" - price: BigInt - - "Scale value to use when converting between quote token and payout token amounts with marketPrice.\n" - scale: BigInt - - "The average bond price across all purchases.\n" - averageBondPrice: BigDecimal - - "A list of all tuning events that have been emitted for this Market.\n" - tunes(skip: Int = 0, first: Int = 100, orderBy: Tune_orderBy, orderDirection: OrderDirection, where: Tune_filter): [Tune!] - - "A list of BondPurchase records for this Market.\n" - bondPurchases(skip: Int = 0, first: Int = 100, orderBy: BondPurchase_orderBy, orderDirection: OrderDirection, where: BondPurchase_filter): [BondPurchase!] - - "A count of BondPurchases for this market\n" - bondsIssued: BigInt! -} - -"Workaround due to no simple entity count being available.\n" -type MarketOwnerCount { - "There should be one MarketOwnerCount entry per market owner, with owner address as id.\n" - id: String! - - "The total number of markets (open and closed) owned by this address on this chain.\n" - count: BigInt! -} - -input MarketOwnerCount_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - count: BigInt - count_not: BigInt - count_gt: BigInt - count_lt: BigInt - count_gte: BigInt - count_lte: BigInt - count_in: [BigInt!] - count_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [MarketOwnerCount_filter] - or: [MarketOwnerCount_filter] -} - -enum MarketOwnerCount_orderBy { - id - count -} - -input Market_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - name: String - name_not: String - name_gt: String - name_lt: String - name_gte: String - name_lte: String - name_in: [String!] - name_not_in: [String!] - name_contains: String - name_contains_nocase: String - name_not_contains: String - name_not_contains_nocase: String - name_starts_with: String - name_starts_with_nocase: String - name_not_starts_with: String - name_not_starts_with_nocase: String - name_ends_with: String - name_ends_with_nocase: String - name_not_ends_with: String - name_not_ends_with_nocase: String - type: String - type_not: String - type_gt: String - type_lt: String - type_gte: String - type_lte: String - type_in: [String!] - type_not_in: [String!] - type_contains: String - type_contains_nocase: String - type_not_contains: String - type_not_contains_nocase: String - type_starts_with: String - type_starts_with_nocase: String - type_not_starts_with: String - type_not_starts_with_nocase: String - type_ends_with: String - type_ends_with_nocase: String - type_not_ends_with: String - type_not_ends_with_nocase: String - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - auctioneer: String - auctioneer_not: String - auctioneer_gt: String - auctioneer_lt: String - auctioneer_gte: String - auctioneer_lte: String - auctioneer_in: [String!] - auctioneer_not_in: [String!] - auctioneer_contains: String - auctioneer_contains_nocase: String - auctioneer_not_contains: String - auctioneer_not_contains_nocase: String - auctioneer_starts_with: String - auctioneer_starts_with_nocase: String - auctioneer_not_starts_with: String - auctioneer_not_starts_with_nocase: String - auctioneer_ends_with: String - auctioneer_ends_with_nocase: String - auctioneer_not_ends_with: String - auctioneer_not_ends_with_nocase: String - teller: String - teller_not: String - teller_gt: String - teller_lt: String - teller_gte: String - teller_lte: String - teller_in: [String!] - teller_not_in: [String!] - teller_contains: String - teller_contains_nocase: String - teller_not_contains: String - teller_not_contains_nocase: String - teller_starts_with: String - teller_starts_with_nocase: String - teller_not_starts_with: String - teller_not_starts_with_nocase: String - teller_ends_with: String - teller_ends_with_nocase: String - teller_not_ends_with: String - teller_not_ends_with_nocase: String - marketId: BigInt - marketId_not: BigInt - marketId_gt: BigInt - marketId_lt: BigInt - marketId_gte: BigInt - marketId_lte: BigInt - marketId_in: [BigInt!] - marketId_not_in: [BigInt!] - owner: String - owner_not: String - owner_gt: String - owner_lt: String - owner_gte: String - owner_lte: String - owner_in: [String!] - owner_not_in: [String!] - owner_contains: String - owner_contains_nocase: String - owner_not_contains: String - owner_not_contains_nocase: String - owner_starts_with: String - owner_starts_with_nocase: String - owner_not_starts_with: String - owner_not_starts_with_nocase: String - owner_ends_with: String - owner_ends_with_nocase: String - owner_not_ends_with: String - owner_not_ends_with_nocase: String - payoutToken: String - payoutToken_not: String - payoutToken_gt: String - payoutToken_lt: String - payoutToken_gte: String - payoutToken_lte: String - payoutToken_in: [String!] - payoutToken_not_in: [String!] - payoutToken_contains: String - payoutToken_contains_nocase: String - payoutToken_not_contains: String - payoutToken_not_contains_nocase: String - payoutToken_starts_with: String - payoutToken_starts_with_nocase: String - payoutToken_not_starts_with: String - payoutToken_not_starts_with_nocase: String - payoutToken_ends_with: String - payoutToken_ends_with_nocase: String - payoutToken_not_ends_with: String - payoutToken_not_ends_with_nocase: String - payoutToken_: Token_filter - quoteToken: String - quoteToken_not: String - quoteToken_gt: String - quoteToken_lt: String - quoteToken_gte: String - quoteToken_lte: String - quoteToken_in: [String!] - quoteToken_not_in: [String!] - quoteToken_contains: String - quoteToken_contains_nocase: String - quoteToken_not_contains: String - quoteToken_not_contains_nocase: String - quoteToken_starts_with: String - quoteToken_starts_with_nocase: String - quoteToken_not_starts_with: String - quoteToken_not_starts_with_nocase: String - quoteToken_ends_with: String - quoteToken_ends_with_nocase: String - quoteToken_not_ends_with: String - quoteToken_not_ends_with_nocase: String - quoteToken_: Token_filter - vesting: BigInt - vesting_not: BigInt - vesting_gt: BigInt - vesting_lt: BigInt - vesting_gte: BigInt - vesting_lte: BigInt - vesting_in: [BigInt!] - vesting_not_in: [BigInt!] - start: BigInt - start_not: BigInt - start_gt: BigInt - start_lt: BigInt - start_gte: BigInt - start_lte: BigInt - start_in: [BigInt!] - start_not_in: [BigInt!] - conclusion: BigInt - conclusion_not: BigInt - conclusion_gt: BigInt - conclusion_lt: BigInt - conclusion_gte: BigInt - conclusion_lte: BigInt - conclusion_in: [BigInt!] - conclusion_not_in: [BigInt!] - vestingType: String - vestingType_not: String - vestingType_gt: String - vestingType_lt: String - vestingType_gte: String - vestingType_lte: String - vestingType_in: [String!] - vestingType_not_in: [String!] - vestingType_contains: String - vestingType_contains_nocase: String - vestingType_not_contains: String - vestingType_not_contains_nocase: String - vestingType_starts_with: String - vestingType_starts_with_nocase: String - vestingType_not_starts_with: String - vestingType_not_starts_with_nocase: String - vestingType_ends_with: String - vestingType_ends_with_nocase: String - vestingType_not_ends_with: String - vestingType_not_ends_with_nocase: String - isInstantSwap: Boolean - isInstantSwap_not: Boolean - isInstantSwap_in: [Boolean!] - isInstantSwap_not_in: [Boolean!] - hasClosed: Boolean - hasClosed_not: Boolean - hasClosed_in: [Boolean!] - hasClosed_not_in: [Boolean!] - totalBondedAmount: BigDecimal - totalBondedAmount_not: BigDecimal - totalBondedAmount_gt: BigDecimal - totalBondedAmount_lt: BigDecimal - totalBondedAmount_gte: BigDecimal - totalBondedAmount_lte: BigDecimal - totalBondedAmount_in: [BigDecimal!] - totalBondedAmount_not_in: [BigDecimal!] - totalPayoutAmount: BigDecimal - totalPayoutAmount_not: BigDecimal - totalPayoutAmount_gt: BigDecimal - totalPayoutAmount_lt: BigDecimal - totalPayoutAmount_gte: BigDecimal - totalPayoutAmount_lte: BigDecimal - totalPayoutAmount_in: [BigDecimal!] - totalPayoutAmount_not_in: [BigDecimal!] - creationBlockTimestamp: BigInt - creationBlockTimestamp_not: BigInt - creationBlockTimestamp_gt: BigInt - creationBlockTimestamp_lt: BigInt - creationBlockTimestamp_gte: BigInt - creationBlockTimestamp_lte: BigInt - creationBlockTimestamp_in: [BigInt!] - creationBlockTimestamp_not_in: [BigInt!] - callbackAddress: String - callbackAddress_not: String - callbackAddress_gt: String - callbackAddress_lt: String - callbackAddress_gte: String - callbackAddress_lte: String - callbackAddress_in: [String!] - callbackAddress_not_in: [String!] - callbackAddress_contains: String - callbackAddress_contains_nocase: String - callbackAddress_not_contains: String - callbackAddress_not_contains_nocase: String - callbackAddress_starts_with: String - callbackAddress_starts_with_nocase: String - callbackAddress_not_starts_with: String - callbackAddress_not_starts_with_nocase: String - callbackAddress_ends_with: String - callbackAddress_ends_with_nocase: String - callbackAddress_not_ends_with: String - callbackAddress_not_ends_with_nocase: String - capacity: BigInt - capacity_not: BigInt - capacity_gt: BigInt - capacity_lt: BigInt - capacity_gte: BigInt - capacity_lte: BigInt - capacity_in: [BigInt!] - capacity_not_in: [BigInt!] - capacityInQuote: Boolean - capacityInQuote_not: Boolean - capacityInQuote_in: [Boolean!] - capacityInQuote_not_in: [Boolean!] - minPrice: BigInt - minPrice_not: BigInt - minPrice_gt: BigInt - minPrice_lt: BigInt - minPrice_gte: BigInt - minPrice_lte: BigInt - minPrice_in: [BigInt!] - minPrice_not_in: [BigInt!] - price: BigInt - price_not: BigInt - price_gt: BigInt - price_lt: BigInt - price_gte: BigInt - price_lte: BigInt - price_in: [BigInt!] - price_not_in: [BigInt!] - scale: BigInt - scale_not: BigInt - scale_gt: BigInt - scale_lt: BigInt - scale_gte: BigInt - scale_lte: BigInt - scale_in: [BigInt!] - scale_not_in: [BigInt!] - averageBondPrice: BigDecimal - averageBondPrice_not: BigDecimal - averageBondPrice_gt: BigDecimal - averageBondPrice_lt: BigDecimal - averageBondPrice_gte: BigDecimal - averageBondPrice_lte: BigDecimal - averageBondPrice_in: [BigDecimal!] - averageBondPrice_not_in: [BigDecimal!] - tunes_: Tune_filter - bondPurchases_: BondPurchase_filter - bondsIssued: BigInt - bondsIssued_not: BigInt - bondsIssued_gt: BigInt - bondsIssued_lt: BigInt - bondsIssued_gte: BigInt - bondsIssued_lte: BigInt - bondsIssued_in: [BigInt!] - bondsIssued_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [Market_filter] - or: [Market_filter] -} - -enum Market_orderBy { - id - name - type - network - chainId - auctioneer - teller - marketId - owner - payoutToken - payoutToken__id - payoutToken__network - payoutToken__chainId - payoutToken__address - payoutToken__decimals - payoutToken__symbol - payoutToken__name - payoutToken__typeName - payoutToken__usedAsPayout - payoutToken__usedAsQuote - payoutToken__totalPayoutAmount - payoutToken__purchaseCount - quoteToken - quoteToken__id - quoteToken__network - quoteToken__chainId - quoteToken__address - quoteToken__decimals - quoteToken__symbol - quoteToken__name - quoteToken__typeName - quoteToken__usedAsPayout - quoteToken__usedAsQuote - quoteToken__totalPayoutAmount - quoteToken__purchaseCount - vesting - start - conclusion - vestingType - isInstantSwap - hasClosed - totalBondedAmount - totalPayoutAmount - creationBlockTimestamp - callbackAddress - capacity - capacityInQuote - minPrice - price - scale - averageBondPrice - tunes - bondPurchases - bondsIssued -} - -"""Defines the order direction, either ascending or descending""" -enum OrderDirection { - asc - desc -} - -"The OwnerBalance entity tracks user balances of fixed-term ERC-1155 bond tokens.\nIt does not track balances of fixed-expiry ERC-20 tokens. These can be found by querying the user's wallet.\n" -type OwnerBalance { - "Unique ID for the OwnerBalance entity, in the format:\n[owner address]_[BondToken tokenId]\n" - id: String! - - "The unique ID of the token, assigned on creation.\n" - tokenId: BigInt! - - "The wallet address the balance pertains to.\n" - owner: String! - - "The current balance of ERC-1155 bond tokens.\n" - balance: BigInt! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "A reference to the BondToken for which the balance is being recorded.\n" - bondToken: BondToken -} - -input OwnerBalance_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - tokenId: BigInt - tokenId_not: BigInt - tokenId_gt: BigInt - tokenId_lt: BigInt - tokenId_gte: BigInt - tokenId_lte: BigInt - tokenId_in: [BigInt!] - tokenId_not_in: [BigInt!] - owner: String - owner_not: String - owner_gt: String - owner_lt: String - owner_gte: String - owner_lte: String - owner_in: [String!] - owner_not_in: [String!] - owner_contains: String - owner_contains_nocase: String - owner_not_contains: String - owner_not_contains_nocase: String - owner_starts_with: String - owner_starts_with_nocase: String - owner_not_starts_with: String - owner_not_starts_with_nocase: String - owner_ends_with: String - owner_ends_with_nocase: String - owner_not_ends_with: String - owner_not_ends_with_nocase: String - balance: BigInt - balance_not: BigInt - balance_gt: BigInt - balance_lt: BigInt - balance_gte: BigInt - balance_lte: BigInt - balance_in: [BigInt!] - balance_not_in: [BigInt!] - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - bondToken: String - bondToken_not: String - bondToken_gt: String - bondToken_lt: String - bondToken_gte: String - bondToken_lte: String - bondToken_in: [String!] - bondToken_not_in: [String!] - bondToken_contains: String - bondToken_contains_nocase: String - bondToken_not_contains: String - bondToken_not_contains_nocase: String - bondToken_starts_with: String - bondToken_starts_with_nocase: String - bondToken_not_starts_with: String - bondToken_not_starts_with_nocase: String - bondToken_ends_with: String - bondToken_ends_with_nocase: String - bondToken_not_ends_with: String - bondToken_not_ends_with_nocase: String - bondToken_: BondToken_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [OwnerBalance_filter] - or: [OwnerBalance_filter] -} - -enum OwnerBalance_orderBy { - id - tokenId - owner - balance - network - chainId - bondToken - bondToken__id - bondToken__decimals - bondToken__symbol - bondToken__expiry - bondToken__teller - bondToken__network - bondToken__chainId - bondToken__type -} - -"The OwnerTokenTbv entity tracks the total of each quote token received by each Market owner.\n" -type OwnerTokenTbv { - "Unique ID for the OwnerTokenTbv entity, in the format:\n[chainId]_[Market owner address]__[quote Token id]\n**NOTE** the Token ID also appends the chain ID before the token address, so the chain ID will appear once at the start of the OwnerTokenTbv ID and once in the quote token subsection of the ID.\n" - id: String! - - "The Market owner address for which TBV is being calculated.\n" - owner: String! - - "The quote Token for which TBV is being calculated.\n" - token: String! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The amount of the quote token received across the owner's markets.\n" - tbv: BigDecimal! - - "A list of BondPurchase records in which the owner has received the quote token.\n" - bondPurchases(skip: Int = 0, first: Int = 100, orderBy: BondPurchase_orderBy, orderDirection: OrderDirection, where: BondPurchase_filter): [BondPurchase!] -} - -input OwnerTokenTbv_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - owner: String - owner_not: String - owner_gt: String - owner_lt: String - owner_gte: String - owner_lte: String - owner_in: [String!] - owner_not_in: [String!] - owner_contains: String - owner_contains_nocase: String - owner_not_contains: String - owner_not_contains_nocase: String - owner_starts_with: String - owner_starts_with_nocase: String - owner_not_starts_with: String - owner_not_starts_with_nocase: String - owner_ends_with: String - owner_ends_with_nocase: String - owner_not_ends_with: String - owner_not_ends_with_nocase: String - token: String - token_not: String - token_gt: String - token_lt: String - token_gte: String - token_lte: String - token_in: [String!] - token_not_in: [String!] - token_contains: String - token_contains_nocase: String - token_not_contains: String - token_not_contains_nocase: String - token_starts_with: String - token_starts_with_nocase: String - token_not_starts_with: String - token_not_starts_with_nocase: String - token_ends_with: String - token_ends_with_nocase: String - token_not_ends_with: String - token_not_ends_with_nocase: String - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - tbv: BigDecimal - tbv_not: BigDecimal - tbv_gt: BigDecimal - tbv_lt: BigDecimal - tbv_gte: BigDecimal - tbv_lte: BigDecimal - tbv_in: [BigDecimal!] - tbv_not_in: [BigDecimal!] - bondPurchases_: BondPurchase_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [OwnerTokenTbv_filter] - or: [OwnerTokenTbv_filter] -} - -enum OwnerTokenTbv_orderBy { - id - owner - token - network - chainId - tbv - bondPurchases -} - -"The Pair entity stores references to the Tokens which make up a Uniswap-V2 or similar LP Pair.\n" -type Pair { - "The address of the LP pair.\n**NOTE** for consistency, this should probably be updated to append the chainId, as Token and BalancerWeightedPool do.\n" - id: String! - - "A reference to the Token record for the LP pair's token0.\n" - token0: Token! - - "A reference to the Token record for the LP pair's token1.\n" - token1: Token! -} - -input Pair_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - token0: String - token0_not: String - token0_gt: String - token0_lt: String - token0_gte: String - token0_lte: String - token0_in: [String!] - token0_not_in: [String!] - token0_contains: String - token0_contains_nocase: String - token0_not_contains: String - token0_not_contains_nocase: String - token0_starts_with: String - token0_starts_with_nocase: String - token0_not_starts_with: String - token0_not_starts_with_nocase: String - token0_ends_with: String - token0_ends_with_nocase: String - token0_not_ends_with: String - token0_not_ends_with_nocase: String - token0_: Token_filter - token1: String - token1_not: String - token1_gt: String - token1_lt: String - token1_gte: String - token1_lte: String - token1_in: [String!] - token1_not_in: [String!] - token1_contains: String - token1_contains_nocase: String - token1_not_contains: String - token1_not_contains_nocase: String - token1_starts_with: String - token1_starts_with_nocase: String - token1_not_starts_with: String - token1_not_starts_with_nocase: String - token1_ends_with: String - token1_ends_with_nocase: String - token1_not_ends_with: String - token1_not_ends_with_nocase: String - token1_: Token_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [Pair_filter] - or: [Pair_filter] -} - -enum Pair_orderBy { - id - token0 - token0__id - token0__network - token0__chainId - token0__address - token0__decimals - token0__symbol - token0__name - token0__typeName - token0__usedAsPayout - token0__usedAsQuote - token0__totalPayoutAmount - token0__purchaseCount - token1 - token1__id - token1__network - token1__chainId - token1__address - token1__decimals - token1__symbol - token1__name - token1__typeName - token1__usedAsPayout - token1__usedAsQuote - token1__totalPayoutAmount - token1__purchaseCount -} - -type PayoutToken { - id: String! -} - -"The PayoutTokenTbv entity tracks the total of each quote token received in exchange for the given payout token.\n" -type PayoutTokenTbv { - "Unique ID for the PayoutTokenTbv entity, in the format:\n[chainId]_[payout token address]__[quote token id]\n**NOTE** the Token ID also appends the chain ID before the token address, so the chain ID will appear once at the start of the OwnerTokenTbv ID and once in the quote token subsection of the ID.\n" - id: String! - - "The payout Token address for which TBV is being calculated.\n" - payoutToken: Token! - - "The quote Token for which TBV is being calculated.\n" - quoteToken: Token! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The amount of the quote token received across the owner's markets.\n" - tbv: BigDecimal! - - "A list of BondPurchase records in which the owner has received the quote token.\n" - bondPurchases(skip: Int = 0, first: Int = 100, orderBy: BondPurchase_orderBy, orderDirection: OrderDirection, where: BondPurchase_filter): [BondPurchase!] -} - -input PayoutTokenTbv_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - payoutToken: String - payoutToken_not: String - payoutToken_gt: String - payoutToken_lt: String - payoutToken_gte: String - payoutToken_lte: String - payoutToken_in: [String!] - payoutToken_not_in: [String!] - payoutToken_contains: String - payoutToken_contains_nocase: String - payoutToken_not_contains: String - payoutToken_not_contains_nocase: String - payoutToken_starts_with: String - payoutToken_starts_with_nocase: String - payoutToken_not_starts_with: String - payoutToken_not_starts_with_nocase: String - payoutToken_ends_with: String - payoutToken_ends_with_nocase: String - payoutToken_not_ends_with: String - payoutToken_not_ends_with_nocase: String - payoutToken_: Token_filter - quoteToken: String - quoteToken_not: String - quoteToken_gt: String - quoteToken_lt: String - quoteToken_gte: String - quoteToken_lte: String - quoteToken_in: [String!] - quoteToken_not_in: [String!] - quoteToken_contains: String - quoteToken_contains_nocase: String - quoteToken_not_contains: String - quoteToken_not_contains_nocase: String - quoteToken_starts_with: String - quoteToken_starts_with_nocase: String - quoteToken_not_starts_with: String - quoteToken_not_starts_with_nocase: String - quoteToken_ends_with: String - quoteToken_ends_with_nocase: String - quoteToken_not_ends_with: String - quoteToken_not_ends_with_nocase: String - quoteToken_: Token_filter - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - tbv: BigDecimal - tbv_not: BigDecimal - tbv_gt: BigDecimal - tbv_lt: BigDecimal - tbv_gte: BigDecimal - tbv_lte: BigDecimal - tbv_in: [BigDecimal!] - tbv_not_in: [BigDecimal!] - bondPurchases_: BondPurchase_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [PayoutTokenTbv_filter] - or: [PayoutTokenTbv_filter] -} - -enum PayoutTokenTbv_orderBy { - id - payoutToken - payoutToken__id - payoutToken__network - payoutToken__chainId - payoutToken__address - payoutToken__decimals - payoutToken__symbol - payoutToken__name - payoutToken__typeName - payoutToken__usedAsPayout - payoutToken__usedAsQuote - payoutToken__totalPayoutAmount - payoutToken__purchaseCount - quoteToken - quoteToken__id - quoteToken__network - quoteToken__chainId - quoteToken__address - quoteToken__decimals - quoteToken__symbol - quoteToken__name - quoteToken__typeName - quoteToken__usedAsPayout - quoteToken__usedAsQuote - quoteToken__totalPayoutAmount - quoteToken__purchaseCount - network - chainId - tbv - bondPurchases -} - -input PayoutToken_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [PayoutToken_filter] - or: [PayoutToken_filter] -} - -enum PayoutToken_orderBy { - id -} - -"Workaround due to no simple entity count being available.\n" -type PurchaseCount { - "There should only be one PurchaseCount entry, with id \"purchase-count\".\n" - id: String! - - "The total number of bond purchases across all markets on this chain.\n" - count: BigInt! -} - -input PurchaseCount_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - count: BigInt - count_not: BigInt - count_gt: BigInt - count_lt: BigInt - count_gte: BigInt - count_lte: BigInt - count_in: [BigInt!] - count_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [PurchaseCount_filter] - or: [PurchaseCount_filter] -} - -enum PurchaseCount_orderBy { - id - count -} - -type Query { - ownerBalance( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): OwnerBalance - ownerBalances( - skip: Int = 0 - first: Int = 100 - orderBy: OwnerBalance_orderBy - orderDirection: OrderDirection - where: OwnerBalance_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [OwnerBalance!]! - uniqueBonder( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueBonder - uniqueBonders( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueBonder_orderBy - orderDirection: OrderDirection - where: UniqueBonder_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueBonder!]! - uniqueBonderCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueBonderCount - uniqueBonderCounts( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueBonderCount_orderBy - orderDirection: OrderDirection - where: UniqueBonderCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueBonderCount!]! - uniqueTokenBonder( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueTokenBonder - uniqueTokenBonders( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueTokenBonder_orderBy - orderDirection: OrderDirection - where: UniqueTokenBonder_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueTokenBonder!]! - uniqueTokenBonderCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueTokenBonderCount - uniqueTokenBonderCounts( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueTokenBonderCount_orderBy - orderDirection: OrderDirection - where: UniqueTokenBonderCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueTokenBonderCount!]! - bondToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BondToken - bondTokens( - skip: Int = 0 - first: Int = 100 - orderBy: BondToken_orderBy - orderDirection: OrderDirection - where: BondToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BondToken!]! - ownerTokenTbv( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): OwnerTokenTbv - ownerTokenTbvs( - skip: Int = 0 - first: Int = 100 - orderBy: OwnerTokenTbv_orderBy - orderDirection: OrderDirection - where: OwnerTokenTbv_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [OwnerTokenTbv!]! - payoutTokenTbv( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PayoutTokenTbv - payoutTokenTbvs( - skip: Int = 0 - first: Int = 100 - orderBy: PayoutTokenTbv_orderBy - orderDirection: OrderDirection - where: PayoutTokenTbv_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PayoutTokenTbv!]! - bondPurchase( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BondPurchase - bondPurchases( - skip: Int = 0 - first: Int = 100 - orderBy: BondPurchase_orderBy - orderDirection: OrderDirection - where: BondPurchase_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BondPurchase!]! - token( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Token - tokens( - skip: Int = 0 - first: Int = 100 - orderBy: Token_orderBy - orderDirection: OrderDirection - where: Token_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Token!]! - market( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Market - markets( - skip: Int = 0 - first: Int = 100 - orderBy: Market_orderBy - orderDirection: OrderDirection - where: Market_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Market!]! - pair( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Pair - pairs( - skip: Int = 0 - first: Int = 100 - orderBy: Pair_orderBy - orderDirection: OrderDirection - where: Pair_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Pair!]! - balancerWeightedPool( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BalancerWeightedPool - balancerWeightedPools( - skip: Int = 0 - first: Int = 100 - orderBy: BalancerWeightedPool_orderBy - orderDirection: OrderDirection - where: BalancerWeightedPool_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BalancerWeightedPool!]! - tune( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Tune - tunes( - skip: Int = 0 - first: Int = 100 - orderBy: Tune_orderBy - orderDirection: OrderDirection - where: Tune_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Tune!]! - purchaseCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PurchaseCount - purchaseCounts( - skip: Int = 0 - first: Int = 100 - orderBy: PurchaseCount_orderBy - orderDirection: OrderDirection - where: PurchaseCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PurchaseCount!]! - marketOwnerCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): MarketOwnerCount - marketOwnerCounts( - skip: Int = 0 - first: Int = 100 - orderBy: MarketOwnerCount_orderBy - orderDirection: OrderDirection - where: MarketOwnerCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [MarketOwnerCount!]! - payoutToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PayoutToken - payoutTokens( - skip: Int = 0 - first: Int = 100 - orderBy: PayoutToken_orderBy - orderDirection: OrderDirection - where: PayoutToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PayoutToken!]! - quoteToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): QuoteToken - quoteTokens( - skip: Int = 0 - first: Int = 100 - orderBy: QuoteToken_orderBy - orderDirection: OrderDirection - where: QuoteToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [QuoteToken!]! - - """Access to subgraph metadata""" - _meta(block: Block_height): _Meta_ -} - -type QuoteToken { - id: String! -} - -input QuoteToken_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [QuoteToken_filter] - or: [QuoteToken_filter] -} - -enum QuoteToken_orderBy { - id -} - -type Subscription { - ownerBalance( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): OwnerBalance - ownerBalances( - skip: Int = 0 - first: Int = 100 - orderBy: OwnerBalance_orderBy - orderDirection: OrderDirection - where: OwnerBalance_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [OwnerBalance!]! - uniqueBonder( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueBonder - uniqueBonders( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueBonder_orderBy - orderDirection: OrderDirection - where: UniqueBonder_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueBonder!]! - uniqueBonderCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueBonderCount - uniqueBonderCounts( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueBonderCount_orderBy - orderDirection: OrderDirection - where: UniqueBonderCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueBonderCount!]! - uniqueTokenBonder( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueTokenBonder - uniqueTokenBonders( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueTokenBonder_orderBy - orderDirection: OrderDirection - where: UniqueTokenBonder_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueTokenBonder!]! - uniqueTokenBonderCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): UniqueTokenBonderCount - uniqueTokenBonderCounts( - skip: Int = 0 - first: Int = 100 - orderBy: UniqueTokenBonderCount_orderBy - orderDirection: OrderDirection - where: UniqueTokenBonderCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [UniqueTokenBonderCount!]! - bondToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BondToken - bondTokens( - skip: Int = 0 - first: Int = 100 - orderBy: BondToken_orderBy - orderDirection: OrderDirection - where: BondToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BondToken!]! - ownerTokenTbv( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): OwnerTokenTbv - ownerTokenTbvs( - skip: Int = 0 - first: Int = 100 - orderBy: OwnerTokenTbv_orderBy - orderDirection: OrderDirection - where: OwnerTokenTbv_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [OwnerTokenTbv!]! - payoutTokenTbv( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PayoutTokenTbv - payoutTokenTbvs( - skip: Int = 0 - first: Int = 100 - orderBy: PayoutTokenTbv_orderBy - orderDirection: OrderDirection - where: PayoutTokenTbv_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PayoutTokenTbv!]! - bondPurchase( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BondPurchase - bondPurchases( - skip: Int = 0 - first: Int = 100 - orderBy: BondPurchase_orderBy - orderDirection: OrderDirection - where: BondPurchase_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BondPurchase!]! - token( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Token - tokens( - skip: Int = 0 - first: Int = 100 - orderBy: Token_orderBy - orderDirection: OrderDirection - where: Token_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Token!]! - market( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Market - markets( - skip: Int = 0 - first: Int = 100 - orderBy: Market_orderBy - orderDirection: OrderDirection - where: Market_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Market!]! - pair( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Pair - pairs( - skip: Int = 0 - first: Int = 100 - orderBy: Pair_orderBy - orderDirection: OrderDirection - where: Pair_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Pair!]! - balancerWeightedPool( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): BalancerWeightedPool - balancerWeightedPools( - skip: Int = 0 - first: Int = 100 - orderBy: BalancerWeightedPool_orderBy - orderDirection: OrderDirection - where: BalancerWeightedPool_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [BalancerWeightedPool!]! - tune( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): Tune - tunes( - skip: Int = 0 - first: Int = 100 - orderBy: Tune_orderBy - orderDirection: OrderDirection - where: Tune_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [Tune!]! - purchaseCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PurchaseCount - purchaseCounts( - skip: Int = 0 - first: Int = 100 - orderBy: PurchaseCount_orderBy - orderDirection: OrderDirection - where: PurchaseCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PurchaseCount!]! - marketOwnerCount( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): MarketOwnerCount - marketOwnerCounts( - skip: Int = 0 - first: Int = 100 - orderBy: MarketOwnerCount_orderBy - orderDirection: OrderDirection - where: MarketOwnerCount_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [MarketOwnerCount!]! - payoutToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): PayoutToken - payoutTokens( - skip: Int = 0 - first: Int = 100 - orderBy: PayoutToken_orderBy - orderDirection: OrderDirection - where: PayoutToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [PayoutToken!]! - quoteToken( - id: ID! - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): QuoteToken - quoteTokens( - skip: Int = 0 - first: Int = 100 - orderBy: QuoteToken_orderBy - orderDirection: OrderDirection - where: QuoteToken_filter - - """ - The block at which the query should be executed. Can either be a `{ hash: Bytes }` value containing a block hash, a `{ number: Int }` containing the block number, or a `{ number_gte: Int }` containing the minimum block number. In the case of `number_gte`, the query will be executed on the latest block only if the subgraph has progressed to or past the minimum block number. Defaults to the latest block when omitted. - """ - block: Block_height - - """ - Set to `allow` to receive data even if the subgraph has skipped over errors while syncing. - """ - subgraphError: _SubgraphErrorPolicy_! = deny - ): [QuoteToken!]! - - """Access to subgraph metadata""" - _meta(block: Block_height): _Meta_ -} - -"A string representation of microseconds UNIX timestamp (16 digits)\n" -scalar Timestamp - -"The Token entity tracks all payout and quote tokens, including LP pairs, Balancer Pools etc and their constituent tokens.\n" -type Token { - "Unique ID for the Token entity, in the format:\n[chainId]_[token address]\n" - id: String! - - "The network name, as used by Graph Protocol.\n**NOTE** This may not be the same as the name as used by wallets.\nAs such, we use the chainId field to identify networks in our frontend.\n" - network: String! - - "The numeric chain ID on which the contracts are deployed.\n" - chainId: BigInt! - - "The address of the Token.\n" - address: String! - - "The number of decimals for the Token.\n" - decimals: BigInt! - - "The Token symbol.\n" - symbol: String! - - "The Token name.\n" - name: String! - - "The smart contract (as opposed to token) name - e.g. \"ERC20\", \"SLP\", \"BalancerWeightedPool\".\n" - typeName: String! - - "A reference to the Pair record, if the Token is a Uniswap-V2 (or compatible) LP token, null if it is not.\n" - lpPair: Pair - - "A reference to the BalancerWeightedPool record, if the Token is a BalancerWeightedPool, or null if it is not.\n" - balancerWeightedPool: BalancerWeightedPool - - "Whether the Token has been used as a Payout Token for any Markets\n" - usedAsPayout: Boolean! - - "Whether the Token has been used as a Quote Token for any Markets\n" - usedAsQuote: Boolean! - - "The amount of the this token paid out across the owner's markets.\n" - totalPayoutAmount: BigDecimal! - - "The total number of times this Token has been purchased on this chain.\n" - purchaseCount: BigInt! - - "A list of PayoutTokenTbv for this Token.\n" - payoutTokenTbvs(skip: Int = 0, first: Int = 100, orderBy: PayoutTokenTbv_orderBy, orderDirection: OrderDirection, where: PayoutTokenTbv_filter): [PayoutTokenTbv!] - - "The UniqueTokenBonderCount for this Token\n" - uniqueBonders: UniqueTokenBonderCount - - "Markets for this Token\n" - markets(skip: Int = 0, first: Int = 100, orderBy: Market_orderBy, orderDirection: OrderDirection, where: Market_filter): [Market!] -} - -input Token_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - network: String - network_not: String - network_gt: String - network_lt: String - network_gte: String - network_lte: String - network_in: [String!] - network_not_in: [String!] - network_contains: String - network_contains_nocase: String - network_not_contains: String - network_not_contains_nocase: String - network_starts_with: String - network_starts_with_nocase: String - network_not_starts_with: String - network_not_starts_with_nocase: String - network_ends_with: String - network_ends_with_nocase: String - network_not_ends_with: String - network_not_ends_with_nocase: String - chainId: BigInt - chainId_not: BigInt - chainId_gt: BigInt - chainId_lt: BigInt - chainId_gte: BigInt - chainId_lte: BigInt - chainId_in: [BigInt!] - chainId_not_in: [BigInt!] - address: String - address_not: String - address_gt: String - address_lt: String - address_gte: String - address_lte: String - address_in: [String!] - address_not_in: [String!] - address_contains: String - address_contains_nocase: String - address_not_contains: String - address_not_contains_nocase: String - address_starts_with: String - address_starts_with_nocase: String - address_not_starts_with: String - address_not_starts_with_nocase: String - address_ends_with: String - address_ends_with_nocase: String - address_not_ends_with: String - address_not_ends_with_nocase: String - decimals: BigInt - decimals_not: BigInt - decimals_gt: BigInt - decimals_lt: BigInt - decimals_gte: BigInt - decimals_lte: BigInt - decimals_in: [BigInt!] - decimals_not_in: [BigInt!] - symbol: String - symbol_not: String - symbol_gt: String - symbol_lt: String - symbol_gte: String - symbol_lte: String - symbol_in: [String!] - symbol_not_in: [String!] - symbol_contains: String - symbol_contains_nocase: String - symbol_not_contains: String - symbol_not_contains_nocase: String - symbol_starts_with: String - symbol_starts_with_nocase: String - symbol_not_starts_with: String - symbol_not_starts_with_nocase: String - symbol_ends_with: String - symbol_ends_with_nocase: String - symbol_not_ends_with: String - symbol_not_ends_with_nocase: String - name: String - name_not: String - name_gt: String - name_lt: String - name_gte: String - name_lte: String - name_in: [String!] - name_not_in: [String!] - name_contains: String - name_contains_nocase: String - name_not_contains: String - name_not_contains_nocase: String - name_starts_with: String - name_starts_with_nocase: String - name_not_starts_with: String - name_not_starts_with_nocase: String - name_ends_with: String - name_ends_with_nocase: String - name_not_ends_with: String - name_not_ends_with_nocase: String - typeName: String - typeName_not: String - typeName_gt: String - typeName_lt: String - typeName_gte: String - typeName_lte: String - typeName_in: [String!] - typeName_not_in: [String!] - typeName_contains: String - typeName_contains_nocase: String - typeName_not_contains: String - typeName_not_contains_nocase: String - typeName_starts_with: String - typeName_starts_with_nocase: String - typeName_not_starts_with: String - typeName_not_starts_with_nocase: String - typeName_ends_with: String - typeName_ends_with_nocase: String - typeName_not_ends_with: String - typeName_not_ends_with_nocase: String - lpPair: String - lpPair_not: String - lpPair_gt: String - lpPair_lt: String - lpPair_gte: String - lpPair_lte: String - lpPair_in: [String!] - lpPair_not_in: [String!] - lpPair_contains: String - lpPair_contains_nocase: String - lpPair_not_contains: String - lpPair_not_contains_nocase: String - lpPair_starts_with: String - lpPair_starts_with_nocase: String - lpPair_not_starts_with: String - lpPair_not_starts_with_nocase: String - lpPair_ends_with: String - lpPair_ends_with_nocase: String - lpPair_not_ends_with: String - lpPair_not_ends_with_nocase: String - lpPair_: Pair_filter - balancerWeightedPool: String - balancerWeightedPool_not: String - balancerWeightedPool_gt: String - balancerWeightedPool_lt: String - balancerWeightedPool_gte: String - balancerWeightedPool_lte: String - balancerWeightedPool_in: [String!] - balancerWeightedPool_not_in: [String!] - balancerWeightedPool_contains: String - balancerWeightedPool_contains_nocase: String - balancerWeightedPool_not_contains: String - balancerWeightedPool_not_contains_nocase: String - balancerWeightedPool_starts_with: String - balancerWeightedPool_starts_with_nocase: String - balancerWeightedPool_not_starts_with: String - balancerWeightedPool_not_starts_with_nocase: String - balancerWeightedPool_ends_with: String - balancerWeightedPool_ends_with_nocase: String - balancerWeightedPool_not_ends_with: String - balancerWeightedPool_not_ends_with_nocase: String - balancerWeightedPool_: BalancerWeightedPool_filter - usedAsPayout: Boolean - usedAsPayout_not: Boolean - usedAsPayout_in: [Boolean!] - usedAsPayout_not_in: [Boolean!] - usedAsQuote: Boolean - usedAsQuote_not: Boolean - usedAsQuote_in: [Boolean!] - usedAsQuote_not_in: [Boolean!] - totalPayoutAmount: BigDecimal - totalPayoutAmount_not: BigDecimal - totalPayoutAmount_gt: BigDecimal - totalPayoutAmount_lt: BigDecimal - totalPayoutAmount_gte: BigDecimal - totalPayoutAmount_lte: BigDecimal - totalPayoutAmount_in: [BigDecimal!] - totalPayoutAmount_not_in: [BigDecimal!] - purchaseCount: BigInt - purchaseCount_not: BigInt - purchaseCount_gt: BigInt - purchaseCount_lt: BigInt - purchaseCount_gte: BigInt - purchaseCount_lte: BigInt - purchaseCount_in: [BigInt!] - purchaseCount_not_in: [BigInt!] - payoutTokenTbvs_: PayoutTokenTbv_filter - uniqueBonders_: UniqueTokenBonderCount_filter - markets_: Market_filter - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [Token_filter] - or: [Token_filter] -} - -enum Token_orderBy { - id - network - chainId - address - decimals - symbol - name - typeName - lpPair - lpPair__id - balancerWeightedPool - balancerWeightedPool__id - balancerWeightedPool__vaultAddress - balancerWeightedPool__poolId - usedAsPayout - usedAsQuote - totalPayoutAmount - purchaseCount - payoutTokenTbvs - uniqueBonders - uniqueBonders__id - uniqueBonders__count - markets -} - -"The Tune entity tracks Market tuning events.\n" -type Tune { - "The ID of the Market to which the event relates.\n" - id: String! - - "A reference to the related Market record.\n" - market: Market! - - "The pre-tuning value of the control variable.\n" - oldControlVariable: BigInt! - - "The post-tuning value of the control variable.\n" - newControlVariable: BigInt! - - "The difference between the old and new control variables.\noldControlVariable - newControlVariable\n" - deltaTime: BigInt! - - "The timestamp at which the tuning event occurred.\n" - timestamp: BigInt! -} - -input Tune_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - market: String - market_not: String - market_gt: String - market_lt: String - market_gte: String - market_lte: String - market_in: [String!] - market_not_in: [String!] - market_contains: String - market_contains_nocase: String - market_not_contains: String - market_not_contains_nocase: String - market_starts_with: String - market_starts_with_nocase: String - market_not_starts_with: String - market_not_starts_with_nocase: String - market_ends_with: String - market_ends_with_nocase: String - market_not_ends_with: String - market_not_ends_with_nocase: String - market_: Market_filter - oldControlVariable: BigInt - oldControlVariable_not: BigInt - oldControlVariable_gt: BigInt - oldControlVariable_lt: BigInt - oldControlVariable_gte: BigInt - oldControlVariable_lte: BigInt - oldControlVariable_in: [BigInt!] - oldControlVariable_not_in: [BigInt!] - newControlVariable: BigInt - newControlVariable_not: BigInt - newControlVariable_gt: BigInt - newControlVariable_lt: BigInt - newControlVariable_gte: BigInt - newControlVariable_lte: BigInt - newControlVariable_in: [BigInt!] - newControlVariable_not_in: [BigInt!] - deltaTime: BigInt - deltaTime_not: BigInt - deltaTime_gt: BigInt - deltaTime_lt: BigInt - deltaTime_gte: BigInt - deltaTime_lte: BigInt - deltaTime_in: [BigInt!] - deltaTime_not_in: [BigInt!] - timestamp: BigInt - timestamp_not: BigInt - timestamp_gt: BigInt - timestamp_lt: BigInt - timestamp_gte: BigInt - timestamp_lte: BigInt - timestamp_in: [BigInt!] - timestamp_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [Tune_filter] - or: [Tune_filter] -} - -enum Tune_orderBy { - id - market - market__id - market__name - market__type - market__network - market__chainId - market__auctioneer - market__teller - market__marketId - market__owner - market__vesting - market__start - market__conclusion - market__vestingType - market__isInstantSwap - market__hasClosed - market__totalBondedAmount - market__totalPayoutAmount - market__creationBlockTimestamp - market__callbackAddress - market__capacity - market__capacityInQuote - market__minPrice - market__price - market__scale - market__averageBondPrice - market__bondsIssued - oldControlVariable - newControlVariable - deltaTime - timestamp -} - -"A UniqueBonder record is created for each unique combination of chain, market owner, bond purchaser.\n" -type UniqueBonder { - "Unique ID for the UniqueBonder entity, in the format:\n[chainId]_[Market owner address]__[bond purchaser address]\n" - id: String! -} - -"Workaround due to no simple entity count being available.\n" -type UniqueBonderCount { - "There should be one UniqueBonderCount entry per market owner, with owner address as id.\n" - id: String! - - "The total number of unique bonders for this token on this chain.\n" - count: BigInt! -} - -input UniqueBonderCount_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - count: BigInt - count_not: BigInt - count_gt: BigInt - count_lt: BigInt - count_gte: BigInt - count_lte: BigInt - count_in: [BigInt!] - count_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [UniqueBonderCount_filter] - or: [UniqueBonderCount_filter] -} - -enum UniqueBonderCount_orderBy { - id - count -} - -input UniqueBonder_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [UniqueBonder_filter] - or: [UniqueBonder_filter] -} - -enum UniqueBonder_orderBy { - id -} - -"A UniqueTokenBonder record is created for each unique combination of chain, payout token address, bond purchaser.\n" -type UniqueTokenBonder { - "Unique ID for the UniqueTokenBonder entity, in the format:\n[chainId]_[payout token address]__[bond purchaser address]\n" - id: String! -} - -"Workaround due to no simple entity count being available.\n" -type UniqueTokenBonderCount { - "There should be one UniqueTokenBonderCount entry per token, with token address as id.\n" - id: String! - - "The token for which bonders are being counted.\n" - token: Token! - - "The total number of unique bonders for this token on this chain.\n" - count: BigInt! -} - -input UniqueTokenBonderCount_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - token: String - token_not: String - token_gt: String - token_lt: String - token_gte: String - token_lte: String - token_in: [String!] - token_not_in: [String!] - token_contains: String - token_contains_nocase: String - token_not_contains: String - token_not_contains_nocase: String - token_starts_with: String - token_starts_with_nocase: String - token_not_starts_with: String - token_not_starts_with_nocase: String - token_ends_with: String - token_ends_with_nocase: String - token_not_ends_with: String - token_not_ends_with_nocase: String - token_: Token_filter - count: BigInt - count_not: BigInt - count_gt: BigInt - count_lt: BigInt - count_gte: BigInt - count_lte: BigInt - count_in: [BigInt!] - count_not_in: [BigInt!] - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [UniqueTokenBonderCount_filter] - or: [UniqueTokenBonderCount_filter] -} - -enum UniqueTokenBonderCount_orderBy { - id - token - token__id - token__network - token__chainId - token__address - token__decimals - token__symbol - token__name - token__typeName - token__usedAsPayout - token__usedAsQuote - token__totalPayoutAmount - token__purchaseCount - count -} - -input UniqueTokenBonder_filter { - id: String - id_not: String - id_gt: String - id_lt: String - id_gte: String - id_lte: String - id_in: [String!] - id_not_in: [String!] - id_contains: String - id_contains_nocase: String - id_not_contains: String - id_not_contains_nocase: String - id_starts_with: String - id_starts_with_nocase: String - id_not_starts_with: String - id_not_starts_with_nocase: String - id_ends_with: String - id_ends_with_nocase: String - id_not_ends_with: String - id_not_ends_with_nocase: String - - """Filter for the block changed event.""" - _change_block: BlockChangedFilter - and: [UniqueTokenBonder_filter] - or: [UniqueTokenBonder_filter] -} - -enum UniqueTokenBonder_orderBy { - id -} - -type _Block_ { - """The hash of the block""" - hash: Bytes - - """The block number""" - number: Int! - - """Integer representation of the timestamp stored in blocks for the chain""" - timestamp: Int - - """The hash of the parent block""" - parentHash: Bytes -} - -"""The type for the top-level _meta field""" -type _Meta_ { - "Information about a specific subgraph block. The hash of the block\nwill be null if the _meta field has a block constraint that asks for\na block number. It will be filled if the _meta field has no block constraint\nand therefore asks for the latest block\n" - block: _Block_! - - """The deployment ID""" - deployment: String! - - """If `true`, the subgraph encountered indexing errors at some past block""" - hasIndexingErrors: Boolean! -} - -enum _SubgraphErrorPolicy_ { - """Data will be returned even if the subgraph has indexing errors""" - allow - - """ - If the subgraph has indexing errors, data will be omitted. The default. - """ - deny -} \ No newline at end of file diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/index.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/index.ts index 3df01c716a..9f8aa65d0a 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/index.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/index.ts @@ -1,3 +1,4 @@ +export * from './pool-addresses' export * from './pools' export * from './top-evm-pools' export * from './top-non-evm-pools' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts new file mode 100644 index 0000000000..b9ba9c6196 --- /dev/null +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts @@ -0,0 +1,42 @@ +import type { VariablesOf } from 'gql.tada' +import { type RequestOptions, request } from 'src/lib/request' +import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { graphql } from '../../graphql' +import { SUSHI_REQUEST_HEADERS } from '../../request-headers' + +export const PoolAddressesQuery = graphql( + ` + query PoolAddresses($chainId: PoolChainId!, $protocols: [Protocol]) { + poolAddresses(chainId: $chainId, protocols: $protocols) + } +`, +) + +export type GetPoolAddresses = VariablesOf + +export async function getPoolAddresses( + variables: GetPoolAddresses, + options?: RequestOptions, +) { + const url = `${SUSHI_DATA_API_HOST}/graphql` + try { + const result = await request( + { + url, + document: PoolAddressesQuery, + variables, + requestHeaders: SUSHI_REQUEST_HEADERS, + }, + options, + ) + if (result) { + return result.poolAddresses + } + } catch (error) { + console.error('getPoolAddresses error', error) + } + + throw new Error('getPoolAddresses error') +} + +export type PoolAddressesResponse = Awaited> diff --git a/packages/graph-client/src/subgraphs/data-api/schema.graphql b/packages/graph-client/src/subgraphs/data-api/schema.graphql index 55381942b7..5cc57ce12c 100644 --- a/packages/graph-client/src/subgraphs/data-api/schema.graphql +++ b/packages/graph-client/src/subgraphs/data-api/schema.graphql @@ -20,8 +20,8 @@ type SushiDayBuckets { type Query { sushiDayBuckets(chainId: SushiSwapChainId!): SushiDayBuckets! - protocolFeeAnalysis: ProtocolFeeAnalysis! pools(chainId: PoolChainId!, page: Int = 1, search: [String], protocols: [Protocol], onlyIncentivized: Boolean = false, onlySmartPools: Boolean = false, orderBy: PoolsOrderBy = liquidityUSD, orderDirection: OrderDirection = desc): Pools! + poolAddresses(chainId: PoolChainId!, protocols: [Protocol]): [Bytes!]! topPools(chainId: String!): [TopPool!]! v2Pool(address: Bytes!, chainId: SushiSwapV2ChainId!): V2Pool! v3Pool(address: Bytes!, chainId: SushiSwapV3ChainId!): V3Pool! @@ -42,9 +42,9 @@ type Query { sushiBarHistory: SushiBarHistory! tokenList(chainId: TokenListChainId!, first: Int = 50, skip: Int, search: String, customTokens: [Bytes!]): [TokenListEntry!]! tokenListBalances(chainId: TokenListChainId!, account: Bytes!, includeNative: Boolean = true, customTokens: [Bytes!]): [TokenListEntryWithBalance!]! - approvedCommunityTokens: [TokenListEntry!]! tokenAnalysis(chainId: Int!, address: Bytes!): TokenAnalysis! pendingTokens: [PendingToken!]! + approvedCommunityTokens: [ApprovedToken!]! trendingTokens(chainId: TrendingTokensChainId!): [TrendingToken!]! v2LiquidityPositions(user: Bytes!, chainId: SushiSwapV2ChainId!): [V2LiquidityPosition!]! v2Swaps(address: Bytes!, chainId: SushiSwapV2ChainId!): [V2Swap!]! @@ -58,36 +58,6 @@ type Query { v3Transactions(address: Bytes!, chainId: SushiSwapV3ChainId!): [V3Transaction!]! } -type NoFeePool { - address: String! - fee: Float! - name: String! - chainId: Int! - token0Address: String! - token1Address: String! - createdAtTimestamp: Int! - volumeUSD1d: Float! - liquidityUSD: Float! -} - -type FeeReport { - totalVolumeUSD1d: Float! - totalLiquidityUSD: Float! - missedRevenueUSD24h: Float! - estimatedAnnualRevenueUSD: Float! -} - -type ProtocolReportByChain { - chainId: Int! - pools: [NoFeePool!]! - report: FeeReport! -} - -type ProtocolFeeAnalysis { - chains: [ProtocolReportByChain!]! - report: FeeReport! -} - enum PoolsOrderBy { liquidityUSD volumeUSD1d @@ -694,8 +664,8 @@ type TokenAnalysis { type PendingToken { token: Token! - tweetUrl: String! logoUrl: String! + tweetUrl: String reasoning: [String!]! createdAt: Int! metrics: TokenValidationMetrics! @@ -732,6 +702,16 @@ type TokenSecurity { holderCount: Float! } +type ApprovedToken { + address: Bytes! + chainId: ChainId! + symbol: String! + name: String! + decimals: Int! + approved: Boolean! + logoUrl: String +} + type TrendingToken { address: Bytes! symbol: String! diff --git a/packages/graph-client/tsconfig.json b/packages/graph-client/tsconfig.json index 3850c6df86..9aca29ba2a 100644 --- a/packages/graph-client/tsconfig.json +++ b/packages/graph-client/tsconfig.json @@ -17,12 +17,6 @@ { "name": "@0no-co/graphqlsp", "schemas": [ - { - "name": "bonds", - "schema": "./src/subgraphs/bonds/schema.graphql", - "tadaOutputLocation": "./src/subgraphs/bonds/bonds-env.d.ts", - "tadaTurboLocation": "./src/subgraphs/bonds/bonds-cache.d.ts" - }, { "name": "bentobox", "schema": "./src/subgraphs/bentobox/schema.graphql", diff --git a/packages/steer-sdk/package.json b/packages/steer-sdk/package.json index 4284b447ce..14b9dacb54 100644 --- a/packages/steer-sdk/package.json +++ b/packages/steer-sdk/package.json @@ -54,7 +54,6 @@ }, "dependencies": { "@steerprotocol/contracts": "2.1.0-beta.14", - "@sushiswap/database": "workspace:*", "sushi": "4.0.5", "tslib": "latest", "viem": "2.21.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e393d5ddd..c97d039575 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -305,15 +305,6 @@ importers: '@snapshot-labs/snapshot.js': specifier: ^0.9.8 version: 0.9.9(bufferutil@4.0.8)(encoding@0.1.13)(utf-8-validate@5.0.10) - '@sushiswap/bonds-sdk': - specifier: workspace:* - version: link:../../packages/bonds-sdk - '@sushiswap/client': - specifier: workspace:* - version: link:../../packages/client - '@sushiswap/database': - specifier: workspace:* - version: link:../../packages/database '@sushiswap/graph-client': specifier: workspace:* version: link:../../packages/graph-client @@ -653,99 +644,6 @@ importers: config/typescript: {} - packages/bonds-sdk: - dependencies: - react: - specifier: 18.2.0 - version: 18.2.0 - react-dom: - specifier: 18.2.0 - version: 18.2.0(react@18.2.0) - sushi: - specifier: 4.0.2 - version: 4.0.2(viem@2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) - optionalDependencies: - next: - specifier: 14.2.11 - version: 14.2.11(@babel/core@7.24.4)(@opentelemetry/api@1.9.0)(@playwright/test@1.45.0)(babel-plugin-macros@3.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - devDependencies: - '@tsconfig/esm': - specifier: 1.0.4 - version: 1.0.4 - '@tsconfig/strictest': - specifier: 2.0.2 - version: 2.0.2 - '@types/node': - specifier: '20' - version: 20.14.14 - typescript: - specifier: 5.5.4 - version: 5.5.4 - viem: - specifier: 2.21.4 - version: 2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8) - - packages/client: - dependencies: - '@sushiswap/bonds-sdk': - specifier: workspace:* - version: link:../bonds-sdk - '@sushiswap/database': - specifier: workspace:* - version: link:../database - '@sushiswap/graph-client': - specifier: workspace:* - version: link:../graph-client - '@sushiswap/steer-sdk': - specifier: workspace:* - version: link:../steer-sdk - '@whatwg-node/fetch': - specifier: 0.8.4 - version: 0.8.4 - deepmerge-ts: - specifier: ^4.3.0 - version: 4.3.0 - sushi: - specifier: 4.0.5 - version: 4.0.5(typescript@5.5.4)(viem@2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) - tslib: - specifier: latest - version: 2.6.2 - viem: - specifier: 2.21.4 - version: 2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8) - zod: - specifier: 3.23.8 - version: 3.23.8 - devDependencies: - '@sushiswap/tokens-api': - specifier: workspace:* - version: link:../../apis/tokens - '@sushiswap/typescript-config': - specifier: workspace:* - version: link:../../config/typescript - '@tsconfig/esm': - specifier: 1.0.4 - version: 1.0.4 - '@tsconfig/strictest': - specifier: 2.0.2 - version: 2.0.2 - '@types/node': - specifier: '20' - version: 20.14.14 - react: - specifier: 18.2.0 - version: 18.2.0 - swr: - specifier: 2.1.5 - version: 2.1.5(react@18.2.0) - tsup: - specifier: 7.2.0 - version: 7.2.0(@swc/core@1.4.2)(postcss@8.4.44)(ts-node@10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4))(typescript@5.5.4) - typescript: - specifier: 5.5.4 - version: 5.5.4 - packages/database: dependencies: '@prisma/client': @@ -779,9 +677,6 @@ importers: packages/graph-client: dependencies: - '@sushiswap/bonds-sdk': - specifier: workspace:* - version: link:../bonds-sdk '@sushiswap/steer-sdk': specifier: workspace:* version: link:../steer-sdk @@ -807,9 +702,6 @@ importers: '@0no-co/graphqlsp': specifier: ^1.12.3 version: 1.12.3(graphql@16.6.0)(typescript@5.5.4) - '@sushiswap/database': - specifier: workspace:* - version: link:../database '@tsconfig/esm': specifier: 1.0.4 version: 1.0.4 @@ -920,9 +812,6 @@ importers: '@steerprotocol/contracts': specifier: 2.1.0-beta.14 version: 2.1.0-beta.14(bufferutil@4.0.8)(encoding@0.1.13)(squirrelly@8.0.8)(ts-node@10.9.2(@types/node@20.14.14)(typescript@5.5.4))(typescript@5.5.4)(utf-8-validate@5.0.10) - '@sushiswap/database': - specifier: workspace:* - version: link:../database sushi: specifier: 4.0.5 version: 4.0.5(typescript@5.5.4)(viem@2.21.4(typescript@5.5.4)(zod@3.23.8))(zod@3.23.8) @@ -5133,17 +5022,6 @@ packages: resolution: {integrity: sha512-pW7QaFiL11O0BphO+bq3MgqeX/INAk9jgBldVDYjlQPO4VddoZnF22TcF9onMhnLVHuNqBJeRf+Fj7eezi/+rQ==} engines: {node: '>= 10.0.0'} - '@peculiar/asn1-schema@2.3.6': - resolution: {integrity: sha512-izNRxPoaeJeg/AyH8hER6s+H7p4itk+03QCa4sbxI3lNdseQYCuxzgsuNK8bTXChtLTjpJz6NmXKA73qLa3rCA==} - - '@peculiar/json-schema@1.1.12': - resolution: {integrity: sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==} - engines: {node: '>=8.0.0'} - - '@peculiar/webcrypto@1.4.3': - resolution: {integrity: sha512-VtaY4spKTdN5LjJ04im/d/joXuvLbQdgy5Z4DXF4MFZhQ+MTrejbNMkfZBp1Bs3O5+bFqnJgyGdPuZQflvIa5A==} - engines: {node: '>=10.12.0'} - '@pedrouid/environment@1.0.1': resolution: {integrity: sha512-HaW78NszGzRZd9SeoI3JD11JqY+lubnaOx7Pewj5pfjqWXOEATpeKIFb9Z4t2WBUK2iryiXX3lzWwmYWgUL0Ug==} @@ -8416,15 +8294,6 @@ packages: '@webassemblyjs/wast-printer@1.12.1': resolution: {integrity: sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA==} - '@whatwg-node/events@0.0.3': - resolution: {integrity: sha512-IqnKIDWfXBJkvy/k6tzskWTc2NK3LcqHlb+KHGCrjOCH4jfQckRX0NAiIcC/vIqQkzLYw2r2CTSwAxcrtcD6lA==} - - '@whatwg-node/fetch@0.8.4': - resolution: {integrity: sha512-xK0NGWt49P+JmsdfN+8zmHzZoscENrV0KL1SyyncvWkc6vbFmSqGSpvItEBuhj1PAfTGFEUpyiRMCsut2hLy/Q==} - - '@whatwg-node/node-fetch@0.3.6': - resolution: {integrity: sha512-w9wKgDO4C95qnXZRwZTfCmLWqyRnooGjcIwG0wADWjw9/HN0p7dtvtgSvItZtUyNteEvgTrd8QojNEqV6DAGTA==} - '@xtuc/ieee754@1.2.0': resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} @@ -8790,10 +8659,6 @@ packages: asn1@0.2.6: resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} - asn1js@3.0.5: - resolution: {integrity: sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==} - engines: {node: '>=12.0.0'} - assert-plus@1.0.0: resolution: {integrity: sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==} engines: {node: '>=0.8'} @@ -9218,12 +9083,6 @@ packages: resolution: {integrity: sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==} engines: {node: '>=12'} - bundle-require@4.0.1: - resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - peerDependencies: - esbuild: '>=0.17' - busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -10241,10 +10100,6 @@ packages: deep-object-diff@1.1.9: resolution: {integrity: sha512-Rn+RuwkmkDwCi2/oXOFS9Gsr5lJZu/yTGpK7wAaAIE75CC+LCGEZHpY6VQJa/RoJcrmaA/docWJZvYohlNkWPA==} - deepmerge-ts@4.3.0: - resolution: {integrity: sha512-if3ZYdkD2dClhnXR5reKtG98cwyaRT1NeugQoAPTTfsOpV9kqyeiBF9Qa5RHjemb3KzD5ulqygv6ED3t5j9eJw==} - engines: {node: '>=12.4.0'} - deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} @@ -11538,9 +11393,6 @@ packages: resolution: {integrity: sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==} engines: {node: '> 0.1.90'} - fast-decode-uri-component@1.0.1: - resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} - fast-deep-equal@2.0.1: resolution: {integrity: sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==} @@ -11564,9 +11416,6 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - fast-querystring@1.1.2: - resolution: {integrity: sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==} - fast-redact@3.3.0: resolution: {integrity: sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ==} engines: {node: '>=6'} @@ -13231,10 +13080,6 @@ packages: joi@17.12.3: resolution: {integrity: sha512-2RRziagf555owrm9IRVtdKynOBeITiDpuZqIpgwqXShPncPKNiRQoiGsl/T8SQdq+8ugRzH2LqY67irr2y/d+g==} - joycon@3.1.1: - resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} - engines: {node: '>=10'} - js-base64@3.7.7: resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} @@ -13536,10 +13381,6 @@ packages: load-plugin@5.1.0: resolution: {integrity: sha512-Lg1CZa1CFj2CbNaxijTL6PCbzd4qGTlZov+iH2p5Xwy/ApcZJh+i6jMN2cYePouTfjJfrNu3nXFdEw8LvbjPFQ==} - load-tsconfig@0.2.5: - resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - loader-runner@4.3.0: resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} engines: {node: '>=6.11.5'} @@ -15628,13 +15469,6 @@ packages: pure-rand@6.0.2: resolution: {integrity: sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ==} - pvtsutils@1.3.4: - resolution: {integrity: sha512-Y2lmrVPui6d2U0n8lWRSTQ2Ri/0VDcA/BHAPS8/+5ElWp5drG4oPryLaqnehJT71Q2GgmGeB4mau+lSR1gCCmA==} - - pvutils@1.1.3: - resolution: {integrity: sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==} - engines: {node: '>=6.0.0'} - q@1.5.1: resolution: {integrity: sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==} engines: {node: '>=0.6.0', teleport: '>=0.2.0'} @@ -17811,22 +17645,6 @@ packages: tsort@0.0.1: resolution: {integrity: sha512-Tyrf5mxF8Ofs1tNoxA13lFeZ2Zrbd6cKbuH3V+MQ5sb6DtBj5FjrXVsRWT8YvNAQTqNoz66dz1WsbigI22aEnw==} - tsup@7.2.0: - resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} - engines: {node: '>=16.14'} - hasBin: true - peerDependencies: - '@swc/core': ^1 - postcss: ^8.4.12 - typescript: 5.5.4 - peerDependenciesMeta: - '@swc/core': - optional: true - postcss: - optional: true - typescript: - optional: true - tsutils@3.21.0: resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} @@ -18217,9 +18035,6 @@ packages: url-set-query@1.0.0: resolution: {integrity: sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==} - urlpattern-polyfill@6.0.2: - resolution: {integrity: sha512-5vZjFlH9ofROmuWmXM9yj2wljYKgWstGwe8YTyiqM7hVum/g9LyCizPZtb3UqsuppVwety9QJmfc42VggLpTgg==} - use-callback-ref@1.3.0: resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==} engines: {node: '>=10'} @@ -18516,10 +18331,6 @@ packages: wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} - web-streams-polyfill@3.2.1: - resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} - engines: {node: '>= 8'} - web-vitals@0.2.4: resolution: {integrity: sha512-6BjspCO9VriYy12z356nL6JBS0GYeEcA457YyRzD+dD6XYCQ75NKhcOHUMHentOE7OcVCIXXDvOm0jKFfQG2Gg==} @@ -18610,9 +18421,6 @@ packages: webauthn-p256@0.0.5: resolution: {integrity: sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg==} - webcrypto-core@1.7.7: - resolution: {integrity: sha512-7FjigXNsBfopEj+5DV2nhNpfic2vumtjjgPmeDKk45z+MJwXKKfhPB7118Pfzrmh4jqOMST6Ch37iPAHoImg5g==} - webextension-polyfill-ts@0.25.0: resolution: {integrity: sha512-ikQhwwHYkpBu00pFaUzIKY26I6L87DeRI+Q6jBT1daZUNuu8dSrg5U9l/ZbqdaQ1M/TTSPKeAa3kolP5liuedw==} deprecated: This project has moved to @types/webextension-polyfill @@ -24280,24 +24088,6 @@ snapshots: '@parcel/watcher-win32-ia32': 2.3.0 '@parcel/watcher-win32-x64': 2.3.0 - '@peculiar/asn1-schema@2.3.6': - dependencies: - asn1js: 3.0.5 - pvtsutils: 1.3.4 - tslib: 2.7.0 - - '@peculiar/json-schema@1.1.12': - dependencies: - tslib: 2.7.0 - - '@peculiar/webcrypto@1.4.3': - dependencies: - '@peculiar/asn1-schema': 2.3.6 - '@peculiar/json-schema': 1.1.12 - pvtsutils: 1.3.4 - tslib: 2.6.3 - webcrypto-core: 1.7.7 - '@pedrouid/environment@1.0.1': {} '@pkgjs/parseargs@0.11.0': @@ -29471,24 +29261,6 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@whatwg-node/events@0.0.3': {} - - '@whatwg-node/fetch@0.8.4': - dependencies: - '@peculiar/webcrypto': 1.4.3 - '@whatwg-node/node-fetch': 0.3.6 - busboy: 1.6.0 - urlpattern-polyfill: 6.0.2 - web-streams-polyfill: 3.2.1 - - '@whatwg-node/node-fetch@0.3.6': - dependencies: - '@whatwg-node/events': 0.0.3 - busboy: 1.6.0 - fast-querystring: 1.1.2 - fast-url-parser: 1.1.3 - tslib: 2.6.3 - '@xtuc/ieee754@1.2.0': {} '@xtuc/long@4.2.2': {} @@ -29950,12 +29722,6 @@ snapshots: dependencies: safer-buffer: 2.1.2 - asn1js@3.0.5: - dependencies: - pvtsutils: 1.3.4 - pvutils: 1.1.3 - tslib: 2.7.0 - assert-plus@1.0.0: {} assert@2.0.0: @@ -30492,11 +30258,6 @@ snapshots: dependencies: run-applescript: 5.0.0 - bundle-require@4.0.1(esbuild@0.18.20): - dependencies: - esbuild: 0.18.20 - load-tsconfig: 0.2.5 - busboy@1.6.0: dependencies: streamsearch: 1.1.0 @@ -31569,8 +31330,6 @@ snapshots: deep-object-diff@1.1.9: {} - deepmerge-ts@4.3.0: {} - deepmerge@4.3.1: {} default-browser-id@3.0.0: @@ -33415,8 +33174,6 @@ snapshots: eyes@0.1.8: {} - fast-decode-uri-component@1.0.1: {} - fast-deep-equal@2.0.1: {} fast-deep-equal@3.1.3: {} @@ -33443,10 +33200,6 @@ snapshots: fast-levenshtein@2.0.6: {} - fast-querystring@1.1.2: - dependencies: - fast-decode-uri-component: 1.0.1 - fast-redact@3.3.0: {} fast-safe-stringify@2.1.1: {} @@ -34178,7 +33931,7 @@ snapshots: uuid: 8.3.2 ws: 7.5.9(bufferutil@4.0.8)(utf-8-validate@5.0.10) optionalDependencies: - ts-node: 10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4) + ts-node: 10.9.2(@types/node@20.14.14)(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: - bufferutil @@ -35757,8 +35510,6 @@ snapshots: '@sideway/formula': 3.0.1 '@sideway/pinpoint': 2.0.0 - joycon@3.1.1: {} - js-base64@3.7.7: {} js-cookie@3.0.5: {} @@ -36171,8 +35922,6 @@ snapshots: '@npmcli/config': 6.4.0 import-meta-resolve: 2.2.2 - load-tsconfig@0.2.5: {} - loader-runner@4.3.0: {} loader-utils@2.0.4: @@ -38104,7 +37853,7 @@ snapshots: yaml: 2.4.1 optionalDependencies: postcss: 8.4.23 - ts-node: 10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4) + ts-node: 10.9.2(@types/node@20.14.14)(typescript@5.5.4) postcss-load-config@4.0.1(postcss@8.4.23)(ts-node@10.9.2(@types/node@22.1.0)(typescript@5.5.4)): dependencies: @@ -38114,14 +37863,6 @@ snapshots: postcss: 8.4.23 ts-node: 10.9.2(@types/node@22.1.0)(typescript@5.5.4) - postcss-load-config@4.0.1(postcss@8.4.44)(ts-node@10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4)): - dependencies: - lilconfig: 2.1.0 - yaml: 2.4.1 - optionalDependencies: - postcss: 8.4.44 - ts-node: 10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4) - postcss-loader@6.2.1(postcss@8.4.23)(webpack@5.91.0): dependencies: cosmiconfig: 7.1.0 @@ -38640,12 +38381,6 @@ snapshots: pure-rand@6.0.2: optional: true - pvtsutils@1.3.4: - dependencies: - tslib: 2.7.0 - - pvutils@1.1.3: {} - q@1.5.1: {} qr-code-styling@1.6.0-rc.1: @@ -40907,20 +40642,6 @@ snapshots: viem: 2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) zod: 3.23.8 - sushi@4.0.2(viem@2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8): - dependencies: - '@uniswap/token-lists': 1.0.0-beta.33 - big.js: 6.1.1 - date-fns: 3.3.1 - decimal.js-light: 2.5.1 - seedrandom: 3.0.5 - tiny-invariant: 1.3.1 - toformat: 2.0.0 - tsx: 4.19.0 - optionalDependencies: - viem: 2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8) - zod: 3.23.8 - sushi@4.0.5(typescript@5.5.4)(viem@2.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8): dependencies: '@uniswap/token-lists': 1.0.0-beta.33 @@ -41414,7 +41135,7 @@ snapshots: optionalDependencies: '@swc/core': 1.4.2 - ts-node@10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4): + ts-node@10.9.2(@types/node@20.14.14)(typescript@5.5.4): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 @@ -41431,8 +41152,6 @@ snapshots: typescript: 5.5.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - optionalDependencies: - '@swc/core': 1.4.2 optional: true ts-node@10.9.2(@types/node@22.1.0)(typescript@5.5.4): @@ -41493,30 +41212,6 @@ snapshots: tsort@0.0.1: {} - tsup@7.2.0(@swc/core@1.4.2)(postcss@8.4.44)(ts-node@10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4))(typescript@5.5.4): - dependencies: - bundle-require: 4.0.1(esbuild@0.18.20) - cac: 6.7.14 - chokidar: 3.5.3 - debug: 4.3.4(supports-color@8.1.1) - esbuild: 0.18.20 - execa: 5.1.1 - globby: 11.1.0 - joycon: 3.1.1 - postcss-load-config: 4.0.1(postcss@8.4.44)(ts-node@10.9.2(@swc/core@1.4.2)(@types/node@20.14.14)(typescript@5.5.4)) - resolve-from: 5.0.0 - rollup: 3.28.0 - source-map: 0.8.0-beta.0 - sucrase: 3.34.0 - tree-kill: 1.2.2 - optionalDependencies: - '@swc/core': 1.4.2 - postcss: 8.4.44 - typescript: 5.5.4 - transitivePeerDependencies: - - supports-color - - ts-node - tsutils@3.21.0(typescript@5.5.4): dependencies: tslib: 1.14.1 @@ -41947,10 +41642,6 @@ snapshots: url-set-query@1.0.0: {} - urlpattern-polyfill@6.0.2: - dependencies: - braces: 3.0.2 - use-callback-ref@1.3.0(@types/react@18.2.14)(react@18.2.0): dependencies: react: 18.2.0 @@ -42414,8 +42105,6 @@ snapshots: dependencies: defaults: 1.0.4 - web-streams-polyfill@3.2.1: {} - web-vitals@0.2.4: {} web3-bzz@1.10.3(bufferutil@4.0.8)(utf-8-validate@5.0.10): @@ -42630,14 +42319,6 @@ snapshots: '@noble/curves': 1.4.0 '@noble/hashes': 1.4.0 - webcrypto-core@1.7.7: - dependencies: - '@peculiar/asn1-schema': 2.3.6 - '@peculiar/json-schema': 1.1.12 - asn1js: 3.0.5 - pvtsutils: 1.3.4 - tslib: 2.7.0 - webextension-polyfill-ts@0.25.0: dependencies: webextension-polyfill: 0.7.0