feat(kandel): Split Geometric Kandel from core kandel and allow usage⦠#679
This check has been archived and is scheduled for deletion.
Learn more about checks retention
GitHub Actions / Test Report
succeeded
Nov 24, 2023 in 0s
Test Report β
β Β coverage-tests-report.json
619 tests were completed in 173s with 619 passed, 0 failed and 0 skipped.
β Β test/integration/cleaner.integration.test.ts
Cleaner integration tests suite
β
clean asks book, offer is successfully taken, therefore cannot clean it
β
clean failing offers collects bounty
β
clean using different takers funds
β
clean via callStatic for failing offers returns bounty
β Β test/integration/kandel/coreKandelInstance.integration.test.ts
CoreKandelInstance integration tests suite onAave=false
β
approve approves(full=false) tokens for deposit base=1 quote=undefined
β
approve approves(full=false) tokens for deposit base=3 quote=4
β
approve approves(full=false) tokens for deposit base=undefined quote=2
β
approve approves(full=false) tokens for deposit base=undefined quote=undefined
β
approve approves(full=true) tokens for deposit base=1 quote=undefined
β
approve approves(full=true) tokens for deposit base=3 quote=4
β
approve approves(full=true) tokens for deposit base=undefined quote=2
β
approve approves(full=true) tokens for deposit base=undefined quote=undefined
β
approve does not approve if already approved
β
getMinimumVolume agrees with seeder on asks
β
getMinimumVolume agrees with seeder on bids
β
has expected immutable data from chain
β
populateChunks can populate some offers inChunks=false
β
populateChunks can populate some offers inChunks=true
β
retractAndWithdraw can withdraw all offers and amounts inChunks=false
β
retractAndWithdraw can withdraw all offers and amounts inChunks=true
β
retractAndWithdraw can withdraw expected offers and amounts to other address
β
retractOffers can withdraw all offers inChunks=false
β
retractOffers can withdraw all offers inChunks=true
β
retractOffers can withdraw select offers inChunks=false
β
retractOffers can withdraw select offers inChunks=true
CoreKandelInstance integration tests suite onAave=true
β
approve approves(full=false) tokens for deposit base=1 quote=undefined
β
approve approves(full=false) tokens for deposit base=3 quote=4
β
approve approves(full=false) tokens for deposit base=undefined quote=2
β
approve approves(full=false) tokens for deposit base=undefined quote=undefined
β
approve approves(full=true) tokens for deposit base=1 quote=undefined
β
approve approves(full=true) tokens for deposit base=3 quote=4
β
approve approves(full=true) tokens for deposit base=undefined quote=2
β
approve approves(full=true) tokens for deposit base=undefined quote=undefined
β
approve does not approve if already approved
β
getMinimumVolume agrees with seeder on asks
β
getMinimumVolume agrees with seeder on bids
β
has expected immutable data from chain
β
populateChunks can populate some offers inChunks=false
β
populateChunks can populate some offers inChunks=true
β
retractAndWithdraw can withdraw all offers and amounts inChunks=false
β
retractAndWithdraw can withdraw all offers and amounts inChunks=true
β
retractAndWithdraw can withdraw expected offers and amounts to other address
β
retractOffers can withdraw all offers inChunks=false
β
retractOffers can withdraw all offers inChunks=true
β
retractOffers can withdraw select offers inChunks=false
β
retractOffers can withdraw select offers inChunks=true
CoreKandelInstance integration tests suite router-agnostic
β
calculateDistributionWithUniformlyChangedVolume creates new distribution with decreased volumes for all live offers
β
can set gasprice
β
can set gasreq
β
deposit can deposit to Kandel
β
fundOnMangrove adds funds
β
getLockedProvisionFromOffers gets the locked provision
β
getMissingProvisionFromOffers gets the additional needed provision for a higher gasprice
β
getMissingProvisionFromOffers gets the additional needed provision for a larger distribution
β
getRequiredProvision can get provision for gaspriceFactor=3 gasprice=2000 gasreq=42000
β
getRequiredProvision can get provision for gaspriceFactor=undefined gasprice=undefined gasreq=undefined
β
getRequiredProvision can get provision with overrides
β
pending, volume, reserve correct after populate with deposit
β
pending, volume, reserve correct after populate without deposit
β
populate throws if pricePoints parameters do not match
β
populate throws if stepSize parameters do not match
β
withdraw can withdraw all amounts
β
withdraw can withdraw specific amounts to recipient
β Β test/integration/kandel/farm.integration.test.ts
KandelFarm integration tests suite
β
getKandels retrieves aave kandel instances
β
getKandels retrieves all base kandel instances using olKey
β
getKandels retrieves all kandel instances
β
getKandels retrieves all market kandel instances using offerList
β
getKandels retrieves non-aave kandel instances
β
getKandels retrieves owned kandel instances
β Β test/integration/kandel/geometricKandelInstance.integration.test.ts
GeometricKandelInstance integration tests suite onAave=false
β
calculateMinimumDistribution can be deployed with a factor of 1
β
calculateMinimumDistribution cannot be deployed with factor=0.5 or gasreq=undefined
β
calculateMinimumDistribution cannot be deployed with factor=undefined or gasreq=-100000
GeometricKandelInstance integration tests suite onAave=true
β
calculateMinimumDistribution can be deployed with a factor of 1
β
calculateMinimumDistribution cannot be deployed with factor=0.5 or gasreq=undefined
β
calculateMinimumDistribution cannot be deployed with factor=undefined or gasreq=-100000
GeometricKandelInstance integration tests suite router-agnostic
β
calculateUniformDistributionFromMinPrice can heal multiple offers
β
calculateUniformDistributionFromMinPrice with 0 available throws
β
can go through life-cycle with numbers as Bigish
β
createDistributionWithOffers can be used to heal an offer
β
getMinimumVolumeForIndex for ask and bid
β
getOfferStatuses retrieves status
β
getOfferStatuses retrieves status
β
populate can be called with non-1 stepSize
β
populate can be with new distribution
β
populate populates a market, deposits and sets parameters inChunks=false
β
populate populates a market, deposits and sets parameters inChunks=true
β
populate through geometric gasSave, reducedCallData, and general with same result
β
populate throws if offset parameters do not match
β
populate throws if ratio parameters do not match
β Β test/integration/kandel/geometricKandelLib.integration.test.ts
GeometricKandelLib integration test suite
β
same exception on both askGives and bidGives undefined
β
stub agrees with static calls - test 001
β
stub agrees with static calls - test 002
β
stub agrees with static calls - test 003
β
stub agrees with static calls - test 004
β
stub agrees with static calls - test 005
β
stub agrees with static calls - test 006
β
stub agrees with static calls - test 007
β
stub agrees with static calls - test 008
β
stub agrees with static calls - test 009
β
stub agrees with static calls - test 010
β
stub agrees with static calls - test 011
β
stub agrees with static calls - test 012
β
stub agrees with static calls - test 013
β
stub agrees with static calls - test 014
β
stub agrees with static calls - test 015
β
stub agrees with static calls - test 016
β
stub agrees with static calls - test 017
β
stub agrees with static calls - test 018
β
stub agrees with static calls - test 019
β
stub agrees with static calls - test 020
β
stub agrees with static calls - test 021
β
stub agrees with static calls - test 022
β
stub agrees with static calls - test 023
β
stub agrees with static calls - test 024
β
stub agrees with static calls - test 025
β
stub agrees with static calls - test 026
β
stub agrees with static calls - test 027
β
stub agrees with static calls - test 028
β
stub agrees with static calls - test 029
β
stub agrees with static calls - test 030
β
stub agrees with static calls - test 031
β Β test/integration/kandel/seeder.integration.test.ts
KandelSeeder integration tests suite
β
minimumVolume uses config and calculates correct value offerType=asks onAave=false
β
minimumVolume uses config and calculates correct value offerType=asks onAave=true
β
minimumVolume uses config and calculates correct value offerType=bids onAave=false
β
minimumVolume uses config and calculates correct value offerType=bids onAave=true
β
sow deploys kandel and returns instance onAave:false liquiditySharing:false
β
sow deploys kandel and returns instance onAave:false liquiditySharing:true
β
sow deploys kandel and returns instance onAave:true liquiditySharing:false
β
sow deploys kandel and returns instance onAave:true liquiditySharing:true
β
sow deploys kandel with overridden gasprice for provision calculation
β Β test/integration/mangrove.integration.test.ts
Mangrove integration tests suite calculateOLKeyHash
β
agrees with hash generated by events
Mangrove integration tests suite getMarkets
β
gets correct market info and updates with cashness
β
has reverse lookup of address
β
updates with mgvReader
Mangrove integration tests suite node utils
β
can deal a test token
β Β test/integration/mangroveToyENS.integration.test.ts
Mangrove functionality watch local addresses
β
can start watching after ToyENS has been created
β
can start watching before ToyENS has been created
β Β test/integration/market.integration.test.ts
Market integration tests suite
β
buying uses best price, with forceRoutingToMangroveOrder:false
β
buying uses best price, with no forceRoutingToMangroveOrder
β
crudely simulates market buy
β
get minimum volume
β
getOfferProvision agrees with calculateOfferProvision for asks with gasprice=10000
β
getOfferProvision agrees with calculateOfferProvision for asks with gasprice=undefined
β
getOfferProvision agrees with calculateOfferProvision for bids with gasprice=10000
β
getOfferProvision agrees with calculateOfferProvision for bids with gasprice=undefined
β
gets config
β
gets OB
β
max gasreq is added to gas estimates
β
max gasreq returns a BigNumber, even if the book is empty
β
mgvIntegrationTestUtils can post offers for asks
β
mgvIntegrationTestUtils can post offers for bids
β
returns correct data when taking offers
β
selling uses best price
β
subscribes
β
updates OB
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=42 and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=42 and gasLimit=undefined
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=7000000 and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=7000000 and gasLimit=undefined
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=undefined and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=false with gasLowerBound=undefined and gasLimit=undefined
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=42 and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=42 and gasLimit=undefined
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=7000000 and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=7000000 and gasLimit=undefined
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=undefined and gasLimit=6500000
β
uses expected gasLimit and forceRoutingToMangroveOrder=true with gasLowerBound=undefined and gasLimit=undefined
Market integration tests suite estimateVolumeTest
β
return estimate value for buy
β
return estimate value for sell
β
return estimate value for sell
Market integration tests suite getMissingProvision
β
can miss some provision
Market integration tests suite getOutboundInbound
β
returns base as inbound and quote as outbound, when bids
β
returns base as outbound and quote as inbound, when asks
β
returns this.base as inbound and this.quote as outbound, when bids
β
returns this.base as outbound and this.quote as inbound, when asks
Market integration tests suite isActive
β
returns false, when asks and bids both not active
β
returns false, when asks is active and bids is not active
β
returns false, when asks is not active and bids is active
β
returns true, when asks and bids are active
Market integration tests suite isLive
β
returns false, when gives is less than 1
β
returns true, when gives is positive
Market integration tests suite offerInfo
β
return offer from ba semi book
β
returns asks offer info
β
returns bids offer info
Market integration tests suite Readonly mode
β
can read book updates in readonly mode
β Β test/integration/mgvtoken.integration.test.ts
MGV Token integration tests suite
β
allowanceInfinite is false if allowance is 2^200
β
allowanceInfinite is true if allowance is 2^200 + 1
β
allowanceInfinite is true if infinite allowance
β
approve can be set to 0
β
approve sets approved amount
β
approveIfHigher sets when higher but not when lower
β
approveIfNotInfinite creates approval TX only if finite
β
converts
β
get token from address
β
has checksum addresses
β
increaseApproval increases except when at max
β
reads allowance and sets
β Β test/integration/offermaker.integration.test.ts
OfferMaker integration test suite
β
checks allowance for EOA provider
β
checks allowance for onchain logic
β
checks provision for EOA provider
β
checks provision for onchain logic
β
checks provision for onchain logic by calling provisionOf
β
gets missing provision for eoa logic
β
gets missing provision for onchain logic
OfferMaker integration test suite After setup
β
approves signer for base transfer
β
cancels offer
β
fails, when trying to cancel a non-existing offer
β
fails, when trying to create an offer on a closed market
β
fails, when trying to push new offer without sufficient provision
β
fails, when trying to update on a closed market
β
OfferMaker updates offer
β
pushes a new offer
β
withdraws
β Β test/integration/restingOrder.integration.test.ts
RestingOrder Resting order integration tests suite
β
no resting order params, with forceRoutingToMangroveOrder:true
β
no resting order params, with forceRoutingToMangroveOrder:true
β
resting order with deadline and custom gasreq
β
resting order, using existing offer
β
simple resting order, with forceRoutingToMangroveOrder:false
β
simple resting order, with forceRoutingToMangroveOrder:true
β
simple resting order, with no forceRoutingToMangroveOrder
RestingOrder RestingOrder connectivity
β
deploys and connects
β Β test/integration/semibook.integration.test.ts
Semibook integration tests suite estimateVolume estimateVolume({to: buy}) - cache tests
β
returns all given as residue when cache and offer list is empty
β
returns correct estimate and residue when cache is empty and offer list is not
β
returns correct estimate and residue when cache is partial and insufficient while offer list is sufficient
β
returns correct estimate and residue when cache is partial and offer list is insufficient
Semibook integration tests suite estimateVolume estimateVolume({to: buy}) - calculation tests
β
estimates all available volume when offer list has 1 offer with insufficient volume
β
estimates all available volume when offer list has multiple offers with insufficient volume
β
estimates volume and no residue when offer list has 1 offer with sufficient volume
β
estimates volume and no residue when offer list has multiple offers which together have sufficient volume
β
returns zero when given is zero
Semibook integration tests suite estimateVolume estimateVolume({to: sell}) - cache tests
β
returns all given as residue when cache and offer list is empty
β
returns correct estimate and residue when cache is empty and offer list is not
β
returns correct estimate and residue when cache is partial and insufficient while offer list is sufficient
β
returns correct estimate and residue when cache is partial and offer list is insufficient
Semibook integration tests suite estimateVolume estimateVolume({to: sell}) - calculation tests
β
estimates all available volume when offer list has 1 offer with insufficient volume
β
estimates all available volume when offer list has multiple offers with insufficient volume
β
estimates volume and no residue when offer list has 1 offer with sufficient volume
β
estimates volume and no residue when offer list has multiple offers which together have sufficient volume
β
returns zero when given is zero
Semibook integration tests suite getBestInCache
β
returns offer id 1, because cache gets synced even though market is created before offer
β
returns offer id 1, because market made after offer
Semibook integration tests suite getConfig
β
returns the config of a block as Mangrove.LocalConfig, when given blocknumber
β
returns the config of a block, when given blocknumber
β
returns the config of the latest block as Mangrove.LocalConfig, when given no blocknumber
β
returns the config of the latest block as Mangrove.RawConfig, when given no blocknumber
Semibook integration tests suite getMaxGasReq
β
finds max gasreq on both asks and bids side of market
β
returns `undefined` when the semibook is empty
Semibook integration tests suite getMinimumVolume
β
gets 1 unit if density is 0
β
gets minimum volume
Semibook integration tests suite initialization options Option.desiredPrice
β
does not fail if offer list is empty
β
fetches all offers if all have a better price
β
fetches only one chunk if no offers have a better price
β
stops fetching when a chunk with a worse price has been fetched
Semibook integration tests suite initialization options Option.desiredVolume {to: buy}
β
does not fail if offer list is empty
β
fetches all offers if offer list has insufficient volume
β
fetches only one chunk if it has sufficient volume
β
stops fetching when sufficient volume has been fetched
Semibook integration tests suite initialization options Option.desiredVolume {to: sell}
β
does not fail if offer list is empty
β
fetches all offers if offer list has insufficient volume
β
fetches only one chunk if it has sufficient volume
β
stops fetching when sufficient volume has been fetched
Semibook integration tests suite offerInfo
β
returns offer from cache, when offer is in cache
β
returns offer from cache, when offer is in cache
β
returns offer from contract, when offer is not in cache
β
returns offer from contract, when offer is not in cache
β Β test/unit/configuration.unit.test.ts
Configuration unit tests suite
β
Adding token config does not affect existing config
β
Can add token config of unknown token
β
can read mangroveOrder config
β
Reset of configuration reverts additions and changes
β Β test/unit/densityLib.unit.test.ts
Density unit test suite
β
test_density_convert_auto
β
test_density_manual
β
test_density_multiply_auto
β
test_multiply_manual
β
test_paramsTo96X32
β Β test/unit/kandel/generalKandelDistribution.unit.test.ts
GeneralKandelDistribution unit tests suite chunkDistribution
β
can chunk an even set
β
can chunk an uneven set
β
can have one extra offer due to boundary
β
works with all asks
β
works with all bids
β Β test/unit/kandel/generalKandelDistributionGenerator.unit.test.ts
GeneralKandelDistributionGenerator unit tests suite uniformlyChangeVolume
β
respects minimums
GeometricKandelDistributionGenerator unit tests suite calculateDistribution
β
calculates expected price points when generating generateFromMid=false
β
calculates expected price points when generating generateFromMid=true
β
can calculate distribution with constant base generateFromMid=false
β
can calculate distribution with constant base generateFromMid=true
β
can calculate distribution with constant outbound
β
can calculate distribution with constant quote
β
can calculate distribution with fixed base/quote constantBase=false volume which follows geometric distribution
β
can calculate distribution with fixed base/quote constantBase=true volume which follows geometric distribution
β
throws on missing initials
GeometricKandelDistributionGenerator unit tests suite calculateDistribution calculateDistribution
β
can calculate distribution with fixed base volume and fixed quote volume which follows geometric price distribution
β
can calculate distribution with only asks
β
can calculate distribution with only bids
β
rounds off base and gives according to decimals
GeometricKandelDistributionGenerator unit tests suite calculateFirstOfferIndexAndFirstAskIndex
β
calculates the right value for fromMid=0 min=1 mid=-10 offset=1 pricePoints=10
β
calculates the right value for fromMid=0 min=2 mid=10 offset=1 pricePoints=2
β
calculates the right value for fromMid=0 min=2 mid=2 offset=1 pricePoints=10
β
calculates the right value for fromMid=0 min=2 mid=6 offset=1 pricePoints=10
β
calculates the right value for fromMid=0 min=2 mid=6 offset=1 pricePoints=3
β
calculates the right value for fromMid=0 min=2 mid=6 offset=1 pricePoints=4
β
calculates the right value for fromMid=0 min=2 mid=7 offset=3 pricePoints=10
β
calculates the right value for fromMid=1 min=1 mid=-10 offset=1 pricePoints=10
β
calculates the right value for fromMid=1 min=2 mid=2 offset=1 pricePoints=10
β
calculates the right value for fromMid=1 min=2 mid=6 offset=1 pricePoints=10
β
calculates the right value for fromMid=1 min=2 mid=6 offset=1 pricePoints=3
β
calculates the right value for fromMid=1 min=2 mid=6 offset=1 pricePoints=4
β
calculates the right value for fromMid=1 min=2 mid=7 offset=3 pricePoints=10
GeometricKandelDistributionGenerator unit tests suite calculateGeometricDistributionParams
β
generateFromMid=false has firstAskIndex higher than max has no asks
β
generateFromMid=false has firstAskIndex higher than max has no asks
β
midPrice higher than max has no asks
β
midPrice higher than max has no asks generateFromMid=false
β
midPrice higher than max has no asks generateFromMid=true
β
passes on TickDistributionParams and calculated values
GeometricKandelDistributionGenerator unit tests suite calculateMinimumDistribution
β
can have constant base
β
can have constant gives
β
can have constant quote
β
throws if both constant
GeometricKandelDistributionGenerator unit tests suite getMinimumVolumeForIndex
β
also can use dual to calculate minimum asks 0.01 100
β
also can use dual to calculate minimum asks 0.1 100
β
also can use dual to calculate minimum bids 0.01 100
β
also can use dual to calculate minimum bids 0.1 100
GeometricKandelDistributionGenerator unit tests suite recalculateDistributionFromAvailable
β
can set new constant base
β
can set new constant gives
β
can set new constant quote
β Β test/unit/kandel/generalKandelDistributionHelper.unit.test.ts
GeneralKandelDistributionHelper unit tests suite chunkIndices
β
can chunk
GeneralKandelDistributionHelper unit tests suite chunkIndicesAroundMiddle
β
can chunk an even set
β
can chunk an uneven set with middle=2
β
can chunk an uneven set with middle=undefined
β
works with middle=0
β
works with middle=4
GeneralKandelDistributionHelper unit tests suite sortByIndex
β
sorts
GeneralKandelDistributionHelper unit tests suite uniformlyChangeVolume
β
can decrease uniformly, respects limits, prices, and rounding
β
can increase and decrease also a single one baseDelta=-2 quoteDelta=undefined
β
can increase and decrease also a single one baseDelta=2 quoteDelta=-2000
β
can increase and decrease also a single one baseDelta=2 quoteDelta=2000
β
can increase and decrease also a single one baseDelta=undefined quoteDelta=-2000
β Β test/unit/kandel/geometricKandel/geometricKandelDistribution.unit.test.ts
GeometricKandelDistribution unit tests suite
β
can retrieve the geometric params
GeometricKandelDistribution unit tests suite getPriceRatio
β
agrees with helper's calculator for baseQuoteTickOffset=1
β
agrees with helper's calculator for baseQuoteTickOffset=6931
β
agrees with helper's calculator for baseQuoteTickOffset=789
β Β test/unit/kandel/geometricKandel/geometricKandelDistributionHelper.unit.test.ts
GeometricKandelDistributionHelper unit tests suite calculateBaseQuoteTickOffset
β
can calculate based on price ratio
β
Fails if less than 1
GeometricKandelDistributionHelper unit tests suite getBaseQuoteTicksFromTick
β
can get baseQuoteTicks from tick
GeometricKandelDistributionHelper unit tests suite getTickDistributionParams
β
calculates sames parameters for all combinations of minPrice, maxPrice, ratio, and pricePoints, and the similar tick-based parameters
β
can get 2 pricePoints from minPrice and maxPrice
β
fails if neither midBaseQuoteTick nor midPrice is given
β
throws error if not enough parameters are given
β
throws error if only 1 price point
β
throws if max too high
β
throws if min too low
β
throws if min/max too close
β Β test/unit/kandel/geometricKandel/geometricKandelStatus.unit.test.ts
GeometricKandelStatus unit tests suite getIndexOfPriceClosestToMid
β
gets closest to mid on multiple
β
gets offer if single
GeometricKandelStatus unit tests suite getOfferStatuses
β
discards outliers even though price is near mid
β
gets all as expected for initial distribution
β
gets price and status with dead and crossed offers
β
gets status with 1 dead near mid with stepSize=1 where dual is not dead
β
gets status with 2 dead near mid with stepSize=1 where dual is dead
β
gets status with 3 dead near mid with stepSize=2 where dual is dead for some
β
gets status with 4 dead near mid with stepSize=2 where dual is dead
β Β test/unit/kandel/kandelConfiguration.unit.test.ts
KandelConfiguration unit tests suite getConfigForBaseQuote
β
inherits and overrides for market
β
parses all expected valid
β
throws on missing config 0 - aaveEnabled is not configured for pair TokenA/FailingConfig0 on network configTest.
β
throws on missing config 1 - minimumBasePerOfferFactor is not configured for pair TokenA/FailingConfig1 on network configTest.
β
throws on missing config 2 - minimumQuotePerOfferFactor is not configured for pair TokenA/FailingConfig2 on network configTest.
β
throws on missing config 3 - stepSize is not configured for pair TokenA/FailingConfig3 on network configTest.
β
throws on missing config 4 - baseQuoteTickOffset is not configured for pair TokenA/FailingConfig4 on network configTest.
KandelConfiguration unit tests suite getConfiguredMarketsForNetwork
β
configTest
β
maticmum
β
unknown
KandelConfiguration unit tests suite getMostSpecificConfig
β
does not fail on missing base
β
does not fail on missing network
β
does not fail on missing properties
β
does not fail on missing quote
β Β test/unit/kandel/kandelDistribution.unit.test.ts
KandelDistribution unit tests suite calculateConstantGivesPerOffer
β
can calculate constant outbound
β
can work without any available
β
throws if 0 available
KandelDistribution unit tests suite getFirstLiveAskIndex
β
is correct when no live asks
β
is correct when some live asks
KandelDistribution unit tests suite getOfferedVolumeForDistribution
β
sums up the base and quote volume of the distribution
β Β test/unit/kandel/kandelDistributionHelper.unit.test.ts
KandelDistributionHelper unit tests suite calculateMinimumInitialGives
β
returns higher than minimum if dual at some price would be below its minimum
β
returns minimum if no prices affect it
β
returns minimum on empty lists
KandelDistributionHelper unit tests suite chunkIndices
β
can chunk
KandelDistributionHelper unit tests suite chunkIndicesAroundMiddle
β
can chunk an even set
β
can chunk an uneven set with middle=2
β
can chunk an uneven set with middle=undefined
β
works with middle=0
β
works with middle=4
KandelDistributionHelper unit tests suite sortByIndex
β
sorts
KandelDistributionHelper unit tests suite uniformlyDecrease
β
can decrease but not total amount if limits prevent
β
can decrease total amount if available, but respect limits
β
can decrease uniformly if all sufficiently above limit
β
can round result
β
does not go beyond limit due to rounding up
KandelDistributionHelper unit tests suite uniformlyIncrease
β
can increase uniformly
β
can round result
β Β test/unit/liquidityProvider.unit.test.ts
Liquidity provider unit tests suite
β
normalizeOfferParams, ask tick = 0 price = 10 different decimals
β
normalizeOfferParams, ask tick = 0 price = 10 different decimals
β
normalizeOfferParams, ask tick = 0 same decimals
β
normalizeOfferParams, ask with tick = -1 different decimals
β
normalizeOfferParams, ask with tick = -1 different decimals
β
normalizeOfferParams, ask with tick = -1 same decimals
β
normalizeOfferParams, ask with tick = -1 same decimals
β
normalizeOfferParams, ask with tick = 1 different decimals
β
normalizeOfferParams, ask with tick = 1 different decimals
β
normalizeOfferParams, ask with tick = 1 same decimals
β
normalizeOfferParams, ask with tick = 1 same decimals
β
normalizeOfferParams, bid tick = 0 different decimals
β
normalizeOfferParams, bid tick = 0 same decimals
β
normalizeOfferParams, with big gives and wants, as asks
β
normalizeOfferParams, with gives and wants, as asks
β
normalizeOfferParams, with gives and wants, as bids
β
normalizeOfferParams, with gives, tick, asks and funding
β
normalizeOfferParams, with gives, tick, bids and no funding
β
normalizeOfferParams, with non-equal decimals gives, tick, bids and no funding
β
normalizeOfferParams, with volume and price 1, as asks
β
normalizeOfferParams, with volume and price 1, as bids
β
normalizeOfferParams, with volume and price 2, as asks
β
normalizeOfferParams, with volume and price 2, as asks
β
normalizeOfferParams, with volume and price 2, as bids
β
normalizeOfferParams, with volume and price 2, as bids
β Β test/unit/market.unit.test.ts
Market unit tests suite getBaseQuoteVolumes
β
returns gives as baseVolume and wants as quoteVolume
β
returns gives as quoteVolume and wants as baseVolume
Market unit tests suite getDisplayDecimalsForPriceDifferences
β
returns 7 decimals when difference is 1e-7
β
returns 7 decimals when difference is 9e-7
β
returns 7 decimals when difference is 9e-7
β
returns no decimals for empty list
β
returns no decimals for list with offers with same price
β
returns no decimals for list with one offer
β
returns no decimals when price differences are integers
β
returns one decimal when difference is -0.1
β
returns one decimal when difference is -0.9999999
β
returns one decimal when difference is 0.1
β
returns one decimal when difference is 0.9999999
β
returns the decimals for the first difference when that is smallest
β
returns the decimals for the last difference when that is smallest
Market unit tests suite getGivesForPrice
β
returns wants divided by price
β
returns wants multiplied by price
Market unit tests suite getGivesWantsForVolumeAtPrice
β
return gives = volume && wants = volume*price for undefined type
β
return gives = volume*price && wants = volume for undefined type
Market unit tests suite getWantsForPrice
β
returns gives multiplied by price
β
returns wants divided by price
β Β test/unit/prettyPrint.unit.test.ts
PrettyPrint Unit test suite consoleOffers
β
should use default filter
β
should use given filter
PrettyPrint Unit test suite prettyPrint
β
prints the offers using the given filter
β Β test/unit/semibook.unit.test.ts
Semibook unit test suite getIsVolumeDesiredForAsks
β
returns false, when desiredVolume is undefined
β
returns false, when what is base and to is sell
β
returns false, when what is quote and to is buy
β
returns true, when what is base and to is buy
β
returns true, when what is quote and to is sell
Semibook unit test suite getIsVolumeDesiredForBids
β
returns false, when desiredVolume is undefined
β
returns false, when what is base and to is buy
β
returns false, when what is quote and to is sell
β
returns true, when what is base and to is sell
β
returns true, when what is quote and to is buy
Semibook unit test suite getOfferFromCacheOrFail
β
returns offer when offer is in cache
β
throws error when offer is not in cache
Semibook unit test suite insertOffer
β
inserting offer exceeds maxOffer size, offer is not worst offer
β
inserting offer exceeds maxOffer size, offer is worst offer
β
inserts offer in empty book
β
inserts offer in non empty book, offer is at a better tick, tick already exist
β
inserts offer in non empty book, offer is at worse tick, tick already exist
β
inserts offer in non empty book, offer is better
β
inserts offer in non empty book, offer is in the middle
β
inserts offer in non empty book, offer is in the middle at an already existing tick
β
inserts offer in non empty book, offer is worse
Semibook unit test suite removeOffer
β
removes last offer in book
β
removes offer from empty book
β
removes offer from non empty book, offer is best offer, does not have others at same tick
β
removes offer from non empty book, offer is best offer, has others at same tick
β
removes offer from non empty book, offer is worst offer, has others at same tick
β
removes offer from non empty book, offer is worst offer, has others at same tick
β Β test/unit/tickLib.unit.test.ts
TickLib unit test suite divExpUp
β
a==0 then rem == 0, should return (a >> e) + rem
β
e<256 and a > 0
β
e>255 then rem == 1, should return (a >> e) + rem
TickLib unit test suite floatLt
β
returns false when exp_a < exp_b
β
returns false when exp_a == exp_b and mantissa_a >= mantissa_b
β
returns true when exp_a == exp_b and mantissa_a < mantissa_b
β
returns true when exp_a > exp_b and mantissa_a < mantissa_b
TickLib unit test suite getTickFromPrice
β
should return the correct tick for price, MAX_TICK
TickLib unit test suite inboundFromOutbound
β
should return the correct value of inbound from outbound based on tick
TickLib unit test suite inboundFromOutboundUp
β
should return the correct rounded up value of inbound from outbound based on tick
TickLib unit test suite inRange
β
should return false if tick is outside the range
β
should return true if tick is within the range
TickLib unit test suite nonNormalizedPriceFromTick
β
Test with maximum tick
β
Test with minimum tick
β
Test with negative tick
β
Test with positive tick
β
Test with tick exceeding MAX_TICK
TickLib unit test suite normalizePrice
β
should handle negative shift correctly
β
should handle positive shift correctly
β
should throw an error if exp is less than 0 after normalization
β
should throw an error if mantissa is zero
TickLib unit test suite outboundFromInbound
β
should return the correct value of outbound from inbound based on tick
TickLib unit test suite outboundFromInboundUp
β
should return the correct rounded up value of outbound from inbound based on tick
TickLib unit test suite priceFromTick
β
should return the correct price for tick, 0
β
should return the correct price for tick, 1
β
should return the correct price for tick, MAX_TICK
β
should return the correct price for tick, MIN_TICK
TickLib unit test suite priceFromVolumes
β
should return the correct mantissa and exp for non-zero inboundAmt and outboundAmt
β
should return the correct mantissa and exp when inboundAmt is 0
β
should return the correct mantissa and exp when outboundAmt is 0
TickLib unit test suite priceToMantissaAndExponent
β
should return the correct mantissa and exponent for price, MAX_TICK
β
should return the correct mantissa and exponent for price, MIN_TICK
β
should return the correct mantissa and exponent for price, tick = -1
β
should return the correct mantissa and exponent for price, tick = -1000
β
should return the correct mantissa and exponent for price, tick = 0
β
should return the correct mantissa and exponent for price, tick = 1
β
should return the correct mantissa and exponent for price, tick = 1000
TickLib unit test suite ratioFromTick
β
test_ratioFromTick
TickLib unit test suite tickFromNormalizedPrice
β
should return the correct tick for normalizedPrice
β
should revert with mgv/tickFromRatio/tooHigh
β
should revert with mgv/tickFromRatio/tooLow
TickLib unit test suite tickFromRatio
β
should return the correct tick for price
TickLib unit test suite tickFromVolumes
β
should return tick
β Β test/unit/tickPriceHelper.unit.test.ts
TickPriceHelper unit tests suite
β
manual calculation
β
manual calculation inverse decimals
TickPriceHelper unit tests suite inboundFromOutbound
β
inboundFromOutbound ba=asks base=1 quote=2 price=2
β
inboundFromOutbound ba=asks base=1 quote=2 price=2
β
inboundFromOutbound ba=asks base=2 quote=1 price=0.5
β
inboundFromOutbound ba=asks base=2 quote=1 price=0.5
β
inboundFromOutbound ba=asks base=6 quote=3 price=0.5
β
inboundFromOutbound ba=asks base=6 quote=3 price=0.5
β
inboundFromOutbound ba=bids base=1 quote=2 price=2
β
inboundFromOutbound ba=bids base=1 quote=2 price=2
β
inboundFromOutbound ba=bids base=2 quote=1 price=0.5
β
inboundFromOutbound ba=bids base=2 quote=1 price=0.5
β
inboundFromOutbound ba=bids base=6 quote=3 price=0.5
β
inboundFromOutbound ba=bids base=6 quote=3 price=0.5
β
outboundFromInbound ba=asks base=1 quote=2 price=2
β
outboundFromInbound ba=asks base=1 quote=2 price=2
β
outboundFromInbound ba=asks base=2 quote=1 price=0.5
β
outboundFromInbound ba=asks base=2 quote=1 price=0.5
β
outboundFromInbound ba=asks base=6 quote=3 price=0.5
β
outboundFromInbound ba=asks base=6 quote=3 price=0.5
β
outboundFromInbound ba=bids base=1 quote=2 price=2
β
outboundFromInbound ba=bids base=1 quote=2 price=2
β
outboundFromInbound ba=bids base=2 quote=1 price=0.5
β
outboundFromInbound ba=bids base=2 quote=1 price=0.5
β
outboundFromInbound ba=bids base=6 quote=3 price=0.5
β
outboundFromInbound ba=bids base=6 quote=3 price=0.5
TickPriceHelper unit tests suite priceFromTick
β
returns price=1 for tick 0 with base decimals: 6, quote decimals: 6 (asks semibook)
β
returns price=1 for tick 0 with base decimals: 6, quote decimals: 6 (bids semibook)
β
returns price=1.00000396574 for tick 414486 with base decimals: 18, quote decimals: 0 (bids semibook)
β
returns price=1.000096 for tick -414487 with base decimals: 0, quote decimals: 18 (bids semibook)
β
returns price=100 for tick 0 with base decimals: 2, quote decimals: 0 (asks semibook)
β
returns price=100 for tick 0 with base decimals: 2, quote decimals: 0 (bids semibook)
β
returns price=1838.53469156 for tick -75171 with base decimals: 18, quote decimals: 18 (bids semibook)
β
returns price=1838.534691561 for tick 75171 with base decimals: 18, quote decimals: 18 (asks semibook)
β
returns price=1e-12 for tick 0 with base decimals: 6, quote decimals: 18 (asks semibook)
β
returns price=1e-12 for tick 0 with base decimals: 6, quote decimals: 18 (bids semibook)
TickPriceHelper unit tests suite priceFromTick is inverse of tickFromPrice (up to tick-step)
β
returns price=1 for tickFromPrice(..., tickFromPrice(..., 1))) with base decimals: 6, quote decimals: 6 for asks semibook
β
returns price=1 for tickFromPrice(..., tickFromPrice(..., 1))) with base decimals: 6, quote decimals: 6 for bids semibook
β
returns price=1.00000396574 for tickFromPrice(..., tickFromPrice(..., 1.00000396574))) with base decimals: 18, quote decimals: 0 for bids semibook
β
returns price=1.000096 for tickFromPrice(..., tickFromPrice(..., 1.000096))) with base decimals: 0, quote decimals: 18 for bids semibook
β
returns price=100 for tickFromPrice(..., tickFromPrice(..., 100))) with base decimals: 2, quote decimals: 0 for asks semibook
β
returns price=100 for tickFromPrice(..., tickFromPrice(..., 100))) with base decimals: 2, quote decimals: 0 for bids semibook
β
returns price=1838.53469156 for tickFromPrice(..., tickFromPrice(..., 1838.53469156))) with base decimals: 18, quote decimals: 18 for bids semibook
β
returns price=1838.534691561 for tickFromPrice(..., tickFromPrice(..., 1838.534691561))) with base decimals: 18, quote decimals: 18 for asks semibook
β
returns price=1e-12 for tickFromPrice(..., tickFromPrice(..., 1e-12))) with base decimals: 6, quote decimals: 18 for asks semibook
β
returns price=1e-12 for tickFromPrice(..., tickFromPrice(..., 1e-12))) with base decimals: 6, quote decimals: 18 for bids semibook
TickPriceHelper unit tests suite tickFromPrice
β
returns tick=-414487 for price 1.000096 with base decimals: 0, quote decimals: 18 (bids semibook))
β
returns tick=-75171 for price 1838.53469156 with base decimals: 18, quote decimals: 18 (bids semibook))
β
returns tick=0 for price 1 with base decimals: 6, quote decimals: 6 (asks semibook))
β
returns tick=0 for price 1 with base decimals: 6, quote decimals: 6 (bids semibook))
β
returns tick=0 for price 100 with base decimals: 2, quote decimals: 0 (asks semibook))
β
returns tick=0 for price 100 with base decimals: 2, quote decimals: 0 (bids semibook))
β
returns tick=0 for price 1e-12 with base decimals: 6, quote decimals: 18 (asks semibook))
β
returns tick=0 for price 1e-12 with base decimals: 6, quote decimals: 18 (bids semibook))
β
returns tick=414486 for price 1.00000396574 with base decimals: 18, quote decimals: 0 (bids semibook))
β
returns tick=75171 for price 1838.534691561 with base decimals: 18, quote decimals: 18 (asks semibook))
TickPriceHelper unit tests suite tickFromPrice is inverse of priceFromTick (up to tick-step)
β
returns tick=-414487 for priceFromTick(..., priceFromTick(..., -414487))) with base decimals: 0, quote decimals: 18 for bids semibook
β
returns tick=-75171 for priceFromTick(..., priceFromTick(..., -75171))) with base decimals: 18, quote decimals: 18 for bids semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 2, quote decimals: 0 for asks semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 2, quote decimals: 0 for bids semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 6, quote decimals: 18 for asks semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 6, quote decimals: 18 for bids semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 6, quote decimals: 6 for asks semibook
β
returns tick=0 for priceFromTick(..., priceFromTick(..., 0))) with base decimals: 6, quote decimals: 6 for bids semibook
β
returns tick=414486 for priceFromTick(..., priceFromTick(..., 414486))) with base decimals: 18, quote decimals: 0 for bids semibook
β
returns tick=75171 for priceFromTick(..., priceFromTick(..., 75171))) with base decimals: 18, quote decimals: 18 for asks semibook
TickPriceHelper unit tests suite tickFromVolumes
β
returns tick=0 for inboundVolume=1, outboundVolume=1 with base decimals: 6, quote decimals: 6 (asks semibook)
β
returns tick=0 for inboundVolume=1, outboundVolume=1 with base decimals: 6, quote decimals: 6 (bids semibook)
β Β test/unit/trade.unit.test.ts
Trade unit tests suite comparePrices
β
returns false, when price = referencePrice and compare is βgtβ
β
returns false, when price = referencePrice and compare is βltβ
β
returns false, when price > referencePrice and compare is βgtβ
β
returns false, when price > referencePrice and compare is βltβ
β
returns true, when price < referencePrice and compare is βgtβ
β
returns true, when price < referencePrice and compare is βltβ
Trade unit tests suite getParamsForBuy
β
returns fillVolume as fillVolume, tick as tick and fillWants as fillWants, when params has tick, fillVolume and fillWants
β
returns fillVolume as fillVolume, tick as tick and fillWants as true, when params has fillVolume and tick, but no fillWants
β
returns fillVolume as gives, tick as TickLib.fromVolume(gives,wants) and fillWants as fillWants, when params has gives, wants and fillWants
β
returns fillVolume as total, tick as tick(price) and fillWants false, when params has price!=null and total
β
returns fillVolume as volume, tick as -1*tick(price) and fillWants true, when params has price!=null and volume
Trade unit tests suite getParamsForSell
β
returns fillVolume as fillVolume, tick as tick and fillWants false, when params has wants and gives, but no fillWants
β
returns fillVolume as gives, tick as TickLib.fromVolume(gives,wants) and fillWants as fillWants, when params has gives, wants and fillWants
β
returns fillVolume as total, tick as tick(price) and fillWants true, when params has price!=null and total
β
returns fillVolume as volume, tick as tick(price) and fillWants false, when params has price!=null and volume
β
returns wants as wants, gives as gives and fillWants as fillWants, when params has wants, gives and fillWants
Trade unit tests suite isPriceBetter
β
Uses βgtβ when ba = bids
β
Uses βltβ when ba = asks
Trade unit tests suite isPriceWorse
β
Uses βgtβ when ba = bids
β
Uses βltβ when ba = asks
Trade unit tests suite validateSlippage
β
return given slippage, when it is valid
β
returns 0, when slippage is undefined
β
throw error, when slippage is above 100
β
throw error, when slippage is lower than 0
β Β test/unit/tradeEventManagement.unit.test.ts
TradeEventManagement unit tests suite createPosthookFailure
β
returns posthookFailure object, always
TradeEventManagement unit tests suite createSuccess
β
returns Success object, always
TradeEventManagement unit tests suite createSummary
β
return summary with partialFill as true, when partialFill func returns true
TradeEventManagement unit tests suite createSummaryForOrderComplete
β
returns createSummary, always
TradeEventManagement unit tests suite createSummaryForOrderSummary
β
returns createSummary with offerId, always
TradeEventManagement unit tests suite createTradeFailure
β
returns TradeFailure object, always
TradeEventManagement unit tests suite rawOfferToOffer
β
returns offer with correct values for asks
β
returns offer with correct values for bids
β Β test/unit/unitCalculations.unit.test.ts
UnitCalculations unit tests suite fromUnits
β
returns Big number, amount is BigNumber and nameOrDecimal is number
β
returns Big number, amount is number and nameOrDecimal is number
β
returns Big number, amount is number and nameOrDecimal is string
β
returns Big number, amount is string and nameOrDecimal is number
Loading