Skip to content

Commit

Permalink
Merge pull request #6 from atmoner/main
Browse files Browse the repository at this point in the history
Update to v1.1.0
  • Loading branch information
atmoner authored Nov 26, 2021
2 parents 185731b + d4c9979 commit 062637c
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 15 deletions.
28 changes: 26 additions & 2 deletions apis/cosmos-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export default class CosmosAPI {
return await this.axios(`https://graphql.bitcanna.io/api/rest/supply/inflation`)
}
async getBcnaApr() {
return await this.axios(`https://api.stakely.io/stats`)
// return await this.axios(`https://api.stakely.io/stats`)
return await this.axios(`https://graphql.bitcanna.io/api/rest/price/apr`)
}

async getValidator(address) {
Expand All @@ -220,6 +221,29 @@ export default class CosmosAPI {
const res = await this.query(`cosmos/bank/v1beta1/supply`)
return BigNumber(res.supply[0].amount)
}
/* async loadValidators() {
const [
validators,
validatorsUnbonding,
// annualProvision,
// supply,
// pool
] = await Promise.all([
this.query(`cosmos/staking/v1beta1/validators?status=BOND_STATUS_BONDED`),
this.query(`cosmos/staking/v1beta1/validators?status=BOND_STATUS_UNBONDED`),
// this.getAnnualProvision().catch(() => undefined),
// this.getStakingSupply(),
// this.query(`cosmos/staking/v1beta1/pool`)
])
const resultValidators = validators.validators.concat(validatorsUnbonding.validators)
const tokensTotal = resultValidators.reduce(function(prev, cur) {
return prev + parseInt(cur.tokens);
}, 0);
return resultValidators.map(validator => reducers.validatorReducer(validator, tokensTotal))
} */
async loadValidators() {
const [
validators,
Expand All @@ -229,7 +253,7 @@ export default class CosmosAPI {
// pool
] = await Promise.all([
this.query(`staking/validators?status=BOND_STATUS_BONDED`),
this.query(`staking/validators?status=BOND_STATUS_UNBONDING`),
this.query(`staking/validators?status=BOND_STATUS_UNBONDED`),
// this.getAnnualProvision().catch(() => undefined),
// this.getStakingSupply(),
// this.query(`cosmos/staking/v1beta1/pool`)
Expand Down
10 changes: 10 additions & 0 deletions components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
<h2 class="app-menu-title">Portfolio</h2>
<i class="material-icons notranslate">chevron_right</i>
</nuxt-link>
<nuxt-link
class="app-menu-item"
to="/earn"
exact="exact"
title="Earn"
@click.native="handleClick()"
>
<h2 class="app-menu-title">Earn</h2>
<i class="material-icons notranslate">chevron_right</i>
</nuxt-link>
<nuxt-link
class="app-menu-item"
to="/validators"
Expand Down
34 changes: 34 additions & 0 deletions components/earn/Card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<div>
<h1>BCNA Earn</h1>
<p>
BitCanna Earn displays the various methods to utilize your BCNA assets to
(potentially) earn additional income. <br />You can either lock your BCNA
in liquidity pools, or use your BCNA to secure the BitCanna network.
</p>
<br />
<p>
For more information about liquidity pools,
<a :href="urlMeduim">click here</a>. For more information about staking,
<a :href="urlDoc">click here</a>.
</p>
</div>
</template>

<script>
export default {
name: `PageSwap`,
data: () => ({
urlMeduim:
'https://medium.com/@BitCannaGlobal/osmosis-dex-liquidity-pools-meet-bitcanna-ea63142644ab',
urlDoc: 'https://docs.bitcanna.io/concepts-and-terminology/staking',
}),
}
</script>

<style>
.paragraph {
margin-bottom: 15px;
letter-spacing: 0.32px;
}
</style>
234 changes: 234 additions & 0 deletions components/earn/Table.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
<template>
<div class="container2">
<h1>Pooling</h1>
<table class="tableearn">
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<thead>
<tr>
<th class="cell"></th>
<th class="cell"></th>
<th class="cell">Lockup</th>
<th class="cell">TVL</th>
<th class="cell">APR</th>
<th class="cell"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell">BCNA/ATOM</td>
<td class="cell">
<img src="icon/BCNA-Atom.svg" />
</td>
<td class="cell">1-7-14 days</td>
<td class="cell">${{ tvlData572 | bigFigureOrShortDecimals }}</td>
<td class="cell">142% + BONUS BCNA</td>
<td class="cell">
<CommonButton
:href="network.osmosAppUrl + '/pool/572'"
value="Start earning"
:link="true"
/>
</td>
</tr>
<tr>
<td class="cell">BCNA/OSMO</td>
<td class="cell">
<img src="icon/BCNA-Osmo.svg" width="80" height="45" />
</td>
<td class="cell">1-7-14 days</td>
<td class="cell">${{ tvlData571 | bigFigureOrShortDecimals }}</td>
<td class="cell">163% + BONUS BCNA</td>
<td class="cell">
<CommonButton
:href="network.osmosAppUrl + '/pool/571'"
value="Start earning"
:link="true"
/>
</td>
</tr>
</tbody>
</table>
<br />
<h1>Stake</h1>
<table class="tableearn">
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<thead>
<tr>
<th class="cell index"></th>
<th class="cell"></th>
<th class="cell">Lockup</th>
<th class="cell">TVL</th>
<th class="cell">APR</th>
<th class="cell"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell">BitCanna Delegate</td>
<td class="cell">
<img src="icon/BCNA-icon.svg" width="45" height="45" />
</td>
<td class="cell">14 days</td>
<td class="cell">
${{ returnBcnaBonded | bigFigureOrShortDecimals }}
</td>
<td class="cell">
{{ bcnaApr | bigFigureOrShortDecimals }}% (excl. commission)
<!-- <nuxt-link to="/earn" @click.native="hi">
<i class="material-icons">help</i>
</nuxt-link> -->
</td>
<td class="cell noel">
<nuxt-link to="/validators" class="li-session">
<CommonButton value="Start earning" />
</nuxt-link>
</td>
</tr>
<tr>
<td class="cell">BitCanna Validate</td>
<td class="cell">
<img src="icon/BCNA-icon.svg" width="45" height="45" />
</td>
<td class="cell">NA</td>
<td class="cell">
${{ returnBcnaBonded | bigFigureOrShortDecimals }}
</td>
<td class="cell">
{{ bcnaApr | bigFigureOrShortDecimals }}% (excl. commission)
<!-- <i class="material-icons">help</i> -->
</td>
<td class="cell">
<CommonButton
:href="'https://docs.bitcanna.io/guides/validator-setup-guide'"
value="Start earning"
:link="true"
/>
</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
import { mapState } from 'vuex'
import axios from 'axios'
import network from '~/network'
import { bigFigureOrShortDecimals } from '~/common/numbers'
export default {
name: `PageSwap`,
filters: {
bigFigureOrShortDecimals,
},
data: () => ({
network,
tvlData571: '',
tvlData572: '',
bcnaAprr: '',
}),
computed: {
...mapState([`session`]),
...mapState(`data`, ['bcnaApr', 'bcnaValue', 'validatorInfoPage']),
returnBcnaBonded() {
const finalBonded =
(this.validatorInfoPage.bonded_tokens / 1000000) * this.bcnaValue
return finalBonded
},
},
async beforeMount() {
// Pool 571
const responseData571 = await axios.get(
'https://api-osmosis.imperator.co/pools/v1/571'
)
this.tvlData571 = responseData571.data[0].liquidity
// Pool 572
const responseData572 = await axios.get(
'https://api-osmosis.imperator.co/pools/v1/572'
)
this.tvlData572 = responseData572.data[0].liquidity
},
mounted() {
this.loadData()
},
methods: {
/* hi(e) {
const textHelp =
'Need help?\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s.'
this.$toast.info(textHelp, {
position: 'top-right',
timeout: 10000,
closeOnClick: true,
showCloseButtonOnHover: false,
hideProgressBar: false,
closeButton: 'button',
icon: true,
})
}, */
loadData() {
this.$store.dispatch('data/refresh')
},
},
}
</script>

<style>
.container2 {
/* overflow: auto; */
border-radius: var(--border-radius);
background: var(--gray-1100);
}
.container2 > h1 {
font-size: 24px;
color: #fff;
color: var(--white);
font-weight: 600;
padding-bottom: 1rem;
}
.icon {
display: inline-flex;
align-self: center;
}
.tableearn {
table-layout: fixed;
min-width: 100%;
border-radius: 30px;
border-collapse: separate;
border-spacing: 0 10px;
margin-top: -10px;
}
.tableearn th {
padding: 1rem 0.75rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
}
.tableearn td {
vertical-align: middle;
border: solid 1px #000;
border-style: solid none;
padding: 15px;
background-color: black;
}
.tableearn td:first-child {
border-left-style: solid;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.tableearn td:last-child {
border-right-style: solid;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
}
</style>
23 changes: 13 additions & 10 deletions components/staking/TableValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ export default {
}),
computed: {
sortedEnrichedValidators() {
const orderedValidators = orderBy(
this.validators.map((validator) => ({
...validator,
smallName: validator.name ? validator.name.toLowerCase() : '',
})),
[this.sort.property],
[this.sort.order]
)
let orderedValidators = ''
if (this.validators[0] !== undefined) {
orderedValidators = orderBy(
this.validators.map((validator) => ({
...validator,
smallName: validator.name ? validator.name.toLowerCase() : '',
})),
[this.sort.property],
[this.sort.order]
)
} else orderedValidators = ''
return orderedValidators
},
properties() {
Expand Down Expand Up @@ -100,7 +103,7 @@ export default {
methods: {
getDelegation({ operatorAddress }) {
return this.delegations.find(
({ validator }) => validator.operatorAddress === operatorAddress
({ validator }) => validator?.operatorAddress === operatorAddress
)
},
getRewards({ operatorAddress }) {
Expand All @@ -109,7 +112,7 @@ export default {
this.rewards
/* istanbul ignore next */
.filter(
({ validator }) => validator.operatorAddress === operatorAddress
({ validator }) => validator?.operatorAddress === operatorAddress
)
)
}
Expand Down
Loading

0 comments on commit 062637c

Please sign in to comment.