Skip to content

Commit

Permalink
chore: Add static lock pool data
Browse files Browse the repository at this point in the history
  • Loading branch information
garethfuller committed Oct 25, 2024
1 parent de39964 commit 03c0cd5
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 35 deletions.
13 changes: 5 additions & 8 deletions src/components/forms/lock_actions/LockForm/LockForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,40 @@
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';
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<Pool | undefined>(
() => lockablePoolQuery.data.value
);
const lockablePool = computed<Pool | undefined>(() => staticLockPool);
const lockablePoolTokenInfo = computed(() =>
lockablePool.value != null ? getToken(lockablePool.value.address) : null
Expand Down
13 changes: 5 additions & 8 deletions src/components/forms/lock_actions/UnlockForm/UnlockForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pool | undefined>(
() => lockablePoolQuery.data.value
);
const lockablePool = computed<Pool | undefined>(() => staticLockPool);
const lockablePoolTokenInfo = computed(() =>
lockablePool.value != null ? getToken(lockablePool.value.address) : null
Expand Down
125 changes: 107 additions & 18 deletions src/composables/useLock.ts
Original file line number Diff line number Diff line change
@@ -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<Pool | undefined>(() => lockPoolQuery.data.value);
const lockPool = computed<Pool | undefined>(() => staticLockPool);
console.log('lockPool', lockPool.value);

const lockPoolToken = computed((): TokenInfo | null =>
lockPool.value != null ? getToken(lockPool.value.address) : null
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config/mainnet/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Keys } from '../types';
const keys: Keys = {
infura: 'daaa68ec242643719749dd1caba2fc66',
alchemy: '',
graph: 'a84caa9e5c322a2faec24ad89ccb9d28',
graph: '91429265f2a0b1852cd6665ce5fa6a3e',
balancerApi: 'da2-7a3ukmnw7bexndpx5x522uafui',
};

Expand Down

0 comments on commit 03c0cd5

Please sign in to comment.