Testnet, tokens have no value. Do not send real assets.
Skip to Content
Testnet appsBorrow against your stock

Borrow against your stock

The testnet lender lends aeUSD against test shares without taking them: you pledge the shares to it, an encumbrance that locks them in your account, and it sends you half their value. While the pledge is active, their dividends go to the lender. Repay the principal and the pledge is released in the same transaction. Test loans of test money, interest-free; testnet, tokens have no value.

Run the setup block first, and hold a test stock (Hold a test stock).

1. The terms

curl -s "$AEVA_APP/api/lender/terms" | jq '{lender, ltv_bps, liquidation_ltv_bps, max_principal}' LENDER=$(curl -s "$AEVA_APP/api/lender/terms" | jq -r .lender) ASSET=$(curl -s "$AEVA_INDEXER/v1/accounts/$ME" | jq -r '.assets[0].asset_id')
Expected output
{ "lender": "aeva1sdu9sc8a3yxrkme7hx3yjc4alp7tapyt4zv2t5", "ltv_bps": 5000, "liquidation_ltv_bps": 8000, "max_principal": "5000000000" }

The loan is 50 % of the shares’ value at the DEX pool’s price, at most 5 000 aeUSD. If the loan reaches 80 % of the shares’ current value, the lender exercises the pledges, takes the pledged units, and the loan is closed.

2. Pledge five shares

The lender takes whole shares: the same units of every kind, each pledge exercisable, with the income routed to the lender, no holder release and no expiry. aevad pledges one kind per transaction; send the three within two minutes.

for k in 0 1 2; do R=$(alias_tx encumbrance pledge "$ASSET" "$k" 5000000 "$LENDER" --exercisable --income-to-beneficiary --from me) wait_tx "$(jq -r .txhash <<<"$R")" >/dev/null && echo "kind $k pledged" done for _ in $(seq 1 30); do L=$(curl -s "$AEVA_APP/api/lender/loans?address=$ME"); [ "$(jq '[.loans[]? | select(.status == "active")] | length' <<<"$L")" -gt 0 ] && break; sleep 2; done jq '.loans[] | select(.status == "active") | {id, symbol, units, principal, ltv_bps, open_tx}' <<<"$L"
Expected output
kind 0 pledged kind 1 pledged kind 2 pledged { "id": <id>, "symbol": "tAAPL", "units": "5000000", "principal": "<aeusd base units>", "ltv_bps": <about 5000>, "open_tx": "<64 hex characters>" }

The shares stay in your account, locked: the explorer lists the three pledges under your address, and your INCOME kind’s dividends now accrue to the lender (routed_income in the loan view).

3. Repay

A repayment is a settlement you propose to the lender that gives the principal and asks for nothing. The lender accepts it and releases the pledges in the same transaction.

P=$(jq -r '.loans[] | select(.status == "active") | .principal' <<<"$L" | head -1) R=$(alias_tx settlement propose "$LENDER" "give:coin:${P}aeusd" --expires-in 1h --from me); wait_tx "$(jq -r .txhash <<<"$R")" >/dev/null for _ in $(seq 1 30); do L=$(curl -s "$AEVA_APP/api/lender/loans?address=$ME"); [ "$(jq '[.loans[]? | select(.status == "active")] | length' <<<"$L")" = 0 ] && break; sleep 2; done jq -r '.loans[-1] | "loan \(.id): \(.status), closed in \(.close_tx)"' <<<"$L" curl -s "$AEVA_INDEXER/v1/accounts/$ME" | jq -r '"pledged units left: \([.assets[].positions[].encumbered | tonumber] | add)"'
Expected output
loan <id>: repaid, closed in <64 hex characters> pledged units left: 0

Why it works this way

  • Pledge, not transfer. The shares never leave your account, so you keep voting with them; the lender’s rights are exactly the encumbrance’s: exercise if the loan goes bad, income while it is open, release on repayment. See Encumbrances.
  • Atomic repayment. Accepting your settlement and releasing the pledges happen in one transaction, so there is no moment when the lender has both the aeUSD and the collateral.
Last updated