diff --git a/bouncer/commands/run_test.ts b/bouncer/commands/run_test.ts index d969b47db98..fe73e8618d8 100755 --- a/bouncer/commands/run_test.ts +++ b/bouncer/commands/run_test.ts @@ -20,7 +20,6 @@ import { testBrokerFeeCollection } from '../tests/broker_fee_collection'; import { testBtcUtxoConsolidation } from '../tests/btc_utxo_consolidation'; -import { testDCASwaps } from '../tests/DCA_test'; import { testEvmDeposits } from '../tests/evm_deposits'; import { testFillOrKill } from '../tests/fill_or_kill'; import { testFundRedeem } from '../tests/fund_redeem'; @@ -40,6 +39,7 @@ import { ConsoleColors, ConsoleLogColors } from '../shared/utils'; import { testDeltaBasedIngress } from '../tests/delta_based_ingress'; import { testCancelOrdersBatch } from '../tests/create_and_delete_multiple_orders'; import { depositChannelCreation } from '../tests/request_swap_deposit_address_with_affiliates'; +import { testDCASwaps } from '../tests/DCA_test'; async function main() { const testName = process.argv[2]; diff --git a/bouncer/shared/setup_swaps.ts b/bouncer/shared/setup_swaps.ts index 4a52f4e7f48..d99505f121e 100755 --- a/bouncer/shared/setup_swaps.ts +++ b/bouncer/shared/setup_swaps.ts @@ -44,23 +44,33 @@ export async function setupSwaps(): Promise { createLpPool('SolUsdc', price.get('SolUsdc')!), ]); - console.log('LP Pools created'); + const lp1Deposits = Promise.all([ + depositLiquidity('Usdc', deposits.get('Usdc')!, false, '//LP_1'), + depositLiquidity('Eth', deposits.get('Eth')!, false, '//LP_1'), + depositLiquidity('Dot', deposits.get('Dot')!, false, '//LP_1'), + depositLiquidity('Btc', deposits.get('Btc')!, false, '//LP_1'), + depositLiquidity('Flip', deposits.get('Flip')!, false, '//LP_1'), + depositLiquidity('Usdt', deposits.get('Usdt')!, false, '//LP_1'), + depositLiquidity('ArbEth', deposits.get('ArbEth')!, false, '//LP_1'), + depositLiquidity('ArbUsdc', deposits.get('ArbUsdc')!, false, '//LP_1'), + depositLiquidity('Sol', deposits.get('Sol')!, false, '//LP_1'), + depositLiquidity('SolUsdc', deposits.get('SolUsdc')!, false, '//LP_1'), + ]); - await Promise.all([ - // provide liquidity to LP_1 - depositLiquidity('Usdc', deposits.get('Usdc')!), - depositLiquidity('Eth', deposits.get('Eth')!), - depositLiquidity('Dot', deposits.get('Dot')!), - depositLiquidity('Btc', deposits.get('Btc')!), - depositLiquidity('Flip', deposits.get('Flip')!), - depositLiquidity('Usdt', deposits.get('Usdt')!), - depositLiquidity('ArbEth', deposits.get('ArbEth')!), - depositLiquidity('ArbUsdc', deposits.get('ArbUsdc')!), - depositLiquidity('Sol', deposits.get('Sol')!), - depositLiquidity('SolUsdc', deposits.get('SolUsdc')!), + const lpApiDeposits = Promise.all([ + depositLiquidity('Usdc', 1000, false, '//LP_API'), + depositLiquidity('Eth', 100, false, '//LP_API'), + depositLiquidity('Dot', 2000, false, '//LP_API'), + depositLiquidity('Btc', 10, false, '//LP_API'), + depositLiquidity('Flip', 10000, false, '//LP_API'), + depositLiquidity('Usdt', 1000, false, '//LP_API'), + depositLiquidity('ArbEth', 10, false, '//LP_API'), + depositLiquidity('ArbUsdc', 1000, false, '//LP_API'), + depositLiquidity('Sol', 500, false, '//LP_API'), + depositLiquidity('SolUsdc', 1000, false, '//LP_API'), ]); - console.log('Liquidity provided'); + await Promise.all([lp1Deposits, lpApiDeposits]); await Promise.all([ rangeOrder('Eth', deposits.get('Eth')! * 0.9999), diff --git a/bouncer/shared/upgrade_network.ts b/bouncer/shared/upgrade_network.ts index d74a33a6a63..c7d1ab67caf 100755 --- a/bouncer/shared/upgrade_network.ts +++ b/bouncer/shared/upgrade_network.ts @@ -10,6 +10,7 @@ import { compileBinaries } from './utils/compile_binaries'; import { submitRuntimeUpgradeWithRestrictions } from './submit_runtime_upgrade'; import { execWithLog } from './utils/exec_with_log'; import { submitGovernanceExtrinsic } from './cf_governance'; +import { setupLpAccount } from './setup_lp_account'; async function readPackageTomlVersion(projectRoot: string): Promise { const data = await fs.readFile(path.join(projectRoot, '/state-chain/runtime/Cargo.toml'), 'utf8'); @@ -338,6 +339,19 @@ export async function upgradeNetworkPrebuilt( ); } + // Temp: until localnet/bouncer initialises to a version where the LP_API is funded already. + if (cleanOldVersion.startsWith('1.6')) { + console.log('Setting up LP account and adding liquidity for the LP-API.'); + // Liquidity is provided as part of the LP-API test setup. + await setupLpAccount('//LP_API'); + // Write LP_API key to keys/ so that the LP-API can use it - when upgrading the old version, which the upgrade-test is + // started from doesn't yet have this key. + await fs.writeFile( + `${localnetInitPath}/keys/LP_API`, + '8e1866e65039304e4142f09452a8305acd28d0ae0b833cd268b21a57d68782c1', + ); + } + if (cleanOldVersion === nodeVersion) { throw Error( 'The versions are the same. No need to upgrade. Please provide a different version.', diff --git a/bouncer/tests/all_concurrent_tests.ts b/bouncer/tests/all_concurrent_tests.ts index fd7bb601ea8..738886ca5f6 100755 --- a/bouncer/tests/all_concurrent_tests.ts +++ b/bouncer/tests/all_concurrent_tests.ts @@ -10,10 +10,10 @@ import { testBrokerFeeCollection } from './broker_fee_collection'; import { testBoostingSwap } from './boost'; import { observeBadEvent } from '../shared/utils/substrate'; import { testFillOrKill } from './fill_or_kill'; -import { testDCASwaps } from './DCA_test'; import { testCancelOrdersBatch } from './create_and_delete_multiple_orders'; import { testAllSwaps } from './all_swaps'; import { depositChannelCreation } from './request_swap_deposit_address_with_affiliates'; +import { testDCASwaps } from './DCA_test'; async function runAllConcurrentTests() { // Specify the number of nodes via providing an argument to this script. diff --git a/bouncer/tests/lp_api_test.ts b/bouncer/tests/lp_api_test.ts index d226fcfbd9c..1c82dccd80f 100644 --- a/bouncer/tests/lp_api_test.ts +++ b/bouncer/tests/lp_api_test.ts @@ -51,7 +51,7 @@ async function provideLiquidityAndTestAssetBalances() { amountToFineAmount(amountToProvide.toString(), assetDecimals('Eth')), ); // We have to wait finalization here because the LP API server is using a finalized block stream (This may change in PRO-777 PR#3986) - await depositLiquidity(testAsset, amountToProvide, true); + await depositLiquidity(testAsset, amountToProvide, true, '//LP_API'); // Wait for the LP API to get the balance update, just incase it was slower than us to see the event. let retryCount = 0; @@ -154,7 +154,7 @@ async function testTransferAsset() { const keyring = new Keyring({ type: 'sr25519' }); - const sourceLpAccount = keyring.createFromUri('//LP_1'); + const sourceLpAccount = keyring.createFromUri('//LP_API'); const destinationLpAccount = keyring.createFromUri('//LP_2'); const oldBalanceSource = await getLpBalance(sourceLpAccount.address); diff --git a/localnet/init/keys/LP_1 b/localnet/init/keys/LP_1 deleted file mode 100644 index f945bbb89ec..00000000000 --- a/localnet/init/keys/LP_1 +++ /dev/null @@ -1 +0,0 @@ -dd6a039fcf330d0eb32797fda2e992d7b59d52c7fb87ec83b33c6762f402a440 \ No newline at end of file diff --git a/localnet/init/keys/LP_API b/localnet/init/keys/LP_API new file mode 100644 index 00000000000..1beccab76b6 --- /dev/null +++ b/localnet/init/keys/LP_API @@ -0,0 +1 @@ +8e1866e65039304e4142f09452a8305acd28d0ae0b833cd268b21a57d68782c1 \ No newline at end of file diff --git a/localnet/init/scripts/start-lp-api.sh b/localnet/init/scripts/start-lp-api.sh index dabc16d1358..18256cad8eb 100755 --- a/localnet/init/scripts/start-lp-api.sh +++ b/localnet/init/scripts/start-lp-api.sh @@ -5,4 +5,4 @@ binary_location=$1 RUST_LOG=debug,jsonrpsee_types::params=trace $binary_location/chainflip-lp-api \ --port=10589 \ --state_chain.ws_endpoint=ws://localhost:9944 \ - --state_chain.signing_key_file $KEYS_DIR/LP_1 > /tmp/chainflip/chainflip-lp-api.$DATETIME.log 2>&1 & + --state_chain.signing_key_file $KEYS_DIR/LP_API > /tmp/chainflip/chainflip-lp-api.$DATETIME.log 2>&1 & diff --git a/state-chain/node/src/chain_spec/testnet.rs b/state-chain/node/src/chain_spec/testnet.rs index 58c6d8ccb6d..d0f1bfc37d7 100644 --- a/state-chain/node/src/chain_spec/testnet.rs +++ b/state-chain/node/src/chain_spec/testnet.rs @@ -127,6 +127,12 @@ pub const SNOW_WHITE_SR25519: [u8; 32] = pub fn extra_accounts() -> Vec<(AccountId, AccountRole, FlipBalance, Option>)> { vec![ + ( + get_account_id_from_seed::("LP_API"), + AccountRole::LiquidityProvider, + 100 * FLIPPERINOS_PER_FLIP, + Some(b"Chainflip Testnet LP API".to_vec()), + ), ( get_account_id_from_seed::("LP_1"), AccountRole::LiquidityProvider,