Skip to content

Commit b57f63f

Browse files
committed
Rebased
2 parents e2ff8c2 + 77079ee commit b57f63f

File tree

4 files changed

+211
-214
lines changed

4 files changed

+211
-214
lines changed

lib/service/Service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ class Service {
735735
const array = side === OrderSide.Sell ? orderArrays.buyArray : orderArrays.sellArray;
736736
for (const order of array) {
737737
if (order.quantity && order.price) {
738-
// market buy max calculation
739738
const maxBuyableFromThisPrice = currentBalance / order.price;
740739
const calculatedQuantity = (maxBuyableFromThisPrice > order.quantity) ? order.quantity : maxBuyableFromThisPrice;
741740
result += calculatedQuantity;

proto/xudrpc.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ message TradingLimits {
914914
// The outbound amount reserved for open orders.
915915
uint64 reserved_outbound = 3 [json_name = "reserved_outbound"];
916916
// The inbound amount reserved for open orders.
917-
uint64 reserved_inbound = 4 [json_name = "reserved_outbound"];
917+
uint64 reserved_inbound = 4 [json_name = "reserved_inbound"];
918918
}
919919

920920
message TradingLimitsRequest {

test/integration/Service.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,8 @@ describe('API Service', () => {
331331
btcUsdt.set('BTC/USDT', {
332332
buyArray: [],
333333
sellArray: [
334-
{ quantity: 0.00045, price: 15000, pairId: 'BTC/USDT', id: 'test_1', createdAt: 1, side: OrderSide.Sell,
334+
{ quantity: 0.38919755, price: 12082.5528, pairId: 'BTC/USDT', id: 'test_1', createdAt: 1, side: OrderSide.Sell,
335335
isOwnOrder: false, nodeIdentifier: { nodePubKey: 'some_key1' } },
336-
{ quantity: 1.05, price: 20000, pairId: 'BTC/USDT', id: 'test_2', createdAt: 1, side: OrderSide.Sell,
337-
isOwnOrder: false, nodeIdentifier: { nodePubKey: 'some_key2' } },
338336
],
339337
});
340338
const ethBtc = new Map<string, ServiceOrderSidesArrays>();
@@ -425,20 +423,20 @@ describe('API Service', () => {
425423
const tradingLimitsMap = new Map<string, TradingLimits>();
426424
tradingLimitsMap.set('BTC', {
427425
maxSell: 0,
428-
maxBuy : 1.025,
426+
maxBuy : 2.4499095,
429427
reservedOutbound: 0,
430428
reservedInbound: 0,
431429
});
432430
tradingLimitsMap.set('USDT', {
433-
maxSell: 5,
431+
maxSell: 1000,
434432
maxBuy : 0,
435433
reservedOutbound: 0,
436434
reservedInbound: 0,
437435
});
438436
tradingLimitsStub.returns(Promise.resolve(tradingLimitsMap));
439437

440438
const number = await service['calculateOrderMaxQuantity']('BTC', 'USDT', OrderSide.Buy, undefined, SwapClientType.Lnd, SwapClientType.Connext);
441-
await expect(number).to.equal(0.0003333333333333333);
439+
await expect(number).to.equal(0.08276396689944529);
442440
});
443441

444442
it('should return min(max amount of base using max sell bound for quote, buy max base) lnd/connext mkt buy - 2', async () => {
@@ -458,7 +456,7 @@ describe('API Service', () => {
458456
tradingLimitsStub.returns(Promise.resolve(tradingLimitsMap));
459457

460458
const number = await service['calculateOrderMaxQuantity']('BTC', 'USDT', OrderSide.Buy, undefined, SwapClientType.Lnd, SwapClientType.Connext);
461-
await expect(number).to.equal(0.00006666666666666667);
459+
await expect(number).to.equal(0.0000827639668994453);
462460
});
463461

464462
it('should return (uses max sell bound for quote to calculate base amount) connext/lnd mkt buy', async () => {

0 commit comments

Comments
 (0)