@gibs/bridge-client 1.30.1 → 1.32.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/coinbase-accept-list/package.json +6 -0
- package/dist/cjs/client.d.ts +9 -1
- package/dist/cjs/client.js +8 -5
- package/dist/cjs/coinbase-accept-list.d.ts +101 -0
- package/dist/cjs/coinbase-accept-list.js +97 -0
- package/dist/cjs/crossing-decision.d.ts +166 -0
- package/dist/cjs/crossing-decision.js +169 -0
- package/dist/cjs/crossing-vector-guard.d.ts +45 -0
- package/dist/cjs/crossing-vector-guard.js +139 -0
- package/dist/cjs/exchange-deposit-board.d.ts +50 -0
- package/dist/cjs/exchange-deposit-board.js +70 -0
- package/dist/cjs/exchange-deposit-chain.d.ts +146 -0
- package/dist/cjs/exchange-deposit-chain.js +228 -0
- package/dist/cjs/exchange-deposit-constants.d.ts +10 -0
- package/dist/cjs/exchange-deposit-constants.js +6 -0
- package/dist/cjs/exchange-deposit-factory-calls.d.ts +245 -0
- package/dist/cjs/exchange-deposit-factory-calls.js +103 -0
- package/dist/cjs/exchange-deposit-factory.d.ts +87 -0
- package/dist/cjs/exchange-deposit-factory.js +110 -0
- package/dist/cjs/exchange-deposit-fake.d.ts +67 -0
- package/dist/cjs/exchange-deposit-fake.js +179 -0
- package/dist/cjs/exchange-deposit-index.d.ts +77 -0
- package/dist/cjs/exchange-deposit-index.js +40 -0
- package/dist/cjs/exchange-deposit-issuance.d.ts +327 -0
- package/dist/cjs/exchange-deposit-issuance.js +244 -0
- package/dist/cjs/exchange-deposit-path.d.ts +16 -0
- package/dist/cjs/exchange-deposit-path.js +15 -0
- package/dist/cjs/exchange-deposit-pow.d.ts +163 -0
- package/dist/cjs/exchange-deposit-pow.js +101 -0
- package/dist/cjs/exchange-deposit-recipient.d.ts +66 -0
- package/dist/cjs/exchange-deposit-recipient.js +35 -0
- package/dist/cjs/exchange-deposit-self-cross.d.ts +163 -0
- package/dist/cjs/exchange-deposit-self-cross.js +60 -0
- package/dist/cjs/exchange-deposit-signin.d.ts +275 -0
- package/dist/cjs/exchange-deposit-signin.js +166 -0
- package/dist/cjs/exchange-deposit-watch.d.ts +133 -0
- package/dist/cjs/exchange-deposit-watch.js +58 -0
- package/dist/cjs/exchange-deposit.d.ts +440 -0
- package/dist/cjs/exchange-deposit.js +154 -0
- package/dist/cjs/exchange-sender-guides.d.ts +29 -0
- package/dist/cjs/exchange-sender-guides.js +25 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +24 -1
- package/dist/cjs/kraken-accept-list.d.ts +70 -0
- package/dist/cjs/kraken-accept-list.js +24 -0
- package/dist/client.d.ts +9 -1
- package/dist/client.js +8 -5
- package/dist/coinbase-accept-list.d.ts +101 -0
- package/dist/coinbase-accept-list.js +89 -0
- package/dist/crossing-decision.d.ts +166 -0
- package/dist/crossing-decision.js +162 -0
- package/dist/crossing-vector-guard.d.ts +45 -0
- package/dist/crossing-vector-guard.js +134 -0
- package/dist/exchange-deposit-board.d.ts +50 -0
- package/dist/exchange-deposit-board.js +28 -0
- package/dist/exchange-deposit-chain.d.ts +146 -0
- package/dist/exchange-deposit-chain.js +218 -0
- package/dist/exchange-deposit-constants.d.ts +10 -0
- package/dist/exchange-deposit-constants.js +3 -0
- package/dist/exchange-deposit-factory-calls.d.ts +245 -0
- package/dist/exchange-deposit-factory-calls.js +97 -0
- package/dist/exchange-deposit-factory.d.ts +87 -0
- package/dist/exchange-deposit-factory.js +104 -0
- package/dist/exchange-deposit-fake.d.ts +67 -0
- package/dist/exchange-deposit-fake.js +171 -0
- package/dist/exchange-deposit-index.d.ts +77 -0
- package/dist/exchange-deposit-index.js +34 -0
- package/dist/exchange-deposit-issuance.d.ts +327 -0
- package/dist/exchange-deposit-issuance.js +224 -0
- package/dist/exchange-deposit-path.d.ts +16 -0
- package/dist/exchange-deposit-path.js +11 -0
- package/dist/exchange-deposit-pow.d.ts +163 -0
- package/dist/exchange-deposit-pow.js +93 -0
- package/dist/exchange-deposit-recipient.d.ts +66 -0
- package/dist/exchange-deposit-recipient.js +28 -0
- package/dist/exchange-deposit-self-cross.d.ts +163 -0
- package/dist/exchange-deposit-self-cross.js +46 -0
- package/dist/exchange-deposit-signin.d.ts +275 -0
- package/dist/exchange-deposit-signin.js +147 -0
- package/dist/exchange-deposit-watch.d.ts +133 -0
- package/dist/exchange-deposit-watch.js +44 -0
- package/dist/exchange-deposit.d.ts +440 -0
- package/dist/exchange-deposit.js +138 -0
- package/dist/exchange-sender-guides.d.ts +29 -0
- package/dist/exchange-sender-guides.js +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/kraken-accept-list.d.ts +70 -0
- package/dist/kraken-accept-list.js +17 -0
- package/exchange-deposit/package.json +6 -0
- package/exchange-deposit-board/package.json +6 -0
- package/exchange-deposit-chain/package.json +6 -0
- package/exchange-deposit-factory/package.json +6 -0
- package/exchange-deposit-fake/package.json +6 -0
- package/exchange-deposit-issuance/package.json +6 -0
- package/exchange-deposit-path/package.json +6 -0
- package/exchange-deposit-pow/package.json +6 -0
- package/exchange-deposit-recipient/package.json +6 -0
- package/exchange-deposit-self-cross/package.json +6 -0
- package/exchange-deposit-signin/package.json +6 -0
- package/exchange-deposit-watch/package.json +6 -0
- package/exchange-sender-guides/package.json +6 -0
- package/kraken-accept-list/package.json +6 -0
- package/package.json +429 -4
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import { type ExchangeDepositAddress, type ExchangeDepositContractGroup, type ExchangeDepositSettings, type ExchangeDepositToken } from './exchange-deposit.js';
|
|
3
|
+
/**
|
|
4
|
+
* The factory's calls: its contract interface, the events that record a use of an address, and the pure encoding of a flush.
|
|
5
|
+
*
|
|
6
|
+
* Kept apart from `exchange-deposit-factory.ts`, which the entry chunk reads on every load. Only the page's chain
|
|
7
|
+
* reader and its flush hook reach this file, so the contract interface and the event definitions load with the page.
|
|
8
|
+
*/
|
|
9
|
+
/** The group number the factory takes: 0 for ether, 2 for a single token. Group 1 is retired and never sent. */
|
|
10
|
+
export declare const factoryGroupOf: (contractGroup: ExchangeDepositContractGroup) => number;
|
|
11
|
+
/** The settings tuple of the factory's functions, with the field names of its contract interface. */
|
|
12
|
+
export interface FactorySettingsTuple {
|
|
13
|
+
readonly recipient: Address;
|
|
14
|
+
readonly unwrap: boolean;
|
|
15
|
+
readonly feeRateE18: bigint;
|
|
16
|
+
readonly partner: Address;
|
|
17
|
+
readonly partnerRateE18: bigint;
|
|
18
|
+
readonly group: number;
|
|
19
|
+
readonly token: Address;
|
|
20
|
+
readonly index: bigint;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The factory's settings tuple for an address. The interface sends no partner: the partner is the zero address with
|
|
24
|
+
* a zero rate.
|
|
25
|
+
*
|
|
26
|
+
* @param input.settings - the settings that define the address
|
|
27
|
+
* @param input.token - the token of the address, resolved
|
|
28
|
+
*/
|
|
29
|
+
export declare const factorySettingsTupleOf: ({ settings, token, }: {
|
|
30
|
+
settings: ExchangeDepositSettings;
|
|
31
|
+
token: ExchangeDepositToken;
|
|
32
|
+
}) => FactorySettingsTuple;
|
|
33
|
+
export declare const SETTINGS_COMPONENTS: readonly [{
|
|
34
|
+
readonly name: "recipient";
|
|
35
|
+
readonly type: "address";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "unwrap";
|
|
38
|
+
readonly type: "bool";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "feeRateE18";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "partner";
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "partnerRateE18";
|
|
47
|
+
readonly type: "uint256";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "group";
|
|
50
|
+
readonly type: "uint8";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "token";
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "index";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
}];
|
|
58
|
+
/**
|
|
59
|
+
* The events the factory emits for a deposit address, from its source. After a flush the address has no balance and
|
|
60
|
+
* no code, so these events are the only record that it was used. Each one names the address as `depositAddress`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const EXCHANGE_DEPOSIT_FACTORY_USAGE_EVENTS: readonly [{
|
|
63
|
+
readonly name: "Flushed";
|
|
64
|
+
readonly type: "event";
|
|
65
|
+
readonly inputs: readonly [{
|
|
66
|
+
readonly type: "bytes32";
|
|
67
|
+
readonly name: "settingsHash";
|
|
68
|
+
readonly indexed: true;
|
|
69
|
+
}, {
|
|
70
|
+
readonly type: "address";
|
|
71
|
+
readonly name: "depositAddress";
|
|
72
|
+
readonly indexed: true;
|
|
73
|
+
}];
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "Rescued";
|
|
76
|
+
readonly type: "event";
|
|
77
|
+
readonly inputs: readonly [{
|
|
78
|
+
readonly type: "bytes32";
|
|
79
|
+
readonly name: "settingsHash";
|
|
80
|
+
readonly indexed: true;
|
|
81
|
+
}, {
|
|
82
|
+
readonly type: "address";
|
|
83
|
+
readonly name: "depositAddress";
|
|
84
|
+
readonly indexed: true;
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
readonly name: "to";
|
|
88
|
+
readonly indexed: true;
|
|
89
|
+
}];
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "Retired";
|
|
92
|
+
readonly type: "event";
|
|
93
|
+
readonly inputs: readonly [{
|
|
94
|
+
readonly type: "bytes32";
|
|
95
|
+
readonly name: "settingsHash";
|
|
96
|
+
readonly indexed: true;
|
|
97
|
+
}, {
|
|
98
|
+
readonly type: "address";
|
|
99
|
+
readonly name: "depositAddress";
|
|
100
|
+
readonly indexed: true;
|
|
101
|
+
}, {
|
|
102
|
+
readonly type: "address";
|
|
103
|
+
readonly name: "recipient";
|
|
104
|
+
readonly indexed: true;
|
|
105
|
+
}];
|
|
106
|
+
}];
|
|
107
|
+
/** The functions of the deposit factory the interface uses: its two maximums, its two address functions and its mediator. */
|
|
108
|
+
export declare const EXCHANGE_DEPOSIT_FACTORY_ABI: readonly [{
|
|
109
|
+
readonly type: "function";
|
|
110
|
+
readonly name: "mediator";
|
|
111
|
+
readonly stateMutability: "view";
|
|
112
|
+
readonly inputs: readonly [];
|
|
113
|
+
readonly outputs: readonly [{
|
|
114
|
+
readonly name: "";
|
|
115
|
+
readonly type: "address";
|
|
116
|
+
}];
|
|
117
|
+
}, {
|
|
118
|
+
readonly type: "function";
|
|
119
|
+
readonly name: "MAXIMUM_FEE_RATE_E18";
|
|
120
|
+
readonly stateMutability: "view";
|
|
121
|
+
readonly inputs: readonly [];
|
|
122
|
+
readonly outputs: readonly [{
|
|
123
|
+
readonly name: "";
|
|
124
|
+
readonly type: "uint256";
|
|
125
|
+
}];
|
|
126
|
+
}, {
|
|
127
|
+
readonly type: "function";
|
|
128
|
+
readonly name: "MAXIMUM_PARTNER_RATE_E18";
|
|
129
|
+
readonly stateMutability: "view";
|
|
130
|
+
readonly inputs: readonly [];
|
|
131
|
+
readonly outputs: readonly [{
|
|
132
|
+
readonly name: "";
|
|
133
|
+
readonly type: "uint256";
|
|
134
|
+
}];
|
|
135
|
+
}, {
|
|
136
|
+
readonly type: "function";
|
|
137
|
+
readonly name: "depositAddress";
|
|
138
|
+
readonly stateMutability: "view";
|
|
139
|
+
readonly inputs: readonly [{
|
|
140
|
+
readonly name: "settings";
|
|
141
|
+
readonly type: "tuple";
|
|
142
|
+
readonly components: readonly [{
|
|
143
|
+
readonly name: "recipient";
|
|
144
|
+
readonly type: "address";
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "unwrap";
|
|
147
|
+
readonly type: "bool";
|
|
148
|
+
}, {
|
|
149
|
+
readonly name: "feeRateE18";
|
|
150
|
+
readonly type: "uint256";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "partner";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "partnerRateE18";
|
|
156
|
+
readonly type: "uint256";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "group";
|
|
159
|
+
readonly type: "uint8";
|
|
160
|
+
}, {
|
|
161
|
+
readonly name: "token";
|
|
162
|
+
readonly type: "address";
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "index";
|
|
165
|
+
readonly type: "uint256";
|
|
166
|
+
}];
|
|
167
|
+
}];
|
|
168
|
+
readonly outputs: readonly [{
|
|
169
|
+
readonly name: "";
|
|
170
|
+
readonly type: "address";
|
|
171
|
+
}];
|
|
172
|
+
}, {
|
|
173
|
+
readonly type: "function";
|
|
174
|
+
readonly name: "flush";
|
|
175
|
+
readonly stateMutability: "payable";
|
|
176
|
+
readonly inputs: readonly [{
|
|
177
|
+
readonly name: "settings";
|
|
178
|
+
readonly type: "tuple";
|
|
179
|
+
readonly components: readonly [{
|
|
180
|
+
readonly name: "recipient";
|
|
181
|
+
readonly type: "address";
|
|
182
|
+
}, {
|
|
183
|
+
readonly name: "unwrap";
|
|
184
|
+
readonly type: "bool";
|
|
185
|
+
}, {
|
|
186
|
+
readonly name: "feeRateE18";
|
|
187
|
+
readonly type: "uint256";
|
|
188
|
+
}, {
|
|
189
|
+
readonly name: "partner";
|
|
190
|
+
readonly type: "address";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "partnerRateE18";
|
|
193
|
+
readonly type: "uint256";
|
|
194
|
+
}, {
|
|
195
|
+
readonly name: "group";
|
|
196
|
+
readonly type: "uint8";
|
|
197
|
+
}, {
|
|
198
|
+
readonly name: "token";
|
|
199
|
+
readonly type: "address";
|
|
200
|
+
}, {
|
|
201
|
+
readonly name: "index";
|
|
202
|
+
readonly type: "uint256";
|
|
203
|
+
}];
|
|
204
|
+
}, {
|
|
205
|
+
readonly name: "tokens";
|
|
206
|
+
readonly type: "address[]";
|
|
207
|
+
}];
|
|
208
|
+
readonly outputs: readonly [];
|
|
209
|
+
}];
|
|
210
|
+
/**
|
|
211
|
+
* The one function of the bridge's mediator the interface reads: the smallest transfer it accepts for a token. The
|
|
212
|
+
* factory's `mediator()` names the mediator, and the mediator keeps the minimum per token.
|
|
213
|
+
*/
|
|
214
|
+
export declare const EXCHANGE_DEPOSIT_MEDIATOR_ABI: readonly [{
|
|
215
|
+
readonly type: "function";
|
|
216
|
+
readonly name: "minPerTx";
|
|
217
|
+
readonly stateMutability: "view";
|
|
218
|
+
readonly inputs: readonly [{
|
|
219
|
+
readonly name: "token";
|
|
220
|
+
readonly type: "address";
|
|
221
|
+
}];
|
|
222
|
+
readonly outputs: readonly [{
|
|
223
|
+
readonly name: "";
|
|
224
|
+
readonly type: "uint256";
|
|
225
|
+
}];
|
|
226
|
+
}];
|
|
227
|
+
/** A transaction a wallet can send. `value` is always zero: a flush moves the address's own funds, not the reader's. */
|
|
228
|
+
export interface ExchangeDepositFlushRequest {
|
|
229
|
+
readonly to: Address;
|
|
230
|
+
readonly data: Hex;
|
|
231
|
+
readonly value: 0n;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The transaction that finishes the job for one address: a `flush` of the address's token. Anyone may send it, and
|
|
235
|
+
* the funds still reach the recipient the settings name. For ether the token is the zero address, so the flush lists
|
|
236
|
+
* the zero address, as the factory expects.
|
|
237
|
+
*
|
|
238
|
+
* @param input.chainId - the chain the address lives on
|
|
239
|
+
* @param input.address - a derived address. A placeholder has no factory behind it, so it has no flush.
|
|
240
|
+
* @throws when the address is a placeholder, or the chain has no factory
|
|
241
|
+
*/
|
|
242
|
+
export declare const exchangeDepositFlushRequest: ({ chainId, address, }: {
|
|
243
|
+
chainId: bigint;
|
|
244
|
+
address: ExchangeDepositAddress;
|
|
245
|
+
}) => ExchangeDepositFlushRequest;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exchangeDepositFlushRequest = exports.EXCHANGE_DEPOSIT_MEDIATOR_ABI = exports.EXCHANGE_DEPOSIT_FACTORY_ABI = exports.EXCHANGE_DEPOSIT_FACTORY_USAGE_EVENTS = exports.SETTINGS_COMPONENTS = exports.factorySettingsTupleOf = exports.factoryGroupOf = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const exchange_deposit_factory_js_1 = require("./exchange-deposit-factory.js");
|
|
6
|
+
const factoryGroupOf = (contractGroup) => {
|
|
7
|
+
if (contractGroup === 'ether')
|
|
8
|
+
return 0;
|
|
9
|
+
if (contractGroup === 'single')
|
|
10
|
+
return 2;
|
|
11
|
+
throw new Error(`the ${String(contractGroup)} group is not one the factory takes`);
|
|
12
|
+
};
|
|
13
|
+
exports.factoryGroupOf = factoryGroupOf;
|
|
14
|
+
const factorySettingsTupleOf = ({ settings, token, }) => ({
|
|
15
|
+
recipient: settings.recipient,
|
|
16
|
+
unwrap: settings.unwrapToNativePls,
|
|
17
|
+
feeRateE18: settings.feeRateE18,
|
|
18
|
+
partner: viem_1.zeroAddress,
|
|
19
|
+
partnerRateE18: 0n,
|
|
20
|
+
group: (0, exports.factoryGroupOf)(token.contractGroup),
|
|
21
|
+
token: token.address,
|
|
22
|
+
index: settings.index,
|
|
23
|
+
});
|
|
24
|
+
exports.factorySettingsTupleOf = factorySettingsTupleOf;
|
|
25
|
+
exports.SETTINGS_COMPONENTS = [
|
|
26
|
+
{ name: 'recipient', type: 'address' },
|
|
27
|
+
{ name: 'unwrap', type: 'bool' },
|
|
28
|
+
{ name: 'feeRateE18', type: 'uint256' },
|
|
29
|
+
{ name: 'partner', type: 'address' },
|
|
30
|
+
{ name: 'partnerRateE18', type: 'uint256' },
|
|
31
|
+
{ name: 'group', type: 'uint8' },
|
|
32
|
+
{ name: 'token', type: 'address' },
|
|
33
|
+
{ name: 'index', type: 'uint256' },
|
|
34
|
+
];
|
|
35
|
+
exports.EXCHANGE_DEPOSIT_FACTORY_USAGE_EVENTS = [
|
|
36
|
+
(0, viem_1.parseAbiItem)('event Flushed(bytes32 indexed settingsHash, address indexed depositAddress)'),
|
|
37
|
+
(0, viem_1.parseAbiItem)('event Rescued(bytes32 indexed settingsHash, address indexed depositAddress, address indexed to)'),
|
|
38
|
+
(0, viem_1.parseAbiItem)('event Retired(bytes32 indexed settingsHash, address indexed depositAddress, address indexed recipient)'),
|
|
39
|
+
];
|
|
40
|
+
exports.EXCHANGE_DEPOSIT_FACTORY_ABI = [
|
|
41
|
+
{
|
|
42
|
+
type: 'function',
|
|
43
|
+
name: 'mediator',
|
|
44
|
+
stateMutability: 'view',
|
|
45
|
+
inputs: [],
|
|
46
|
+
outputs: [{ name: '', type: 'address' }],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'function',
|
|
50
|
+
name: 'MAXIMUM_FEE_RATE_E18',
|
|
51
|
+
stateMutability: 'view',
|
|
52
|
+
inputs: [],
|
|
53
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'function',
|
|
57
|
+
name: 'MAXIMUM_PARTNER_RATE_E18',
|
|
58
|
+
stateMutability: 'view',
|
|
59
|
+
inputs: [],
|
|
60
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'function',
|
|
64
|
+
name: 'depositAddress',
|
|
65
|
+
stateMutability: 'view',
|
|
66
|
+
inputs: [{ name: 'settings', type: 'tuple', components: exports.SETTINGS_COMPONENTS }],
|
|
67
|
+
outputs: [{ name: '', type: 'address' }],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'function',
|
|
71
|
+
name: 'flush',
|
|
72
|
+
stateMutability: 'payable',
|
|
73
|
+
inputs: [
|
|
74
|
+
{ name: 'settings', type: 'tuple', components: exports.SETTINGS_COMPONENTS },
|
|
75
|
+
{ name: 'tokens', type: 'address[]' },
|
|
76
|
+
],
|
|
77
|
+
outputs: [],
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
exports.EXCHANGE_DEPOSIT_MEDIATOR_ABI = [
|
|
81
|
+
{
|
|
82
|
+
type: 'function',
|
|
83
|
+
name: 'minPerTx',
|
|
84
|
+
stateMutability: 'view',
|
|
85
|
+
inputs: [{ name: 'token', type: 'address' }],
|
|
86
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
const exchangeDepositFlushRequest = ({ chainId, address, }) => {
|
|
90
|
+
if (address.origin !== 'derived')
|
|
91
|
+
throw new Error('a placeholder address has no flush');
|
|
92
|
+
const { address: factory } = (0, exchange_deposit_factory_js_1.exchangeDepositFactoryOf)(chainId);
|
|
93
|
+
return {
|
|
94
|
+
to: factory,
|
|
95
|
+
value: 0n,
|
|
96
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
97
|
+
abi: exports.EXCHANGE_DEPOSIT_FACTORY_ABI,
|
|
98
|
+
functionName: 'flush',
|
|
99
|
+
args: [(0, exports.factorySettingsTupleOf)({ settings: address.settings, token: address.token }), [address.token.address]],
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
exports.exchangeDepositFlushRequest = exchangeDepositFlushRequest;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { ExchangeDepositToken } from './exchange-deposit.js';
|
|
3
|
+
/**
|
|
4
|
+
* The deposit factory: its address per chain, and the tokens and prices each chain offers.
|
|
5
|
+
*
|
|
6
|
+
* THE ONE PLACE THE FACTORY ADDRESS LIVES. The factory is redeployed with a simpler constructor. When that happens,
|
|
7
|
+
* change the entry of its chain in {@link EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN} and nothing else. No other file names
|
|
8
|
+
* the address.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here reads the chain. Addresses are derived by calling the factory (`depositAddress`), never by a local
|
|
11
|
+
* CREATE2 copy, so a change to the factory's derivation cannot leave this code behind.
|
|
12
|
+
*
|
|
13
|
+
* THIS FILE IS LIGHT ON PURPOSE. It holds only the map, the route checks and the link names, because the bridge's
|
|
14
|
+
* entry chunk reads it on every load. The contract interface, the events and the flush encoding live in `exchange-deposit-factory-calls.ts`.
|
|
15
|
+
*/
|
|
16
|
+
/** One deployment of the deposit factory, and the tokens the interface offers on its chain. */
|
|
17
|
+
export interface ExchangeDepositFactoryEntry {
|
|
18
|
+
/** The factory contract. */
|
|
19
|
+
readonly address: Address;
|
|
20
|
+
/** The chain's proper name as a reader sees it, such as `Sepolia`. It is never translated. */
|
|
21
|
+
readonly chainName: string;
|
|
22
|
+
/** Whether the chain is a test network. A test network's addresses take test funds only, and the page says so. */
|
|
23
|
+
readonly isTestNetwork: boolean;
|
|
24
|
+
/** The PulseChain chain the funds arrive on when a deposit from an exchange crosses. */
|
|
25
|
+
readonly destinationChainId: bigint;
|
|
26
|
+
/** The destination chain's proper name as a reader sees it, such as `PulseChain testnet`. It is never translated. */
|
|
27
|
+
readonly destinationChainName: string;
|
|
28
|
+
/** The name the address bar uses for this chain, such as `sepolia`, in `?network=`. */
|
|
29
|
+
readonly addressBarName: string;
|
|
30
|
+
/** The block the factory was deployed at. Read it before scanning logs for the factory. */
|
|
31
|
+
readonly deployedBlock: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* The wrapped ether token of this chain. The factory wraps ether before it crosses, so the mediator keeps the
|
|
34
|
+
* minimum of ether under this address (crossing spec, section 3.2), and the minimum of ether is read from here.
|
|
35
|
+
*/
|
|
36
|
+
readonly wrappedEtherAddress: Address;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the Glamsterdam upgrade is active on this chain. It turns on the warning that a plain ether send of 21,000
|
|
39
|
+
* gas fails (see `exchangeDepositNeedsGasLimitWarning`). It does not choose the gas table, which is a separate choice
|
|
40
|
+
* (`EXCHANGE_DEPOSIT_GAS_TABLE_NAME_BY_CHAIN`).
|
|
41
|
+
*/
|
|
42
|
+
readonly glamsterdamActive: boolean;
|
|
43
|
+
/** The tokens the interface offers on this chain, in the order to show them. */
|
|
44
|
+
readonly tokens: readonly ExchangeDepositToken[];
|
|
45
|
+
/**
|
|
46
|
+
* The price the interface assumes for each token, by lower case address, in wei of ether per whole token. A test
|
|
47
|
+
* network has no market, so this is a stated assumption and not a feed. A token with no entry has no threshold.
|
|
48
|
+
*/
|
|
49
|
+
readonly weiPerWholeTokenByAddress: Readonly<Record<string, bigint>>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The factory per chain. There is ONE entry per deployment; a chain without an entry has no real deposit addresses.
|
|
53
|
+
*/
|
|
54
|
+
export declare const EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN: ReadonlyMap<bigint, ExchangeDepositFactoryEntry>;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a bridge route is one a deposit from an exchange serves: its origin chain has a factory, and the route ends
|
|
57
|
+
* on the chain that factory's deposits arrive on. The factories are read from the map, never named here, so a factory
|
|
58
|
+
* added to the map turns its route on with no other change.
|
|
59
|
+
*
|
|
60
|
+
* @param input.originChainId - the chain the bridge sends from
|
|
61
|
+
* @param input.destinationChainId - the chain the bridge sends to
|
|
62
|
+
* @param input.factories - the factories to read. Defaults to the deployed ones.
|
|
63
|
+
*/
|
|
64
|
+
export declare const isExchangeDepositRoute: ({ originChainId, destinationChainId, factories, }: {
|
|
65
|
+
originChainId: number;
|
|
66
|
+
destinationChainId: number;
|
|
67
|
+
factories?: ReadonlyMap<bigint, ExchangeDepositFactoryEntry>;
|
|
68
|
+
}) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The address-bar name of the factory on a chain, for a link that must open that chain's deposits. A chain with no
|
|
71
|
+
* factory has no name, so a link to it carries no network.
|
|
72
|
+
*
|
|
73
|
+
* @param input.chainId - the chain the deposit starts on
|
|
74
|
+
* @param input.factories - the factories to read. Defaults to the deployed ones.
|
|
75
|
+
* @returns the name, or null when the chain has no factory
|
|
76
|
+
*/
|
|
77
|
+
export declare const addressBarNetworkOf: ({ chainId, factories, }: {
|
|
78
|
+
chainId: number;
|
|
79
|
+
factories?: ReadonlyMap<bigint, ExchangeDepositFactoryEntry>;
|
|
80
|
+
}) => string | null;
|
|
81
|
+
/**
|
|
82
|
+
* The factory entry of a chain. It never falls back to another chain's factory.
|
|
83
|
+
*
|
|
84
|
+
* @param chainId - the Ethereum chain the deposit runs on
|
|
85
|
+
* @throws when no factory is deployed for the chain in this repository
|
|
86
|
+
*/
|
|
87
|
+
export declare const exchangeDepositFactoryOf: (chainId: bigint) => ExchangeDepositFactoryEntry;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exchangeDepositFactoryOf = exports.addressBarNetworkOf = exports.isExchangeDepositRoute = exports.EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const exchange_deposit_constants_js_1 = require("./exchange-deposit-constants.js");
|
|
6
|
+
const SEPOLIA_USDC_ADDRESS = (0, viem_1.getAddress)('0xda9d4f9b69ac6C22e444eD9aF0CfC043b7a7f53f');
|
|
7
|
+
const SEPOLIA_TOKENS = [
|
|
8
|
+
{
|
|
9
|
+
symbol: 'ETH',
|
|
10
|
+
name: 'Sepolia Ether',
|
|
11
|
+
address: viem_1.zeroAddress,
|
|
12
|
+
decimals: 18,
|
|
13
|
+
contractGroup: 'ether',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
symbol: 'USDC',
|
|
17
|
+
name: 'USD Coin',
|
|
18
|
+
address: SEPOLIA_USDC_ADDRESS,
|
|
19
|
+
decimals: 6,
|
|
20
|
+
contractGroup: 'single',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
const SEPOLIA_WEI_PER_WHOLE_TOKEN_BY_ADDRESS = {
|
|
24
|
+
[viem_1.zeroAddress]: exchange_deposit_constants_js_1.WEI_PER_ETHER,
|
|
25
|
+
[SEPOLIA_USDC_ADDRESS.toLowerCase()]: exchange_deposit_constants_js_1.WEI_PER_ETHER / 3200n,
|
|
26
|
+
};
|
|
27
|
+
const MAINNET_USDC_ADDRESS = (0, viem_1.getAddress)('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48');
|
|
28
|
+
const MAINNET_USDT_ADDRESS = (0, viem_1.getAddress)('0xdAC17F958D2ee523a2206206994597C13D831ec7');
|
|
29
|
+
const MAINNET_DAI_ADDRESS = (0, viem_1.getAddress)('0x6B175474E89094C44Da98b954EedeAC495271d0F');
|
|
30
|
+
const MAINNET_TOKENS = [
|
|
31
|
+
{
|
|
32
|
+
symbol: 'ETH',
|
|
33
|
+
name: 'Ether',
|
|
34
|
+
address: viem_1.zeroAddress,
|
|
35
|
+
decimals: 18,
|
|
36
|
+
contractGroup: 'ether',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
symbol: 'USDC',
|
|
40
|
+
name: 'USD Coin',
|
|
41
|
+
address: MAINNET_USDC_ADDRESS,
|
|
42
|
+
decimals: 6,
|
|
43
|
+
contractGroup: 'single',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
symbol: 'USDT',
|
|
47
|
+
name: 'Tether',
|
|
48
|
+
address: MAINNET_USDT_ADDRESS,
|
|
49
|
+
decimals: 6,
|
|
50
|
+
contractGroup: 'single',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
symbol: 'DAI',
|
|
54
|
+
name: 'Dai',
|
|
55
|
+
address: MAINNET_DAI_ADDRESS,
|
|
56
|
+
decimals: 18,
|
|
57
|
+
contractGroup: 'single',
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
const MAINNET_WEI_PER_WHOLE_TOKEN_BY_ADDRESS = {
|
|
61
|
+
[viem_1.zeroAddress]: exchange_deposit_constants_js_1.WEI_PER_ETHER,
|
|
62
|
+
};
|
|
63
|
+
exports.EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN = new Map([
|
|
64
|
+
[
|
|
65
|
+
exchange_deposit_constants_js_1.SEPOLIA_CHAIN_ID,
|
|
66
|
+
{
|
|
67
|
+
address: (0, viem_1.getAddress)('0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D'),
|
|
68
|
+
chainName: 'Sepolia',
|
|
69
|
+
isTestNetwork: true,
|
|
70
|
+
destinationChainId: 943n,
|
|
71
|
+
destinationChainName: 'PulseChain testnet',
|
|
72
|
+
addressBarName: 'sepolia',
|
|
73
|
+
deployedBlock: 12144436n,
|
|
74
|
+
wrappedEtherAddress: (0, viem_1.getAddress)('0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9'),
|
|
75
|
+
glamsterdamActive: true,
|
|
76
|
+
tokens: SEPOLIA_TOKENS,
|
|
77
|
+
weiPerWholeTokenByAddress: SEPOLIA_WEI_PER_WHOLE_TOKEN_BY_ADDRESS,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
exchange_deposit_constants_js_1.ETHEREUM_MAINNET_CHAIN_ID,
|
|
82
|
+
{
|
|
83
|
+
address: (0, viem_1.getAddress)('0x2cf3A381Ae662A06E478491D73bf5D7fD4ebCa0e'),
|
|
84
|
+
chainName: 'Ethereum',
|
|
85
|
+
isTestNetwork: false,
|
|
86
|
+
destinationChainId: 369n,
|
|
87
|
+
destinationChainName: 'PulseChain',
|
|
88
|
+
addressBarName: 'ethereum',
|
|
89
|
+
deployedBlock: 26439236n,
|
|
90
|
+
wrappedEtherAddress: (0, viem_1.getAddress)('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
91
|
+
glamsterdamActive: false,
|
|
92
|
+
tokens: MAINNET_TOKENS,
|
|
93
|
+
weiPerWholeTokenByAddress: MAINNET_WEI_PER_WHOLE_TOKEN_BY_ADDRESS,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
]);
|
|
97
|
+
const isExchangeDepositRoute = ({ originChainId, destinationChainId, factories = exports.EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN, }) => {
|
|
98
|
+
const factory = factories.get(BigInt(originChainId));
|
|
99
|
+
return factory !== undefined && factory.destinationChainId === BigInt(destinationChainId);
|
|
100
|
+
};
|
|
101
|
+
exports.isExchangeDepositRoute = isExchangeDepositRoute;
|
|
102
|
+
const addressBarNetworkOf = ({ chainId, factories = exports.EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN, }) => factories.get(BigInt(chainId))?.addressBarName ?? null;
|
|
103
|
+
exports.addressBarNetworkOf = addressBarNetworkOf;
|
|
104
|
+
const exchangeDepositFactoryOf = (chainId) => {
|
|
105
|
+
const entry = exports.EXCHANGE_DEPOSIT_FACTORY_BY_CHAIN.get(chainId);
|
|
106
|
+
if (entry === undefined)
|
|
107
|
+
throw new Error(`no deposit factory is configured for chain ${chainId}`);
|
|
108
|
+
return entry;
|
|
109
|
+
};
|
|
110
|
+
exports.exchangeDepositFactoryOf = exchangeDepositFactoryOf;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import { type ExchangeDepositAddress, type ExchangeDepositFeeLimits, type ExchangeDepositCrossingConditions, type ExchangeDepositRequest, type ExchangeDepositSettings, type ExchangeDepositSource, type ExchangeDepositToken } from './exchange-deposit.js';
|
|
3
|
+
import { type ExchangeDepositSeed } from './exchange-deposit-index.js';
|
|
4
|
+
/** The tokens the fake source offers, in the order a reader sees them. */
|
|
5
|
+
export declare const FAKE_EXCHANGE_DEPOSIT_TOKENS: readonly ExchangeDepositToken[];
|
|
6
|
+
/** Which situations the fake source can act out. */
|
|
7
|
+
export type FakeExchangeDepositScenario = 'empty' | 'partway' | 'ready' | 'crossing';
|
|
8
|
+
/** Every scenario, for a screen that lets a reviewer pick one. */
|
|
9
|
+
export declare const FAKE_EXCHANGE_DEPOSIT_SCENARIOS: readonly FakeExchangeDepositScenario[];
|
|
10
|
+
/**
|
|
11
|
+
* Whether a string names a scenario.
|
|
12
|
+
*
|
|
13
|
+
* @param value - text from an address bar, or null
|
|
14
|
+
*/
|
|
15
|
+
export declare const isFakeExchangeDepositScenario: (value: string | null) => value is FakeExchangeDepositScenario;
|
|
16
|
+
/**
|
|
17
|
+
* One fake address from its settings. NOT the real derivation (TODO-real): it
|
|
18
|
+
* hashes the settings so the same settings give the same address and a new index
|
|
19
|
+
* gives another, which is the only property the screens need. Like the factory,
|
|
20
|
+
* it gives ether one address (the `ether` group) and every token its own address
|
|
21
|
+
* (the `single` group).
|
|
22
|
+
*
|
|
23
|
+
* @param settings - the settings that define the address
|
|
24
|
+
*/
|
|
25
|
+
export declare const fakeDeriveExchangeDepositAddress: (settings: ExchangeDepositSettings) => Address;
|
|
26
|
+
/**
|
|
27
|
+
* What the fake executor weighs: a crossing on Ethereum mainnet at the paid gas of its table, at a base fee of
|
|
28
|
+
* 1.2 gwei plus a tip of 0.1 gwei, times 2, with ether at 3,200 dollars.
|
|
29
|
+
*/
|
|
30
|
+
export declare const FAKE_EXCHANGE_DEPOSIT_CONDITIONS: ExchangeDepositCrossingConditions;
|
|
31
|
+
/**
|
|
32
|
+
* Builds the fake address of a set of settings, in the state a scenario describes.
|
|
33
|
+
*
|
|
34
|
+
* @param input.settings - the settings that define the address
|
|
35
|
+
* @param input.scenario - the situation to act out
|
|
36
|
+
* @throws when the fake source does not offer the token of the settings
|
|
37
|
+
*/
|
|
38
|
+
export declare const fakeExchangeDepositAddress: ({ settings, scenario, }: {
|
|
39
|
+
settings: ExchangeDepositSettings;
|
|
40
|
+
scenario: FakeExchangeDepositScenario;
|
|
41
|
+
}) => ExchangeDepositAddress;
|
|
42
|
+
/**
|
|
43
|
+
* The settings of a request. Wrapped PLS arrives as PLS: the only token that asks for the unwrap. The factory index is
|
|
44
|
+
* derived from the request's seed, the same way the real source derives it.
|
|
45
|
+
*
|
|
46
|
+
* @param request - the recipient, the token, the fee, the counter and the seed
|
|
47
|
+
*/
|
|
48
|
+
export declare const settingsOfRequest: (request: ExchangeDepositRequest) => ExchangeDepositSettings;
|
|
49
|
+
/**
|
|
50
|
+
* The seed the fake source uses. A development build that acts out a scenario skips the sign-in, so the fake addresses
|
|
51
|
+
* need a fixed seed rather than a signature. It is not a secret: the fake addresses hold nothing.
|
|
52
|
+
*/
|
|
53
|
+
export declare const FAKE_EXCHANGE_DEPOSIT_SEED: ExchangeDepositSeed;
|
|
54
|
+
/** The recipient the fake source reports as a contract: any address ending in `c0de`. */
|
|
55
|
+
export declare const FAKE_CONTRACT_RECIPIENT: Address;
|
|
56
|
+
/**
|
|
57
|
+
* The maximums the fake factory reports: the same 1e16 (1 percent) for each rate as the deployed factory. A test or a
|
|
58
|
+
* draft reads these in place of the chain.
|
|
59
|
+
*/
|
|
60
|
+
export declare const FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS: ExchangeDepositFeeLimits;
|
|
61
|
+
/**
|
|
62
|
+
* A source that acts out one scenario. TODO-real: replace with the source the
|
|
63
|
+
* contract work provides.
|
|
64
|
+
*
|
|
65
|
+
* @param scenario - the situation to act out
|
|
66
|
+
*/
|
|
67
|
+
export declare const fakeExchangeDepositSource: (scenario: FakeExchangeDepositScenario) => ExchangeDepositSource;
|