@orbs-network/twap 1.8.1 → 1.8.2
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/dist/src/lib.d.ts +3 -3
- package/dist/src/lib.js +10 -9
- package/package.json +1 -1
package/dist/src/lib.d.ts
CHANGED
|
@@ -39,11 +39,11 @@ export declare class TWAPLib {
|
|
|
39
39
|
getAllOrders(): Promise<Order[]>;
|
|
40
40
|
parseOrder(r: any): Order;
|
|
41
41
|
getToken(address: string): Promise<TokenData>;
|
|
42
|
-
findSwapDataForBid(
|
|
42
|
+
findSwapDataForBid(order: Order): Promise<{
|
|
43
43
|
srcToken: TokenData;
|
|
44
44
|
dstToken: TokenData;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
srcNextChunkAmountIn: BN;
|
|
46
|
+
dstNextChunkAmountOut: BN;
|
|
47
47
|
raw: any;
|
|
48
48
|
data: string;
|
|
49
49
|
}>;
|
package/dist/src/lib.js
CHANGED
|
@@ -209,24 +209,25 @@ class TWAPLib {
|
|
|
209
209
|
return { address, decimals: yield t.decimals(), symbol: yield t.methods.symbol().call() };
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
findSwapDataForBid(
|
|
212
|
+
findSwapDataForBid(order) {
|
|
213
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
if (order.ask.exchange !== web3_candies_1.zeroAddress && !(0, web3_candies_1.eqIgnoreCase)(order.ask.exchange, this.config.exchangeAddress))
|
|
215
|
+
throw new Error(`mismatched exchange and config`);
|
|
216
|
+
const srcNextChunkAmountIn = bignumber_js_1.default.min(order.ask.srcBidAmount, order.ask.srcAmount.minus(order.srcFilledAmount));
|
|
216
217
|
const [srcToken, dstToken] = yield Promise.all([
|
|
217
218
|
this.getToken(order.ask.srcToken),
|
|
218
219
|
this.getToken(order.ask.dstToken),
|
|
219
220
|
]);
|
|
220
|
-
const route = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken,
|
|
221
|
-
const
|
|
221
|
+
const route = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcNextChunkAmountIn, this.config.pathfinderKey);
|
|
222
|
+
const dstNextChunkAmountOut = (0, bignumber_js_1.default)(route.destAmount);
|
|
222
223
|
switch (this.config.exchangeType) {
|
|
223
224
|
case "UniswapV2Exchange":
|
|
224
225
|
const path = paraswap_1.Paraswap.getDirectPath(route, this.config.pathfinderKey);
|
|
225
226
|
return {
|
|
226
227
|
srcToken,
|
|
227
228
|
dstToken,
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
srcNextChunkAmountIn,
|
|
230
|
+
dstNextChunkAmountOut,
|
|
230
231
|
raw: path,
|
|
231
232
|
data: (0, web3_candies_1.web3)().eth.abi.encodeParameters(["bool", "address[]"], [true, path]),
|
|
232
233
|
};
|
|
@@ -234,8 +235,8 @@ class TWAPLib {
|
|
|
234
235
|
return {
|
|
235
236
|
srcToken,
|
|
236
237
|
dstToken,
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
srcNextChunkAmountIn,
|
|
239
|
+
dstNextChunkAmountOut,
|
|
239
240
|
raw: route,
|
|
240
241
|
data: yield paraswap_1.Paraswap.buildSwapData(route, this.config.twapAddress),
|
|
241
242
|
};
|