-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate Routes between MRL and XCM and get moon chain fee balance in…
… source (#366) * add peaq evm alphanet configuration * Add moonChainFee and separate MrlChainRoute from ChainRoute * Update packages/mrl/src/getTransferData/getSourceData.ts Co-authored-by: elmar <[email protected]> * remove optional in moonChainfee --------- Co-authored-by: elmar <[email protected]>
- Loading branch information
Showing
15 changed files
with
214 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import type { ChainRoutes } from '../types/ChainRoutes'; | ||
import type { MrlChainRoutes } from '../types/MrlChainRoutes'; | ||
import { fantomTestnetRoutes } from './fantomTestnet'; | ||
import { moonbaseAlphaRoutes } from './moonbaseAlpha'; | ||
import { moonbaseBetaRoutes } from './moonbaseBeta'; | ||
import { peaqAlphanetRoutes } from './peaqAlphanet'; | ||
import { peaqEvmAlphanetRoutes } from './peaqEvmAlphanet'; | ||
|
||
export const mrlRoutesList: ChainRoutes[] = [ | ||
export const mrlRoutesList: MrlChainRoutes[] = [ | ||
fantomTestnetRoutes, | ||
moonbaseAlphaRoutes, | ||
moonbaseBetaRoutes, | ||
peaqAlphanetRoutes, | ||
peaqEvmAlphanetRoutes, | ||
]; | ||
|
||
export const mrlRoutesMap = new Map<string, ChainRoutes>( | ||
export const mrlRoutesMap = new Map<string, MrlChainRoutes>( | ||
mrlRoutesList.map((config) => [config.chain.key, config]), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { BalanceBuilder, MrlBuilder } from '@moonbeam-network/xcm-builder'; | ||
import { agng, dev, ftm, ftmwh } from '../assets'; | ||
import { fantomTestnet, peaqEvmAlphanet } from '../chains'; | ||
import { MrlChainRoutes } from '../types/MrlChainRoutes'; | ||
|
||
export const peaqEvmAlphanetRoutes = new MrlChainRoutes({ | ||
chain: peaqEvmAlphanet, | ||
routes: [ | ||
{ | ||
source: { | ||
asset: ftmwh, | ||
balance: BalanceBuilder().evm().erc20(), | ||
destinationFee: { | ||
asset: ftmwh, | ||
balance: BalanceBuilder().evm().erc20(), | ||
}, | ||
moonChainFee: { | ||
asset: dev, | ||
balance: BalanceBuilder().evm().erc20(), | ||
}, | ||
fee: { | ||
asset: agng, | ||
balance: BalanceBuilder().substrate().system().accountEvmTo32(), | ||
}, | ||
}, | ||
destination: { | ||
asset: ftm, | ||
chain: fantomTestnet, | ||
balance: BalanceBuilder().evm().native(), | ||
fee: { | ||
asset: ftm, | ||
amount: 0, | ||
}, | ||
}, | ||
mrl: { | ||
isAutomaticPossible: true, | ||
transfer: MrlBuilder() | ||
.wormhole() | ||
.contract() | ||
.TokenBridgeRelayer() | ||
.transferTokensWithRelay(), | ||
moonChain: { | ||
asset: ftmwh, | ||
fee: { | ||
asset: dev, | ||
amount: 0.1, | ||
balance: BalanceBuilder().substrate().system().account(), | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { BalanceConfigBuilder } from '@moonbeam-network/xcm-builder'; | ||
import type { Asset } from '@moonbeam-network/xcm-types'; | ||
import { | ||
AssetRoute, | ||
type AssetRouteConstructorParams, | ||
type SourceConfig, | ||
} from './AssetRoute'; | ||
|
||
export interface MrlAssetRouteConstructorParams | ||
extends AssetRouteConstructorParams { | ||
source: MrlSourceConfig; | ||
} | ||
|
||
export interface MrlSourceConfig extends SourceConfig { | ||
moonChainFee?: { | ||
asset: Asset; | ||
balance: BalanceConfigBuilder; | ||
}; | ||
} | ||
|
||
export class MrlAssetRoute extends AssetRoute { | ||
readonly source: MrlSourceConfig; | ||
|
||
constructor({ | ||
source, | ||
destination, | ||
contract, | ||
extrinsic, | ||
mrl, | ||
}: MrlAssetRouteConstructorParams & { source: MrlSourceConfig }) { | ||
super({ source, destination, contract, extrinsic, mrl }); | ||
this.source = source; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ChainRoutes, type ChainRoutesConstructorParams } from './ChainRoutes'; | ||
import { | ||
MrlAssetRoute, | ||
type MrlAssetRouteConstructorParams, | ||
type MrlSourceConfig, | ||
} from './MrlAssetRoute'; | ||
|
||
export interface MrlChainRoutesConstructorParams | ||
extends ChainRoutesConstructorParams { | ||
routes: MrlRoutesParam[]; | ||
} | ||
|
||
interface MrlRoutesParam | ||
extends Omit<MrlAssetRouteConstructorParams, 'source'> { | ||
source: Omit<MrlSourceConfig, 'chain'>; | ||
} | ||
|
||
export class MrlChainRoutes extends ChainRoutes { | ||
readonly #routes: Map<string, MrlAssetRoute>; | ||
|
||
constructor({ chain, routes }: MrlChainRoutesConstructorParams) { | ||
super({ chain, routes }); | ||
this.#routes = new Map( | ||
routes.map(({ source, destination, contract, extrinsic, mrl }) => [ | ||
`${source.asset.key}-${destination.chain.key}`, | ||
new MrlAssetRoute({ | ||
source: { ...source, chain }, | ||
destination, | ||
contract, | ||
extrinsic, | ||
mrl, | ||
}), | ||
]), | ||
); | ||
} | ||
|
||
getRoutes(): MrlAssetRoute[] { | ||
return Array.from(this.#routes.values()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.