Added code to handle price of ownership token and market valuation

This commit is contained in:
Vivek Teega 2023-06-08 19:28:47 +05:30
parent 3ac92560f4
commit 90680c6ad6

View File

@ -283,7 +283,9 @@
Add up all expenses
</p>
<p>
Production valuation is the sum of all the expenses incurred to operate the system. When tokens are sold the valuation should be atleast equal to cost of operating the system.
Production valuation is the sum of all the expenses incurred to operate the system.
When tokens are sold the valuation should be atleast equal to cost of operating the
system.
</p>
</td>
<td class="stat-value">
@ -298,7 +300,9 @@
Number of room nights consumed * Consumption valuation per night
</p>
<p>
Consumption valuation is the result of valuation the system is building on account of the basic good or service being offered for consumption. This represents the gains and earnings from the operation of system.
Consumption valuation is the result of valuation the system is building on account
of the basic good or service being offered for consumption. This represents the
gains and earnings from the operation of system.
</p>
</td>
<td class="stat-value">
@ -352,7 +356,8 @@
Reserve Pool = Market valuation - Production valuation
</p>
<p>
Reserve Pool is a Bitcoin Multisig address which acts as the bank account for this system. All payments and expenses related to the system will happen there.
Reserve Pool is a Bitcoin Multisig address which acts as the bank account for this
system. All payments and expenses related to the system will happen there.
</p>
</td>
<td class="stat-value">
@ -364,10 +369,11 @@
Investments
</h4>
<p>
</p>
<p>
Investments help in providing for the initial production valuation and they add to the reserve pool.
Investments help in providing for the initial production valuation and they add to
the reserve pool.
</p>
</td>
<td class="stat-value">
@ -406,7 +412,7 @@
<div class="grid gap-0-5" id="banner">
<strong> Price per ownership token </strong>
<p>
</p>
<b id="price-per-ownership-token">
<sm-spinner></sm-spinner>
@ -506,7 +512,8 @@
Investment(committed + delivered) and room revenues (Booked + stayed)
</h4>
<p>
The total money we have either received or got committment for from token sales, room night investments and on the spot bookings
The total money we have either received or got committment for from token sales,
room night investments and on the spot bookings
</p>
</td>
<td id="total-consumption-cost" class="stat-value">
@ -518,22 +525,20 @@
<br>
<div class="grid gap-0-5" id="banner">
<strong> Objectives </strong>
<br>
<p>Consumption Valuation should be higher than Production valuation.
Amount to go till Consumption Valuation catches up with production Valuation
</p>
<b id="amount-left-production-consumption-catchup">
<sm-spinner></sm-spinner>
</b>
<br>
<p>Initial token sales should cover up for the production cost at the time of sale
</p>
<b id="amount-left-production-consumption-catchup">
<sm-spinner></sm-spinner>
</b>
<p>Consumption of the service should take care of the running costs
<br>
<p>Consumption of the service should take care of the running costs
</p>
<b id="amount-left-production-consumption-catchup">
<sm-spinner></sm-spinner>
</b>
</div>
</section>
@ -731,7 +736,7 @@
<script id="onLoadStartUp">
function formatAmount(amount) {
console.log(amount)
console.log(`amount: ${amount}`)
return amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
}
async function onLoadStartUp() {
@ -752,74 +757,93 @@
'Access-Control-Allow-Origin': '*'
}
})
.then(response => response.json())
.then(data => {
const { productionValuation, consumptionNumber, consumptionCost, consumptionValuation, systemValuation } = data
getRef("total-amount-issued").textContent = formatAmount(productionValuation)
getRef("price-per-unit-consumption").textContent = formatAmount(consumptionValuation / consumptionNumber)
getRef("price-per-ownership-token").textContent = formatAmount(consumptionValuation / consumptionNumber)
getRef("total-consumption-measured").textContent = consumptionNumber
getRef("total-consumption-cost").textContent = formatAmount(consumptionCost)
getRef("consumption-valuation").textContent = formatAmount(consumptionValuation)
getRef("system-valuation").textContent = formatAmount(systemValuation)
getRef("market-valuation").textContent = formatAmount(-1)
getRef("amount-left-production-consumption-catchup").textContent = formatAmount(Math.max(0, (productionValuation - consumptionValuation)))
resolve()
})
.catch(error => {
console.error('Error:', error)
reject(error)
})
.then(response => response.json())
.then(data => {
const { productionValuation, consumptionNumber, consumptionCost, consumptionValuation, systemValuation } = data
getRef("total-amount-issued").textContent = formatAmount(productionValuation)
getRef("price-per-unit-consumption").textContent = formatAmount(consumptionValuation / consumptionNumber)
getRef("total-consumption-measured").textContent = consumptionNumber
getRef("total-consumption-cost").textContent = formatAmount(consumptionCost)
getRef("consumption-valuation").textContent = formatAmount(consumptionValuation)
getRef("system-valuation").textContent = formatAmount(systemValuation)
getRef("amount-left-production-consumption-catchup").textContent = formatAmount(Math.max(0, (productionValuation - consumptionValuation)))
resolve()
})
.catch(error => {
console.error('Error:', error)
reject(error)
})
fetch(`${floGlobals.token_api}/api/v2/tokenInfo/tokenroom`, {
// call api for price per ownership token
smartContractInfo_api = fetch(`${floGlobals.token_api}/api/v2/smartContractInfo?contractName=swap-tokenroom-usd&contractAddress=FUSBi3sQ9YFRs76wiMrDYmhqguPCXue8po`, {
headers: {
'Access-Control-Allow-Origin': '*'
}
})
.then(response => response.json())
.then(data => {
const { token, tokenSupply} = data
getRef("ownership-tokens-amount").textContent = tokenSupply
resolve()
})
.catch(error => {
console.error('Error:', error)
reject(error)
})
.then(response => response.json())
.then(data => {
const { price, priceType } = data['contractInfo']
getRef("price-per-ownership-token").textContent = formatAmount(price)
return price
})
.catch(error => {
console.error('Error:', error)
reject(error)
})
tokenInfo_api = fetch(`${floGlobals.token_api}/api/v2/tokenInfo/tokenroom`, {
headers: {
'Access-Control-Allow-Origin': '*'
}
})
.then(response => response.json())
.then(data => {
const { token, tokenSupply } = data
getRef("ownership-tokens-amount").textContent = tokenSupply
return tokenSupply
})
.catch(error => {
console.error('Error:', error)
reject(error)
})
Promise.all([smartContractInfo_api, tokenInfo_api]).then(([price, tokenSupply]) => {
getRef("market-valuation").textContent = formatAmount(price*tokenSupply)
resolve()
});
btcOperator.getBalance('bc1qh38s56q6vqahqv758dgsrvh92tkrt5drg259zklqectmj44uy5lsg4ppps')
.then((btcAddresBalance) => {
console.log(`BTC balance ${btcAddresBalance}`)
getRef("reserve-tokens-amount").textContent = `${btcAddresBalance} BTC`
})
.then((btcAddresBalance) => {
console.log(`BTC balance ${btcAddresBalance}`)
getRef("reserve-tokens-amount").textContent = `${btcAddresBalance} BTC`
})
})
})
floDapps.launchStartUp().then((result) => {
console.log(result);
//window.location.hash = '#userinfo';
// getRef('user_flo_id').value = myFloID
// getRef('user_login_popup_button').classList.add('hide')
// getRef('userpage-userfloid').innerText = myFloID
// getRef('user_signout_popup_button').classList.remove('hide')
floDapps.launchStartUp().then((result) => {
console.log(result);
//window.location.hash = '#userinfo';
// getRef('user_flo_id').value = myFloID
// getRef('user_login_popup_button').classList.add('hide')
// getRef('userpage-userfloid').innerText = myFloID
// getRef('user_signout_popup_button').classList.remove('hide')
// Check if subadmin
if (floGlobals.subAdmins.includes(myFloID)) {
console.log('This is a subadmin')
document.getElementById('subadmin-nav').classList.remove('hide')
}
// Check if subadmin
if (floGlobals.subAdmins.includes(myFloID)) {
console.log('This is a subadmin')
document.getElementById('subadmin-nav').classList.remove('hide')
}
// Show userinfo
//document.getElementById('userinfo-nav').classList.remove('hide')
//document.getElementById('userinfo-nav').click()
// Show userinfo
//document.getElementById('userinfo-nav').classList.remove('hide')
//document.getElementById('userinfo-nav').click()
//App functions....
//App functions....
}).catch((error) => console.error(error));
}
}).catch((error) => console.error(error));
}
</script>
<script src="https://ranchimall.github.io/Standard_Operations/lib.js"></script>