mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-13 19:49:29 +00:00
189 lines
6.3 KiB
Bash
189 lines
6.3 KiB
Bash
source venv/bin/activate
|
|
export KEYCARD_PIN=111111
|
|
|
|
echo ""
|
|
echo "=== Create LEZ and LEE token definitions (without keycard) ==="
|
|
|
|
wallet account new public --label lez-def
|
|
wallet account new public --label lez-supply
|
|
wallet account new public --label lee-def
|
|
wallet account new public --label lee-supply
|
|
|
|
sleep 5
|
|
|
|
LEZ_DEF_ID=$(wallet account id --account-label lez-def)
|
|
LEE_DEF_ID=$(wallet account id --account-label lee-def)
|
|
|
|
wallet token new \
|
|
--definition-account-label lez-def \
|
|
--supply-account-label lez-supply \
|
|
--total-supply 100000 \
|
|
--name LEZ
|
|
echo "LEZ token created"
|
|
|
|
wallet token new \
|
|
--definition-account-label lee-def \
|
|
--supply-account-label lee-supply \
|
|
--total-supply 100000 \
|
|
--name LEE
|
|
echo "LEE token created"
|
|
|
|
# =============================================================================
|
|
# Initialize LEE token holding accounts:
|
|
# - two public keycard holders (paths 2 and 3)
|
|
# - one private holder (without keycard)
|
|
# =============================================================================
|
|
echo ""
|
|
echo "=== Initialize LEE/LEZ token holding accounts ==="
|
|
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEE_DEF_ID" \
|
|
--holder-key-path "m/44'/60'/0'/0/2"
|
|
echo "LEE holding initialized for keycard m/44'/60'/0'/0/2"
|
|
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEE_DEF_ID" \
|
|
--holder-key-path "m/44'/60'/0'/0/3"
|
|
echo "LEE holding initialized for keycard m/44'/60'/0'/0/3"
|
|
|
|
# For shielded transfer
|
|
wallet account new private --label lee-priv-holder 2>/dev/null || true
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEE_DEF_ID" \
|
|
--holder-account-label lee-priv-holder
|
|
echo "Private LEE holding initialized"
|
|
|
|
# Fund the two keycard LEE holdings from the supply.
|
|
# Only the sender (lee-supply, stored key) needs to sign for a token Transfer
|
|
# to an already-initialized holding.
|
|
wallet token send \
|
|
--from-label lee-supply \
|
|
--to-key-path "m/44'/60'/0'/0/2" \
|
|
--amount 5000
|
|
echo "Transferred 5000 LEE → keycard path 2"
|
|
|
|
wallet token send \
|
|
--from-label lee-supply \
|
|
--to-key-path "m/44'/60'/0'/0/3" \
|
|
--amount 5000
|
|
echo "Transferred 5000 LEE → keycard path 3"
|
|
|
|
sleep 5
|
|
|
|
echo "Keycard path 2 LEE state (balance should be 5000):"
|
|
wallet account get --key-path "m/44'/60'/0'/0/2"
|
|
echo "Keycard path 3 LEE state (balance should be 5000):"
|
|
wallet account get --key-path "m/44'/60'/0'/0/3"
|
|
|
|
|
|
# =============================================================================
|
|
# Shielded (public → private) LEE transfer from keycard holding to the
|
|
# private LEE holding account.
|
|
# =============================================================================
|
|
echo ""
|
|
echo "=== Test Shielded transfer keycard LEE holding → private LEE holding ==="
|
|
|
|
wallet token send \
|
|
--from-key-path "m/44'/60'/0'/0/2" \
|
|
--to-label lee-priv-holder \
|
|
--amount 500
|
|
echo "Shielded transfer complete (500 LEE: path-2 keycard → private holder)"
|
|
|
|
wallet account sync-private
|
|
echo "Private LEE holder state (balance should be 500):"
|
|
wallet account get --account-label lee-priv-holder
|
|
|
|
# =============================================================================
|
|
# Create AMM pool for LEZ/LEE (without keycard)
|
|
# =============================================================================
|
|
echo ""
|
|
echo "=== Test Create AMM pool for LEZ/LEE (without keycard) ==="
|
|
|
|
wallet account new public --label amm-lp-lez-holding 2>/dev/null || true
|
|
wallet account new public --label amm-lp-lee-holding 2>/dev/null || true
|
|
wallet account new public --label amm-lp-lp-holding 2>/dev/null || true
|
|
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEZ_DEF_ID" \
|
|
--holder-account-label amm-lp-lez-holding
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEE_DEF_ID" \
|
|
--holder-account-label amm-lp-lee-holding
|
|
|
|
wallet token send --from-label lez-supply --to-label amm-lp-lez-holding --amount 40000
|
|
wallet token send --from-label lee-supply --to-label amm-lp-lee-holding --amount 40000
|
|
|
|
wallet amm new \
|
|
--user-holding-a-label amm-lp-lez-holding \
|
|
--user-holding-b-label amm-lp-lee-holding \
|
|
--user-holding-lp-label amm-lp-lp-holding \
|
|
--balance-a 40000 \
|
|
--balance-b 40000
|
|
echo "AMM pool created for LEZ/LEE"
|
|
|
|
# =============================================================================
|
|
# Swaps, add liquidity, remove liquidity using keycard holding accounts.
|
|
#
|
|
# Path layout:
|
|
# path 2 → LEE holding (4500 LEE after step 4)
|
|
# path 3 → LEE holding (5000 LEE)
|
|
# path 4 → fresh; initialized below as LEZ holding (receives swapped LEZ)
|
|
# =============================================================================
|
|
echo ""
|
|
echo "=== Test Initialize LEZ holding for keycard path 4 (swap output) ==="
|
|
wallet token init \
|
|
--definition-account-id "Public/$LEZ_DEF_ID" \
|
|
--holder-key-path "m/44'/60'/0'/0/4"
|
|
echo "LEZ holding initialized for keycard m/44'/60'/0'/0/4"
|
|
|
|
# Resolve raw account IDs needed for the swap --user-holding-* args.
|
|
PATH2_ID=$(wallet account id --key-path "m/44'/60'/0'/0/2")
|
|
PATH3_ID=$(wallet account id --key-path "m/44'/60'/0'/0/3")
|
|
PATH4_ID=$(wallet account id --key-path "m/44'/60'/0'/0/4")
|
|
|
|
echo "Path 2: $PATH2_ID Path 3: $PATH3_ID Path 4: $PATH4_ID"
|
|
echo "LEE def ID: $LEE_DEF_ID"
|
|
|
|
echo ""
|
|
echo "=== Swap LEE → LEZ (path 2 sells LEE, path 4 receives LEZ) ==="
|
|
wallet amm swap-exact-input \
|
|
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
|
|
--user-holding-b-key-path "m/44'/60'/0'/0/2" \
|
|
--amount-in 100 \
|
|
--min-amount-out 1 \
|
|
--token-definition "$LEE_DEF_ID" \
|
|
echo "Swap LEE→LEZ complete via keycard"
|
|
|
|
|
|
echo "Path 4 (LEZ) state:"
|
|
wallet account get --key-path "m/44'/60'/0'/0/4"
|
|
echo "Path 2 (LEE) state:"
|
|
wallet account get --key-path "m/44'/60'/0'/0/2"
|
|
|
|
echo ""
|
|
echo "=== Test (6c): Add liquidity (path 4 LEZ + path 3 LEE) ==="
|
|
wallet amm add-liquidity \
|
|
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
|
|
--user-holding-b-key-path "m/44'/60'/0'/0/3" \
|
|
--user-holding-lp-label "m/44'/60'/0'/0/5" \
|
|
--min-amount-lp 1 \
|
|
--max-amount-a 200 \
|
|
--max-amount-b 200
|
|
echo "Add liquidity complete via keycard"
|
|
|
|
echo ""
|
|
echo "=== Test (6d): Remove liquidity (LP from amm-lp-lp-holding) ==="
|
|
wallet amm remove-liquidity \
|
|
--user-holding-a-label "m/44'/60'/0'/0/4"\
|
|
--user-holding-b-label "m/44'/60'/0'/0/3" \
|
|
--user-holding-lp-label amm-lp-lp-holding \
|
|
--balance-lp 1000 \
|
|
--min-amount-a 1 \
|
|
--min-amount-b 1
|
|
echo "Remove liquidity complete"
|
|
|
|
|
|
echo ""
|
|
echo "=== All keycard tests finished ==="
|
|
|