-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathtypes.ts
172 lines (161 loc) · 6.3 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
import { SwapRole, SwapPhase, SwapState, SwapFailureReason } from '../constants/enums';
export type SwapDeal = {
/** Our role in the swap. */
role: SwapRole;
/** The most updated deal phase */
phase: SwapPhase;
/**
* The most updated deal state. State works together with phase to indicate where the
* deal is in its life cycle and if the deal is active, errored, or completed.
*/
state: SwapState;
/** The reason for being in the current state. */
errorMessage?: string;
failureReason?: SwapFailureReason;
/** The xud node pub key of the counterparty to this swap deal. */
peerPubKey: string;
/** The global order id in the XU network for the maker order being executed. */
orderId: string;
/** Whether the maker order is a buy order. */
isBuy: boolean;
/** The local id of the own order involved in the swap. */
localId: string;
/** The quantity of the order to execute as proposed by the taker. */
proposedQuantity: number;
/** The quantity of the order to execute as accepted by the maker. */
quantity?: number;
/** The trading pair for the swap. The pairId together with the orderId are needed to find the maker order in the order book. */
pairId: string;
/** The amount the taker is expecting to receive denominated in satoshis. */
takerAmount: number;
/** The number of the smallest base units of the currency (like satoshis or wei) the maker is expecting to receive. */
takerUnits: bigint;
/** The currency the taker is expecting to receive. */
takerCurrency: string;
/** Taker's lnd pubkey on the taker currency's network. */
takerPubKey?: string;
/** The CLTV delta from the current height that should be used to set the timelock for the final hop when sending to taker. */
takerCltvDelta: number;
/** The amount the maker is expecting to receive denominated in satoshis. */
makerAmount: number;
/** The number of the smallest base units of the currency (like satoshis or wei) the maker is expecting to receive. */
makerUnits: bigint;
/** The currency the maker is expecting to receive. */
makerCurrency: string;
/** The CLTV delta from the current height that should be used to set the timelock for the final hop when sending to maker. */
makerCltvDelta?: number;
/** The price of the order that's being executed. */
price: number;
/** The hex-encoded hash of the preimage. */
rHash: string;
/** The hex-encoded preimage. */
rPreimage?: string;
/** The maximum time lock from the maker to the taker in blocks. */
takerMaxTimeLock?: number;
/** The identifier for the payment channel network node we should pay to complete the swap. */
destination?: string;
/** The time when we created this swap deal locally. */
createTime: number;
/** The time when we began executing the swap for an accepted deal. */
executeTime?: number;
/** The time when the swap either completed successfully or failed. */
completeTime?: number;
};
/** The result of a successful swap. */
export type SwapSuccess = Pick<
SwapDeal,
'orderId' | 'localId' | 'pairId' | 'rHash' | 'peerPubKey' | 'price' | 'rPreimage' | 'role'
> & {
/** The amount received denominated in satoshis. */
amountReceived: number;
/** The amount sent denominated in satoshis. */
amountSent: number;
/** The ticker symbol of the currency received. */
currencyReceived: string;
/** The ticker symbol of the currency sent. */
currencySent: string;
/** The quantity that was swapped. */
quantity: number;
};
/** A swap that has been accepted. */
export type SwapAccepted = Pick<SwapDeal, 'orderId' | 'localId' | 'pairId' | 'rHash' | 'peerPubKey' | 'price'> & {
amountReceiving: number;
amountSending: number;
currencyReceiving: string;
currencySending: string;
/** The quantity that was accepted. */
quantity: number;
};
export type SwapFailure = Pick<SwapDeal, 'orderId' | 'pairId' | 'quantity' | 'peerPubKey'> & {
/** The quantity that was attempted and failed for the swap. */
quantity: number;
failureReason: SwapFailureReason;
};
export type Route = {
getTotalTimeLock: Function;
};
/** Tracks the state of a pending swap of 1 satoshi for 1 satoshi of a specified currency. */
export type SanitySwap = Pick<SwapDeal, 'rHash' | 'rPreimage' | 'peerPubKey'> & {
/** The currency for the swap. */
currency: string;
};
export type SwapCapacities = {
/** Max outbound capacity for a distinct channel denominated in satoshis. */
maxOutboundChannelCapacity: number;
/** Max inbound capacity for a distinct channel denominated in satoshis. */
maxInboundChannelCapacity: number;
/** The total outbound capacity. */
totalOutboundCapacity: number;
/** The total inbound capacity. */
totalInboundCapacity: number;
};
export type TradingLimits = {
/** Maximum outbound limit for a sell order denominated in satoshis. */
maxSell: number;
/** Maximum inbound limit for a buy order denominated in satoshis. */
maxBuy: number;
/** The outbound amount reserved for open sell orders. */
reservedSell: number;
/** The inbound amount reserved for open buy orders. */
reservedBuy: number;
};
export type ResolveRequest = {
/** The amount of the incoming payment pending resolution, in the smallest units supported by the token. */
units: bigint;
rHash: string;
tokenAddress: string;
/** The number of blocks before the incoming payment expires. */
expiration: number;
chainHeight: number;
};
export type CloseChannelParams = {
/** The remote node with which to close channels.. */
remoteIdentifier?: string;
/**
* The amount to extract from the channel, if applicable. If 0 or unspecified,
* the entire off-chain balance for the specified currency will be extracted.
*/
units?: bigint;
currency?: string;
/**
* The on-chain address to send funds extracted from the channel. If unspecified
* the funds return to the default wallet for the client closing the channel.
*/
destination?: string;
force?: boolean;
/** The fee in sat per byte. */
fee?: number;
};
export type OpenChannelParams = {
/** The remote node with which to open the channel. */
remoteIdentifier?: string;
/** The size of the channel. */
units: bigint;
currency?: string;
/** Uris with which to connect to the remote node. */
uris?: string[];
/** The balance to assign to the remote node. */
pushUnits?: bigint;
/** The fee in sat per byte. */
fee?: number;
};