Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bond & tokenomics) feat: bond migration final #75

Merged
merged 22 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f20fd6c
fix: update dispenser ABI
mohandast52 Aug 8, 2024
3149f9c
fix: update tokenomics ABI
mohandast52 Aug 8, 2024
e104e99
feat: update bonding products
mohandast52 Aug 8, 2024
8165e72
feat: update deposit component tag
mohandast52 Aug 9, 2024
eac13e4
chore: raw send transaction for deposit
mohandast52 Aug 9, 2024
f7da5b5
chore: minor updates to deposit
mohandast52 Aug 9, 2024
a1386c0
chore: remove logs
mohandast52 Aug 9, 2024
b3a13f0
refactor: Remove unused code and optimize useWhirlPoolInformation hook
mohandast52 Aug 9, 2024
af689c3
chore: address Tanya's review request
mohandast52 Aug 9, 2024
0097a42
chore: remove duplicate middleware
mohandast52 Aug 12, 2024
43dae31
chore: remvoe support for goerli
mohandast52 Aug 12, 2024
3afe314
chore: remove goerli and some CSS change
mohandast52 Aug 12, 2024
aad7b57
fix: bond error resolved
mohandast52 Aug 13, 2024
6226a88
chore: add logs for issue faced on Solana Liquidity
mohandast52 Aug 16, 2024
7db34fc
feat: calculation fix for deposit
mohandast52 Aug 16, 2024
3ff28ac
feat: calculate OLAS payout
mohandast52 Aug 16, 2024
6cf8d7d
feat: enhance error message in Solana liquidity management
mohandast52 Aug 22, 2024
b7ac697
feat: add tooltip to MyBonds - OLAS payout column
mohandast52 Aug 22, 2024
5c33ca9
fix: Add missing file to .gitleaksignore
mohandast52 Aug 22, 2024
501e504
fix: minor chnages
mohandast52 Aug 22, 2024
91701fc
feat: fix bonds-footer
mohandast52 Aug 22, 2024
04202e3
feat: add RPC endpoint to allowed origins in CSP header
mohandast52 Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Collaborator

@77ph 77ph Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not config for CELO

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't support CELO in tokenomics, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CELO bonding in tokenomics at stage of preparing voting. yes, not supported atm.

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
Comment on lines +241 to +242
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this our own API?
if so it should return some nullish reponse rather than 0, as this is an incorrect value..
no worries if not

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value is 0, which is why this calculation exists and also, we need to move the 0s to the bottom.

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
Loading