Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request connext collateral based on order amount #1845

Closed
kilrau opened this issue Aug 27, 2020 · 17 comments · Fixed by #1885
Closed

Request connext collateral based on order amount #1845

kilrau opened this issue Aug 27, 2020 · 17 comments · Fixed by #1885
Assignees
Labels
connext P1 top priority

Comments

@kilrau
Copy link
Contributor

kilrau commented Aug 27, 2020

As discussed before, we should request channel collateralization (remote balance) from the connext node ahead of (swap) time to avoid on-the-fly collateralization.

How it could work:

  1. placeOrder
  2. xud checks tradinglimits
  3. if lnd remote balance not enough to fully swap order, xud fail order placement as is
  4. if connext remote balance is not enough to fully swap, xud request remainder as collateral from the node and puts order on hold
  5. once collateralization is done (xud can just hit the /balance endpoint to see if remote balance is there
  6. once remote balance appears, place order. If remote balance doesn't appear within certain timeout, drop order. (some tbd's here, e.g. how to handle arby replacing current order on-hold)
  7. subsequent replace orders (e.g. via arby replace) should pass without collateralization needed

Depending on:
connext/rest-api-client#89 -> PR: connext/rest-api-client#90
connext/indra#1405 (comment) -> PR: connext/indra#1406

@kilrau kilrau added P1 top priority connext labels Aug 27, 2020
@kilrau kilrau assigned ghost , sangaman and raladev Aug 27, 2020
@kilrau
Copy link
Contributor Author

kilrau commented Aug 28, 2020

connext/indra#1405 (comment) + connext/rest-api-client#89 should get us all we need. Connext moved fast, and a PR for connext/indra#1405 is already up: connext/indra#1406 props to @rhlsthrm

@ghost
Copy link

ghost commented Aug 28, 2020

As discussed before, we should request channel collateralization (remote balance) from the connext node ahead of (swap) time to avoid on-the-fly collateralization.

How it could work:

1. `placeOrder`

2. `xud` checks `tradinglimits`

3. if lnd remote balance not enough to fully swap order, xud fail order placement as is

4. if connext remote balance is not enough to fully swap, xud request remainder as collateral from the node and puts order on hold

What if instead of putting it on hold we fail the PlaceOrder request and ask the user to try again later (while starting the collateral request to the node). Consecutive, PlaceOrder requests would fail immediately if the request for collateral is in progress (and additional collateral is needed to fill that order).

7. subsequent replace orders (e.g. via arby replace) should pass without collateralization needed

Hmm, replace order could also need additional collateral if the price changes.

@kilrau
Copy link
Contributor Author

kilrau commented Aug 28, 2020

What if instead of putting it on hold we fail the PlaceOrder request and ask the user to try again later (while starting the collateral request to the node). Consecutive, PlaceOrder requests would fail immediately if the request for collateral is in progress (and additional collateral is needed to fill that order).

That would also work. Easier from an implementation perspective I guess (even though there would be a new check against "collateralization already in progress, don't re-request").

Hmm, replace order could also need additional collateral if the price changes.

If the price changes and consequently amount exceeds remote balance. What we can do is, request 3% more from the node to account for that.

@ghost
Copy link

ghost commented Aug 31, 2020

If the price changes and consequently amount exceeds remote balance. What we can do is, request 3% more from the node to account for that.

Yep, some buffer would probably be nice to have.

The scenario I was thinking of was when the user deposits additional funds to BTC/LTC channels/CEX. In that case the logic would be the same as regular PlaceOrder - we wait until the additional collateralization is added in the background.

@kilrau kilrau changed the title RFC: Request collateral from connext node based on order amount Request connext collateral based on order amount Aug 31, 2020
@ghost
Copy link

ghost commented Aug 31, 2020

@sangaman any thoughts/ideas?

@kilrau
Copy link
Contributor Author

kilrau commented Sep 1, 2020

Reiterating @raladev 's question about this on yesterday's call: do we still ask the node to automatically collateralize a fixed % of the amount (boltz-style) on openchannel for connext?

