@strimz/shared-config 0.3.0 → 0.4.0

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.
package/dist/tiers.cjs CHANGED
@@ -1,73 +1,113 @@
1
1
  'use strict';
2
2
 
3
+ // src/tokens.ts
4
+ var PAYMENT_TOKENS = ["USDC", "EURC"];
5
+ var TOKENS = {
6
+ USDC: {
7
+ symbol: "USDC",
8
+ name: "USD Coin",
9
+ decimals: 6,
10
+ paymentEligible: true,
11
+ yieldBearing: false
12
+ },
13
+ EURC: {
14
+ symbol: "EURC",
15
+ name: "Euro Coin",
16
+ decimals: 6,
17
+ paymentEligible: true,
18
+ yieldBearing: false
19
+ },
20
+ USYC: {
21
+ symbol: "USYC",
22
+ name: "US Yield Coin",
23
+ decimals: 6,
24
+ paymentEligible: false,
25
+ yieldBearing: true
26
+ }
27
+ };
28
+
3
29
  // src/tiers.ts
4
- var TIERS = {
30
+ var PAID_FEATURES = [
31
+ "storefront",
32
+ "anomaly_alerts",
33
+ "yield_recommendations"
34
+ ];
35
+ var PLANS = {
5
36
  free: {
6
37
  id: "free",
7
38
  name: "Free",
8
- monthlyFeeUsdCents: 0,
9
- oneShotFeeBps: 150,
10
- // 1.5%
11
- subscriptionPremiumBps: 20,
12
- // +0.2% on recurring => 1.7% effective
13
- monthlyVolumeCapUsdCents: 1e6,
14
- // $10,000
15
- whiteLabelEligible: false,
39
+ feeBps: 0,
40
+ entersAtVolume: 0,
41
+ features: [],
16
42
  prioritySupport: false
17
43
  },
44
+ starter: {
45
+ id: "starter",
46
+ name: "Starter",
47
+ feeBps: 50,
48
+ entersAtVolume: 1e3,
49
+ features: PAID_FEATURES,
50
+ prioritySupport: true
51
+ },
18
52
  growth: {
19
53
  id: "growth",
20
54
  name: "Growth",
21
- monthlyFeeUsdCents: 4900,
22
- // $49
23
- oneShotFeeBps: 80,
24
- // 0.8%
25
- subscriptionPremiumBps: 20,
26
- // 1.0% effective
27
- monthlyVolumeCapUsdCents: 1e7,
28
- // $100,000
29
- whiteLabelEligible: true,
30
- prioritySupport: false
31
- },
32
- business: {
33
- id: "business",
34
- name: "Business",
35
- monthlyFeeUsdCents: 19900,
36
- // $199
37
- oneShotFeeBps: 50,
38
- // 0.5%
39
- subscriptionPremiumBps: 20,
40
- // 0.7% effective
41
- monthlyVolumeCapUsdCents: 1e8,
42
- // $1,000,000
43
- whiteLabelEligible: true,
55
+ feeBps: 40,
56
+ entersAtVolume: 5e4,
57
+ features: PAID_FEATURES,
44
58
  prioritySupport: true
45
59
  },
46
60
  enterprise: {
47
61
  id: "enterprise",
48
62
  name: "Enterprise",
49
- monthlyFeeUsdCents: null,
50
- oneShotFeeBps: null,
51
- subscriptionPremiumBps: null,
52
- monthlyVolumeCapUsdCents: null,
53
- whiteLabelEligible: true,
63
+ feeBps: null,
64
+ entersAtVolume: null,
65
+ features: PAID_FEATURES,
54
66
  prioritySupport: true
55
67
  }
56
68
  };
57
69
  var DEFAULT_TIER = "free";
58
- function getTier(id) {
59
- return TIERS[id];
70
+ var PLAN_ORDER = ["free", "starter", "growth", "enterprise"];
71
+ var VOLUME_PLANS = ["free", "starter", "growth"];
72
+ var PLAN_FEE_CEILING_BPS = Math.max(
73
+ ...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0)
74
+ );
75
+ function planFeeBps(plan) {
76
+ return PLANS[plan].feeBps;
77
+ }
78
+ function planIncludes(plan, feature) {
79
+ return PLANS[plan].features.includes(feature);
80
+ }
81
+ function plansWith(feature) {
82
+ return PLAN_ORDER.filter((plan) => planIncludes(plan, feature));
60
83
  }
61
- function effectiveFeeBps(tier, kind) {
62
- const def = TIERS[tier];
63
- if (def.oneShotFeeBps === null) return null;
64
- if (kind === "one_shot") return def.oneShotFeeBps;
65
- return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0);
84
+ function lowestPlanWith(feature) {
85
+ const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature));
86
+ if (!plan) throw new Error(`no plan includes ${feature}`);
87
+ return plan;
88
+ }
89
+ function thresholdInBaseUnits(plan, token) {
90
+ const wholeUnits = PLANS[plan].entersAtVolume;
91
+ if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`);
92
+ return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals);
93
+ }
94
+ function planForVolume(volumes) {
95
+ let reached = "free";
96
+ for (const plan of VOLUME_PLANS) {
97
+ if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {
98
+ reached = plan;
99
+ }
100
+ }
101
+ return reached;
66
102
  }
67
103
 
68
104
  exports.DEFAULT_TIER = DEFAULT_TIER;
69
- exports.TIERS = TIERS;
70
- exports.effectiveFeeBps = effectiveFeeBps;
71
- exports.getTier = getTier;
105
+ exports.PLANS = PLANS;
106
+ exports.PLAN_FEE_CEILING_BPS = PLAN_FEE_CEILING_BPS;
107
+ exports.lowestPlanWith = lowestPlanWith;
108
+ exports.planFeeBps = planFeeBps;
109
+ exports.planForVolume = planForVolume;
110
+ exports.planIncludes = planIncludes;
111
+ exports.plansWith = plansWith;
72
112
  //# sourceMappingURL=tiers.cjs.map
73
113
  //# sourceMappingURL=tiers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tiers.ts"],"names":[],"mappings":";;;AA2BO,IAAM,KAAA,GAA8C;AAAA,EACzD,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,MAAA;AAAA,IACJ,IAAA,EAAM,MAAA;AAAA,IACN,kBAAA,EAAoB,CAAA;AAAA,IACpB,aAAA,EAAe,GAAA;AAAA;AAAA,IACf,sBAAA,EAAwB,EAAA;AAAA;AAAA,IACxB,wBAAA,EAA0B,GAAA;AAAA;AAAA,IAC1B,kBAAA,EAAoB,KAAA;AAAA,IACpB,eAAA,EAAiB;AAAA,GACnB;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,EAAA,EAAI,QAAA;AAAA,IACJ,IAAA,EAAM,QAAA;AAAA,IACN,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pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nexport type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise'\n\nexport interface TierDefinition {\n id: MerchantTier\n name: string\n /** Monthly fee in USD cents (0 for free, null for custom enterprise). */\n monthlyFeeUsdCents: number | null\n /** Per-transaction fee on one-shot payments, in basis points. */\n oneShotFeeBps: number | null\n /** Per-transaction premium added on subscription payments, in basis points. */\n subscriptionPremiumBps: number | null\n /** Monthly transaction volume cap in USD cents. `null` for unlimited. */\n monthlyVolumeCapUsdCents: number | null\n /** Whether the \"Powered by Strimz\" badge can be removed from checkout. */\n whiteLabelEligible: boolean\n /** Whether the tier includes priority support. */\n prioritySupport: boolean\n}\n\nexport const TIERS: Record<MerchantTier, TierDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n monthlyFeeUsdCents: 0,\n oneShotFeeBps: 150, // 1.5%\n subscriptionPremiumBps: 20, // +0.2% on recurring => 1.7% effective\n monthlyVolumeCapUsdCents: 1_000_000, // $10,000\n whiteLabelEligible: false,\n prioritySupport: false,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n monthlyFeeUsdCents: 4_900, // $49\n oneShotFeeBps: 80, // 0.8%\n subscriptionPremiumBps: 20, // 1.0% effective\n monthlyVolumeCapUsdCents: 10_000_000, // $100,000\n whiteLabelEligible: true,\n prioritySupport: false,\n },\n business: {\n id: 'business',\n name: 'Business',\n monthlyFeeUsdCents: 19_900, // $199\n oneShotFeeBps: 50, // 0.5%\n subscriptionPremiumBps: 20, // 0.7% effective\n monthlyVolumeCapUsdCents: 100_000_000, // $1,000,000\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n monthlyFeeUsdCents: null,\n oneShotFeeBps: null,\n subscriptionPremiumBps: null,\n monthlyVolumeCapUsdCents: null,\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nexport function getTier(id: MerchantTier): TierDefinition {\n return TIERS[id]\n}\n\n/**\n * Effective fee in bps for a given tier and payment kind.\n * Returns `null` for the enterprise tier (custom-priced).\n */\nexport function effectiveFeeBps(\n tier: MerchantTier,\n kind: 'one_shot' | 'subscription',\n): number | null {\n const def = TIERS[tier]\n if (def.oneShotFeeBps === null) return null\n if (kind === 'one_shot') return def.oneShotFeeBps\n return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0)\n}\n"]}
1
+ {"version":3,"sources":["../src/tokens.ts","../src/tiers.ts"],"names":[],"mappings":";;;AAkBO,IAAM,cAAA,GAA0C,CAAC,MAAA,EAAQ,MAAM,CAAA;AAkB/D,IAAM,MAAA,GAA+C;AAAA,EAC1D,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,UAAA;AAAA,IACN,QAAA,EAAU,CAAA;AAAA,IACV,eAAA,EAAiB,IAAA;AAAA,IACjB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,WAAA;AAAA,IACN,QAAA,EAAU,CAAA;AAAA,IACV,eAAA,EAAiB,IAAA;AAAA,IACjB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,eAAA;AAAA,IACN,QAAA,EAAU,CAAA;AAAA,IACV,eAAA,EAAiB,KAAA;AAAA,IACjB,YAAA,EAAc;AAAA;AAElB,CAAA;;;ACjCA,IAAM,aAAA,GAAwC;AAAA,EAC5C,YAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA;AAEO,IAAM,KAAA,GAA8C;AAAA,EACzD,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,MAAA;AAAA,IACJ,IAAA,EAAM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AAM,IAAI,CAAA,CAAE,QAAA,CAAS,SAAS,OAAO,CAAA;AAC9C;AAEO,SAAS,UAAU,OAAA,EAAsC;AAC9D,EAAA,OAAO,WAAW,MAAA,CAAO,CAAC,SAAS,YAAA,CAAa,IAAA,EAAM,OAAO,CAAC,CAAA;AAChE;AAEO,SAAS,eAAe,OAAA,EAAoC;AACjE,EAAA,MAAM,IAAA,GAAO,WAAW,IAAA,CAAK,CAAC,cAAc,YAAA,CAAa,SAAA,EAAW,OAAO,CAAC,CAAA;AAC5E,EAAA,IAAI,CAAC,IAAA,EAAM,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAE,CAAA;AACxD,EAAA,OAAO,IAAA;AACT;AAIA,SAAS,oBAAA,CAAqB,MAAkB,KAAA,EAA6B;AAC3E,EAAA,MAAM,UAAA,GAAa,KAAA,CAAM,IAAI,CAAA,CAAE,cAAA;AAC/B,EAAA,IAAI,eAAe,IAAA,EAAM,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA,wBAAA,CAA0B,CAAA;AAC1E,EAAA,OAAO,MAAA,CAAO,UAAU,CAAA,GAAI,GAAA,IAAO,OAAO,MAAA,CAAO,KAAK,EAAE,QAAQ,CAAA;AAClE;AAEO,SAAS,cAAc,OAAA,EAAqC;AACjE,EAAA,IAAI,OAAA,GAAsB,MAAA;AAC1B,EAAA,KAAA,MAAW,QAAQ,YAAA,EAAc;AAC/B,IAAA,IAAI,cAAA,CAAe,IAAA,CAAK,CAAC,KAAA,KAAU,OAAA,CAAQ,KAAK,CAAA,IAAK,oBAAA,CAAqB,IAAA,EAAM,KAAK,CAAC,CAAA,EAAG;AACvF,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT","file":"tiers.cjs","sourcesContent":["/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens. They can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only. Merchants\n * can hold it and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { getArcChain, parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',\n USYC: '0x8a5D989Bbb96929F689B0200f435f53dA42bF490',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[parseArcEnvironment(env)][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return getArcChain(env).id\n}\n","/**\n * Strimz pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nimport { PAYMENT_TOKENS, TOKENS, type PaymentToken } from './tokens.js'\n\nexport type MerchantTier = 'free' | 'starter' | 'growth' | 'enterprise'\n\nexport type VolumePlan = Exclude<MerchantTier, 'enterprise'>\n\nexport type PlanFeature = 'storefront' | 'anomaly_alerts' | 'yield_recommendations'\n\nexport interface PlanDefinition {\n id: MerchantTier\n name: string\n feeBps: number | null\n entersAtVolume: number | null\n features: readonly PlanFeature[]\n prioritySupport: boolean\n}\n\nconst PAID_FEATURES: readonly PlanFeature[] = [\n 'storefront',\n 'anomaly_alerts',\n 'yield_recommendations',\n]\n\nexport const PLANS: Record<MerchantTier, PlanDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n feeBps: 0,\n entersAtVolume: 0,\n features: [],\n prioritySupport: false,\n },\n starter: {\n id: 'starter',\n name: 'Starter',\n feeBps: 50,\n entersAtVolume: 1_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n feeBps: 40,\n entersAtVolume: 50_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n feeBps: null,\n entersAtVolume: null,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nconst PLAN_ORDER: readonly MerchantTier[] = ['free', 'starter', 'growth', 'enterprise']\n\nconst VOLUME_PLANS: readonly VolumePlan[] = ['free', 'starter', 'growth']\n\nexport const PLAN_FEE_CEILING_BPS: number = Math.max(\n ...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0),\n)\n\nexport function planFeeBps(plan: MerchantTier): number | null {\n return PLANS[plan].feeBps\n}\n\nexport function planIncludes(plan: MerchantTier, feature: PlanFeature): boolean {\n return PLANS[plan].features.includes(feature)\n}\n\nexport function plansWith(feature: PlanFeature): MerchantTier[] {\n return PLAN_ORDER.filter((plan) => planIncludes(plan, feature))\n}\n\nexport function lowestPlanWith(feature: PlanFeature): MerchantTier {\n const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature))\n if (!plan) throw new Error(`no plan includes ${feature}`)\n return plan\n}\n\nexport type PaymentVolumes = Readonly<Record<PaymentToken, bigint>>\n\nfunction thresholdInBaseUnits(plan: VolumePlan, token: PaymentToken): bigint {\n const wholeUnits = PLANS[plan].entersAtVolume\n if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`)\n return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals)\n}\n\nexport function planForVolume(volumes: PaymentVolumes): VolumePlan {\n let reached: VolumePlan = 'free'\n for (const plan of VOLUME_PLANS) {\n if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {\n reached = plan\n }\n }\n return reached\n}\n"]}
package/dist/tiers.d.cts CHANGED
@@ -1,3 +1,7 @@
1
+ import { PaymentToken } from './tokens.cjs';
2
+ import 'viem';
3
+ import './chains.cjs';
4
+
1
5
  /**
2
6
  * Strimz pricing tiers.
3
7
  *
@@ -5,30 +9,26 @@
5
9
  * The subscription premium is added to the per-transaction rate when the
6
10
  * payment is recurring (i.e. originated from a SubscriptionPlan).
7
11
  */
