-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes KILTprotocol/ticket#3467. Not meant to be merged until all other stacked PRs will be merged into this. Adds the first round of features to the swap pallet, specifically it includes a swap pool that supports only the runtime local currency, swappable 1:1 (not configurable yet) with a configurable remote token. The XCM fees are paid in a local fungible token as injected by the runtime. The pallet also exposes two implementations of the `IsReserve` trait that must be added to the runtime to allow the configured tokens (to swap back to local currency and to pay for XCM fees) to be reserve-transferred to this chain. That code is not yet part of this PR. Additional TODOs for the pallet is both within the code where applicable, and in the pallet `README.md` file. --------- Co-authored-by: Adel Golghalyani <48685760+Ad96el@users.noreply.github.com> Co-authored-by: Adel Golghalyani <ad96el@gmail.com>
- Loading branch information
1 parent
39b3a6f
commit fdb57ca
Showing
117 changed files
with
16,624 additions
and
338 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,58 @@ | ||
import { setupContext, SetupOption } from '@acala-network/chopsticks-testing' | ||
import type { Config } from './types.js' | ||
import { initialBalanceDOT, initialBalanceHDX, initialBalanceKILT, toNumber } from '../utils.js' | ||
|
||
/// Options used to create the HydraDx context | ||
export const options: SetupOption = { | ||
endpoint: process.env.BASILISK_WS || ['wss://basilisk-rococo-rpc.play.hydration.cloud'], | ||
db: './db/basilisk.db.sqlite', | ||
port: toNumber(process.env.HYDRADX_PORT) || 9005, | ||
} | ||
|
||
// On Basilisk, there is only KSM. We use that currency and treat it as ROC, since the location is {parents: 1, interior: Here} | ||
export const dotTokenId = 5 | ||
|
||
export const eKILTTokenId = 90 | ||
|
||
/// Assigns the native tokens to an accounts | ||
export function assignNativeTokensToAccounts(addr: string[], balance: bigint = initialBalanceHDX) { | ||
return { | ||
System: { | ||
Account: addr.map((address) => [[address], { providers: 1, data: { free: balance } }]), | ||
}, | ||
} | ||
} | ||
|
||
/// Assigns ROCs tokens to an accounts | ||
export function assignRocTokensToAccounts(addr: string[], balance: bigint = initialBalanceDOT) { | ||
return { | ||
Tokens: { | ||
Accounts: addr.map((address) => [[address, dotTokenId], { free: balance }]), | ||
}, | ||
} | ||
} | ||
|
||
export function createRemoteAsset( | ||
addr: string[], | ||
assetLocation: Record<string, unknown>, | ||
balance: bigint = initialBalanceKILT | ||
) { | ||
return { | ||
assetRegistry: { | ||
assetIds: [[['eKILT'], 90]], | ||
assetLocations: [[[90], assetLocation]], | ||
assetMetadataMap: [[[90], { symbol: 'eKILT', decimals: 15 }]], | ||
}, | ||
|
||
tokens: { | ||
accounts: addr.map((acc) => [[acc, 90], { free: balance }]), | ||
}, | ||
} | ||
} | ||
|
||
/// Basilisk ParaId | ||
export const paraId = 2090 | ||
|
||
export async function getContext(): Promise<Config> { | ||
return setupContext(options) | ||
} |
Oops, something went wrong.