From 1b4808be30813075141c9ff3ee8179de2a2a980d Mon Sep 17 00:00:00 2001 From: shmuel Date: Sun, 10 Oct 2021 13:38:19 +0300 Subject: [PATCH 1/6] working state --- assets/icons/b-protocol.svg | 24 ++ .../protocols/bprotocol/CardBprotocolBamm.vue | 139 +++++++++++ .../bprotocol/SidebarBprotocolDeposit.vue | 216 +++++++++++++++++ .../bprotocol/SidebarBprotocolWithdraw.vue | 219 ++++++++++++++++++ .../liquity/SidebarLiquityPoolWithdraw.vue | 2 +- .../protocols/useBprotocolLqtyClaim.ts | 62 +++++ .../protocols/useBprotocolPositions.ts | 155 +++++++++++++ composables/useSidebar.ts | 6 + constant/abi/read/bprotocol.json | 1 + constant/abis.ts | 7 +- constant/addresses.ts | 4 +- pages/index.vue | 9 +- pages/mainnet/bprotocol.vue | 115 +++++++++ 13 files changed, 954 insertions(+), 5 deletions(-) create mode 100644 assets/icons/b-protocol.svg create mode 100644 components/protocols/bprotocol/CardBprotocolBamm.vue create mode 100644 components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue create mode 100644 components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue create mode 100644 composables/protocols/useBprotocolLqtyClaim.ts create mode 100644 composables/protocols/useBprotocolPositions.ts create mode 100644 constant/abi/read/bprotocol.json create mode 100644 pages/mainnet/bprotocol.vue diff --git a/assets/icons/b-protocol.svg b/assets/icons/b-protocol.svg new file mode 100644 index 0000000..3331f89 --- /dev/null +++ b/assets/icons/b-protocol.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/protocols/bprotocol/CardBprotocolBamm.vue b/components/protocols/bprotocol/CardBprotocolBamm.vue new file mode 100644 index 0000000..5217950 --- /dev/null +++ b/components/protocols/bprotocol/CardBprotocolBamm.vue @@ -0,0 +1,139 @@ + + + diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue b/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue new file mode 100644 index 0000000..44616a6 --- /dev/null +++ b/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue @@ -0,0 +1,216 @@ + + + diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue new file mode 100644 index 0000000..6044925 --- /dev/null +++ b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue @@ -0,0 +1,219 @@ + + + + diff --git a/components/sidebar/context/liquity/SidebarLiquityPoolWithdraw.vue b/components/sidebar/context/liquity/SidebarLiquityPoolWithdraw.vue index 1acf20c..b17c947 100644 --- a/components/sidebar/context/liquity/SidebarLiquityPoolWithdraw.vue +++ b/components/sidebar/context/liquity/SidebarLiquityPoolWithdraw.vue @@ -26,7 +26,7 @@

- Amount to supply + Amount to withdraw

