This commit is contained in:
Georges KABBOUCHI 2021-09-06 20:04:21 +03:00
parent 41803ddffe
commit 4430b40dbd

View File

@ -7,7 +7,7 @@ import reflexerSafes from "~/constant/tokens/safes";
import { useBigNumber } from "~/composables/useBigNumber"; import { useBigNumber } from "~/composables/useBigNumber";
import { useDSA } from "~/composables/useDSA"; import { useDSA } from "~/composables/useDSA";
import { useToken } from "~/composables/useToken"; import { useToken } from "~/composables/useToken";
import { useWeb3 } from "~/composables/useWeb3"; import { useWeb3 } from "@instadapp/vue-web3";
import { AbiItem } from "web3-utils"; import { AbiItem } from "web3-utils";
import { useBalances } from "../useBalances"; import { useBalances } from "../useBalances";
@ -57,7 +57,7 @@ export function useReflexerPosition(
collateralAmountRef: Ref = null, collateralAmountRef: Ref = null,
debtAmountRef: Ref = null debtAmountRef: Ref = null
) { ) {
const { web3, chainId, networkName } = useWeb3(); const { library } = useWeb3();
const { activeAccount } = useDSA(); const { activeAccount } = useDSA();
const { isZero, ensureValue, times, div, max, gt, toBN } = useBigNumber(); const { isZero, ensureValue, times, div, max, gt, toBN } = useBigNumber();
const { getTokenByKey } = useToken(); const { getTokenByKey } = useToken();
@ -132,23 +132,23 @@ export function useReflexerPosition(
); );
const fetchPosition = async () => { const fetchPosition = async () => {
if (!web3.value) { if (!library.value) {
return; return;
} }
safeTypes.value = await getSafeTypes(web3.value); safeTypes.value = await getSafeTypes(library.value);
if (!activeAccount.value) { if (!activeAccount.value) {
return; return;
} }
safes.value = await getSafes(activeAccount.value.address, web3.value); safes.value = await getSafes(activeAccount.value.address, library.value);
if (safes.value.length > 0 && !safeId.value) { if (safes.value.length > 0 && !safeId.value) {
safeId.value = safes.value[0].id; safeId.value = safes.value[0].id;
} }
}; };
watch( watch(
web3, library,
async val => { async val => {
if (val) { if (val) {
fetchPosition(); fetchPosition();