Skip to content

Commit

Permalink
Fixes Trade Summary Fees, Whitelist crvUSD vaults on Arbitrum (#772)
Browse files Browse the repository at this point in the history
* build: adds product dashboard to vaults page

* build: adds incentives

* build: hides negative yields adds header

* build: clean up

* build: addresses comments

* build: updates naming

* build: fixes sorting issues adds hide yields button

* build: updates vault dashboard grid card data

* build: updates comp name

* build: wip

* build: adds different dashboard componenets to dashboard view

* build: adds grid dashboards removes card pages

* build: addresses comments

* build: fixes dashboard sorting

* build: fixes issues

* build: updates tvl to liquidity on dashbaord cards

* build: updates prop naming

* build: adds fixed lend list view

* build: adds list view

* build: clean up

* build: updates styles

* build: gets network selectors working

* Bugfix/all markets yields (#647)

* fix: all market yields

* fix: network selector logic

* fix: add network selector

* fix: rename component and add to portfolio

* fix: add network selector to portfolio, move useSelectedNetwork

* fix: adding network icon to grid

* Feat/token settings (#649)

* fix: build issues (#651)

* build: updates styles of multi select dropdown

* build: add right toggle and all networks toggle to data table filter

* build: adds all networks toggle

* build: removes log

* build: adds network icon to tables adds body from mui cleans up styles

* build: fixes issues related to ntoken apy chart and mainnet

* build: updates landing page product cards to new style

* build: removes log

* Bugfix/txn submit bugs (#663)

* build: updates red usage

* build: removes logs

* build: updates fait token and percent decimal places

* build: adds toAbbrDisplayString fixes other decimal issues

* build: removes log

* build: fixes incorrect error and fixed borrow grid order

* build: removes comment

* Bugfix/to abbr display string (#681)

* fix: initial fix

* fix: display string logic

* fix: vault loading issues

* build: adds tanstack react table v8

* build: upgrades table to v8

* build: adds scrollable table wip

* build: type updates

* build: fixes issues after rebase

* build: addresses comments

* Feat/whitelist vaults (#711)

* fix: yield cache (#699)

* build: fixes small bugs

* fix: claim arb button (#703)

* build: fixes sorting

* build: wip

* build: adds organic value on dashboard cards

* build: removes console logs

* build: addresses comments

* fix: ntoken spot price (#705)

* build: removes networks switcher fixes usdc e error

* build: adds key to bar chart tooltip

* fix: adding more vaults (#707)

* fix: variable rate utilization (#708)

* fix: update vault addresses

* fix: vault data and liquidator code

* feat: updating vault addresses

* fix: adding deposit value chart

* fix: area chart

* fix: update bar charts

* fix: update chart headers

* fix: update summary page

* fix: chart bugs

* fix: bar chart tooltips

* fix: adds ntoken price chart

* fix: apy chart data keys

* fix: data server fixes

* fix: ntoken apy charts

* fix: whitelisted vaults

* fix: registry yield sync

---------

Co-authored-by: matthew-garrett <[email protected]>

* Feat/update transaction history (#712)

* fix: initial query change

* fix: initial remapping for labels

* fix: ntokens and incentives

* fix: renaming rest of txns

* Feat/vault default select (#713)

* fix: auto select borrow option for vaults

* fix: default chart select

* fix: performance chart scale (#714)

* Bugfix/various issues (#715)

* fix: improving txn grouping

* feat: system txn history

* fix: slider cell (#716)

* Feat/renzo etherfi vaults (#719)

* fix: points headers (#721)

* Bugfix/point multiples (#723)

* build: udpates type form link

* Feat: GHO Vault, Deposit Value Charts, Txn History Updates (#717)

* build: react helmet wip

* build: adds Meta tags to porfotlio and all markets

* build: fixes vault list link

* build: moves MetaTagManager to app layout route

* build: undefined meta tag check and fixes about us small bugs

* Bugfix/metrics for regisitries (#722)

* fix: point multiples

---------

Co-authored-by: matthew-garrett <[email protected]>
Co-authored-by: matthew-garrett <[email protected]>

* fix: function (#724)

* Bugfix/points multiples leverage (#728)

* fix: points multiples

* fix: holdings pnl

* Bugfix/liquidity withdraw (#729)

* fix: using exchange in max withdraw

* fix: ntoken withdraw direction

* fix: liquidity withdraw issues

* fix: adding gnosis module (#733)

* fix: update dependencies (#734)

* Feat/switch to implied rates (#735)

* fix: adding spot rates to oracle registry

* fix: change fcash rate source

* fix: testing lend fixed borrow fixed

* fix: convert fcash

* fix: order details bugs

* Bugfix/ntoken implied rates (#738)

* Bugfix/implied rate issues (#739)

* fix: various issues

* fix: manage convert roll labels

* fix: remove vault returns

* Bugfix/add deleverage buffer (#741)

* fix: adding deleverage buffer math

* fix: latest commit

* fix: working calculation

* fix: cleaning up deleverage buffer code

* fix: refactor summary table

* fix: adjust ntoken post mint value

* fix: update deleverage buffer error

* fix: add max mint deviation

* fix: vault share apy label

* fix: adding deviation limit warning

* Feat/etherfi points (#742)

* fix: create etherfi points worker

* fix: making points worker

* fix: rename to points

* fix: adding ezETH vault

* fix: allow site to load if subgraph is down

* fix: oracle registry server resiliancy

* fix: performance chart labels (#757)

* Feat/intercom (#759)

* build: intercom wip

* build: sets up intercom

* build: removes script tag

* fix: add workflow info

---------

Co-authored-by: Jeff Wu <[email protected]>

* Bugfix/fee slippage values (#765)

* fix: initial change

* fix: deposit and withdraw summaries

* fix: simplify liquidation risk

* fix: leveraged vault fees

* fix: deleverage withdraw summary

* fix: roll debt convert asset

* fix: realized calculations

* fix: roll vault position

* fix: max vault withdraw

* fix: vault risk bug

* fix: traded interest rates (#768)

* Bugfix/various fee bugs (#769)

* fix: hero stats (#766)

* fix: some initial issues

* fix: withdraw liquidity bugs

* fix: add max withdraw message (#770)

* Feat/list crv vaults arb (#771)

* fix: listed new pools

* fix: switch to no admin fee config

* fix: remove intercom

* fix: remove intercom boot

---------

Co-authored-by: matthew-garrett <[email protected]>
Co-authored-by: matthew-garrett <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent d636690 commit 380420f
Show file tree
Hide file tree
Showing 26 changed files with 529 additions and 431 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-arb-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
NX_DD_SITE: ${{ secrets.NX_DD_SITE }}
NX_APP_URL: ${{ secrets.NX_APP_URL }}
NX_DATA_URL: ${{ secrets.NX_DATA_URL }}
NX_INTERCOM_APP_ID: ${{ secrets.NX_INTERCOM_APP_ID }}
# This segment key is not the same as the prod one
NX_SEGMENT_KEY: ${{ secrets.NX_DEV_SEGMENT_KEY }}
NX_ENV: ${{ github.event.inputs.environment || 'arb' }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-arb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
NX_SEGMENT_KEY: ${{ secrets.NX_SEGMENT_KEY }}
NX_ENV: ${{ github.event.inputs.environment || 'arb' }}
NX_COMMIT_REF: ${{ github.sha }}
NX_INTERCOM_APP_ID: ${{ secrets.NX_INTERCOM_APP_ID }}
- name: Publish Dev
uses: cloudflare/pages-action@1
with:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"react-scroll": "^1.8.9",
"react-slick": "^0.29.0",
"react-swipeable": "^7.0.0",
"react-use-intercom": "^5.4.0",
"react-youtube": "^9.0.2",
"recharts": "^2.3.2",
"regenerator-runtime": "0.13.7",
Expand Down
8 changes: 3 additions & 5 deletions packages/core-entities/src/client/exchange-registry-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ export class ExchangeRegistryClient extends ClientRegistry<PoolDefinition> {
network: Network,
address: string
) {
const pool = this.getLatestFromSubject(
network,
// Converts to a checksummed address
ethers.utils.getAddress(address)
);
const pool =
this.getLatestFromSubject(network, ethers.utils.getAddress(address)) ||
this.getLatestFromSubject(network, address.toLowerCase());
if (!pool) throw Error(`Pool ${address} on ${network} not found`);
return this._buildPool<T>(network, pool);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core-entities/src/config/whitelisted-vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export const whitelistedVaults = (network: Network) => {
'0xdb08f663e5d765949054785f2ed1b2aa1e9c22cf',
// "[USDT]:USDC_e_xUSDT"
'0x431dbfe3050ea39abbff3e0d86109fb5bafa28fd',
// // "[USDC]:crvUSD_xUSDC"
// '0x5c36a0deab3531d29d848e684e8bdf5f81cdb643',
// // "[USDT]:crvUSD_xUSDT"
// '0xae04e4887cbf5f25c05ac1384bcd0b7e885a1f4a',
// "[USDC]:crvUSD_xUSDC"
'0x5c36a0deab3531d29d848e684e8bdf5f81cdb643',
// "[USDT]:crvUSD_xUSDT"
'0xae04e4887cbf5f25c05ac1384bcd0b7e885a1f4a',
// "[rETH]:xrETH_WETH"
'0x3df035433cface65b6d68b77cc916085d020c8b8',
// "[USDC]:xUSDC_DAI_USDT_USDC_e"
Expand Down
59 changes: 41 additions & 18 deletions packages/core-entities/src/exchanges/default-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const defaultPools: Record<Network, PoolDefinition[]> = {
},
{
address: '0x383E6b4437b59fff47B619CBA855CA29342A8559',
PoolClass: 'Curve2TokenPoolV1_SelfLPToken',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
{
id: '0x383E6b4437b59fff47B619CBA855CA29342A8559',
Expand All @@ -80,7 +80,7 @@ const defaultPools: Record<Network, PoolDefinition[]> = {
},
{
address: '0x4DEcE678ceceb27446b35C672dC7d61F30bAD69E',
PoolClass: 'Curve2TokenPoolV1_SelfLPToken',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
{
id: '0x4DEcE678ceceb27446b35C672dC7d61F30bAD69E',
Expand All @@ -106,7 +106,7 @@ const defaultPools: Record<Network, PoolDefinition[]> = {
},
{
address: '0x390f3595bCa2Df7d23783dFd126427CCeb997BF4',
PoolClass: 'Curve2TokenPoolV1_SelfLPToken',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
{
id: '0x390f3595bCa2Df7d23783dFd126427CCeb997BF4',
Expand Down Expand Up @@ -286,7 +286,7 @@ const defaultPools: Record<Network, PoolDefinition[]> = {
},
{
address: '0x7f90122BF0700F9E7e1F688fe926940E8839F353',
PoolClass: 'Curve2TokenPoolV1_SelfLPToken',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
// USDT / USDC v1 pool
{
Expand Down Expand Up @@ -340,30 +340,53 @@ const defaultPools: Record<Network, PoolDefinition[]> = {
],
},
{
// NOTE: the pool address here is different from the lp token address
address: '0x6eB2dc694eB516B16Dc9FBc678C60052BbdD7d80',
PoolClass: 'Curve2TokenPoolV1_HasOracle',
address: '0x73af1150f265419ef8a5db41908b700c32d49135',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
// ETH / wstETH Pool
{
id: '0xDbcD16e622c95AcB2650b38eC799f76BFC557a0b',
address: '0xDbcD16e622c95AcB2650b38eC799f76BFC557a0b',
id: '0x73af1150f265419ef8a5db41908b700c32d49135',
address: '0x73af1150f265419ef8a5db41908b700c32d49135',
network: Network.arbitrum,
symbol: 'wstETHCRV',
name: 'Curve.fi ETH/wstETH',
symbol: 'crvUSDC',
name: 'crvUSD/USDT',
decimals: 18,
tokenInterface: 'ERC20',
tokenType: 'Underlying',
},
// Register ALT_ETH
{
id: ALT_ETH,
address: ALT_ETH,
id: '0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5',
address: '0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5',
network: Network.arbitrum,
symbol: 'ETH [Alt]',
name: 'Ether [Alternate]',
symbol: 'crvUSD',
name: 'Curve.Fi USD Stablecoin',
decimals: 18,
tokenInterface: 'ERC20', // TODO: change this to Ether interface
tokenInterface: 'ERC20',
tokenType: 'Underlying',
},
],
},
{
address: '0xec090cf6dd891d2d014bea6edada6e05e025d93d',
PoolClass: 'Curve2TokenPoolV1_SelfLPTokenNoAdmin',
registerTokens: [
{
id: '0xec090cf6dd891d2d014bea6edada6e05e025d93d',
address: '0xec090cf6dd891d2d014bea6edada6e05e025d93d',
network: Network.arbitrum,
symbol: 'crvUSDC',
name: 'crvUSD/USDC',
decimals: 18,
tokenInterface: 'ERC20',
tokenType: 'Underlying',
},
{
id: '0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5',
address: '0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5',
network: Network.arbitrum,
symbol: 'crvUSD',
name: 'Curve.Fi USD Stablecoin',
decimals: 18,
tokenInterface: 'ERC20',
tokenType: 'Underlying',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,6 @@ export const useLiquidityDetails = () => {
greenOnArrowUp: true,
},
},
{
label: 'Net Worth',
current: currentHoldings?.presentValue.toDisplayStringWithSymbol() || '-',
updated: {
value: newNetWorth?.toDisplayStringWithSymbol() || '-',
arrowUp:
getChangeType(
currentHoldings?.presentValue.toFloat(),
newNetWorth?.toFloat()
) === 'increase',
checkmark:
getChangeType(
currentHoldings?.presentValue.toFloat(),
newNetWorth?.toFloat()
) === 'cleared',
greenOnCheckmark: false,
greenOnArrowUp: true,
},
},
{
label: 'Leverage Ratio',
current: currentHoldings?.leverageRatio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const CreateOrIncreasePosition = () => {
{currentPosition ? (
<ManageTerms
borrowType={
currentPosition.debt.tokenType === 'PrimeDebt'
currentPosition.debt.balance.tokenType === 'PrimeDebt'
? 'Variable'
: 'Fixed'
}
Expand Down
23 changes: 7 additions & 16 deletions packages/features/portfolio/src/side-drawers/convert-asset.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { Box, useTheme } from '@mui/material';
import { Box } from '@mui/material';
import { TokenBalance } from '@notional-finance/core-entities';
import { SideBarSubHeader, useCurrencyInputRef } from '@notional-finance/mui';
import { useCurrencyInputRef } from '@notional-finance/mui';
import { useTradeContext } from '@notional-finance/notionable-hooks';
import { AssetInput } from '@notional-finance/trade';
import { PORTFOLIO_ACTIONS } from '@notional-finance/util';
import { defineMessage } from 'react-intl';
import { PortfolioSideDrawer } from './components/portfolio-side-drawer';
import { SelectConvertAsset } from './components/select-convert-asset';
import { messages } from './messages';
import { useState } from 'react';

export const ConvertAsset = () => {
const theme = useTheme();
const context = useTradeContext('ConvertAsset');
const { currencyInputRef } = useCurrencyInputRef();
const {
state: { collateral },
updateState,
} = context;
const [hasUserTouched, setHasUserTouched] = useState<boolean>(false)
const [hasUserTouched, setHasUserTouched] = useState<boolean>(false);

const onBalanceChange = (
inputAmount: TokenBalance | undefined,
_: TokenBalance | undefined,
maxBalance: TokenBalance | undefined
) => {
if (inputAmount) setHasUserTouched(true)
// Fixes a race condition where the screen flashes
if (inputAmount === undefined && hasUserTouched === false) return;
if (inputAmount) setHasUserTouched(true);
updateState({
debtBalance: inputAmount,
maxWithdraw: maxBalance && inputAmount?.neg().eq(maxBalance),
Expand All @@ -35,19 +35,10 @@ export const ConvertAsset = () => {
return (
<Box>
<Box sx={{ display: collateral === undefined ? 'block' : 'none' }}>
<SelectConvertAsset context={context} hasUserTouched={hasUserTouched}/>
<SelectConvertAsset context={context} hasUserTouched={hasUserTouched} />
</Box>
{collateral && (
<PortfolioSideDrawer context={context}>
<SideBarSubHeader
callback={() => updateState({ collateral: undefined })}
sx={{
position: 'absolute',
top: 0,
background: theme.palette.background.paper,
}}
titleText={defineMessage({ defaultMessage: 'Back' })}
></SideBarSubHeader>
<AssetInput
ref={currencyInputRef}
debtOrCollateral="Debt"
Expand Down
17 changes: 4 additions & 13 deletions packages/features/portfolio/src/side-drawers/roll-debt.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Box, useTheme } from '@mui/material';
import { Box } from '@mui/material';
import { TokenBalance } from '@notional-finance/core-entities';
import { SideBarSubHeader, useCurrencyInputRef } from '@notional-finance/mui';
import { useCurrencyInputRef } from '@notional-finance/mui';
import { useTradeContext } from '@notional-finance/notionable-hooks';
import { AssetInput } from '@notional-finance/trade';
import { PORTFOLIO_ACTIONS } from '@notional-finance/util';
import { defineMessage } from 'react-intl';
import { PortfolioSideDrawer } from './components/portfolio-side-drawer';
import { SelectConvertAsset } from './components/select-convert-asset';
import { messages } from './messages';
import { useState } from 'react';

export const RollDebt = () => {
const theme = useTheme();
const context = useTradeContext('RollDebt');
const { currencyInputRef } = useCurrencyInputRef();
const {
Expand All @@ -25,6 +23,8 @@ export const RollDebt = () => {
_: TokenBalance | undefined,
maxBalance: TokenBalance | undefined
) => {
// Fixes a race condition where the screen flashes
if (inputAmount === undefined && hasUserTouched === false) return;
if (inputAmount) setHasUserTouched(true);
updateState({
collateralBalance: inputAmount,
Expand All @@ -42,15 +42,6 @@ export const RollDebt = () => {
context={context}
enablePrimeBorrow={debt?.tokenType === 'PrimeDebt'}
>
<SideBarSubHeader
callback={() => updateState({ debt: undefined })}
sx={{
position: 'absolute',
top: 0,
background: theme.palette.background.paper,
}}
titleText={defineMessage({ defaultMessage: 'Back' })}
/>
<AssetInput
ref={currencyInputRef}
debtOrCollateral="Collateral"
Expand Down
2 changes: 2 additions & 0 deletions packages/features/portfolio/src/side-drawers/withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const Withdraw = () => {
setCurrencyInput,
onMaxValue,
maxWithdrawUnderlying,
belowMaxWarning,
} = useMaxWithdraw(context);
const {
state: { selectedNetwork },
Expand Down Expand Up @@ -59,6 +60,7 @@ export const Withdraw = () => {
context={context}
inputRef={currencyInputRef}
maxWithdraw={maxWithdrawUnderlying}
warningMsg={belowMaxWarning}
onMaxValue={onMaxValue}
newRoute={(newToken) =>
`/portfolio/${selectedNetwork}/${category}/${sideDrawerKey}/${newToken}`
Expand Down
11 changes: 4 additions & 7 deletions packages/features/vault/src/components/vault-side-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ToggleSwitchProps } from '@notional-finance/mui';
import { TransactionSidebar } from '@notional-finance/trade';
import { useHistory } from 'react-router';
import { messages } from '../messages';
import { VaultDetailsTable } from './vault-details-table';
import {
VaultContext,
useVaultProperties,
Expand Down Expand Up @@ -43,14 +42,12 @@ export const VaultSideDrawer = ({
showDrawer={false}
heading={messages[tradeType].heading}
advancedToggle={advancedToggle}
onCancelRouteCallback={() => history.push(`/vaults/${selectedNetwork}/${vaultAddress}`)}
onCancelRouteCallback={() =>
history.push(`/vaults/${selectedNetwork}/${vaultAddress}`)
}
hideTextOnMobile={false}
riskComponent={
tradeType === 'CreateVaultPosition' ? (
<CreateVaultLiquidationRisk key={'vault-risk-table'} state={state} />
) : (
<VaultDetailsTable key={'vault-risk-table'} />
)
<CreateVaultLiquidationRisk key={'vault-risk-table'} state={state} />
}
helptext={{
...messages[tradeType].helptext,
Expand Down
11 changes: 8 additions & 3 deletions packages/features/vault/src/hooks/use-vault-details-table.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useContext } from 'react';
import { formatMaturity } from '@notional-finance/util';
import { VaultActionContext } from '../vault';
import { useVaultLiquidationRisk } from '@notional-finance/notionable-hooks';
import { useVaultDetails } from '@notional-finance/notionable-hooks';

export function useVaultDetailsTable() {
const { state } = useContext(VaultActionContext);
const { priorVaultBalances, collateralBalance } = state;
const { tableData, priorAccountNoRisk, postAccountNoRisk, tooRisky, onlyCurrent } =
useVaultLiquidationRisk(state);
const {
tableData,
priorAccountNoRisk,
postAccountNoRisk,
tooRisky,
onlyCurrent,
} = useVaultDetails(state);

const maturity =
collateralBalance?.maturity ||
Expand Down
Loading

0 comments on commit 380420f

Please sign in to comment.