diff --git a/components/common/input/Dropdown.vue b/components/common/input/Dropdown.vue new file mode 100644 index 0000000..c3cf623 --- /dev/null +++ b/components/common/input/Dropdown.vue @@ -0,0 +1,46 @@ + + + diff --git a/components/protocols/DropdownMakerdao.vue b/components/protocols/DropdownMakerdao.vue new file mode 100644 index 0000000..e8517aa --- /dev/null +++ b/components/protocols/DropdownMakerdao.vue @@ -0,0 +1,96 @@ + + + diff --git a/components/protocols/DropdownMenu.vue b/components/protocols/DropdownMenu.vue new file mode 100644 index 0000000..85dd0e2 --- /dev/null +++ b/components/protocols/DropdownMenu.vue @@ -0,0 +1,21 @@ + + + diff --git a/components/sidebar/context/makerdao/SidebarMakerdaoCollateral.vue b/components/sidebar/context/makerdao/SidebarMakerdaoCollateral.vue new file mode 100644 index 0000000..f7f6f4e --- /dev/null +++ b/components/sidebar/context/makerdao/SidebarMakerdaoCollateral.vue @@ -0,0 +1,83 @@ + + + diff --git a/composables/useMakerdaoPosition.ts b/composables/useMakerdaoPosition.ts index ba0d0f4..e1d2fcb 100644 --- a/composables/useMakerdaoPosition.ts +++ b/composables/useMakerdaoPosition.ts @@ -25,7 +25,7 @@ const defaultVault = { netvalue: "0" }; -const vaultId = ref("0"); +const vaultId = ref(null); const vaults = ref([]); const isNewVault = ref(false); const vaultTypes = ref([]); @@ -50,7 +50,10 @@ const vault = computed(() => { return defaultVault; }); -export function useMakerdaoPosition(collateralAmountRef: Ref =null, debtAmountRef: Ref = null) { +export function useMakerdaoPosition( + collateralAmountRef: Ref = null, + debtAmountRef: Ref = null +) { const { web3, chainId, networkName } = useWeb3(); const { activeAccount } = useDSA(); const { isZero, ensureValue, times, div, max, gt } = useBigNumber(); @@ -78,19 +81,32 @@ export function useMakerdaoPosition(collateralAmountRef: Ref =null, debtAmountRe const netValue = computed(() => ensureValue(vault.value.netValue).toFixed()); const status = computed(() => { - if (!collateralAmountRef || !debtAmountRef) return ensureValue(vault.value.status).toFixed() + if (!collateralAmountRef || !debtAmountRef) + return ensureValue(vault.value.status).toFixed(); return isZero(collateralAmountRef.value) && !isZero(debtAmountRef.value) - ? '1.1' - : div(debtAmountRef.value, times(collateralAmountRef.value, price.value)).toFixed() - }) + ? "1.1" + : div( + debtAmountRef.value, + times(collateralAmountRef.value, price.value) + ).toFixed(); + }); const liquidationPrice = computed(() => { if (!collateralAmountRef || !debtAmountRef) - return max(div(div(debt.value, collateral.value), liquidation.value), '0').toFixed() + return max( + div(div(debt.value, collateral.value), liquidation.value), + "0" + ).toFixed(); return isZero(collateralAmountRef.value) && !isZero(debtAmountRef.value) - ? times(price.value, '1.1').toFixed() - : max(div(div(debtAmountRef.value, collateralAmountRef.value), liquidation.value), '0').toFixed() - }) + ? times(price.value, "1.1").toFixed() + : max( + div( + div(debtAmountRef.value, collateralAmountRef.value), + liquidation.value + ), + "0" + ).toFixed(); + }); const debt = computed(() => ensureValue(vault.value.debt).toFixed()); const minDebt = computed(() => vaultTypes.value[0]?.totalFloor || "5000"); @@ -136,9 +152,16 @@ export function useMakerdaoPosition(collateralAmountRef: Ref =null, debtAmountRe { immediate: true } ); + const selectVault = vid => { + if (vid === vaultId.value && !isNewVault.value) return; + vaultId.value = vid; + isNewVault.value = false; + }; + return { fetchPosition, - vaultId, + vaultId: computed(() => (isNewVault.value ? "0" : vaultId.value || "0")), + selectVault, vaultTokenType, vault, vaults, @@ -245,7 +268,7 @@ async function getVaults(user, web3) { ratePerBlock, priceInWei, liquidationRatioCbyD, - urn, + urn ]) => { const collateral = new BigNumber(collInWei).dividedBy(1e18); const debt = new BigNumber(debtInWei).dividedBy(1e18); diff --git a/composables/useSidebar.ts b/composables/useSidebar.ts index ff1c27d..258d1f2 100644 --- a/composables/useSidebar.ts +++ b/composables/useSidebar.ts @@ -23,6 +23,7 @@ import SidebarCompoundSupply from '~/components/sidebar/context/compound/Sidebar import SidebarCompoundBorrow from '~/components/sidebar/context/compound/SidebarCompoundBorrow.vue' import SidebarCompoundPayback from '~/components/sidebar/context/compound/SidebarCompoundPayback.vue' +import SidebarMakerdaoCollateral from '~/components/sidebar/context/makerdao/SidebarMakerdaoCollateral.vue' import SidebarMakerdaoSupply from '~/components/sidebar/context/makerdao/SidebarMakerdaoSupply.vue' import SidebarMakerdaoWithdraw from '~/components/sidebar/context/makerdao/SidebarMakerdaoWithdraw.vue' import SidebarMakerdaoBorrow from '~/components/sidebar/context/makerdao/SidebarMakerdaoBorrow.vue' @@ -53,6 +54,7 @@ const sidebars = { "/mainnet/compound#payback": { component: SidebarCompoundPayback }, "/mainnet/maker": { component: null }, + '/mainnet/maker#collateral': { component: SidebarMakerdaoCollateral }, "/mainnet/maker#supply": { component: SidebarMakerdaoSupply }, "/mainnet/maker#withdraw": { component: SidebarMakerdaoWithdraw }, "/mainnet/maker#borrow": { component: SidebarMakerdaoBorrow }, diff --git a/layouts/default.vue b/layouts/default.vue index 7733590..befc0ec 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -115,10 +115,9 @@ export default defineComponent({ } }, { immediate: true }) - // onErrorCaptured(() => { - - // return false - // }) + onErrorCaptured(() => { + return false + }) return { active, diff --git a/pages/mainnet/maker.vue b/pages/mainnet/maker.vue index b9a7c45..1ccecee 100644 --- a/pages/mainnet/maker.vue +++ b/pages/mainnet/maker.vue @@ -10,8 +10,10 @@ -
+

MakerDAO

+ +
@@ -148,6 +150,7 @@ import { useFormatting } from "~/composables/useFormatting"; import { useMakerdaoPosition } from "~/composables/useMakerdaoPosition"; import { useStatus } from "~/composables/useStatus"; import { useNotification } from "~/composables/useNotification"; +import DropdownMakerdao from "~/components/protocols/DropdownMakerdao.vue"; export default defineComponent({ components: { @@ -157,7 +160,8 @@ export default defineComponent({ SVGBalance, SVGEarnings, SVGArrowRight, - SVGPercent + SVGPercent, + DropdownMakerdao }, setup() { const router = useRouter(); diff --git a/pages/test.vue b/pages/test.vue deleted file mode 100644 index 2ad9082..0000000 --- a/pages/test.vue +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file