@infiniteezverse/monskills-ezpath 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/.well-known/agent.json +241 -0
- package/.well-known/openapi.json +310 -0
- package/ARENA.md +551 -0
- package/DEPLOYMENT.md +460 -0
- package/LAUNCH.md +345 -0
- package/LICENSE +24 -0
- package/MANIFEST.md +356 -0
- package/MONAD.md +375 -0
- package/QUICKSTART.md +378 -0
- package/README.md +88 -0
- package/X402_IMPLEMENTATION.md +468 -0
- package/dist/agents/arena-agent.d.ts +166 -0
- package/dist/agents/arena-agent.d.ts.map +1 -0
- package/dist/agents/arena-agent.js +267 -0
- package/dist/agents/arena-agent.js.map +1 -0
- package/dist/agents/bankroll-manager.d.ts +114 -0
- package/dist/agents/bankroll-manager.d.ts.map +1 -0
- package/dist/agents/bankroll-manager.js +293 -0
- package/dist/agents/bankroll-manager.js.map +1 -0
- package/dist/agents/index.d.ts +9 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +29 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/strategy.d.ts +48 -0
- package/dist/agents/strategy.d.ts.map +1 -0
- package/dist/agents/strategy.js +265 -0
- package/dist/agents/strategy.js.map +1 -0
- package/dist/agents/types.d.ts +197 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +7 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/config/monad.d.ts +175 -0
- package/dist/config/monad.d.ts.map +1 -0
- package/dist/config/monad.js +222 -0
- package/dist/config/monad.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +153 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/eip3009.d.ts +210 -0
- package/dist/payments/eip3009.d.ts.map +1 -0
- package/dist/payments/eip3009.js +261 -0
- package/dist/payments/eip3009.js.map +1 -0
- package/dist/payments/index.d.ts +8 -0
- package/dist/payments/index.d.ts.map +1 -0
- package/dist/payments/index.js +25 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/quote-execution.d.ts +76 -0
- package/dist/payments/quote-execution.d.ts.map +1 -0
- package/dist/payments/quote-execution.js +285 -0
- package/dist/payments/quote-execution.js.map +1 -0
- package/dist/types/ezpath.d.ts +65 -0
- package/dist/types/ezpath.d.ts.map +1 -0
- package/dist/types/ezpath.js +7 -0
- package/dist/types/ezpath.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-3009 TransferWithAuthorization Implementation
|
|
3
|
+
* Enables X402 payment handling for EZ-Path quotes on Base
|
|
4
|
+
*
|
|
5
|
+
* References:
|
|
6
|
+
* - EIP-3009: https://eips.ethereum.org/EIPS/eip-3009
|
|
7
|
+
* - USDC v2 on Base: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* EIP-3009 Domain Separator for USDC v2 on Base
|
|
11
|
+
* These values are fixed and specific to USDC's deployment
|
|
12
|
+
*/
|
|
13
|
+
export declare const USDC_BASE_DOMAIN: {
|
|
14
|
+
readonly name: "USD Coin";
|
|
15
|
+
readonly version: "2";
|
|
16
|
+
readonly chainId: 8453;
|
|
17
|
+
readonly verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* EIP-712 TypedData for TransferWithAuthorization
|
|
21
|
+
*/
|
|
22
|
+
export declare const TRANSFER_WITH_AUTHORIZATION_TYPE: {
|
|
23
|
+
readonly TransferWithAuthorization: readonly [{
|
|
24
|
+
readonly name: "from";
|
|
25
|
+
readonly type: "address";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "to";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "value";
|
|
31
|
+
readonly type: "uint256";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "validAfter";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "validBefore";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "nonce";
|
|
40
|
+
readonly type: "bytes32";
|
|
41
|
+
}];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Authorization message for EIP-3009
|
|
45
|
+
*/
|
|
46
|
+
export interface TransferAuthorizationMessage {
|
|
47
|
+
from: string;
|
|
48
|
+
to: string;
|
|
49
|
+
value: string;
|
|
50
|
+
validAfter: number;
|
|
51
|
+
validBefore: number;
|
|
52
|
+
nonce: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Construct a TransferWithAuthorization message
|
|
56
|
+
*/
|
|
57
|
+
export declare function createAuthorizationMessage(from: string, to: string, amountInAtomic: bigint, validityDuration?: number): TransferAuthorizationMessage;
|
|
58
|
+
/**
|
|
59
|
+
* Calculate domain separator per EIP-712
|
|
60
|
+
* domainSeparator = keccak256(EIP712Domain(name, version, chainId, verifyingContract))
|
|
61
|
+
*/
|
|
62
|
+
export declare function getDomainSeparator(): string;
|
|
63
|
+
/**
|
|
64
|
+
* EIP-712 Hash Struct for TransferWithAuthorization
|
|
65
|
+
* Calculates the hash of the message according to EIP-712
|
|
66
|
+
*/
|
|
67
|
+
export declare function hashAuthorizationMessage(_message: TransferAuthorizationMessage): string;
|
|
68
|
+
/**
|
|
69
|
+
* X402 Payment Signature Package
|
|
70
|
+
*/
|
|
71
|
+
export interface X402PaymentSignature {
|
|
72
|
+
signature: string;
|
|
73
|
+
authorization: TransferAuthorizationMessage;
|
|
74
|
+
quote_issued_at: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* X402 Payment Header Value
|
|
78
|
+
* Encodes payment signature for HTTP X-Payment header
|
|
79
|
+
*/
|
|
80
|
+
export declare function createX402PaymentHeader(signature: X402PaymentSignature): string;
|
|
81
|
+
/**
|
|
82
|
+
* Parse X402 Payment Header
|
|
83
|
+
* Decodes base64 X-Payment header
|
|
84
|
+
*/
|
|
85
|
+
export declare function parseX402PaymentHeader(header: string): X402PaymentSignature | null;
|
|
86
|
+
/**
|
|
87
|
+
* Validate Authorization Message
|
|
88
|
+
* Checks that message is properly formed and within validity window
|
|
89
|
+
*/
|
|
90
|
+
export declare function validateAuthorizationMessage(message: TransferAuthorizationMessage): {
|
|
91
|
+
valid: boolean;
|
|
92
|
+
error?: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Configuration for common payment tiers
|
|
96
|
+
*/
|
|
97
|
+
export declare const PAYMENT_TIERS: {
|
|
98
|
+
readonly basic: {
|
|
99
|
+
readonly name: "Basic";
|
|
100
|
+
readonly costUSDC: 0.03;
|
|
101
|
+
readonly costAtomic: 30000n;
|
|
102
|
+
readonly description: "Direct 0x routing";
|
|
103
|
+
};
|
|
104
|
+
readonly resilient: {
|
|
105
|
+
readonly name: "Resilient";
|
|
106
|
+
readonly costUSDC: 0.1;
|
|
107
|
+
readonly costAtomic: 100000n;
|
|
108
|
+
readonly description: "4-venue racing";
|
|
109
|
+
};
|
|
110
|
+
readonly institutional: {
|
|
111
|
+
readonly name: "Institutional";
|
|
112
|
+
readonly costUSDC: 0.5;
|
|
113
|
+
readonly costAtomic: 500000n;
|
|
114
|
+
readonly description: "10-venue racing";
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Get payment tier by cost
|
|
119
|
+
*/
|
|
120
|
+
export declare function getTierByAmount(amountInAtomic: bigint): string;
|
|
121
|
+
/**
|
|
122
|
+
* Toll address (EZ-Path payment recipient on Base)
|
|
123
|
+
*/
|
|
124
|
+
export declare const TOLL_ADDRESS = "0x13dDE704389b1118B20d2BCc6D3Ace749600e2ad";
|
|
125
|
+
/**
|
|
126
|
+
* X402 Protocol Configuration
|
|
127
|
+
*/
|
|
128
|
+
export declare const X402_CONFIG: {
|
|
129
|
+
readonly protocol: "X402";
|
|
130
|
+
readonly version: 1;
|
|
131
|
+
readonly paymentMethod: "EIP-3009";
|
|
132
|
+
readonly chain: "base";
|
|
133
|
+
readonly chainId: 8453;
|
|
134
|
+
readonly usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
135
|
+
readonly tollAddress: "0x13dDE704389b1118B20d2BCc6D3Ace749600e2ad";
|
|
136
|
+
readonly maxRetries: 3;
|
|
137
|
+
readonly retryDelayMs: 1000;
|
|
138
|
+
readonly quoteTTL: 300;
|
|
139
|
+
};
|
|
140
|
+
declare const _default: {
|
|
141
|
+
USDC_BASE_DOMAIN: {
|
|
142
|
+
readonly name: "USD Coin";
|
|
143
|
+
readonly version: "2";
|
|
144
|
+
readonly chainId: 8453;
|
|
145
|
+
readonly verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
146
|
+
};
|
|
147
|
+
TRANSFER_WITH_AUTHORIZATION_TYPE: {
|
|
148
|
+
readonly TransferWithAuthorization: readonly [{
|
|
149
|
+
readonly name: "from";
|
|
150
|
+
readonly type: "address";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "to";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "value";
|
|
156
|
+
readonly type: "uint256";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "validAfter";
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
}, {
|
|
161
|
+
readonly name: "validBefore";
|
|
162
|
+
readonly type: "uint256";
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "nonce";
|
|
165
|
+
readonly type: "bytes32";
|
|
166
|
+
}];
|
|
167
|
+
};
|
|
168
|
+
PAYMENT_TIERS: {
|
|
169
|
+
readonly basic: {
|
|
170
|
+
readonly name: "Basic";
|
|
171
|
+
readonly costUSDC: 0.03;
|
|
172
|
+
readonly costAtomic: 30000n;
|
|
173
|
+
readonly description: "Direct 0x routing";
|
|
174
|
+
};
|
|
175
|
+
readonly resilient: {
|
|
176
|
+
readonly name: "Resilient";
|
|
177
|
+
readonly costUSDC: 0.1;
|
|
178
|
+
readonly costAtomic: 100000n;
|
|
179
|
+
readonly description: "4-venue racing";
|
|
180
|
+
};
|
|
181
|
+
readonly institutional: {
|
|
182
|
+
readonly name: "Institutional";
|
|
183
|
+
readonly costUSDC: 0.5;
|
|
184
|
+
readonly costAtomic: 500000n;
|
|
185
|
+
readonly description: "10-venue racing";
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
TOLL_ADDRESS: string;
|
|
189
|
+
X402_CONFIG: {
|
|
190
|
+
readonly protocol: "X402";
|
|
191
|
+
readonly version: 1;
|
|
192
|
+
readonly paymentMethod: "EIP-3009";
|
|
193
|
+
readonly chain: "base";
|
|
194
|
+
readonly chainId: 8453;
|
|
195
|
+
readonly usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
196
|
+
readonly tollAddress: "0x13dDE704389b1118B20d2BCc6D3Ace749600e2ad";
|
|
197
|
+
readonly maxRetries: 3;
|
|
198
|
+
readonly retryDelayMs: 1000;
|
|
199
|
+
readonly quoteTTL: 300;
|
|
200
|
+
};
|
|
201
|
+
createAuthorizationMessage: typeof createAuthorizationMessage;
|
|
202
|
+
getDomainSeparator: typeof getDomainSeparator;
|
|
203
|
+
hashAuthorizationMessage: typeof hashAuthorizationMessage;
|
|
204
|
+
createX402PaymentHeader: typeof createX402PaymentHeader;
|
|
205
|
+
parseX402PaymentHeader: typeof parseX402PaymentHeader;
|
|
206
|
+
validateAuthorizationMessage: typeof validateAuthorizationMessage;
|
|
207
|
+
getTierByAmount: typeof getTierByAmount;
|
|
208
|
+
};
|
|
209
|
+
export default _default;
|
|
210
|
+
//# sourceMappingURL=eip3009.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip3009.d.ts","sourceRoot":"","sources":["../../src/payments/eip3009.ts"],"names":[],"mappings":"AA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EAAE,MAAM,GAAG,MAAM,CAW9D;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,+CAA+C,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,wBAaE"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* EIP-3009 TransferWithAuthorization Implementation
|
|
4
|
+
* Enables X402 payment handling for EZ-Path quotes on Base
|
|
5
|
+
*
|
|
6
|
+
* References:
|
|
7
|
+
* - EIP-3009: https://eips.ethereum.org/EIPS/eip-3009
|
|
8
|
+
* - USDC v2 on Base: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.X402_CONFIG = exports.TOLL_ADDRESS = exports.PAYMENT_TIERS = exports.TRANSFER_WITH_AUTHORIZATION_TYPE = exports.USDC_BASE_DOMAIN = void 0;
|
|
15
|
+
exports.createAuthorizationMessage = createAuthorizationMessage;
|
|
16
|
+
exports.getDomainSeparator = getDomainSeparator;
|
|
17
|
+
exports.hashAuthorizationMessage = hashAuthorizationMessage;
|
|
18
|
+
exports.createX402PaymentHeader = createX402PaymentHeader;
|
|
19
|
+
exports.parseX402PaymentHeader = parseX402PaymentHeader;
|
|
20
|
+
exports.validateAuthorizationMessage = validateAuthorizationMessage;
|
|
21
|
+
exports.getTierByAmount = getTierByAmount;
|
|
22
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
23
|
+
/**
|
|
24
|
+
* EIP-3009 Domain Separator for USDC v2 on Base
|
|
25
|
+
* These values are fixed and specific to USDC's deployment
|
|
26
|
+
*/
|
|
27
|
+
exports.USDC_BASE_DOMAIN = {
|
|
28
|
+
name: 'USD Coin',
|
|
29
|
+
version: '2',
|
|
30
|
+
chainId: 8453, // Base mainnet
|
|
31
|
+
verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* EIP-712 TypedData for TransferWithAuthorization
|
|
35
|
+
*/
|
|
36
|
+
exports.TRANSFER_WITH_AUTHORIZATION_TYPE = {
|
|
37
|
+
TransferWithAuthorization: [
|
|
38
|
+
{ name: 'from', type: 'address' },
|
|
39
|
+
{ name: 'to', type: 'address' },
|
|
40
|
+
{ name: 'value', type: 'uint256' },
|
|
41
|
+
{ name: 'validAfter', type: 'uint256' },
|
|
42
|
+
{ name: 'validBefore', type: 'uint256' },
|
|
43
|
+
{ name: 'nonce', type: 'bytes32' },
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Construct a TransferWithAuthorization message
|
|
48
|
+
*/
|
|
49
|
+
function createAuthorizationMessage(from, to, amountInAtomic, validityDuration = 300 // 5 minutes
|
|
50
|
+
) {
|
|
51
|
+
const now = Math.floor(Date.now() / 1000);
|
|
52
|
+
const nonce = '0x' + crypto_1.default.randomBytes(32).toString('hex');
|
|
53
|
+
return {
|
|
54
|
+
from: from.toLowerCase().startsWith('0x') ? from.toLowerCase() : '0x' + from.toLowerCase(),
|
|
55
|
+
to: to.toLowerCase().startsWith('0x') ? to.toLowerCase() : '0x' + to.toLowerCase(),
|
|
56
|
+
value: amountInAtomic.toString(),
|
|
57
|
+
validAfter: 0,
|
|
58
|
+
validBefore: now + validityDuration,
|
|
59
|
+
nonce,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Calculate domain separator per EIP-712
|
|
64
|
+
* domainSeparator = keccak256(EIP712Domain(name, version, chainId, verifyingContract))
|
|
65
|
+
*/
|
|
66
|
+
function getDomainSeparator() {
|
|
67
|
+
// In production, this would be calculated using ethers.js
|
|
68
|
+
// For now, return the pre-calculated value for USDC v2 on Base
|
|
69
|
+
// This should be verified against the actual contract
|
|
70
|
+
// The domain separator is calculated as:
|
|
71
|
+
// keccak256(
|
|
72
|
+
// abi.encode(
|
|
73
|
+
// keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
|
|
74
|
+
// keccak256('USD Coin'),
|
|
75
|
+
// keccak256('2'),
|
|
76
|
+
// 8453,
|
|
77
|
+
// 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
78
|
+
// )
|
|
79
|
+
// )
|
|
80
|
+
// Pre-calculated for USDC v2 on Base:
|
|
81
|
+
return '0x0b50407de9fa158521f154e2ca1ea1732aafec63675491e98e500d4e4b8714b8';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* EIP-712 Hash Struct for TransferWithAuthorization
|
|
85
|
+
* Calculates the hash of the message according to EIP-712
|
|
86
|
+
*/
|
|
87
|
+
function hashAuthorizationMessage(_message) {
|
|
88
|
+
// This is a simplified version. In production, use ethers.js
|
|
89
|
+
// const hash = ethers.TypedDataEncoder.hash(domain, types, message)
|
|
90
|
+
// For demonstration, we'll show the structure:
|
|
91
|
+
// hashStruct(TransferWithAuthorization) = keccak256(
|
|
92
|
+
// abi.encode(
|
|
93
|
+
// keccak256('TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)'),
|
|
94
|
+
// message.from,
|
|
95
|
+
// message.to,
|
|
96
|
+
// message.value,
|
|
97
|
+
// message.validAfter,
|
|
98
|
+
// message.validBefore,
|
|
99
|
+
// message.nonce
|
|
100
|
+
// )
|
|
101
|
+
// )
|
|
102
|
+
// digest = keccak256(
|
|
103
|
+
// abi.encodePacked(
|
|
104
|
+
// bytes2(0x1901),
|
|
105
|
+
// domainSeparator,
|
|
106
|
+
// hashStruct
|
|
107
|
+
// )
|
|
108
|
+
// )
|
|
109
|
+
// For now, return placeholder - actual implementation uses ethers.js
|
|
110
|
+
return '0x' + crypto_1.default.randomBytes(32).toString('hex');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* X402 Payment Header Value
|
|
114
|
+
* Encodes payment signature for HTTP X-Payment header
|
|
115
|
+
*/
|
|
116
|
+
function createX402PaymentHeader(signature) {
|
|
117
|
+
const payload = {
|
|
118
|
+
payload: signature,
|
|
119
|
+
};
|
|
120
|
+
// Encode as base64 per X402 spec
|
|
121
|
+
const json = JSON.stringify(payload);
|
|
122
|
+
return Buffer.from(json).toString('base64');
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parse X402 Payment Header
|
|
126
|
+
* Decodes base64 X-Payment header
|
|
127
|
+
*/
|
|
128
|
+
function parseX402PaymentHeader(header) {
|
|
129
|
+
try {
|
|
130
|
+
const json = Buffer.from(header, 'base64').toString('utf8');
|
|
131
|
+
const parsed = JSON.parse(json);
|
|
132
|
+
return parsed.payload;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error('Failed to parse X402 payment header:', error);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Validate Authorization Message
|
|
141
|
+
* Checks that message is properly formed and within validity window
|
|
142
|
+
*/
|
|
143
|
+
function validateAuthorizationMessage(message) {
|
|
144
|
+
const now = Math.floor(Date.now() / 1000);
|
|
145
|
+
// Check validity window
|
|
146
|
+
if (message.validAfter > now) {
|
|
147
|
+
return {
|
|
148
|
+
valid: false,
|
|
149
|
+
error: `Authorization not yet valid (validAfter: ${message.validAfter}, now: ${now})`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (message.validBefore < now) {
|
|
153
|
+
return {
|
|
154
|
+
valid: false,
|
|
155
|
+
error: `Authorization expired (validBefore: ${message.validBefore}, now: ${now})`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Check addresses
|
|
159
|
+
if (!message.from.startsWith('0x') || message.from.length !== 42) {
|
|
160
|
+
return {
|
|
161
|
+
valid: false,
|
|
162
|
+
error: 'Invalid from address',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (!message.to.startsWith('0x') || message.to.length !== 42) {
|
|
166
|
+
return {
|
|
167
|
+
valid: false,
|
|
168
|
+
error: 'Invalid to address',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// Check nonce
|
|
172
|
+
if (!message.nonce.startsWith('0x') || message.nonce.length !== 66) {
|
|
173
|
+
return {
|
|
174
|
+
valid: false,
|
|
175
|
+
error: 'Invalid nonce (should be 0x + 64 hex characters)',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// Check value
|
|
179
|
+
try {
|
|
180
|
+
BigInt(message.value);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return {
|
|
184
|
+
valid: false,
|
|
185
|
+
error: 'Invalid value (should be numeric string)',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return { valid: true };
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Configuration for common payment tiers
|
|
192
|
+
*/
|
|
193
|
+
exports.PAYMENT_TIERS = {
|
|
194
|
+
basic: {
|
|
195
|
+
name: 'Basic',
|
|
196
|
+
costUSDC: 0.03,
|
|
197
|
+
costAtomic: 30000n,
|
|
198
|
+
description: 'Direct 0x routing',
|
|
199
|
+
},
|
|
200
|
+
resilient: {
|
|
201
|
+
name: 'Resilient',
|
|
202
|
+
costUSDC: 0.1,
|
|
203
|
+
costAtomic: 100000n,
|
|
204
|
+
description: '4-venue racing',
|
|
205
|
+
},
|
|
206
|
+
institutional: {
|
|
207
|
+
name: 'Institutional',
|
|
208
|
+
costUSDC: 0.5,
|
|
209
|
+
costAtomic: 500000n,
|
|
210
|
+
description: '10-venue racing',
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Get payment tier by cost
|
|
215
|
+
*/
|
|
216
|
+
function getTierByAmount(amountInAtomic) {
|
|
217
|
+
if (amountInAtomic >= exports.PAYMENT_TIERS.institutional.costAtomic) {
|
|
218
|
+
return 'institutional';
|
|
219
|
+
}
|
|
220
|
+
if (amountInAtomic >= exports.PAYMENT_TIERS.resilient.costAtomic) {
|
|
221
|
+
return 'resilient';
|
|
222
|
+
}
|
|
223
|
+
if (amountInAtomic >= exports.PAYMENT_TIERS.basic.costAtomic) {
|
|
224
|
+
return 'basic';
|
|
225
|
+
}
|
|
226
|
+
return 'unknown';
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Toll address (EZ-Path payment recipient on Base)
|
|
230
|
+
*/
|
|
231
|
+
exports.TOLL_ADDRESS = '0x13dDE704389b1118B20d2BCc6D3Ace749600e2ad';
|
|
232
|
+
/**
|
|
233
|
+
* X402 Protocol Configuration
|
|
234
|
+
*/
|
|
235
|
+
exports.X402_CONFIG = {
|
|
236
|
+
protocol: 'X402',
|
|
237
|
+
version: 1,
|
|
238
|
+
paymentMethod: 'EIP-3009',
|
|
239
|
+
chain: 'base',
|
|
240
|
+
chainId: 8453,
|
|
241
|
+
usdcAddress: exports.USDC_BASE_DOMAIN.verifyingContract,
|
|
242
|
+
tollAddress: exports.TOLL_ADDRESS,
|
|
243
|
+
maxRetries: 3,
|
|
244
|
+
retryDelayMs: 1000,
|
|
245
|
+
quoteTTL: 300, // 5 minutes
|
|
246
|
+
};
|
|
247
|
+
exports.default = {
|
|
248
|
+
USDC_BASE_DOMAIN: exports.USDC_BASE_DOMAIN,
|
|
249
|
+
TRANSFER_WITH_AUTHORIZATION_TYPE: exports.TRANSFER_WITH_AUTHORIZATION_TYPE,
|
|
250
|
+
PAYMENT_TIERS: exports.PAYMENT_TIERS,
|
|
251
|
+
TOLL_ADDRESS: exports.TOLL_ADDRESS,
|
|
252
|
+
X402_CONFIG: exports.X402_CONFIG,
|
|
253
|
+
createAuthorizationMessage,
|
|
254
|
+
getDomainSeparator,
|
|
255
|
+
hashAuthorizationMessage,
|
|
256
|
+
createX402PaymentHeader,
|
|
257
|
+
parseX402PaymentHeader,
|
|
258
|
+
validateAuthorizationMessage,
|
|
259
|
+
getTierByAmount,
|
|
260
|
+
};
|
|
261
|
+
//# sourceMappingURL=eip3009.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip3009.js","sourceRoot":"","sources":["../../src/payments/eip3009.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;AA4CH,gEAiBC;AAMD,gDAkBC;AAMD,4DA2BC;AAeD,0DAUC;AAMD,wDASC;AAMD,oEAuDC;AA6BD,0CAWC;AAjQD,oDAA4B;AAE5B;;;GAGG;AACU,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI,EAAE,eAAe;IAC9B,iBAAiB,EAAE,4CAA4C;CACvD,CAAC;AAEX;;GAEG;AACU,QAAA,gCAAgC,GAAG;IAC9C,yBAAyB,EAAE;QACzB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;QACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;QAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;QAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;QACvC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;QACxC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;KACnC;CACO,CAAC;AAcX;;GAEG;AACH,SAAgB,0BAA0B,CACxC,IAAY,EACZ,EAAU,EACV,cAAsB,EACtB,mBAA2B,GAAG,CAAC,YAAY;;IAE3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,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
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* X402 Payment Module Exports
|
|
3
|
+
* EIP-3009 signing and settlement execution for DEX routing
|
|
4
|
+
*/
|
|
5
|
+
export * from './eip3009';
|
|
6
|
+
export { QuoteExecutor } from './quote-execution';
|
|
7
|
+
export type { ExecutionResult } from './quote-execution';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* X402 Payment Module Exports
|
|
4
|
+
* EIP-3009 signing and settlement execution for DEX routing
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.QuoteExecutor = void 0;
|
|
22
|
+
__exportStar(require("./eip3009"), exports);
|
|
23
|
+
var quote_execution_1 = require("./quote-execution");
|
|
24
|
+
Object.defineProperty(exports, "QuoteExecutor", { enumerable: true, get: function () { return quote_execution_1.QuoteExecutor; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,4CAA0B;AAC1B,qDAAkD;AAAzC,gHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quote Execution with X402 Payment
|
|
3
|
+
* Handles the complete flow: probe → payment signing → retry → settlement
|
|
4
|
+
*
|
|
5
|
+
* Flow:
|
|
6
|
+
* 1. GET /api/v1/quote → HTTP 402 Payment Required
|
|
7
|
+
* 2. Extract toll address and payment amount from 402 response
|
|
8
|
+
* 3. Create EIP-3009 TransferWithAuthorization message
|
|
9
|
+
* 4. Sign message with agent's private key
|
|
10
|
+
* 5. Retry GET /api/v1/quote with X-Payment header
|
|
11
|
+
* 6. Return settlement transaction and quote data
|
|
12
|
+
*/
|
|
13
|
+
import type { TransferAuthorizationMessage, X402PaymentSignature } from './eip3009';
|
|
14
|
+
import type { EZPathQuoteRequest } from '../types/ezpath';
|
|
15
|
+
/**
|
|
16
|
+
* Quote execution result
|
|
17
|
+
*/
|
|
18
|
+
export interface ExecutionResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
data?: {
|
|
21
|
+
status: string;
|
|
22
|
+
request_id: string;
|
|
23
|
+
sellToken: string;
|
|
24
|
+
buyToken: string;
|
|
25
|
+
sellAmount: string;
|
|
26
|
+
buyAmount: string;
|
|
27
|
+
price: string;
|
|
28
|
+
sources: Array<{
|
|
29
|
+
name: string;
|
|
30
|
+
buyAmount: string;
|
|
31
|
+
}>;
|
|
32
|
+
routingEngine: string;
|
|
33
|
+
tier: string;
|
|
34
|
+
settlement_tx?: string;
|
|
35
|
+
};
|
|
36
|
+
error?: string;
|
|
37
|
+
paymentRequired?: boolean;
|
|
38
|
+
estimatedFee?: {
|
|
39
|
+
usd: number;
|
|
40
|
+
atomic: string;
|
|
41
|
+
token: 'USDC';
|
|
42
|
+
};
|
|
43
|
+
paymentSignature?: X402PaymentSignature;
|
|
44
|
+
retries: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Quote Executor
|
|
48
|
+
* Handles quotes with optional X402 payment
|
|
49
|
+
*/
|
|
50
|
+
export declare class QuoteExecutor {
|
|
51
|
+
private ezPathUrl;
|
|
52
|
+
private signingFunction?;
|
|
53
|
+
private agentAddress?;
|
|
54
|
+
private maxRetries;
|
|
55
|
+
private retryDelayMs;
|
|
56
|
+
constructor(ezPathUrl?: string, options?: {
|
|
57
|
+
maxRetries?: number;
|
|
58
|
+
retryDelayMs?: number;
|
|
59
|
+
signingFunction?: (message: TransferAuthorizationMessage) => Promise<string>;
|
|
60
|
+
agentAddress?: string;
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Execute quote with optional X402 payment
|
|
64
|
+
*/
|
|
65
|
+
executeQuote(request: EZPathQuoteRequest, paymentSigningFunction?: (message: TransferAuthorizationMessage) => Promise<string>): Promise<ExecutionResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Make quote request (internal)
|
|
68
|
+
*/
|
|
69
|
+
private makeQuoteRequest;
|
|
70
|
+
/**
|
|
71
|
+
* Delay utility
|
|
72
|
+
*/
|
|
73
|
+
private delay;
|
|
74
|
+
}
|
|
75
|
+
export default QuoteExecutor;
|
|
76
|
+
//# sourceMappingURL=quote-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-execution.d.ts","sourceRoot":"","sources":["../../src/payments/quote-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,KAAK,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