vault upgrades; fees; refactoring
This commit is contained in:
17
src/components/HubSpot.vue
Normal file
17
src/components/HubSpot.vue
Normal file
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
const importUrl = 'https://js-na1.hs-scripts.com/46028804.js'
|
||||
|
||||
const viteWsUrl = import.meta.env.VITE_WS_URL;
|
||||
|
||||
if (viteWsUrl.indexOf('localhost') === -1) {
|
||||
console.log('loading HubSpot')
|
||||
let script = document.createElement('script')
|
||||
script.setAttribute('src', importUrl)
|
||||
document.head.appendChild(script)
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -43,7 +43,7 @@ function placeOrder() {
|
||||
const route = os.route
|
||||
const amt = FixedNumber.fromString(os.totalAmount.toString(), {decimals: os.amountToken.decimals}).value
|
||||
const ts = props.tranches()
|
||||
const order = newOrder(tokenIn, tokenOut, route.exchange, route.fee, amt, os.amountIsInput, ts) // todo: minAmount, outputToOwner, chainOrder
|
||||
const order = newOrder(tokenIn, tokenOut, route.exchange, route.fee, amt, os.amountIsInput, ts) // todo: minAmount, outputToOwner, conditionalOrder
|
||||
pendOrder(order)
|
||||
route('Status')
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
</suspense>
|
||||
</td>
|
||||
<td class="d-flex align-center text-left">
|
||||
<!-- todo describe rate limits -->
|
||||
<div class="text-right">
|
||||
<div class="mx-3">{{ describeTrancheTime(item, true, t) }}</div>
|
||||
<div class="mx-3">{{ describeTrancheTime(item, false, t) }}</div>
|
||||
@@ -160,7 +161,6 @@ const s = useStore()
|
||||
const ws = useWalletStore()
|
||||
const props = defineProps(['vault'])
|
||||
const vaultAddr = computed(()=>props.vault?props.vault:s.vault)
|
||||
const inverted = ref({})
|
||||
|
||||
|
||||
const datatableHeaders = [
|
||||
@@ -191,11 +191,11 @@ const orders = computed(()=>{
|
||||
// false, min is barrier
|
||||
// false, max is barrier
|
||||
// false, market order
|
||||
// false, reserved
|
||||
// false, reserved
|
||||
// false, reserved
|
||||
// 0, reserved
|
||||
// 0, reserved
|
||||
// 0, minIsRatio
|
||||
// 0, maxIsRatio
|
||||
// false, _reserved7
|
||||
// 0, rateLimitFraction
|
||||
// 0, rateLimitPeriod
|
||||
// 0, start time
|
||||
// 20, end time
|
||||
// 730643660, min intercept
|
||||
|
||||
72
src/components/UpgradeAlert.vue
Normal file
72
src/components/UpgradeAlert.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div v-if="upgradeVersion>0">
|
||||
<v-alert type="info" closable rounded="0">
|
||||
Vault Upgrade Available!
|
||||
<v-btn @click="showDialog=true" size="small">
|
||||
Upgrade Now
|
||||
</v-btn>
|
||||
</v-alert>
|
||||
<v-dialog v-model="showDialog">
|
||||
<v-card title="Upgrade Vault" width="25em" class="mx-auto">
|
||||
<v-card-text>An upgrade to version {{upgradeVersion}} is available for your approval.</v-card-text>
|
||||
<v-card-text><v-icon icon="mdi-information" color="yellow"/> Any currently open orders will continue to execute normally.</v-card-text>
|
||||
<v-card-actions class="d-flex justify-center">
|
||||
<v-btn color='primary' @click="doUpgrade">Upgrade Vault</v-btn>
|
||||
<v-btn @click="showDialog=false">Cancel</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-alert v-if="upgradeResult==='SUCCESS'" type="info" closable rounded="0">
|
||||
Vault Upgraded Successfully!
|
||||
</v-alert>
|
||||
<v-alert v-if="upgradeResult && upgradeResult!=='SUCCESS'" type="warning" closable rounded="0">
|
||||
Vault upgrade failed! ({{upgradeResult}})
|
||||
</v-alert>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref} from "vue";
|
||||
import {upgradeVault, detectUpgrade} from "@/blockchain/wallet.js";
|
||||
import {useStore} from "@/store/store.js";
|
||||
|
||||
const s = useStore()
|
||||
const upgradeVersion = ref(0)
|
||||
const showDialog = ref(false)
|
||||
const upgradeResult = ref(null)
|
||||
|
||||
detectUpgrade().then((version)=>{
|
||||
if (version===0) {
|
||||
console.log('Vault is the latest version')
|
||||
}
|
||||
else {
|
||||
upgradeVersion.value = version
|
||||
console.log(`Vault upgrade available to version ${version}`)
|
||||
}
|
||||
})
|
||||
|
||||
async function doUpgrade() {
|
||||
showDialog.value = false
|
||||
if (!s.upgrade) {
|
||||
console.error('no upgrade available')
|
||||
return
|
||||
}
|
||||
const vault = s.vault
|
||||
if (!vault) {
|
||||
console.error('no vault logged in')
|
||||
return
|
||||
}
|
||||
upgradeVault(vault, s.upgrade).then(()=>{
|
||||
upgradeVersion.value = 0
|
||||
console.log('vault upgraded')
|
||||
upgradeResult.value = 'SUCCESS'
|
||||
}).catch((reason)=>{
|
||||
upgradeResult.value = reason
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -108,7 +108,7 @@ function buildOrder() {
|
||||
// uint256 minFillAmount; // if a tranche has less than this amount available to fill, it is considered completed
|
||||
// bool amountIsInput;
|
||||
// bool outputDirectlyToOwner;
|
||||
// uint64 chainOrder; // use NO_CHAIN for no chaining. chainOrder index must be < than this order's index for safety (written first) and chainOrder state must be Template
|
||||
// uint64 conditionalOrder; // use NO_CONDITIONAL_ORDER for no chaining. conditionalOrder index must be < than this order's index for safety (written first) and conditionalOrder state must be Template
|
||||
// Tranche[] tranches;
|
||||
// }
|
||||
const symbol = co.selectedSymbol
|
||||
|
||||
@@ -303,9 +303,7 @@ const _extendLeft = ref(false)
|
||||
const extendLeft = computed({
|
||||
get() {return _extendLeft.value},
|
||||
set(v) {
|
||||
console.log('set extendLeft', v)
|
||||
if (v !== _extendLeft.value) {
|
||||
console.log('DO set extendLeft')
|
||||
_extendLeft.value = v;
|
||||
const b = {...props.builder}
|
||||
b.extendLeft = v
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<toolbar :title="title" :icon="icon">
|
||||
<slot name="toolbar"/>
|
||||
</toolbar>
|
||||
<upgrade-alert/>
|
||||
<div class="overflow-y-auto">
|
||||
<slot/>
|
||||
</div>
|
||||
@@ -12,6 +13,7 @@
|
||||
<script setup>
|
||||
|
||||
import Toolbar from "@/components/chart/Toolbar.vue";
|
||||
import UpgradeAlert from "@/components/UpgradeAlert.vue";
|
||||
|
||||
const props = defineProps(['title', 'icon'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user