From 954c9f57b861663d6974bf1cca8c75957f36769a Mon Sep 17 00:00:00 2001 From: samlior Date: Mon, 20 May 2024 17:38:09 +0800 Subject: [PATCH] Fix bugs --- src/amm/amm.requests.ts | 2 + .../synfutures/synfutures.controllers.ts | 4 +- src/connectors/synfutures/synfutures.ts | 28 +- src/services/common-interfaces.ts | 3 +- src/templates/lists/blast_tokens_mainnet.json | 314 +++++++++--------- 5 files changed, 186 insertions(+), 165 deletions(-) diff --git a/src/amm/amm.requests.ts b/src/amm/amm.requests.ts index 962462877f..eb954c95d1 100644 --- a/src/amm/amm.requests.ts +++ b/src/amm/amm.requests.ts @@ -230,6 +230,8 @@ export interface PerpPositionResponse extends PerpPosition { latency: number; base: string; quote: string; + balance?: string; + liquidationPrice?: string; } export interface PerpAvailablePairsResponse { diff --git a/src/connectors/synfutures/synfutures.controllers.ts b/src/connectors/synfutures/synfutures.controllers.ts index 6c4c28f9d5..facb395ca3 100644 --- a/src/connectors/synfutures/synfutures.controllers.ts +++ b/src/connectors/synfutures/synfutures.controllers.ts @@ -32,7 +32,7 @@ import { PerpBalanceResponse, PerpBalanceRequest, } from '../../amm/amm.requests'; -import { PerpPosition } from '../perp/perp'; +import { SynFuturesPosition } from './synfutures'; async function getWallet(ethereumish: Ethereumish, address: string) { let wallet: Wallet; @@ -127,7 +127,7 @@ export async function getPosition( latency: latency(startTimestamp, Date.now()), base: req.base, quote: req.quote, - ...(position as PerpPosition), + ...(position as SynFuturesPosition), }; } diff --git a/src/connectors/synfutures/synfutures.ts b/src/connectors/synfutures/synfutures.ts index ecbeab90ae..8032bd19f7 100644 --- a/src/connectors/synfutures/synfutures.ts +++ b/src/connectors/synfutures/synfutures.ts @@ -13,6 +13,7 @@ import { encodeTradeParam, NULL_DDL, PairModel, + wdiv, } from '@synfutures/oyster-sdk'; import { Token } from '@uniswap/sdk'; import { Transaction, Wallet, ethers } from 'ethers'; @@ -29,13 +30,18 @@ function toTickerSymbol(symbol: string) { throw new Error('invalid symbol: ' + symbol); } - return symbol.substring(0, index - 1); + return symbol.substring(0, index); } function formatSlippage(slippage: number) { return Math.floor(slippage * 10000); } +export interface SynFuturesPosition extends PerpPosition { + balance: string; + liquidationPrice: string; +} + export class SynFutures implements SynFuturesish { private static _instances: { [name: string]: SynFutures }; private ethereum: Ethereum; @@ -202,7 +208,7 @@ export class SynFutures implements SynFuturesish { async isMarketActive(tickerSymbol: string): Promise { const pair = this.pairs[tickerSymbol]; - return ( + return !!( pair && pair.rootInstrument.state.condition === InstrumentCondition.NORMAL && (pair.amm.status === AMMStatus.TRADING || @@ -219,7 +225,7 @@ export class SynFutures implements SynFuturesish { async getPositions( address: string, tickerSymbol: string, - ): Promise { + ): Promise { const pair = this.pairs[tickerSymbol]; if (!pair) { @@ -237,11 +243,15 @@ export class SynFutures implements SynFuturesish { return { positionAmt: position.size.abs().toString(), positionSide: position.size.gt(0) ? 'LONG' : 'SHORT', - unrealizedProfit: position.unrealizedPnl.toString(), + unrealizedProfit: position.unrealizedPnl + .sub(position.unrealizedFundingFee) + .toString(), leverage: ethers.utils.formatUnits(position.leverageWad), - entryPrice: position.entryNotional.div(position.size.abs()).toString(), + entryPrice: wdiv(position.entryNotional, position.size.abs()).toString(), tickerSymbol, pendingFundingPayment: position.unrealizedFundingFee.toString(), + balance: position.balance.toString(), + liquidationPrice: position.liquidationPrice.toString(), }; } @@ -275,6 +285,10 @@ export class SynFutures implements SynFuturesish { const slippage = formatSlippage(this.getAllowedSlippage(allowedSlippage)); + await this.synfutures.syncVaultCache(wallet.address, [ + pair.rootInstrument.info.quote.address, + ]); + const account = await this.synfutures.updatePairLevelAccount( wallet.address, pair.rootInstrument.info.addr, @@ -338,6 +352,10 @@ export class SynFutures implements SynFuturesish { throw new Error('invalid ticker symbol: ' + tickerSymbol); } + await this.synfutures.syncVaultCache(wallet.address, [ + pair.rootInstrument.info.quote.address, + ]); + const account = await this.synfutures.updatePairLevelAccount( wallet.address, pair.rootInstrument.info.addr, diff --git a/src/services/common-interfaces.ts b/src/services/common-interfaces.ts index bb360ce6e9..8aae3eb752 100644 --- a/src/services/common-interfaces.ts +++ b/src/services/common-interfaces.ts @@ -95,6 +95,7 @@ import { Fraction as XsswapFraction, } from 'xsswap-sdk'; import { PerpPosition } from '../connectors/perp/perp'; +import { SynFuturesPosition } from "../connectors/synfutures/synfutures"; import { XdcBase } from '../chains/xdc/xdc.base'; import { NearBase } from '../chains/near/near.base'; import { TezosBase } from '../chains/tezos/tezos.base'; @@ -704,7 +705,7 @@ export interface SynFuturesish { getPositions( address: string, tickerSymbol: string, - ): Promise; + ): Promise; /** * Attempts to return balance of a connected acct diff --git a/src/templates/lists/blast_tokens_mainnet.json b/src/templates/lists/blast_tokens_mainnet.json index b530ee02cb..0100eccdb5 100644 --- a/src/templates/lists/blast_tokens_mainnet.json +++ b/src/templates/lists/blast_tokens_mainnet.json @@ -4,386 +4,386 @@ { "chainId": 81457, "address": "0x129ed667bf8c065fe5f66c9b44b7cb0126d85cc3", - "name": "AI Waifu", - "symbol": "$wai", + "name": "AIWAIFU", + "symbol": "$WAI", "decimals": 18 }, { "chainId": 81457, - "address": "0x0f8881fc1fca1f5151fa4205d55922ffa15e707a", - "name": "Blast Disperse", - "symbol": "disp", + "address": "0x049e6a52e2c9b7814c8178908f3630726c134c92", + "name": "Ankr Staked ETH", + "symbol": "ankrETH", "decimals": 18 }, { "chainId": 81457, - "address": "0x95b9b27f2eba05433b4a64257f0342285d89a479", - "name": "Avolend", - "symbol": "avo", + "address": "0x60701c37cd9fed322dde7c17dc1e356f09a35b88", + "name": "BlastDEX", + "symbol": "BD", "decimals": 18 }, { "chainId": 81457, "address": "0xb9dfcd4cf589bb8090569cb52fac1b88dbe4981f", "name": "Bag", - "symbol": "bag", + "symbol": "BAG", "decimals": 18 }, { "chainId": 81457, - "address": "0x60701c37cd9fed322dde7c17dc1e356f09a35b88", - "name": "BlastDEX", - "symbol": "bd", - "decimals": 18 - }, - { - "chainId": 81457, - "address": "0x764933fbad8f5d04ccd088602096655c2ed9879f", - "name": "Any Inu", - "symbol": "ai", + "address": "0x95b9b27f2eba05433b4a64257f0342285d89a479", + "name": "AVO", + "symbol": "AVO", "decimals": 18 }, { "chainId": 81457, - "address": "0xd1fedd031b92f50a50c05e2c45af1adb4cea82f4", - "name": "BladeSwap", - "symbol": "blade", + "address": "0x3580ac35bed2981d6bdd671a5982c2467d301241", + "name": "Ankr Network", + "symbol": "ANKR", "decimals": 18 }, { "chainId": 81457, - "address": "0x9bd75c164daf830733ac2ea71a0258f95aac7c57", - "name": "BlastCat", - "symbol": "bcat", - "decimals": 18 + "address": "0x34050224f9ea1859790b7cbbbe2264f1204771a6", + "name": "Blast Inu", + "symbol": "BINU", + "decimals": 9 }, { "chainId": 81457, "address": "0x336d814f94581bd70898da35feb266163bfc8199", - "name": "Blastnet", - "symbol": "bnet", + "name": "BlastNET", + "symbol": "BNET", "decimals": 18 }, { "chainId": 81457, - "address": "0xd55edfc79c0d14084260d16f38bda75e28abfb6a", - "name": "BlastOff", - "symbol": "off", + "address": "0xd1fedd031b92f50a50c05e2c45af1adb4cea82f4", + "name": "Blade", + "symbol": "BLADE", "decimals": 18 }, { "chainId": 81457, - "address": "0xb582dc28968c725d2868130752afa0c13ebf9b1a", - "name": "Blast Pepe", - "symbol": "bepe", + "address": "0xd55edfc79c0d14084260d16f38bda75e28abfb6a", + "name": "OFF", + "symbol": "OFF", "decimals": 18 }, { "chainId": 81457, "address": "0x33c62f70b14c438075be70defb77626b1ac3b503", - "name": "BlastUP", - "symbol": "blp", + "name": "BlastUP Token", + "symbol": "BLP", "decimals": 18 }, { "chainId": 81457, - "address": "0xc96a98c8c95a0f64a60d9925220d54d28bfe2441", - "name": "ByteonBlast", - "symbol": "byte", + "address": "0x9bd75c164daf830733ac2ea71a0258f95aac7c57", + "name": "BlastCat", + "symbol": "BCat", "decimals": 18 }, { "chainId": 81457, "address": "0x233b23de890a8c21f6198d03425a2b986ae05536", "name": "Core Markets", - "symbol": "core", + "symbol": "CORE", "decimals": 18 }, { "chainId": 81457, - "address": "0xd43d8adac6a4c7d9aeece7c3151fca8f23752cf8", - "name": "AndyBlast", - "symbol": "andy", - "decimals": 9 - }, - { - "chainId": 81457, - "address": "0x3580ac35bed2981d6bdd671a5982c2467d301241", - "name": "Ankr Network", - "symbol": "ankr", + "address": "0x963eec23618bbc8e1766661d5f263f18094ae4d5", + "name": "Cybro Token", + "symbol": "CYBRO", "decimals": 18 }, { "chainId": 81457, - "address": "0x049e6a52e2c9b7814c8178908f3630726c134c92", - "name": "Ankr Staked ETH", - "symbol": "ankreth", + "address": "0xc96a98c8c95a0f64a60d9925220d54d28bfe2441", + "name": "ByteonBlast", + "symbol": "BYTE", "decimals": 18 }, { "chainId": 81457, - "address": "0x34050224f9ea1859790b7cbbbe2264f1204771a6", - "name": "Blast Inu", - "symbol": "binu", - "decimals": 9 + "address": "0x47c337bd5b9344a6f3d6f58c474d9d8cd419d8ca", + "name": "Dackie Token", + "symbol": "DACKIE", + "decimals": 18 }, { "chainId": 81457, "address": "0x67fa2887914fa3729e9eed7630294fe124f417a0", - "name": "Crypto Valleys YIELD Token", - "symbol": "yield", + "name": "Yield Token", + "symbol": "YIELD", "decimals": 18 }, { "chainId": 81457, - "address": "0x47c337bd5b9344a6f3d6f58c474d9d8cd419d8ca", - "name": "DackieSwap", - "symbol": "dackie", + "address": "0x1ba52a63adf7e9425ddd85b378dda25e3818e596", + "name": "DUCKIE", + "symbol": "DUCKIE", "decimals": 18 }, { "chainId": 81457, - "address": "0x1ba52a63adf7e9425ddd85b378dda25e3818e596", - "name": "Duckie The Meme Token", - "symbol": "$duckie", + "address": "0x491e6de43b55c8eae702edc263e32339da42f58c", + "name": "eesee", + "symbol": "ESE", "decimals": 18 }, { "chainId": 81457, - "address": "0x7135b32e9903bdb4e19a8b1d22fc2038964b8451", - "name": "EarlyFans", - "symbol": "early", - "decimals": 18 + "address": "0x9fe9991daf6b9a5d79280f48cbb6827d46de2ea4", + "name": "HyperBlast", + "symbol": "HYPE", + "decimals": 9 }, { "chainId": 81457, - "address": "0x818a92bc81aad0053d72ba753fb5bc3d0c5c0923", - "name": "Juice Finance", - "symbol": "juice", + "address": "0x5a7a183b6b44dc4ec2e3d2ef43f98c5152b1d76d", + "name": "InceptionLRT restaked ETH", + "symbol": "inETH", "decimals": 18 }, { "chainId": 81457, - "address": "0x76da31d7c9cbeae102aff34d3398bc450c8374c1", - "name": "Magic Internet Money (Blast)", - "symbol": "mim", + "address": "0x0f8881fc1fca1f5151fa4205d55922ffa15e707a", + "name": "Blast Disperse", + "symbol": "DISP", "decimals": 18 }, { "chainId": 81457, - "address": "0x491e6de43b55c8eae702edc263e32339da42f58c", - "name": "Eesee", - "symbol": "ese", + "address": "0xb582dc28968c725d2868130752afa0c13ebf9b1a", + "name": "Blast Pepe", + "symbol": "BEPE", "decimals": 18 }, { "chainId": 81457, - "address": "0x15d24de366f69b835be19f7cf9447e770315dd80", - "name": "KAP Games", - "symbol": "kap", + "address": "0x818a92bc81aad0053d72ba753fb5bc3d0c5c0923", + "name": "Juice", + "symbol": "JUICE", "decimals": 18 }, { "chainId": 81457, - "address": "0xdb13df2ea134e7df2208d74b96db063837db5b5c", - "name": "LAMB by OPNX", - "symbol": "lamb", + "address": "0x15d24de366f69b835be19f7cf9447e770315dd80", + "name": "KAP Games", + "symbol": "KAP", "decimals": 18 }, { "chainId": 81457, - "address": "0x963eec23618bbc8e1766661d5f263f18094ae4d5", - "name": "CYBRO", - "symbol": "cybro", + "address": "0x76da31d7c9cbeae102aff34d3398bc450c8374c1", + "name": "Magic Internet Money", + "symbol": "MIM", "decimals": 18 }, { "chainId": 81457, "address": "0x9a50953716ba58e3d6719ea5c437452ac578705f", - "name": "MetaStreet V2 mwstETH-WPUNKS:20", - "symbol": "punketh-20", + "name": "MetaStreet V2 Deposit: WPUNKS-wstETH:20", + "symbol": "mwstETH-WPUNKS:20", "decimals": 18 }, { "chainId": 81457, - "address": "0xa4c7aa67189ec5623121c6c94ec757dfed932d4b", - "name": "Mia", - "symbol": "mia", + "address": "0xdb13df2ea134e7df2208d74b96db063837db5b5c", + "name": "LAMB by OPNX", + "symbol": "LAMB", "decimals": 18 }, { "chainId": 81457, "address": "0x837fe561e9c5dfa73f607fda679295dbc2be5e40", - "name": "MonoSwap USD", - "symbol": "musd", + "name": "Monoswap USD", + "symbol": "MUSD", "decimals": 18 }, - { - "chainId": 81457, - "address": "0x9fe9991daf6b9a5d79280f48cbb6827d46de2ea4", - "name": "HyperBlast", - "symbol": "hype", - "decimals": 9 - }, { "chainId": 81457, "address": "0x75483179a38d21f3608e71bbede5ec1314f0067d", "name": "NeptuneX", - "symbol": "nptx", + "symbol": "NPTX", "decimals": 18 }, { "chainId": 81457, "address": "0x000000daa580e54635a043d2773f2c698593836a", - "name": "Oh no", - "symbol": "ohno", + "name": "Oh No", + "symbol": "OHNO", "decimals": 18 }, { "chainId": 81457, - "address": "0x9e20461bc2c4c980f62f1b279d71734207a6a356", - "name": "OmniCat", - "symbol": "omni", + "address": "0x7135b32e9903bdb4e19a8b1d22fc2038964b8451", + "name": "EARLY Token", + "symbol": "EARLY", "decimals": 18 }, { "chainId": 81457, - "address": "0x42e12d42b3d6c4a74a88a61063856756ea2db357", - "name": "Orbit Protocol", - "symbol": "orbit", + "address": "0x9e20461bc2c4c980f62f1b279d71734207a6a356", + "name": "OmniCat", + "symbol": "OMNI", "decimals": 18 }, { "chainId": 81457, "address": "0x7217124c626f0b7077be91df939195c9a8184ecc", "name": "Finger Blast", - "symbol": "finger", + "symbol": "FINGER", + "decimals": 18 + }, + { + "chainId": 81457, + "address": "0x216a5a1135a9dab49fa9ad865e0f22fe22b5630a", + "name": "Pump", + "symbol": "PUMP", "decimals": 18 }, { "chainId": 81457, "address": "0xba0dda8762c24da9487f5fa026a9b64b695a07ea", "name": "OX Coin", - "symbol": "ox", + "symbol": "OX", "decimals": 18 }, { "chainId": 81457, - "address": "0x5ffd9ebd27f2fcab044c0f0a26a45cb62fa29c06", - "name": "PacMoon", - "symbol": "pac", + "address": "0x236bb48fcf61ce996b2c8c196a9258c176100c7d", + "name": "RabbitX", + "symbol": "RBX", + "decimals": 18 + }, + { + "chainId": 81457, + "address": "0xd582879453337bd149ae53ec2092b0af5281d1d7", + "name": "GLORY", + "symbol": "GLORY", "decimals": 18 }, { "chainId": 81457, "address": "0x2416092f143378750bb29b79ed961ab195cceea5", "name": "Renzo Restaked ETH", - "symbol": "ezeth", + "symbol": "ezETH", "decimals": 18 }, { "chainId": 81457, - "address": "0x4fee793d435c6d2c10c135983bb9d6d4fc7b9bbd", - "name": "Overnight.fi USD+", - "symbol": "usd+", + "address": "0x5ffd9ebd27f2fcab044c0f0a26a45cb62fa29c06", + "name": "PacMoon", + "symbol": "PAC", "decimals": 18 }, { "chainId": 81457, - "address": "0xe070b87c4d88826d4cd1b85babe186fdb14cd321", - "name": "Cyberblast Token", - "symbol": "cbr", + "address": "0xd07379a755a8f11b57610154861d694b2a0f615a", + "name": "SwapBlast Finance Token", + "symbol": "SBF", "decimals": 18 }, { "chainId": 81457, - "address": "0x4300000000000000000000000000000000000003", - "name": "USDB", - "symbol": "usdb", + "address": "0x87e154e86fb691ab8a27116e93ed8d54e2b8c18c", + "name": "Titan Trading Token", + "symbol": "TES", "decimals": 18 }, { "chainId": 81457, "address": "0x870a8f46b62b8bdeda4c02530c1750cddf2ed32e", - "name": "Overnight.fi USDC+", - "symbol": "usdc+", + "name": "USDC+", + "symbol": "USDC+", "decimals": 18 }, { "chainId": 81457, - "address": "0x87e154e86fb691ab8a27116e93ed8d54e2b8c18c", - "name": "Titan Trading Token", - "symbol": "tes", + "address": "0x4fee793d435c6d2c10c135983bb9d6d4fc7b9bbd", + "name": "USD+", + "symbol": "USD+", "decimals": 18 }, { "chainId": 81457, - "address": "0x4300000000000000000000000000000000000004", - "name": "WETH", - "symbol": "weth", + "address": "0x42e12d42b3d6c4a74a88a61063856756ea2db357", + "name": "Orbit Protocol", + "symbol": "ORBIT", "decimals": 18 }, { "chainId": 81457, - "address": "0xd07379a755a8f11b57610154861d694b2a0f615a", - "name": "SwapBlast Finance Token", - "symbol": "sbf", + "address": "0x4300000000000000000000000000000000000004", + "name": "Wrapped Ether", + "symbol": "WETH", "decimals": 18 }, { "chainId": 81457, "address": "0x9b0ae1c1fbe7006697356030d45ab3e17cbcf70f", "name": "XDX", - "symbol": "xdx", + "symbol": "XDX", + "decimals": 18 + }, + { + "chainId": 81457, + "address": "0x764933fbad8f5d04ccd088602096655c2ed9879f", + "name": "Any Inu (non-ITS)", + "symbol": "AI", "decimals": 18 }, { "chainId": 81457, "address": "0x20fe91f17ec9080e3cac2d688b4ecb48c5ac3a9c", - "name": "YES Money", - "symbol": "yes", + "name": "YES", + "symbol": "YES", "decimals": 18 }, { "chainId": 81457, "address": "0x68449870eea84453044bd430822827e21fd8f101", - "name": "Zaibot", - "symbol": "zai", + "name": "ZAIBOT.io", + "symbol": "ZAI", "decimals": 18 }, { "chainId": 81457, - "address": "0x236bb48fcf61ce996b2c8c196a9258c176100c7d", - "name": "RabbitX", - "symbol": "rbx", + "address": "0xa4c7aa67189ec5623121c6c94ec757dfed932d4b", + "name": "Mia", + "symbol": "MIA", "decimals": 18 }, { "chainId": 81457, - "address": "0x216a5a1135a9dab49fa9ad865e0f22fe22b5630a", - "name": "Pump", - "symbol": "pump", + "address": "0xfd4d19f9fbb9f730c3c88a21755832bd2455144e", + "name": "SSS", + "symbol": "SSS", "decimals": 18 }, { "chainId": 81457, - "address": "0xd582879453337bd149ae53ec2092b0af5281d1d7", - "name": "Sekai Glory", - "symbol": "glory", + "address": "0x4300000000000000000000000000000000000003", + "name": "USDB", + "symbol": "USDB", "decimals": 18 }, { "chainId": 81457, - "address": "0xfd4d19f9fbb9f730c3c88a21755832bd2455144e", - "name": "Super Sushi Samurai", - "symbol": "sss", - "decimals": 18 + "address": "0xd43d8adac6a4c7d9aeece7c3151fca8f23752cf8", + "name": "Andy", + "symbol": "ANDY", + "decimals": 9 }, { "chainId": 81457, - "address": "0x5a7a183b6b44dc4ec2e3d2ef43f98c5152b1d76d", - "name": "Inception Restaked ETH", - "symbol": "ineth", + "address": "0xe070b87c4d88826d4cd1b85babe186fdb14cd321", + "name": "Cyberblast Token", + "symbol": "CBR", "decimals": 18 } ]