Skip to content

Weight lottery by actual sats donated (devfund% × fee rate) - #2561

Open
TempleOfSats wants to merge 6 commits into
RoboSats:mainfrom
TempleOfSats:pr-2560
Open

Weight lottery by actual sats donated (devfund% × fee rate)#2561
TempleOfSats wants to merge 6 commits into
RoboSats:mainfrom
TempleOfSats:pr-2560

Conversation

@TempleOfSats

Copy link
Copy Markdown
Contributor

Follow-up to #2560

The lottery weight is now devfund% × (maker_fee + taker_fee) instead of devfund% alone. A coordinator with high devfund% but low fees no longer outranks one that donates more actual sats.

Changes:

  • federationLottery.ts: Added feeOverrides parameter and DEFAULT_TOTAL_FEE constant
  • Federation.model.ts: Build feeOverrides map from live /api/info/ probe data

Static fallback uses 0.2% default total fee. No backend changes needed.

gabbygator184 and others added 6 commits August 10, 2026 16:36
Adds devfund (percentage = DEVFUND × 100) to the public GET /api/info/ response, documents it in the serializer/OAS schema, adds value tests (0/5/20/100%), and updates env/docs. Additive and backward-compatible: old clients ignore the new field.
Dormant frontend plumbing. Info.devfund? type; federationLottery(federation, devfundOverrides) with a backward-compatible signature (clamp [0, 50]); a new service that probes each coordinator's /api/info/ (silent requests, 15 s timeout, 30 min module cache) returning alias → %. Nothing consumes it yet — behavior unchanged, project compiles.
Federation gains loadDevFund() + devFundLoaded flag: probes coordinators, overwrites badges.donatesToDevFund for reachable ones, re-runs the weighted lottery and reorders coordinators, then notifies the UI. Not called yet — dormant, no side effects.
Activates the feature. FederationContext calls loadDevFund() on mount; GarageContext re-derives the default MakerForm host to the new [0] once devFundLoaded, guarded by coordinatorPickedRef (markCoordinatorPicked/resetCoordinatorPicked wired in MakerForm) so a late lottery shuffle never overwrites an explicit user choice. Only user-visible behavior change.
Consolidate the live DevFund lookup into the canonical Coordinator.loadInfo(). DevFundProfile no longer issues its own GET /api/info/ request — it reuses the coordinator's fetch (now a shared in-flight Promise, guarded by a private _infoPromise) and reads devfund from coordinator.info. Coordinators with valid info are not re-fetched. Timeout (15s), silent requests, 30-min cache and the static-fallback behavior are preserved; concurrent callers (startup probe + dialogs) collapse into one request per coordinator.
The lottery weight is now devfund% × (maker_fee + taker_fee) instead of
devfund% alone. A coordinator with high devfund% but low fees no longer
outranks one that donates more actual sats. Fee data is read from the
existing /api/info/ probe (no new request, no backend change). Static
fallback uses a 0.2% default total fee.
@TempleOfSats
TempleOfSats requested a review from a team as a code owner August 12, 2026 07:26
@alicecoordinator

Copy link
Copy Markdown
Contributor

Good idea to fetch the updated devfund live. I wish we would also move more stuff from the federation.json to endpoints.

@alicecoordinator

Copy link
Copy Markdown
Contributor

Only now I read that this is a follow up to #2560. I think both changes are reasonable, so I think we can merge this PR (I guess the other one will be automatically closed).

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.

3 participants