fix: extend trading limits functions to multiple assets #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When trading limit related functionality was introduced it was restricted to only
asset0
for each exchange, as at the time no exchange had limits configured on both assets. This is no longer the case since multiple exchanges have limits configured on both, so In such cases, the result ofmento.getTradingLimits()
is incorrect.This PR does a few different things:
getTradingLimits()
now returns the current limits on both assetsgetTradingLimitConfig()
andgetTradingLimitState()
now return an array ofTradingLimitsConfig
andTradingLimitsState
with an additionalasset
field instead of a single config/state, containing the configs/states for all assets in the exchange.getTradingLimits
where now the state of limits with a smaller timeframe is constrained by the state of larger ones. For example, if L1 has been maxed out or has a very small capacity left, L0 should reflect that as well. Similarly if LG was completely maxed out and had a remaining of 0, both L1 and L0 should also be set to 0.Tested
Wrote a few additional tests and tested this manually using
scripts/tradingLimits.ts
to fetch the config, state and limits of several exchanges, particularly CELO/eXOF as it's currently maxed out on the CELO side:configs:
state:
limits (
0x471EcE3750Da237f93B8E339c536989b8978a438
is CELO):Backwards compatibility
Because the changes to the signature of
getTradingLimitConfig
andgetTradingLimitState
these changes won't be backwards compatible and will require a major patch, so I have bumped the version of the package to1.0.0