From cd1847999faab0ea6941d81107dab6b611dd470d Mon Sep 17 00:00:00 2001 From: naturexie <786281870@qq.com> Date: Tue, 18 Feb 2025 21:35:46 +0800 Subject: [PATCH] feat: reserve nbtc gas logic --- api/get-balance.ts | 8 +++++++- utils/config.ts | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api/get-balance.ts b/api/get-balance.ts index e82ba576..d5312931 100644 --- a/api/get-balance.ts +++ b/api/get-balance.ts @@ -9,7 +9,7 @@ import { ViewMethodsREFV1, IShadowRecordInfo, } from "../interfaces"; -import { lpTokenPrefix } from "../utils/config"; +import { lpTokenPrefix, NBTCTokenId } from "../utils/config"; export const getTokenContract = async (tokenContractAddress: string): Promise => { const { account } = await getBurrow(); @@ -47,6 +47,12 @@ const getBalance = async ( account_id: accountId, }, )) as string; + if ( + tokenId === NBTCTokenId && + window.selector?.store?.getState()?.selectedWalletId === "btc-wallet" + ) { + return Decimal.max(new Decimal(balanceInYocto || 0).minus(1000), "0").toFixed(); + } } return balanceInYocto; } catch (err: any) { diff --git a/utils/config.ts b/utils/config.ts index 674fd8aa..f46e608e 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -34,7 +34,10 @@ export const BRRR_LABS_TOKEN = { testnet: "brrr.ft.ref-labs.testnet", mainnet: "brrr.ft.ref-labs.testnet", }; - +export const NBTCTokenId = { + testnet: "nbtc-dev.testnet", + mainnet: "nbtc.bridge.near", +}[defaultNetwork]; export const WALLET_CONNECT_ID = process.env.NEXT_PUBLIC_WALLET_CONNECT_ID || ("87e549918631f833447b56c15354e450" as string);