Skip to content

Commit

Permalink
fix: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Jun 27, 2023
1 parent 8560cbb commit 57aa06e
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useWeb3 from '@/services/web3/useWeb3';
import useNumbers, { FNumFormats } from '@/composables/useNumbers';
import useVeBal from '@/composables/useVeBAL';
import { useTokens } from '@/providers/tokens.provider';
import BigNumber from 'bignumber.js';
import { bnum } from '@/lib/utils';
import {
useCrossChainSync,
NetworkSyncState,
Expand Down Expand Up @@ -42,7 +42,7 @@ const isSyncModalOpen = ref(false);
* COMPUTED
*/
const isVebalBalanceZero = computed(() => {
return new BigNumber(veBalBalance.value).isEqualTo(0);
return bnum(veBalBalance.value).isEqualTo(0);
});
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const networkSyncSteps = computed(() => {
}),
});
});
console.log('actions', actions);
return actions;
});
</script>
Expand Down
13 changes: 6 additions & 7 deletions src/composables/queries/useCrossChainNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import configs, { Network } from '@/lib/config';
import { allEqual } from '@/lib/utils/array';
import BigNumber from 'bignumber.js';
import { NetworkSyncState } from '@/providers/cross-chain-sync.provider';
import { OmniEscrowLock } from './useOmniEscrowLocksQuery';
import {
VotingEscrowLock,
useVotingEscrowLocksQuery,
} from './useVotingEscrowQuery';
import useWeb3 from '@/services/web3/useWeb3';
import { bnum } from '@/lib/utils';

export function useCrossChainNetwork(
networkId: Network,
Expand Down Expand Up @@ -89,17 +89,16 @@ export function useCrossChainNetwork(
const slope = votingEscrowLocks.value?.slope;
const timestamp = votingEscrowLocks.value?.timestamp;

if (!bias || !slope || !timestamp)
return new BigNumber(0).toFixed(4).toString();
if (!bias || !slope || !timestamp) return bnum(0).toFixed(4).toString();

const x = new BigNumber(slope).multipliedBy(
const x = bnum(slope).multipliedBy(
Math.floor(Date.now() / 1000) - timestamp
);

if (x.isLessThan(0)) return new BigNumber(bias).toFixed(4).toString();
if (x.isLessThan(0)) return bnum(bias).toFixed(4).toString();

const balance = new BigNumber(bias).minus(x);
if (balance.isLessThan(0)) return new BigNumber(0).toFixed(4).toString();
const balance = bnum(bias).minus(x);
if (balance.isLessThan(0)) return bnum(0).toFixed(4).toString();

return balance.toFixed(4).toString();
}
Expand Down
5 changes: 2 additions & 3 deletions src/composables/queries/useOmniEscrowLocksQuery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import QUERY_KEYS from '@/constants/queryKeys';
import useGraphQuery from './useGraphQuery';
import useNetwork from '../useNetwork';
import { networkSubgraphGagesMap } from './useVotingEscrowQuery';
import { Network } from '@/lib/config';
import config, { Network } from '@/lib/config';

const attrs = {
id: true,
Expand Down Expand Up @@ -41,7 +40,7 @@ export function useOmniEscrowLocksQuery(account: ComputedRef<string>) {
const queryKey = QUERY_KEYS.Gauges.OmniEscrowLocks(networkId, account);

return useGraphQuery<OmniEscrowLockResponse>(
networkSubgraphGagesMap[Network.MAINNET],
config[Network.MAINNET].subgraphs.gauge,
queryKey,
() => ({
__name: 'OmniEscrowLocks',
Expand Down
17 changes: 2 additions & 15 deletions src/composables/queries/useVotingEscrowQuery.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import QUERY_KEYS from '@/constants/queryKeys';
import useGraphQuery from './useGraphQuery';
import useWeb3 from '@/services/web3/useWeb3';
import { Network } from '@/lib/config';

export const networkSubgraphGagesMap = {
[Network.MAINNET]:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges',
[Network.ARBITRUM]:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-arbitrum',
[Network.POLYGON]:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-polygon',
[Network.OPTIMISM]:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-optimism',
[Network.GNOSIS]:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-gnosis-chain',
};
import config, { Network } from '@/lib/config';

export interface VotingEscrowLock {
id: string;
Expand Down Expand Up @@ -54,7 +41,7 @@ export function useVotingEscrowLocksQuery(
});

return useGraphQuery<VotingEscrowLockResponse>(
networkSubgraphGagesMap[networkId],
config[networkId].subgraphs.gauge,
QUERY_KEYS.Gauges.VotingEscrowLocksByNetworkId(networkId, account, user),
() => ({
__name: 'VotingEscrowLocks',
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function useLock({ enabled = true }: Options = {}) {
: '0'
);

const poolShares = computed(() => {
const bptPrice = computed(() => {
if (!lockPool.value) return bnum(0);
return bnum(lockPool.value.totalLiquidity).div(lockPool.value.totalShares);
});
Expand All @@ -76,7 +76,7 @@ export function useLock({ enabled = true }: Options = {}) {
});

const fiatTotal = computed(() =>
poolShares.value.times(bptBalance.value).toString()
bptPrice.value.times(bptBalance.value).toString()
);

return {
Expand Down
13 changes: 0 additions & 13 deletions src/lib/utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,3 @@ export function buildConnectorIconURL(wallet: Wallet): string {
import.meta.url
).href;
}

export function buildNetworkIconUrlV2(network: Network | string): string {
const networkName =
typeof network === 'string' ? network : getNetworkIconName(network);

const result = new URL(
// https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url
// Warning: Don't extract this template into a variable or it will stop working in production builds
`/src/assets/images/icons/networks-2/${networkName}.svg`,
import.meta.url
).href;
return result;
}
1 change: 0 additions & 1 deletion src/pages/vebal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ providePoolStaking();
{{ $t('veBAL.notSupported.title') }}
</div>
<div>{{ $t('veBAL.notSupported.description') }}</div>
<div></div>
</div>
</div>
</template>
1 change: 0 additions & 1 deletion src/providers/cross-chain-sync.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export const crossChainSyncProvider = () => {
);

const { nativeFee } = tx;
console.log('nativeFee', nativeFee);

const sendUserBalanceTx = await omniVotingEscrowContract.sendUserBalance({
signer,
Expand Down
1 change: 0 additions & 1 deletion src/providers/wallet.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export const wallets = () => {
return getAddress(pluginState.connector.account);
}
return '';
// return '0x4ec8459bb6bab83d8987373f6ae47b9a60bd5a6a';
});

const chainId = computed(() => {
Expand Down

0 comments on commit 57aa06e

Please sign in to comment.