+
+
diff --git a/components/sidebar/context/aaveV2/SidebarAaveV2Borrow.vue b/components/sidebar/context/aaveV2/SidebarAaveV2Borrow.vue
index 7923e36..50f46af 100644
--- a/components/sidebar/context/aaveV2/SidebarAaveV2Borrow.vue
+++ b/components/sidebar/context/aaveV2/SidebarAaveV2Borrow.vue
@@ -35,7 +35,7 @@
@@ -212,6 +212,7 @@ export default defineComponent({
formatUsdMax,
formatUsd,
maxLiquidation,
+ liquidation,
liquidationPrice,
liquidationMaxPrice,
errorMessages,
diff --git a/components/sidebar/context/yearn-v2/SidebarYearnV2Supply.vue b/components/sidebar/context/yearn-v2/SidebarYearnV2Supply.vue
new file mode 100644
index 0000000..0970d01
--- /dev/null
+++ b/components/sidebar/context/yearn-v2/SidebarYearnV2Supply.vue
@@ -0,0 +1,183 @@
+
+
+ Supply {{ symbol }}
+
+
+
+ {{ formatNumber(balance) }} {{ symbol }}
+
+
+
+
+ Amount to supply
+
+
+
+
+
+
+
+
+
+
+
+
+ Supply
+
+
+
+
+
+
+
+
+
diff --git a/components/sidebar/context/yearn-v2/SidebarYearnV2Withdraw.vue b/components/sidebar/context/yearn-v2/SidebarYearnV2Withdraw.vue
new file mode 100644
index 0000000..6edefdd
--- /dev/null
+++ b/components/sidebar/context/yearn-v2/SidebarYearnV2Withdraw.vue
@@ -0,0 +1,179 @@
+
+
+ Withdraw {{ symbol }}
+
+
+
+ {{ formatNumber(balance) }} {{ symbol }}
+
+
+
+
+ Amount to withdraw
+
+
+
+
+
+
+
+
+
+
+
+
+ Withdraw
+
+
+
+
+
+
+
+
+
diff --git a/composables/protocols/useYearnV2Position.ts b/composables/protocols/useYearnV2Position.ts
new file mode 100644
index 0000000..a7a642d
--- /dev/null
+++ b/composables/protocols/useYearnV2Position.ts
@@ -0,0 +1,138 @@
+import { useWeb3 } from "@instadapp/vue-web3";
+import { ref, useContext, watch } from "@nuxtjs/composition-api";
+import addresses from "~/constant/addresses";
+import tokens from "~/constant/tokens";
+import { useDSA } from "../useDSA";
+import yearnV2ABI from "~/abis/read/yearnV2.json";
+import useEventBus from "../useEventBus";
+import BigNumber from "bignumber.js";
+import { useBigNumber } from "../useBigNumber";
+
+const resolver = addresses.mainnet.resolver.yearnV2;
+
+const allTokens = tokens.mainnet.allTokens.map(token => token.address);
+
+const wantAddresses = allTokens;
+
+const vaults = ref([]);
+
+export function useYearnV2Position() {
+ const { $axios } = useContext();
+ const { times } = useBigNumber();
+ const { library } = useWeb3();
+ const { activeAccount } = useDSA();
+ const { onEvent } = useEventBus();
+
+ const fetchPosition = async () => {
+ const availableVaults = await $axios
+ .$get("https://api.yearn.finance/v1/chains/1/vaults/all")
+ .then(vs => vs.filter(v => v.type === "v2"));
+
+ if (!library.value) {
+ return;
+ }
+
+ if (!activeAccount.value) {
+ return;
+ }
+
+ const resolverInstance = new library.value.eth.Contract(
+ yearnV2ABI as any,
+ resolver
+ );
+
+ // const tokensArr = wantAddresses;
+
+ // allow user to add custom tokens
+ const tokensArr = [
+ ...new Set(
+ availableVaults.filter(v => v.type === "v2").map(v => v.token.address)
+ .filter(a => allTokens.includes(a))
+ )
+ ];
+
+
+ const rawData = await resolverInstance.methods
+ .getPositionsForLatest(activeAccount.value.address, tokensArr)
+ .call();
+
+ const newVaults = [];
+
+ rawData.forEach(
+ ([
+ vaultLatestVersion,
+ vault,
+ want,
+ pricePerShare,
+ availableDepositLimit,
+ totalAssets,
+ balanceOf,
+ wantBalanceOf,
+ expectedShareValue,
+ decimals,
+ isDeprecated,
+ emergencyShutdown
+ ]) => {
+ const v = availableVaults.find(v => v.address === vault);
+ if (v) {
+ const supply = new BigNumber(balanceOf)
+ .dividedBy(10 ** decimals)
+ .toFixed();
+
+ newVaults.push({
+ ...v,
+ priceInUsd: v.tvl.price.toString(),
+ position: {
+ vaultLatestVersion,
+ vault,
+ want,
+ pricePerShare,
+ availableDepositLimit,
+ totalAssets,
+ balanceOf,
+ wantBalanceOf,
+ expectedShareValue,
+ decimals,
+ isDeprecated,
+ emergencyShutdown,
+ supply,
+ supplyUsd: times(supply, v.tvl.price).toFixed()
+ }
+ });
+ }
+ }
+ );
+ vaults.value = newVaults;
+ };
+
+ const refreshPosition = async () => {
+ await fetchPosition();
+ };
+
+ onEvent("protocol::compound::refresh", refreshPosition);
+
+ watch(
+ library,
+ async val => {
+ if (val) {
+ refreshPosition();
+ }
+ },
+ { immediate: true }
+ );
+
+ watch(
+ activeAccount,
+ async val => {
+ if (val) {
+ refreshPosition();
+ }
+ },
+ { immediate: true }
+ );
+
+ return {
+ vaults,
+ refreshPosition
+ };
+}
diff --git a/composables/useSidebar.ts b/composables/useSidebar.ts
index eeb2231..709a099 100644
--- a/composables/useSidebar.ts
+++ b/composables/useSidebar.ts
@@ -43,6 +43,9 @@ import SidebarReflexerWithdraw from '~/components/sidebar/context/reflexer/Sideb
import SidebarReflexerBorrow from '~/components/sidebar/context/reflexer/SidebarReflexerBorrow.vue'
import SidebarReflexerPayback from '~/components/sidebar/context/reflexer/SidebarReflexerPayback.vue'
+import SidebarYearnV2Supply from "~/components/sidebar/context/yearn-v2/SidebarYearnV2Supply.vue";
+import SidebarYearnV2Withdraw from '~/components/sidebar/context/yearn-v2/SidebarYearnV2Withdraw.vue'
+
import SidebarStrategySelection from '~/components/sidebar/context/strategy/SidebarStrategySelection.vue'
import SidebarStrategy from '~/components/sidebar/context/strategy/SidebarStrategy.vue'
@@ -86,6 +89,11 @@ const sidebars = {
"/mainnet/reflexer#withdraw": { component: SidebarReflexerWithdraw },
"/mainnet/reflexer#borrow": { component: SidebarReflexerBorrow },
"/mainnet/reflexer#payback": { component: SidebarReflexerPayback },
+
+
+ "/mainnet/yearn-v2": { component: null },
+ "/mainnet/yearn-v2#supply": { component: SidebarYearnV2Supply },
+ "/mainnet/yearn-v2#withdraw": { component: SidebarYearnV2Withdraw },
};
const sidebar = ref(null);
diff --git a/constant/addresses.ts b/constant/addresses.ts
index a1b4ac0..4268b2c 100644
--- a/constant/addresses.ts
+++ b/constant/addresses.ts
@@ -10,7 +10,8 @@ const addresses = {
maker: "0x84addce4fac0b6ee4b0cd132120d6d4b700e35c0",
unipool: "0x22bddA39D14eD0aafeee36B6e784602fdDE64723",
liquity: "0xDAf2A39503463B0F41f899EDD82213b3c96b6Cf8",
- reflexer: "0x016ca8d0993d1a7073b01802a2e22fd0df7e633a"
+ reflexer: "0x016ca8d0993d1a7073b01802a2e22fd0df7e633a",
+ yearnV2: "0x3f6DCA8a0b7d04737BC3B2aEAbeB1C09431581f0"
}
},
diff --git a/layouts/default.vue b/layouts/default.vue
index d60dd84..10d7dd1 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -9,7 +9,17 @@
class="px-8 md:px-4 max-w-6xl mx-auto"
:class="{ 'text-center': !active, 'py-12': active }"
>
-
+
+
+ Assembly doesn't support DSA v1
+
+
+ Please create or switch to DSA v2.
+
+
+
@@ -95,6 +105,7 @@ import { useNetwork } from "~/composables/useNetwork";
import { useModal } from "~/composables/useModal";
import { useEagerConnect } from "~/composables/useEagerConnect";
import Web3Modal from "~/components/modal/web3/Web3Modal.vue";
+import { useDSA } from "~/composables/useDSA";
export default defineComponent({
components: {
@@ -105,6 +116,7 @@ export default defineComponent({
},
setup() {
const { active, activate, deactivate, chainId } = useWeb3();
+ const { activeAccount } = useDSA();
const { activeNetworkId, activeNetwork, checkForNetworkMismatch } = useNetwork();
const { isShown: isBackdropShown, close: closeBackdrop } = useBackdrop()
const { redirect } = useContext()
@@ -154,6 +166,7 @@ export default defineComponent({
})
return {
+ activeAccount,
active,
activate,
deactivate,
diff --git a/package.json b/package.json
index d3f6966..be20e8c 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"bignumber.js": "^9.0.1",
"core-js": "^3.15.1",
"css-color-function": "^1.3.3",
- "dsa-connect": "^0.4.9",
+ "dsa-connect": "^0.5.0",
"nuxt": "^2.15.7",
"qrcode": "^1.4.4",
"slugify": "^1.6.0",
diff --git a/pages/aave-v2.vue b/pages/aave-v2.vue
index 3b00a21..4886640 100644
--- a/pages/aave-v2.vue
+++ b/pages/aave-v2.vue
@@ -131,7 +131,7 @@