mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
Merge pull request #26 from backstop-protocol/master
B.Protocol - liquity's connector
This commit is contained in:
commit
9f9039c273
24
assets/icons/b-protocol.svg
Normal file
24
assets/icons/b-protocol.svg
Normal file
|
@ -0,0 +1,24 @@
|
|||
<svg viewBox="0 0 56 45" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<polygon id="path-1" points="0.37603442 0.491832026 21.8015076 0.491832026 21.8015076 18.9725662 0.37603442 18.9725662"></polygon>
|
||||
<polygon id="path-3" points="0.138736807 0.266976014 24.7335133 0.266976014 24.7335133 27.8069775 0.138736807 27.8069775"></polygon>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="BProtocol-|-Desktop-HP-Final" transform="translate(-88.000000, -3794.000000)">
|
||||
<g id="Group-11" transform="translate(88.000000, 3794.000000)">
|
||||
<path d="M22.9420524,19.9199747 L14.743556,11.7214782 L1.04094726,25.4227909 C-0.346420818,26.811455 -0.346420818,29.0626071 1.04094726,30.4512712 L9.24009169,38.6497676 L22.9420524,24.9484549 C24.3307165,23.5597908 24.3307165,21.3086387 22.9420524,19.9199747" id="Fill-1" fill="white">
|
||||
</path><g id="Group-5" transform="translate(16.200001, 0.156298)">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<g id="Clip-4">
|
||||
</g>
|
||||
<path d="M13.6030111,17.9310682 L21.8015076,9.73257172 L13.6030111,1.53277928 C12.214347,0.144763208 9.96384293,0.144763208 8.57517885,1.53277928 L0.37603442,9.73257172 L8.57517885,17.9310682 C9.96384293,19.3197322 12.214347,19.3197322 13.6030111,17.9310682" id="Fill-3" fill="white" mask="url(#mask-2)">
|
||||
</path>
|
||||
</g>
|
||||
<path d="M24.7753093,26.7809342 L16.5761649,34.9794307 L24.7753093,43.1792231 C26.1639734,44.5672392 28.4144775,44.5672392 29.8031416,43.1792231 L38.001638,34.9794307 L29.8031416,26.7809342 C28.4144775,25.3922701 26.1639734,25.3922701 24.7753093,26.7809342" id="Fill-6" fill="white">
|
||||
</path>
|
||||
<g id="Group-10" transform="translate(30.456002, 5.340298)">
|
||||
<mask id="mask-4" fill="white"><use xlink:href="#path-3"></use></mask>
|
||||
<g id="Clip-9"></g><path d="M23.6925661,8.46547245 L15.4940696,0.266976014 L1.17974886,14.5800008 C-0.208267211,15.9680168 -0.208267211,18.219817 1.17974886,19.607833 L9.3788933,27.8069775 L23.6925661,13.4933047 C25.0812301,12.1052886 25.0812301,9.85413652 23.6925661,8.46547245" id="Fill-8" fill="white" mask="url(#mask-4)"></path></g></g></g></g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
29
assets/img/icons/bprotocol/earn.svg
Normal file
29
assets/img/icons/bprotocol/earn.svg
Normal file
|
@ -0,0 +1,29 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="66" height="78" viewBox="0 0 66 78">
|
||||
<defs>
|
||||
<path id="fmbzkjj25a" d="M0.351 0.099L24.698 0.099 24.698 49.005 0.351 49.005z"/>
|
||||
<path id="61evv3voxc" d="M0 0.098L24.347 0.098 24.347 49.005 0 49.005z"/>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#e4e9f8" d="M12.312 20.7H65.7v44.388c0 6.8-5.512 12.312-12.312 12.312H0V33.012C0 26.212 5.512 20.7 12.312 20.7z" transform="translate(-864.000000, -644.000000) translate(864.000000, 644.000000) translate(32.850000, 49.050000) scale(-1, 1) translate(-32.850000, -49.050000)"/>
|
||||
<g>
|
||||
<path fill="#000" d="M26.943 26.95c-.058.857-.427 1.675-1.098 2.412-.58.64-1.432 1.052-2.538 1.226v.538c0 .367-.148.68-.419.877-.221.164-.465.248-.718.248-.264 0-.516-.092-.728-.266-.17-.143-.37-.404-.37-.859v-.505c-1.148-.118-2.159-.447-3.011-.984-1.057-.676-1.71-1.657-1.944-2.923-.099-.385.063-.663.17-.79.107-.13.385-.346.807-.31.54.014.948.356 1.01.87.137.555.486 1.068 1.054 1.497.458.346 1.1.571 1.914.672l-.003-4.84c-1.125-.132-2.151-.542-2.936-1.197-.864-.752-1.366-1.729-1.502-2.91-.06-.651.029-1.278.26-1.876.242-.592.587-1.1 1.031-1.52.433-.42.977-.756 1.66-1.016.474-.176.964-.294 1.487-.357v-.577c0-.415.184-.677.337-.823.481-.415 1.051-.393 1.499-.04.274.24.402.53.402.863v.697c.907.2 1.672.609 2.283 1.218.768.755 1.173 1.77 1.205 3.017-.124.679-.473 1.029-.948 1.085-.487.05-.978-.209-1.057-.893-.025-.288-.085-.573-.178-.866-.092-.269-.228-.516-.402-.722-.204-.248-.444-.464-.718-.65-.06-.04-.12-.077-.185-.11v5.01c.68.164 1.233.385 1.68.673.537.336.974.746 1.289 1.213.31.486.505.984.592 1.496.094.498.12.966.075 1.421M21.528 8.483S12.3 17.256 12.3 24.93c0 5.096 4.131 9.226 9.227 9.226 5.095 0 9.226-4.13 9.226-9.226 0-7.585-9.226-16.447-9.226-16.447" transform="translate(-864.000000, -644.000000) translate(864.000000, 644.000000) translate(6.300000, 0.000000)"/>
|
||||
<path fill="#000" d="M18.714 19.583c.022.233.075.47.161.723.077.2.215.4.4.574.223.22.525.423.934.632.227.114.516.21.86.288v-4.889c-.708.123-1.26.39-1.654.8-.509.536-.738 1.15-.701 1.872M23.307 24.205v4.4c.23-.051.42-.118.568-.2.37-.199.577-.396.687-.527.135-.176.24-.369.297-.552.091-.277.098-.405.098-.439v-.014c.02-.882-.155-1.545-.52-1.973-.26-.292-.632-.523-1.13-.695M30.814 11.37c2.256 0 4.085-1.833 4.085-4.088C34.899 3.924 30.814 0 30.814 0s-4.088 3.882-4.088 7.282c0 2.255 1.831 4.087 4.088 4.087M40.164 24.625c3.384 0 6.127-2.743 6.127-6.128 0-5.04-6.127-10.925-6.127-10.925s-6.127 5.825-6.127 10.925c0 3.385 2.742 6.128 6.127 6.128" transform="translate(-864.000000, -644.000000) translate(864.000000, 644.000000) translate(6.300000, 0.000000)"/>
|
||||
<g transform="translate(-864.000000, -644.000000) translate(864.000000, 644.000000) translate(6.300000, 0.000000) translate(29.565000, 11.009925)">
|
||||
<mask id="395ck0cvnb" fill="#fff">
|
||||
<use xlink:href="#fmbzkjj25a"/>
|
||||
</mask>
|
||||
<path fill="#000" d="M23.17 27.68c.726-1.46 1.08-16.78 1.528-27.488-.434-.238-1.334.012-1.904.38-.77.497-2.118 1.711-2.505 4.253-.475 3.112-1.667 10.364-2.121 13.114.922.007 1.701.151 2.219.353.582.229 1.01.73 1.148 1.342.137.618-.039 1.26-.47 1.717-.7.748-6.332 7.86-7.828 10.143-.27.415-.108-2.789 6.527-11.362l-.03-.178c-1.03-.409-3.455-.409-5.616.856-3.867 2.262-9.711 7.359-11.914 11.055-1.981 3.325-.076 9.836-.057 9.902.025.084.037.171.037.258l-.005 1.277H.35v5.703H14.49v-5.703h-2.563l-.113-2.905c-.01-.234.073-.46.23-.634 2.487-2.747 10.263-10.667 11.125-12.083" mask="url(#395ck0cvnb)"/>
|
||||
</g>
|
||||
<g transform="translate(-864.000000, -644.000000) translate(864.000000, 644.000000) translate(6.300000, 0.000000) translate(0.000000, 11.009925)">
|
||||
<mask id="hxgkc801dd" fill="#fff">
|
||||
<use xlink:href="#61evv3voxc"/>
|
||||
</mask>
|
||||
<path fill="#000" d="M22.513 42.025c0-.087.012-.174.037-.258.02-.066 1.925-6.577-.057-9.902-2.202-3.696-8.046-8.793-11.913-11.056-2.162-1.264-4.587-1.264-5.617-.855l-.03.178c6.636 8.573 6.797 11.776 6.527 11.362C9.965 29.21 4.334 22.1 3.632 21.351c-.43-.458-.607-1.099-.469-1.717.137-.611.566-1.113 1.148-1.342.517-.202 1.297-.346 2.219-.353-.454-2.75-1.646-10.002-2.12-13.114C4.021 2.283 2.672 1.069 1.903.573 1.334.203.434-.047 0 .193.448 10.9.801 26.22 1.528 27.68c.862 1.416 8.64 9.336 11.125 12.083.157.174.24.4.23.634l-.112 2.905h-2.563v5.703h14.139v-5.703h-1.828l-.006-1.277z" mask="url(#hxgkc801dd)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
27
assets/img/icons/bprotocol/stableize.svg
Normal file
27
assets/img/icons/bprotocol/stableize.svg
Normal file
|
@ -0,0 +1,27 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="66" height="79" viewBox="0 0 66 79">
|
||||
<defs>
|
||||
<path id="mnwhm70zra" d="M0.67 0.189L54.67 0.189 54.67 19.989 0.67 19.989z"/>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#e4e9f8" d="M12.312 21.6H65.7v44.388c0 6.8-5.512 12.312-12.312 12.312H0V33.912C0 27.112 5.512 21.6 12.312 21.6z" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(32.850000, 49.950000) scale(-1, 1) translate(-32.850000, -49.950000)"/>
|
||||
<g>
|
||||
<path fill="#000" d="M44.712 63.612c0 .716-6.963 1.296-15.552 1.296-8.59 0-15.552-.58-15.552-1.296 0-.716 6.963-1.296 15.552-1.296 8.59 0 15.552.58 15.552 1.296" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<path fill="#000" stroke="#000" stroke-width="2.7" d="M27.864 11.75v46.656c0 .716.58 1.296 1.296 1.296V10.454c-.716 0-1.296.58-1.296 1.296M30.456 58.406V11.75c0-.715-.58-1.296-1.296-1.296v49.248c.716 0 1.296-.58 1.296-1.296" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<path fill="#000" stroke="#000" stroke-width="1.8" d="M21.453 58.406c-.645 0-1.244.441-1.347 1.079l-.006.035c-.112.824-.738 1.478-1.57 1.478h-.965c-.645 0-1.244.441-1.347 1.079-.133.811.49 1.513 1.278 1.513H29.16v-5.184h-7.707zM42.102 62.077c-.103-.638-.702-1.079-1.348-1.079h-.963c-.833 0-1.459-.654-1.572-1.478l-.005-.035c-.103-.638-.702-1.079-1.348-1.079H29.16v5.184h11.664c.787 0 1.41-.702 1.278-1.513" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<path fill="#000" d="M18.792 39.614c0 5.01-4.062 9.072-9.072 9.072-5.01 0-9.072-4.061-9.072-9.072h18.144zM57.672 23.09c0 5.01-4.062 9.072-9.072 9.072-5.01 0-9.072-4.061-9.072-9.072h18.144z" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<path fill="#000" d="M18.144 39.938c-.125 0-.244-.073-.297-.195L9.72 20.99 1.593 39.743c-.071.164-.262.24-.426.169-.164-.072-.24-.262-.168-.426l8.424-19.44c.103-.238.491-.238.594 0l8.424 19.44c.071.164-.004.354-.168.426-.042.018-.086.026-.129.026M57.024 23.414c-.125 0-.244-.073-.297-.195L48.6 4.465 40.473 23.22c-.071.164-.26.239-.426.169-.164-.072-.24-.262-.168-.427l8.424-19.44c.102-.237.492-.237.594 0l8.424 19.44c.071.165-.004.355-.168.427-.042.018-.086.026-.129.026" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<path fill="#000" stroke="#000" stroke-width="1.8" d="M10.413 20.706L48.876 5.198c.664-.267.985-1.023.718-1.686L8.726 19.989c.268.664 1.023.985 1.687.717" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
<g transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000) translate(2.124000, 0.000000)">
|
||||
<mask id="0mb4fvludb" fill="#fff">
|
||||
<use xlink:href="#mnwhm70zra"/>
|
||||
</mask>
|
||||
<path fill="#000" stroke="#000" stroke-width="1.8" d="M45.783 2.794L7.32 18.302c-.664.268-.985 1.023-.718 1.687L47.47 3.512c-.268-.664-1.023-.985-1.687-.718" mask="url(#0mb4fvludb)"/>
|
||||
</g>
|
||||
<path fill="#000" d="M29.16 13.532c-1.431 0-2.592-1.16-2.592-2.592 0-1.431 1.16-2.592 2.592-2.592 1.431 0 2.592 1.16 2.592 2.592 0 1.432-1.16 2.592-2.592 2.592z" transform="translate(-361.000000, -643.000000) translate(361.000000, 643.000000) translate(3.600000, 0.000000)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.9 KiB |
17
assets/img/icons/bprotocol/use-v2.svg
Normal file
17
assets/img/icons/bprotocol/use-v2.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="67" height="66" viewBox="0 0 67 66">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#e4e9f8" d="M12.312 9H65.7v44.388c0 6.8-5.512 12.312-12.312 12.312H0V21.312C0 14.512 5.512 9 12.312 9z" transform="translate(-1374.000000, -657.000000) translate(1374.000000, 657.000000) translate(0.800000, 0.000000) translate(32.850000, 37.350000) scale(-1, 1) translate(-32.850000, -37.350000)"/>
|
||||
<g>
|
||||
<path d="M0 43.2L50.4 43.2 50.4 0 0 0z" transform="translate(-1374.000000, -657.000000) translate(1374.000000, 657.000000) translate(0.800000, 0.000000) translate(7.200000, 0.000000)"/>
|
||||
<path fill="#000" d="M3.6 53.2L12.6 53.2 12.6 49.6 3.6 49.6zM37.8 53.2L46.8 53.2 46.8 49.6 37.8 49.6z" transform="translate(-1374.000000, -657.000000) translate(1374.000000, 657.000000) translate(0.800000, 0.000000) translate(7.200000, 0.000000)"/>
|
||||
<path stroke="#000" stroke-width="4" d="M2 2h46.4v43.8H2V2z" transform="translate(-1374.000000, -657.000000) translate(1374.000000, 657.000000) translate(0.800000, 0.000000) translate(7.200000, 0.000000)"/>
|
||||
<path fill="#000" d="M23.4 18.5H27v-3.6h-3.6v3.6zm0 7.2H27v-3.6h-3.6v3.6zm0 7.2H27v-3.6h-3.6v3.6zm-7.2-14.4h3.6v-3.6h-3.6v3.6zm0 7.2h3.6v-3.6h-3.6v3.6zm0 7.2h3.6v-3.6h-3.6v3.6zM9 18.5h3.6v-3.6H9v3.6zm0 7.2h3.6v-3.6H9v3.6zm0 7.2h3.6v-3.6H9v3.6zM36.9 27.5c-1.988 0-3.6-1.612-3.6-3.6s1.612-3.6 3.6-3.6 3.6 1.612 3.6 3.6-1.612 3.6-3.6 3.6m0-9c-2.982 0-5.4 2.418-5.4 5.4s2.418 5.4 5.4 5.4 5.4-2.418 5.4-5.4-2.418-5.4-5.4-5.4" transform="translate(-1374.000000, -657.000000) translate(1374.000000, 657.000000) translate(0.800000, 0.000000) translate(7.200000, 0.000000)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
140
components/protocols/bprotocol/CardBprotocolBamm.vue
Normal file
140
components/protocols/bprotocol/CardBprotocolBamm.vue
Normal file
|
@ -0,0 +1,140 @@
|
|||
<template>
|
||||
<div
|
||||
class="flex-shrink-0 bg-white rounded-lg relative flex flex-col flex-1 px-4 pt-4 pb-6 dark:bg-dark-500"
|
||||
style="box-shadow: -1px -3px 10px rgba(12, 25, 91, 0.03), 2px 4px 12px rgba(12, 25, 91, 0.05)"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconCurrency :currency="token.key" class="w-12 h-12" no-height />
|
||||
<div class="flex flex-col flex-grow mx-4">
|
||||
<div class="mb-1 font-medium leading-none whitespace-no-wrap text-19">
|
||||
{{ formatUsd(amountUsd, 2) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="self-start">
|
||||
<Badge :color="supplyNotZero ? 'green' : 'grey'" class="w-20">{{
|
||||
badge
|
||||
}}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<div class="flex items-center w-full px-4 mb-2">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div
|
||||
class="flex items-center font-medium leading-none whitespace-no-wrap text-14"
|
||||
>
|
||||
<span>Rewards</span>
|
||||
</div>
|
||||
<div class="flex items-center font-medium leading-none text-14">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="lqty" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(stabilityLqtyGain) }}</div>
|
||||
<div>LQTY</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex w-full px-4 mt-4">
|
||||
<ButtonOutlined
|
||||
class="flex-1"
|
||||
:loading="pendingLqtyClaim"
|
||||
:disabled="false"
|
||||
@click="claimLqty"
|
||||
>Claim LQTY
|
||||
</ButtonOutlined>
|
||||
</div>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<div v-if="ethIsGreaterThanOnePromille" class="flex items-center w-full px-4 mb-2">
|
||||
<div class="flex items-start justify-between w-full">
|
||||
<div
|
||||
class="flex font-medium leading-none whitespace-no-wrap text-14"
|
||||
>
|
||||
<span>Your Deposit</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center font-medium leading-none text-14 ">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="lusd" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(lusdUserBalance) }}</div>
|
||||
<div>LUSD</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center font-medium leading-none text-14 mt-2">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="eth" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(ethUserBalance) }}</div>
|
||||
<div>ETH</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-around px-4 mt-6">
|
||||
<button
|
||||
class="mr-4 h-10 w-full bg-primary-blue-dark shadow text-white rounded-[4px] hover:bg-primary-blue-hover"
|
||||
@click="$router.push({ hash: 'deposit'})"
|
||||
>
|
||||
Supply
|
||||
</button>
|
||||
<button
|
||||
class="h-10 w-full text-primary-blue-dark shadow border border-primary-blue-dark hover:border-primary-blue-hover rounded-[4px] hover:text-primary-blue-hover"
|
||||
:disabled="!supplyNotZero"
|
||||
@click="$router.push({ hash: 'withdraw'})"
|
||||
>
|
||||
Withdraw
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
|
||||
import { useFormatting } from '@/composables/useFormatting'
|
||||
import { useBprotocolLqtyClaim } from '@/composables/protocols/useBprotocolLqtyClaim'
|
||||
import { useBigNumber } from '~/composables/useBigNumber'
|
||||
import ButtonOutlined from '~/components/common/input/ButtonOutlined.vue'
|
||||
|
||||
export default defineComponent({
|
||||
components: { ButtonOutlined },
|
||||
props: {
|
||||
amount: { type: String, default: '0' },
|
||||
amountUsd: { type: String, default: '0' },
|
||||
token: { type: Object, default: () => { } },
|
||||
priceInUsd: { type: String, default: '0' },
|
||||
ethUserBalance: { type: String, default: '0' },
|
||||
stabilityLqtyGain: { type: String, default: '0' },
|
||||
lusdUserBalance: { type: String, default: '0' },
|
||||
ethIsGreaterThanOnePromille: { type: Boolean, default: false }
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const { app } = useContext()
|
||||
const { formatUsd, formatDecimal } = useFormatting()
|
||||
const { isZero } = useBigNumber()
|
||||
|
||||
const { claimLqty, pendingLqtyClaim } = useBprotocolLqtyClaim()
|
||||
|
||||
const claimLqtyDisabled = computed(() => isZero(props.amount) || pendingLqtyClaim.value)
|
||||
|
||||
const supplyNotZero = computed(() => !isZero(props.amount))
|
||||
|
||||
const badge = computed(() => (supplyNotZero.value ? 'Supplied' : 'No position'))
|
||||
|
||||
return {
|
||||
formatUsd,
|
||||
formatDecimal,
|
||||
badge,
|
||||
supplyNotZero,
|
||||
pendingLqtyClaim,
|
||||
claimLqty: () => claimLqtyDisabled.value ? null : claimLqty()
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
229
components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue
Normal file
229
components/sidebar/context/bprotocol/SidebarBprotocolDeposit.vue
Normal file
|
@ -0,0 +1,229 @@
|
|||
<template>
|
||||
<SidebarContextRootContainer class="bg-[#C5CCE1] bg-opacity-[0.15]">
|
||||
<template #title>Supply to Stability Pool</template>
|
||||
|
||||
<div class="flex justify-around items-center w-full">
|
||||
<SidebarSectionValueWithIcon class="" label="Stability Pool Balance" center>
|
||||
<template #icon
|
||||
><IconCurrency :currency="poolToken.key" class="w-16 h-16" noHeight
|
||||
/></template>
|
||||
<template #value
|
||||
>{{ formatDecimal(changedBammDeposit, 2) }} USD</template
|
||||
>
|
||||
</SidebarSectionValueWithIcon>
|
||||
|
||||
<SidebarSectionValueWithIcon class="" label="Wallet Balance" center>
|
||||
<template #icon
|
||||
><IconCurrency :currency="poolToken.key" class="w-16 h-16" noHeight
|
||||
/></template>
|
||||
|
||||
<template #value
|
||||
>{{ formatDecimal(changedBalance) }} {{ poolToken.symbol }}</template
|
||||
>
|
||||
</SidebarSectionValueWithIcon>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 p-8">
|
||||
<h3 class="text-primary-gray text-xs font-semibold mb-2.5">
|
||||
Amount to supply
|
||||
</h3>
|
||||
|
||||
<input-numeric
|
||||
v-model="amount"
|
||||
placeholder="Amount to supply"
|
||||
: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>
|
||||
|
||||
<div v-if="ethIsGreaterThanOnePromille">
|
||||
|
||||
<div class="flex items-center w-full px-4 mb-2 mt-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div
|
||||
class="flex items-center font-medium leading-none whitespace-no-wrap text-14"
|
||||
>
|
||||
<span>Stability Pool Balance</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center w-full px-4 mb-2 mt-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="flex items-center font-medium leading-none text-14">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="lusd" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(newLusdBalance) }}</div>
|
||||
<div>LUSD</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center w-full px-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="flex items-center font-medium leading-none text-14">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="eth" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(newEthBalance) }}</div>
|
||||
<div>ETH</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-shrink-0 mt-10">
|
||||
<ButtonCTA
|
||||
class="w-full"
|
||||
:disabled="!isValid || pending"
|
||||
:loading="pending"
|
||||
@click="cast"
|
||||
>
|
||||
Supply
|
||||
</ButtonCTA>
|
||||
</div>
|
||||
|
||||
<ValidationErrors :error-messages="errorMessages" class="mt-6" />
|
||||
</div>
|
||||
</SidebarContextRootContainer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, defineComponent } from '@nuxtjs/composition-api'
|
||||
import { useFormatting } from '~/composables/useFormatting'
|
||||
import { useMaxAmountActive } from '~/composables/useMaxAmountActive'
|
||||
import { useValidators } from '~/composables/useValidators'
|
||||
import { useValidation } from '~/composables/useValidation'
|
||||
import { useParsing } from '~/composables/useParsing'
|
||||
import { useBigNumber } from '~/composables/useBigNumber'
|
||||
import { useLiquityPosition } from '~/composables/protocols/useLiquityPosition'
|
||||
import { useBalances } from '~/composables/useBalances'
|
||||
import { useWeb3 } from '@instadapp/vue-web3'
|
||||
import { useNotification } from '~/composables/useNotification'
|
||||
import ButtonCTA from '~/components/common/input/ButtonCTA.vue'
|
||||
import InputNumeric from '~/components/common/input/InputNumeric.vue'
|
||||
import { useToken } from '~/composables/useToken'
|
||||
import { useDSA } from '~/composables/useDSA'
|
||||
import { useSidebar } from '~/composables/useSidebar'
|
||||
import { useBprotocolPosition } from '~/composables/protocols/useBprotocolPositions'
|
||||
|
||||
export default defineComponent({
|
||||
components: { ButtonCTA, InputNumeric },
|
||||
setup() {
|
||||
const { fetchUserData, userBammInUsd, ethUserBalance, lusdUserBalance, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth, ethIsGreaterThanOnePromille } = useBprotocolPosition()
|
||||
const { account } = useWeb3()
|
||||
const { dsa } = useDSA()
|
||||
const { formatDecimal } = useFormatting()
|
||||
const { parseSafeFloat } = useParsing()
|
||||
const { plus, isZero, max, minus } = useBigNumber()
|
||||
const { getBalanceByKey, fetchBalances } = useBalances()
|
||||
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))
|
||||
|
||||
const { poolToken, stabilityAmount, fetchPosition } = useLiquityPosition()
|
||||
const balance = computed(() => getBalanceByKey(poolToken.value.key))
|
||||
|
||||
const newEthBalance = computed(() => plus(absolutlWithdrawAmountInEth(amountParsed.value), ethUserBalance.value))
|
||||
const newLusdBalance = computed(() => plus(absolutlWithdrawAmountInLusd(amountParsed.value), lusdUserBalance.value))
|
||||
|
||||
const changedBammDeposit = computed(() => plus(userBammInUsd.value, amountParsed.value).toFixed())
|
||||
|
||||
const { toggle, isMaxAmount } = useMaxAmountActive(amount, balance)
|
||||
|
||||
const { validateAmount, validateIsLoggedIn } = useValidators()
|
||||
const errors = computed(() => {
|
||||
const hasAmountValue = !isZero(amount.value)
|
||||
|
||||
return {
|
||||
amount: { message: validateAmount(amountParsed.value, balance.value), show: hasAmountValue },
|
||||
auth: { message: validateIsLoggedIn(!!account.value), show: true },
|
||||
}
|
||||
})
|
||||
const { errorMessages, isValid } = useValidation(errors)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
async function cast() {
|
||||
pending.value = true
|
||||
try {
|
||||
|
||||
const supplyAmountInWei = valInt(amountParsed.value, poolToken.value.decimals)
|
||||
const getDepositId = 0
|
||||
const setDepositId = 0
|
||||
const setEthGainId = 0
|
||||
const setLqtyGainId = 0
|
||||
|
||||
const frontendTag = '0x0000000000000000000000000000000000000000'
|
||||
|
||||
const spells = dsa.value.Spell()
|
||||
|
||||
spells.add({
|
||||
connector: 'B-LIQUITY-A',
|
||||
method: 'deposit',
|
||||
args: [supplyAmountInWei, 0, getDepositId, setDepositId],
|
||||
})
|
||||
|
||||
|
||||
const txHash = await dsa.value.cast({
|
||||
spells,
|
||||
from: account.value,
|
||||
onReceipt: async receipt => {
|
||||
showConfirmedTransaction(receipt.transactionHash);
|
||||
|
||||
await fetchBalances(true);
|
||||
await fetchUserData();
|
||||
}
|
||||
})
|
||||
|
||||
showPendingTransaction(txHash)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
showWarning(error.message)
|
||||
}
|
||||
|
||||
pending.value = false
|
||||
|
||||
close()
|
||||
}
|
||||
|
||||
return {
|
||||
symbol: computed(() => poolToken.value.symbol),
|
||||
balance,
|
||||
amount,
|
||||
changedBammDeposit,
|
||||
poolToken,
|
||||
amountParsed,
|
||||
formatDecimal,
|
||||
errors,
|
||||
errorMessages,
|
||||
isMaxAmount,
|
||||
isValid,
|
||||
cast,
|
||||
pending,
|
||||
toggle,
|
||||
newEthBalance,
|
||||
newLusdBalance,
|
||||
ethUserBalance,
|
||||
changedBalance,
|
||||
ethIsGreaterThanOnePromille
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,230 @@
|
|||
<template>
|
||||
<SidebarContextRootContainer class="bg-[#C5CCE1] bg-opacity-[0.15]">
|
||||
<template #title>Withdraw from Stability Pool</template>
|
||||
|
||||
<div class="flex justify-around items-center w-full">
|
||||
<SidebarSectionValueWithIcon class="" label="Stability Pool Balance" center>
|
||||
<template #icon
|
||||
><IconCurrency :currency="poolToken.key" class="w-16 h-16" noHeight
|
||||
/></template>
|
||||
<template #value
|
||||
>{{ formatDecimal(changedPoolDeposit, 2) }} USD</template
|
||||
>
|
||||
|
||||
</SidebarSectionValueWithIcon>
|
||||
|
||||
<SidebarSectionValueWithIcon class="" label="Wallet Balance" center>
|
||||
<template #icon
|
||||
><IconCurrency :currency="poolToken.key" class="w-16 h-16" noHeight
|
||||
/></template>
|
||||
|
||||
<template #value
|
||||
>{{ formatDecimal(changedBalance) }} {{ poolToken.symbol }}</template
|
||||
>
|
||||
</SidebarSectionValueWithIcon>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 p-8">
|
||||
<h3 class="text-primary-gray text-xs font-semibold mb-2.5">
|
||||
Amount to withdraw
|
||||
</h3>
|
||||
|
||||
<input-numeric
|
||||
v-model="amount"
|
||||
placeholder="Amount to withdraw"
|
||||
: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>
|
||||
|
||||
<div v-if="ethIsGreaterThanOnePromille">
|
||||
|
||||
<div class="flex items-center w-full px-4 mb-2 mt-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div
|
||||
class="flex items-center font-medium leading-none whitespace-no-wrap text-14"
|
||||
>
|
||||
<span>Receive</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center w-full px-4 mb-2 mt-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="flex items-center font-medium leading-none text-14">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="lusd" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(lusdWithdrawAmount) }}</div>
|
||||
<div>LUSD</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center w-full px-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="flex items-center font-medium leading-none text-14">
|
||||
<div class="flex items-center mr-1">
|
||||
<IconCurrency currency="eth" no-height class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="mr-1">{{ formatDecimal(ethWithdrawAmount) }}</div>
|
||||
<div>ETH</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-shrink-0 mt-10">
|
||||
<ButtonCTA
|
||||
class="w-full"
|
||||
:disabled="!isValid || pending"
|
||||
:loading="pending"
|
||||
@click="cast"
|
||||
>
|
||||
Withdraw
|
||||
</ButtonCTA>
|
||||
</div>
|
||||
|
||||
<ValidationErrors :error-messages="errorMessages" class="mt-6" />
|
||||
</div>
|
||||
</SidebarContextRootContainer>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import { computed, ref, defineComponent } from '@nuxtjs/composition-api'
|
||||
import { useFormatting } from '~/composables/useFormatting'
|
||||
import { useMaxAmountActive } from '~/composables/useMaxAmountActive'
|
||||
import { useValidators } from '~/composables/useValidators'
|
||||
import { useValidation } from '~/composables/useValidation'
|
||||
import { useParsing } from '~/composables/useParsing'
|
||||
import { useBigNumber } from '~/composables/useBigNumber'
|
||||
import { useLiquityPosition } from '~/composables/protocols/useLiquityPosition'
|
||||
import { useBalances } from '~/composables/useBalances'
|
||||
import { useWeb3 } from '@instadapp/vue-web3'
|
||||
import { useNotification } from '~/composables/useNotification'
|
||||
import ButtonCTA from '~/components/common/input/ButtonCTA.vue'
|
||||
import InputNumeric from '~/components/common/input/InputNumeric.vue'
|
||||
import { useToken } from '~/composables/useToken'
|
||||
import { useDSA } from '~/composables/useDSA'
|
||||
import { useSidebar } from '~/composables/useSidebar'
|
||||
import { useBprotocolPosition } from '~/composables/protocols/useBprotocolPositions'
|
||||
|
||||
export default defineComponent({
|
||||
components: { ButtonCTA, InputNumeric },
|
||||
setup() {
|
||||
const { userBammInUsd, fetchUserData, userBamm, lusdWithdrawAmountToBamm, absolutlWithdrawAmountInLusd, absolutlWithdrawAmountInEth, ethUserBalance, ethIsGreaterThanOnePromille } = useBprotocolPosition()
|
||||
const { account } = useWeb3()
|
||||
const { dsa } = useDSA()
|
||||
const { formatUsd, formatUsdMax, formatDecimal } = useFormatting()
|
||||
const { parseSafeFloat } = useParsing()
|
||||
const { isZero, minus, max, plus } = useBigNumber()
|
||||
const { getBalanceByKey, fetchBalances } = useBalances()
|
||||
const { valInt } = useToken()
|
||||
const { close } = useSidebar()
|
||||
const { showPendingTransaction, showConfirmedTransaction, showWarning } = useNotification()
|
||||
|
||||
const amount = ref('')
|
||||
const amountParsed = computed(() => parseSafeFloat(amount.value))
|
||||
|
||||
const { poolToken, stabilityAmount, fetchPosition } = useLiquityPosition()
|
||||
const balance = computed(() => getBalanceByKey(poolToken.value.key))
|
||||
|
||||
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)
|
||||
|
||||
const { validateAmount, validateIsLoggedIn } = useValidators()
|
||||
|
||||
const errors = computed(() => {
|
||||
const hasAmountValue = !isZero(amount.value)
|
||||
|
||||
return {
|
||||
amount: { message: validateAmount(amountParsed.value, userBammInUsd.value), show: hasAmountValue },
|
||||
auth: { message: validateIsLoggedIn(!!account.value), show: true },
|
||||
}
|
||||
})
|
||||
const { errorMessages, isValid } = useValidation(errors)
|
||||
|
||||
const pending = ref(false)
|
||||
async function cast() {
|
||||
pending.value = true
|
||||
try {
|
||||
const supplyAmountInWei = valInt(lusdWithdrawAmountToBamm(amountParsed.value), 18)
|
||||
const getDepositId = 0
|
||||
const setDepositId = 0
|
||||
const setEthGainId = 0
|
||||
const setLqtyGainId = 0
|
||||
|
||||
const spells = dsa.value.Spell()
|
||||
spells.add({
|
||||
connector: 'B-LIQUITY-A',
|
||||
method: 'withdraw',
|
||||
args: [supplyAmountInWei, 0, setDepositId, setEthGainId],
|
||||
})
|
||||
|
||||
|
||||
const txHash = await dsa.value.cast({
|
||||
spells,
|
||||
from: account.value,
|
||||
onReceipt: async receipt => {
|
||||
showConfirmedTransaction(receipt.transactionHash);
|
||||
|
||||
await fetchBalances(true);
|
||||
await fetchUserData();
|
||||
}
|
||||
})
|
||||
|
||||
showPendingTransaction(txHash)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
showWarning(error.message)
|
||||
}
|
||||
|
||||
pending.value = false
|
||||
|
||||
close()
|
||||
}
|
||||
|
||||
return {
|
||||
symbol: computed(() => poolToken.value.symbol),
|
||||
amount,
|
||||
status,
|
||||
formatUsd,
|
||||
formatUsdMax,
|
||||
formatDecimal,
|
||||
errors,
|
||||
errorMessages,
|
||||
isMaxAmount,
|
||||
isValid,
|
||||
cast,
|
||||
pending,
|
||||
toggle,
|
||||
poolToken,
|
||||
changedPoolDeposit,
|
||||
amountParsed,
|
||||
isZero,
|
||||
ethWithdrawAmount,
|
||||
lusdWithdrawAmount,
|
||||
ethUserBalance,
|
||||
changedBalance,
|
||||
ethIsGreaterThanOnePromille
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<div class="mt-10 p-8">
|
||||
<h3 class="text-primary-gray text-xs font-semibold mb-2.5">
|
||||
Amount to supply
|
||||
Amount to withdraw
|
||||
</h3>
|
||||
|
||||
<input-numeric
|
||||
|
|
62
composables/protocols/useBprotocolLqtyClaim.ts
Normal file
62
composables/protocols/useBprotocolLqtyClaim.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
import { useWeb3 } from "@instadapp/vue-web3";
|
||||
import { ref, computed } from "@nuxtjs/composition-api";
|
||||
import { useBalances } from "../useBalances";
|
||||
import { useDSA } from "../useDSA";
|
||||
import { useNotification } from "../useNotification";
|
||||
import { useBprotocolPosition } from "./useBprotocolPositions";
|
||||
|
||||
export function useBprotocolLqtyClaim() {
|
||||
const { account } = useWeb3();
|
||||
const { dsa } = useDSA();
|
||||
const {
|
||||
fetchUserData
|
||||
} = useBprotocolPosition();
|
||||
|
||||
const {
|
||||
showConfirmedTransaction,
|
||||
showPendingTransaction,
|
||||
showWarning,
|
||||
} = useNotification();
|
||||
const { fetchBalances } = useBalances();
|
||||
|
||||
const pendingLqtyClaim = ref(false);
|
||||
|
||||
async function claimLqty() {
|
||||
|
||||
pendingLqtyClaim.value = true;
|
||||
|
||||
try {
|
||||
|
||||
const spells = dsa.value.Spell();
|
||||
spells.add({
|
||||
connector: 'B-LIQUITY-A',
|
||||
method: 'withdraw',
|
||||
args: [0, 0, 0, 0],
|
||||
})
|
||||
|
||||
const tx = await dsa.value.cast({
|
||||
spells,
|
||||
from: account.value,
|
||||
onReceipt: async receipt => {
|
||||
showConfirmedTransaction(receipt.transactionHash);
|
||||
|
||||
await fetchBalances(true);
|
||||
await fetchUserData();
|
||||
}
|
||||
});
|
||||
|
||||
showPendingTransaction(tx);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
showWarning(error.message);
|
||||
}
|
||||
|
||||
pendingLqtyClaim.value = false;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
claimLqty,
|
||||
pendingLqtyClaim,
|
||||
};
|
||||
}
|
161
composables/protocols/useBprotocolPositions.ts
Normal file
161
composables/protocols/useBprotocolPositions.ts
Normal file
|
@ -0,0 +1,161 @@
|
|||
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<any>({
|
||||
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))
|
||||
});
|
||||
const ethIsGreaterThanOnePromille = computed(()=> {
|
||||
if(userBammInUsd.value === "0"){
|
||||
return false;
|
||||
}
|
||||
const userEthInUsd = new BigNumber(ethUserBalance.value).multipliedBy(ethPrice.value)
|
||||
const ethInSp = userEthInUsd.dividedBy(userBammInUsd.value)
|
||||
return ethInSp.isGreaterThan(0.001)
|
||||
})
|
||||
|
||||
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,
|
||||
ethIsGreaterThanOnePromille
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
return userInfo
|
||||
|
||||
}catch (e) {
|
||||
console.error(e);
|
||||
return {};
|
||||
}
|
||||
}
|
|
@ -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'
|
||||
|
@ -83,6 +86,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 },
|
||||
|
|
1
constant/abi/read/bprotocol.json
Normal file
1
constant/abi/read/bprotocol.json
Normal file
|
@ -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"}]
|
|
@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const addresses = {
|
||||
mainnet: {
|
||||
makerProxyRegistry: "0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4",
|
||||
bprotocolBamm: "0x0d3AbAA7E088C2c82f54B2f47613DA438ea8C598",
|
||||
resolver: {
|
||||
aave: "0xA6Dc31dC10f8071c02099B05B76Ba15dfcD2B04c",
|
||||
aave_v2: "0xFb3a1D56eD56F046721B9aCa749895100754578b",
|
||||
|
@ -11,6 +12,7 @@ const addresses = {
|
|||
unipool: "0x22bddA39D14eD0aafeee36B6e784602fdDE64723",
|
||||
liquity: "0xDAf2A39503463B0F41f899EDD82213b3c96b6Cf8",
|
||||
reflexer: "0x016ca8d0993d1a7073b01802a2e22fd0df7e633a",
|
||||
bprotocol: "0x3843019c19259117ed473947007bcafc5c0c7129",
|
||||
yearnV2: "0x3f6DCA8a0b7d04737BC3B2aEAbeB1C09431581f0"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
</div>
|
||||
|
||||
<h2 class="mt-4 font-semibold text-19">{{ app.name }}</h2>
|
||||
<p class="mt-2 text-14 font-regular text-grey-dark opacity-90">
|
||||
{{ app.description }}
|
||||
<p class="mt-2 text-14 font-regular text-grey-dark opacity-90"
|
||||
v-html="app.description">
|
||||
</p>
|
||||
</nuxt-link>
|
||||
</div>
|
||||
|
@ -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";
|
||||
import YearnIcon from "~/assets/icons/yearn.svg?inline";
|
||||
|
||||
|
@ -77,6 +78,13 @@ const appsPerNetwork = {
|
|||
url: "/mainnet/liquity",
|
||||
description: "Collateralized LUSD Debt"
|
||||
},
|
||||
{
|
||||
id: "bprotocol",
|
||||
icon: BprotocolIcon,
|
||||
name: "B.Protocol v2",
|
||||
url: "/mainnet/bprotocol",
|
||||
description: "Automated Rebalancing <br/>for Liquity Stability Pool"
|
||||
},
|
||||
{
|
||||
id: "reflexer",
|
||||
icon: ReflexerIcon,
|
||||
|
@ -124,7 +132,6 @@ export default defineComponent({
|
|||
const { activeNetworkId } = useNetwork();
|
||||
|
||||
const apps = computed(() => appsPerNetwork[activeNetworkId.value]);
|
||||
|
||||
return {
|
||||
apps
|
||||
};
|
||||
|
|
172
pages/mainnet/bprotocol.vue
Normal file
172
pages/mainnet/bprotocol.vue
Normal file
|
@ -0,0 +1,172 @@
|
|||
<template>
|
||||
<div>
|
||||
<div>
|
||||
<nuxt-link
|
||||
to="/"
|
||||
class="text-[#C0C5D7] text-lg font-semibold flex items-center"
|
||||
>
|
||||
<BackIcon class="w-4 h-4 mr-3" />
|
||||
Apps
|
||||
</nuxt-link>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<div
|
||||
style="background: radial-gradient(42.15% 42.15% at 48.94% 48.94%, #D6DAE0 75.67%, #F0F3F9 100%), #C4C4C4;"
|
||||
class="w-16 h-16 rounded-full flex items-center justify-center border border-[#CCDCF3]"
|
||||
>
|
||||
<div
|
||||
class="w-12 h-12 rounded-full flex items-center justify-center bg-[#1874FF]"
|
||||
>
|
||||
<BprotocolIcon class="w-8 h-8 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="ml-4 text-primary-black text-2xl font-semibold">B.Protocol</h1>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-10">
|
||||
<h2 class="text-primary-gray text-lg font-semibold">Overview</h2>
|
||||
|
||||
<div
|
||||
class="px-1 mt-6 grid w-full grid-cols-1 gap-4 sm:grid-cols-3 xl:gap-[18px]"
|
||||
>
|
||||
<div class="shadow rounded-lg py-8 px-6 flex">
|
||||
<div class="flex-1">
|
||||
<h3 class="text-2xl text-primary-black font-medium">
|
||||
Stabilize
|
||||
Liquity Protocol
|
||||
</h3>
|
||||
<p class="mt-4 text-primary font-medium">
|
||||
<a target="_blank" href="https://docs.liquity.org/faq/stability-pool-and-liquidations">Learn More</a></p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<SVGStableize />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="shadow rounded-lg py-8 px-6 flex">
|
||||
<div class="flex-1">
|
||||
<h3 class="text-2xl text-primary-black font-medium">
|
||||
Get Passive
|
||||
Yield on Your LUSD
|
||||
</h3>
|
||||
<p class="mt-4 text-primary font-medium">
|
||||
<a target="_blank" href="https://medium.com/b-protocol/b-protocol-liquity-integration-is-live-1342605e7cfb">Learn More</a></p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<SVGEarn />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="shadow rounded-lg py-8 px-6 flex">
|
||||
<div class="flex-1">
|
||||
<h3 class="text-2xl text-primary-black font-medium">
|
||||
Improved Liquidity Mining Program
|
||||
</h3>
|
||||
<p class="mt-4 text-primary font-medium">
|
||||
<a target="_blank" href="https://docs.bprotocol.org/info/liquidity-mining">Learn More</a></p>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<SVGUse />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-[60px]">
|
||||
<div
|
||||
class="w-full flex flex-col mt-6 sm:flex-row sm:items-center sm:justify-between xl:mt-4"
|
||||
>
|
||||
<h2 class="text-primary-gray text-lg font-semibold">Your Positions</h2>
|
||||
</div>
|
||||
<div
|
||||
class="mt-3 grid w-full grid-cols-1 gap-4 sm:grid-cols-2 xxl:gap-6 min-w-max-content px-1"
|
||||
>
|
||||
|
||||
<CardBprotocolBamm
|
||||
:amount="userBammInLusd"
|
||||
:amount-usd="userBammInUsd"
|
||||
:ethUserBalance="ethUserBalance"
|
||||
:stability-lqty-gain="unclaimedLqty"
|
||||
price-in-usd="1"
|
||||
:token="bammToken"
|
||||
:lusdUserBalance="lusdUserBalance"
|
||||
:ethIsGreaterThanOnePromille="ethIsGreaterThanOnePromille"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed, useRouter } from "@nuxtjs/composition-api";
|
||||
import BackIcon from "~/assets/icons/back.svg?inline";
|
||||
import SVGBalance from "@/assets/img/icons/balance.svg?inline";
|
||||
import SVGStableize from "@/assets/img/icons/bprotocol/stableize.svg?inline";
|
||||
import SVGUse from "@/assets/img/icons/bprotocol/use-v2.svg?inline";
|
||||
import SVGEarn from "@/assets/img/icons/bprotocol/earn.svg?inline";
|
||||
import SVGPercent from "@/assets/img/icons/percent.svg?inline";
|
||||
import SVGAdd from "~/assets/img/icons/add.svg?inline";
|
||||
import BprotocolIcon from "~/assets/icons/b-protocol.svg?inline";
|
||||
import ButtonDashed from "~/components/common/input/ButtonDashed.vue";
|
||||
import { useFormatting } from "~/composables/useFormatting";
|
||||
import { useStatus } from "~/composables/useStatus";
|
||||
import { useBigNumber } from "~/composables/useBigNumber";
|
||||
import CardLiquityTrove from "~/components/protocols/liquity/CardLiquityTrove.vue";
|
||||
import ButtonCTAOutlined from "~/components/common/input/ButtonCTAOutlined.vue";
|
||||
import { useBprotocolPosition } from '~/composables/protocols/useBprotocolPositions'
|
||||
import CardBprotocolBamm from '~/components/protocols/bprotocol/CardBprotocolBamm.vue';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
BackIcon,
|
||||
BprotocolIcon,
|
||||
ButtonCTAOutlined,
|
||||
SVGBalance,
|
||||
SVGStableize,
|
||||
SVGEarn,
|
||||
SVGUse,
|
||||
SVGPercent,
|
||||
CardBprotocolBamm
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
const {formatDecimal} = useFormatting();
|
||||
const {
|
||||
bammTotalSupply,
|
||||
bammUserBalance,
|
||||
ethTotal,
|
||||
ethUserBalance,
|
||||
lusdTotal,
|
||||
lusdUserBalance,
|
||||
unclaimedLqty,
|
||||
userBammInLusd,
|
||||
bammToken,
|
||||
userBammInUsd,
|
||||
totalBammSupplyInUsd,
|
||||
ethIsGreaterThanOnePromille
|
||||
} = useBprotocolPosition()
|
||||
|
||||
return {
|
||||
bammTotalSupply,
|
||||
bammUserBalance,
|
||||
ethTotal,
|
||||
ethUserBalance,
|
||||
lusdTotal,
|
||||
lusdUserBalance,
|
||||
unclaimedLqty,
|
||||
formatDecimal,
|
||||
userBammInLusd,
|
||||
bammToken,
|
||||
userBammInUsd,
|
||||
totalBammSupplyInUsd,
|
||||
ethIsGreaterThanOnePromille
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user