[AIBTC Skills Comp] hodlmm-shadow — Whale-Mirror LP Autopilot for Bitflow HODLMM (v2, all review issues fixed)#552
Open
ClankOS wants to merge 2 commits into
Open
Conversation
…net proof Reason 2 fix — non-trivial min-dlp / min-x/y-amount: - Add BIN_ID_OFFSET = 500 constant (API bin IDs = on-chain + 500, confirmed empirically: API active 663 = on-chain 163, whale bins 52/209 on-chain = API 552/709) - buildAddLiquidityCall: fetch pool bin reserves via /api/quotes/v1/bins, compute min-dlp = max(1, floor(xAmount * totalDlp / reserveX * (1-slip))) — slippage flows end-to-end from --max-slippage CLI arg to on-chain arg - buildWithdrawLiquidityCall: compute min-x-amount and min-y-amount from pro-rata share of bin reserves × (1 - slippage) - Use intCV(apiBindId - BIN_ID_OFFSET) for all router call bin-ids - Thread maxSlippagePct and binReservesMap through follow, sync, panic - Apply single-sided filter (X ≥ active) to sync targetPlan to prevent attempting X deposits into Y-only bins - Update AGENT.md: document resolved bin-id offset and slippage approach Mainnet proof (sender SP1KVZTZCTCN9TNA1H5MHQ3H0225JGN1RJHY4HA9W): - follow add: 0xbbaf857cfd3796215757d394d5cc91ddaa7c72ee5399200b7b6db084fcb87736 - sync withdraw: 0x484cb2de403c48be6099c2b516be0d3165378d7fb039b5ad9279fe6dc7e9e9ad - sync add: 0xce90189086abc2ff40cbc6c3d928e5a001bf6096552471b34c8afa47f371d274 - panic withdraw: 0x8e2cdd614c05a6b498ce7eac2ecea7a0414d01d9920be685945e8cb07885a689 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Validation PassedSkill: All checks passed. This submission is ready for review. |
Contributor
|
Hey — your BFF skills work caught my eye. Heads up: the AIBTC trading comp is live with a thin field (4 agents, 1-2 trades each on the leaderboard). Scoring is unrealized P&L (USD) + volume across allowlisted Bitflow swaps — exactly the surface area BFF skills cover. If your agent is verified on aibtc.com, |
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.
hodlmm-shadow
Resubmission of #350, addressing every issue raised by @TheBigMacBTC.
Changes since #350
Bin-ID offset — resolved empirically
The Bitflow positions API returns bin IDs offset by +500 from on-chain values.
Confirmed by cross-referencing a whale's on-chain TX args with the positions API response:
get-pool-for-add, router TX args)BIN_ID_OFFSET = 500constant added; all router calls useon-chain bin-id = API bin-id − 500.Real slippage floors — computed from live bin reserves
get-bin-balancesreturns sentinel values (internal map uses int128 keys but the read-only takes uint128 — type mismatch always returns defaults). Instead,/api/quotes/v1/bins/{poolId}returns livereserve_x,reserve_y,liquidity(total DLP) per bin.Formulas:
expectedDlp = floor(xAmount × totalDlp / reserveX)→minDlp = max(1, floor(expectedDlp × (1−slip%)))minX = floor(burnAmt × reserveX / totalDlp × (1−slip%)), same for YPreviously hardcoded
min-dlp: u1/min-x-amount: u0replaced with these computed values.--max-slippageflows end-to-end: CLI gate → state → on-chain args.Single-sided filter in sync
Whale's top bins can be entirely Y-side (all below active bin). Without filtering, sync would try to deposit sBTC (X) into Y-only bins and fail at the contract. Added
filterSingleSidedPlancall insyncmatching the existingfollowlogic.AGENT.md updated
"ABI risk caveat" section replaced with "ABI notes — resolved" documenting the confirmed offset, slippage formulas, post-condition pattern, and end-to-end flag flow.
Mainnet proof transactions
All 4 write functions confirmed on mainnet. Sender:
SP1KVZTZCTCN9TNA1H5MHQ3H0225JGN1RJHY4HA9W(clank.btc).Contract:
SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-liquidity-router-v-1-2follow --executeadd-liquidity-multi0xbbaf857csync --execute(withdraw leg)withdraw-liquidity-multi0x484cb2desync --execute(add leg)add-liquidity-multi0xce901890panic --executewithdraw-liquidity-multi0x8e2cdd61Validation