From cdcedfdc4098e8edf4b09d70f7f0e4e92fc6976e Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Tue, 12 Sep 2023 00:22:57 +0800 Subject: [PATCH 1/3] support mantle --- packages/apps/bridges/bridges.ts | 12 + packages/apps/bridges/index.ts | 7 + .../Arbitrum2MantleLnBridge.tsx | 10 + .../lnbridge/arbitrum-mantle/config/bridge.ts | 33 ++ .../lnbridge/arbitrum-mantle/config/index.ts | 1 + .../bridges/lnbridge/arbitrum-mantle/index.ts | 1 + .../lnbridge/arbitrum-mantle/model/bridge.ts | 21 + .../lnbridge/arbitrum-mantle/model/index.ts | 1 + .../lnbridge/arbitrum-mantle/utils/bridge.ts | 17 + .../lnbridge/arbitrum-mantle/utils/index.ts | 1 + .../Ethereum2MantleLnBridge.tsx | 10 + .../lnbridge/ethereum-mantle/config/bridge.ts | 27 + .../lnbridge/ethereum-mantle/config/index.ts | 1 + .../bridges/lnbridge/ethereum-mantle/index.ts | 1 + .../lnbridge/ethereum-mantle/model/bridge.ts | 21 + .../lnbridge/ethereum-mantle/model/index.ts | 1 + .../lnbridge/ethereum-mantle/utils/bridge.ts | 17 + .../lnbridge/ethereum-mantle/utils/index.ts | 1 + .../linea-mantle/Linea2MantleLnBridge.tsx | 10 + .../lnbridge/linea-mantle/config/bridge.ts | 32 ++ .../lnbridge/linea-mantle/config/index.ts | 1 + .../bridges/lnbridge/linea-mantle/index.ts | 1 + .../lnbridge/linea-mantle/model/bridge.ts | 21 + .../lnbridge/linea-mantle/model/index.ts | 1 + .../lnbridge/linea-mantle/utils/bridge.ts | 17 + .../lnbridge/linea-mantle/utils/index.ts | 1 + .../lnbridge/lnbridge/config/abi/default.json | 474 ++++++++++-------- .../lnbridge/config/abi/opposite.json | 394 ++++++++------- .../bridges/lnbridge/lnbridge/utils/bridge.ts | 15 +- .../Mantle2ArbitrumLnBridge.tsx | 10 + .../lnbridge/mantle-arbitrum/config/bridge.ts | 33 ++ .../lnbridge/mantle-arbitrum/config/index.ts | 1 + .../bridges/lnbridge/mantle-arbitrum/index.ts | 1 + .../lnbridge/mantle-arbitrum/model/bridge.ts | 21 + .../lnbridge/mantle-arbitrum/model/index.ts | 1 + .../lnbridge/mantle-arbitrum/utils/bridge.ts | 17 + .../lnbridge/mantle-arbitrum/utils/index.ts | 1 + .../Mantle2EthereumLnBridge.tsx | 10 + .../lnbridge/mantle-ethereum/config/bridge.ts | 28 ++ .../lnbridge/mantle-ethereum/config/index.ts | 1 + .../bridges/lnbridge/mantle-ethereum/index.ts | 1 + .../lnbridge/mantle-ethereum/model/bridge.ts | 21 + .../lnbridge/mantle-ethereum/model/index.ts | 1 + .../lnbridge/mantle-ethereum/utils/bridge.ts | 17 + .../lnbridge/mantle-ethereum/utils/index.ts | 1 + .../mantle-linea/Mantle2LineaLnBridge.tsx | 10 + .../lnbridge/mantle-linea/config/bridge.ts | 33 ++ .../lnbridge/mantle-linea/config/index.ts | 1 + .../bridges/lnbridge/mantle-linea/index.ts | 1 + .../lnbridge/mantle-linea/model/bridge.ts | 21 + .../lnbridge/mantle-linea/model/index.ts | 1 + .../lnbridge/mantle-linea/utils/bridge.ts | 17 + .../lnbridge/mantle-linea/utils/index.ts | 1 + packages/apps/components/CrossChain.tsx | 7 + .../components/form-control/Destination.tsx | 5 +- packages/apps/config/bridge.ts | 12 + packages/apps/model/tx.ts | 2 + packages/apps/public/image/mantle.svg | 43 ++ packages/apps/public/image/mnt.svg | 4 + packages/apps/utils/validate.ts | 14 +- .../shared/components/widget/ExplorerLink.tsx | 2 + .../shared/config/network/arbitrum-goerli.ts | 69 ++- packages/shared/config/network/goerli.ts | 56 +-- packages/shared/config/network/index.ts | 2 + .../shared/config/network/linea-goerli.ts | 42 +- packages/shared/config/network/linea.ts | 2 +- .../shared/config/network/mantle-goerli.ts | 113 +++++ packages/shared/config/network/mantle.ts | 81 +++ packages/shared/config/network/networks.ts | 4 + .../shared/config/network/zksync-goerli.ts | 35 +- packages/shared/config/theme.ts | 6 + packages/shared/model/bridge/supports.ts | 10 +- packages/shared/model/network/network.ts | 2 + 73 files changed, 1415 insertions(+), 496 deletions(-) create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/Arbitrum2MantleLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/index.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/arbitrum-mantle/utils/index.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/Ethereum2MantleLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/index.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/ethereum-mantle/utils/index.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/Linea2MantleLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/index.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/linea-mantle/utils/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/Mantle2ArbitrumLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-arbitrum/utils/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/Mantle2EthereumLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-ethereum/utils/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/Mantle2LineaLnBridge.tsx create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/config/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/model/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/model/index.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/utils/bridge.ts create mode 100644 packages/apps/bridges/lnbridge/mantle-linea/utils/index.ts create mode 100644 packages/apps/public/image/mantle.svg create mode 100644 packages/apps/public/image/mnt.svg create mode 100644 packages/shared/config/network/mantle-goerli.ts create mode 100644 packages/shared/config/network/mantle.ts diff --git a/packages/apps/bridges/bridges.ts b/packages/apps/bridges/bridges.ts index f1dd050f3..42c38c14c 100644 --- a/packages/apps/bridges/bridges.ts +++ b/packages/apps/bridges/bridges.ts @@ -36,6 +36,12 @@ import { ArbitrumZksyncBridge as ArbitrumZksyncBridgeLnBridge } from './lnbridge import { ZksyncArbitrumBridge as ZksyncArbitrumBridgeLnBridge } from './lnbridge/zksync-arbitrum/utils'; import { LineaZksyncBridge as LineaZksyncBridgeLnBridge } from './lnbridge/linea-zksync/utils'; import { ZksyncLineaBridge as ZksyncLineaBridgeLnBridge } from './lnbridge/zksync-linea/utils'; +import { MantleArbitrumBridge as MantleArbitrumBridgeLnBridge } from './lnbridge/mantle-arbitrum/utils'; +import { ArbitrumMantleBridge as ArbitrumMantleBridgeLnBridge } from './lnbridge/arbitrum-mantle/utils'; +import { MantleEthereumBridge as MantleEthereumBridgeLnBridge } from './lnbridge/mantle-ethereum/utils'; +import { EthereumMantleBridge as EthereumMantleBridgeLnBridge } from './lnbridge/ethereum-mantle/utils'; +import { MantleLineaBridge as MantleLineaBridgeLnBridge } from './lnbridge/mantle-linea/utils'; +import { LineaMantleBridge as LineaMantleBridgeLnBridge } from './lnbridge/linea-mantle/utils'; export const bridgeConstructors = [ CBridgeBridge, @@ -75,6 +81,12 @@ export const bridgeConstructors = [ ZksyncArbitrumBridgeLnBridge, LineaZksyncBridgeLnBridge, ZksyncLineaBridgeLnBridge, + MantleArbitrumBridgeLnBridge, + ArbitrumMantleBridgeLnBridge, + MantleEthereumBridgeLnBridge, + EthereumMantleBridgeLnBridge, + MantleLineaBridgeLnBridge, + LineaMantleBridgeLnBridge, ]; export function bridgeFactory( diff --git a/packages/apps/bridges/index.ts b/packages/apps/bridges/index.ts index 6f8a7978d..a37d81eb4 100644 --- a/packages/apps/bridges/index.ts +++ b/packages/apps/bridges/index.ts @@ -63,3 +63,10 @@ export { Zksync2ArbitrumLnBridge } from './lnbridge/zksync-arbitrum'; export { Linea2ZksyncLnBridge } from './lnbridge/linea-zksync'; export { Zksync2LineaLnBridge } from './lnbridge/zksync-linea'; + +export { Mantle2ArbitrumLnBridge } from './lnbridge/mantle-arbitrum'; +export { Arbitrum2MantleLnBridge } from './lnbridge/arbitrum-mantle'; +export { Mantle2EthereumLnBridge } from './lnbridge/mantle-ethereum'; +export { Ethereum2MantleLnBridge } from './lnbridge/ethereum-mantle'; +export { Mantle2LineaLnBridge } from './lnbridge/mantle-linea'; +export { Linea2MantleLnBridge } from './lnbridge/linea-mantle'; diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/Arbitrum2MantleLnBridge.tsx b/packages/apps/bridges/lnbridge/arbitrum-mantle/Arbitrum2MantleLnBridge.tsx new file mode 100644 index 000000000..5b18874ea --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/Arbitrum2MantleLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { ArbitrumMantleBridge } from './utils/bridge'; + +export function Arbitrum2MantleLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts new file mode 100644 index 000000000..fc0a8dc24 --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts @@ -0,0 +1,33 @@ +import { arbitrumConfig, mantleConfig } from 'shared/config/network'; +import { arbitrumGoerliConfig, mantleGoerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { ArbitrumMantleBridgeConfig } from '../model'; + +const arbitrumMantleConfig: ArbitrumMantleBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const arbitrumGoerliMantleGoerliConfig: ArbitrumMantleBridgeConfig = { + contracts: { + backing: '0x504F597CfB0A32704AA6533Fb75dCD60dB982836', + issuing: '', + }, +}; + +export const arbitrumMantleLnBridge = new BridgeBase(arbitrumConfig, mantleConfig, arbitrumMantleConfig, { + name: 'arbitrum-mantle', + category: 'lnbridgev20-default', +}); + +export const arbitrumGoerliMantleGoerliLnBridge = new BridgeBase( + arbitrumGoerliConfig, + mantleGoerliConfig, + arbitrumGoerliMantleGoerliConfig, + { + name: 'arbitrum-mantle', + category: 'lnbridgev20-default', + } +); diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/config/index.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/index.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/index.ts new file mode 100644 index 000000000..2589ee78f --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/index.ts @@ -0,0 +1 @@ +export * from './Arbitrum2MantleLnBridge'; diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/model/bridge.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/model/bridge.ts new file mode 100644 index 000000000..45103a372 --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type ArbitrumMantleContractConfig = ContractConfig; + +export type ArbitrumMantleBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/model/index.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/bridge.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/bridge.ts new file mode 100644 index 000000000..18c2df3fd --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, ArbitrumMantleBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class ArbitrumMantleBridge extends LnBridgeBridge { + static readonly alias: string = 'ArbitrumMantleLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/index.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/Ethereum2MantleLnBridge.tsx b/packages/apps/bridges/lnbridge/ethereum-mantle/Ethereum2MantleLnBridge.tsx new file mode 100644 index 000000000..c7e5be4b1 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/Ethereum2MantleLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { EthereumMantleBridge } from './utils/bridge'; + +export function Ethereum2MantleLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/config/bridge.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/config/bridge.ts new file mode 100644 index 000000000..36764c2f9 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/config/bridge.ts @@ -0,0 +1,27 @@ +import { mantleConfig, ethereumConfig, mantleGoerliConfig, goerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { EthereumMantleBridgeConfig } from '../model'; + +const ethereumMantleConfig: EthereumMantleBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const goerliMantleGoerliConfig: EthereumMantleBridgeConfig = { + contracts: { + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', + issuing: '', + }, +}; + +export const ethereumMantleLnBridge = new BridgeBase(ethereumConfig, mantleConfig, ethereumMantleConfig, { + name: 'ethereum-mantle', + category: 'lnbridgev20-default', +}); + +export const goerliMantleGoerliLnBridge = new BridgeBase(goerliConfig, mantleGoerliConfig, goerliMantleGoerliConfig, { + name: 'ethereum-mantle', + category: 'lnbridgev20-default', +}); diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/config/index.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/index.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/index.ts new file mode 100644 index 000000000..f48421a77 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/index.ts @@ -0,0 +1 @@ +export * from './Ethereum2MantleLnBridge'; diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/model/bridge.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/model/bridge.ts new file mode 100644 index 000000000..d81776fcd --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type EthereumMantleContractConfig = ContractConfig; + +export type EthereumMantleBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/model/index.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/utils/bridge.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/utils/bridge.ts new file mode 100644 index 000000000..f39fb1935 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, EthereumMantleBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class EthereumMantleBridge extends LnBridgeBridge { + static readonly alias: string = 'EthereumMantleLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/ethereum-mantle/utils/index.ts b/packages/apps/bridges/lnbridge/ethereum-mantle/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/ethereum-mantle/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/Linea2MantleLnBridge.tsx b/packages/apps/bridges/lnbridge/linea-mantle/Linea2MantleLnBridge.tsx new file mode 100644 index 000000000..33dd69f43 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/Linea2MantleLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { LineaMantleBridge } from './utils/bridge'; + +export function Linea2MantleLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts b/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts new file mode 100644 index 000000000..4d3b0feec --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts @@ -0,0 +1,32 @@ +import { lineaConfig, mantleConfig, lineaGoerliConfig, mantleGoerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { LineaMantleBridgeConfig } from '../model'; + +const lineaMantleConfig: LineaMantleBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const lineaGoerliMantleGoerliConfig: LineaMantleBridgeConfig = { + contracts: { + backing: '0xE4B4b7707450b60421b5d7DE372fA5920F2bBDa8', + issuing: '', + }, +}; + +export const lineaMantleLnBridge = new BridgeBase(lineaConfig, mantleConfig, lineaMantleConfig, { + name: 'linea-mantle', + category: 'lnbridgev20-default', +}); + +export const lineaGoerliMantleGoerliLnBridge = new BridgeBase( + lineaGoerliConfig, + mantleGoerliConfig, + lineaGoerliMantleGoerliConfig, + { + name: 'linea-mantle', + category: 'lnbridgev20-default', + } +); diff --git a/packages/apps/bridges/lnbridge/linea-mantle/config/index.ts b/packages/apps/bridges/lnbridge/linea-mantle/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/index.ts b/packages/apps/bridges/lnbridge/linea-mantle/index.ts new file mode 100644 index 000000000..114c9fc04 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/index.ts @@ -0,0 +1 @@ +export * from './Linea2MantleLnBridge'; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/model/bridge.ts b/packages/apps/bridges/lnbridge/linea-mantle/model/bridge.ts new file mode 100644 index 000000000..567d474a8 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type LineaMantleContractConfig = ContractConfig; + +export type LineaMantleBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/model/index.ts b/packages/apps/bridges/lnbridge/linea-mantle/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/utils/bridge.ts b/packages/apps/bridges/lnbridge/linea-mantle/utils/bridge.ts new file mode 100644 index 000000000..0e2ba7fd5 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, LineaMantleBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class LineaMantleBridge extends LnBridgeBridge { + static readonly alias: string = 'LineaMantleLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/linea-mantle/utils/index.ts b/packages/apps/bridges/lnbridge/linea-mantle/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/linea-mantle/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/lnbridge/config/abi/default.json b/packages/apps/bridges/lnbridge/lnbridge/config/abi/default.json index 92afe1b73..29fc52217 100644 --- a/packages/apps/bridges/lnbridge/lnbridge/config/abi/default.json +++ b/packages/apps/bridges/lnbridge/lnbridge/config/abi/default.json @@ -8,14 +8,29 @@ { "anonymous": false, "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, { "indexed": false, "internalType": "uint112", "name": "baseFee", "type": "uint112" }, { "indexed": false, "internalType": "uint8", "name": "liquidityfeeRate", "type": "uint8" } ], "name": "LnProviderUpdated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "indexed": false, "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" } + ], + "name": "MarginUpdated", + "type": "event" + }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], @@ -25,46 +40,64 @@ { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } + { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "margin", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "slasher", "type": "address" } ], - "name": "RoleAdminChanged", + "name": "Slash", "type": "event" }, { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "bytes32", "name": "expectedTransferId", "type": "bytes32" } ], - "name": "RoleGranted", + "name": "SlashRequest", "type": "event" }, { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } ], - "name": "RoleRevoked", + "name": "SlashReserveUpdated", "type": "event" }, { "anonymous": false, "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" }, { "indexed": false, "internalType": "uint112", "name": "fee", "type": "uint112" }, + { "indexed": false, "internalType": "uint64", "name": "timestamp", "type": "uint64" }, { "indexed": false, "internalType": "address", "name": "receiver", "type": "address" } ], "name": "TokenLocked", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" } + ], + "name": "TransferFilled", + "type": "event" + }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], @@ -74,138 +107,97 @@ { "anonymous": false, "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" } ], - "name": "WithdrawMargin", + "name": "WithdrawMarginRequest", "type": "event" }, { "inputs": [], - "name": "DAO_ADMIN_ROLE", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "INIT_SLASH_TRANSFER_ID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "LIQUIDITY_FEE_RATE_BASE", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MAX_TRANSFER_AMOUNT", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MIN_SLASH_TIMESTAMP", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "OPERATOR_ROLE", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "dao", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "address", "name": "targetToken", "type": "address" } - ], - "name": "getDefaultProviderKey", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint256", "name": "_margin", "type": "uint256" } ], - "name": "getProviderKey", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], - "name": "getRoleAdmin", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", + "name": "depositProviderMargin", + "outputs": [], + "stateMutability": "payable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "uint256", "name": "index", "type": "uint256" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } ], - "name": "getRoleMember", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], - "name": "getRoleMemberCount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", + "name": "depositSlashFundReserve", + "outputs": [], + "stateMutability": "payable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { + "components": [ + { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "provider", "type": "address" }, + { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, + { "internalType": "address", "name": "receiver", "type": "address" } + ], + "internalType": "struct LnBridgeHelper.TransferParameter", + "name": "_params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_slasher", "type": "address" }, + { "internalType": "uint112", "name": "_fee", "type": "uint112" }, + { "internalType": "uint112", "name": "_penalty", "type": "uint112" } ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", + "name": "encodeSlashCall", + "outputs": [{ "internalType": "bytes", "name": "message", "type": "bytes" }], + "stateMutability": "pure", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "bytes32", "name": "_lastTransferId", "type": "bytes32" }, + { "internalType": "uint64", "name": "_withdrawNonce", "type": "uint64" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" } ], - "name": "hasRole", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "name": "encodeWithdrawCall", + "outputs": [{ "internalType": "bytes", "name": "message", "type": "bytes" }], "stateMutability": "view", "type": "function" }, { - "inputs": [], - "name": "inbox", - "outputs": [{ "internalType": "contract IInbox", "name": "", "type": "address" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "fillTransfers", + "outputs": [ + { "internalType": "uint64", "name": "timestamp", "type": "uint64" }, + { "internalType": "address", "name": "slasher", "type": "address" } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { "internalType": "address", "name": "_dao", "type": "address" }, - { "internalType": "address", "name": "_inbox", "type": "address" } - ], + "inputs": [{ "internalType": "address", "name": "dao", "type": "address" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", @@ -213,34 +205,32 @@ }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "lnProviders", + "name": "lockInfos", "outputs": [ - { - "components": [ - { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, - { "internalType": "uint8", "name": "liquidityFeeRate", "type": "uint8" } - ], - "internalType": "struct LnDefaultBridgeSource.LnProviderFee", - "name": "fee", - "type": "tuple" - }, - { "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" }, - { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" } + { "internalType": "uint112", "name": "fee", "type": "uint112" }, + { "internalType": "uint112", "name": "penalty", "type": "uint112" }, + { "internalType": "uint32", "name": "timestamp", "type": "uint32" } ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "lockInfos", + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "messagers", "outputs": [ - { "internalType": "uint112", "name": "fee", "type": "uint112" }, - { "internalType": "uint112", "name": "penalty", "type": "uint112" }, - { "internalType": "bool", "name": "isLocked", "type": "bool" } + { "internalType": "address", "name": "sendService", "type": "address" }, + { "internalType": "address", "name": "receiveService", "type": "address" } ], "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "operator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], @@ -257,50 +247,79 @@ "type": "function" }, { - "inputs": [], - "name": "remoteBridge", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" } + ], + "name": "providerPause", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" } ], - "name": "renounceRole", + "name": "providerUnpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "uint256", "name": "maxSubmissionCost", "type": "uint256" }, - { "internalType": "uint256", "name": "maxGas", "type": "uint256" }, - { "internalType": "uint256", "name": "gasPriceBid", "type": "uint256" } + { + "components": [ + { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "provider", "type": "address" }, + { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, + { "internalType": "address", "name": "receiver", "type": "address" } + ], + "internalType": "struct LnBridgeHelper.TransferParameter", + "name": "_params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_expectedTransferId", "type": "bytes32" }, + { "internalType": "bytes", "name": "_extParams", "type": "bytes" } ], - "name": "requestWithdrawMargin", + "name": "requestSlashAndRemoteRelease", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" }, + { "internalType": "bytes", "name": "_extParams", "type": "bytes" } ], - "name": "revokeRole", + "name": "requestWithdrawMargin", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_operator", "type": "address" }], + "name": "setOperator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, - { "internalType": "uint8", "name": "liquidityFeeRate", "type": "uint8" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_baseFee", "type": "uint112" }, + { "internalType": "uint8", "name": "_liquidityFeeRate", "type": "uint8" } ], "name": "setProviderFee", "outputs": [], @@ -308,14 +327,30 @@ "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "_remoteBridge", "type": "address" }], - "name": "setRemoteBridge", + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_remoteBridge", "type": "address" }, + { "internalType": "address", "name": "_service", "type": "address" } + ], + "name": "setReceiveService", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_remoteBridge", "type": "address" }, + { "internalType": "address", "name": "_service", "type": "address" } + ], + "name": "setSendService", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, { "internalType": "address", "name": "_sourceToken", "type": "address" }, { "internalType": "address", "name": "_targetToken", "type": "address" }, { "internalType": "uint112", "name": "_protocolFee", "type": "uint112" }, @@ -337,78 +372,59 @@ { "internalType": "address", "name": "sourceToken", "type": "address" }, { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "uint64", "name": "timestamp", "type": "uint64" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, { "internalType": "address", "name": "receiver", "type": "address" } ], "internalType": "struct LnBridgeHelper.TransferParameter", - "name": "params", + "name": "_params", "type": "tuple" }, - { "internalType": "bytes32", "name": "expectedTransferId", "type": "bytes32" }, - { "internalType": "uint256", "name": "maxSubmissionCost", "type": "uint256" }, - { "internalType": "uint256", "name": "maxGas", "type": "uint256" }, - { "internalType": "uint256", "name": "gasPriceBid", "type": "uint256" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_slasher", "type": "address" }, + { "internalType": "uint112", "name": "_fee", "type": "uint112" }, + { "internalType": "uint112", "name": "_penalty", "type": "uint112" } ], - "name": "slashAndRemoteRelease", + "name": "slash", "outputs": [], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ - { "internalType": "uint256", "name": "baseFee", "type": "uint256" }, + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "srcProviders", + "outputs": [ { "components": [ - { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "uint64", "name": "timestamp", "type": "uint64" }, - { "internalType": "address", "name": "receiver", "type": "address" } + { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, + { "internalType": "uint16", "name": "liquidityFeeRate", "type": "uint16" }, + { "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" }, + { "internalType": "bool", "name": "pause", "type": "bool" } ], - "internalType": "struct LnBridgeHelper.TransferParameter", - "name": "params", + "internalType": "struct LnDefaultBridgeSource.SourceProviderConfigure", + "name": "config", "type": "tuple" }, - { "internalType": "address", "name": "slasher", "type": "address" }, - { "internalType": "uint112", "name": "fee", "type": "uint112" }, - { "internalType": "uint112", "name": "penalty", "type": "uint112" }, - { "internalType": "uint256", "name": "percentIncrease", "type": "uint256" } + { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" } ], - "name": "submissionSlashFee", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { "internalType": "uint256", "name": "baseFee", "type": "uint256" }, - { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" }, - { "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" }, - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "uint256", "name": "percentIncrease", "type": "uint256" } - ], - "name": "submissionWithdrawFee", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], - "name": "supportsInterface", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "tgtProviders", + "outputs": [ + { "internalType": "uint256", "name": "margin", "type": "uint256" }, + { "internalType": "uint256", "name": "slashReserveFund", "type": "uint256" }, + { "internalType": "uint64", "name": "lastExpireFillTime", "type": "uint64" }, + { "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "name": "tokenInfos", "outputs": [ - { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "uint112", "name": "protocolFee", "type": "uint112" }, { "internalType": "uint112", "name": "penaltyLnCollateral", "type": "uint112" }, { "internalType": "uint8", "name": "sourceDecimals", "type": "uint8" }, @@ -420,9 +436,11 @@ }, { "inputs": [ - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" } ], "name": "totalFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], @@ -433,24 +451,57 @@ "inputs": [ { "components": [ + { "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "internalType": "address", "name": "provider", "type": "address" }, { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, { "internalType": "uint112", "name": "totalFee", "type": "uint112" }, { "internalType": "uint64", "name": "withdrawNonce", "type": "uint64" } ], "internalType": "struct LnDefaultBridgeSource.Snapshot", - "name": "snapshot", + "name": "_snapshot", "type": "tuple" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "address", "name": "receiver", "type": "address" } + { "internalType": "uint112", "name": "_amount", "type": "uint112" }, + { "internalType": "address", "name": "_receiver", "type": "address" } ], "name": "transferAndLockMargin", "outputs": [], "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "provider", "type": "address" }, + { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, + { "internalType": "address", "name": "receiver", "type": "address" } + ], + "internalType": "struct LnBridgeHelper.TransferParameter", + "name": "_params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_expectedTransferId", "type": "bytes32" } + ], + "name": "transferAndReleaseMargin", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_dao", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_receiver", "type": "address" }], @@ -459,5 +510,32 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_lastTransferId", "type": "bytes32" }, + { "internalType": "uint64", "name": "_withdrawNonce", "type": "uint64" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "withdrawSlashFundReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "stateMutability": "payable", "type": "receive" } ] diff --git a/packages/apps/bridges/lnbridge/lnbridge/config/abi/opposite.json b/packages/apps/bridges/lnbridge/lnbridge/config/abi/opposite.json index 039462a66..b0fb14a92 100644 --- a/packages/apps/bridges/lnbridge/lnbridge/config/abi/opposite.json +++ b/packages/apps/bridges/lnbridge/lnbridge/config/abi/opposite.json @@ -8,8 +8,10 @@ { "anonymous": false, "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, - { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" } ], "name": "LiquidityWithdrawn", @@ -18,11 +20,13 @@ { "anonymous": false, "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, - { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, { "indexed": false, "internalType": "uint112", "name": "margin", "type": "uint112" }, { "indexed": false, "internalType": "uint112", "name": "baseFee", "type": "uint112" }, - { "indexed": false, "internalType": "uint8", "name": "liquidityfeeRate", "type": "uint8" } + { "indexed": false, "internalType": "uint16", "name": "liquidityfeeRate", "type": "uint16" } ], "name": "LnProviderUpdated", "type": "event" @@ -36,298 +40,293 @@ { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint112", "name": "margin", "type": "uint112" }, + { "indexed": false, "internalType": "address", "name": "slasher", "type": "address" } ], - "name": "RoleAdminChanged", + "name": "Slash", "type": "event" }, { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" } ], - "name": "RoleGranted", + "name": "SlashRequest", "type": "event" }, { "anonymous": false, "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, + { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "indexed": false, "internalType": "uint112", "name": "fee", "type": "uint112" }, + { "indexed": false, "internalType": "uint64", "name": "timestamp", "type": "uint64" }, + { "indexed": false, "internalType": "address", "name": "receiver", "type": "address" } ], - "name": "RoleRevoked", + "name": "TokenLocked", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, - { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, - { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, - { "indexed": false, "internalType": "uint112", "name": "margin", "type": "uint112" }, { "indexed": false, "internalType": "address", "name": "slasher", "type": "address" } ], - "name": "Slash", + "name": "TransferFilled", "type": "event" }, { "anonymous": false, - "inputs": [ - { "indexed": false, "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, - { "indexed": false, "internalType": "address", "name": "provider", "type": "address" }, - { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, - { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "indexed": false, "internalType": "uint112", "name": "fee", "type": "uint112" }, - { "indexed": false, "internalType": "address", "name": "receiver", "type": "address" } - ], - "name": "TokenLocked", + "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], + "name": "Unpaused", "type": "event" }, { "anonymous": false, - "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], - "name": "Unpaused", + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "sourceToken", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "targetToken", "type": "address" }, + { "indexed": false, "internalType": "uint112", "name": "amount", "type": "uint112" } + ], + "name": "WithdrawMarginRequest", "type": "event" }, { "inputs": [], - "name": "DAO_ADMIN_ROLE", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "dao", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "fillTransfers", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { - "inputs": [], - "name": "INIT_SLASH_TRANSFER_ID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", + "inputs": [{ "internalType": "address", "name": "_dao", "type": "address" }], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "LIQUIDITY_FEE_RATE_BASE", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "lockInfos", + "outputs": [ + { "internalType": "uint112", "name": "amountWithFeeAndPenalty", "type": "uint112" }, + { "internalType": "uint32", "name": "timestamp", "type": "uint32" }, + { "internalType": "bool", "name": "hasSlashed", "type": "bool" } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "MAX_TRANSFER_AMOUNT", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "operator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, + { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], - "name": "OPERATOR_ROLE", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "feeReceiver", + "name": "protocolFeeReceiver", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "token", "type": "address" } - ], - "name": "getProviderKey", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], - "name": "getRoleAdmin", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "uint256", "name": "index", "type": "uint256" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" } ], - "name": "getRoleMember", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], - "name": "getRoleMemberCount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", + "name": "providerPause", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" } ], - "name": "grantRole", + "name": "providerUnpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_transferId", "type": "bytes32" }, + { "internalType": "bytes", "name": "_extParams", "type": "bytes" } ], - "name": "hasRole", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "dao", "type": "address" }], - "name": "initialize", + "name": "requestRetrySlashAndRemoteRelease", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "payable", "type": "function" }, { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "lnProviders", - "outputs": [ + "inputs": [ { "components": [ - { "internalType": "uint112", "name": "margin", "type": "uint112" }, - { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, - { "internalType": "uint8", "name": "liquidityFeeRate", "type": "uint8" } + { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "provider", "type": "address" }, + { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, + { "internalType": "address", "name": "receiver", "type": "address" } ], - "internalType": "struct LnOppositeBridgeSource.LnProviderConfigure", - "name": "config", + "internalType": "struct LnBridgeHelper.TransferParameter", + "name": "_params", "type": "tuple" }, - { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "lockInfos", - "outputs": [ - { "internalType": "uint112", "name": "amountWithFeeAndPenalty", "type": "uint112" }, - { "internalType": "bool", "name": "hasSlashed", "type": "bool" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_expectedTransferId", "type": "bytes32" }, + { "internalType": "bytes", "name": "_extParams", "type": "bytes" } ], - "stateMutability": "view", - "type": "function" - }, - { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [], - "name": "paused", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", + "name": "requestSlashAndRemoteRelease", + "outputs": [], + "stateMutability": "payable", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, - { "internalType": "uint112", "name": "protocolFee", "type": "uint112" }, - { "internalType": "uint112", "name": "penaltyLnCollateral", "type": "uint112" }, - { "internalType": "uint8", "name": "sourceDecimals", "type": "uint8" }, - { "internalType": "uint8", "name": "targetDecimals", "type": "uint8" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_lastTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" }, + { "internalType": "bytes", "name": "_extParams", "type": "bytes" } ], - "name": "registerToken", + "name": "requestWithdrawMargin", "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "remoteBridge", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", + "stateMutability": "payable", "type": "function" }, { - "inputs": [], - "name": "remoteBridgeAlias", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", + "inputs": [{ "internalType": "address", "name": "_operator", "type": "address" }], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_remoteBridge", "type": "address" }, + { "internalType": "address", "name": "_service", "type": "address" } ], - "name": "renounceRole", + "name": "setReceiveService", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "bytes32", "name": "role", "type": "bytes32" }, - { "internalType": "address", "name": "account", "type": "address" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_remoteBridge", "type": "address" }, + { "internalType": "address", "name": "_service", "type": "address" } ], - "name": "revokeRole", + "name": "setSendService", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "_remoteBridge", "type": "address" }], - "name": "setRemoteBridge", + "inputs": [ + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_protocolFee", "type": "uint112" }, + { "internalType": "uint112", "name": "_penaltyLnCollateral", "type": "uint112" }, + { "internalType": "uint8", "name": "_sourceDecimals", "type": "uint8" }, + { "internalType": "uint8", "name": "_targetDecimals", "type": "uint8" } + ], + "name": "setTokenInfo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "_remoteBridgeAlias", "type": "address" }], - "name": "setRemoteBridgeAlias", + "inputs": [ + { "internalType": "bytes32", "name": "_latestSlashTransferId", "type": "bytes32" }, + { "internalType": "bytes32", "name": "_transferId", "type": "bytes32" }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "uint256", "name": "_timestamp", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_slasher", "type": "address" } + ], + "name": "slash", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ - { "internalType": "bytes32", "name": "latestSlashTransferId", "type": "bytes32" }, - { "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "slashInfos", + "outputs": [ { "internalType": "address", "name": "provider", "type": "address" }, { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "address", "name": "slasher", "type": "address" } + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "address", "name": "slasher", "type": "address" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" } ], - "name": "slash", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], - "name": "supportsInterface", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "srcProviders", + "outputs": [ + { + "components": [ + { "internalType": "uint112", "name": "margin", "type": "uint112" }, + { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, + { "internalType": "uint16", "name": "liquidityFeeRate", "type": "uint16" }, + { "internalType": "bool", "name": "pause", "type": "bool" } + ], + "internalType": "struct LnOppositeBridgeSource.SourceProviderConfigure", + "name": "config", + "type": "tuple" + }, + { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "name": "tokenInfos", "outputs": [ - { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "uint112", "name": "protocolFee", "type": "uint112" }, { "internalType": "uint112", "name": "penaltyLnCollateral", "type": "uint112" }, { "internalType": "uint8", "name": "sourceDecimals", "type": "uint8" }, @@ -339,9 +338,11 @@ }, { "inputs": [ - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" } ], "name": "totalFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], @@ -352,48 +353,73 @@ "inputs": [ { "components": [ + { "internalType": "uint256", "name": "remoteChainId", "type": "uint256" }, { "internalType": "address", "name": "provider", "type": "address" }, { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "bytes32", "name": "transferId", "type": "bytes32" }, - { "internalType": "uint112", "name": "depositedMargin", "type": "uint112" }, - { "internalType": "uint112", "name": "totalFee", "type": "uint112" } + { "internalType": "uint112", "name": "totalFee", "type": "uint112" }, + { "internalType": "uint112", "name": "depositedMargin", "type": "uint112" } ], "internalType": "struct LnOppositeBridgeSource.Snapshot", - "name": "snapshot", + "name": "_snapshot", "type": "tuple" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" }, - { "internalType": "address", "name": "receiver", "type": "address" } + { "internalType": "uint112", "name": "_amount", "type": "uint112" }, + { "internalType": "address", "name": "_receiver", "type": "address" } ], "name": "transferAndLockMargin", "outputs": [], "stateMutability": "payable", "type": "function" }, - { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "_receiver", "type": "address" }], - "name": "updateFeeReceiver", + "inputs": [ + { + "components": [ + { "internalType": "bytes32", "name": "previousTransferId", "type": "bytes32" }, + { "internalType": "address", "name": "provider", "type": "address" }, + { "internalType": "address", "name": "sourceToken", "type": "address" }, + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "uint112", "name": "amount", "type": "uint112" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, + { "internalType": "address", "name": "receiver", "type": "address" } + ], + "internalType": "struct LnBridgeHelper.TransferParameter", + "name": "_params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "bytes32", "name": "_expectedTransferId", "type": "bytes32" } + ], + "name": "transferAndReleaseMargin", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_dao", "type": "address" }], + "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint112", "name": "_protocolFee", "type": "uint112" } - ], - "name": "updateProtocolFee", + "inputs": [{ "internalType": "address", "name": "_receiver", "type": "address" }], + "name": "updateFeeReceiver", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "margin", "type": "uint112" }, - { "internalType": "uint112", "name": "baseFee", "type": "uint112" }, - { "internalType": "uint8", "name": "liquidityFeeRate", "type": "uint8" } + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_margin", "type": "uint112" }, + { "internalType": "uint112", "name": "_baseFee", "type": "uint112" }, + { "internalType": "uint16", "name": "_liquidityFeeRate", "type": "uint16" } ], "name": "updateProviderFeeAndMargin", "outputs": [], @@ -402,11 +428,13 @@ }, { "inputs": [ - { "internalType": "bytes32", "name": "latestSlashTransferId", "type": "bytes32" }, - { "internalType": "bytes32", "name": "lastTransferId", "type": "bytes32" }, - { "internalType": "address", "name": "provider", "type": "address" }, - { "internalType": "address", "name": "sourceToken", "type": "address" }, - { "internalType": "uint112", "name": "amount", "type": "uint112" } + { "internalType": "bytes32", "name": "_latestSlashTransferId", "type": "bytes32" }, + { "internalType": "bytes32", "name": "_lastTransferId", "type": "bytes32" }, + { "internalType": "uint256", "name": "_remoteChainId", "type": "uint256" }, + { "internalType": "address", "name": "_provider", "type": "address" }, + { "internalType": "address", "name": "_sourceToken", "type": "address" }, + { "internalType": "address", "name": "_targetToken", "type": "address" }, + { "internalType": "uint112", "name": "_amount", "type": "uint112" } ], "name": "withdrawMargin", "outputs": [], diff --git a/packages/apps/bridges/lnbridge/lnbridge/utils/bridge.ts b/packages/apps/bridges/lnbridge/lnbridge/utils/bridge.ts index e857fcfb7..66e92df28 100644 --- a/packages/apps/bridges/lnbridge/lnbridge/utils/bridge.ts +++ b/packages/apps/bridges/lnbridge/lnbridge/utils/bridge.ts @@ -49,11 +49,20 @@ export abstract class LnBridgeBridge< contractAddress, async (contract) => { if (snapshot) { - const { relayer, sourceToken, transferId, depositedMargin, totalFee, withdrawNonce } = snapshot; + const { + remoteChainId, + relayer, + sourceToken, + targetToken, + transferId, + depositedMargin, + totalFee, + withdrawNonce, + } = snapshot; const snapshotArgs = bridge.category === 'lnbridgev20-default' - ? [relayer, sourceToken, transferId, totalFee, withdrawNonce] - : [relayer, sourceToken, transferId, depositedMargin, totalFee]; + ? [remoteChainId, relayer, sourceToken, targetToken, transferId, totalFee, withdrawNonce] + : [remoteChainId, relayer, sourceToken, targetToken, transferId, totalFee, depositedMargin]; if (type === 'native') { return contract.transferAndLockMargin(snapshotArgs, transferAmount, recipient, { diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/Mantle2ArbitrumLnBridge.tsx b/packages/apps/bridges/lnbridge/mantle-arbitrum/Mantle2ArbitrumLnBridge.tsx new file mode 100644 index 000000000..38796bae2 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/Mantle2ArbitrumLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { MantleArbitrumBridge } from './utils/bridge'; + +export function Mantle2ArbitrumLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts new file mode 100644 index 000000000..346279f86 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts @@ -0,0 +1,33 @@ +import { mantleConfig, arbitrumConfig } from 'shared/config/network'; +import { mantleGoerliConfig, arbitrumGoerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { MantleArbitrumBridgeConfig } from '../model'; + +const mantleArbitrumConfig: MantleArbitrumBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const mantleGoerliArbitrumGoerliConfig: MantleArbitrumBridgeConfig = { + contracts: { + backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + issuing: '', + }, +}; + +export const mantleArbitrumLnBridge = new BridgeBase(mantleConfig, arbitrumConfig, mantleArbitrumConfig, { + name: 'mantle-arbitrum', + category: 'lnbridgev20-default', +}); + +export const mantleGoerliArbitrumGoerliLnBridge = new BridgeBase( + mantleGoerliConfig, + arbitrumGoerliConfig, + mantleGoerliArbitrumGoerliConfig, + { + name: 'mantle-arbitrum', + category: 'lnbridgev20-default', + } +); diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/config/index.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/index.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/index.ts new file mode 100644 index 000000000..d75e13a74 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/index.ts @@ -0,0 +1 @@ +export * from './Mantle2ArbitrumLnBridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/model/bridge.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/model/bridge.ts new file mode 100644 index 000000000..e2b6bcd1d --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type MantleArbitrumContractConfig = ContractConfig; + +export type MantleArbitrumBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/model/index.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/bridge.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/bridge.ts new file mode 100644 index 000000000..3df308e2c --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, MantleArbitrumBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class MantleArbitrumBridge extends LnBridgeBridge { + static readonly alias: string = 'MantleArbitrumLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/index.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/Mantle2EthereumLnBridge.tsx b/packages/apps/bridges/lnbridge/mantle-ethereum/Mantle2EthereumLnBridge.tsx new file mode 100644 index 000000000..93b999178 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/Mantle2EthereumLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { MantleEthereumBridge } from './utils/bridge'; + +export function Mantle2EthereumLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts new file mode 100644 index 000000000..dc58806f9 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts @@ -0,0 +1,28 @@ +import { mantleConfig, ethereumConfig } from 'shared/config/network'; +import { mantleGoerliConfig, goerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { MantleEthereumBridgeConfig } from '../model'; + +const mantleEthereumConfig: MantleEthereumBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const mantleGoerliGoerliConfig: MantleEthereumBridgeConfig = { + contracts: { + backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + issuing: '', + }, +}; + +export const mantleEthereumLnBridge = new BridgeBase(mantleConfig, ethereumConfig, mantleEthereumConfig, { + name: 'mantle-ethereum', + category: 'lnbridgev20-default', +}); + +export const mantleGoerliGoerliLnBridge = new BridgeBase(mantleGoerliConfig, goerliConfig, mantleGoerliGoerliConfig, { + name: 'mantle-ethereum', + category: 'lnbridgev20-default', +}); diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/config/index.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/index.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/index.ts new file mode 100644 index 000000000..9fd5dd6b6 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/index.ts @@ -0,0 +1 @@ +export * from './Mantle2EthereumLnBridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/model/bridge.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/model/bridge.ts new file mode 100644 index 000000000..4f934d785 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type MantleEthereumContractConfig = ContractConfig; + +export type MantleEthereumBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/model/index.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/utils/bridge.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/utils/bridge.ts new file mode 100644 index 000000000..ea0b65f8d --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, MantleEthereumBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class MantleEthereumBridge extends LnBridgeBridge { + static readonly alias: string = 'MantleEthereumLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/utils/index.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/Mantle2LineaLnBridge.tsx b/packages/apps/bridges/lnbridge/mantle-linea/Mantle2LineaLnBridge.tsx new file mode 100644 index 000000000..20e6cc204 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/Mantle2LineaLnBridge.tsx @@ -0,0 +1,10 @@ +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../components/bridge/Bridge'; +import { CrossChainComponentProps } from '../../../model/component'; +import { MantleLineaBridge } from './utils/bridge'; + +export function Mantle2LineaLnBridge( + props: CrossChainComponentProps, CrossToken> +) { + return ; +} diff --git a/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts new file mode 100644 index 000000000..86279c876 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts @@ -0,0 +1,33 @@ +import { mantleConfig, lineaConfig } from 'shared/config/network'; +import { mantleGoerliConfig, lineaGoerliConfig } from 'shared/config/network'; +import { BridgeBase } from 'shared/core/bridge'; +import { MantleLineaBridgeConfig } from '../model'; + +const mantleLineaConfig: MantleLineaBridgeConfig = { + contracts: { + backing: '', + issuing: '', + }, +}; + +const mantleGoerliLineaGoerliConfig: MantleLineaBridgeConfig = { + contracts: { + backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + issuing: '', + }, +}; + +export const mantleLineaLnBridge = new BridgeBase(mantleConfig, lineaConfig, mantleLineaConfig, { + name: 'mantle-linea', + category: 'lnbridgev20-default', +}); + +export const mantleGoerliLineaGoerliLnBridge = new BridgeBase( + mantleGoerliConfig, + lineaGoerliConfig, + mantleGoerliLineaGoerliConfig, + { + name: 'mantle-linea', + category: 'lnbridgev20-default', + } +); diff --git a/packages/apps/bridges/lnbridge/mantle-linea/config/index.ts b/packages/apps/bridges/lnbridge/mantle-linea/config/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/config/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/index.ts b/packages/apps/bridges/lnbridge/mantle-linea/index.ts new file mode 100644 index 000000000..6940c02ca --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/index.ts @@ -0,0 +1 @@ +export * from './Mantle2LineaLnBridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/model/bridge.ts b/packages/apps/bridges/lnbridge/mantle-linea/model/bridge.ts new file mode 100644 index 000000000..bc172012c --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/model/bridge.ts @@ -0,0 +1,21 @@ +import { BridgeConfig } from 'shared/model'; +import { ContractConfig } from 'shared/model'; +import { CrossToken, DVMChainConfig } from 'shared/model'; +import { Bridge } from '../../../../core/bridge'; +import { CrossChainPayload } from '../../../../model/tx'; + +type MantleLineaContractConfig = ContractConfig; + +export type MantleLineaBridgeConfig = Required>; + +export type IssuingPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; + +export type RedeemPayload = CrossChainPayload< + Bridge, + CrossToken, + CrossToken +>; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/model/index.ts b/packages/apps/bridges/lnbridge/mantle-linea/model/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/model/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/utils/bridge.ts b/packages/apps/bridges/lnbridge/mantle-linea/utils/bridge.ts new file mode 100644 index 000000000..dc6be97c6 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/utils/bridge.ts @@ -0,0 +1,17 @@ +import { BN } from '@polkadot/util'; +import { DVMChainConfig, Tx } from 'shared/model'; +import { Observable } from 'rxjs'; +import { IssuingPayload, RedeemPayload, MantleLineaBridgeConfig } from '../model'; +import { LnBridgeBridge } from '../../lnbridge/utils/bridge'; + +export class MantleLineaBridge extends LnBridgeBridge { + static readonly alias: string = 'MantleLineaLnBridge'; + + back(payload: IssuingPayload, fee: BN): Observable { + return this.send(payload, fee); + } + + burn(payload: RedeemPayload, fee: BN): Observable { + return this.send(payload, fee); + } +} diff --git a/packages/apps/bridges/lnbridge/mantle-linea/utils/index.ts b/packages/apps/bridges/lnbridge/mantle-linea/utils/index.ts new file mode 100644 index 000000000..292563932 --- /dev/null +++ b/packages/apps/bridges/lnbridge/mantle-linea/utils/index.ts @@ -0,0 +1 @@ +export * from './bridge'; diff --git a/packages/apps/components/CrossChain.tsx b/packages/apps/components/CrossChain.tsx index 28d63b53f..15a8b2ee6 100644 --- a/packages/apps/components/CrossChain.tsx +++ b/packages/apps/components/CrossChain.tsx @@ -35,6 +35,7 @@ import { ContractConfig, SupportedWallet, TokenInfoWithMeta, + EthereumChainConfig, } from 'shared/model'; import { isMetamaskChainConsistent } from 'shared/utils/connection'; import { toWei, truncate } from 'shared/utils/helper/balance'; @@ -556,8 +557,12 @@ export function CrossChain() { _relayerCount = relayersInfo?.sortedLnv20RelayInfos.length || 0; if (relayersInfo?.sortedLnv20RelayInfos.length) { + const remoteChainId = BigNumber.from( + (value.direction.to.meta as EthereumChainConfig).ethereumChain.chainId + ); const relayer = relayersInfo.sortedLnv20RelayInfos[0].relayer; const sourceToken = relayersInfo.sortedLnv20RelayInfos[0].sendToken; + const targetToken = value.direction.to.address; const depositedMargin = BigNumber.from(relayersInfo.sortedLnv20RelayInfos[0].margin); const baseFee = BigNumber.from(relayersInfo.sortedLnv20RelayInfos[0].baseFee); const liquidityFeeRate = relayersInfo.sortedLnv20RelayInfos[0].liquidityFeeRate; @@ -573,8 +578,10 @@ export function CrossChain() { return { ...value, snapshot: { + remoteChainId, relayer, sourceToken, + targetToken, transferId, depositedMargin, totalFee, diff --git a/packages/apps/components/form-control/Destination.tsx b/packages/apps/components/form-control/Destination.tsx index be6050403..f94f3d2b3 100644 --- a/packages/apps/components/form-control/Destination.tsx +++ b/packages/apps/components/form-control/Destination.tsx @@ -51,7 +51,10 @@ export function Destination({ ), tokens: item.tokens - .filter((token) => (!fromToken || isTransferableTokenPair(token, fromToken)) && !!token.cross.length) + .filter( + (token) => + (!fromToken && token.cross.length > 0) || (fromToken && isTransferableTokenPair(fromToken, token)) + ) .map((token) => ({ ...token, label: ( diff --git a/packages/apps/config/bridge.ts b/packages/apps/config/bridge.ts index 4e9466a94..cb87dcce7 100644 --- a/packages/apps/config/bridge.ts +++ b/packages/apps/config/bridge.ts @@ -59,6 +59,12 @@ import { arbitrumGoerliZksyncGoerliLnBridge } from '../bridges/lnbridge/arbitrum import { zksyncGoerliArbitrumGoerliLnBridge } from '../bridges/lnbridge/zksync-arbitrum/config'; import { lineaGoerliZksyncGoerliLnBridge } from '../bridges/lnbridge/linea-zksync/config'; import { zksyncGoerliLineaGoerliLnBridge } from '../bridges/lnbridge/zksync-linea/config'; +import { mantleGoerliArbitrumGoerliLnBridge } from '../bridges/lnbridge/mantle-arbitrum/config'; +import { arbitrumGoerliMantleGoerliLnBridge } from '../bridges/lnbridge/arbitrum-mantle/config'; +import { mantleGoerliGoerliLnBridge } from '../bridges/lnbridge/mantle-ethereum/config'; +import { goerliMantleGoerliLnBridge } from '../bridges/lnbridge/ethereum-mantle/config'; +import { mantleGoerliLineaGoerliLnBridge } from '../bridges/lnbridge/mantle-linea/config'; +import { lineaGoerliMantleGoerliLnBridge } from '../bridges/lnbridge/linea-mantle/config'; const formalBridges = [ arbitrumAstar, @@ -130,6 +136,12 @@ const testBridges = [ zksyncGoerliArbitrumGoerliLnBridge, lineaGoerliZksyncGoerliLnBridge, zksyncGoerliLineaGoerliLnBridge, + mantleGoerliArbitrumGoerliLnBridge, + arbitrumGoerliMantleGoerliLnBridge, + mantleGoerliGoerliLnBridge, + goerliMantleGoerliLnBridge, + mantleGoerliLineaGoerliLnBridge, + lineaGoerliMantleGoerliLnBridge, ]; export const BRIDGES = (() => { diff --git a/packages/apps/model/tx.ts b/packages/apps/model/tx.ts index fd4223899..6750572e4 100644 --- a/packages/apps/model/tx.ts +++ b/packages/apps/model/tx.ts @@ -5,8 +5,10 @@ import { CrossChainDirection, CrossToken } from 'shared/model/bridge/cross-chain // lnbridge snapshot parameter interface Snapshot { + remoteChainId: BigNumber; relayer: string; sourceToken: string; + targetToken: string; transferId: string; depositedMargin: BigNumber; totalFee: BigNumber; diff --git a/packages/apps/public/image/mantle.svg b/packages/apps/public/image/mantle.svg new file mode 100644 index 000000000..8d722321a --- /dev/null +++ b/packages/apps/public/image/mantle.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/apps/public/image/mnt.svg b/packages/apps/public/image/mnt.svg new file mode 100644 index 000000000..dbbf58c4d --- /dev/null +++ b/packages/apps/public/image/mnt.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/apps/utils/validate.ts b/packages/apps/utils/validate.ts index 7badd376b..a524e9f0c 100644 --- a/packages/apps/utils/validate.ts +++ b/packages/apps/utils/validate.ts @@ -1,19 +1,11 @@ import { isAddress } from 'ethers/lib/utils'; -import { CrossOverview, Network, PolkadotChainConfig, TokenWithBridgesInfo } from 'shared/model'; +import { Network, PolkadotChainConfig, TokenWithBridgesInfo } from 'shared/model'; import { isSS58Address } from 'shared/utils/helper/validator'; import { isPolkadotNetwork } from 'shared/utils/network/network'; import { chainConfigs } from './network'; -export const isTransferableTokenPair = (token1: TokenWithBridgesInfo, token2: TokenWithBridgesInfo): boolean => { - const check = (token: TokenWithBridgesInfo) => (item: CrossOverview) => - item.partner.name === token.host && item.partner.symbol === token.symbol; - - const inToken1 = check(token1); - const inToken2 = check(token2); - const overviewList1 = token1.cross.filter(inToken2); - const overviewList2 = token2.cross.filter(inToken1); - - return !!overviewList1.length && !!overviewList2.length; +export const isTransferableTokenPair = (fromToken: TokenWithBridgesInfo, toToken: TokenWithBridgesInfo): boolean => { + return fromToken.cross.some(({ partner }) => partner.name === toToken.host && partner.symbol === toToken.symbol); }; export const isValidAddressStrict = (address: string, network: Network): boolean => { diff --git a/packages/shared/components/widget/ExplorerLink.tsx b/packages/shared/components/widget/ExplorerLink.tsx index 1a579df51..8f77a3310 100644 --- a/packages/shared/components/widget/ExplorerLink.tsx +++ b/packages/shared/components/widget/ExplorerLink.tsx @@ -94,6 +94,8 @@ export function ExplorerLink({ linea: `https://lineascan.build/tx/${txHash}`, 'zksync-goerli': `https://goerli.explorer.zksync.io/tx/${txHash}`, zksync: `https://explorer.zksync.io/tx/${txHash}`, + mantle: `https://explorer.mantle.xyz/tx/${txHash}`, + 'mantle-goerli': `https://explorer.testnet.mantle.xyz/tx/${txHash}`, }; const href = diff --git a/packages/shared/config/network/arbitrum-goerli.ts b/packages/shared/config/network/arbitrum-goerli.ts index ebf15b6eb..bd36c665a 100644 --- a/packages/shared/config/network/arbitrum-goerli.ts +++ b/packages/shared/config/network/arbitrum-goerli.ts @@ -25,37 +25,37 @@ export const arbitrumGoerliConfig: EthereumChainConfig = { { name: 'RING', decimals: 18, - cross: [ - { - category: 'helixLpBridge', - bridge: 'arbitrum-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'RING' }, - basefee: 5000, - index: 0, - deprecated: true, - }, - { - category: 'lnbridgev20-opposite', - bridge: 'arbitrum-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'RING' }, - basefee: 5000, - }, - ], + cross: [], type: 'erc20', host: 'arbitrum-goerli', logo: 'token-ring.svg', symbol: 'RING', address: '0xfbad806bdf9cec2943be281fb355da05068de925', }, + { + name: 'KTON', + decimals: 18, + cross: [], + type: 'erc20', + host: 'arbitrum-goerli', + logo: 'token-kton.svg', + symbol: 'KTON', + address: '', + }, + { + name: 'ETH', + decimals: 18, + cross: [], + type: 'native', + host: 'arbitrum-goerli', + logo: 'token-ethereum.svg', + symbol: 'ETH', + address: '', + }, { name: 'USDC', decimals: 6, cross: [ - { - category: 'lnbridgev20-opposite', - bridge: 'arbitrum-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'USDC' }, - }, { category: 'lnbridgev20-default', bridge: 'arbitrum-linea', @@ -63,15 +63,36 @@ export const arbitrumGoerliConfig: EthereumChainConfig = { }, { category: 'lnbridgev20-default', - bridge: 'arbitrum-zksync', - partner: { name: 'zksync-goerli', role: 'issuing', symbol: 'USDC' }, + bridge: 'arbitrum-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDC' }, }, ], type: 'erc20', host: 'arbitrum-goerli', logo: 'token-usdc.svg', symbol: 'USDC', - address: '0xEA70a40Df1432A1b38b916A51Fb81A4cc805a963', + address: '0x39dE82E1d9B8F62E11022FC3FC127a82F93fE47E', + }, + { + name: 'USDT', + decimals: 18, + cross: [ + { + category: 'lnbridgev20-default', + bridge: 'arbitrum-linea', + partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'arbitrum-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDT' }, + }, + ], + type: 'erc20', + host: 'arbitrum-goerli', + logo: 'token-usdt.svg', + symbol: 'USDT', + address: '0x6d828718c1097A4C573bc25c638Cc05bF10dFeAF', }, ], wallets: ['metamask', 'mathwallet-ethereum'], diff --git a/packages/shared/config/network/goerli.ts b/packages/shared/config/network/goerli.ts index 3f9b10a68..b3bb956da 100644 --- a/packages/shared/config/network/goerli.ts +++ b/packages/shared/config/network/goerli.ts @@ -27,18 +27,7 @@ export const goerliConfig: EthereumChainConfig = { { name: 'GoerliETH', decimals: 18, - cross: [ - { - category: 'lnbridgev20-default', - bridge: 'ethereum-zksync', - partner: { name: 'zksync-goerli', role: 'issuing', symbol: 'zkETH' }, - }, - { - category: 'lnbridgev20-default', - bridge: 'ethereum-linea', - partner: { name: 'linea-goerli', role: 'issuing', symbol: 'lineaETH' }, - }, - ], + cross: [], type: 'native', host: 'goerli', logo: 'token-ethereum.svg', @@ -66,21 +55,11 @@ export const goerliConfig: EthereumChainConfig = { name: 'RING', decimals: 18, cross: [ - { - category: 'lnbridgev20-default', - bridge: 'ethereum-arbitrum', - partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'RING' }, - }, { category: 'l1tol2', bridge: 'ethereum-arbitrum', partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'RING' }, }, - { - category: 'lnbridgev20-default', - bridge: 'ethereum-zksync', - partner: { name: 'zksync-goerli', role: 'issuing', symbol: 'RING' }, - }, ], type: 'erc20', host: 'goerli', @@ -99,31 +78,46 @@ export const goerliConfig: EthereumChainConfig = { }, { category: 'lnbridgev20-default', - bridge: 'ethereum-zksync', - partner: { name: 'zksync-goerli', role: 'issuing', symbol: 'USDC' }, + bridge: 'ethereum-linea', + partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDC' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'ethereum-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDC' }, }, ], type: 'erc20', host: 'goerli', logo: 'token-usdc.svg', symbol: 'USDC', - address: '0xd35CCeEAD182dcee0F148EbaC9447DA2c4D449c4', + address: '0x1a70127284B774fF4A4dbfe0115114642f0eca65', }, { - name: 'USD//C', - decimals: 6, + name: 'USDT', + decimals: 18, cross: [ + { + category: 'lnbridgev20-default', + bridge: 'ethereum-arbitrum', + partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'USDT' }, + }, { category: 'lnbridgev20-default', bridge: 'ethereum-linea', - partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDC' }, + partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'ethereum-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDT' }, }, ], type: 'erc20', host: 'goerli', - logo: 'token-usdc.svg', - symbol: 'USD//C', - address: '0x07865c6E87B9F70255377e024ace6630C1Eaa37F', + logo: 'token-usdt.svg', + symbol: 'USDT', + address: '0x2303e4d55BF16a897Cb5Ab71c6225399509d9314', }, ], wallets: ['metamask', 'mathwallet-ethereum'], diff --git a/packages/shared/config/network/index.ts b/packages/shared/config/network/index.ts index 77656f8f0..50576ba46 100644 --- a/packages/shared/config/network/index.ts +++ b/packages/shared/config/network/index.ts @@ -26,3 +26,5 @@ export * from './zksync-goerli'; export * from './zksync'; export * from './linea'; export * from './linea-goerli'; +export * from './mantle'; +export * from './mantle-goerli'; diff --git a/packages/shared/config/network/linea-goerli.ts b/packages/shared/config/network/linea-goerli.ts index 16f644ed5..f0f485590 100644 --- a/packages/shared/config/network/linea-goerli.ts +++ b/packages/shared/config/network/linea-goerli.ts @@ -47,13 +47,7 @@ export const lineaGoerliConfig: EthereumChainConfig = { { name: 'lineaETH', decimals: 18, - cross: [ - { - category: 'lnbridgev20-opposite', - bridge: 'linea-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'GoerliETH' }, - }, - ], + cross: [], type: 'native', host: 'linea-goerli', logo: 'token-ethereum.svg', @@ -67,7 +61,7 @@ export const lineaGoerliConfig: EthereumChainConfig = { { category: 'lnbridgev20-opposite', bridge: 'linea-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'USD//C' }, + partner: { name: 'goerli', role: 'issuing', symbol: 'USDC' }, }, { category: 'lnbridgev20-default', @@ -76,15 +70,41 @@ export const lineaGoerliConfig: EthereumChainConfig = { }, { category: 'lnbridgev20-default', - bridge: 'linea-zksync', - partner: { name: 'zksync-goerli', role: 'issuing', symbol: 'USDC' }, + bridge: 'linea-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDC' }, }, ], type: 'erc20', host: 'linea-goerli', logo: 'token-usdc.svg', symbol: 'USDC', - address: '0xB4257F31750961C8e536f5cfCBb3079437700416', + address: '0xb5E028f980dF5533cB0e8F04530B76637383d993', + }, + { + name: 'USDT', + decimals: 18, + cross: [ + { + category: 'lnbridgev20-opposite', + bridge: 'linea-ethereum', + partner: { name: 'goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'linea-arbitrum', + partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'linea-mantle', + partner: { name: 'mantle-goerli', role: 'issuing', symbol: 'USDT' }, + }, + ], + type: 'erc20', + host: 'linea-goerli', + logo: 'token-usdt.svg', + symbol: 'USDT', + address: '0xBC1A2f123Dc9CD2ec8d3cE42eF16c28F3C9bA686', }, ], wallets: ['metamask', 'mathwallet-ethereum'], diff --git a/packages/shared/config/network/linea.ts b/packages/shared/config/network/linea.ts index 4aab6b51c..498a043b4 100644 --- a/packages/shared/config/network/linea.ts +++ b/packages/shared/config/network/linea.ts @@ -60,7 +60,7 @@ export const lineaConfig: EthereumChainConfig = { cross: [], type: 'erc20', host: 'linea', - logo: 'token-usdt.svg', + logo: 'token-usdc.svg', symbol: 'USDC', address: '', }, diff --git a/packages/shared/config/network/mantle-goerli.ts b/packages/shared/config/network/mantle-goerli.ts new file mode 100644 index 000000000..a1a5d0871 --- /dev/null +++ b/packages/shared/config/network/mantle-goerli.ts @@ -0,0 +1,113 @@ +import { hexValue } from 'ethers/lib/utils'; +import { EthereumChainConfig } from '../../model'; + +export const mantleGoerliConfig: EthereumChainConfig = { + ethereumChain: { + // eslint-disable-next-line no-magic-numbers + chainId: hexValue(5001), + chainName: 'Mantle Testnet', + nativeCurrency: { + decimals: 18, + symbol: 'MNT', + }, + rpcUrls: ['https://rpc.testnet.mantle.xyz'], + }, + isTest: true, + logos: [{ name: 'mantle.svg', type: 'main' }], + name: 'mantle-goerli', + fullName: 'Mantle Testnet', + provider: { + https: 'https://rpc.testnet.mantle.xyz', + wss: 'wss://rpc.testnet.mantle.xyz', + }, + social: { + portal: 'https://www.mantle.xyz/', + github: 'https://github.com/mantlenetworkio', + twitter: 'https://twitter.com/0xMantle', + }, + tokens: [ + { + name: 'RING', + decimals: 18, + cross: [], + type: 'erc20', + host: 'mantle-goerli', + logo: 'token-ring.svg', + symbol: 'RING', + address: '', + }, + { + name: 'KTON', + decimals: 18, + cross: [], + type: 'erc20', + host: 'mantle-goerli', + logo: 'token-kton.svg', + symbol: 'KTON', + address: '', + }, + { + name: 'MNT', + decimals: 18, + cross: [], + type: 'native', + host: 'mantle-goerli', + logo: 'mnt.svg', + symbol: 'MNT', + address: '', + }, + { + name: 'USDC', + decimals: 6, + cross: [ + { + category: 'lnbridgev20-default', + bridge: 'mantle-ethereum', + partner: { name: 'goerli', role: 'issuing', symbol: 'USDC' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'mantle-linea', + partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDC' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'mantle-arbitrum', + partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'USDC' }, + }, + ], + type: 'erc20', + host: 'mantle-goerli', + logo: 'token-usdc.svg', + symbol: 'USDC', + address: '0x0258Eb547bFEd540ed17843658C018569fe1E328', + }, + { + name: 'USDT', + decimals: 18, + cross: [ + { + category: 'lnbridgev20-default', + bridge: 'mantle-ethereum', + partner: { name: 'goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'mantle-linea', + partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDT' }, + }, + { + category: 'lnbridgev20-default', + bridge: 'mantle-arbitrum', + partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'USDT' }, + }, + ], + type: 'erc20', + host: 'mantle-goerli', + logo: 'token-usdt.svg', + symbol: 'USDT', + address: '0x5F8D4232367759bCe5d9488D3ade77FCFF6B9b6B', + }, + ], + wallets: ['metamask', 'mathwallet-ethereum'], +}; diff --git a/packages/shared/config/network/mantle.ts b/packages/shared/config/network/mantle.ts new file mode 100644 index 000000000..6504c5dd4 --- /dev/null +++ b/packages/shared/config/network/mantle.ts @@ -0,0 +1,81 @@ +import { hexValue } from 'ethers/lib/utils'; +import { EthereumChainConfig } from '../../model'; + +export const mantleConfig: EthereumChainConfig = { + ethereumChain: { + // eslint-disable-next-line no-magic-numbers + chainId: hexValue(5000), + chainName: 'Mantle', + nativeCurrency: { + decimals: 18, + symbol: 'MNT', + }, + rpcUrls: ['https://rpc.mantle.xyz'], + }, + isTest: false, + logos: [{ name: 'mantle.svg', type: 'main' }], + name: 'mantle', + fullName: 'Mantle', + provider: { + https: 'https://rpc.mantle.xyz', + wss: 'wss://rpc.mantle.xyz', + }, + social: { + portal: 'https://www.mantle.xyz/', + github: 'https://github.com/mantlenetworkio', + twitter: 'https://twitter.com/0xMantle', + }, + tokens: [ + { + name: 'RING', + decimals: 18, + cross: [], + type: 'erc20', + host: 'mantle', + logo: 'token-ring.svg', + symbol: 'RING', + address: '', + }, + { + name: 'KTON', + decimals: 18, + cross: [], + type: 'erc20', + host: 'mantle', + logo: 'token-kton.svg', + symbol: 'KTON', + address: '', + }, + { + name: 'MNT', + decimals: 18, + cross: [], + type: 'native', + host: 'mantle', + logo: 'mnt.svg', + symbol: 'MNT', + address: '', + }, + { + name: 'USDC', + decimals: 6, + cross: [], + type: 'erc20', + host: 'mantle', + logo: 'token-usdc.svg', + symbol: 'USDC', + address: '', + }, + { + name: 'USDT', + decimals: 6, + cross: [], + type: 'erc20', + host: 'mantle', + logo: 'token-usdt.svg', + symbol: 'USDT', + address: '', + }, + ], + wallets: ['metamask', 'mathwallet-ethereum'], +}; diff --git a/packages/shared/config/network/networks.ts b/packages/shared/config/network/networks.ts index 8ea0570bb..b6f6fd6b2 100644 --- a/packages/shared/config/network/networks.ts +++ b/packages/shared/config/network/networks.ts @@ -33,6 +33,8 @@ import { zksyncGoerliConfig } from './zksync-goerli'; import { zksyncConfig } from './zksync'; import { lineaConfig } from './linea'; import { lineaGoerliConfig } from './linea-goerli'; +// import { mantleConfig } from './mantle'; +import { mantleGoerliConfig } from './mantle-goerli'; export const SYSTEM_CHAIN_CONFIGURATIONS: (EthereumChainConfig | PolkadotChainConfig | ParachainChainConfig)[] = [ arbitrumConfig, @@ -60,6 +62,7 @@ export const SYSTEM_CHAIN_CONFIGURATIONS: (EthereumChainConfig | PolkadotChainCo zksyncConfig, lineaGoerliConfig, lineaConfig, + mantleGoerliConfig, ]; export const knownParachainNetworks: ParachainNetwork[] = ['crab-parachain', 'karura', 'khala', 'moonriver', 'shiden']; @@ -91,6 +94,7 @@ export const knownEthereumNetworks: (DVMNetwork | EthereumTypeNetwork)[] = [ 'zksync', 'linea-goerli', 'linea', + 'mantle-goerli', ...knownDVMNetworks, ...knownParachainEthereumCompatibleNetworks, ]; diff --git a/packages/shared/config/network/zksync-goerli.ts b/packages/shared/config/network/zksync-goerli.ts index 9ab213da6..70bdb9294 100644 --- a/packages/shared/config/network/zksync-goerli.ts +++ b/packages/shared/config/network/zksync-goerli.ts @@ -25,14 +25,7 @@ export const zksyncGoerliConfig: EthereumChainConfig = { { name: 'RING', decimals: 18, - cross: [ - { - category: 'lnbridgev20-opposite', - bridge: 'zksync-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'RING' }, - basefee: 5000, - }, - ], + cross: [], type: 'erc20', host: 'zksync-goerli', logo: 'token-ring.svg', @@ -52,13 +45,7 @@ export const zksyncGoerliConfig: EthereumChainConfig = { { name: 'zkETH', decimals: 18, - cross: [ - { - category: 'lnbridgev20-opposite', - bridge: 'zksync-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'GoerliETH' }, - }, - ], + cross: [], type: 'native', host: 'zksync-goerli', logo: 'token-ethereum.svg', @@ -68,23 +55,7 @@ export const zksyncGoerliConfig: EthereumChainConfig = { { name: 'USDC', decimals: 6, - cross: [ - { - category: 'lnbridgev20-opposite', - bridge: 'zksync-ethereum', - partner: { name: 'goerli', role: 'issuing', symbol: 'USDC' }, - }, - { - category: 'lnbridgev20-default', - bridge: 'zksync-arbitrum', - partner: { name: 'arbitrum-goerli', role: 'issuing', symbol: 'USDC' }, - }, - { - category: 'lnbridgev20-default', - bridge: 'zksync-linea', - partner: { name: 'linea-goerli', role: 'issuing', symbol: 'USDC' }, - }, - ], + cross: [], type: 'erc20', host: 'zksync-goerli', logo: 'token-usdc.svg', diff --git a/packages/shared/config/theme.ts b/packages/shared/config/theme.ts index 3db7d2364..0edc0a4e3 100644 --- a/packages/shared/config/theme.ts +++ b/packages/shared/config/theme.ts @@ -21,6 +21,8 @@ export const NETWORK_LIGHT_THEME: NetworkThemeConfig<{ [key in keyof typeof darw 'arbitrum-goerli': pangolin, 'zksync-goerli': pangolin, 'linea-goerli': pangolin, + mantle: pangolin, + 'mantle-goerli': pangolin, linea: pangolin, zksync: pangolin, arbitrum: pangolin, @@ -60,6 +62,8 @@ export const NETWORK_DARK_THEME: NetworkThemeConfig<{ [key in keyof typeof darwi 'arbitrum-goerli': pangolinDark, 'zksync-goerli': pangolinDark, 'linea-goerli': pangolinDark, + mantle: pangolinDark, + 'mantle-goerli': pangolinDark, linea: pangolinDark, zksync: pangolinDark, arbitrum: pangolinDark, @@ -98,6 +102,8 @@ export const chainColors: { [key in Network]: string } = { 'arbitrum-goerli': '#2c384b', 'zksync-goerli': '#2c384b', 'linea-goerli': '#2c384b', + mantle: '#2c384b', + 'mantle-goerli': '#2c384b', linea: '#2c384b', zksync: '#2c384b', arbitrum: '#2c384b', diff --git a/packages/shared/model/bridge/supports.ts b/packages/shared/model/bridge/supports.ts index 530875134..a7d981359 100644 --- a/packages/shared/model/bridge/supports.ts +++ b/packages/shared/model/bridge/supports.ts @@ -63,4 +63,12 @@ export type BridgeName = | 'arbitrum-zksync' | 'zksync-arbitrum' | 'linea-zksync' - | 'zksync-linea'; + | 'zksync-linea' + | 'mantle-ethereum' + | 'ethereum-mantle' + | 'mantle-linea' + | 'linea-mantle' + | 'mantle-arbitrum' + | 'arbitrum-mantle' + | 'mantle-zksync' + | 'zksync-mantle'; diff --git a/packages/shared/model/network/network.ts b/packages/shared/model/network/network.ts index 38e727160..4d13b9ab8 100644 --- a/packages/shared/model/network/network.ts +++ b/packages/shared/model/network/network.ts @@ -28,6 +28,8 @@ export type EthereumTypeNetwork = | 'goerli' | 'linea' | 'linea-goerli' + | 'mantle' + | 'mantle-goerli' | ParachainEthereumCompatibleNetwork | DVMNetwork; From add3601ccbe2a047b166b63b4172a534de6083ef Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Tue, 12 Sep 2023 13:18:24 +0800 Subject: [PATCH 2/3] fix contract address --- .../apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts | 2 +- .../apps/bridges/lnbridge/ethereum-linea/config/bridge.ts | 4 ++-- .../apps/bridges/lnbridge/linea-ethereum/config/bridge.ts | 4 ++-- packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts | 2 +- .../apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts | 2 +- .../apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts | 2 +- packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts index fc0a8dc24..2b63d6e5c 100644 --- a/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts @@ -12,7 +12,7 @@ const arbitrumMantleConfig: ArbitrumMantleBridgeConfig = { const arbitrumGoerliMantleGoerliConfig: ArbitrumMantleBridgeConfig = { contracts: { - backing: '0x504F597CfB0A32704AA6533Fb75dCD60dB982836', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/ethereum-linea/config/bridge.ts b/packages/apps/bridges/lnbridge/ethereum-linea/config/bridge.ts index c4f675b78..61a638dba 100644 --- a/packages/apps/bridges/lnbridge/ethereum-linea/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/ethereum-linea/config/bridge.ts @@ -11,8 +11,8 @@ const ethereumLineaConfig: EthereumLineaBridgeConfig = { const goerliLineaGoerliConfig: EthereumLineaBridgeConfig = { contracts: { - backing: '0x5A351EA4F4128F58EA13DDa52E3d1842c0b3B690', - issuing: '0xeA5f0a09A8723444965FDd6f76523C338faB00f7', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', + issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/linea-ethereum/config/bridge.ts b/packages/apps/bridges/lnbridge/linea-ethereum/config/bridge.ts index dd62a5618..c85d1ec87 100644 --- a/packages/apps/bridges/lnbridge/linea-ethereum/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/linea-ethereum/config/bridge.ts @@ -11,8 +11,8 @@ const lineaEthereumConfig: LineaEthereumBridgeConfig = { const lineaGoerliGoerliConfig: LineaEthereumBridgeConfig = { contracts: { - backing: '0x9C80EdD342b5D179c3a87946fC1F0963BfcaAa09', - issuing: '0x91bdd735Dc214876605C18A57C7841CFF7eE959a', + backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts b/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts index 4d3b0feec..9f937e3ec 100644 --- a/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts @@ -11,7 +11,7 @@ const lineaMantleConfig: LineaMantleBridgeConfig = { const lineaGoerliMantleGoerliConfig: LineaMantleBridgeConfig = { contracts: { - backing: '0xE4B4b7707450b60421b5d7DE372fA5920F2bBDa8', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts index 346279f86..026757a0c 100644 --- a/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/mantle-arbitrum/config/bridge.ts @@ -12,7 +12,7 @@ const mantleArbitrumConfig: MantleArbitrumBridgeConfig = { const mantleGoerliArbitrumGoerliConfig: MantleArbitrumBridgeConfig = { contracts: { - backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts index dc58806f9..fce579828 100644 --- a/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/mantle-ethereum/config/bridge.ts @@ -12,7 +12,7 @@ const mantleEthereumConfig: MantleEthereumBridgeConfig = { const mantleGoerliGoerliConfig: MantleEthereumBridgeConfig = { contracts: { - backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', issuing: '', }, }; diff --git a/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts b/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts index 86279c876..0c3405241 100644 --- a/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts +++ b/packages/apps/bridges/lnbridge/mantle-linea/config/bridge.ts @@ -12,7 +12,7 @@ const mantleLineaConfig: MantleLineaBridgeConfig = { const mantleGoerliLineaGoerliConfig: MantleLineaBridgeConfig = { contracts: { - backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D', + backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E', issuing: '', }, }; From 7bcba2af547158084615e40d77190644d3287979 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Tue, 12 Sep 2023 13:18:44 +0800 Subject: [PATCH 3/3] fix unit test --- packages/apps/__tests__/bridge.spec.ts | 5 +++-- packages/apps/__tests__/network.spec.ts | 4 ++-- packages/shared/__tests__/components/ExplorerLink.spec.tsx | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/apps/__tests__/bridge.spec.ts b/packages/apps/__tests__/bridge.spec.ts index 3177e9096..05c2c169e 100644 --- a/packages/apps/__tests__/bridge.spec.ts +++ b/packages/apps/__tests__/bridge.spec.ts @@ -38,6 +38,7 @@ const mapToTestChain: { [key: string]: string } = { arbitrum: 'arbitrum-goerli', zksync: 'zksync-goerli', linea: 'linea-goerli', + mantle: 'mantle-goerli', }; describe('bridge utils', () => { @@ -49,12 +50,12 @@ describe('bridge utils', () => { console.log('🌉 All cross-chain directions to be tested', allDirections); it('should support bridge count: ', () => { - expect(testBridges).toHaveLength(6); + expect(testBridges).toHaveLength(9); expect(formalBridges).toHaveLength(47); }); it('should support transfer count: ', () => { - expect(allDirections).toHaveLength(132); + expect(allDirections).toHaveLength(144); }); it('Should correct bridge category name', () => { diff --git a/packages/apps/__tests__/network.spec.ts b/packages/apps/__tests__/network.spec.ts index 13b08c251..0933f35f2 100644 --- a/packages/apps/__tests__/network.spec.ts +++ b/packages/apps/__tests__/network.spec.ts @@ -38,7 +38,7 @@ describe('network utils', () => { .find((item) => item.partner.name === arrival); it('should contains chains count: ', () => { - expect(chainConfigs).toHaveLength(19); + expect(chainConfigs).toHaveLength(20); }); it('crab-dvm contains 5 leafs and substrate-substrateDVM deprecated', () => { @@ -183,7 +183,7 @@ describe('network utils', () => { const group = data.find((item) => item[0] === 'goerli'); expect(group).not.toEqual(undefined); - expect(uniq(sort(group![1]))).toEqual(sort(['linea-goerli', 'arbitrum-goerli', 'zksync-goerli'])); + expect(uniq(sort(group![1]))).toEqual(sort(['linea-goerli', 'arbitrum-goerli', 'zksync-goerli', 'mantle-goerli'])); }); it('pangoro-dvm contains 0 leafs', () => { diff --git a/packages/shared/__tests__/components/ExplorerLink.spec.tsx b/packages/shared/__tests__/components/ExplorerLink.spec.tsx index 95200c7cf..ab7682a3c 100644 --- a/packages/shared/__tests__/components/ExplorerLink.spec.tsx +++ b/packages/shared/__tests__/components/ExplorerLink.spec.tsx @@ -204,6 +204,8 @@ describe('', () => { linea: `https://lineascan.build/tx/0x123456`, 'zksync-goerli': `https://goerli.explorer.zksync.io/tx/0x123456`, zksync: `https://explorer.zksync.io/tx/0x123456`, + mantle: `https://explorer.mantle.xyz/tx/0x123456`, + 'mantle-goerli': `https://explorer.testnet.mantle.xyz/tx/0x123456`, }; const expected = explorers[config.name] ?? href;