Skip to content

fix: leverage_cdp — resolve ROB positions and the treasury where they actually live - #54

Open
adacapo21 wants to merge 1 commit into
mainfrom
fix/indy-141-leverage-rob-treasury
Open

fix: leverage_cdp — resolve ROB positions and the treasury where they actually live#54
adacapo21 wants to merge 1 commit into
mainfrom
fix/indy-141-leverage-rob-treasury

Conversation

@adacapo21

Copy link
Copy Markdown
Member

Fixes INDY-141.

leverage_cdp could not build for any iAsset. It failed before reaching the SDK, with
No ROB positions found on-chain for this iAsset (iBTC) or No ADA-only treasury UTxO available (iUSD), depending on which lookup ran out first.

Both lookups scanned an enterprise script address while the real UTxOs carry a staking
credential, so both returned nothing.

ROB positions

They carry the owner's staking credential, so they are spread across as many addresses as
there are owners — 18 across the 38 live positions — and they hold no auth token to look them
up by. An address scan cannot work in principle, not just in practice.

Resolved through the indexer's order book instead, the same source the read tools and the web
app already use.

Treasury

The treasury lives at its address with the staking credential; the enterprise address holds a
single unrelated UTxO. Resolving all ~350 orefs from the indexer would be a lot of provider
traffic, so this asks the indexer for one, reads the address off that UTxO, and takes the set
from the chain.

Which UTxO matters. The validator caps the continuing output at two asset classes:

/// Too many asset classes
value_helpers.assets_count(continuing_output_value) <= 2

So a candidate only works if it already holds the iAsset beside lovelace, or holds lovelace
alone. Selecting by "holds the most of the iAsset" still fails with Too many asset classes
that was the first thing I tried. This is also what the ADA-only filter in findTreasuryOref
was reaching for: the rule was right, the address was not.

What is deliberately left alone

findTreasuryOref still returns undefined on mainnet, which selects the SDK's
direct-payment branch — verified working for every iAsset across the CDP write tools. Turning
it into a treasury spend is a different code path and would need all of them re-tested, so it
keeps its behaviour and gains a comment explaining why, rather than being "fixed" into a
regression.

Verification

asset open_cdp leverage_cdp
iUSD, iSOL, iEUR, iJPY, iETH, iBTC, iADA builds builds

14/14, unsigned CBOR through the MCP protocol on mainnet, build-only. tsc --noEmit clean ·
144/144 tests · Prettier clean.

The Pyth wiring test gains stubs for the new resolver and for the system-params fields the
leverage tool now reads.

`leverage_cdp` could not build for any iAsset. Both of the lookups it needs
scanned an enterprise script address, while the real UTxOs carry a staking
credential, so each returned nothing and the tool failed before touching the
SDK — iBTC with "No ROB positions found on-chain for this iAsset", iUSD with
"No ADA-only treasury UTxO available".

ROB positions carry the *owner's* staking credential, so they are spread over as
many addresses as there are owners — 18 across the 38 live positions — and they
hold no auth token to look them up by. An address scan cannot work in principle,
so resolve them through the indexer's order book, the same source the read tools
and the web app already use.

The treasury sits at its address with the staking credential rather than the
enterprise one, where a scan finds a single unrelated UTxO. Resolving all ~350
orefs from the indexer would be a lot of provider traffic, so ask it for one,
read the address off that UTxO, and take the set from the chain.

Which treasury UTxO matters: the validator caps the continuing output at two
asset classes, so a candidate only works if it already holds the iAsset beside
lovelace, or holds lovelace alone. That is what the ADA-only filter in
findTreasuryOref was reaching for — the rule was right, the address was not.
Picking by "holds the most of the iAsset" instead still fails with "Too many
asset classes".

findTreasuryOref is left alone. It returns undefined on mainnet, which selects
the SDK's direct-payment branch, and that branch is verified working for every
iAsset across the CDP write tools. Turning it into a treasury spend is a
different code path and would need all of them re-tested; documented in place so
it is not "fixed" into a regression.

Verified: leverage_cdp builds unsigned CBOR for all seven iAssets, and open_cdp
still builds for all seven.

Refs INDY-141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant