2020117-agent 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/session.js +13 -3
  2. package/package.json +1 -1
package/dist/session.js CHANGED
@@ -37,6 +37,9 @@ for (const arg of process.argv.slice(2)) {
37
37
  case '--provider':
38
38
  process.env.PROVIDER_PEER = val;
39
39
  break;
40
+ case '--mint':
41
+ process.env.CASHU_MINT_URL = val;
42
+ break;
40
43
  }
41
44
  }
42
45
  import { SwarmNode, topicFromKind } from './swarm.js';
@@ -781,16 +784,23 @@ async function main() {
781
784
  const tickMinutes = satsPerToken / satsPerMinute; // e.g. 0.1 sats/min → 1 sat every 10 min
782
785
  state.tickIntervalMs = Math.round(tickMinutes * 60_000);
783
786
  state.satsPerToken = satsPerToken;
784
- // Check mint fees — the token amount must cover satsPerToken + swap fee
787
+ // Check mint fees — each micro-token must cover satsPerToken + swap fee (so provider
788
+ // can claim it), and each wallet.send during splitting also costs a fee.
785
789
  const mintUrl = process.env.CASHU_MINT_URL || 'https://nofee.testnut.cashu.space';
786
790
  const { wallet: tmpWallet } = createWallet(mintUrl);
787
791
  await tmpWallet.loadMint();
788
792
  const swapFee = tmpWallet.getFeesForKeyset(1, tmpWallet.keysetId);
789
- const tokenAmount = satsPerToken + swapFee;
790
- const totalNeeded = tokenAmount * Math.ceil(BUDGET / satsPerToken);
793
+ const tokenAmount = satsPerToken + swapFee; // what each micro-token contains
794
+ const numTokens = Math.ceil(BUDGET / satsPerToken);
795
+ // Each split (wallet.send) also costs a fee, plus proof fragmentation overhead
796
+ const splitOverhead = swapFee > 0 ? Math.ceil(swapFee * 1.5) : 0;
797
+ const totalNeeded = (tokenAmount + splitOverhead) * numTokens;
791
798
  const mintAmount = Math.max(BUDGET, totalNeeded);
792
799
  if (swapFee > 0) {
793
800
  log(`Mint swap fee: ${swapFee} sats/token → minting ${tokenAmount} sats/token (${satsPerToken} + ${swapFee} fee)`);
801
+ if (mintAmount > BUDGET * 3) {
802
+ warn(`High fee overhead: minting ${mintAmount} sats for ${BUDGET} sats budget. Consider using a no-fee mint.`);
803
+ }
794
804
  }
795
805
  log(`Minting ${mintAmount} sats...`);
796
806
  const { token: bigToken } = await mintTokens(mintAmount, mintUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "2020117-agent",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "2020117 agent runtime — API polling + Hyperswarm P2P + Cashu streaming payments",
5
5
  "type": "module",
6
6
  "bin": {