{ + showConfirmedTransaction(receipt.transactionHash); + + await fetchBalances(true); + await fetchUserData(); + } + }); + + showPendingTransaction(tx); + } catch (error) { + console.log(error); + showWarning(error.message); + } + + pendingLqtyClaim.value = false; + } + + + return { + claimLqty, + pendingLqtyClaim, + }; +} diff --git a/composables/protocols/useBprotocolPositions.ts b/composables/protocols/useBprotocolPositions.ts new file mode 100644 index 0000000..15464ad --- /dev/null +++ b/composables/protocols/useBprotocolPositions.ts @@ -0,0 +1,155 @@ +import { computed, Ref, ref, watch } from "@nuxtjs/composition-api"; +import { useBalances } from "../useBalances"; +import { useBigNumber } from "../useBigNumber"; +import { useToken } from "../useToken"; +import { useWeb3 } from "@instadapp/vue-web3"; +import { AbiItem } from "web3-utils"; +import BigNumber from "bignumber.js"; +BigNumber.config({ POW_PRECISION: 200 }); +import abis from "~/constant/abis"; +import addresses from "~/constant/addresses"; +import { useDSA } from "../useDSA"; +import useEventBus from "../useEventBus"; + +export const userData = ref({ + bammTotalSupply: "0", + bammUserBalance: "0", + ethTotal: "0", + ethUserBalance: "0", + lusdPrice: "0", + lusdTotal: "0", + lusdUserBalance: "0", + unclaimedLqty: "0" +}); + +const fromWei = (n) => new BigNumber(n).dividedBy(1e18).toString(); +const toWei = (n) => new BigNumber(n).multipliedBy(1e18).toString(); + +export function useBprotocolPosition (){ + const { activeAccount } = useDSA(); + const { library } = useWeb3(); + const { onEvent } = useEventBus() + const { getTokenByKey } = useToken(); + + const bammToken = computed(() => getTokenByKey('lusd')) + const ethPrice = computed(() => fromWei(userData.value.lusdPrice)) // wrong mapping + const bammTotalSupply = computed(() => fromWei(userData.value.bammTotalSupply)); + const bammUserBalance = computed(() => fromWei(userData.value.bammUserBalance)); + const ethTotal = computed(() => fromWei(userData.value.ethTotal)); + const ethUserBalance = computed(() => fromWei(userData.value.ethUserBalance)); + const lusdTotal = computed(() => fromWei(userData.value.lusdTotal)); + const lusdUserBalance = computed(() => fromWei(userData.value.lusdUserBalance)); + const unclaimedLqty = computed(() => fromWei(userData.value.unclaimedLqty)); + const userBammInUsd = computed(() => { + if(userData.value.bammTotalSupply === "0"){ + return "0" + } + const userEthInUsd = new BigNumber(userData.value.ethUserBalance).multipliedBy(ethPrice.value) + return fromWei(userEthInUsd.plus(userData.value.lusdUserBalance)) + }); + const totalBammSupplyInUsd = computed(() => { + if(userData.value.bammTotalSupply === "0"){ + return "0" + } + const userEthInUsd = new BigNumber(userData.value.ethTotal).multipliedBy(ethPrice.value) + return fromWei(userEthInUsd.plus(userData.value.lusdTotal)) + }); + const userBammInLusd = computed(() => { + if(userData.value.bammTotalSupply === "0"){ + return "0" + } + return fromWei((new BigNumber(userData.value.bammUserBalance).dividedBy(userData.value.bammTotalSupply)).multipliedBy(userData.value.lusdTotal)) + }); + + function lusdWithdrawAmountToBamm (lusd) { + const bammWithdrawRatio = new BigNumber(lusd).dividedBy(userBammInUsd.value) + const res = bammWithdrawRatio.multipliedBy(bammUserBalance.value).toString() + return res + } + + function absolutlWithdrawAmountInEth (lusd) { + const bammWithdrawRatio = new BigNumber(lusd).dividedBy(userBammInUsd.value) + const res = bammWithdrawRatio.multipliedBy(ethUserBalance.value).toString() + return res + } + + function absolutlWithdrawAmountInLusd (lusd) { + const bammWithdrawRatio = new BigNumber(lusd).dividedBy(userBammInUsd.value) + const res = bammWithdrawRatio.multipliedBy(lusdUserBalance.value).toString() + return res + } + + async function fetchUserData (){ + if (!library.value || !activeAccount.value) { + return + } + const struct = await getUserInfo(activeAccount.value.address, library.value) + const data = {} + Object.keys(struct).filter(k=> isNaN(Number(k))).forEach(k=> { + data[k] = struct[k] + }) + userData.value = data + } + + onEvent("protocol::bprotocol::refresh", fetchUserData); + + watch( + library, + async val => { + if (val) { + fetchUserData(); + } + }, + { immediate: true } + ); + + watch( + activeAccount, + async val => { + if (val) { + fetchUserData(); + } + }, + { immediate: true } + ); + + return { + bammTotalSupply, + bammUserBalance, + ethTotal, + ethUserBalance, + ethPrice, + lusdTotal, + lusdUserBalance, + unclaimedLqty, + fetchUserData, + userBammInLusd, + lusdWithdrawAmountToBamm, + bammToken, + absolutlWithdrawAmountInEth, + absolutlWithdrawAmountInLusd, + userBammInUsd, + totalBammSupplyInUsd + } +} + +async function getUserInfo (user, web3){ + try { + const resolveABI = abis.resolver.bprotocol; + const resolveAddr = addresses.mainnet.resolver.bprotocol; + const bammAddr = addresses.mainnet.bprotocolBamm; + const bprotocolInstance = new web3.eth.Contract( + resolveABI as AbiItem[], + resolveAddr + ); + const userInfo = await bprotocolInstance.methods.getUserInfo(user, bammAddr, '0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D').call() + debugger + return userInfo + + }catch (e) { + console.error(e); + return {}; + } + + +} \ No newline at end of file diff --git a/composables/useSidebar.ts b/composables/useSidebar.ts index eeb2231..dc2d58f 100644 --- a/composables/useSidebar.ts +++ b/composables/useSidebar.ts @@ -37,6 +37,9 @@ import SidebarLiquityTrovePayback from '~/components/sidebar/context/liquity/Sid import SidebarLiquityPoolSupply from '~/components/sidebar/context/liquity/SidebarLiquityPoolSupply.vue' import SidebarLiquityPoolWithdraw from '~/components/sidebar/context/liquity/SidebarLiquityPoolWithdraw.vue' +import SidebarBprotocolDeposit from '~/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue' +import SidebarBprotocolWithdraw from '~/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue' + import SidebarReflexerCollateral from '~/components/sidebar/context/reflexer/SidebarReflexerCollateral.vue' import SidebarReflexerSupply from '~/components/sidebar/context/reflexer/SidebarReflexerSupply.vue' import SidebarReflexerWithdraw from '~/components/sidebar/context/reflexer/SidebarReflexerWithdraw.vue' @@ -80,6 +83,9 @@ const sidebars = { '/mainnet/liquity#pool-supply': { component: SidebarLiquityPoolSupply }, '/mainnet/liquity#pool-withdraw': { component: SidebarLiquityPoolWithdraw }, + "/mainnet/bprotocol#deposit": { component: SidebarBprotocolDeposit }, + "/mainnet/bprotocol#withdraw": { component: SidebarBprotocolWithdraw }, + "/mainnet/reflexer": { component: null }, '/mainnet/reflexer#collateral': { component: SidebarReflexerCollateral }, "/mainnet/reflexer#supply": { component: SidebarReflexerSupply }, diff --git a/constant/abi/read/bprotocol.json b/constant/abi/read/bprotocol.json new file mode 100644 index 0000000..dd47ee1 --- /dev/null +++ b/constant/abi/read/bprotocol.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"add","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"contract BAMM","name":"bamm","type":"address"},{"internalType":"contract ERC20","name":"token","type":"address"}],"name":"getUnclaimedLqty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"contract BAMM","name":"bamm","type":"address"},{"internalType":"contract ERC20","name":"lqty","type":"address"}],"name":"getUserInfo","outputs":[{"components":[{"internalType":"uint256","name":"unclaimedLqty","type":"uint256"},{"internalType":"uint256","name":"bammUserBalance","type":"uint256"},{"internalType":"uint256","name":"bammTotalSupply","type":"uint256"},{"internalType":"uint256","name":"lusdUserBalance","type":"uint256"},{"internalType":"uint256","name":"ethUserBalance","type":"uint256"},{"internalType":"uint256","name":"lusdTotal","type":"uint256"},{"internalType":"uint256","name":"ethTotal","type":"uint256"},{"internalType":"uint256","name":"lusdPrice","type":"uint256"}],"internalType":"struct BLens.UserInfo","name":"info","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"mul","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"rdiv","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"rmul","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"rmulup","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"sub","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"wdiv","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"wdivup","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"wmul","outputs":[{"internalType":"uint256","name":"z","type":"uint256"}],"stateMutability":"pure","type":"function"}] \ No newline at end of file diff --git a/constant/abis.ts b/constant/abis.ts index 974c464..29d1364 100644 --- a/constant/abis.ts +++ b/constant/abis.ts @@ -7,7 +7,9 @@ import makerABI from "./abi/read/maker.json"; import makerProxyRegistryABI from "./abi/makerProxyRegistry.json"; import unipoolABI from "./abi/read/unipool.json"; import liquityABI from "./abi/read/liquity.json"; -import reflexerABI from './abi/read/reflexer.json' +import reflexerABI from './abi/read/reflexer.json'; +import bprotocolABI from './abi/read/bprotocol.json'; + const abis = { makerProxyRegistry: makerProxyRegistryABI, resolver: { @@ -19,7 +21,8 @@ const abis = { maker: makerABI, unipool: unipoolABI, liquity: liquityABI, - reflexer: reflexerABI + reflexer: reflexerABI, + bprotocol: bprotocolABI, } }; diff --git a/constant/addresses.ts b/constant/addresses.ts index a1b4ac0..e726b2c 100644 --- a/constant/addresses.ts +++ b/constant/addresses.ts @@ -1,6 +1,7 @@ const addresses = { mainnet: { makerProxyRegistry: "0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4", + bprotocolBamm: "0x0d3AbAA7E088C2c82f54B2f47613DA438ea8C598", resolver: { aave: "0xA6Dc31dC10f8071c02099B05B76Ba15dfcD2B04c", aave_v2: "0xFb3a1D56eD56F046721B9aCa749895100754578b", @@ -10,7 +11,8 @@ const addresses = { maker: "0x84addce4fac0b6ee4b0cd132120d6d4b700e35c0", unipool: "0x22bddA39D14eD0aafeee36B6e784602fdDE64723", liquity: "0xDAf2A39503463B0F41f899EDD82213b3c96b6Cf8", - reflexer: "0x016ca8d0993d1a7073b01802a2e22fd0df7e633a" + reflexer: "0x016ca8d0993d1a7073b01802a2e22fd0df7e633a", + bprotocol: "0x3843019c19259117ed473947007bcafc5c0c7129" } }, diff --git a/pages/index.vue b/pages/index.vue index 62eb823..148c6fa 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -37,6 +37,7 @@ import CompoundIcon from "~/assets/icons/compound.svg?inline"; import MakerIcon from "~/assets/icons/makerdao.svg?inline"; import OneInchIcon from "~/assets/icons/1inch.svg?inline"; import LiquityIcon from "~/assets/icons/liquity.svg?inline"; +import BprotocolIcon from "~/assets/icons/b-protocol.svg?inline"; import ReflexerIcon from "~/assets/icons/reflexer.svg?inline"; const appsPerNetwork = { @@ -76,6 +77,13 @@ const appsPerNetwork = { url: "/mainnet/liquity", description: "Collateralized LUSD Debt" }, + { + id: "bprotocol", + icon: BprotocolIcon, + name: "B.Protocol", + url: "/mainnet/bprotocol", + description: "Stake LUSD" + }, { id: "reflexer", icon: ReflexerIcon, @@ -107,7 +115,6 @@ export default defineComponent({ const { activeNetworkId } = useNetwork(); const apps = computed(() => appsPerNetwork[activeNetworkId.value]); - return { apps }; diff --git a/pages/mainnet/bprotocol.vue b/pages/mainnet/bprotocol.vue new file mode 100644 index 0000000..ccdd400 --- /dev/null +++ b/pages/mainnet/bprotocol.vue @@ -0,0 +1,115 @@ + + + From 1cb57aa70f17aae31e9fe6c5d8d23bb5888c54f6 Mon Sep 17 00:00:00 2001 From: shmuel Date: Sun, 10 Oct 2021 13:49:59 +0300 Subject: [PATCH 2/6] cleanup --- pages/mainnet/bprotocol.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/pages/mainnet/bprotocol.vue b/pages/mainnet/bprotocol.vue index ccdd400..e4695f1 100644 --- a/pages/mainnet/bprotocol.vue +++ b/pages/mainnet/bprotocol.vue @@ -85,7 +85,6 @@ export default defineComponent({ bammUserBalance, ethTotal, ethUserBalance, - lusdPrice, lusdTotal, lusdUserBalance, unclaimedLqty, @@ -100,7 +99,6 @@ export default defineComponent({ bammUserBalance, ethTotal, ethUserBalance, - lusdPrice, lusdTotal, lusdUserBalance, unclaimedLqty, From 8f7bde5c1c60bf72b07729d1149cb200c3637345 Mon Sep 17 00:00:00 2001 From: shmuel Date: Sun, 10 Oct 2021 16:16:50 +0300 Subject: [PATCH 3/6] UI improvmetns --- .../protocols/bprotocol/CardBprotocolBamm.vue | 5 +++-- .../bprotocol/SidebarBprotocolDeposit.vue | 18 +++++++++++++++--- .../bprotocol/SidebarBprotocolWithdraw.vue | 19 +++++++++++++++---- .../protocols/useBprotocolPositions.ts | 14 +++++++++++--- pages/index.vue | 6 +++--- pages/mainnet/bprotocol.vue | 7 +++++-- 6 files changed, 52 insertions(+), 17 deletions(-) diff --git a/components/protocols/bprotocol/CardBprotocolBamm.vue b/components/protocols/bprotocol/CardBprotocolBamm.vue index 5217950..4bfe480 100644 --- a/components/protocols/bprotocol/CardBprotocolBamm.vue +++ b/components/protocols/bprotocol/CardBprotocolBamm.vue @@ -49,7 +49,7 @@
-
+
Supply to Stability Pool
- + @@ -11,6 +11,16 @@ >{{ formatDecimal(changedBammDeposit, 2) }} USD + + + + + +
@@ -43,7 +53,7 @@
- Balance + Stability Pool Balance
@@ -122,6 +132,7 @@ export default defineComponent({ const { valInt } = useToken() const { close } = useSidebar() const { showPendingTransaction, showConfirmedTransaction, showWarning } = useNotification() + const changedBalance = computed(() => max(minus(balance.value, amountParsed.value), '0').toFixed()) const amount = ref('') const amountParsed = computed(() => parseSafeFloat(amount.value)) @@ -209,7 +220,8 @@ export default defineComponent({ toggle, newEthBalance, newLusdBalance, - ethUserBalance + ethUserBalance, + changedBalance } }, }) diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue index 6044925..30a4dfb 100644 --- a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue +++ b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue @@ -3,13 +3,24 @@
- + + + + + + + +
@@ -124,8 +135,6 @@ export default defineComponent({ const { valInt } = useToken() const { close } = useSidebar() const { showPendingTransaction, showConfirmedTransaction, showWarning } = useNotification() - - const amount = ref('') const amountParsed = computed(() => parseSafeFloat(amount.value)) @@ -136,6 +145,7 @@ export default defineComponent({ const changedPoolDeposit = computed(() => max(minus(userBammInUsd.value, amountParsed.value), '0').toFixed()) const ethWithdrawAmount = computed(() => absolutlWithdrawAmountInEth(amountParsed.value)) const lusdWithdrawAmount = computed(() => absolutlWithdrawAmountInLusd(amountParsed.value)) + const changedBalance = computed(() => plus(balance.value, amountParsed.value).toFixed()) const { toggle, isMaxAmount } = useMaxAmountActive(amount, userBammInUsd) @@ -212,7 +222,8 @@ export default defineComponent({ isZero, ethWithdrawAmount, lusdWithdrawAmount, - ethUserBalance + ethUserBalance, + changedBalance } }, }) diff --git a/composables/protocols/useBprotocolPositions.ts b/composables/protocols/useBprotocolPositions.ts index 15464ad..b19965a 100644 --- a/composables/protocols/useBprotocolPositions.ts +++ b/composables/protocols/useBprotocolPositions.ts @@ -60,6 +60,15 @@ export function useBprotocolPosition (){ } return fromWei((new BigNumber(userData.value.bammUserBalance).dividedBy(userData.value.bammTotalSupply)).multipliedBy(userData.value.lusdTotal)) }); + const ethIsGreaterThanOnePerMile = computed(()=> { + if(userBammInUsd.value === "0"){ + return false; + } + const userEthInUsd = new BigNumber(ethUserBalance.value).multipliedBy(ethPrice.value) + const ethInSp = userEthInUsd.dividedBy(userBammInUsd.value) + debugger + return ethInSp.isGreaterThan(0.0001) + }) function lusdWithdrawAmountToBamm (lusd) { const bammWithdrawRatio = new BigNumber(lusd).dividedBy(userBammInUsd.value) @@ -129,7 +138,8 @@ export function useBprotocolPosition (){ absolutlWithdrawAmountInEth, absolutlWithdrawAmountInLusd, userBammInUsd, - totalBammSupplyInUsd + totalBammSupplyInUsd, + ethIsGreaterThanOnePerMile } } @@ -150,6 +160,4 @@ async function getUserInfo (user, web3){ console.error(e); return {}; } - - } \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index 7791d9e..ce0f3e7 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -21,8 +21,8 @@