8
- type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise';
9
- interface TierDefinition {
12
+
13
+ type MerchantTier = 'free' | 'starter' | 'growth' | 'enterprise';
14
+ type VolumePlan = Exclude<MerchantTier, 'enterprise'>;
15
+ type PlanFeature = 'storefront' | 'anomaly_alerts' | 'yield_recommendations';
16
+ interface PlanDefinition {
10
17
  id: MerchantTier;
11
18
  name: string;
12
- /** Monthly fee in USD cents (0 for free, null for custom enterprise). */
13
- monthlyFeeUsdCents: number | null;
14
- /** Per-transaction fee on one-shot payments, in basis points. */
15
- oneShotFeeBps: number | null;
16
- /** Per-transaction premium added on subscription payments, in basis points. */
17
- subscriptionPremiumBps: number | null;
18
- /** Monthly transaction volume cap in USD cents. `null` for unlimited. */
19
- monthlyVolumeCapUsdCents: number | null;
20
- /** Whether the "Powered by Strimz" badge can be removed from checkout. */
21
- whiteLabelEligible: boolean;
22
- /** Whether the tier includes priority support. */
19
+ feeBps: number | null;
20
+ entersAtVolume: number | null;
21
+ features: readonly PlanFeature[];
23
22
  prioritySupport: boolean;
24
23
  }
25
- declare const TIERS: Record<MerchantTier, TierDefinition>;
24
+ declare const PLANS: Record<MerchantTier, PlanDefinition>;
26
25
  declare const DEFAULT_TIER: MerchantTier;
27
- declare function getTier(id: MerchantTier): TierDefinition;
28
- /**
29
- * Effective fee in bps for a given tier and payment kind.
30
- * Returns `null` for the enterprise tier (custom-priced).
31
- */
32
- declare function effectiveFeeBps(tier: MerchantTier, kind: 'one_shot' | 'subscription'): number | null;
26
+ declare const PLAN_FEE_CEILING_BPS: number;
27
+ declare function planFeeBps(plan: MerchantTier): number | null;
28
+ declare function planIncludes(plan: MerchantTier, feature: PlanFeature): boolean;
29
+ declare function plansWith(feature: PlanFeature): MerchantTier[];
30
+ declare function lowestPlanWith(feature: PlanFeature): MerchantTier;
31
+ type PaymentVolumes = Readonly<Record<PaymentToken, bigint>>;
32
+ declare function planForVolume(volumes: PaymentVolumes): VolumePlan;
33
33
 
34
- export { DEFAULT_TIER, type MerchantTier, TIERS, type TierDefinition, effectiveFeeBps, getTier };
34
+ export { DEFAULT_TIER, type MerchantTier, PLANS, PLAN_FEE_CEILING_BPS, type PaymentVolumes, type PlanDefinition, type PlanFeature, type VolumePlan, lowestPlanWith, planFeeBps, planForVolume, planIncludes, plansWith };
package/dist/tiers.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { PaymentToken } from './tokens.js';
2
+ import 'viem';
3
+ import './chains.js';
4
+
1
5
  /**
2
6
  * Strimz pricing tiers.
3
7
  *
@@ -5,30 +9,26 @@
5
9
  * The subscription premium is added to the per-transaction rate when the
6
10
  * payment is recurring (i.e. originated from a SubscriptionPlan).
7
11
  */
8
- type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise';
9
- interface TierDefinition {
12
+
13
+ type MerchantTier = 'free' | 'starter' | 'growth' | 'enterprise';
14
+ type VolumePlan = Exclude<MerchantTier, 'enterprise'>;
15
+ type PlanFeature = 'storefront' | 'anomaly_alerts' | 'yield_recommendations';
16
+ interface PlanDefinition {
10
17
  id: MerchantTier;
11
18
  name: string;
12
- /** Monthly fee in USD cents (0 for free, null for custom enterprise). */
13
- monthlyFeeUsdCents: number | null;
14
- /** Per-transaction fee on one-shot payments, in basis points. */
15
- oneShotFeeBps: number | null;
16
- /** Per-transaction premium added on subscription payments, in basis points. */
17
- subscriptionPremiumBps: number | null;
18
- /** Monthly transaction volume cap in USD cents. `null` for unlimited. */
19
- monthlyVolumeCapUsdCents: number | null;
20
- /** Whether the "Powered by Strimz" badge can be removed from checkout. */
21
- whiteLabelEligible: boolean;
22
- /** Whether the tier includes priority support. */
19
+ feeBps: number | null;
20
+ entersAtVolume: number | null;
21
+ features: readonly PlanFeature[];
23
22
  prioritySupport: boolean;
24
23
  }
25
- declare const TIERS: Record<MerchantTier, TierDefinition>;
24
+ declare const PLANS: Record<MerchantTier, PlanDefinition>;
26
25
  declare const DEFAULT_TIER: MerchantTier;
27
- declare function getTier(id: MerchantTier): TierDefinition;
28
- /**
29
- * Effective fee in bps for a given tier and payment kind.
30
- * Returns `null` for the enterprise tier (custom-priced).
31
- */
32
- declare function effectiveFeeBps(tier: MerchantTier, kind: 'one_shot' | 'subscription'): number | null;
26
+ declare const PLAN_FEE_CEILING_BPS: number;
27
+ declare function planFeeBps(plan: MerchantTier): number | null;
28
+ declare function planIncludes(plan: MerchantTier, feature: PlanFeature): boolean;
29
+ declare function plansWith(feature: PlanFeature): MerchantTier[];
30
+ declare function lowestPlanWith(feature: PlanFeature): MerchantTier;
31
+ type PaymentVolumes = Readonly<Record<PaymentToken, bigint>>;
32
+ declare function planForVolume(volumes: PaymentVolumes): VolumePlan;
33
33
 
34
- export { DEFAULT_TIER, type MerchantTier, TIERS, type TierDefinition, effectiveFeeBps, getTier };
34
+ export { DEFAULT_TIER, type MerchantTier, PLANS, PLAN_FEE_CEILING_BPS, type PaymentVolumes, type PlanDefinition, type PlanFeature, type VolumePlan, lowestPlanWith, planFeeBps, planForVolume, planIncludes, plansWith };
package/dist/tiers.js CHANGED
@@ -1,68 +1,104 @@
1
+ // src/tokens.ts
2
+ var PAYMENT_TOKENS = ["USDC", "EURC"];
3
+ var TOKENS = {
4
+ USDC: {
5
+ symbol: "USDC",
6
+ name: "USD Coin",
7
+ decimals: 6,
8
+ paymentEligible: true,
9
+ yieldBearing: false
10
+ },
11
+ EURC: {
12
+ symbol: "EURC",
13
+ name: "Euro Coin",
14
+ decimals: 6,
15
+ paymentEligible: true,
16
+ yieldBearing: false
17
+ },
18
+ USYC: {
19
+ symbol: "USYC",
20
+ name: "US Yield Coin",
21
+ decimals: 6,
22
+ paymentEligible: false,
23
+ yieldBearing: true
24
+ }
25
+ };
26
+
1
27
  // src/tiers.ts
2
- var TIERS = {
28
+ var PAID_FEATURES = [
29
+ "storefront",
30
+ "anomaly_alerts",
31
+ "yield_recommendations"
32
+ ];
33
+ var PLANS = {
3
34
  free: {
4
35
  id: "free",
5
36
  name: "Free",
6
- monthlyFeeUsdCents: 0,
7
- oneShotFeeBps: 150,
8
- // 1.5%
9
- subscriptionPremiumBps: 20,
10
- // +0.2% on recurring => 1.7% effective
11
- monthlyVolumeCapUsdCents: 1e6,
12
- // $10,000
13
- whiteLabelEligible: false,
37
+ feeBps: 0,
38
+ entersAtVolume: 0,
39
+ features: [],
14
40
  prioritySupport: false
15
41
  },
42
+ starter: {
43
+ id: "starter",
44
+ name: "Starter",
45
+ feeBps: 50,
46
+ entersAtVolume: 1e3,
47
+ features: PAID_FEATURES,
48
+ prioritySupport: true
49
+ },
16
50
  growth: {
17
51
  id: "growth",
18
52
  name: "Growth",
19
- monthlyFeeUsdCents: 4900,
20
- // $49
21
- oneShotFeeBps: 80,
22
- // 0.8%
23
- subscriptionPremiumBps: 20,
24
- // 1.0% effective
25
- monthlyVolumeCapUsdCents: 1e7,
26
- // $100,000
27
- whiteLabelEligible: true,
28
- prioritySupport: false
29
- },
30
- business: {
31
- id: "business",
32
- name: "Business",
33
- monthlyFeeUsdCents: 19900,
34
- // $199
35
- oneShotFeeBps: 50,
36
- // 0.5%
37
- subscriptionPremiumBps: 20,
38
- // 0.7% effective
39
- monthlyVolumeCapUsdCents: 1e8,
40
- // $1,000,000
41
- whiteLabelEligible: true,
53
+ feeBps: 40,
54
+ entersAtVolume: 5e4,
55
+ features: PAID_FEATURES,
42
56
  prioritySupport: true
43
57
  },
44
58
  enterprise: {
45
59
  id: "enterprise",
46
60
  name: "Enterprise",
47
- monthlyFeeUsdCents: null,
48
- oneShotFeeBps: null,
49
- subscriptionPremiumBps: null,
50
- monthlyVolumeCapUsdCents: null,
51
- whiteLabelEligible: true,
61
+ feeBps: null,
62
+ entersAtVolume: null,
63
+ features: PAID_FEATURES,
52
64
  prioritySupport: true
53
65
  }
54
66
  };
55
67
  var DEFAULT_TIER = "free";
56
- function getTier(id) {
57
- return TIERS[id];
68
+ var PLAN_ORDER = ["free", "starter", "growth", "enterprise"];
69
+ var VOLUME_PLANS = ["free", "starter", "growth"];
70
+ var PLAN_FEE_CEILING_BPS = Math.max(
71
+ ...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0)
72
+ );
73
+ function planFeeBps(plan) {
74
+ return PLANS[plan].feeBps;
75
+ }
76
+ function planIncludes(plan, feature) {
77
+ return PLANS[plan].features.includes(feature);
78
+ }
79
+ function plansWith(feature) {
80
+ return PLAN_ORDER.filter((plan) => planIncludes(plan, feature));
58
81
  }
59
- function effectiveFeeBps(tier, kind) {
60
- const def = TIERS[tier];
61
- if (def.oneShotFeeBps === null) return null;
62
- if (kind === "one_shot") return def.oneShotFeeBps;
63
- return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0);
82
+ function lowestPlanWith(feature) {
83
+ const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature));
84
+ if (!plan) throw new Error(`no plan includes ${feature}`);
85
+ return plan;
86
+ }
87
+ function thresholdInBaseUnits(plan, token) {
88
+ const wholeUnits = PLANS[plan].entersAtVolume;
89
+ if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`);
90
+ return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals);
91
+ }
92
+ function planForVolume(volumes) {
93
+ let reached = "free";
94
+ for (const plan of VOLUME_PLANS) {
95
+ if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {
96
+ reached = plan;
97
+ }
98
+ }
99
+ return reached;
64
100
  }
65
101
 
66
- export { DEFAULT_TIER, TIERS, effectiveFeeBps, getTier };
102
+ export { DEFAULT_TIER, PLANS, PLAN_FEE_CEILING_BPS, lowestPlanWith, planFeeBps, planForVolume, planIncludes, plansWith };
67
103
  //# sourceMappingURL=tiers.js.map
68
104
  //# sourceMappingURL=tiers.js.map
package/dist/tiers.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tiers.ts"],"names":[],"mappings":";AA2BO,IAAM,KAAA,GAA8C;AAAA,EACzD,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,MAAA;AAAA,IACJ,IAAA,EAAM,MAAA;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EACe;AACf,EAAA,MAAM,GAAA,GAAM,MAAM,IAAI,CAAA;AACtB,EAAA,IAAI,GAAA,CAAI,aAAA,KAAkB,IAAA,EAAM,OAAO,IAAA;AACvC,EAAA,IAAI,IAAA,KAAS,UAAA,EAAY,OAAO,GAAA,CAAI,aAAA;AACpC,EAAA,OAAO,GAAA,CAAI,aAAA,IAAiB,GAAA,CAAI,sBAAA,IAA0B,CAAA,CAAA;AAC5D","file":"tiers.js","sourcesContent":["/**\n * Strimz pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nexport type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise'\n\nexport interface TierDefinition {\n id: MerchantTier\n name: string\n /** Monthly fee in USD cents (0 for free, null for custom enterprise). */\n monthlyFeeUsdCents: number | null\n /** Per-transaction fee on one-shot payments, in basis points. */\n oneShotFeeBps: number | null\n /** Per-transaction premium added on subscription payments, in basis points. */\n subscriptionPremiumBps: number | null\n /** Monthly transaction volume cap in USD cents. `null` for unlimited. */\n monthlyVolumeCapUsdCents: number | null\n /** Whether the \"Powered by Strimz\" badge can be removed from checkout. */\n whiteLabelEligible: boolean\n /** Whether the tier includes priority support. */\n prioritySupport: boolean\n}\n\nexport const TIERS: Record<MerchantTier, TierDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n monthlyFeeUsdCents: 0,\n oneShotFeeBps: 150, // 1.5%\n subscriptionPremiumBps: 20, // +0.2% on recurring => 1.7% effective\n monthlyVolumeCapUsdCents: 1_000_000, // $10,000\n whiteLabelEligible: false,\n prioritySupport: false,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n monthlyFeeUsdCents: 4_900, // $49\n oneShotFeeBps: 80, // 0.8%\n subscriptionPremiumBps: 20, // 1.0% effective\n monthlyVolumeCapUsdCents: 10_000_000, // $100,000\n whiteLabelEligible: true,\n prioritySupport: false,\n },\n business: {\n id: 'business',\n name: 'Business',\n monthlyFeeUsdCents: 19_900, // $199\n oneShotFeeBps: 50, // 0.5%\n subscriptionPremiumBps: 20, // 0.7% effective\n monthlyVolumeCapUsdCents: 100_000_000, // $1,000,000\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n monthlyFeeUsdCents: null,\n oneShotFeeBps: null,\n subscriptionPremiumBps: null,\n monthlyVolumeCapUsdCents: null,\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nexport function getTier(id: MerchantTier): TierDefinition {\n return TIERS[id]\n}\n\n/**\n * Effective fee in bps for a given tier and payment kind.\n * Returns `null` for the enterprise tier (custom-priced).\n */\nexport function effectiveFeeBps(\n tier: MerchantTier,\n kind: 'one_shot' | 'subscription',\n): number | null {\n const def = TIERS[tier]\n if (def.oneShotFeeBps === null) return null\n if (kind === 'one_shot') return def.oneShotFeeBps\n return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0)\n}\n"]}
1
+ {"version":3,"sources":["../src/tokens.ts","../src/tiers.ts"],"names":[],"mappings":";AAkBO,IAAM,cAAA,GAA0C,CAAC,MAAA,EAAQ,MAAM,CAAA;AAkB/D,IAAM,MAAA,GAA+C;AAAA,EAC1D,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,UAAA;AAAA,IACN,QAAA,EAAU,CAAA;AAAA,IACV,eAAA,EAAiB,IAAA;AAAA,IACjB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,WAAA;AAAA,IACN,QAAA,EAAU,CAAA;AAAA,IACV,eAAA,EAAiB,IAAA;AAAA,IACjB,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,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Ae,IAAA,CAAK,CAAC,KAAA,KAAU,OAAA,CAAQ,KAAK,CAAA,IAAK,oBAAA,CAAqB,IAAA,EAAM,KAAK,CAAC,CAAA,EAAG;AACvF,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT","file":"tiers.js","sourcesContent":["/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens. They can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only. Merchants\n * can hold it and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { getArcChain, parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',\n USYC: '0x8a5D989Bbb96929F689B0200f435f53dA42bF490',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[parseArcEnvironment(env)][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return getArcChain(env).id\n}\n","/**\n * Strimz pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nimport { PAYMENT_TOKENS, TOKENS, type PaymentToken } from './tokens.js'\n\nexport type MerchantTier = 'free' | 'starter' | 'growth' | 'enterprise'\n\nexport type VolumePlan = Exclude<MerchantTier, 'enterprise'>\n\nexport type PlanFeature = 'storefront' | 'anomaly_alerts' | 'yield_recommendations'\n\nexport interface PlanDefinition {\n id: MerchantTier\n name: string\n feeBps: number | null\n entersAtVolume: number | null\n features: readonly PlanFeature[]\n prioritySupport: boolean\n}\n\nconst PAID_FEATURES: readonly PlanFeature[] = [\n 'storefront',\n 'anomaly_alerts',\n 'yield_recommendations',\n]\n\nexport const PLANS: Record<MerchantTier, PlanDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n feeBps: 0,\n entersAtVolume: 0,\n features: [],\n prioritySupport: false,\n },\n starter: {\n id: 'starter',\n name: 'Starter',\n feeBps: 50,\n entersAtVolume: 1_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n feeBps: 40,\n entersAtVolume: 50_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n feeBps: null,\n entersAtVolume: null,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nconst PLAN_ORDER: readonly MerchantTier[] = ['free', 'starter', 'growth', 'enterprise']\n\nconst VOLUME_PLANS: readonly VolumePlan[] = ['free', 'starter', 'growth']\n\nexport const PLAN_FEE_CEILING_BPS: number = Math.max(\n ...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0),\n)\n\nexport function planFeeBps(plan: MerchantTier): number | null {\n return PLANS[plan].feeBps\n}\n\nexport function planIncludes(plan: MerchantTier, feature: PlanFeature): boolean {\n return PLANS[plan].features.includes(feature)\n}\n\nexport function plansWith(feature: PlanFeature): MerchantTier[] {\n return PLAN_ORDER.filter((plan) => planIncludes(plan, feature))\n}\n\nexport function lowestPlanWith(feature: PlanFeature): MerchantTier {\n const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature))\n if (!plan) throw new Error(`no plan includes ${feature}`)\n return plan\n}\n\nexport type PaymentVolumes = Readonly<Record<PaymentToken, bigint>>\n\nfunction thresholdInBaseUnits(plan: VolumePlan, token: PaymentToken): bigint {\n const wholeUnits = PLANS[plan].entersAtVolume\n if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`)\n return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals)\n}\n\nexport function planForVolume(volumes: PaymentVolumes): VolumePlan {\n let reached: VolumePlan = 'free'\n for (const plan of VOLUME_PLANS) {\n if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {\n reached = plan\n }\n }\n return reached\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strimz/shared-config",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Single source of truth for chain definitions, token registry, fee tiers, webhook events, and agent flags.",
5
5
  "license": "MIT",
6
6
  "author": "Strimz <hello@strimz.finance>",