Resolved merge conflict

This commit is contained in:
Lester Moore Lambac 2021-08-12 16:16:00 +08:00
commit 946fe27248
10 changed files with 29 additions and 100 deletions

View File

@ -1,4 +1,4 @@
# assembly-nuxt # Assembly
## Build Setup ## Build Setup
@ -18,52 +18,3 @@ $ yarn generate
``` ```
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org). For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
## Special Directories
You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.
### `assets`
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
### `components`
The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).
### `layouts`
Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).
### `pages`
This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
### `plugins`
The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
### `static`
This directory contains your static files. Each file inside this directory is mapped to `/`.
Example: `/static/robots.txt` is mapped as `/robots.txt`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
### `store`
This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).

View File

@ -68,7 +68,16 @@
> >
<!-- Selected: "font-semibold", Not Selected: "font-normal" --> <!-- Selected: "font-semibold", Not Selected: "font-normal" -->
<span class="flex items-center text-white"> <span class="flex items-center text-white">
<div class="mr-2">
<span
class="text-white flex-grow-0 flex-shrink-0 bg-primary-blue-border shadow-sm rounded text-[10px] p-1"
>
v{{ account.version }}
</span>
</div>
#{{ account.id }} #{{ account.id }}
</span> </span>
<span <span
@ -105,7 +114,11 @@
</div> </div>
</div> </div>
<button class="bg-primary-blue-darker hover:bg-primary-blue-hover border border-primary-blue-border text-white text-sm p-2 rounded flex items-center justify-center w-40" @click="createAccount" v-else> <button
class="bg-primary-blue-darker hover:bg-primary-blue-hover border border-primary-blue-border text-white text-sm p-2 rounded flex items-center justify-center w-40"
@click="createAccount"
v-else
>
Create Account Create Account
</button> </button>
</template> </template>

View File