{{ app.name }}

-

- {{ app.description }} +

@@ -83,7 +83,7 @@ const appsPerNetwork = { icon: BprotocolIcon, name: "B.Protocol", url: "/mainnet/bprotocol", - description: "Stake LUSD" + description: "Automated Rebalancing
for Liquity Stability Pool" }, { id: "reflexer", diff --git a/pages/mainnet/bprotocol.vue b/pages/mainnet/bprotocol.vue index e4695f1..6de5815 100644 --- a/pages/mainnet/bprotocol.vue +++ b/pages/mainnet/bprotocol.vue @@ -45,6 +45,7 @@ price-in-usd="1" :token="bammToken" :lusdUserBalance="lusdUserBalance" + :ethIsGreaterThanOnePerMile="ethIsGreaterThanOnePerMile" />
@@ -91,7 +92,8 @@ export default defineComponent({ userBammInLusd, bammToken, userBammInUsd, - totalBammSupplyInUsd + totalBammSupplyInUsd, + ethIsGreaterThanOnePerMile } = useBprotocolPosition() return { @@ -106,7 +108,8 @@ export default defineComponent({ userBammInLusd, bammToken, userBammInUsd, - totalBammSupplyInUsd + totalBammSupplyInUsd, + ethIsGreaterThanOnePerMile }; } }); From d79eadf02fc35934c4b0cb9d9994ac186bc26814 Mon Sep 17 00:00:00 2001 From: shmuel Date: Sun, 10 Oct 2021 16:58:11 +0300 Subject: [PATCH 4/6] refine + remove debugger + add explainer links text and images --- assets/img/icons/bprotocol/earn.svg | 29 ++++++++++ assets/img/icons/bprotocol/stableize.svg | 27 +++++++++ assets/img/icons/bprotocol/use-v2.svg | 17 ++++++ .../bprotocol/SidebarBprotocolWithdraw.vue | 1 - .../protocols/useBprotocolLqtyClaim.ts | 2 +- .../protocols/useBprotocolPositions.ts | 2 - pages/index.vue | 2 +- pages/mainnet/bprotocol.vue | 57 +++++++++++++++++++ 8 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 assets/img/icons/bprotocol/earn.svg create mode 100644 assets/img/icons/bprotocol/stableize.svg create mode 100644 assets/img/icons/bprotocol/use-v2.svg diff --git a/assets/img/icons/bprotocol/earn.svg b/assets/img/icons/bprotocol/earn.svg new file mode 100644 index 0000000..b209419 --- /dev/null +++ b/assets/img/icons/bprotocol/earn.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/img/icons/bprotocol/stableize.svg b/assets/img/icons/bprotocol/stableize.svg new file mode 100644 index 0000000..ade5743 --- /dev/null +++ b/assets/img/icons/bprotocol/stableize.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/img/icons/bprotocol/use-v2.svg b/assets/img/icons/bprotocol/use-v2.svg new file mode 100644 index 0000000..872c357 --- /dev/null +++ b/assets/img/icons/bprotocol/use-v2.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue index 30a4dfb..3b2d085 100644 --- a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue +++ b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue @@ -166,7 +166,6 @@ export default defineComponent({ pending.value = true try { const supplyAmountInWei = valInt(lusdWithdrawAmountToBamm(amountParsed.value), 18) - debugger const getDepositId = 0 const setDepositId = 0 const setEthGainId = 0 diff --git a/composables/protocols/useBprotocolLqtyClaim.ts b/composables/protocols/useBprotocolLqtyClaim.ts index 5552c5c..fe90b97 100644 --- a/composables/protocols/useBprotocolLqtyClaim.ts +++ b/composables/protocols/useBprotocolLqtyClaim.ts @@ -22,7 +22,7 @@ export function useBprotocolLqtyClaim() { const pendingLqtyClaim = ref(false); async function claimLqty() { - debugger + pendingLqtyClaim.value = true; try { diff --git a/composables/protocols/useBprotocolPositions.ts b/composables/protocols/useBprotocolPositions.ts index b19965a..84aab86 100644 --- a/composables/protocols/useBprotocolPositions.ts +++ b/composables/protocols/useBprotocolPositions.ts @@ -66,7 +66,6 @@ export function useBprotocolPosition (){ } const userEthInUsd = new BigNumber(ethUserBalance.value).multipliedBy(ethPrice.value) const ethInSp = userEthInUsd.dividedBy(userBammInUsd.value) - debugger return ethInSp.isGreaterThan(0.0001) }) @@ -153,7 +152,6 @@ async function getUserInfo (user, web3){ resolveAddr ); const userInfo = await bprotocolInstance.methods.getUserInfo(user, bammAddr, '0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D').call() - debugger return userInfo }catch (e) { diff --git a/pages/index.vue b/pages/index.vue index ce0f3e7..8cf3120 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -81,7 +81,7 @@ const appsPerNetwork = { { id: "bprotocol", icon: BprotocolIcon, - name: "B.Protocol", + name: "B.Protocol v2", url: "/mainnet/bprotocol", description: "Automated Rebalancing
for Liquity Stability Pool" }, diff --git a/pages/mainnet/bprotocol.vue b/pages/mainnet/bprotocol.vue index 6de5815..4386941 100644 --- a/pages/mainnet/bprotocol.vue +++ b/pages/mainnet/bprotocol.vue @@ -27,6 +27,57 @@
+
+

Overview

+ +
+
+
+

+ Stabilize + Liquity Protocol +

+

+ Learn More

+
+
+ +
+
+ +
+
+

+ Get Passive + Yield on Your LUSD +

+

+ Learn More

+
+
+ +
+
+ +
+
+

+ Using
+ B.Protocl V2 +

+

+ Learn More

+
+
+ +
+
+ +
+
+
Date: Sun, 10 Oct 2021 17:13:08 +0300 Subject: [PATCH 5/6] TYPO --- components/protocols/bprotocol/CardBprotocolBamm.vue | 4 ++-- composables/protocols/useBprotocolPositions.ts | 4 ++-- pages/mainnet/bprotocol.vue | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/protocols/bprotocol/CardBprotocolBamm.vue b/components/protocols/bprotocol/CardBprotocolBamm.vue index 4bfe480..4600c8a 100644 --- a/components/protocols/bprotocol/CardBprotocolBamm.vue +++ b/components/protocols/bprotocol/CardBprotocolBamm.vue @@ -49,7 +49,7 @@
-
+
{ + const ethIsGreaterThanOnePromille = computed(()=> { if(userBammInUsd.value === "0"){ return false; } @@ -138,7 +138,7 @@ export function useBprotocolPosition (){ absolutlWithdrawAmountInLusd, userBammInUsd, totalBammSupplyInUsd, - ethIsGreaterThanOnePerMile + ethIsGreaterThanOnePromille } } diff --git a/pages/mainnet/bprotocol.vue b/pages/mainnet/bprotocol.vue index 4386941..688f122 100644 --- a/pages/mainnet/bprotocol.vue +++ b/pages/mainnet/bprotocol.vue @@ -64,11 +64,10 @@

- Using
- B.Protocl V2 + Improved Liquidity Mining Program

- Learn More

+ Learn More

@@ -96,7 +95,7 @@ price-in-usd="1" :token="bammToken" :lusdUserBalance="lusdUserBalance" - :ethIsGreaterThanOnePerMile="ethIsGreaterThanOnePerMile" + :ethIsGreaterThanOnePromille="ethIsGreaterThanOnePromille" />
@@ -150,7 +149,7 @@ export default defineComponent({ bammToken, userBammInUsd, totalBammSupplyInUsd, - ethIsGreaterThanOnePerMile + ethIsGreaterThanOnePromille } = useBprotocolPosition() return { @@ -166,7 +165,7 @@ export default defineComponent({ bammToken, userBammInUsd, totalBammSupplyInUsd, - ethIsGreaterThanOnePerMile + ethIsGreaterThanOnePromille }; } }); From 2251f7e6697363f0b47f128feb07423ffcf8e0d3 Mon Sep 17 00:00:00 2001 From: shmuel Date: Sun, 10 Oct 2021 18:41:32 +0300 Subject: [PATCH 6/6] fix --- .../sidebar/context/bprotocol/SidebarBprotocolDeposit.vue | 7 ++++--- .../sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue | 7 ++++--- composables/protocols/useBprotocolPositions.ts | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue b/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue index 6a9d570..ec6ffc4 100644 --- a/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue +++ b/components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue @@ -46,7 +46,7 @@ -
+
@@ -122,7 +122,7 @@ import { useBprotocolPosition } from '~/composables/protocols/useBprotocolPositi export default defineComponent({ components: { ButtonCTA, InputNumeric }, setup() { - const { fetchUserData, userBammInUsd, ethUserBalance, lusdUserBalance, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth } = useBprotocolPosition() + const { fetchUserData, userBammInUsd, ethUserBalance, lusdUserBalance, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth, ethIsGreaterThanOnePromille } = useBprotocolPosition() const { account } = useWeb3() const { dsa } = useDSA() const { formatDecimal } = useFormatting() @@ -221,7 +221,8 @@ export default defineComponent({ newEthBalance, newLusdBalance, ethUserBalance, - changedBalance + changedBalance, + ethIsGreaterThanOnePromille } }, }) diff --git a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue index 3b2d085..c6799a8 100644 --- a/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue +++ b/components/sidebar/context/bprotocol/SidebarBprotocolWithdraw.vue @@ -48,7 +48,7 @@ -
+
@@ -125,7 +125,7 @@ import { useBprotocolPosition } from '~/composables/protocols/useBprotocolPositi export default defineComponent({ components: { ButtonCTA, InputNumeric }, setup() { - const { userBammInUsd, fetchUserData, userBamm, lusdWithdrawAmountToBamm, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth, ethUserBalance } = useBprotocolPosition() + const { userBammInUsd, fetchUserData, userBamm, lusdWithdrawAmountToBamm, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth, ethUserBalance, ethIsGreaterThanOnePromille } = useBprotocolPosition() const { account } = useWeb3() const { dsa } = useDSA() const { formatUsd, formatUsdMax, formatDecimal } = useFormatting() @@ -222,7 +222,8 @@ export default defineComponent({ ethWithdrawAmount, lusdWithdrawAmount, ethUserBalance, - changedBalance + changedBalance, + ethIsGreaterThanOnePromille } }, }) diff --git a/composables/protocols/useBprotocolPositions.ts b/composables/protocols/useBprotocolPositions.ts index e00e749..c4b2673 100644 --- a/composables/protocols/useBprotocolPositions.ts +++ b/composables/protocols/useBprotocolPositions.ts @@ -66,7 +66,7 @@ export function useBprotocolPosition (){ } const userEthInUsd = new BigNumber(ethUserBalance.value).multipliedBy(ethPrice.value) const ethInSp = userEthInUsd.dividedBy(userBammInUsd.value) - return ethInSp.isGreaterThan(0.0001) + return ethInSp.isGreaterThan(0.001) }) function lusdWithdrawAmountToBamm (lusd) {