From 64be0d1bdb4cebb7b27b7b8bb38cd1aa6622ee0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:38:01 +0000 Subject: [PATCH 1/8] Bump @types/chai from 4.3.10 to 4.3.11 Bumps [@types/chai](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/chai) from 4.3.10 to 4.3.11. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/chai) --- updated-dependencies: - dependency-name: "@types/chai" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9a556ac..b43670d 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.5", "@typechain/ethers-v5": "^11.1.1", - "@types/chai": "^4.3.10", + "@types/chai": "^4.3.11", "@types/mocha": "^10.0.0", "@types/node": "^18.18.8", "@types/sinon": "^10.0.15", diff --git a/yarn.lock b/yarn.lock index f17171c..90cd8ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -670,10 +670,10 @@ lodash "^4.17.15" ts-essentials "^7.0.1" -"@types/chai@^4.3.10": - version "4.3.10" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.10.tgz#2ad2959d1767edee5b0e4efb1a0cd2b500747317" - integrity sha512-of+ICnbqjmFCiixUnqRulbylyXQrPqIGf/B3Jax1wIF3DvSheysQxAWvqHhZiW3IQrycvokcLcFQlveGp+vyNg== +"@types/chai@^4.3.11": + version "4.3.11" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.11.tgz#e95050bf79a932cb7305dd130254ccdf9bde671c" + integrity sha512-qQR1dr2rGIHYlJulmr8Ioq3De0Le9E4MJ5AiaeAETJJpndT1uUNHsGFK3L/UIu+rbkQSdj8J/w2bCsBZc/Y5fQ== "@types/estree@*", "@types/estree@^1.0.0": version "1.0.0" From fb2ae82e73c4852f4e93ef5dab532d074692b4d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:39:02 +0000 Subject: [PATCH 2/8] Bump typechain from 8.3.1 to 8.3.2 Bumps [typechain](https://github.com/ethereum-ts/Typechain) from 8.3.1 to 8.3.2. - [Release notes](https://github.com/ethereum-ts/Typechain/releases) - [Commits](https://github.com/ethereum-ts/Typechain/compare/typechain@8.3.1...typechain@8.3.2) --- updated-dependencies: - dependency-name: typechain dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9a556ac..23ed62f 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "sinon": "^16.0.0", "ts-node": "^10.9.1", "tslib": "^2.6.2", - "typechain": "^8.3.1", + "typechain": "^8.3.2", "typescript": "^5.2.2" }, "dependencies": { diff --git a/yarn.lock b/yarn.lock index f17171c..740f17f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2360,10 +2360,10 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== -typechain@^8.3.1: - version "8.3.1" - resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.1.tgz#dccbc839b94877997536c356380eff7325395cfb" - integrity sha512-fA7clol2IP/56yq6vkMTR+4URF1nGjV82Wx6Rf09EsqD4tkzMAvEaqYxVFCavJm/1xaRga/oD55K+4FtuXwQOQ== +typechain@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.2.tgz#1090dd8d9c57b6ef2aed3640a516bdbf01b00d73" + integrity sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q== dependencies: "@types/prettier" "^2.1.1" debug "^4.3.1" From 89e6cad8ab23b972131db62d9b325c8a1c7f3c3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 23:38:07 +0000 Subject: [PATCH 3/8] Bump @typescript-eslint/eslint-plugin from 6.12.0 to 6.21.0 Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.12.0 to 6.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.21.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 84 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index fbd5faa..8a8b4d1 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "@types/mocha": "^10.0.0", "@types/node": "^18.18.8", "@types/sinon": "^10.0.15", - "@typescript-eslint/eslint-plugin": "^6.12.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.12.0", "chai": "^4.3.10", "eslint": "^8.46.0", diff --git a/yarn.lock b/yarn.lock index f17171c..5f77986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -731,16 +731,16 @@ resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz#bf2e02a3dbd4aecaf95942ecd99b7402e03fad5e" integrity sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA== -"@typescript-eslint/eslint-plugin@^6.12.0": - version "6.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.12.0.tgz#2a647d278bb48bf397fef07ba0507612ff9dd812" - integrity sha512-XOpZ3IyJUIV1b15M7HVOpgQxPPF7lGXgsfcEIu3yDxFPaf/xZKt7s9QO/pbk7vpWQyVulpJbu4E5LwpZiQo4kA== +"@typescript-eslint/eslint-plugin@^6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz#30830c1ca81fd5f3c2714e524c4303e0194f9cd3" + integrity sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA== dependencies: "@eslint-community/regexpp" "^4.5.1" - "@typescript-eslint/scope-manager" "6.12.0" - "@typescript-eslint/type-utils" "6.12.0" - "@typescript-eslint/utils" "6.12.0" - "@typescript-eslint/visitor-keys" "6.12.0" + "@typescript-eslint/scope-manager" "6.21.0" + "@typescript-eslint/type-utils" "6.21.0" + "@typescript-eslint/utils" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" debug "^4.3.4" graphemer "^1.4.0" ignore "^5.2.4" @@ -767,13 +767,21 @@ "@typescript-eslint/types" "6.12.0" "@typescript-eslint/visitor-keys" "6.12.0" -"@typescript-eslint/type-utils@6.12.0": - version "6.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.12.0.tgz#968f7c95162808d69950ab5dff710ad730e58287" - integrity sha512-WWmRXxhm1X8Wlquj+MhsAG4dU/Blvf1xDgGaYCzfvStP2NwPQh6KBvCDbiOEvaE0filhranjIlK/2fSTVwtBng== +"@typescript-eslint/scope-manager@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz#ea8a9bfc8f1504a6ac5d59a6df308d3a0630a2b1" + integrity sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg== dependencies: - "@typescript-eslint/typescript-estree" "6.12.0" - "@typescript-eslint/utils" "6.12.0" + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + +"@typescript-eslint/type-utils@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz#6473281cfed4dacabe8004e8521cee0bd9d4c01e" + integrity sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag== + dependencies: + "@typescript-eslint/typescript-estree" "6.21.0" + "@typescript-eslint/utils" "6.21.0" debug "^4.3.4" ts-api-utils "^1.0.1" @@ -782,6 +790,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.12.0.tgz#ffc5297bcfe77003c8b7b545b51c2505748314ac" integrity sha512-MA16p/+WxM5JG/F3RTpRIcuOghWO30//VEOvzubM8zuOOBYXsP+IfjoCXXiIfy2Ta8FRh9+IO9QLlaFQUU+10Q== +"@typescript-eslint/types@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.21.0.tgz#205724c5123a8fef7ecd195075fa6e85bac3436d" + integrity sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg== + "@typescript-eslint/typescript-estree@6.12.0": version "6.12.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.12.0.tgz#764ccc32598549e5b48ec99e3b85f89b1385310c" @@ -795,17 +808,31 @@ semver "^7.5.4" ts-api-utils "^1.0.1" -"@typescript-eslint/utils@6.12.0": - version "6.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.12.0.tgz#c6ce8c06fe9b0212620e5674a2036f6f8f611754" - integrity sha512-LywPm8h3tGEbgfyjYnu3dauZ0U7R60m+miXgKcZS8c7QALO9uWJdvNoP+duKTk2XMWc7/Q3d/QiCuLN9X6SWyQ== +"@typescript-eslint/typescript-estree@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz#c47ae7901db3b8bddc3ecd73daff2d0895688c46" + integrity sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ== + dependencies: + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + minimatch "9.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/utils@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134" + integrity sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ== dependencies: "@eslint-community/eslint-utils" "^4.4.0" "@types/json-schema" "^7.0.12" "@types/semver" "^7.5.0" - "@typescript-eslint/scope-manager" "6.12.0" - "@typescript-eslint/types" "6.12.0" - "@typescript-eslint/typescript-estree" "6.12.0" + "@typescript-eslint/scope-manager" "6.21.0" + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/typescript-estree" "6.21.0" semver "^7.5.4" "@typescript-eslint/visitor-keys@6.12.0": @@ -816,6 +843,14 @@ "@typescript-eslint/types" "6.12.0" eslint-visitor-keys "^3.4.1" +"@typescript-eslint/visitor-keys@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz#87a99d077aa507e20e238b11d56cc26ade45fe47" + integrity sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A== + dependencies: + "@typescript-eslint/types" "6.21.0" + eslint-visitor-keys "^3.4.1" + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -1871,6 +1906,13 @@ minimatch@5.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@9.0.3: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" From 1ec0593d472151e111bbb64258d6c48894baa68b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 23:26:49 +0000 Subject: [PATCH 4/8] Bump @types/node from 18.18.8 to 18.19.17 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.18.8 to 18.19.17. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fbd5faa..3dacef4 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "@typechain/ethers-v5": "^11.1.1", "@types/chai": "^4.3.10", "@types/mocha": "^10.0.0", - "@types/node": "^18.18.8", + "@types/node": "^18.19.17", "@types/sinon": "^10.0.15", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", diff --git a/yarn.lock b/yarn.lock index f17171c..3c1558c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -697,10 +697,10 @@ dependencies: undici-types "~5.26.4" -"@types/node@^18.18.8": - version "18.18.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.8.tgz#2b285361f2357c8c8578ec86b5d097c7f464cfd6" - integrity sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ== +"@types/node@^18.19.17": + version "18.19.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.17.tgz#a581a9fb4b2cfdbc61f008804f4436b2d5c40354" + integrity sha512-SzyGKgwPzuWp2SHhlpXKzCX0pIOfcI4V2eF37nNBJOhwlegQ83omtVQ1XxZpDE06V/d6AQvfQdPfnw0tRC//Ng== dependencies: undici-types "~5.26.4" From f42164fff612ce9cf12decf9b956f9f3eb513b17 Mon Sep 17 00:00:00 2001 From: Doron Zavelevsky Date: Mon, 8 Jul 2024 02:31:04 +0100 Subject: [PATCH 5/8] encodeOrder better error handling and helper methods --- src/utils/encoders.ts | 41 +++++++++++++++++++------- tests/encoders.spec.ts | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 10 deletions(-) diff --git a/src/utils/encoders.ts b/src/utils/encoders.ts index 71caab0..a8b9f2a 100644 --- a/src/utils/encoders.ts +++ b/src/utils/encoders.ts @@ -64,6 +64,29 @@ export const encodeOrders = ([order0, order1]: [DecodedOrder, DecodedOrder]): [ return [encodeOrder(order0), encodeOrder(order1)]; }; +export const isOrderEncodable = (order: DecodedOrder) => { + try { + encodeOrder(order); + return true; + } catch (e) { + return false; + } +}; + +/** + * Checks if the rates are equal after scaling them + * @param {string} x - the first rate + * @param {string} y - the second rate + * @returns {boolean} - true if the rates are equal after scaling, false otherwise + */ +export const scaleRatesAndCheckIsEqual = (x: string, y: string) => { + const xDec = new Decimal(x); + const yDec = new Decimal(y); + const xScaled = DecToBn(encodeRate(xDec)); + const yScaled = DecToBn(encodeRate(yDec)); + return xScaled.eq(yScaled); +}; + export const encodeOrder = ( order: DecodedOrder, z?: BigNumber @@ -73,13 +96,16 @@ export const encodeOrder = ( const highestRate = new Decimal(order.highestRate); const marginalRate = new Decimal(order.marginalRate); + const y = DecToBn(liquidity); + const L = DecToBn(encodeRate(lowestRate)); + const H = DecToBn(encodeRate(highestRate)); + const M = DecToBn(encodeRate(marginalRate)); + if ( !( - (highestRate.gte(marginalRate) && marginalRate.gt(lowestRate)) || - (highestRate.eq(marginalRate) && marginalRate.eq(lowestRate)) || - (highestRate.gt(marginalRate) && - marginalRate.eq(lowestRate) && - liquidity.isZero()) + (H.gte(M) && M.gt(L)) || + (H.eq(M) && M.eq(L)) || + (H.gt(M) && M.eq(L) && y.isZero()) ) ) throw new Error( @@ -90,11 +116,6 @@ export const encodeOrder = ( `(highestRate = ${highestRate}, marginalRate = ${marginalRate}, lowestRate = ${lowestRate}), liquidity = ${liquidity}` ); - const y = DecToBn(liquidity); - const L = DecToBn(encodeRate(lowestRate)); - const H = DecToBn(encodeRate(highestRate)); - const M = DecToBn(encodeRate(marginalRate)); - return { y, z: diff --git a/tests/encoders.spec.ts b/tests/encoders.spec.ts index c652e91..40bd532 100644 --- a/tests/encoders.spec.ts +++ b/tests/encoders.spec.ts @@ -1,6 +1,8 @@ import { expect } from 'chai'; import { encodeOrder, + isOrderEncodable, + scaleRatesAndCheckIsEqual, decodeOrder, calculateRequiredLiquidity, calculateCorrelatedZ, @@ -99,6 +101,27 @@ describe('encoders', () => { ); }); + it('should throw an exception when high price is higher than mid which is too close to min - so scaled rates are equal', () => { + const order = { + liquidity: '30424317585815', + lowestRate: + '9.999999999999947841981611412981873775987881042119111152377541884561651386320590972900390625', + highestRate: + '99.90009990009982561394106455162611276581802969426471250358190445695072412490844726562500000000000002', + marginalRate: + '9.999999999999973770354085873786350785392842669271401327708947225166629806745858567718077125618947319', + }; + expect(() => { + encodeOrder(order); + }).to.throw( + 'Either one of the following must hold:\n' + + '- highestRate >= marginalRate > lowestRate\n' + + '- highestRate == marginalRate == lowestRate\n' + + '- (highestRate > marginalRate == lowestRate) AND liquidity == 0\n' + + `(highestRate = ${order.highestRate}, marginalRate = ${order.marginalRate}, lowestRate = ${order.lowestRate}), liquidity = ${order.liquidity}` + ); + }); + it('should return the original order after computing and uncomputing, with tolerance', () => { const originalOrder = { liquidity: '100000000000000000000', @@ -144,6 +167,50 @@ describe('encoders', () => { }); }); + describe('isOrderEncodable', () => { + it('should return false when high price is higher than mid which is too close to min - so scaled rates are equal', () => { + const order = { + liquidity: '30424317585815', + lowestRate: + '9.999999999999947841981611412981873775987881042119111152377541884561651386320590972900390625', + highestRate: + '99.90009990009982561394106455162611276581802969426471250358190445695072412490844726562500000000000002', + marginalRate: + '9.999999999999973770354085873786350785392842669271401327708947225166629806745858567718077125618947319', + }; + expect(isOrderEncodable(order)).to.be.false; + }); + it('should return true when the order is encodable', () => { + const order = { + liquidity: '100', + lowestRate: '0.5', + highestRate: '0.5', + marginalRate: '0.5', + }; + expect(isOrderEncodable(order)).to.be.true; + }); + }); + + describe('scaleRatesAndCheckIsEqual', () => { + it('should return true when the rates are equal', () => { + const x = '0.5'; + const y = '0.5'; + expect(scaleRatesAndCheckIsEqual(x, y)).to.be.true; + }); + it('should return false when the rates are not equal', () => { + const x = '0.5'; + const y = '0.6'; + expect(scaleRatesAndCheckIsEqual(x, y)).to.be.false; + }); + it('should return true when the rates are only equal afr scaling', () => { + const x = + '9.999999999999947841981611412981873775987881042119111152377541884561651386320590972900390625'; + const y = + '9.999999999999973770354085873786350785392842669271401327708947225166629806745858567718077125618947319'; + expect(scaleRatesAndCheckIsEqual(x, y)).to.be.true; + }); + }); + describe('encodeStrategy', () => { it('should return the expected value', () => { const strategy = { From 84dc0507e46f8be13c956dde6c02b252b7d6ff9d Mon Sep 17 00:00:00 2001 From: Doron Zavelevsky Date: Mon, 8 Jul 2024 17:24:33 +0100 Subject: [PATCH 6/8] method name --- src/utils/encoders.ts | 2 +- tests/encoders.spec.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/encoders.ts b/src/utils/encoders.ts index a8b9f2a..135a1cf 100644 --- a/src/utils/encoders.ts +++ b/src/utils/encoders.ts @@ -79,7 +79,7 @@ export const isOrderEncodable = (order: DecodedOrder) => { * @param {string} y - the second rate * @returns {boolean} - true if the rates are equal after scaling, false otherwise */ -export const scaleRatesAndCheckIsEqual = (x: string, y: string) => { +export const areScaledRatesEqual = (x: string, y: string): boolean => { const xDec = new Decimal(x); const yDec = new Decimal(y); const xScaled = DecToBn(encodeRate(xDec)); diff --git a/tests/encoders.spec.ts b/tests/encoders.spec.ts index 40bd532..59f6c6e 100644 --- a/tests/encoders.spec.ts +++ b/tests/encoders.spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { encodeOrder, isOrderEncodable, - scaleRatesAndCheckIsEqual, + areScaledRatesEqual, decodeOrder, calculateRequiredLiquidity, calculateCorrelatedZ, @@ -191,23 +191,23 @@ describe('encoders', () => { }); }); - describe('scaleRatesAndCheckIsEqual', () => { + describe('areScaledRatesEqual', () => { it('should return true when the rates are equal', () => { const x = '0.5'; const y = '0.5'; - expect(scaleRatesAndCheckIsEqual(x, y)).to.be.true; + expect(areScaledRatesEqual(x, y)).to.be.true; }); it('should return false when the rates are not equal', () => { const x = '0.5'; const y = '0.6'; - expect(scaleRatesAndCheckIsEqual(x, y)).to.be.false; + expect(areScaledRatesEqual(x, y)).to.be.false; }); it('should return true when the rates are only equal afr scaling', () => { const x = '9.999999999999947841981611412981873775987881042119111152377541884561651386320590972900390625'; const y = '9.999999999999973770354085873786350785392842669271401327708947225166629806745858567718077125618947319'; - expect(scaleRatesAndCheckIsEqual(x, y)).to.be.true; + expect(areScaledRatesEqual(x, y)).to.be.true; }); }); From 9f1dc04a44295df75b6ba33e6769b50d480c5759 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:40:03 +0000 Subject: [PATCH 7/8] Bump braces from 3.0.2 to 3.0.3 Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3c1558c..69e1c9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -959,11 +959,11 @@ brace-expansion@^2.0.1: balanced-match "^1.0.0" braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: - fill-range "^7.0.1" + fill-range "^7.1.1" brorand@^1.1.0: version "1.1.0" @@ -1405,10 +1405,10 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: to-regex-range "^5.0.1" From 39bf5b835476642f1241498cbc6eb6c7f6e3db46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:26:48 +0000 Subject: [PATCH 8/8] Bump typescript from 5.2.2 to 5.5.4 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.2.2 to 5.5.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.2.2...v5.5.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9c94c04..541012c 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "ts-node": "^10.9.1", "tslib": "^2.6.2", "typechain": "^8.3.2", - "typescript": "^5.2.2" + "typescript": "^5.5.4" }, "dependencies": { "@ethersproject/abi": "^5.7.0", diff --git a/yarn.lock b/yarn.lock index f9517a0..88c8146 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2418,10 +2418,10 @@ typechain@^8.3.2: ts-command-line-args "^2.2.0" ts-essentials "^7.0.1" -typescript@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" - integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== typical@^4.0.0: version "4.0.0"