Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contract address #541

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/apps/src/bridges/lnbridge-opposite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class LnBridgeOpposite extends LnBridgeBase {
private initContract() {
if (this.sourceChain?.id === ChainID.ARBITRUM && this.targetChain?.id === ChainID.ETHEREUM) {
this.contract = {
sourceAddress: "0x9e523234D36973f9e38642886197D023C88e307e",
targetAddress: "0x9469D013805bFfB7D3DEBe5E7839237e535ec483",
sourceAddress: "0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23",
targetAddress: "0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23",
};
} else {
this.contract = {
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/src/components/faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function Faucet() {
return (
<>
<button
className="text-white/50 transition-colors hover:text-white disabled:cursor-not-allowed disabled:text-white/50"
className="text-primary transition-[color,transform] hover:text-white lg:active:translate-y-1"
onClick={() => setIsOpen(true)}
>
<span className="text-sm font-normal">Faucet</span>
Expand Down
5 changes: 3 additions & 2 deletions packages/apps/src/components/fee-rate-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Input from "@/ui/input";
import { parseFeeRate } from "@/utils/misc";

export default function FeeRateInput({
placeholder,
Expand All @@ -9,7 +10,7 @@ export default function FeeRateInput({
value?: { formatted: number; value: string };
onChange?: (value: { formatted: number; value: string }) => void;
}) {
const invalid = (value?.formatted || 0) < 0 || 100 < (value?.formatted || 0);
const invalid = (value?.formatted || 0) < 0 || 100000 < (value?.formatted || 0);
return (
<div
className={`gap-small bg-app-bg p-small lg:p-middle normal-input-wrap flex items-center justify-between ${
Expand All @@ -22,7 +23,7 @@ export default function FeeRateInput({
onChange={(e) => {
if (e.target.value) {
if (!Number.isNaN(Number(e.target.value))) {
onChange({ value: e.target.value, formatted: Number(e.target.value) });
onChange({ value: e.target.value, formatted: parseFeeRate(e.target.value) });
}
} else {
onChange({ value: e.target.value, formatted: 0 });
Expand Down
6 changes: 5 additions & 1 deletion packages/apps/src/components/relayer-manage-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useNetwork, useSwitchNetwork } from "wagmi";
import { formatBalance } from "@/utils/balance";
import { useRelayer } from "@/hooks/use-relayer";
import dynamic from "next/dynamic";
import { formatFeeRate } from "@/utils/misc";

type TabKey = "update" | "deposit" | "withdraw";
const Modal = dynamic(() => import("@/ui/modal"), { ssr: false });
Expand Down Expand Up @@ -74,7 +75,10 @@ export default function RelayerManageModal({ relayerInfo, isOpen, onClose, onSuc
}

if (relayerInfo?.liquidityFeeRate) {
setFeeRate({ formatted: Number(relayerInfo.liquidityFeeRate), value: `${relayerInfo.liquidityFeeRate}` });
setFeeRate({
formatted: Number(relayerInfo.liquidityFeeRate),
value: `${formatFeeRate(relayerInfo.liquidityFeeRate)}`,
});
}

if (relayerInfo?.bridge === "lnbridgev20-default" && _targetToken && relayerInfo.margin) {
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/src/components/relayer-register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Token, TokenSymbol } from "@/types/token";
import { BridgeCategory } from "@/types/bridge";
import { useAccount, useNetwork, useSwitchNetwork } from "wagmi";
import Image from "next/image";
import { getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import { formatFeeRate, getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import Tooltip from "@/ui/tooltip";
import StepCompleteItem from "./step-complete-item";
import { BalanceInput } from "./balance-input";
Expand Down Expand Up @@ -410,7 +410,7 @@ export default function RelayerRegister() {
balance={margin.formatted}
/>
<StepCompleteItem property="Base Fee" token={sourceToken} balance={baseFee.formatted} />
<StepCompleteItem property="Liquidity Fee Rate" percent={feeRate.formatted} />
<StepCompleteItem property="Liquidity Fee Rate" percent={formatFeeRate(feeRate.formatted)} />
</div>
</>
)}
Expand Down Expand Up @@ -527,7 +527,7 @@ export default function RelayerRegister() {
<PrettyBaseFee fee={baseFee.formatted} token={sourceToken} />

<span>Liquidity Fee Rate</span>
<span>{feeRate.formatted}%</span>
<span>{formatFeeRate(feeRate.formatted)}%</span>
</div>

<Divider />
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/src/components/relayers-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Image from "next/image";
import PrettyAddress from "./pretty-address";
import { Network } from "@/types/chain";
import { getChainConfig } from "@/utils/chain";
import { getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import { formatFeeRate, getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import { formatBalance } from "@/utils/balance";
import { useState } from "react";
import Button from "@/ui/button";
Expand Down Expand Up @@ -89,8 +89,8 @@ const commonColumns: ColumnType<DataSource>[] = [
/>
),
render: ({ liquidityFeeRate }) =>
liquidityFeeRate ? (
<span className="text-sm font-normal text-white">{`${liquidityFeeRate}%`}</span>
typeof liquidityFeeRate === "number" ? (
<span className="text-sm font-normal text-white">{`${formatFeeRate(liquidityFeeRate)}%`}</span>
) : (
<span>-</span>
),
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/src/components/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function Section({
return (
<div className={`gap-small lg:gap-middle relative flex flex-col ${className}`}>
<div className="absolute -top-8 left-0 flex w-full items-center justify-between">
<span className="text-sm font-normal text-white">{label}</span>
<span className="text-sm font-normal text-white/50">{label}</span>
{extra}
</div>
{children}
Expand Down
5 changes: 4 additions & 1 deletion packages/apps/src/config/constant.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export {};
/**
* If the fee rate is 10.123%, its value in the contract is 10123 (10.123 * 1000)
*/
export const FEE_RATE_BASE = 1000;
9 changes: 9 additions & 0 deletions packages/apps/src/utils/misc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FEE_RATE_BASE } from "@/config/constant";
import { RecordStatus } from "@/types/graphql";

export function formatRecordStatus(status: RecordStatus) {
Expand Down Expand Up @@ -28,3 +29,11 @@ export function getChainLogoSrc(fileName?: string | null) {
export function getBridgeLogoSrc(fileName: string) {
return `/images/bridge/${fileName}`;
}

export function parseFeeRate(rate: string) {
return Math.round(Number(rate) * FEE_RATE_BASE);
}

export function formatFeeRate(rate: number) {
return Number((rate / FEE_RATE_BASE).toFixed(3));
}
Loading