# Cross-Ecosystem TEER
context: https://hackmd.io/@acatangiu/SkxHNEnYcJl
## Management Summary
This document shall specify how the TEER token moves across parachains and consensus systems.
## Requirements
1. TEER is the native token of both integritee-kusama (IK) and integritee-polkadot (IP) and shall be of equal value and common total supply cap
2. TEER shall be bridged to Ethereum as ERC20
3. optimize for UX
1. one interaction per gap (one signature)
2. pay fees in TEER and only TEER (swapping behind the scenes is acceptable)
5. Unified governance of IK and IP
6. It must be possible to sunset IK if such decision should be taken by gov eventually. A clear migration path must be sketched
7. (optional) [TEERdays](https://app.incognitee.io/teerdays-lp/) are non-transferrable tokens. It would be desirable to be able to bridge them but keep ownership with same account
## Assumptions
1. we do not want to operate dedicated bridge lanes / do not want to wait for this to be possible
2. We assume that our CEXes (kraken, gate) will migrate to AssetHub for deposits and withdrawals. It is assumed beneficial for Integritee Network if that will be PAH rather than KAH
## Optimal Solution
**TEER-k and TEER-p are fungible accross the P<>K bridge such that we can teleport TEER between IK<>KAH<>PAH<>IP.**
Advantages:
* no derivatives, only one token supply which can be easily audited as TotalIssuance of (IK + IP + PAH + KAH)
Disadvantages:
* non-trivial to unify governance (electorate volatility) as TEER can move freely during referendum period.
This seems not to be possible today.
## Option 1: Adrian's Recommendation (AFAIU)
along https://hackmd.io/2HdBtgpsT-WlXZPnGC8WEw?both=#Leverage-the-canonical-PltgtK-AH-Bridge-lane-possible-today
TEER-p becomes the reference token and must be minted to full TEER supply. TEER-k becomes a (one-way redeemable) voucher for TEER-p which has to be available on IK (as bridged asset) to be swapped 1:1. TEER-k shall be burned in the process
### Concept Diagram

Advantages:
* possible today
* clear path from IK to IP longterm (if this should be deemed desirable). Holders can only move one way
* clear path for governance to move to IP
Disadvantages:
* no meaningful coexistence of IK & IP long term. Transition phase will still take a while becasue we can't force holders to move. Also, CEX migration to PAH isn't entirely in our hands
* complex derivation of total supply: sum(TEER-p)+sum(TEER-k) > TEER cap. This might confuse markets
#### Q&A
* How would an XCM look like to enact a referendum decision from IP to IK? How can we send XCM(transact) from IP to IK without a dedicated bridge lane?
* how can a TEER holder move TEER and pay fees only in TEER if interaction with AH is unavoidable?
* are there instructions how to spin up a local zombienet including the P<>K bridge and possibly P < snowbridge > Ethereum?
## Option 2: Custom pallets to burn&mint across bridge
If we can XCM-transact arbitrary calls from IK to IP (and preserve origin with XCMv5), we can implement a de-facto teleport ourselves:
We have other stuff users may want to move (e.g. TEERdays which are non-transferrable tokens)
One-way design example, assuming IK will be obsolete and people only move one-way. (it's possible to do this bidirectionally)
pallet_k_to_p (only on IK)
* burn_and_move_account_to_p(account)
* burns TEER-k
* burns TEERdays
* ignores assets (e.g. KSM)
pallet_p_to_k (only on IP)
* mint_and_move_account_from_k(...)
* mint TEER-p
* mint TEERdays
advantages:
* solves TEERday bridging at the same time
*
### XCMv5 Instruction
via AH along: https://forum.polkadot.network/t/dotsama-parachains-options-for-using-polkadot-kusama-bridge/10873/2#p-25376-option-1-use-assethubs-bridge-lane-1
notes:
* it should be possible to send TEER-k and don't explicitly exchange them to pay fees. if there are pools available for TEER-k on KAH & PAH the exchange should happen automatically
```
// executes on IK with ROOT local origin (must be root to prove that funds have been burned on sender side)
// as Alice calls burn_and_move_account_to_p()
XCM(
// withdraw native asset for fees and pay for transport
WithdrawAsset(TEER-k),
PayFees(TEER-k),
// initiate a transfer to KAH including custom logic
InitiateTransfer(
// send to KAH
dest: KusamaAssetHub,
// teleport TEER-k as foreign asset on KAH,
remote_fee: Teleport(TEER-k),
// move no other assets beyond fee payment
assets: (),
// executes on KAH
remote_xcm: XCM(
// for fees
ExchangeAsset(TEER-k, KSM),
// initiate transfer to PAH including custom logic
InitiateTransfer(
// send to PAH
dest: PolkadotAssetHub,
// send KSM to pay remote fees (on PAH)
remote_fee: ReserveDeposit(KSM),
// include the other assets
assets: (),
// executes on PAH
remote_xcm: XCM(
// exchange KSM for some DOT for fees
ExchangeAsset(KSM, DOT),
// initiate transfer to IP including custom logic
InitiateTransfer(
// send DOT to pay remote fees (on IP)
remote_fee: ReserveDeposit(DOT),
// include any other assets
assets: (),
// executes on IP
remote_xcm: XCM(
// transact on IP as IK/root
Transact(mint_and_move_account_from_k(alice, balance)),
// refund any fees not spent
RefundSurplus,
// deposit all remaining assets to Alice IP
Deposit(All, Sovereign(IK))
)
)
)
)
)
)
)
```
## Option 3: brute force
In the case where we decide that IK should be deprecated in favor of IP, we can simply snapshot IK and apply it to IP (like we did from solochain to IK years back)
Why worry about lazy bridging if we can bridge all at once? (we still have sudo on IP)
# Test Setup
```
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2412/polkadot
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2412/polkadot-execute-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2412/polkadot-prepare-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2412/polkadot-parachain
wget https://github.com/paritytech/zombienet/releases/download/v1.3.128/zombienet-linux-x64 -O zombienet
chmod +x polkadot*
yarn global add @polkadot/api-cli
git clone https://github.com/paritytech/parity-bridges-common.git
cd parity-bridges-common
cargo +nightly build -p substrate-relay --release
cp ./target/release/substrate-relay ~/local_bridge_testing/bin/
in runtimes repo:
git checkout v1.5.1
git apply ./integration-tests/bridges/sudo-relay.patch
cargo +nightly build --release -p chain-spec-generator --no-default-features --features fast-runtime,polkadot,kusama,bridge-hub-kusama,bridge-hub-polkadot,asset-hub-kusama,asset-hub-polkadot
in runtimes/integration-tests/bridges
./run-test.sh 0001-polkadot-kusama-asset-transfer
```
## Alternative: dry-run XCM
https://hackmd.io/@n9QBuDYOQXG-nWCBrwx8YQ/rkRNb5m71e