Skip to content

Commit 062637c

Browse files
authored
Merge pull request #6 from atmoner/main
Update to v1.1.0
2 parents 185731b + d4c9979 commit 062637c

16 files changed

+462
-15
lines changed

apis/cosmos-source.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ export default class CosmosAPI {
204204
return await this.axios(`https://graphql.bitcanna.io/api/rest/supply/inflation`)
205205
}
206206
async getBcnaApr() {
207-
return await this.axios(`https://api.stakely.io/stats`)
207+
// return await this.axios(`https://api.stakely.io/stats`)
208+
return await this.axios(`https://graphql.bitcanna.io/api/rest/price/apr`)
208209
}
209210

210211
async getValidator(address) {
@@ -220,6 +221,29 @@ export default class CosmosAPI {
220221
const res = await this.query(`cosmos/bank/v1beta1/supply`)
221222
return BigNumber(res.supply[0].amount)
222223
}
224+
/* async loadValidators() {
225+
const [
226+
validators,
227+
validatorsUnbonding,
228+
// annualProvision,
229+
// supply,
230+
// pool
231+
] = await Promise.all([
232+
this.query(`cosmos/staking/v1beta1/validators?status=BOND_STATUS_BONDED`),
233+
this.query(`cosmos/staking/v1beta1/validators?status=BOND_STATUS_UNBONDED`),
234+
// this.getAnnualProvision().catch(() => undefined),
235+
// this.getStakingSupply(),
236+
// this.query(`cosmos/staking/v1beta1/pool`)
237+
])
238+
239+
const resultValidators = validators.validators.concat(validatorsUnbonding.validators)
240+
241+
const tokensTotal = resultValidators.reduce(function(prev, cur) {
242+
return prev + parseInt(cur.tokens);
243+
}, 0);
244+
245+
return resultValidators.map(validator => reducers.validatorReducer(validator, tokensTotal))
246+
} */
223247
async loadValidators() {
224248
const [
225249
validators,
@@ -229,7 +253,7 @@ export default class CosmosAPI {
229253
// pool
230254
] = await Promise.all([
231255
this.query(`staking/validators?status=BOND_STATUS_BONDED`),
232-
this.query(`staking/validators?status=BOND_STATUS_UNBONDING`),
256+
this.query(`staking/validators?status=BOND_STATUS_UNBONDED`),
233257
// this.getAnnualProvision().catch(() => undefined),
234258
// this.getStakingSupply(),
235259
// this.query(`cosmos/staking/v1beta1/pool`)

components/common/AppMenu.vue

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
<h2 class="app-menu-title">Portfolio</h2>
1313
<i class="material-icons notranslate">chevron_right</i>
1414
</nuxt-link>
15+
<nuxt-link
16+
class="app-menu-item"
17+
to="/earn"
18+
exact="exact"
19+
title="Earn"
20+
@click.native="handleClick()"
21+
>
22+
<h2 class="app-menu-title">Earn</h2>
23+
<i class="material-icons notranslate">chevron_right</i>
24+
</nuxt-link>
1525
<nuxt-link
1626
class="app-menu-item"
1727
to="/validators"

components/earn/Card.vue

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<div>
3+
<h1>BCNA Earn</h1>
4+
<p>
5+
BitCanna Earn displays the various methods to utilize your BCNA assets to
6+
(potentially) earn additional income. <br />You can either lock your BCNA
7+
in liquidity pools, or use your BCNA to secure the BitCanna network.
8+
</p>
9+
<br />
10+
<p>
11+
For more information about liquidity pools,
12+
<a :href="urlMeduim">click here</a>. For more information about staking,
13+
<a :href="urlDoc">click here</a>.
14+
</p>
15+
</div>
16+
</template>
17+
18+
<script>
19+
export default {
20+
name: `PageSwap`,
21+
data: () => ({
22+
urlMeduim:
23+
'https://medium.com/@BitCannaGlobal/osmosis-dex-liquidity-pools-meet-bitcanna-ea63142644ab',
24+
urlDoc: 'https://docs.bitcanna.io/concepts-and-terminology/staking',
25+
}),
26+
}
27+
</script>
28+
29+
<style>
30+
.paragraph {
31+
margin-bottom: 15px;
32+
letter-spacing: 0.32px;
33+
}
34+
</style>

components/earn/Table.vue

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
<template>
2+
<div class="container2">
3+
<h1>Pooling</h1>
4+
<table class="tableearn">
5+
<col style="width: 20%" />
6+
<col style="width: 20%" />
7+
<col style="width: 20%" />
8+
<col style="width: 20%" />
9+
<col style="width: 20%" />
10+
<thead>
11+
<tr>
12+
<th class="cell"></th>
13+
<th class="cell"></th>
14+
<th class="cell">Lockup</th>
15+
<th class="cell">TVL</th>
16+
<th class="cell">APR</th>
17+
<th class="cell"></th>
18+
</tr>
19+
</thead>
20+
<tbody>
21+
<tr>
22+
<td class="cell">BCNA/ATOM</td>
23+
<td class="cell">
24+
<img src="icon/BCNA-Atom.svg" />
25+
</td>
26+
<td class="cell">1-7-14 days</td>
27+
<td class="cell">${{ tvlData572 | bigFigureOrShortDecimals }}</td>
28+
<td class="cell">142% + BONUS BCNA</td>
29+
<td class="cell">
30+
<CommonButton
31+
:href="network.osmosAppUrl + '/pool/572'"
32+
value="Start earning"
33+
:link="true"
34+
/>
35+
</td>
36+
</tr>
37+
<tr>
38+
<td class="cell">BCNA/OSMO</td>
39+
<td class="cell">
40+
<img src="icon/BCNA-Osmo.svg" width="80" height="45" />
41+
</td>
42+
<td class="cell">1-7-14 days</td>
43+
<td class="cell">${{ tvlData571 | bigFigureOrShortDecimals }}</td>
44+
<td class="cell">163% + BONUS BCNA</td>
45+
<td class="cell">
46+
<CommonButton
47+
:href="network.osmosAppUrl + '/pool/571'"
48+
value="Start earning"
49+
:link="true"
50+
/>
51+
</td>
52+
</tr>
53+
</tbody>
54+
</table>
55+
<br />
56+
<h1>Stake</h1>
57+
<table class="tableearn">
58+
<col style="width: 20%" />
59+
<col style="width: 20%" />
60+
<col style="width: 20%" />
61+
<col style="width: 20%" />
62+
<col style="width: 20%" />
63+
<thead>
64+
<tr>
65+
<th class="cell index"></th>
66+
<th class="cell"></th>
67+
<th class="cell">Lockup</th>
68+
<th class="cell">TVL</th>
69+
<th class="cell">APR</th>
70+
<th class="cell"></th>
71+
</tr>
72+
</thead>
73+
<tbody>
74+
<tr>
75+
<td class="cell">BitCanna Delegate</td>
76+
<td class="cell">
77+
<img src="icon/BCNA-icon.svg" width="45" height="45" />
78+
</td>
79+
<td class="cell">14 days</td>
80+
<td class="cell">
81+
${{ returnBcnaBonded | bigFigureOrShortDecimals }}
82+
</td>
83+
<td class="cell">
84+
{{ bcnaApr | bigFigureOrShortDecimals }}% (excl. commission)
85+
<!-- <nuxt-link to="/earn" @click.native="hi">
86+
<i class="material-icons">help</i>
87+
</nuxt-link> -->
88+
</td>
89+
<td class="cell noel">
90+
<nuxt-link to="/validators" class="li-session">
91+
<CommonButton value="Start earning" />
92+
</nuxt-link>
93+
</td>
94+
</tr>
95+
<tr>
96+
<td class="cell">BitCanna Validate</td>
97+
<td class="cell">
98+
<img src="icon/BCNA-icon.svg" width="45" height="45" />
99+
</td>
100+
<td class="cell">NA</td>
101+
<td class="cell">
102+
${{ returnBcnaBonded | bigFigureOrShortDecimals }}
103+
</td>
104+
<td class="cell">
105+
{{ bcnaApr | bigFigureOrShortDecimals }}% (excl. commission)
106+
<!-- <i class="material-icons">help</i> -->
107+
</td>
108+
<td class="cell">
109+
<CommonButton
110+
:href="'https://docs.bitcanna.io/guides/validator-setup-guide'"
111+
value="Start earning"
112+
:link="true"
113+
/>
114+
</td>
115+
</tr>
116+
</tbody>
117+
</table>
118+
</div>
119+
</template>
120+
121+
<script>
122+
import { mapState } from 'vuex'
123+
import axios from 'axios'
124+
import network from '~/network'
125+
import { bigFigureOrShortDecimals } from '~/common/numbers'
126+
127+
export default {
128+
name: `PageSwap`,
129+
filters: {
130+
bigFigureOrShortDecimals,
131+
},
132+
data: () => ({
133+
network,
134+
tvlData571: '',
135+
tvlData572: '',
136+
bcnaAprr: '',
137+
}),
138+
computed: {
139+
...mapState([`session`]),
140+
...mapState(`data`, ['bcnaApr', 'bcnaValue', 'validatorInfoPage']),
141+
returnBcnaBonded() {
142+
const finalBonded =
143+
(this.validatorInfoPage.bonded_tokens / 1000000) * this.bcnaValue
144+
return finalBonded
145+
},
146+
},
147+
async beforeMount() {
148+
// Pool 571
149+
const responseData571 = await axios.get(
150+
'https://api-osmosis.imperator.co/pools/v1/571'
151+
)
152+
this.tvlData571 = responseData571.data[0].liquidity
153+
154+
// Pool 572
155+
const responseData572 = await axios.get(
156+
'https://api-osmosis.imperator.co/pools/v1/572'
157+
)
158+
this.tvlData572 = responseData572.data[0].liquidity
159+
},
160+
mounted() {
161+
this.loadData()
162+
},
163+
methods: {
164+
/* hi(e) {
165+
const textHelp =
166+
'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.'
167+
this.$toast.info(textHelp, {
168+
position: 'top-right',
169+
timeout: 10000,
170+
closeOnClick: true,
171+
showCloseButtonOnHover: false,
172+
hideProgressBar: false,
173+
closeButton: 'button',
174+
icon: true,
175+
})
176+
}, */
177+
loadData() {
178+
this.$store.dispatch('data/refresh')
179+
},
180+
},
181+
}
182+
</script>
183+
184+
<style>
185+
.container2 {
186+
/* overflow: auto; */
187+
border-radius: var(--border-radius);
188+
background: var(--gray-1100);
189+
}
190+
.container2 > h1 {
191+
font-size: 24px;
192+
color: #fff;
193+
color: var(--white);
194+
font-weight: 600;
195+
padding-bottom: 1rem;
196+
}
197+
.icon {
198+
display: inline-flex;
199+
align-self: center;
200+
}
201+
202+
.tableearn {
203+
table-layout: fixed;
204+
min-width: 100%;
205+
border-radius: 30px;
206+
border-collapse: separate;
207+
border-spacing: 0 10px;
208+
margin-top: -10px;
209+
}
210+
.tableearn th {
211+
padding: 1rem 0.75rem;
212+
overflow: hidden;
213+
text-overflow: ellipsis;
214+
white-space: nowrap;
215+
text-align: left;
216+
}
217+
.tableearn td {
218+
vertical-align: middle;
219+
border: solid 1px #000;
220+
border-style: solid none;
221+
padding: 15px;
222+
background-color: black;
223+
}
224+
.tableearn td:first-child {
225+
border-left-style: solid;
226+
border-top-left-radius: 10px;
227+
border-bottom-left-radius: 10px;
228+
}
229+
.tableearn td:last-child {
230+
border-right-style: solid;
231+
border-bottom-right-radius: 10px;
232+
border-top-right-radius: 10px;
233+
}
234+
</style>

components/staking/TableValidators.vue

+13-10
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ export default {
5858
}),
5959
computed: {
6060
sortedEnrichedValidators() {
61-
const orderedValidators = orderBy(
62-
this.validators.map((validator) => ({
63-
...validator,
64-
smallName: validator.name ? validator.name.toLowerCase() : '',
65-
})),
66-
[this.sort.property],
67-
[this.sort.order]
68-
)
61+
let orderedValidators = ''
62+
if (this.validators[0] !== undefined) {
63+
orderedValidators = orderBy(
64+
this.validators.map((validator) => ({
65+
...validator,
66+
smallName: validator.name ? validator.name.toLowerCase() : '',
67+
})),
68+
[this.sort.property],
69+
[this.sort.order]
70+
)
71+
} else orderedValidators = ''
6972
return orderedValidators
7073
},
7174
properties() {
@@ -100,7 +103,7 @@ export default {
100103
methods: {
101104
getDelegation({ operatorAddress }) {
102105
return this.delegations.find(
103-
({ validator }) => validator.operatorAddress === operatorAddress
106+
({ validator }) => validator?.operatorAddress === operatorAddress
104107
)
105108
},
106109
getRewards({ operatorAddress }) {
@@ -109,7 +112,7 @@ export default {
109112
this.rewards
110113
/* istanbul ignore next */
111114
.filter(
112-
({ validator }) => validator.operatorAddress === operatorAddress
115+
({ validator }) => validator?.operatorAddress === operatorAddress
113116
)
114117
)
115118
}

0 commit comments

Comments
 (0)