@strimz/shared-config 0.1.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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/agents.cjs +65 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +39 -0
- package/dist/agents.d.ts +39 -0
- package/dist/agents.js +60 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +37 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +28 -0
- package/dist/api-keys.d.ts +28 -0
- package/dist/api-keys.js +30 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/cctp.cjs +51 -0
- package/dist/cctp.cjs.map +1 -0
- package/dist/cctp.d.cts +38 -0
- package/dist/cctp.d.ts +38 -0
- package/dist/cctp.js +46 -0
- package/dist/cctp.js.map +1 -0
- package/dist/chains.cjs +64 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +23 -0
- package/dist/chains.d.ts +23 -0
- package/dist/chains.js +56 -0
- package/dist/chains.js.map +1 -0
- package/dist/index.cjs +403 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +363 -0
- package/dist/index.js.map +1 -0
- package/dist/tiers.cjs +73 -0
- package/dist/tiers.cjs.map +1 -0
- package/dist/tiers.d.cts +34 -0
- package/dist/tiers.d.ts +34 -0
- package/dist/tiers.js +68 -0
- package/dist/tiers.js.map +1 -0
- package/dist/tokens.cjs +107 -0
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.cts +44 -0
- package/dist/tokens.d.ts +44 -0
- package/dist/tokens.js +99 -0
- package/dist/tokens.js.map +1 -0
- package/dist/webhooks.cjs +73 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +55 -0
- package/dist/webhooks.d.ts +55 -0
- package/dist/webhooks.js +65 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +96 -0
- package/src/agents.ts +102 -0
- package/src/api-keys.ts +43 -0
- package/src/cctp.ts +68 -0
- package/src/chains.ts +70 -0
- package/src/index.ts +17 -0
- package/src/tiers.ts +89 -0
- package/src/tokens.ts +96 -0
- package/src/webhooks.ts +80 -0
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strimz/shared-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Single source of truth for chain definitions, token registry, fee tiers, webhook events, and agent flags.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Strimz <hello@strimz.finance>",
|
|
7
|
+
"homepage": "https://github.com/StrimzLab/strimz/tree/main/packages/shared-config#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/StrimzLab/strimz.git",
|
|
11
|
+
"directory": "packages/shared-config"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/StrimzLab/strimz/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"strimz",
|
|
18
|
+
"usdc",
|
|
19
|
+
"stablecoin",
|
|
20
|
+
"arc",
|
|
21
|
+
"billing"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./chains": {
|
|
38
|
+
"types": "./dist/chains.d.ts",
|
|
39
|
+
"import": "./dist/chains.js",
|
|
40
|
+
"require": "./dist/chains.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./tokens": {
|
|
43
|
+
"types": "./dist/tokens.d.ts",
|
|
44
|
+
"import": "./dist/tokens.js",
|
|
45
|
+
"require": "./dist/tokens.cjs"
|
|
46
|
+
},
|
|
47
|
+
"./tiers": {
|
|
48
|
+
"types": "./dist/tiers.d.ts",
|
|
49
|
+
"import": "./dist/tiers.js",
|
|
50
|
+
"require": "./dist/tiers.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./webhooks": {
|
|
53
|
+
"types": "./dist/webhooks.d.ts",
|
|
54
|
+
"import": "./dist/webhooks.js",
|
|
55
|
+
"require": "./dist/webhooks.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./api-keys": {
|
|
58
|
+
"types": "./dist/api-keys.d.ts",
|
|
59
|
+
"import": "./dist/api-keys.js",
|
|
60
|
+
"require": "./dist/api-keys.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./agents": {
|
|
63
|
+
"types": "./dist/agents.d.ts",
|
|
64
|
+
"import": "./dist/agents.js",
|
|
65
|
+
"require": "./dist/agents.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./cctp": {
|
|
68
|
+
"types": "./dist/cctp.d.ts",
|
|
69
|
+
"import": "./dist/cctp.js",
|
|
70
|
+
"require": "./dist/cctp.cjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"dist",
|
|
75
|
+
"src",
|
|
76
|
+
"README.md",
|
|
77
|
+
"LICENSE"
|
|
78
|
+
],
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"viem": "^2.22.6"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"eslint": "^9.18.0",
|
|
84
|
+
"tsup": "^8.3.5",
|
|
85
|
+
"typescript": "^5.7.3",
|
|
86
|
+
"@strimz/eslint-config": "0.0.0",
|
|
87
|
+
"@strimz/tsconfig": "0.0.0"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "tsup",
|
|
91
|
+
"dev": "tsup --watch",
|
|
92
|
+
"lint": "eslint .",
|
|
93
|
+
"typecheck": "tsc --noEmit",
|
|
94
|
+
"clean": "rm -rf dist .turbo *.tsbuildinfo"
|
|
95
|
+
}
|
|
96
|
+
}
|
package/src/agents.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strimz AutoPay Agent — feature flags and defaults.
|
|
3
|
+
*
|
|
4
|
+
* The agent is composed of independent capabilities that can be enabled or
|
|
5
|
+
* disabled per merchant. Defaults are conservative; merchants opt in to
|
|
6
|
+
* value-moving capabilities (recovery retries, treasury auto-convert).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type AgentCapability =
|
|
10
|
+
| 'identity'
|
|
11
|
+
| 'recovery'
|
|
12
|
+
| 'routing'
|
|
13
|
+
| 'cashflow'
|
|
14
|
+
| 'commerce'
|
|
15
|
+
| 'pricing_intelligence'
|
|
16
|
+
|
|
17
|
+
export interface AgentCapabilityDescriptor {
|
|
18
|
+
id: AgentCapability
|
|
19
|
+
name: string
|
|
20
|
+
/** Whether the capability moves money or signs transactions. */
|
|
21
|
+
valueMoving: boolean
|
|
22
|
+
/** Default enabled state for a newly created merchant. */
|
|
23
|
+
defaultEnabled: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const AGENT_CAPABILITIES: Record<AgentCapability, AgentCapabilityDescriptor> = {
|
|
27
|
+
identity: {
|
|
28
|
+
id: 'identity',
|
|
29
|
+
name: 'Agent Identity (ERC-8004)',
|
|
30
|
+
valueMoving: false,
|
|
31
|
+
defaultEnabled: true,
|
|
32
|
+
},
|
|
33
|
+
recovery: {
|
|
34
|
+
id: 'recovery',
|
|
35
|
+
name: 'Subscription Recovery',
|
|
36
|
+
valueMoving: true,
|
|
37
|
+
defaultEnabled: false,
|
|
38
|
+
},
|
|
39
|
+
routing: {
|
|
40
|
+
id: 'routing',
|
|
41
|
+
name: 'Cross-Chain Payment Routing',
|
|
42
|
+
valueMoving: true,
|
|
43
|
+
defaultEnabled: false,
|
|
44
|
+
},
|
|
45
|
+
cashflow: {
|
|
46
|
+
id: 'cashflow',
|
|
47
|
+
name: 'Treasury Cash Flow Insights',
|
|
48
|
+
valueMoving: false,
|
|
49
|
+
defaultEnabled: false,
|
|
50
|
+
},
|
|
51
|
+
commerce: {
|
|
52
|
+
id: 'commerce',
|
|
53
|
+
name: 'Agentic B2B Commerce (ERC-8183)',
|
|
54
|
+
valueMoving: true,
|
|
55
|
+
defaultEnabled: false,
|
|
56
|
+
},
|
|
57
|
+
pricing_intelligence: {
|
|
58
|
+
id: 'pricing_intelligence',
|
|
59
|
+
name: 'Subscription Pricing Intelligence',
|
|
60
|
+
valueMoving: false,
|
|
61
|
+
defaultEnabled: false,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type GracePeriodHours = 24 | 48 | 72
|
|
66
|
+
|
|
67
|
+
export const RECOVERY_GRACE_PERIODS: readonly GracePeriodHours[] = [24, 48, 72] as const
|
|
68
|
+
|
|
69
|
+
export type RecoveryRetryStrategy = 'once' | 'twice' | 'until_grace_ends'
|
|
70
|
+
|
|
71
|
+
export interface AgentDefaultConfig {
|
|
72
|
+
recovery: {
|
|
73
|
+
gracePeriodHours: GracePeriodHours
|
|
74
|
+
strategy: RecoveryRetryStrategy
|
|
75
|
+
}
|
|
76
|
+
cashflow: {
|
|
77
|
+
digestEnabled: boolean
|
|
78
|
+
anomalySensitivity: 'low' | 'medium' | 'high'
|
|
79
|
+
autoConvertToYield: boolean
|
|
80
|
+
}
|
|
81
|
+
commerce: {
|
|
82
|
+
requireHumanApprovalAboveUsdCents: number
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const AGENT_DEFAULTS: AgentDefaultConfig = {
|
|
87
|
+
recovery: {
|
|
88
|
+
gracePeriodHours: 48,
|
|
89
|
+
strategy: 'twice',
|
|
90
|
+
},
|
|
91
|
+
cashflow: {
|
|
92
|
+
digestEnabled: false,
|
|
93
|
+
anomalySensitivity: 'medium',
|
|
94
|
+
autoConvertToYield: false,
|
|
95
|
+
},
|
|
96
|
+
commerce: {
|
|
97
|
+
requireHumanApprovalAboveUsdCents: 100_000, // $1,000
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Time-to-live for the agent activity log, in days. */
|
|
102
|
+
export const AGENT_ACTIVITY_LOG_RETENTION_DAYS = 90
|
package/src/api-keys.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API key prefix conventions.
|
|
3
|
+
*
|
|
4
|
+
* Prefix tells you immediately which environment a key targets and whether it
|
|
5
|
+
* is safe to expose to the client. Secret keys are server-side only; publishable
|
|
6
|
+
* keys can ship in browser bundles.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ApiKeyMode = 'test' | 'live'
|
|
10
|
+
export type ApiKeyKind = 'secret' | 'publishable'
|
|
11
|
+
|
|
12
|
+
export const API_KEY_PREFIXES = {
|
|
13
|
+
secret: {
|
|
14
|
+
test: 'sk_test_',
|
|
15
|
+
live: 'sk_live_',
|
|
16
|
+
},
|
|
17
|
+
publishable: {
|
|
18
|
+
test: 'pk_test_',
|
|
19
|
+
live: 'pk_live_',
|
|
20
|
+
},
|
|
21
|
+
} as const satisfies Record<ApiKeyKind, Record<ApiKeyMode, string>>
|
|
22
|
+
|
|
23
|
+
/** Length of the random portion of a key, before prefix. Base62, 256 bits of entropy. */
|
|
24
|
+
export const API_KEY_RANDOM_BYTES = 32
|
|
25
|
+
|
|
26
|
+
export function prefixFor(kind: ApiKeyKind, mode: ApiKeyMode): string {
|
|
27
|
+
return API_KEY_PREFIXES[kind][mode]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function modeFromKey(key: string): ApiKeyMode | null {
|
|
31
|
+
if (key.startsWith('sk_test_') || key.startsWith('pk_test_')) return 'test'
|
|
32
|
+
if (key.startsWith('sk_live_') || key.startsWith('pk_live_')) return 'live'
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function kindFromKey(key: string): ApiKeyKind | null {
|
|
37
|
+
if (key.startsWith('sk_')) return 'secret'
|
|
38
|
+
if (key.startsWith('pk_')) return 'publishable'
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Number of leading characters of a key safe to display in dashboards/logs. */
|
|
43
|
+
export const API_KEY_PREFIX_DISPLAY_LENGTH = 12
|
package/src/cctp.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circle CCTP V2 contract addresses for Arc.
|
|
3
|
+
*
|
|
4
|
+
* CCTP lets a payer hold USDC on any supported chain (Ethereum, Base, Polygon,
|
|
5
|
+
* Arbitrum, Solana, etc.) and pay a Strimz merchant who receives Arc USDC.
|
|
6
|
+
*
|
|
7
|
+
* @see https://developers.circle.com/stablecoins/cctp-getting-started
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { Address } from 'viem'
|
|
11
|
+
import type { ArcEnvironment } from './chains.js'
|
|
12
|
+
|
|
13
|
+
export interface CCTPContractSet {
|
|
14
|
+
tokenMessengerV2: Address
|
|
15
|
+
messageTransmitterV2: Address
|
|
16
|
+
gatewayWallet: Address
|
|
17
|
+
gatewayMinter: Address
|
|
18
|
+
/** CCTP domain identifier for the destination chain. */
|
|
19
|
+
domainId: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const CCTP_CONTRACTS: Record<ArcEnvironment, CCTPContractSet> = {
|
|
23
|
+
testnet: {
|
|
24
|
+
tokenMessengerV2: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
25
|
+
messageTransmitterV2: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
26
|
+
gatewayWallet: '0x0077777d7EBA4688BDeF3E311b846F25870A19B9',
|
|
27
|
+
gatewayMinter: '0x0022222ABE238Cc2C7Bb1f21003F0a260052475B',
|
|
28
|
+
domainId: 26,
|
|
29
|
+
},
|
|
30
|
+
mainnet: {
|
|
31
|
+
// Pending Circle's mainnet publication of CCTP V2 addresses for Arc.
|
|
32
|
+
// Mirror testnet as a placeholder so type signatures stay non-null.
|
|
33
|
+
tokenMessengerV2: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
34
|
+
messageTransmitterV2: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
35
|
+
gatewayWallet: '0x0077777d7EBA4688BDeF3E311b846F25870A19B9',
|
|
36
|
+
gatewayMinter: '0x0022222ABE238Cc2C7Bb1f21003F0a260052475B',
|
|
37
|
+
domainId: 26,
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** CCTP domain ids for source chains a payer can bridge from. */
|
|
42
|
+
export const CCTP_DOMAIN_IDS = {
|
|
43
|
+
ethereum: 0,
|
|
44
|
+
avalanche: 1,
|
|
45
|
+
optimism: 2,
|
|
46
|
+
arbitrum: 3,
|
|
47
|
+
noble: 4,
|
|
48
|
+
solana: 5,
|
|
49
|
+
base: 6,
|
|
50
|
+
polygon: 7,
|
|
51
|
+
arc: 26,
|
|
52
|
+
} as const
|
|
53
|
+
|
|
54
|
+
export type CCTPSourceChain = keyof typeof CCTP_DOMAIN_IDS
|
|
55
|
+
|
|
56
|
+
export const CCTP_SUPPORTED_SOURCE_CHAINS: readonly CCTPSourceChain[] = [
|
|
57
|
+
'ethereum',
|
|
58
|
+
'avalanche',
|
|
59
|
+
'optimism',
|
|
60
|
+
'arbitrum',
|
|
61
|
+
'base',
|
|
62
|
+
'polygon',
|
|
63
|
+
'solana',
|
|
64
|
+
] as const
|
|
65
|
+
|
|
66
|
+
export function getCctpContracts(env: ArcEnvironment): CCTPContractSet {
|
|
67
|
+
return CCTP_CONTRACTS[env]
|
|
68
|
+
}
|
package/src/chains.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arc blockchain definitions.
|
|
3
|
+
*
|
|
4
|
+
* Arc is Circle's stablecoin-native L1 where gas is paid in USDC.
|
|
5
|
+
* - Testnet is live (chain id 5042002).
|
|
6
|
+
* - Mainnet beta is expected in 2026; the mainnet entry is a placeholder
|
|
7
|
+
* until Circle publishes the production chain id and RPC endpoint.
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.arc.network
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { defineChain, type Chain } from 'viem'
|
|
13
|
+
|
|
14
|
+
export const ARC_TESTNET_CHAIN_ID = 5042002 as const
|
|
15
|
+
export const ARC_MAINNET_CHAIN_ID = 5040001 as const
|
|
16
|
+
|
|
17
|
+
const NATIVE_USDC = {
|
|
18
|
+
name: 'USD Coin',
|
|
19
|
+
symbol: 'USDC',
|
|
20
|
+
decimals: 6,
|
|
21
|
+
} as const
|
|
22
|
+
|
|
23
|
+
export const arcTestnet: Chain = defineChain({
|
|
24
|
+
id: ARC_TESTNET_CHAIN_ID,
|
|
25
|
+
name: 'Arc Testnet',
|
|
26
|
+
nativeCurrency: NATIVE_USDC,
|
|
27
|
+
rpcUrls: {
|
|
28
|
+
default: { http: ['https://rpc.testnet.arc.network'] },
|
|
29
|
+
public: { http: ['https://rpc.testnet.arc.network'] },
|
|
30
|
+
},
|
|
31
|
+
blockExplorers: {
|
|
32
|
+
default: {
|
|
33
|
+
name: 'ArcScan',
|
|
34
|
+
url: 'https://testnet.arcscan.app',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
testnet: true,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const arcMainnet: Chain = defineChain({
|
|
41
|
+
id: ARC_MAINNET_CHAIN_ID,
|
|
42
|
+
name: 'Arc',
|
|
43
|
+
nativeCurrency: NATIVE_USDC,
|
|
44
|
+
rpcUrls: {
|
|
45
|
+
default: { http: ['https://rpc.arc.network'] },
|
|
46
|
+
public: { http: ['https://rpc.arc.network'] },
|
|
47
|
+
},
|
|
48
|
+
blockExplorers: {
|
|
49
|
+
default: {
|
|
50
|
+
name: 'ArcScan',
|
|
51
|
+
url: 'https://arcscan.app',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
testnet: false,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export type ArcEnvironment = 'testnet' | 'mainnet'
|
|
58
|
+
|
|
59
|
+
export const ARC_CHAINS: Record<ArcEnvironment, Chain> = {
|
|
60
|
+
testnet: arcTestnet,
|
|
61
|
+
mainnet: arcMainnet,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getArcChain(env: ArcEnvironment): Chain {
|
|
65
|
+
return ARC_CHAINS[env]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function isArcChain(chainId: number): boolean {
|
|
69
|
+
return chainId === ARC_TESTNET_CHAIN_ID || chainId === ARC_MAINNET_CHAIN_ID
|
|
70
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @strimz/shared-config
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for chain definitions, token registry, fee tiers,
|
|
5
|
+
* webhook event names, API key conventions, agent flags, and CCTP addresses.
|
|
6
|
+
*
|
|
7
|
+
* Every other Strimz TypeScript package and app reads these constants from
|
|
8
|
+
* here. Do not duplicate values; import them.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from './chains.js'
|
|
12
|
+
export * from './tokens.js'
|
|
13
|
+
export * from './tiers.js'
|
|
14
|
+
export * from './webhooks.js'
|
|
15
|
+
export * from './api-keys.js'
|
|
16
|
+
export * from './agents.js'
|
|
17
|
+
export * from './cctp.js'
|
package/src/tiers.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strimz pricing tiers.
|
|
3
|
+
*
|
|
4
|
+
* Fees are expressed in basis points (bps): 100 bps = 1%.
|
|
5
|
+
* The subscription premium is added to the per-transaction rate when the
|
|
6
|
+
* payment is recurring (i.e. originated from a SubscriptionPlan).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise'
|
|
10
|
+
|
|
11
|
+
export interface TierDefinition {
|
|
12
|
+
id: MerchantTier
|
|
13
|
+
name: string
|
|
14
|
+
/** Monthly fee in USD cents (0 for free, null for custom enterprise). */
|
|
15
|
+
monthlyFeeUsdCents: number | null
|
|
16
|
+
/** Per-transaction fee on one-shot payments, in basis points. */
|
|
17
|
+
oneShotFeeBps: number | null
|
|
18
|
+
/** Per-transaction premium added on subscription payments, in basis points. */
|
|
19
|
+
subscriptionPremiumBps: number | null
|
|
20
|
+
/** Monthly transaction volume cap in USD cents. `null` for unlimited. */
|
|
21
|
+
monthlyVolumeCapUsdCents: number | null
|
|
22
|
+
/** Whether the "Powered by Strimz" badge can be removed from checkout. */
|
|
23
|
+
whiteLabelEligible: boolean
|
|
24
|
+
/** Whether the tier includes priority support. */
|
|
25
|
+
prioritySupport: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const TIERS: Record<MerchantTier, TierDefinition> = {
|
|
29
|
+
free: {
|
|
30
|
+
id: 'free',
|
|
31
|
+
name: 'Free',
|
|
32
|
+
monthlyFeeUsdCents: 0,
|
|
33
|
+
oneShotFeeBps: 150, // 1.5%
|
|
34
|
+
subscriptionPremiumBps: 20, // +0.2% on recurring => 1.7% effective
|
|
35
|
+
monthlyVolumeCapUsdCents: 1_000_000, // $10,000
|
|
36
|
+
whiteLabelEligible: false,
|
|
37
|
+
prioritySupport: false,
|
|
38
|
+
},
|
|
39
|
+
growth: {
|
|
40
|
+
id: 'growth',
|
|
41
|
+
name: 'Growth',
|
|
42
|
+
monthlyFeeUsdCents: 4_900, // $49
|
|
43
|
+
oneShotFeeBps: 80, // 0.8%
|
|
44
|
+
subscriptionPremiumBps: 20, // 1.0% effective
|
|
45
|
+
monthlyVolumeCapUsdCents: 10_000_000, // $100,000
|
|
46
|
+
whiteLabelEligible: true,
|
|
47
|
+
prioritySupport: false,
|
|
48
|
+
},
|
|
49
|
+
business: {
|
|
50
|
+
id: 'business',
|
|
51
|
+
name: 'Business',
|
|
52
|
+
monthlyFeeUsdCents: 19_900, // $199
|
|
53
|
+
oneShotFeeBps: 50, // 0.5%
|
|
54
|
+
subscriptionPremiumBps: 20, // 0.7% effective
|
|
55
|
+
monthlyVolumeCapUsdCents: 100_000_000, // $1,000,000
|
|
56
|
+
whiteLabelEligible: true,
|
|
57
|
+
prioritySupport: true,
|
|
58
|
+
},
|
|
59
|
+
enterprise: {
|
|
60
|
+
id: 'enterprise',
|
|
61
|
+
name: 'Enterprise',
|
|
62
|
+
monthlyFeeUsdCents: null,
|
|
63
|
+
oneShotFeeBps: null,
|
|
64
|
+
subscriptionPremiumBps: null,
|
|
65
|
+
monthlyVolumeCapUsdCents: null,
|
|
66
|
+
whiteLabelEligible: true,
|
|
67
|
+
prioritySupport: true,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const DEFAULT_TIER: MerchantTier = 'free'
|
|
72
|
+
|
|
73
|
+
export function getTier(id: MerchantTier): TierDefinition {
|
|
74
|
+
return TIERS[id]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Effective fee in bps for a given tier and payment kind.
|
|
79
|
+
* Returns `null` for the enterprise tier (custom-priced).
|
|
80
|
+
*/
|
|
81
|
+
export function effectiveFeeBps(
|
|
82
|
+
tier: MerchantTier,
|
|
83
|
+
kind: 'one_shot' | 'subscription',
|
|
84
|
+
): number | null {
|
|
85
|
+
const def = TIERS[tier]
|
|
86
|
+
if (def.oneShotFeeBps === null) return null
|
|
87
|
+
if (kind === 'one_shot') return def.oneShotFeeBps
|
|
88
|
+
return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0)
|
|
89
|
+
}
|
package/src/tokens.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token registry for Arc.
|
|
3
|
+
*
|
|
4
|
+
* USDC and EURC are first-class payment tokens — they can be requested in a
|
|
5
|
+
* payment session and used as a subscription currency.
|
|
6
|
+
*
|
|
7
|
+
* USYC is yield-bearing and is treated as a treasury asset only — merchants
|
|
8
|
+
* can hold and earn yield, but a payer cannot pay in USYC.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Address } from 'viem'
|
|
12
|
+
import { ARC_TESTNET_CHAIN_ID, ARC_MAINNET_CHAIN_ID, type ArcEnvironment } from './chains.js'
|
|
13
|
+
|
|
14
|
+
export type TokenSymbol = 'USDC' | 'EURC' | 'USYC'
|
|
15
|
+
|
|
16
|
+
/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */
|
|
17
|
+
export type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>
|
|
18
|
+
|
|
19
|
+
export const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const
|
|
20
|
+
|
|
21
|
+
export interface TokenDescriptor {
|
|
22
|
+
symbol: TokenSymbol
|
|
23
|
+
name: string
|
|
24
|
+
decimals: number
|
|
25
|
+
/** Whether the token is accepted as direct payment. */
|
|
26
|
+
paymentEligible: boolean
|
|
27
|
+
/** Whether the token is yield-bearing. */
|
|
28
|
+
yieldBearing: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TokenAddress {
|
|
32
|
+
symbol: TokenSymbol
|
|
33
|
+
address: Address
|
|
34
|
+
chainId: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const TOKENS: Record<TokenSymbol, TokenDescriptor> = {
|
|
38
|
+
USDC: {
|
|
39
|
+
symbol: 'USDC',
|
|
40
|
+
name: 'USD Coin',
|
|
41
|
+
decimals: 6,
|
|
42
|
+
paymentEligible: true,
|
|
43
|
+
yieldBearing: false,
|
|
44
|
+
},
|
|
45
|
+
EURC: {
|
|
46
|
+
symbol: 'EURC',
|
|
47
|
+
name: 'Euro Coin',
|
|
48
|
+
decimals: 6,
|
|
49
|
+
paymentEligible: true,
|
|
50
|
+
yieldBearing: false,
|
|
51
|
+
},
|
|
52
|
+
USYC: {
|
|
53
|
+
symbol: 'USYC',
|
|
54
|
+
name: 'US Yield Coin',
|
|
55
|
+
decimals: 6,
|
|
56
|
+
paymentEligible: false,
|
|
57
|
+
yieldBearing: true,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Native, Circle-issued addresses on Arc.
|
|
63
|
+
* The same address is reused across testnet and mainnet for native tokens
|
|
64
|
+
* since Arc preserves canonical addresses across environments where possible.
|
|
65
|
+
*/
|
|
66
|
+
export const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {
|
|
67
|
+
testnet: {
|
|
68
|
+
USDC: '0x3600000000000000000000000000000000000000',
|
|
69
|
+
EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
|
|
70
|
+
USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',
|
|
71
|
+
},
|
|
72
|
+
mainnet: {
|
|
73
|
+
// Mainnet addresses pending Arc mainnet beta launch; placeholders mirror
|
|
74
|
+
// testnet for now and must be replaced when Circle publishes the canonical
|
|
75
|
+
// mainnet token registry.
|
|
76
|
+
USDC: '0x3600000000000000000000000000000000000000',
|
|
77
|
+
EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
|
|
78
|
+
USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {
|
|
83
|
+
return TOKEN_ADDRESSES[env][symbol]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {
|
|
87
|
+
return (TOKENS as Record<string, TokenDescriptor>)[symbol]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function isPaymentToken(symbol: string): symbol is PaymentToken {
|
|
91
|
+
return PAYMENT_TOKENS.includes(symbol as PaymentToken)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function chainIdFor(env: ArcEnvironment): number {
|
|
95
|
+
return env === 'testnet' ? ARC_TESTNET_CHAIN_ID : ARC_MAINNET_CHAIN_ID
|
|
96
|
+
}
|
package/src/webhooks.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook event names.
|
|
3
|
+
*
|
|
4
|
+
* Wire format is `<resource>.<action>`. Every event payload is versioned at
|
|
5
|
+
* the envelope level so additive changes do not break consumers.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const WEBHOOK_EVENTS = {
|
|
9
|
+
payment: {
|
|
10
|
+
created: 'payment.created',
|
|
11
|
+
completed: 'payment.completed',
|
|
12
|
+
failed: 'payment.failed',
|
|
13
|
+
},
|
|
14
|
+
subscription: {
|
|
15
|
+
created: 'subscription.created',
|
|
16
|
+
charged: 'subscription.charged',
|
|
17
|
+
chargeFailed: 'subscription.charge_failed',
|
|
18
|
+
recoveryAttempt: 'subscription.recovery_attempt',
|
|
19
|
+
recoveryOutcome: 'subscription.recovery_outcome',
|
|
20
|
+
cancelled: 'subscription.cancelled',
|
|
21
|
+
lapsed: 'subscription.lapsed',
|
|
22
|
+
},
|
|
23
|
+
refund: {
|
|
24
|
+
created: 'refund.created',
|
|
25
|
+
completed: 'refund.completed',
|
|
26
|
+
failed: 'refund.failed',
|
|
27
|
+
},
|
|
28
|
+
invoice: {
|
|
29
|
+
created: 'invoice.created',
|
|
30
|
+
paid: 'invoice.paid',
|
|
31
|
+
overdue: 'invoice.overdue',
|
|
32
|
+
},
|
|
33
|
+
agent: {
|
|
34
|
+
actionExecuted: 'agent.action_executed',
|
|
35
|
+
jobProposed: 'agent.job_proposed',
|
|
36
|
+
jobCompleted: 'agent.job_completed',
|
|
37
|
+
jobDisputed: 'agent.job_disputed',
|
|
38
|
+
},
|
|
39
|
+
compliance: {
|
|
40
|
+
walletFlagged: 'compliance.wallet_flagged',
|
|
41
|
+
walletBlocked: 'compliance.wallet_blocked',
|
|
42
|
+
},
|
|
43
|
+
} as const
|
|
44
|
+
|
|
45
|
+
export type WebhookEventName =
|
|
46
|
+
| (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment]
|
|
47
|
+
| (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription]
|
|
48
|
+
| (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund]
|
|
49
|
+
| (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice]
|
|
50
|
+
| (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent]
|
|
51
|
+
| (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance]
|
|
52
|
+
|
|
53
|
+
export const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[] = [
|
|
54
|
+
...Object.values(WEBHOOK_EVENTS.payment),
|
|
55
|
+
...Object.values(WEBHOOK_EVENTS.subscription),
|
|
56
|
+
...Object.values(WEBHOOK_EVENTS.refund),
|
|
57
|
+
...Object.values(WEBHOOK_EVENTS.invoice),
|
|
58
|
+
...Object.values(WEBHOOK_EVENTS.agent),
|
|
59
|
+
...Object.values(WEBHOOK_EVENTS.compliance),
|
|
60
|
+
] as const
|
|
61
|
+
|
|
62
|
+
/** Exponential backoff schedule for webhook delivery, in seconds. */
|
|
63
|
+
export const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[] = [
|
|
64
|
+
60, // 1 minute
|
|
65
|
+
300, // 5 minutes
|
|
66
|
+
1_800, // 30 minutes
|
|
67
|
+
7_200, // 2 hours
|
|
68
|
+
86_400, // 24 hours
|
|
69
|
+
] as const
|
|
70
|
+
|
|
71
|
+
export const WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1
|
|
72
|
+
|
|
73
|
+
/** Webhook signatures older than this are rejected to prevent replay. */
|
|
74
|
+
export const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300
|
|
75
|
+
|
|
76
|
+
/** HTTP header carrying the HMAC signature. */
|
|
77
|
+
export const WEBHOOK_SIGNATURE_HEADER = 'strimz-signature'
|
|
78
|
+
|
|
79
|
+
/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */
|
|
80
|
+
export const WEBHOOK_DELIVERY_ID_HEADER = 'strimz-delivery-id'
|