Thinking about this again, I think it's better to solely rely on order amounts to request collateral from the connext node. This is simply much more precise and the node's capital is used more efficiently. User's might deposit funds into a connext channel and never use it in an order or at least not for a long period of time. In that caes the nodes capital remains unused. And in the moment it is used for an order, chances are high that the needed collateral amount for the order is be larger than what the node collateralized (fixed %) before. Connext channels give us this flexibility, so we should use it. That means in particular, I suggest xud not to request and collateral based on openchannel, but on placeorder only.

@sangaman
Copy link
Collaborator

sangaman commented Sep 1, 2020

The scenario I was thinking of was when the user deposits additional funds to BTC/LTC channels/CEX. In that case the logic would be the same as regular PlaceOrder - we wait until the additional collateralization is added in the background.

I agree with this logic. Failing rather than waiting if the collateral/remote balance isn't sufficient, particularly since delaying an order isn't great UX given that prices may be changing and the order may no longer be desirable after collateral is there.

That means in particular, I suggest xud not to request and collateral based on openchannel, but on placeorder only.

I think I'd be OK with this, but then would we expect that the first order that receives via Connext will always fail due to needing to wait for collateralization? Maybe it can be optional when using OpenChannel with connext?

@kilrau
Copy link
Contributor Author

kilrau commented Sep 1, 2020

but then would we expect that the first order that receives via Connext will always fail due to needing to wait for collateralization?

No, that's precisely what we would want to prevent here, at least failing as in "swap timeout failing". In the moment the first order receiving connext is placed, xud requests collateralization for the required amount. Question is if we fail the order on CLI level (@erkarl s suggestion) in that case or put it on hold in the background and automatically add it to the order book once the collateralization is through. The latter is much better from user perpective, but would be more complicated to implement I guess. For example we'd need a timer to fail the order, if collateralization is taking longer than X minutes, because then it might be undesirable for the user that the order goes through.

@sangaman
Copy link
Collaborator

sangaman commented Sep 1, 2020

No, that's precisely what we would want to prevent here, at least failing as in "swap timeout failing". In the moment the first order receiving connext is placed, xud requests collateralization for the required amount. Question is if we fail the order on CLI level (@erkarl s suggestion) in that case or put it on hold in the background and automatically add it to the order book once the collateralization is through. The latter is much better from user perpective, but would be more complicated to implement I guess. For example we'd need a timer to fail the order, if collateralization is taking longer than X minutes, because then it might be undesirable for the user that the order goes through.

Yes, I was referring to the order being rejected upon being submitted due to lack of collateral, not due to failing a swap. I'm not sure whether adding the order on a delay is better tho as I mentioned above since a user might only want the order to be good for a few seconds, particularly in the case of market orders.

@ghost
Copy link

ghost commented Sep 1, 2020

I'm not sure whether adding the order on a delay is better tho as I mentioned above since a user might only want the order to be good for a few seconds, particularly in the case of market orders.

I'm strongly of the opinion that we shouldn't automatically place the order in the orderbook once the collateralization completes.

My desired flow would be:

sell 0.1 BTC/USDT 11000
-> CLI: started collateralization of your channel, please try again in 1 minute
30 sec later
sell 0.1 BTC/USDT 11000
-> CLI: collateralization already in progress, please try again in 1 minute
once the collateralization completes
-> xud logs print collateralization complete, new inbound balance: 12345
sell 0.1 BTC/USDT 11000
order placed to the orderbook

@ghost
Copy link

ghost commented Sep 1, 2020

Or alternatively the behaviour that @kilrau suggests would be behind a flag:
sell 0.1 BTC/USDT 11000 --wait-for-collateralization-and-then-place-order-automatically

@kilrau
Copy link
Contributor Author

kilrau commented Sep 1, 2020

a user might only want the order to be good for a few seconds, particularly in the case of market orders.

I'm strongly of the opinion that we shouldn't automatically place the order in the orderbook

