fix: leverage_cdp — resolve ROB positions and the treasury where they actually live - #54
Open
adacapo21 wants to merge 1 commit into
Open
fix: leverage_cdp — resolve ROB positions and the treasury where they actually live#54adacapo21 wants to merge 1 commit into
adacapo21 wants to merge 1 commit into
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes INDY-141.
leverage_cdpcould not build for any iAsset. It failed before reaching the SDK, withNo ROB positions found on-chain for this iAsset(iBTC) orNo 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:
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
findTreasuryOrefwas reaching for: the rule was right, the address was not.
What is deliberately left alone
findTreasuryOrefstill returnsundefinedon mainnet, which selects the SDK'sdirect-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
open_cdpleverage_cdp14/14, unsigned CBOR through the MCP protocol on mainnet, build-only.
tsc --noEmitclean ·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.