Fix staking for reserved contribution spots
Reserved contributions for the current wallet were not properly being added into the available contribution room available to a wallet; this fixes it to include any unfilled reserved spots when showing available stakes.
This commit is contained in:
parent
2d1188f2ad
commit
9079f4cf2b
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "loki-electron-wallet",
|
"name": "oxen-electron-wallet",
|
||||||
"version": "1.5.4",
|
"version": "1.5.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "oxen-electron-wallet",
|
"name": "oxen-electron-wallet",
|
||||||
"version": "1.5.6",
|
"version": "1.5.7",
|
||||||
"description": "Modern GUI interface for Oxen Currency",
|
"description": "Modern GUI interface for Oxen Currency",
|
||||||
"productName": "Oxen Electron Wallet",
|
"productName": "Oxen Electron Wallet",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
</span>
|
</span>
|
||||||
<span v-if="node.awaitingContribution" class="contrib-amounts">
|
<span v-if="node.awaitingContribution" class="contrib-amounts">
|
||||||
{{ $t("strings.serviceNodeDetails.minContribution") }}:
|
{{ $t("strings.serviceNodeDetails.minContribution") }}:
|
||||||
{{ getMinContribution(node) }} OXEN •
|
{{ getMinContribution(node, our_address) }} OXEN •
|
||||||
{{ $t("strings.serviceNodeDetails.maxContribution") }}:
|
{{ $t("strings.serviceNodeDetails.maxContribution") }}:
|
||||||
{{ openForContriubtionOxen(node) }} OXEN
|
{{ openForContributionOxen(node, our_address) }} OXEN
|
||||||
</span>
|
</span>
|
||||||
</q-item-label>
|
</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
|
@ -118,7 +118,7 @@ export default {
|
||||||
nodeWithMinContribution(node) {
|
nodeWithMinContribution(node) {
|
||||||
const nodeWithMinContribution = {
|
const nodeWithMinContribution = {
|
||||||
...node,
|
...node,
|
||||||
minContribution: this.getMinContribution(node)
|
minContribution: this.getMinContribution(node, this.our_address)
|
||||||
};
|
};
|
||||||
return nodeWithMinContribution;
|
return nodeWithMinContribution;
|
||||||
},
|
},
|
||||||
|
|
|
@ -289,11 +289,11 @@ export default {
|
||||||
},
|
},
|
||||||
minStake() {
|
minStake() {
|
||||||
const node = this.getNodeWithPubKey();
|
const node = this.getNodeWithPubKey();
|
||||||
return this.getMinContribution(node);
|
return this.getMinContribution(node, this.award_address);
|
||||||
},
|
},
|
||||||
maxStake() {
|
maxStake() {
|
||||||
const node = this.getNodeWithPubKey();
|
const node = this.getNodeWithPubKey();
|
||||||
return this.openForContriubtionOxen(node);
|
return this.openForContributionOxen(node, this.award_address);
|
||||||
},
|
},
|
||||||
getFeeDecimal(node) {
|
getFeeDecimal(node) {
|
||||||
const operatorPortion = node.portions_for_operator;
|
const operatorPortion = node.portions_for_operator;
|
||||||
|
|
|
@ -1,27 +1,43 @@
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
getMinContribution(node) {
|
// Returns the atomic, unfilled, reserved contributions for the given wallet
|
||||||
|
getUnfilledReservedContribution(node, addr) {
|
||||||
|
for (const contributor of node.contributors)
|
||||||
|
if (contributor.address === addr && contributor.amount === 0 && contributor.reserved > 0)
|
||||||
|
return contributor.reserved;
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
getMinContribution(node, myaddr) {
|
||||||
|
if (node.funded)
|
||||||
|
return 0;
|
||||||
|
|
||||||
const MAX_NUMBER_OF_CONTRIBUTORS = 4;
|
const MAX_NUMBER_OF_CONTRIBUTORS = 4;
|
||||||
// This is calculated in the same way it is calculated on the LokiBlocks site
|
// If we have a reserved spot then that is our minimum:
|
||||||
const openContributionRemaining = this.openForContribution(node);
|
let minContributionAtomicUnits = this.getUnfilledReservedContribution(node, myaddr);
|
||||||
const minContributionAtomicUnits =
|
// Otherwise we can contribute our fair share of whatever amount is left (i.e. REMAINING/N
|
||||||
!node.funded && node.contributors.length < MAX_NUMBER_OF_CONTRIBUTORS
|
// when there are N available spots).
|
||||||
? openContributionRemaining /
|
if (minContributionAtomicUnits === 0 && node.contributors.length < MAX_NUMBER_OF_CONTRIBUTORS) {
|
||||||
(MAX_NUMBER_OF_CONTRIBUTORS - node.contributors.length)
|
const openContributionRemaining = this.openForContribution(node);
|
||||||
: 0;
|
|
||||||
|
minContributionAtomicUnits = openContributionRemaining /
|
||||||
|
(MAX_NUMBER_OF_CONTRIBUTORS - node.contributors.length);
|
||||||
|
}
|
||||||
|
|
||||||
const minContributionOxen = minContributionAtomicUnits / 1e9;
|
const minContributionOxen = minContributionAtomicUnits / 1e9;
|
||||||
// ceiling to 4 decimal places
|
// ceiling to 4 decimal places
|
||||||
return minContributionOxen.toFixed(4);
|
return minContributionOxen.toFixed(4);
|
||||||
},
|
},
|
||||||
openForContribution(node) {
|
openForContribution(node, addr = null) {
|
||||||
const openContributionRemaining =
|
let openContributionRemaining =
|
||||||
node.staking_requirement > node.total_reserved
|
node.staking_requirement > node.total_reserved
|
||||||
? node.staking_requirement - node.total_reserved
|
? node.staking_requirement - node.total_reserved
|
||||||
: 0;
|
: 0;
|
||||||
|
if (addr)
|
||||||
|
openContributionRemaining += this.getUnfilledReservedContribution(node, addr);
|
||||||
return openContributionRemaining;
|
return openContributionRemaining;
|
||||||
},
|
},
|
||||||
openForContriubtionOxen(node) {
|
openForContributionOxen(node, addr = null) {
|
||||||
return (this.openForContribution(node) / 1e9).toFixed(4);
|
return (this.openForContribution(node, addr) / 1e9).toFixed(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue