symbol rework; fee % switching; symbol search improvements

This commit is contained in:
tim
2024-10-11 00:26:29 -04:00
parent 6d19adb130
commit 5b23864c2e
11 changed files with 233 additions and 178 deletions

View File

@@ -26,6 +26,7 @@ export async function getToken(chainId, addr) {
chainId = s.chainId
}
let found = metadataMap[chainId][addr]
// console.log('token from metadataMap', found)
if (found)
return found
if (!(addr in s.tokens))
@@ -37,6 +38,7 @@ export async function getToken(chainId, addr) {
const _inFlightLookups = {}
export async function addExtraToken(chainId, addr) {
// console.log('addExtraToken', chainId, addr)
if (addr===undefined) { // todo remove check
console.warn('addExtraToken(addr) is deprecated. use addExtraToken(chainId,addr)')
addr = chainId
@@ -51,7 +53,7 @@ export async function addExtraToken(chainId, addr) {
const prom = new Promise((resolve) => {
const s = useStore()
console.log('querying token', addr)
socket.emit('lookupToken', chainId, addr, (info) => {
socket.emit('lookupToken', chainId, addr, async (info) => {
console.log('server token info', addr, info)
if (info !== null) {
s.addToken(chainId, info)
@@ -63,7 +65,7 @@ export async function addExtraToken(chainId, addr) {
resolve(null)
}
else {
const token = newContract(addr, 'IERC20Metadata', provider)
const token = await newContract(addr, 'IERC20Metadata', provider)
Promise.all( [token.name(), token.symbol(), token.decimals()] ).then((name,symbol,decimals)=>{
info = {
a: addr,

View File

@@ -303,7 +303,7 @@ export async function pendOrder(order, fee=null) {
id: uuid(),
chainId: s.chainId,
placementTime: Date.now()/1000,
fee: fee,
fee: fee, // dexorder place and gas fee total
vault: s.vaults.length ? s.vaults[0] : null,
state: PendingOrderState.Submitted,
order