From 03c0cd5b0a9077e6590a57596cd8f5a3393cca94 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Fri, 25 Oct 2024 15:46:29 +0100 Subject: [PATCH] chore: Add static lock pool data --- .../forms/lock_actions/LockForm/LockForm.vue | 13 +- .../lock_actions/UnlockForm/UnlockForm.vue | 13 +- src/composables/useLock.ts | 125 +++++++++++++++--- src/lib/config/mainnet/keys.ts | 2 +- 4 files changed, 118 insertions(+), 35 deletions(-) diff --git a/src/components/forms/lock_actions/LockForm/LockForm.vue b/src/components/forms/lock_actions/LockForm/LockForm.vue index cbc940d4a5..2573b04489 100644 --- a/src/components/forms/lock_actions/LockForm/LockForm.vue +++ b/src/components/forms/lock_actions/LockForm/LockForm.vue @@ -2,11 +2,9 @@ import { computed } from 'vue'; import Col3Layout from '@/components/layouts/Col3Layout.vue'; -import usePoolQuery from '@/composables/queries/usePoolQuery'; import useVeBalLockInfoQuery from '@/composables/queries/useVeBalLockInfoQuery'; import useBreakpoints from '@/composables/useBreakpoints'; import { useTokens } from '@/providers/tokens.provider'; -import useVeBal from '@/composables/useVeBAL'; import { Pool } from '@/services/pool/types'; import useWeb3 from '@/services/web3/useWeb3'; @@ -14,31 +12,30 @@ import HowToLock from './components/HowToLock.vue'; import LockableTokens from './components/LockableTokens.vue'; import MyVeBAL from './components/MyVeBAL.vue'; import VeBalForm from './components/VeBalForm/VeBalForm.vue'; +import { staticLockPool } from '@/composables/useLock'; /** * COMPOSABLES */ const { getToken } = useTokens(); const { isWalletReady } = useWeb3(); -const { lockablePoolId } = useVeBal(); +// const { lockablePoolId } = useVeBal(); const { isDesktop, isMobile } = useBreakpoints(); /** * QUERIES */ -const lockablePoolQuery = usePoolQuery(lockablePoolId.value as string); +// const lockablePoolQuery = usePoolQuery(lockablePoolId.value as string); const veBalLockInfoQuery = useVeBalLockInfoQuery(); /** * COMPUTED */ -const lockablePoolLoading = computed(() => lockablePoolQuery.isLoading.value); +const lockablePoolLoading = computed(() => false); const veBalQueryLoading = computed(() => veBalLockInfoQuery.isLoading.value); -const lockablePool = computed( - () => lockablePoolQuery.data.value -); +const lockablePool = computed(() => staticLockPool); const lockablePoolTokenInfo = computed(() => lockablePool.value != null ? getToken(lockablePool.value.address) : null diff --git a/src/components/forms/lock_actions/UnlockForm/UnlockForm.vue b/src/components/forms/lock_actions/UnlockForm/UnlockForm.vue index 2a4d9d3b08..b59ff48229 100644 --- a/src/components/forms/lock_actions/UnlockForm/UnlockForm.vue +++ b/src/components/forms/lock_actions/UnlockForm/UnlockForm.vue @@ -2,39 +2,36 @@ import { computed } from 'vue'; import Col3Layout from '@/components/layouts/Col3Layout.vue'; -import usePoolQuery from '@/composables/queries/usePoolQuery'; import useVeBalLockInfoQuery from '@/composables/queries/useVeBalLockInfoQuery'; import { useTokens } from '@/providers/tokens.provider'; -import useVeBal from '@/composables/useVeBAL'; import { Pool } from '@/services/pool/types'; import useWeb3 from '@/services/web3/useWeb3'; import MyVeBAL from '../LockForm/components/MyVeBAL.vue'; import VeBalUnlockForm from './components/VeBalUnlockForm/VeBalUnlockForm.vue'; +import { staticLockPool } from '@/composables/useLock'; /** * COMPOSABLES */ const { getToken } = useTokens(); const { isWalletReady } = useWeb3(); -const { lockablePoolId } = useVeBal(); +// const { lockablePoolId } = useVeBal(); /** * QUERIES */ -const lockablePoolQuery = usePoolQuery(lockablePoolId.value as string); +// const lockablePoolQuery = usePoolQuery(lockablePoolId.value as string); const veBalLockInfoQuery = useVeBalLockInfoQuery(); /** * COMPUTED */ -const lockablePoolLoading = computed(() => lockablePoolQuery.isLoading.value); +const lockablePoolLoading = computed(() => false); const veBalQueryLoading = computed(() => veBalLockInfoQuery.isLoading.value); -const lockablePool = computed( - () => lockablePoolQuery.data.value -); +const lockablePool = computed(() => staticLockPool); const lockablePoolTokenInfo = computed(() => lockablePool.value != null ? getToken(lockablePool.value.address) : null diff --git a/src/composables/useLock.ts b/src/composables/useLock.ts index 688d4e178e..1b18c65b42 100644 --- a/src/composables/useLock.ts +++ b/src/composables/useLock.ts @@ -1,49 +1,138 @@ -import { Pool } from '@/services/pool/types'; +import { Pool, PoolType } from '@/services/pool/types'; import { TokenInfo } from '@/types/TokenList'; import { useTokens } from '@/providers/tokens.provider'; import { useUserData } from '@/providers/user-data.provider'; -import usePoolQuery from './queries/usePoolQuery'; import { fiatValueOf } from './usePoolHelpers'; -import useVeBal, { isVeBalSupported } from './useVeBAL'; import { bnum } from '@/lib/utils'; +export const staticLockPool: Pool = { + id: '0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014', + name: 'Balancer 80 BAL 20 WETH', + address: '0x5c6ee304399dbdb9c8ef030ab642b10820db8f56', + chainId: 1, + poolType: PoolType.Weighted, + poolTypeVersion: 1, + swapFee: '0.005', + swapEnabled: true, + protocolYieldFeeCache: '0.5', + protocolSwapFeeCache: '0.5', + owner: '0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b', + factory: '0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0', + symbol: 'B-80BAL-20WETH', + tokens: [ + { + address: '0xba100000625a3754423978a60c9317c58a424e3d', + balance: '19385573.977733216984154245', + decimals: 18, + isExemptFromYieldProtocolFee: false, + priceRate: '1', + symbol: 'BAL', + token: { + pool: null, + latestUSDPrice: '3.020051763151765590907891699486145', + }, + weight: '0.8', + }, + { + address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + balance: '3708.004332746461130832', + decimals: 18, + isExemptFromYieldProtocolFee: false, + priceRate: '1', + symbol: 'WETH', + token: { + pool: null, + latestUSDPrice: '2544.423752510128812336112279381925', + }, + weight: '0.2', + }, + ], + tokensList: [ + '0xba100000625a3754423978a60c9317c58a424e3d', + '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + ], + tokenAddresses: [ + '0xba100000625a3754423978a60c9317c58a424e3d', + '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + ], + totalLiquidity: '67980171.169812751723110183', + totalShares: '6792743.266911456277523322', + totalSwapFee: '6173259.879907230383616330051651873', + totalSwapVolume: '1398500114.898508628102297818442082', + priceRateProviders: [], + createTime: 1620153071, + totalWeight: '1', + lowerTarget: '0', + upperTarget: '0', + isInRecoveryMode: false, + isPaused: false, + isNew: false, + onchain: { + tokens: { + '0xba100000625a3754423978a60c9317c58a424e3d': { + decimals: 18, + balance: '19385573.977733216984154245', + weight: 0.8, + symbol: 'BAL', + name: 'Balancer', + logoURI: + 'https://raw.githubusercontent.com/balancer/tokenlists/main/src/assets/images/tokens/0xba100000625a3754423978a60c9317c58a424e3d.png', + }, + '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2': { + decimals: 18, + balance: '3708.004332746461130832', + weight: 0.2, + symbol: 'WETH', + name: 'Wrapped Ether', + logoURI: + 'https://raw.githubusercontent.com/balancer/tokenlists/main/src/assets/images/tokens/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png', + }, + }, + amp: '0', + swapEnabled: true, + totalSupply: '6792743.266911456277523322', + decimals: 18, + swapFee: '0.005', + }, + feesSnapshot: '866.901337693887527854586071982', + volumeSnapshot: '333819.702829775009564326720188', +}; + interface Options { enabled?: boolean; } +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function useLock({ enabled = true }: Options = {}) { /** * COMPOSABLES */ - const { lockablePoolId } = useVeBal(); + // const { lockablePoolId } = useVeBal(); const { getToken, balanceFor } = useTokens(); /** * QUERIES */ - const shouldFetchLockPool = computed( - (): boolean => isVeBalSupported.value && enabled - ); - const lockPoolQuery = usePoolQuery( - lockablePoolId.value as string, - shouldFetchLockPool - ); + // const shouldFetchLockPool = computed( + // (): boolean => isVeBalSupported.value && enabled + // ); + // const lockPoolQuery = usePoolQuery( + // lockablePoolId.value as string, + // shouldFetchLockPool + // ); const { lockQuery } = useUserData(); /** * COMPUTED */ - const isLoadingLockPool = computed( - (): boolean => lockPoolQuery.isLoading.value - ); + const isLoadingLockPool = false; const isLoadingLockInfo = computed((): boolean => lockQuery.isLoading.value); - const isLoadingLock = computed( - (): boolean => isLoadingLockPool.value || isLoadingLockInfo.value - ); + const isLoadingLock = computed((): boolean => isLoadingLockInfo.value); - const lockPool = computed(() => lockPoolQuery.data.value); + const lockPool = computed(() => staticLockPool); + console.log('lockPool', lockPool.value); const lockPoolToken = computed((): TokenInfo | null => lockPool.value != null ? getToken(lockPool.value.address) : null diff --git a/src/lib/config/mainnet/keys.ts b/src/lib/config/mainnet/keys.ts index 1385da2c5d..e941fd0583 100644 --- a/src/lib/config/mainnet/keys.ts +++ b/src/lib/config/mainnet/keys.ts @@ -3,7 +3,7 @@ import { Keys } from '../types'; const keys: Keys = { infura: 'daaa68ec242643719749dd1caba2fc66', alchemy: '', - graph: 'a84caa9e5c322a2faec24ad89ccb9d28', + graph: '91429265f2a0b1852cd6665ce5fa6a3e', balancerApi: 'da2-7a3ukmnw7bexndpx5x522uafui', };