@ -27,17 +27,6 @@
placeholder="Amount to borrow" placeholder="Amount to borrow"
:error="errors.amount.message" :error="errors.amount.message"
> >
<template v-if="!isMaxAmount" #suffix>
<div class="absolute mt-2 top-0 right-0 mr-4">
<button
type="button"
class="text-primary-blue-dark font-semibold text-sm hover:text-primary-blue-hover"
@click="toggle"
>
Max
</button>
</div>
</template>
</input-numeric> </input-numeric>
<SidebarContextHeading class="mt-5"> <SidebarContextHeading class="mt-5">
@ -150,12 +139,6 @@ export default defineComponent({
const address = computed(() => token.value?.address) const address = computed(() => token.value?.address)
const factor = computed(
() => displayPositions.value?.find((position) => rootTokenKey.value === position.key)?.factor
)
const { toggle, isMaxAmount } = useMaxAmountActive(amount, balance)
const { validateAmount, validateLiquidation, validateLiquidity, validateIsLoggedIn } = useValidators() const { validateAmount, validateLiquidation, validateLiquidity, validateIsLoggedIn } = useValidators()
const errors = computed(() => { const errors = computed(() => {
const hasAmountValue = !isZero(amount.value) const hasAmountValue = !isZero(amount.value)
@ -218,8 +201,6 @@ export default defineComponent({
formatNumber, formatNumber,
formatUsdMax, formatUsdMax,
formatUsd, formatUsd,
toggle,
isMaxAmount,
maxLiquidation, maxLiquidation,
liquidationPrice, liquidationPrice,
liquidationMaxPrice, liquidationMaxPrice,

View File

@ -19,17 +19,6 @@
placeholder="Amount to borrow" placeholder="Amount to borrow"
:error="errors.amount.message" :error="errors.amount.message"
> >
<template v-if="!isMaxAmount" #suffix>
<div class="absolute mt-2 top-0 right-0 mr-4">
<button
type="button"
class="text-primary-blue-dark font-semibold text-sm hover:text-primary-blue-hover"
@click="toggle"
>
Max
</button>
</div>
</template>
</input-numeric> </input-numeric>
<SidebarContextHeading class="mt-5"> <SidebarContextHeading class="mt-5">
@ -70,14 +59,12 @@
<script> <script>
import { computed, defineComponent, ref } from '@nuxtjs/composition-api' import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
import InputNumeric from '~/components/common/input/InputNumeric.vue' import InputNumeric from '~/components/common/input/InputNumeric.vue'
import { useBalances } from '~/composables/useBalances'
import { useBigNumber } from '~/composables/useBigNumber' import { useBigNumber } from '~/composables/useBigNumber'
import { useFormatting } from '~/composables/useFormatting' import { useFormatting } from '~/composables/useFormatting'
import { useValidators } from '~/composables/useValidators' import { useValidators } from '~/composables/useValidators'
import { useValidation } from '~/composables/useValidation' import { useValidation } from '~/composables/useValidation'
import { useToken } from '~/composables/useToken' import { useToken } from '~/composables/useToken'
import { useParsing } from '~/composables/useParsing' import { useParsing } from '~/composables/useParsing'
import { useMaxAmountActive } from '~/composables/useMaxAmountActive'
import { useWeb3 } from '~/composables/useWeb3' import { useWeb3 } from '~/composables/useWeb3'
import ToggleButton from '~/components/common/input/ToggleButton.vue' import ToggleButton from '~/components/common/input/ToggleButton.vue'
import { useDSA } from '~/composables/useDSA' import { useDSA } from '~/composables/useDSA'
@ -140,10 +127,6 @@ export default defineComponent({
return currentPosition.value?.borrow || '0' return currentPosition.value?.borrow || '0'
}) })
const address = computed(() => token.value?.address)
const { toggle, isMaxAmount } = useMaxAmountActive(amount, balance)
const { validateAmount, validateLiquidation, validateLiquidity, validateIsLoggedIn } = useValidators() const { validateAmount, validateLiquidation, validateLiquidity, validateIsLoggedIn } = useValidators()
const errors = computed(() => { const errors = computed(() => {
const hasAmountValue = !isZero(amount.value) const hasAmountValue = !isZero(amount.value)
@ -202,8 +185,6 @@ export default defineComponent({
formatNumber, formatNumber,
formatUsdMax, formatUsdMax,
formatUsd, formatUsd,
toggle,
isMaxAmount,
liquidationPrice, liquidationPrice,
liquidationMaxPrice, liquidationMaxPrice,
errorMessages, errorMessages,

View File

@ -11,6 +11,7 @@ import { Network } from "./useNetwork";
import { useBigNumber } from "./useBigNumber"; import { useBigNumber } from "./useBigNumber";
import { usePosition } from "./usePosition"; import { usePosition } from "./usePosition";
import { useToken } from "./useToken"; import { useToken } from "./useToken";
import { useSorting } from "./useSorting";
const { const {
times, times,
@ -67,7 +68,8 @@ export function useAaveV2Position(
const { web3, chainId, networkName } = useWeb3(); const { web3, chainId, networkName } = useWeb3();
const { activeAccount } = useDSA(); const { activeAccount } = useDSA();
const { getTokenByKey, allATokensV2 } = useToken(); const { getTokenByKey, allATokensV2 } = useToken();
const { byMaxSupplyOrBorrowDesc } = useSorting()
const resolver = computed(() => const resolver = computed(() =>
chainId.value === 1 chainId.value === 1
? "0xFb3a1D56eD56F046721B9aCa749895100754578b" ? "0xFb3a1D56eD56F046721B9aCa749895100754578b"
@ -204,7 +206,8 @@ export function useAaveV2Position(
max(a.supplyUsd, a.borrowUsd) max(a.supplyUsd, a.borrowUsd)
).toNumber() ).toNumber()
) )
.map(overridePosition); .map(overridePosition)
.sort(byMaxSupplyOrBorrowDesc);
}); });
function getPositionOrDefaultPosition(token, position) { function getPositionOrDefaultPosition(token, position) {

View File

@ -13,6 +13,7 @@ import { useToken } from "./useToken";
import addresses from "~/constant/addresses"; import addresses from "~/constant/addresses";
import ctokens from "~/constant/ctokens"; import ctokens from "~/constant/ctokens";
import tokenIdMapping from "~/constant/tokenIdMapping"; import tokenIdMapping from "~/constant/tokenIdMapping";
import { useSorting } from "./useSorting";
const { const {
times, times,
@ -64,7 +65,7 @@ export function useCompoundPosition(
const { web3, networkName } = useWeb3(); const { web3, networkName } = useWeb3();
const { activeAccount } = useDSA(); const { activeAccount } = useDSA();
const { getTokenByKey } = useToken(); const { getTokenByKey } = useToken();
const { byMaxSupplyOrBorrowDesc } = useSorting()
const resolver = computed(() => addresses.mainnet.resolver.compound); const resolver = computed(() => addresses.mainnet.resolver.compound);
const fetchPosition = async () => { const fetchPosition = async () => {
@ -195,7 +196,8 @@ export function useCompoundPosition(
return false; return false;
} }
return true; return true;
}); })
.sort(byMaxSupplyOrBorrowDesc);
}); });
function getPositionOrDefaultPosition(token, pos) { function getPositionOrDefaultPosition(token, pos) {

View File

@ -16,8 +16,7 @@ export function useDSA() {
if (web3.value) { if (web3.value) {
dsa.value = new DSA(web3.value, chainId.value); dsa.value = new DSA(web3.value, chainId.value);
} }
}, }
{ immediate: true }
); );
watch( watch(
@ -39,8 +38,7 @@ export function useDSA() {
activeAccount.value = accounts.value[0]; activeAccount.value = accounts.value[0];
} }
} }
}, }
{ immediate: true }
); );
watch( watch(

View File

@ -110,6 +110,7 @@ export function useWeb3() {
// Subscribe to chainId change // Subscribe to chainId change
provider.on("chainChanged", refreshWeb3); provider.on("chainChanged", refreshWeb3);
provider.on("accountsChanged", refreshWeb3);
}; };
const refreshWeb3 = async () => { const refreshWeb3 = async () => {
@ -119,7 +120,6 @@ export function useWeb3() {
let newWeb3 = new Web3(web3Provider); let newWeb3 = new Web3(web3Provider);
chainId.value = await newWeb3.eth.getChainId(); chainId.value = await newWeb3.eth.getChainId();
web3.value = newWeb3; web3.value = newWeb3;
window.web3 = web3.value;
}; };
return { return {

View File

@ -12,7 +12,7 @@
<div class="text-center py-8"> <div class="text-center py-8">
<a <a
class="font-medium text-primary-blue-dark hover:text-primary-blue-hover hover:underline" class="font-medium text-primary-blue-dark hover:text-primary-blue-hover hover:underline"
href="https://github.com/Instadapp/assembly-nuxt" href="https://github.com/Instadapp/assembly"
target="_blank" target="_blank"
> >
Contribute on GitHub Contribute on GitHub

View File

@ -1,5 +1,5 @@
{ {
"name": "assembly-nuxt", "name": "assembly",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"scripts": { "scripts": {