-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
212 lines (180 loc) · 4.46 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import { BigNumber } from "bignumber.js";
import { Bitstream } from "./bitstream";
// Make sure to keep this in sync with the Multihash smart contract
export enum SignAlgorithm {
Ethereum = 0, // Sign with web3.eth_sign
// Should be compatible with Trezor now (with latest firmware):
// https://github.com/ethereum/go-ethereum/issues/14794#issuecomment-392028942
EIP712 = 1, // Sign with web3.eth.signTypedData
// EIP712: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md
None = 255, // Do not sign
}
export enum TokenType {
ERC20 = 0,
COUNT = 1,
}
export interface Spendable {
initialized?: boolean;
amount?: BigNumber;
reserved?: BigNumber;
index?: number;
// Testing
initialAmount?: BigNumber;
}
export interface OrderInfo {
version?: number;
// required fields in contract
owner?: string;
tokenS: string;
tokenB: string;
amountS: number;
amountB: number;
validSince?: number;
tokenSpendableS?: Spendable;
tokenSpendableFee?: Spendable;
// optional fields
dualAuthAddr?: string;
broker?: string;
brokerSpendableS?: Spendable;
brokerSpendableFee?: Spendable;
orderInterceptor?: string;
walletAddr?: string;
validUntil?: number;
allOrNone?: boolean;
sig?: string;
dualAuthSig?: string;
feeToken?: string;
feeAmount?: number;
waiveFeePercentage?: number;
tokenSFeePercentage?: number;
tokenBFeePercentage?: number;
tokenRecipient?: string;
walletSplitPercentage?: number;
tokenTypeS?: TokenType;
tokenTypeB?: TokenType;
tokenTypeFee?: TokenType;
trancheS?: string;
trancheB?: string;
transferDataS?: string;
// helper field
P2P?: boolean;
filledAmountS?: BigNumber;
brokerInterceptor?: string;
valid?: boolean;
hash?: Buffer;
signAlgorithm?: SignAlgorithm;
dualAuthSignAlgorithm?: SignAlgorithm;
index?: number;
balanceS?: number;
balanceFee?: number;
balanceB?: number;
onChain?: boolean;
signerPrivateKey?: string;
[key: string]: any;
}
export interface Participation {
order: OrderInfo;
// computed fields
splitS: BigNumber;
feeAmount: BigNumber;
feeAmountS: BigNumber;
feeAmountB: BigNumber;
rebateFee: BigNumber;
rebateS: BigNumber;
rebateB: BigNumber;
fillAmountS: BigNumber;
fillAmountB: BigNumber;
// test fields
ringSpendableS: BigNumber;
ringSpendableFee: BigNumber;
}
export interface RingsSubmitParam {
ringSpecs: number[][];
data: Bitstream;
tables: Bitstream;
}
export interface OrderExpectation {
filledFraction: number;
payMatchingFeeUsingAmountB?: boolean;
P2P?: boolean;
margin?: number;
}
export interface RingExpectation {
fail?: boolean;
orders?: OrderExpectation[];
}
export interface TransactionExpectation {
revert?: boolean;
revertMessage?: string;
rings?: RingExpectation[];
decimalsPrecision?: number;
}
export interface RingsInfo {
description?: string;
feeRecipient?: string;
miner?: string;
sig?: string;
rings: number[][];
orders: OrderInfo[];
signAlgorithm?: SignAlgorithm;
hash?: Buffer;
transactionOrigin?: string;
expected?: TransactionExpectation;
[key: string]: any;
}
export interface DetailedTokenTransfer {
description: string;
token: string;
from: string;
to: string;
amount: number;
subPayments: DetailedTokenTransfer[];
}
export interface OrderPayments {
payments: DetailedTokenTransfer[];
}
export interface RingPayments {
orders: OrderPayments[];
}
export interface TransactionPayments {
rings: RingPayments[];
}
export interface SimulatorReport {
reverted: boolean;
revertMessage?: string;
ringMinedEvents: RingMinedEvent[];
invalidRingEvents: InvalidRingEvent[];
transferItems: TransferItem[];
feeBalancesBefore: { [id: string]: any; };
feeBalancesAfter: { [id: string]: any; };
filledAmountsBefore: { [hash: string]: BigNumber; };
filledAmountsAfter: { [hash: string]: BigNumber; };
balancesBefore: { [id: string]: any; };
balancesAfter: { [id: string]: any; };
payments: TransactionPayments;
}
export interface TransferItem {
token: string;
from: string;
to: string;
amount: BigNumber;
}
export interface Fill {
orderHash: string;
owner: string;
tokenS: string;
amountS: BigNumber;
split: BigNumber;
feeAmount: BigNumber;
feeAmountS: BigNumber;
feeAmountB: BigNumber;
}
export interface RingMinedEvent {
ringIndex: BigNumber;
ringHash: string;
feeRecipient: string;
fills: Fill[];
}
export interface InvalidRingEvent {
ringHash: string;
}