Skip to content

Commit

Permalink
(bond & tokenomics) feat: bond migration final (#75)
Browse files Browse the repository at this point in the history
* fix: update dispenser ABI

* fix: update tokenomics ABI

* feat: update bonding products

* feat: update deposit component tag

* chore: raw send transaction for deposit

* chore: minor updates to deposit

* chore: remove logs

* refactor: Remove unused code and optimize useWhirlPoolInformation hook

* chore: address Tanya's review request

* chore: remove duplicate middleware

* chore: remvoe support for goerli

* chore: remove goerli and some CSS change

* fix: bond error resolved

* chore: add logs for issue faced on Solana Liquidity

* feat: calculation fix for deposit

* feat: calculate OLAS payout

* feat: enhance error message in Solana liquidity management

* feat: add tooltip to MyBonds - OLAS payout column

* fix: Add missing file to .gitleaksignore

* fix: minor chnages

* feat: fix bonds-footer

* feat: add RPC endpoint to allowed origins in CSP header
  • Loading branch information
mohandast52 authored Aug 23, 2024
1 parent f425ced commit dcc2ad3
Show file tree
Hide file tree
Showing 22 changed files with 1,126 additions and 541 deletions.
11 changes: 8 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NEXT_PUBLIC_GNOSIS_TEST_RPC=__URL__
NEXT_PUBLIC_POLYGON_TEST_RPC=__URL__
NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET=

# autonolas-registry-frontend
# registry
NEXT_PUBLIC_REGISTRY_URL=__value__
NEXT_PUBLIC_AUTONOLAS_URL=__value__
NEXT_PUBLIC_GNOSIS_SAFE_API_MAINNET=__value__
Expand All @@ -30,8 +30,13 @@ NEXT_PUBLIC_ETHERSCAN_API_KEY=__value__
NEXT_PUBLIC_SOLANA_MAINNET_BETA_URL=__value__
NEXT_PUBLIC_SVM_PUBLIC_KEY=__value__

# autonolas-tokenomics-frontend
# tokenomics
NEXT_PUBLIC_GRAPH_ENDPOINT_MAINNET=__URL__
NEXT_PUBLIC_SHYFT_API_KEY=__KEY__
NEXT_PUBLIC_IS_CONNECTED_TO_LOCAL=__TRUE_OR_FALSE__

# bond
NEXT_PUBLIC_MAINNET_BALANCER_URL=__URL__
NEXT_PUBLIC_OPTIMISM_BALANCER_URL=__URL__
NEXT_PUBLIC_GNOSIS_BALANCER_URL=__URL__
NEXT_PUBLIC_POLYGON_BALANCER_URL=__URL__
NEXT_PUBLIC_ARBITRUM_BALANCER_URL=__URL__
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ c286a015e94a4abfa474749e6d0d38d944b25e8b:apps/govern/common-util/Contracts/addre
19198deff3574e55dbb56fba98533722a641c6e7:apps/launcher/common-util/Contracts/addresses.tsx:generic-api-key:31
19198deff3574e55dbb56fba98533722a641c6e7:apps/launcher/common-util/Contracts/addresses.tsx:generic-api-key:29
c286a015e94a4abfa474749e6d0d38d944b25e8b:apps/govern/common-util/Contracts/addresses.tsx:generic-api-key:74
6cf8d7df061c4bdb1e3ccbb8dbf3585b715ad874:apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx:generic-api-key:53
9 changes: 3 additions & 6 deletions apps/bond/common-util/functions/frontend-library.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { notifyError } from 'libs/util-functions/src';
import {
getProvider as getProviderFn,
getChainId as getChainIdFn,
getChainIdOrDefaultToMainnet as getChainIdOrDefaultToMainnetFn,
sendTransaction as sendTransactionFn,
LOCAL_FORK_ID,
notifyError,
sendTransaction as sendTransactionFn,
} from '@autonolas/frontend-library';

import { RPC_URLS } from 'common-util/constants/rpcs';
Expand Down Expand Up @@ -39,7 +39,4 @@ export const getChainId = (chainId) => {
};

export const sendTransaction = (fn, account) =>
sendTransactionFn(fn, account, {
supportedChains,
rpcUrls: RPC_URLS,
});
sendTransactionFn(fn, account, { supportedChains, rpcUrls: RPC_URLS });
34 changes: 19 additions & 15 deletions apps/bond/common-util/graphql/clients.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { GraphQLClient } from 'graphql-request';
import {
arbitrum,
base,
gnosis,
mainnet,
optimism,
polygon,
} from 'viem/chains';

const requestConfig = {
jsonSerializer: {
Expand All @@ -16,32 +24,28 @@ export const AUTONOLAS_GRAPH_CLIENTS = {

// https://docs.balancer.fi/reference/subgraph/ for future subgraph endpoints
export const BALANCER_GRAPH_CLIENTS = {
1: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2',
requestConfig,
),
5: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2',
[mainnet.id]: new GraphQLClient(
process.env.NEXT_PUBLIC_MAINNET_BALANCER_URL,
requestConfig,
),
10: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-optimism-v2',
[optimism.id]: new GraphQLClient(
process.env.NEXT_PUBLIC_OPTIMISM_BALANCER_URL,
requestConfig,
),
100: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2',
[gnosis.id]: new GraphQLClient(
process.env.NEXT_PUBLIC_GNOSIS_BALANCER_URL,
requestConfig,
),
137: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2',
[polygon.id]: new GraphQLClient(
process.env.NEXT_PUBLIC_POLYGON_BALANCER_URL,
requestConfig,
),
8453: new GraphQLClient(
[base.id]: new GraphQLClient(
'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest',
requestConfig,
),
42161: new GraphQLClient(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2',
[arbitrum.id]: new GraphQLClient(
process.env.NEXT_PUBLIC_ARBITRUM_BALANCER_URL,
requestConfig,
),
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
QuestionCircleOutlined,
UnorderedListOutlined,
} from '@ant-design/icons';
import { Button, Empty, Popconfirm, Spin, Table, Tag, Tooltip, Typography } from 'antd';
import { Button, Empty, Popconfirm, Skeleton, Spin, Table, Tag, Tooltip, Typography } from 'antd';
import { isNaN, remove, round } from 'lodash';
import Link from 'next/link';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -33,6 +33,10 @@ const Container = styled.div`
}
`;

const Loader = () => <Skeleton.Button size="small" className="full-width" active block />;

const isCurrentPriceLpZero = (currentPrice) => Number(currentPrice) === 0;

const getTitle = (title, tooltipDesc) => (
<Tooltip title={tooltipDesc}>
<span>
Expand Down Expand Up @@ -86,11 +90,17 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts
dataIndex: 'fullCurrentPriceLp',
key: 'fullCurrentPriceLp',
width: 140,
render: (x, details) => (
<a href={details.currentPriceLpLink} rel="noopener noreferrer" target="_blank">
{x}
</a>
),
render: (text, details) => {
if (isCurrentPriceLpZero(text)) {
return <Loader />;
}

return (
<a href={details.currentPriceLpLink} rel="noopener noreferrer" target="_blank">
{text}
</a>
);
},
},
{
title: getTitle(
Expand Down Expand Up @@ -223,8 +233,16 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts
return columns;
};

const sortList = (list) =>
const sortProducts = (list) =>
list.sort((a, b) => {
// if the current price of the LP token is zero, then move it to the end of the list
// NOTE: It can be zero because
// - the API returns zero (shouldn't happen) OR
// - has error OR
// - not fetched yet
const isSvm = a.lpChainId === VM_TYPE.SVM || b.lpChainId === VM_TYPE.SVM;
if (isSvm && isCurrentPriceLpZero(a.fullCurrentPriceLp)) return 1;

if (isNaN(a.projectedChange)) return 1;
if (isNaN(b.projectedChange)) return -1;
return b.projectedChange - a.projectedChange;
Expand Down Expand Up @@ -282,7 +300,7 @@ export const BondingList = ({ bondingProgramType, hideEmptyProducts }) => {
}, [handleProductDetails]);

const getProductsDataSource = useCallback(() => {
const sortedList = sortList(filteredProducts);
const sortedList = sortProducts(filteredProducts);
const processedList = hideEmptyProducts
? sortedList.filter((x) => x.supplyLeft > 0.00001)
: sortedList;
Expand All @@ -308,17 +326,19 @@ export const BondingList = ({ bondingProgramType, hideEmptyProducts }) => {
pagination={false}
scroll={{ x: 400 }}
className="mb-16"
rowHoverable={false}
/>

{!!productDetails && (
<Deposit
productId={productDetails?.id}
productToken={productDetails?.token}
productLpPriceInBg={getLpTokenWithDiscount(
productLpPriceAfterDiscount={getLpTokenWithDiscount(
productDetails?.priceLp,
productDetails?.discount,
)}
).toString()}
productSupply={productDetails?.supply}
productLpTokenName={productDetails?.lpTokenName}
getProducts={refetch}
closeModal={handleModalClose}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePublicClient } from 'wagmi';
import { VM_TYPE, areAddressesEqual } from '@autonolas/frontend-library';

import { DEPOSITORY } from 'libs/util-contracts/src/lib/abiAndAddresses';

import { ADDRESSES } from 'common-util/constants/addresses';
import { ADDRESS_ZERO, ONE_ETH } from 'common-util/constants/numbers';
import { DEX } from 'common-util/enums';
Expand Down
Loading

0 comments on commit dcc2ad3

Please sign in to comment.