Compare commits

...

7 commits

Author SHA1 Message Date
Hossein Zoda
0eb86131f4 ido: keep offeredTokenTotalSupply in Active parameters
IdoActiveParameters dropped offeredTokenTotalSupply, so clients couldn't compute the offered-vs-total-supply share for live (non-PREINIT) IDOs. Carry it forward from the preinit parameters at the PreInit->Active transition and add it to the struct. A serde default of -1 (the pre-existing-token "unknown supply" sentinel) lets ido_state rows written before this field existed still deserialize.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 01:01:55 +03:00
Hossein Zoda
a73dff52df update offering initial output 2026-07-17 03:40:30 +03:00
Hossein Zoda
da26864cba update ipfs rebuild contract 2026-07-16 21:23:47 +03:00
Hossein Zoda
c1952142de ido: categories in display/UI byte order, drop hardcoded PLP limits
libriften moved encodeVmTokenCategory/decodeVmTokenCategory (which reverse
the 32 category bytes, display<->VM) into the ido announcement and ORB
IdoParams serialize/deserialize layer. Net wire effects the indexer sees:
- preinit announcement delphiCategory[44..76] and xTokenCategory[126..158]
  are now VM/little-endian (were display order);
- the IdoParams commitment stays VM on-wire, but the derived on-chain
  postlaunch orbPoolParamsCategory push flips display->VM (decode now
  returns display, the unchanged bake re-wraps it in encodeVmTokenCategory).

Keep the three categories (delphiCategory, xTokenCategory,
orbPoolParamsCategory) in display/UI byte order in-memory and over RPC:
reverse at every parse site (announcement + IdoParams NFT commitment) and
restore the .rev() on the output#0 delphi-NFT to_blob() compare. The
build_*_bytecode helpers keep reversing display->VM when baking, so the
output#7 P2SH32 rebuild matches the new on-chain layout.

Also drop the now-unused hardcoded MAX_PLP_SHARE / MAX_PLP_ANNUAL_DISCOUNT
/ MIN_PLP_ANNUAL_DISCOUNT statics and dead checks; the min-PLP limits are
NFT-pinned (minPlpShare / minPlpAfterDiscount) and the discount/max-discount
checks now just guard against negatives.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 21:44:18 +00:00
Hossein Zoda
4677cc955e ido: port "CldIdo00" signature + announcement permanentLiquidityMinFee
Sync the IDO indexer to libriften 48aa1f7 (+ follow-ups):

- IDO_SIGNATURE 20->10 bytes: [0x08 "CldIdo00" 0x75] (was OP_PUSH18
  "CauldronIdo-2026Q2"). The separate "CauldronIdo0" announcement
  signature is folded into the same 8 raw bytes, so
  IDO_PREINIT_ANNOUNCEMENT_SIGNATURE = 6a 4c b9 + "CldIdo00";
  is_preinit_broadcast is now length-agnostic. Electrum mempool
  filters track automatically (they reference the constants).
- Recompile the 3 affected contracts from templates: IDO initiator
  233->231, IDO preinit 1469->1465, offering launcher 630->628.
  IDO_POSTLAUNCH_CONTRACT and the other offering contracts are
  byte-identical and left as-is.
- Announcement OP_RETURN carries permanentLiquidityMinFee as a 2-byte
  field at data[166..168]; mainData is now 185 bytes. Read minFee from
  the announcement rather than the (unreadable) postlaunch copy.

Fix the source of the two "free" postlaunch params:

- Output #7 (ido initiator bytecode storage) is P2SH32, so the partial
  bytecode cannot be read back from it. Drop the impossible extraction
  (extract_params_from_partial_ido_initiator_bytecode +
  PartialPostlaunchExtractedParams). extract_data_from_storage_script_
  with_data_and_size is kept for its valid callers (revealed redeem
  scripts, bare bcmr storages).
- orbPoolParamsCategory now comes from the ORB IdoParams NFT commitment
  (output #10). The commitment parse is moved above the params
  construction so the value is available; the now-tautological
  orbPoolParamsCategory vs NFT check is removed.
- Verification is the existing output #7 rebuild: build the expected
  bytecode from the announcement values plus the NFT-sourced
  orbPoolParamsCategory, hash to P2SH32, and compare. Since minFee is a
  2-byte announcement field it always fits the postlaunch's 2-byte push,
  so build_partial_postlaunch_bytecode stays infallible.

- Tests: preinit_detect -> legacy_preinit_announcement_not_detected
  (legacy fixture must no longer be detected under the new signature);
  replace the extraction round-trip test with a structural check of the
  partial postlaunch bytecode layout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 19:32:20 +00:00
Hossein Zoda
c8450e210b ido: sync IdoParams commitment to 127-byte layout, enforce NFT-pinned min PLP
libriften 0941c88 grew the ORB IdoParams NFT commitment 121->127 bytes,
inserting minPlpAfterDiscount/minPlpShare (4-byte pIntLE numerators over
PERMANENT_LIQUIDITY_SHARE_DENOMINATOR) between maxExpireDuration and
entryExecutionFee, and shrinking paramsUseFee 4->2 bytes.

- Parse the two new fields; shift entryExecutionFee/createExecutionFee offsets.
- Drop the hardcoded MIN_PLP_SHARE / MIN_PLP_AFTER_DISCOUNT statics; enforce
  both minimums from the NFT commitment inside the version-verified block
  (permanentLiquidityShareNumerator >= minPlpShare, and
  maxDiscountRateNumerator + minPlpAfterDiscount <= permanentLiquidityShareNumerator).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 11:22:41 +00:00
Hossein Zoda
ca7f829591 ido: resync postlaunch contract & enforce IdoParams NFT version
- update IDO_POSTLAUNCH_CONTRACT to the recompiled 1627-byte script
  (libriften cd58dd1): postlaunch.cash reordered the permanent-pool
  sibling config, moving the all-zero nftOwner to the end. The indexer
  byte-compares this body against on-chain output#7, so the stale
  1669-byte constant would have marked every new IDO invalid.
- set CHIPNET_IDO_PARAMS_NFT_CATEGORY (was an all-zero placeholder).
- validate the ORB IdoParams NFT commitment version byte: only index
  when it equals IDO_PARAMS_VERSION (0x00), else push an
  "incompatible with the indexer" reason and mark the IDO invalid.
  The other commitment fields are read at v0 offsets, so the parameter
  comparisons are skipped on a version mismatch to avoid spurious errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 01:51:56 +00:00

File diff suppressed because one or more lines are too long