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) {
const s = useStore()
console.log('discoverVaults', owner)
@@ -522,7 +512,67 @@ function upgradeError(e) {
console.error('error while upgrading vault', e)
}
export async function upgradeVault(vault, impl) {
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)
co.selectedSymbol = null
else {
updateFeeDropdown()
const info = lookupSymbol(symbol.ticker)
symbolChangedCbs.forEach((cb) => cb(info))
co.selectedSymbol = info
}
updateFeeDropdown()
}
@@ -109,7 +109,10 @@ export function updateFeeDropdown() {
const [_addr, fee] = p
return {
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)
}
const MEAN_RANGE_MULTIPLIER = 10
const MEAN_RANGE_MULTIPLIER = 3
function chartMeanRange() {
let range = 0

View File

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

View File

@@ -23,7 +23,7 @@
<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="Withdraw" key="withdraw" value="withdraw" prepend-icon="mdi-arrow-down-bold"
@click="()=>onWithdraw()"/>
@click="onWithdraw"/>
</v-list>
</v-menu>
</td>

View File

@@ -33,7 +33,7 @@ import {FixedNumber} from "ethers";
const s = useStore()
const props = defineProps(['modelValue', 'vault', 'maxAmount'])
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)
function wrapNative() {

View File

@@ -23,7 +23,7 @@
<div v-if="status===Status.NEEDS_NETWORK">
<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>
</div>
@@ -39,7 +39,7 @@
<script setup>
import {useStore} from "@/store/store";
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 Logo from "@/components/Logo.vue";
import BetaSignin from "@/components/BetaSignin.vue";
@@ -75,6 +75,14 @@ async function connect() {
// explicit user rejection
return
}
else if (e.code===4902) {
try {
await addNetwork(s.chainId)
}
catch (e) {
console.log(`Could not add network ${s.chainId}`)
}
}
else
console.log('switchChain() failure',e)
}

View File

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

View File

@@ -11,12 +11,6 @@
</v-card-text>
</div>
<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">
<copy-button :text="addr">Deposit {{addr}}</copy-button>
</v-card-subtitle>
@@ -30,12 +24,12 @@
everything looks good.
</p>
-->
<p v-if="!s.mockenv">There are no funds currently in your vault.
<!-- todo re-enable deposit UI
Send tokens to the address above to fund your vault. -->
<p v-if="!s.mockenv">
There are no funds currently in your vault. Send tokens to the address above to fund your trading 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 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-item v-if="!empty">
<v-table>

View File

@@ -2,7 +2,7 @@
<toolbar-pane title="Assets" icon="mdi-currency-btc">
<needs-signer>
<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>
</toolbar-pane>
</template>

View File

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

View File

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

View File

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