This commit is contained in:
tim
2024-10-22 03:42:08 -04:00
parent 82fccc1be3
commit d33eca6931
12 changed files with 101 additions and 40 deletions

View File

@@ -156,16 +156,6 @@ export async function connectWallet(chainId) {
} }
export async function switchChain(chainId) {
if (useWalletStore().chainId === chainId)
return
await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [{"chainId": '0x' + chainId.toString(16)}]
})
}
function discoverVaults(owner) { function discoverVaults(owner) {
const s = useStore() const s = useStore()
console.log('discoverVaults', owner) console.log('discoverVaults', owner)
@@ -522,7 +512,67 @@ function upgradeError(e) {
console.error('error while upgrading vault', e) console.error('error while upgrading vault', e)
} }
export async function upgradeVault(vault, impl) { export async function upgradeVault(vault, impl) {
pendTransaction(upgradeSender(vault, impl), upgradeError) pendTransaction(upgradeSender(vault, impl), upgradeError)
} }
const _chainInfos = {
// Arbitrum One
42161: {
"chainId": "0xa4b1",
"chainName": "Arbitrum One",
"rpcUrls": ["https://arbitrum-mainnet.infura.io"],
"blockExplorerUrls": ['https://explorer.arbitrum.io'],
"nativeCurrency": {
"name": "Ethereum",
"symbol": "ETH",
"decimals": 18
}
},
1337: {
"chainId": "0x539",
"chainName": "Dexorder Alpha Testnet",
"rpcUrls": ["https://rpc.alpha.dexorder.trade"],
"nativeCurrency": {
"name": "Test Ethereum",
"symbol": "TETH",
"decimals": 18
}
},
31337: {
"chainId": "0x7a69",
"chainName": "Mockchain",
"rpcUrls": ["http://localhost:8545"],
"nativeCurrency": {
"name": "Test Ethereum",
"symbol": "TETH",
"decimals": 18
}
},
}
export async function switchChain(chainId) {
if (useWalletStore().chainId === chainId)
return
await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [{"chainId": '0x' + chainId.toString(16)}]
})
}
export async function addNetwork(chainId) {
const info = _chainInfos[chainId]
if (!info) {
console.log(`No info to add chain ${chainId}`)
return
}
await window.ethereum.request({
"method": "wallet_addEthereumChain",
"params": [info]
});
}

View File

@@ -26,11 +26,11 @@ function symbolChanged(symbol) {
if (symbol===null) if (symbol===null)
co.selectedSymbol = null co.selectedSymbol = null
else { else {
updateFeeDropdown()
const info = lookupSymbol(symbol.ticker) const info = lookupSymbol(symbol.ticker)
symbolChangedCbs.forEach((cb) => cb(info)) symbolChangedCbs.forEach((cb) => cb(info))
co.selectedSymbol = info co.selectedSymbol = info
} }
updateFeeDropdown()
} }
@@ -109,7 +109,10 @@ export function updateFeeDropdown() {
const [_addr, fee] = p const [_addr, fee] = p
return { return {
title: (fee / 10000).toFixed(2) + '%', title: (fee / 10000).toFixed(2) + '%',
onSelect: fee === symbolItem.fee ? ()=>{} : () => selectPool(fee), onSelect: ()=>{
if (fee !== symbolItem.fee)
selectPool(fee)
},
} }
}) })
} }
@@ -460,7 +463,7 @@ export function deleteShapeId(id) {
chart.removeEntity(id) chart.removeEntity(id)
} }
const MEAN_RANGE_MULTIPLIER = 10 const MEAN_RANGE_MULTIPLIER = 3
function chartMeanRange() { function chartMeanRange() {
let range = 0 let range = 0

View File

@@ -207,7 +207,7 @@ export class Shape {
// return an object with property defaults, e.g. { "linetoolhorzline.linecolor": "#7f11e0" } // return an object with property defaults, e.g. { "linetoolhorzline.linecolor": "#7f11e0" }
// https://www.tradingview.com/charting-library-docs/latest/api/modules/Charting_Library#drawingoverrides // https://www.tradingview.com/charting-library-docs/latest/api/modules/Charting_Library#drawingoverrides
drawingOverrides() { drawingOverrides() {
return this.colorProps() return mixin(this.colorProps(), this.creationOptions)
} }
create() { create() {
@@ -547,8 +547,8 @@ export class DLine extends Line {
// Model // Model
this.model.pointA = null // {time:..., price:...} this.model.pointA = null // {time:..., price:...}
this.model.pointB = null this.model.pointB = null
this.model.extendLeft = false this.model.extendLeft = true
this.model.extendRight = false this.model.extendRight = true
this.setModel(model) // call setModel at the end this.setModel(model) // call setModel at the end
} }

View File

@@ -23,7 +23,7 @@
<v-list-subheader title="ETH"/> <v-list-subheader title="ETH"/>
<v-list-item title="Wrap" key="wrap" value="wrap" prepend-icon="mdi-location-enter" @click="onWrap"/> <v-list-item title="Wrap" key="wrap" value="wrap" prepend-icon="mdi-location-enter" @click="onWrap"/>
<v-list-item title="Withdraw" key="withdraw" value="withdraw" prepend-icon="mdi-arrow-down-bold" <v-list-item title="Withdraw" key="withdraw" value="withdraw" prepend-icon="mdi-arrow-down-bold"
@click="()=>onWithdraw()"/> @click="onWithdraw"/>
</v-list> </v-list>
</v-menu> </v-menu>
</td> </td>

View File

@@ -33,7 +33,7 @@ import {FixedNumber} from "ethers";
const s = useStore() const s = useStore()
const props = defineProps(['modelValue', 'vault', 'maxAmount']) const props = defineProps(['modelValue', 'vault', 'maxAmount'])
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const balanceFloat = computed(() => Number(props.maxAmount)/1e18) const balanceFloat = computed(() => Number(props.maxAmount)/1e18) // todo configurable native decimals
const floatAmount = ref(0) const floatAmount = ref(0)
function wrapNative() { function wrapNative() {

View File

@@ -23,7 +23,7 @@
<div v-if="status===Status.NEEDS_NETWORK"> <div v-if="status===Status.NEEDS_NETWORK">
<v-card-text> <v-card-text>
Please connect your wallet to the Arbitrum-Sepolia test network to continue. Please connect your wallet to the Arbitrum One network to continue.
</v-card-text> </v-card-text>
</div> </div>
@@ -39,7 +39,7 @@
<script setup> <script setup>
import {useStore} from "@/store/store"; import {useStore} from "@/store/store";
import {computed, ref} from "vue"; import {computed, ref} from "vue";
import {connectWallet, switchChain} from "@/blockchain/wallet.js"; import {addNetwork, connectWallet, switchChain} from "@/blockchain/wallet.js";
import Btn from "@/components/Btn.vue"; import Btn from "@/components/Btn.vue";
import Logo from "@/components/Logo.vue"; import Logo from "@/components/Logo.vue";
import BetaSignin from "@/components/BetaSignin.vue"; import BetaSignin from "@/components/BetaSignin.vue";
@@ -75,6 +75,14 @@ async function connect() {
// explicit user rejection // explicit user rejection
return return
} }
else if (e.code===4902) {
try {
await addNetwork(s.chainId)
}
catch (e) {
console.log(`Could not add network ${s.chainId}`)
}
}
else else
console.log('switchChain() failure',e) console.log('switchChain() failure',e)
} }

View File

@@ -133,7 +133,7 @@ body {
} }
.top { .top {
height: 68%; height: 60%;
width: 100%; width: 100%;
min-height: 5em; min-height: 5em;
} }

View File

@@ -11,12 +11,6 @@
</v-card-text> </v-card-text>
</div> </div>
<div v-if="hasVault"> <div v-if="hasVault">
<!--
<v-card-title>
Your Deposit Address {{ s.vaults.length > 1 ? '#' + (num + 1) : '' }}
</v-card-title> &lt;!&ndash; todo vault nicknames &ndash;&gt;
-->
<v-card-subtitle class="overflow-x-hidden"> <v-card-subtitle class="overflow-x-hidden">
<copy-button :text="addr">Deposit {{addr}}</copy-button> <copy-button :text="addr">Deposit {{addr}}</copy-button>
</v-card-subtitle> </v-card-subtitle>
@@ -30,12 +24,12 @@
everything looks good. everything looks good.
</p> </p>
--> -->
<p v-if="!s.mockenv">There are no funds currently in your vault. <p v-if="!s.mockenv">
<!-- todo re-enable deposit UI There are no funds currently in your vault. Send tokens to the address above to fund your trading vault.
Send tokens to the address above to fund your vault. --> </p>
<p v-if="s.mockenv">
There are no funds currently in your vault. Use the faucet below to mint some testnet coins.
</p> </p>
<p v-if="s.mockenv">There are no funds currently in your vault. Use the faucet below to mint some testnet coins
into your vault.</p>
</v-card-text> </v-card-text>
<v-card-item v-if="!empty"> <v-card-item v-if="!empty">
<v-table> <v-table>

View File

@@ -2,7 +2,7 @@
<toolbar-pane title="Assets" icon="mdi-currency-btc"> <toolbar-pane title="Assets" icon="mdi-currency-btc">
<needs-signer> <needs-signer>
<vault :owner="s.account" :num="0"/> <vault :owner="s.account" :num="0"/>
<faucet v-if="s.chainId in [1337, 31337, 421614]" variant="outlined" text="Get Free Testnet Coins!" style="width: 15em"/> <faucet v-if="[1337, 31337, 421614].includes(s.chainId)" variant="outlined" text="Get Free Testnet Coins!" style="width: 15em"/>
</needs-signer> </needs-signer>
</toolbar-pane> </toolbar-pane>
</template> </template>

View File

@@ -180,8 +180,10 @@ const endpoints = computed({
} }
}) })
const alignTimes = ref(true)
const time1A = computed({ const time1A = computed({
get() { return _endpoints.value[0] === null ? 0 : _endpoints.value[0][0] }, get() { return _endpoints.value[0] === null ? null : _endpoints.value[0][0] },
set(v) { set(v) {
const flatline0 = _endpoints.value[0]; const flatline0 = _endpoints.value[0];
update( update(
@@ -203,7 +205,7 @@ const price1A = computed({
}) })
const time1B = computed({ const time1B = computed({
get() { return _endpoints.value[0] === null ? 0 : _endpoints.value[0][2] }, get() { return _endpoints.value[0] === null ? null : _endpoints.value[0][2] },
set(v) { set(v) {
const flatline0 = _endpoints.value[0]; const flatline0 = _endpoints.value[0];
update( update(
@@ -225,7 +227,7 @@ const price1B = computed({
}) })
const time2A = computed({ const time2A = computed({
get() { return _endpoints.value[1] === null ? 0 : _endpoints.value[1][0] }, get() { return _endpoints.value[1] === null ? null : _endpoints.value[1][0] },
set(v) { set(v) {
const flatline = _endpoints.value[1]; const flatline = _endpoints.value[1];
update( update(
@@ -247,7 +249,7 @@ const price2A = computed({
}) })
const time2B = computed({ const time2B = computed({
get() { return _endpoints.value[1] === null ? 0 : _endpoints.value[1][2] }, get() { return _endpoints.value[1] === null ? null : _endpoints.value[1][2] },
set(v) { set(v) {
const flatline = _endpoints.value[1]; const flatline = _endpoints.value[1];
update( update(
@@ -288,7 +290,7 @@ function setShapes(a,b) {
} }
const _extendLeft = ref(false) const _extendLeft = ref(true)
const extendLeft = computed({ const extendLeft = computed({
get() {return _extendLeft.value}, get() {return _extendLeft.value},
set(v) { set(v) {
@@ -304,7 +306,7 @@ const extendLeft = computed({
}) })
const _extendRight = ref(false) const _extendRight = ref(true)
const extendRight = computed({ const extendRight = computed({
get() {return _extendRight.value}, get() {return _extendRight.value},
set(v) { set(v) {

View File

@@ -7,7 +7,7 @@
<v-text-field type="number" v-model="rungs" <v-text-field type="number" v-model="rungs"
density="compact" hide-details class="mx-1 my-2" variant="outlined" density="compact" hide-details class="mx-1 my-2" variant="outlined"
label="Rungs" label="Rungs"
:color="color" :base-color="color" min="1" :color="color" :base-color="color" min="1" :max="MAX_RUNGS"
:disabled="rungsDisabled" :disabled="rungsDisabled"
style="width: 4.5em;" style="width: 4.5em;"
/> />
@@ -92,6 +92,7 @@ function setEndpoints(a, b) {
endpoints.value = [devectorize(a), devectorize(b)] endpoints.value = [devectorize(a), devectorize(b)]
} }
const MAX_RUNGS = 10 // todo remove arbitrary limit
const rungs = computed({ const rungs = computed({
get() { get() {
@@ -102,6 +103,8 @@ const rungs = computed({
props.builder.rungs = 1 props.builder.rungs = 1
return return
} }
if (r>MAX_RUNGS)
r = MAX_RUNGS
let [a,b] = endpoints.value let [a,b] = endpoints.value
a = vectorize(a) a = vectorize(a)
b = vectorize(b) b = vectorize(b)

View File

@@ -3,6 +3,7 @@
<phone-card class="maxw"> <phone-card class="maxw">
<vault :owner="s.account" :num="0"/> <vault :owner="s.account" :num="0"/>
</phone-card> </phone-card>
<div>Vault? "{{s.mockenv}}" "{{s.vault}}"</div>
<phone-card v-if="s.mockenv && s.vault" class="maxw"> <phone-card v-if="s.mockenv && s.vault" class="maxw">
<faucet class="mt-3"/> <faucet class="mt-3"/>
</phone-card> </phone-card>