From d41610638395c8a02e6c56310c4bd7ff32f8ed81 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 30 Sep 2024 16:59:13 +0200 Subject: [PATCH 1/9] enable forexamm for pendulum --- src/config/apps/nabla.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config/apps/nabla.ts b/src/config/apps/nabla.ts index cf0da3de..14ba5360 100644 --- a/src/config/apps/nabla.ts +++ b/src/config/apps/nabla.ts @@ -14,11 +14,16 @@ export type NablaConfig = AppConfigBase & >; export const nablaConfig: NablaConfig = { - tenants: [TenantName.Foucoco], - environment: ['staging', 'development'], + tenants: [TenantName.Foucoco, TenantName.Pendulum], + environment: ['staging', 'development', 'production'], foucoco: { indexerUrl: 'https://pendulum.squids.live/foucoco-squid/graphql', router: '6mYwT4yRrrMK978NszqBvxkvXjYnsmKfs2BkYGJGiR4XY9Sc', oracle: '6kqj1tnYUGY3L93YFArXKF2E4tpQ2tUJ4DARwkAjZEyDoof6', }, + pendulum: { + indexerUrl: 'https://pendulum.squids.live/pendulum-squid/graphql', + router: '6fEJAs1ycfTNDZY7ZoAtkBhuhHnRVNscdALMBLdjDV12K4uE', + oracle: '6fxpVAp3W5mJsXqnBiQresTd8HZDkNMRFCafbXC9X2AAjFHY', + }, }; From 869c5e25bde3ce0fa70ee68ae4b54f05929e3b0a Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 7 Oct 2024 16:24:26 +0200 Subject: [PATCH 2/9] fix expanding Swap details Nabla --- src/components/nabla/Swap/To.tsx | 20 ++++++++++---------- src/components/nabla/Swap/index.tsx | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/nabla/Swap/To.tsx b/src/components/nabla/Swap/To.tsx index b88c78da..ed0f737f 100644 --- a/src/components/nabla/Swap/To.tsx +++ b/src/components/nabla/Swap/To.tsx @@ -47,8 +47,8 @@ export function To({ }, [toAmountQuote.data?.amountOut.preciseString, setValue]); return ( -
-
+
+
{toAmountQuote.isLoading ? ( @@ -74,13 +74,13 @@ export function To({ type="button" > - {toToken?.name} + {toToken?.name} {toToken?.symbol || 'Select'} - +
-
+
{toToken ? : '$ -'}
{walletAccount && (
@@ -96,11 +96,11 @@ export function To({
-
+
{fromToken !== undefined && toToken !== undefined && @@ -114,13 +114,13 @@ export function To({
- +
-
+
Expected Output:
{toAmountQuote.data !== undefined ? ( diff --git a/src/components/nabla/Swap/index.tsx b/src/components/nabla/Swap/index.tsx index f8f0c4c5..0c465870 100644 --- a/src/components/nabla/Swap/index.tsx +++ b/src/components/nabla/Swap/index.tsx @@ -44,10 +44,10 @@ const Swap = (props: UseSwapComponentProps): JSX.Element | null => { return ( <> - +
-
+
Swap @@ -71,7 +71,7 @@ const Swap = (props: UseSwapComponentProps): JSX.Element | null => { })} button={ } /> From bc2be4f60680340f182f61fbbed441d3d910afcb Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 7 Oct 2024 16:30:21 +0200 Subject: [PATCH 3/9] change footer Nabla Swap --- src/components/nabla/common/NablaFootnote.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/nabla/common/NablaFootnote.tsx b/src/components/nabla/common/NablaFootnote.tsx index 46dbce5e..37b50f2f 100644 --- a/src/components/nabla/common/NablaFootnote.tsx +++ b/src/components/nabla/common/NablaFootnote.tsx @@ -1,10 +1,15 @@ -const nablaHomepageUrl = 'https://nabla.fi'; +const nablaHomepageUrl = 'https://vortexfinance.co'; export function NablaFootnote() { return ( -
+
Powered by{' '} - + Vortex Finance
From a91945f5e1611b38768a67b6e56864de661e39e4 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 7 Oct 2024 16:40:36 +0200 Subject: [PATCH 4/9] add assets icons to nabla swap pools --- src/components/nabla/Pools/Swap/columns.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/nabla/Pools/Swap/columns.tsx b/src/components/nabla/Pools/Swap/columns.tsx index ca0fef2f..359fbc81 100644 --- a/src/components/nabla/Pools/Swap/columns.tsx +++ b/src/components/nabla/Pools/Swap/columns.tsx @@ -1,12 +1,13 @@ import { CellContext, ColumnDef } from '@tanstack/react-table'; -import { Badge, Button } from 'react-daisyui'; +import { Avatar, Badge, Button } from 'react-daisyui'; +import Big from 'big.js'; import { useModalToggle } from '../../../../services/modal'; import { rawToDecimal } from '../../../../shared/parseNumbers/metric'; import { NablaInstanceBackstopPool, NablaInstanceSwapPool } from '../../../../hooks/nabla/useNablaInstance'; import { swapPoolAbi } from '../../../../contracts/nabla/SwapPool'; +import { getIcon } from '../../../../shared/AssetIcons'; import { Erc20Balance } from '../../common/Erc20Balance'; import { LiquidityModalProps } from './SwapPoolModals'; -import Big from 'big.js'; export type SwapPoolColumn = NablaInstanceSwapPool & { backstopPool: NablaInstanceBackstopPool; @@ -17,7 +18,14 @@ const BIG_100 = new Big(100); export const nameColumn: ColumnDef = { header: 'Name', accessorKey: 'name', - accessorFn: (row) => row.token?.name || '', + accessorFn: (row) => row.token.name, + cell: ({ row: { original } }) => + ( +
+ +

{original.token.name}

+
+ ) || '', enableSorting: true, } as const; @@ -46,7 +54,7 @@ export const aprColumn: ColumnDef = { accessorKey: 'apr', accessorFn: (row) => rawToDecimal(row.apr, row.token.decimals).mul(BIG_100).toFixed(2, 0), cell: (props): JSX.Element | null => ( - + {props.renderValue()}% ), From 4f4ee7012ba73a9f7a15ae4e91482673b41ecaf0 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 7 Oct 2024 17:00:52 +0200 Subject: [PATCH 5/9] show nabla swap price by input amount --- src/components/nabla/Swap/From.tsx | 19 ++++++++++++----- src/components/nabla/Swap/To.tsx | 13 +++++++++++- .../nabla/common/NablaTokenPrice.tsx | 21 ++++++++++++++++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/components/nabla/Swap/From.tsx b/src/components/nabla/Swap/From.tsx index c4a69313..4eeaf90b 100644 --- a/src/components/nabla/Swap/From.tsx +++ b/src/components/nabla/Swap/From.tsx @@ -38,7 +38,7 @@ export function From -
+
- {fromToken?.name} + {fromToken?.name} {fromToken?.symbol || 'Select'} - +
-
+
- {fromToken ? : '$ -'} + {fromToken ? ( + + ) : ( + '$ -' + )}
{fromTokenBalance !== undefined && walletAccount && ( diff --git a/src/components/nabla/Swap/To.tsx b/src/components/nabla/Swap/To.tsx index ed0f737f..e9314671 100644 --- a/src/components/nabla/Swap/To.tsx +++ b/src/components/nabla/Swap/To.tsx @@ -81,7 +81,18 @@ export function To({
-
{toToken ? : '$ -'}
+
+ {toToken ? ( + + ) : ( + '$ -' + )} +
{walletAccount && (
Balance:{' '} diff --git a/src/components/nabla/common/NablaTokenPrice.tsx b/src/components/nabla/common/NablaTokenPrice.tsx index 45944ae8..50831468 100644 --- a/src/components/nabla/common/NablaTokenPrice.tsx +++ b/src/components/nabla/common/NablaTokenPrice.tsx @@ -5,14 +5,33 @@ export type TokenPriceProps = { address: string; prefix?: ReactNode; fallback?: ReactNode; + currentTokenAmount?: number; + formatByAmount?: boolean; }; -export function NablaTokenPrice({ address, prefix = null, fallback = null }: TokenPriceProps): JSX.Element | null { +export function NablaTokenPrice({ + currentTokenAmount, + address, + prefix = null, + fallback = null, + formatByAmount = false, +}: TokenPriceProps): JSX.Element | null { const { data, isLoading } = useNablaTokenPrice(address); if (isLoading) return ; if (data === undefined) return fallback; + if (formatByAmount) { + const currentAmountPrice = (Number(data.approximateStrings.atLeast2Decimals) * (currentTokenAmount || 0)).toFixed( + 2, + ); + return ( + + {prefix}${currentAmountPrice} + + ); + } + return ( {prefix}${data.approximateStrings.atLeast2Decimals} From e1e31dac78fc11853d9d20c28dee087c0638942e Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Tue, 8 Oct 2024 12:43:17 +0200 Subject: [PATCH 6/9] use Big for calculating the input price --- src/components/nabla/Swap/From.tsx | 21 ++++++----- src/components/nabla/Swap/To.tsx | 36 +++++++++---------- src/components/nabla/Swap/index.tsx | 17 ++++----- .../nabla/common/NablaTokenPrice.tsx | 12 +++---- 4 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/components/nabla/Swap/From.tsx b/src/components/nabla/Swap/From.tsx index 4eeaf90b..37d886b2 100644 --- a/src/components/nabla/Swap/From.tsx +++ b/src/components/nabla/Swap/From.tsx @@ -1,6 +1,7 @@ +import { FieldPath, FieldValues, UseFormReturn, useFormContext } from 'react-hook-form'; import { ChevronDownIcon } from '@heroicons/react/20/solid'; import { Button } from 'react-daisyui'; -import { FieldPath, FieldValues, UseFormReturn, useFormContext } from 'react-hook-form'; +import Big from 'big.js'; import { NablaTokenPrice } from '../common/NablaTokenPrice'; import { fractionOfValue } from '../../../shared/parseNumbers/metric'; @@ -14,21 +15,23 @@ import { useGlobalState } from '../../../GlobalStateProvider'; import { SwapFormValues } from './schema'; interface FromProps> { - fromToken: NablaInstanceToken | undefined; - onOpenSelector: () => void; - inputHasError: boolean; - fromFormFieldName: TFieldName; form: UseFormReturn; fromTokenBalance: UseContractReadResult; + fromToken?: NablaInstanceToken; + fromAmount?: Big; + fromFormFieldName: TFieldName; + onOpenSelector: () => void; + inputHasError: boolean; } export function From>({ + form, fromToken, + fromAmount, + fromTokenBalance, + fromFormFieldName, onOpenSelector, inputHasError, - fromFormFieldName, - form, - fromTokenBalance, }: FromProps) { const { setValue } = useFormContext(); @@ -65,7 +68,7 @@ export function From diff --git a/src/components/nabla/Swap/To.tsx b/src/components/nabla/Swap/To.tsx index e9314671..b4d5caa2 100644 --- a/src/components/nabla/Swap/To.tsx +++ b/src/components/nabla/Swap/To.tsx @@ -5,24 +5,24 @@ import { useFormContext } from 'react-hook-form'; import Big from 'big.js'; import { UseTokenOutAmountResult } from '../../../hooks/nabla/useTokenOutAmount'; -import useBoolean from '../../../hooks/useBoolean'; -import { NumberLoader } from '../../Loader'; -import { Skeleton } from '../../Skeleton'; -import { SwapFormValues } from './schema'; import { NablaInstanceToken } from '../../../hooks/nabla/useNablaInstance'; +import useBoolean from '../../../hooks/useBoolean'; import { erc20WrapperAbi } from '../../../contracts/nabla/ERC20Wrapper'; import { NablaTokenPrice } from '../common/NablaTokenPrice'; import { Erc20Balance } from '../common/Erc20Balance'; import { getIcon } from '../../../shared/AssetIcons'; import { useGlobalState } from '../../../GlobalStateProvider'; +import { NumberLoader } from '../../Loader'; +import { Skeleton } from '../../Skeleton'; +import { SwapFormValues } from './schema'; export interface ToProps { - onOpenSelector: () => void; - fromToken: NablaInstanceToken | undefined; - toToken: NablaInstanceToken | undefined; + fromToken?: NablaInstanceToken; + fromAmount?: Big; + toToken?: NablaInstanceToken; toAmountQuote: UseTokenOutAmountResult; - fromAmount: Big | undefined; slippage: number; + onOpenSelector: () => void; } export function To({ @@ -47,8 +47,8 @@ export function To({ }, [toAmountQuote.data?.amountOut.preciseString, setValue]); return ( -
-
+
+
{toAmountQuote.isLoading ? ( @@ -74,18 +74,18 @@ export function To({ type="button" > - {toToken?.name} + {toToken?.name} {toToken?.symbol || 'Select'} - +
-
+
{toToken ? ( @@ -111,7 +111,7 @@ export function To({ isOpen ? 'collapse-open' : '' }`} > -
+
{fromToken !== undefined && toToken !== undefined && @@ -125,13 +125,13 @@ export function To({
- +
-
+
Expected Output:
{toAmountQuote.data !== undefined ? ( diff --git a/src/components/nabla/Swap/index.tsx b/src/components/nabla/Swap/index.tsx index 0c465870..a15fb935 100644 --- a/src/components/nabla/Swap/index.tsx +++ b/src/components/nabla/Swap/index.tsx @@ -44,10 +44,10 @@ const Swap = (props: UseSwapComponentProps): JSX.Element | null => { return ( <> - + -
+
Swap @@ -71,18 +71,19 @@ const Swap = (props: UseSwapComponentProps): JSX.Element | null => { })} button={ } />
setModalType('from')} - inputHasError={inputHasErrors} form={form} + fromToken={fromToken} + fromAmount={fromAmount} fromFormFieldName="fromAmount" fromTokenBalance={fromTokenBalance} + onOpenSelector={() => setModalType('from')} + inputHasError={inputHasErrors} /> { @@ -90,13 +91,13 @@ const Swap = (props: UseSwapComponentProps): JSX.Element | null => { }} /> setModalType('to')} - fromAmount={fromAmount} slippage={slippage} /> diff --git a/src/components/nabla/common/NablaTokenPrice.tsx b/src/components/nabla/common/NablaTokenPrice.tsx index 50831468..7590bec2 100644 --- a/src/components/nabla/common/NablaTokenPrice.tsx +++ b/src/components/nabla/common/NablaTokenPrice.tsx @@ -1,20 +1,21 @@ -import { NumberLoader } from '../../Loader'; +import Big from 'big.js'; import { useNablaTokenPrice } from '../../../hooks/nabla/useNablaTokenPrice'; +import { NumberLoader } from '../../Loader'; export type TokenPriceProps = { address: string; prefix?: ReactNode; fallback?: ReactNode; - currentTokenAmount?: number; + currentTokenAmount?: Big; formatByAmount?: boolean; }; export function NablaTokenPrice({ - currentTokenAmount, address, prefix = null, fallback = null, formatByAmount = false, + currentTokenAmount = Big(0), }: TokenPriceProps): JSX.Element | null { const { data, isLoading } = useNablaTokenPrice(address); if (isLoading) return ; @@ -22,9 +23,8 @@ export function NablaTokenPrice({ if (data === undefined) return fallback; if (formatByAmount) { - const currentAmountPrice = (Number(data.approximateStrings.atLeast2Decimals) * (currentTokenAmount || 0)).toFixed( - 2, - ); + const currentAmountPrice = Big(data.approximateStrings.atLeast2Decimals).mul(currentTokenAmount).toFixed(2); + return ( {prefix}${currentAmountPrice} From c2ef20e6b33b44c4fe91460f46556276bb6b4bb6 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Tue, 8 Oct 2024 12:44:42 +0200 Subject: [PATCH 7/9] remove deprecated husky code --- .husky/pre-commit | 3 --- 1 file changed, 3 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af2198..2312dc58 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx lint-staged From 368ba85da18a0ce818a64c5a9bf1a42494d186f0 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Tue, 8 Oct 2024 12:48:15 +0200 Subject: [PATCH 8/9] remove deprecated husky code --- .husky/pre-commit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 2312dc58..aae14ee5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,2 @@ -npx lint-staged +# .husky/pre-commit +yarn lint-staged From 88a4e64b5e8201919fdf21602f27c8118c22ed7e Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Wed, 9 Oct 2024 13:19:46 +0200 Subject: [PATCH 9/9] round down NablaTokenPrice --- src/components/nabla/common/NablaTokenPrice.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/nabla/common/NablaTokenPrice.tsx b/src/components/nabla/common/NablaTokenPrice.tsx index 7590bec2..e6b1c252 100644 --- a/src/components/nabla/common/NablaTokenPrice.tsx +++ b/src/components/nabla/common/NablaTokenPrice.tsx @@ -23,7 +23,7 @@ export function NablaTokenPrice({ if (data === undefined) return fallback; if (formatByAmount) { - const currentAmountPrice = Big(data.approximateStrings.atLeast2Decimals).mul(currentTokenAmount).toFixed(2); + const currentAmountPrice = Big(data.approximateStrings.atLeast2Decimals).mul(currentTokenAmount).toFixed(2, 0); return (