Ok I see that. Let's go with Karl's suggestion. Regarding wording/structure of output I suggest:

sell 0.1 BTC/USDT 11000
-> CLI: requested inbound liquidity for your USDT channel, please try again in ~1 minute
30 sec later
sell 0.1 BTC/USDT 11000
-> CLI: already requested inbound liquidity for your USDT channel, please try again in ~1 minute
once the collateralization completes
sell 0.1 BTC/USDT 11000
-> matched 0.1 BTC @ 11000 with peer FunnyGuy order 4522e390-ec73-11ea-b021-9d791f14027a, attempting swap...
(regular matching output)

@kilrau kilrau unassigned ghost and raladev Sep 7, 2020
sangaman added a commit that referenced this issue Sep 10, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we
check the inbound amount against the available collateral for that
currency.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

Closes #1845.
sangaman added a commit that referenced this issue Sep 11, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is no longer requested upon depositing funds to a Connext
channel, instead it is only requested upon placing orders.

Closes #1845.
@raladev
Copy link
Contributor

raladev commented Sep 14, 2020

a user might only want the order to be good for a few seconds, particularly in the case of market orders.

I'm strongly of the opinion that we shouldn't automatically place the order in the orderbook

may we add some flag to autoplace order after collateralization? (replacing is annoying) @kilrau @erkarl

@kilrau
Copy link
Contributor Author

kilrau commented Sep 14, 2020

may we add some flag to autoplace order after collateralization? (replacing is annoying) @kilrau @erkarl

We discussed before that this can be dangerous because the market may move significantly within the time the collateralization takes. As an optional flag this can be useful though (for people who understand the consequences). Other opinions?

@raladev
Copy link
Contributor

raladev commented Sep 14, 2020

may we add some flag to autoplace order after collateralization? (replacing is annoying) @kilrau @erkarl

We discussed before that this can be dangerous because the market may move significantly within the time the collateralization takes. As an optional flag this can be useful though (for people who understand the consequences). Other opinions?

Yeap, i am talking about optional flag with false value as default (no autoplacement as default).

@kilrau
Copy link
Contributor Author

kilrau commented Sep 14, 2020

I think I'd be ok with it, let's see what @erkarl and @sangaman think

@ghost
Copy link

ghost commented Sep 14, 2020

I think I'd be ok with it, let's see what @erkarl and @sangaman think

I'm also OK with an optional flag that enables this functionality. This can be done outside of this PR as a follow-up.

sangaman added a commit that referenced this issue Sep 15, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is no longer requested upon depositing funds to a Connext
channel, instead it is only requested upon placing orders.

Closes #1845.
sangaman added a commit that referenced this issue Sep 17, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 17, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 18, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 18, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the missing capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 22, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 22, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 22, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 22, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 23, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 23, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
sangaman added a commit that referenced this issue Sep 24, 2020
This adds a check when a new order is receiving tokens via connext that
ensures we have sufficient collateral from the connext node to fulfill
the order. If not, we fail the order request and request the additional
collateral necessary. This involves the following changes:

1. The Connext client now tracks the inbound node collateral for each
currency and refreshes this value every time it queries for channel
balances and every time a collateral request completes.

2. Before placing a new order that is receiving Connext tokens we check
the inbound amount against the available collateral for that currency.
In the case of market orders, we use the best available matching price
in the order book to calculate inbound & outbound amounts.

3. If the collateral is insufficient, the order will be rejected and a
collateral request will be performed for the necessary capacity plus a
5% buffer.

4. Any other collateral checks while we're awaiting a response for a
collateral request will not perform an additional collateral request so
as to prevent duplicate calls.

5. Traders may repeat their order request and it will be accepted once
sufficient collateral to complete the trade is acquired.

6. Collateral is only requested upon depositing funds to a Connext
channel according to hardcoded collateral request minimums per currency.

There are also several hardcoded collateral request minimums. If the
capacity shortage is smaller than these minimums, the minimum amount
will be requested instead.

Closes #1845.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connext P1 top priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants