-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore - add helper script to configure a new testnet parachain #817
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
#!/usr/bin/env bash | ||
set -exo pipefail | ||
|
||
if ! [ -x "$(command -v polkadot-js-api)" ]; then | ||
echo 'Error: polkadot-js-api is not installed.' | ||
exit 1 | ||
fi | ||
|
||
RELAYCHAIN_WSS="${RELAYCHAIN_WSS:-wss://api-testnet.interlay.io/relaychain/}" | ||
PARACHAIN_WSS="${PARACHAIN_WSS:-wss://api-testnet.interlay.io/parachain/}" | ||
|
||
declare -A TOKEN_IDS | ||
TOKEN_IDS["DOT"]=0 | ||
TOKEN_IDS["INTERBTC"]=1 | ||
TOKEN_IDS["INTR"]=2 | ||
TOKEN_IDS["KSM"]=10 | ||
TOKEN_IDS["KBTC"]=11 | ||
TOKEN_IDS["KINT"]=12 | ||
|
||
WASM_FILENAME=$1 | ||
GENESIS_FILENAME=$2 | ||
|
||
if [ -z "${PARACHAIN_SEED}" ]; then | ||
echo "Env. PARACHAIN_SEED not set" | ||
exit 1 | ||
fi | ||
|
||
function setup_parachain { | ||
if [ -z "${WASM_FILENAME}" ] || [ ! -f ${WASM_FILENAME:1} ]; then | ||
echo "WASM file not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${GENESIS_FILENAME}" ] || [ ! -f ${GENESIS_FILENAME:1} ]; then | ||
echo "Genesis file not set" | ||
exit 1 | ||
fi | ||
|
||
# sudoScheduleParaInitialize(id, genesis) | ||
polkadot-js-api --ws $RELAYCHAIN_WSS --sudo --seed "//Alice" \ | ||
tx.parasSudoWrapper.sudoScheduleParaInitialize \ | ||
2121 \ | ||
"{ \"genesisHead\":\"${GENESIS_FILENAME?}\", \"validationCode\":\"${WASM_FILENAME?}\", \"parachain\": true }" | ||
|
||
# forceLease(para, leaser, amount, periodBegin, periodCount) | ||
polkadot-js-api --ws $RELAYCHAIN_WSS --sudo --seed "//Alice" \ | ||
tx.slots.forceLease \ | ||
2121 \ | ||
5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL \ | ||
0 \ | ||
1 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be 0 |
||
1000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use 100000 |
||
} | ||
|
||
function setup_foreign_assets { | ||
# assetRegistry.registerAsset(metadata, assetId) | ||
polkadot-js-api --ws "${PARACHAIN_WSS}" --sudo --seed "${PARACHAIN_SEED}" \ | ||
tx.assetRegistry.registerAsset \ | ||
'{ | ||
"decimals": 6, | ||
"name": "Tether USD", | ||
"symbol": "USDT", | ||
"existentialDeposit": 0, | ||
"location": null, | ||
"additional": { "feePerSecond": 8153838, "coingeckoId": "tether" } | ||
}' \ | ||
1 | ||
} | ||
|
||
function setup_vault_registry { | ||
# TODO | ||
} | ||
|
||
function fund_faucet_account { | ||
# Fund the faucet accounts with tokens | ||
TOKENS=( "KSM" "KINT" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add USDT and KBTC for Kintsugi. For Interlay we need DOT, IBTC, USDT and INTR. |
||
for T in "${TOKENS[@]}" | ||
do | ||
polkadot-js-api --ws "${PARACHAIN_WSS}" --sudo --seed "${PARACHAIN_SEED}" \ | ||
tx.tokens.setBalance \ | ||
5DqzGaydetDXGya818gyuHA7GAjEWRsQN6UWNKpvfgq2KyM7 \ | ||
"{ \"Token\": ${TOKEN_IDS[$T]} }" \ | ||
20000000000000 \ | ||
0 | ||
done | ||
} | ||
|
||
function setup_lending_markets { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lending markets are different between interlay and kintsugi testnets. So there needs to be a gate somewhere that sets up different markets. Interlay: DOT, IBTC, USDT, INTR. Also note that DOT, and INTR have just 10 decimals. Kintsugi: KSM, KBTC, USDT, KINT. |
||
# KSM | ||
polkadot-js-api --ws "${PARACHAIN_WSS}" --sudo --seed "${PARACHAIN_SEED}" \ | ||
tx.loans.addMarket \ | ||
"{ \"Token\": ${TOKEN_IDS["KSM"]} }" \ | ||
'{ | ||
"collateralFactor": 540000, | ||
"liquidationThreshold": 610000, | ||
"reserveFactor": 200000, | ||
"closeFactor": 500000, | ||
"liquidateIncentive": "1100000000000000000", | ||
"liquidateIncentiveReservedFactor": 25000, | ||
"rateModel": { | ||
"Jump": { | ||
"baseRate": 0, | ||
"jumpRate": "15000000000000000", | ||
"fullRate": "40000000000000000", | ||
"jumpUtilization": 900000 | ||
} | ||
}, | ||
"state": "Active", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the state has to be |
||
"supplyCap": "30000000000000000", | ||
"borrowCap": "30000000000000000", | ||
"lendTokenId": { | ||
"LendToken": 0 | ||
} | ||
}' | ||
|
||
# KBTC | ||
polkadot-js-api --ws "${PARACHAIN_WSS}" --sudo --seed "${PARACHAIN_SEED}" \ | ||
tx.loans.addMarket \ | ||
"{ \"Token\": ${TOKEN_IDS["KBTC"]} }" \ | ||
'{ | ||
"collateralFactor": 610000, | ||
"liquidationThreshold": 650000, | ||
"reserveFactor": 200000, | ||
"closeFactor": 500000, | ||
"liquidateIncentive": "1100000000000000000", | ||
"liquidateIncentiveReservedFactor": 25000, | ||
"rateModel": { | ||
"Jump": { | ||
"baseRate": 0, | ||
"jumpRate": "5000000000000000", | ||
"fullRate": "50000000000000000", | ||
"jumpUtilization": 900000 | ||
} | ||
}, | ||
"state": "Active", | ||
"supplyCap": "20000000000000", | ||
"borrowCap": "20000000000000", | ||
"lendTokenId": { | ||
"LendToken": 0 | ||
} | ||
}' | ||
|
||
|
||
# KINT | ||
polkadot-js-api --ws "${PARACHAIN_WSS}" --sudo --seed "${PARACHAIN_SEED}" \ | ||
tx.loans.addMarket \ | ||
"{ \"Token\": ${TOKEN_IDS["KINT"]} }" \ | ||
'{ | ||
"collateralFactor": 610000, | ||
"liquidationThreshold": 650000, | ||
"reserveFactor": 200000, | ||
"closeFactor": 500000, | ||
"liquidateIncentive": "1100000000000000000", | ||
"liquidateIncentiveReservedFactor": 25000, | ||
"rateModel": { | ||
"Jump": { | ||
"baseRate": 0, | ||
"jumpRate": "5000000000000000", | ||
"fullRate": "50000000000000000", | ||
"jumpUtilization": 900000 | ||
} | ||
}, | ||
"state": "Active", | ||
"supplyCap": "20000000000000", | ||
"borrowCap": "20000000000000", | ||
"lendTokenId": { | ||
"LendToken": 0 | ||
} | ||
}' | ||
} | ||
|
||
|
||
setup_parachain | ||
setup_foreign_assets | ||
setup_vault_registry | ||
fund_faucet_account | ||
setup_lending_markets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not 2121 anymore - use 2092 for kintsugi or 2032 for interlay