diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e33ba57..c2952425 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,3 +101,8 @@ jobs: run: | npm ci npm run build + - name: "Build React production application" + working-directory: src/ui + run: | + npm ci + npm run build diff --git a/README.md b/README.md index cf9af9c5..38121a38 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ This project is the implementation of Compound Protocol on Tezos chain using SmartPy language. +Node.js 22 is required for the JavaScript and TypeScript packages. Run `nvm use` from the repository root before installing dependencies. + The diagram demonstrates relations between contracts ![](https://github.com/RSerhii/TezFin/blob/master/docs/ContractsRelations.png) @@ -376,9 +378,10 @@ npm install ```sh cd src/ui npm install +npm run build ``` -2. Run +3. Run ```sh cd src/ui diff --git a/postdeploy/package-lock.json b/postdeploy/package-lock.json index 6d55283c..bbc06e37 100644 --- a/postdeploy/package-lock.json +++ b/postdeploy/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "bignumber.js": "^9.0.1", + "bignumber.js": "^10.0.2", "conseiljs": "5.3.0", "conseiljs-softsigner": "^5.0.4", "csv": "^6.1.0", @@ -22,7 +22,10 @@ }, "devDependencies": { "@types/node-fetch": "^2.5.7", - "typescript": "^4.1.2" + "typescript": "^4.9.5" + }, + "engines": { + "node": "22.x" } }, "../src/util": { @@ -30,24 +33,28 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { + "@taquito/michel-codec": "25.0.0", + "@taquito/taquito": "25.0.0", + "@taquito/utils": "25.0.0", "big-integer": "^1.6.51", - "bignumber.js": "9.0.1", - "chai": "^4.3.6", - "conseiljs": "5.3.0", + "bignumber.js": "^10.0.2", "decimal.js": "^10.3.1", - "jsonpath-plus": "^6.0.1", - "mathjs": "^10.5.3" + "loglevel": "^1.7.1" }, "devDependencies": { + "@types/chai": "^5.0.1", + "@types/mocha": "^10.0.10", "@types/node": "^16.10.3", - "@types/node-fetch": "^3.0.3", + "chai": "^4.3.6", "eslint": "^8.2.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.25.2", - "loglevel": "^1.7.1", - "node-fetch": "2.6.1", + "mocha": "^11.0.1", "ts-mocha": "^10.0.0", - "typescript": "^4.4.3" + "typescript": "^4.9.5" + }, + "engines": { + "node": "22.x" } }, "node_modules/@types/node": { @@ -88,12 +95,10 @@ } }, "node_modules/bignumber.js": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", - "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", - "engines": { - "node": "*" - } + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", + "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", + "license": "MIT" }, "node_modules/bip39": { "version": "3.0.3", @@ -199,6 +204,15 @@ "npm": ">=6.14.10" } }, + "node_modules/conseiljs/node_modules/bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", @@ -628,10 +642,11 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -682,9 +697,9 @@ "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==" }, "bignumber.js": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", - "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==" + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", + "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" }, "bip39": { "version": "3.0.3", @@ -765,6 +780,13 @@ "jsonpath-plus": "6.0.1", "moo": "0.5.0", "nearley": "2.19.1" + }, + "dependencies": { + "bignumber.js": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz", + "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==" + } } }, "conseiljs-softsigner": { @@ -1121,22 +1143,23 @@ "tezoslendingplatformjs": { "version": "file:../src/util", "requires": { + "@taquito/michel-codec": "25.0.0", + "@taquito/taquito": "25.0.0", + "@taquito/utils": "25.0.0", + "@types/chai": "^5.0.1", + "@types/mocha": "^10.0.10", "@types/node": "^16.10.3", - "@types/node-fetch": "^3.0.3", "big-integer": "^1.6.51", - "bignumber.js": "9.0.1", + "bignumber.js": "^10.0.2", "chai": "^4.3.6", - "conseiljs": "5.3.0", "decimal.js": "^10.3.1", "eslint": "^8.2.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.25.2", - "jsonpath-plus": "^6.0.1", "loglevel": "^1.7.1", - "mathjs": "^10.5.3", - "node-fetch": "2.6.1", + "mocha": "^11.0.1", "ts-mocha": "^10.0.0", - "typescript": "^4.4.3" + "typescript": "^4.9.5" } }, "tweetnacl": { @@ -1145,9 +1168,9 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true }, "util-deprecate": { diff --git a/postdeploy/package.json b/postdeploy/package.json index 4e8412a9..4f81ac03 100644 --- a/postdeploy/package.json +++ b/postdeploy/package.json @@ -3,6 +3,9 @@ "version": "0.0.1-alpha", "description": "Utility for testing the tezfin wrapper code and contracts", "private": true, + "engines": { + "node": "22.x" + }, "scripts": { "postinstall": "npm run build", "build": "rm -rf ./build/ && tsc", @@ -12,7 +15,7 @@ "author": "Stable Technologies", "license": "MIT", "dependencies": { - "bignumber.js": "^9.0.1", + "bignumber.js": "^10.0.2", "conseiljs": "5.3.0", "conseiljs-softsigner": "^5.0.4", "csv": "^6.1.0", @@ -24,6 +27,6 @@ }, "devDependencies": { "@types/node-fetch": "^2.5.7", - "typescript": "^4.1.2" + "typescript": "^4.9.5" } } diff --git a/src/ui/config-overrides.js b/src/ui/config-overrides.js index 12dd943e..90e6f7b5 100644 --- a/src/ui/config-overrides.js +++ b/src/ui/config-overrides.js @@ -3,6 +3,16 @@ const webpack = require('webpack'); module.exports = function override(config) { + const oneOfRule = config.module && config.module.rules + ? config.module.rules.find((rule) => Array.isArray(rule.oneOf)) + : undefined; + if (oneOfRule) { + oneOfRule.oneOf.unshift({ + test: /\.cjs$/, + type: 'javascript/auto' + }); + } + const fallback = config.resolve.fallback || {}; Object.assign(fallback, { crypto: require.resolve('crypto-browserify'), diff --git a/src/ui/package-lock.json b/src/ui/package-lock.json index e14b3366..95b39ed4 100644 --- a/src/ui/package-lock.json +++ b/src/ui/package-lock.json @@ -16,8 +16,8 @@ "@mui/material": "^5.0.1", "@mui/styles": "^5.0.1", "@mui/system": "^5.8.2", - "@taquito/beacon-wallet": "^24.3.0", - "@taquito/taquito": "^24.3.0", + "@taquito/beacon-wallet": "25.0.0", + "@taquito/taquito": "25.0.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", @@ -25,7 +25,7 @@ "@types/react-dom": "^17.0.11", "async-mutex": "^0.3.2", "big-integer": "1.6.51", - "bignumber.js": "^9.0.1", + "bignumber.js": "^10.0.2", "clsx": "^1.1.1", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -55,9 +55,12 @@ "react-app-rewired": "^2.1.11", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", - "typescript": "^4.5.2", + "typescript": "^4.9.5", "url": "^0.11.4", "vm-browserify": "^1.1.2" + }, + "engines": { + "node": "22.x" } }, "../util": { @@ -65,11 +68,11 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { - "@taquito/michel-codec": "^24.3.0", - "@taquito/taquito": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/michel-codec": "25.0.0", + "@taquito/taquito": "25.0.0", + "@taquito/utils": "25.0.0", "big-integer": "^1.6.51", - "bignumber.js": "9.0.1", + "bignumber.js": "^10.0.2", "decimal.js": "^10.3.1", "loglevel": "^1.7.1" }, @@ -83,7 +86,10 @@ "eslint-plugin-import": "^2.25.2", "mocha": "^11.0.1", "ts-mocha": "^10.0.0", - "typescript": "^4.4.3" + "typescript": "^4.9.5" + }, + "engines": { + "node": "22.x" } }, "node_modules/@adobe/css-tools": { @@ -2617,24 +2623,24 @@ } }, "node_modules/@ecadlabs/beacon-ui/node_modules/react": { - "version": "19.2.6", - "resolved": "https://registry.npmjs.org/react/-/react-19.2.6.tgz", - "integrity": "sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==", + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", + "integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==", "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/@ecadlabs/beacon-ui/node_modules/react-dom": { - "version": "19.2.6", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.6.tgz", - "integrity": "sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g==", + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz", + "integrity": "sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==", "license": "MIT", "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { - "react": "^19.2.6" + "react": "^19.2.7" } }, "node_modules/@ecadlabs/beacon-ui/node_modules/scheduler": { @@ -5356,16 +5362,16 @@ } }, "node_modules/@taquito/beacon-wallet": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/beacon-wallet/-/beacon-wallet-24.3.0.tgz", - "integrity": "sha512-nEbrPCvJ/XPNS1t6wT5Ndv5yYJ65eWL0STw2Ko8Wo5hNzXuTIIsjod5pf9u4u9Nxy5/gwY0P+PT/+YoiUf3jAA==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/beacon-wallet/-/beacon-wallet-25.0.0.tgz", + "integrity": "sha512-p+4WFmZ0/6iCdvniKvXB/w2fHxalhDzPncPSLBuogj49/U5LGfA56B+MKaIAgx9vhCGSBNQ9xrjSB1fbUZNXNg==", "license": "Apache-2.0", "dependencies": { - "@ecadlabs/beacon-dapp": "4.8.1-ecad.7", - "@ecadlabs/beacon-types": "4.8.1-ecad.7", - "@taquito/core": "^24.3.0", - "@taquito/taquito": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@ecadlabs/beacon-dapp": "4.8.4-ecad", + "@ecadlabs/beacon-types": "4.8.4-ecad", + "@taquito/core": "^25.0.0", + "@taquito/taquito": "^25.0.0", + "@taquito/utils": "^25.0.0", "typedarray-to-buffer": "^4.0.0", "util": "^0.12.5" }, @@ -5374,9 +5380,9 @@ } }, "node_modules/@taquito/core": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/core/-/core-24.3.0.tgz", - "integrity": "sha512-NReAUkdJVY8Dsdw0fykJTaYsdEPL5VHh6Ydc9LD96SHW7WowkKxOuYsmcocxSWOjiVmHrsjWR4slAy9QD/gK6w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/core/-/core-25.0.0.tgz", + "integrity": "sha512-TlU+eMEn47mAmIjTFP2U4ReHRU05FsnyVn/c5DQnJC0psZ6LRJXimAIA1KQ94afsCDByewsXLN5fjKwn47l72A==", "license": "Apache-2.0", "dependencies": { "json-stringify-safe": "^5.0.1" @@ -5386,25 +5392,25 @@ } }, "node_modules/@taquito/http-utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-24.3.0.tgz", - "integrity": "sha512-B/Z92oMr6SDWvYJLaQddPI/UkJvLZ97s2B1RmPQOls8cTRg1m3iWKj/Yaqrj16qJ2DRklVVw5pDAY366TLlrgw==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-25.0.0.tgz", + "integrity": "sha512-/nkwDeTXEW10lSQdyTrLgp9GIWQc2yi6wQLjEFvXveevrMjuA+lfFU8QoOOZxXH0GM42KEmU/y/VA1wcgl+gKQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" }, "engines": { "node": ">=22" } }, "node_modules/@taquito/local-forging": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-24.3.0.tgz", - "integrity": "sha512-cXkJPLR0YPak8dx32cbiAqCwvLNhzebG9Y5Hgup+dm/hKzWE0bhi28lw23UkhG9DbQeCnFDTTAnO8ZCh2YtP3A==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-25.0.0.tgz", + "integrity": "sha512-sFeObpxya59PP5xFFsPWb3zLxASe3QwQqQ1fJWTPCs/Fph7/cxk5Kj0Oco961SC7CVSkG/ayz4/WINmm+oTlPA==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-text-encoding": "^1.0.6" }, @@ -5412,34 +5418,28 @@ "node": ">=22" } }, - "node_modules/@taquito/local-forging/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/michel-codec": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-24.3.0.tgz", - "integrity": "sha512-iq2mfwiUhFk1q+3o0SIwBYpYU1luJglP5nA3QWlctyYPRVQ4U2EoreNIKSA83PQKBDtdFjHhTcYcGsbJa14j7Q==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-25.0.0.tgz", + "integrity": "sha512-ITM3lM3tEAblPVdzQk5Rv2nLMMOalrXbnIt5b5St8OVYwqaDyfsH3fxSGIVDPxRQyyBdgJ1403aVu6768/8m4Q==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" }, "engines": { "node": ">=22" } }, "node_modules/@taquito/michelson-encoder": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-24.3.0.tgz", - "integrity": "sha512-GwB1x1IhTXVvaXwnkFJII4csS35PnS/LGbMSWYw8JcfBgBk5zqv2U5R++pMgvuSnlCSQ6qWshNYAg3fUck+ePQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-25.0.0.tgz", + "integrity": "sha512-BWwAAwBhY3zngcMK8SkmBWDZ5aNVRnHlHvi7Xu6jnGW109yM3n9awxxCrFD8jOXPb3dly+/pulGnkv28+EvIIQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-json-stable-stringify": "^2.1.0" }, @@ -5447,45 +5447,33 @@ "node": ">=22" } }, - "node_modules/@taquito/michelson-encoder/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/rpc": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-24.3.0.tgz", - "integrity": "sha512-j0qAcsnXXXYn+599aCDgNDttB6sIljyfNEpx5uW+qAN7ffMhVu+D1J1GEKfwIzRdH2sHGEwhiQjpIqhheMIO+w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-25.0.0.tgz", + "integrity": "sha512-qqV4boldGOavsM6ZzK6xky4xAEyllYDyIO5C16cvkoUzoMCCsWMpRuXa1csSrQc+0IECkkDurNLTbrMJPne9tA==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2" }, "engines": { "node": ">=22" } }, - "node_modules/@taquito/rpc/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/signer": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-24.3.0.tgz", - "integrity": "sha512-v6JRjMlcOjlIQueDWrHB9ytUWEQ6gh2Z8Y+trVOZTjW7buWXkul9hwgsl75ELvOAome5t/6KzNuuHsyImlt2BQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-25.0.0.tgz", + "integrity": "sha512-UDHwWd3O0VwZjbEw0NDsoQoIhoQv+xHxb/XAKW7ruSjUT6OkH5whhHpgTZ+T2eJLPDBZLY1RH8IdSl+6ZFtUXg==", "license": "Apache-2.0", "dependencies": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@scure/bip39": "^2.0.1", + "@noble/hashes": "^2.2.0", + "@scure/bip39": "^2.2.0", "@stablelib/nacl": "^1.0.4", - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.2", "typedarray-to-buffer": "^4.0.0" @@ -5603,19 +5591,19 @@ } }, "node_modules/@taquito/taquito": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-24.3.0.tgz", - "integrity": "sha512-3PHMi0JucJKejInHV4vmyAcVzb+HTUTbo80N3XOkY2v63Goaq2b4fgGgBIeJo+FchUBKHfJdoYQqOKyNs6h5Sg==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-25.0.0.tgz", + "integrity": "sha512-MBNKXK1CrOlwBrI0IkjWbVcuwY238ZF8B6fuf2qA0uYp+UmVjukUJ4QCvRf+bayWzfiWBbkYP0upY6VGV3C1VQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/local-forging": "^24.3.0", - "@taquito/michel-codec": "^24.3.0", - "@taquito/michelson-encoder": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/local-forging": "^25.0.0", + "@taquito/michel-codec": "^25.0.0", + "@taquito/michelson-encoder": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "rxjs": "^7.8.2" }, @@ -5623,21 +5611,15 @@ "node": ">=22" } }, - "node_modules/@taquito/taquito/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-24.3.0.tgz", - "integrity": "sha512-G2z+1fRg2jpK1qsdfRtdRxLNwtSTfXI2x29HP3qKFhKz+uCoPQfrClfqBSHkJoy6SzxSZhU3BOoQ4x983hhkfQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-25.0.0.tgz", + "integrity": "sha512-I/9hndZcx0yL6f1djPMhgxCpAopbh/E1ta5kYGs3AxDGrYKt0QpbWAvvUV7fwU9kgzHRQlm7fX8DP7zUbz7ntg==", "license": "Apache-2.0", "dependencies": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@taquito/core": "^24.3.0", + "@noble/hashes": "^2.2.0", + "@taquito/core": "^25.0.0", "@types/bs58check": "^2.1.2", "bignumber.js": "^10.0.2", "blakejs": "^1.2.1", @@ -5655,12 +5637,6 @@ "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==", "license": "MIT" }, - "node_modules/@taquito/utils/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/utils/node_modules/bs58": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", @@ -5956,9 +5932,9 @@ } }, "node_modules/@types/chrome": { - "version": "0.1.42", - "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.1.42.tgz", - "integrity": "sha512-tdT2roFqGecZZDjA9fUEAINb2STxSPifHMDvY6EfRjNRCjdrs/0FwKt5RCIA9MKMd1arAYZZL3nwEkp6ZLZu2w==", + "version": "0.1.43", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.1.43.tgz", + "integrity": "sha512-ukH/HhmR6ht+UTX3PLUWJxgJ/RQcK2Foj4lBzsF24SIWsXgqhGuXqjd8FFuwioPP7d/JUKLM4g8GZxw3F4HTcA==", "license": "MIT", "dependencies": { "@types/filesystem": "*", @@ -8589,13 +8565,10 @@ } }, "node_modules/bignumber.js": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", - "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", - "license": "MIT", - "engines": { - "node": "*" - } + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", + "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", + "license": "MIT" }, "node_modules/binary-extensions": { "version": "2.3.0", diff --git a/src/ui/package.json b/src/ui/package.json index d12cb11e..b8a20e18 100644 --- a/src/ui/package.json +++ b/src/ui/package.json @@ -2,6 +2,9 @@ "name": "client", "version": "0.2.0", "private": true, + "engines": { + "node": "22.x" + }, "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@emotion/react": "^11.4.1", @@ -11,8 +14,8 @@ "@mui/material": "^5.0.1", "@mui/styles": "^5.0.1", "@mui/system": "^5.8.2", - "@taquito/beacon-wallet": "^24.3.0", - "@taquito/taquito": "^24.3.0", + "@taquito/beacon-wallet": "25.0.0", + "@taquito/taquito": "25.0.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", @@ -20,7 +23,7 @@ "@types/react-dom": "^17.0.11", "async-mutex": "^0.3.2", "big-integer": "1.6.51", - "bignumber.js": "^9.0.1", + "bignumber.js": "^10.0.2", "clsx": "^1.1.1", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -32,16 +35,6 @@ "tezoslendingplatformjs": "../util/", "web-vitals": "^1.1.2" }, - "overrides": { - "@ecadlabs/beacon-core": "4.8.4-ecad", - "@ecadlabs/beacon-dapp": "4.8.4-ecad", - "@ecadlabs/beacon-transport-matrix": "4.8.4-ecad", - "@ecadlabs/beacon-transport-postmessage": "4.8.4-ecad", - "@ecadlabs/beacon-transport-walletconnect": "4.8.4-ecad", - "@ecadlabs/beacon-types": "4.8.4-ecad", - "@ecadlabs/beacon-ui": "4.8.4-ecad", - "@ecadlabs/beacon-utils": "4.8.4-ecad" - }, "devDependencies": { "@types/node": "^16.11.10", "@types/node-fetch": "^3.0.3", @@ -60,7 +53,7 @@ "react-app-rewired": "^2.1.11", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", - "typescript": "^4.5.2", + "typescript": "^4.9.5", "url": "^0.11.4", "vm-browserify": "^1.1.2" }, diff --git a/src/ui/src/App.test.js b/src/ui/src/App.test.js index 76247839..86636b01 100644 --- a/src/ui/src/App.test.js +++ b/src/ui/src/App.test.js @@ -26,7 +26,7 @@ test('disables collateral controls in Guard recovery mode', () => { }); test('enables collateral controls outside Guard recovery mode', () => { - process.env.REACT_APP_ENV = 'tezosx-previewnet'; + process.env.REACT_APP_ENV = 'shadownet'; renderSwitch(); diff --git a/src/ui/src/components/AllMarketModal/index.js b/src/ui/src/components/AllMarketModal/index.js index 96788e2a..40dca6e4 100644 --- a/src/ui/src/components/AllMarketModal/index.js +++ b/src/ui/src/components/AllMarketModal/index.js @@ -1,7 +1,7 @@ // eslint-disable-next-line no-use-before-define import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import { marketAction } from '../../reduxContent/market/actions'; @@ -156,11 +156,12 @@ const AllMarketModal = (props) => { useEffect(() => { if ((currentTab === 'two') && (tokenValue > 0)) { - const tokenValueUsd = new BigNumber(tokenValue).multipliedBy(new BigNumber(tokenDetails.usdPrice)).toNumber(); + const safeTokenValue = (tokenValue === '' || tokenValue == null) ? '0' : tokenValue.toString(); + const tokenValueUsd = new BigNumber(safeTokenValue).multipliedBy(new BigNumber((tokenDetails.usdPrice ?? 0).toString())).toNumber(); const pendingBorrowing = borrowing + tokenValueUsd; const pendingBorrowLimit = totalCollateral - pendingBorrowing; setPendingLimit(pendingBorrowLimit); - setPendingLimitUsed(new BigNumber(pendingBorrowing).dividedBy(new BigNumber(totalCollateral)).multipliedBy(100)); + setPendingLimitUsed(new BigNumber(pendingBorrowing.toString()).dividedBy(new BigNumber((totalCollateral || 0).toString())).multipliedBy(100)); } return () => { setPendingLimit(''); @@ -197,7 +198,7 @@ const AllMarketModal = (props) => { visibility={true} mainModal={true} inputBtnTextOne = "Use Max" - inputBtnTextTwo = {`${new BigNumber(tokenDetails.collateralFactor).multipliedBy(100)}% Limit`} + inputBtnTextTwo = {`${new BigNumber((tokenDetails.collateralFactor ?? 0).toString()).multipliedBy(100)}% Limit`} useMaxAmount= {useMaxAmount} errorText={publicKeyHash && ((currentTab === 'one') ? buttonOne.errorText : buttonTwo.errorText)} disabled={(currentTab === 'one') ? buttonOne.disabled : buttonTwo.disabled} diff --git a/src/ui/src/components/BorrowModal/index.js b/src/ui/src/components/BorrowModal/index.js index 1eb364ac..40858f4d 100644 --- a/src/ui/src/components/BorrowModal/index.js +++ b/src/ui/src/components/BorrowModal/index.js @@ -1,6 +1,6 @@ // eslint-disable-next-line no-use-before-define import React, { useEffect, useState } from 'react'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import { useDispatch, useSelector } from 'react-redux'; @@ -167,7 +167,8 @@ const BorrowModal = (props) => { }, [currentTab, tokenDetails, tokenValue, useMaxAmount]); useEffect(() => { - const tokenValueUsd = new BigNumber(tokenValue).multipliedBy(new BigNumber(tokenDetails.usdPrice)).toNumber(); + const safeTokenValue = (tokenValue === '' || tokenValue == null) ? '0' : tokenValue.toString(); + const tokenValueUsd = new BigNumber(safeTokenValue).multipliedBy(new BigNumber((tokenDetails.usdPrice ?? 0).toString())).toNumber(); let pendingBorrowing = 0; if (tokenValue > 0) { if (currentTab === 'one') { @@ -179,7 +180,7 @@ const BorrowModal = (props) => { const pendingBorrowLimit = totalCollateral - pendingBorrowing; setPendingLimit(pendingBorrowLimit); setPendingLimitUsed( - new BigNumber(pendingBorrowing).dividedBy(new BigNumber(totalCollateral)).multipliedBy(100) + new BigNumber(pendingBorrowing.toString()).dividedBy(new BigNumber((totalCollateral || 0).toString())).multipliedBy(100) ); } @@ -232,7 +233,7 @@ const BorrowModal = (props) => { setAmount={(e) => { setAmount(e); }} - inputBtnTextOne={`${new BigNumber(tokenDetails.collateralFactor).multipliedBy(100)}% Limit`} + inputBtnTextOne={`${new BigNumber((tokenDetails.collateralFactor ?? 0).toString()).multipliedBy(100)}% Limit`} inputBtnTextTwo="Use Max" useMaxAmount={useMaxAmount} errorText={currentTab === 'one' ? buttonOne.errorText : buttonTwo.errorText} diff --git a/src/ui/src/components/Dashboard/BorrowedTokenTable.tsx b/src/ui/src/components/Dashboard/BorrowedTokenTable.tsx index 169c9025..a1b1dc77 100644 --- a/src/ui/src/components/Dashboard/BorrowedTokenTable.tsx +++ b/src/ui/src/components/Dashboard/BorrowedTokenTable.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import Table from '@mui/material/Table'; @@ -60,7 +60,7 @@ const BorrowedTokenTable = (props) => { if (rate <= 0) { return '0'; } - return new BigNumber(rate).gt(new BigNumber(10000000000000000)) + return new BigNumber((rate ?? 0).toString()).gt(new BigNumber(10000000000000000)) ? roundValue(decimalify(rate, 18)) : '<0.01'; }; diff --git a/src/ui/src/components/Dashboard/SuppliedTokenTable.tsx b/src/ui/src/components/Dashboard/SuppliedTokenTable.tsx index 90c37207..1b6e2d8d 100644 --- a/src/ui/src/components/Dashboard/SuppliedTokenTable.tsx +++ b/src/ui/src/components/Dashboard/SuppliedTokenTable.tsx @@ -77,7 +77,7 @@ const SuppliedTokenTable = (props) => { if (rate <= 0) { return '0'; } - return new BigNumber(rate).gt(new BigNumber(10000000000000000)) + return new BigNumber((rate ?? 0).toString()).gt(new BigNumber(10000000000000000)) ? roundValue(decimalify(rate, 18)) : '<0.01'; }; diff --git a/src/ui/src/components/Dashboard/index.tsx b/src/ui/src/components/Dashboard/index.tsx index ed73bbfc..66519702 100644 --- a/src/ui/src/components/Dashboard/index.tsx +++ b/src/ui/src/components/Dashboard/index.tsx @@ -12,7 +12,7 @@ import SuppliedTokenTable from './SuppliedTokenTable'; import BorrowMarketTokenTable from './BorrowMarketTokenTable'; import SupplyMarketTokenTable from './SupplyMarketTokenTable'; -import { borrowedMarketAction, allMarketAction, suppliedMarketAction } from '../../reduxContent/market/actions'; +import { allMarketAction } from '../../reduxContent/market/actions'; import { useStyles } from './style'; @@ -29,9 +29,6 @@ const Dashboard = () => { return; } dispatch(allMarketAction(account, markets)); - - dispatch(suppliedMarketAction(allMarkets)); - dispatch(borrowedMarketAction(allMarkets)); }, [dispatch, account, markets]); return ( diff --git a/src/ui/src/components/DashboardModal/index.js b/src/ui/src/components/DashboardModal/index.js index a7a3f60e..d86522ee 100644 --- a/src/ui/src/components/DashboardModal/index.js +++ b/src/ui/src/components/DashboardModal/index.js @@ -5,7 +5,7 @@ import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import Box from '@mui/material/Box'; diff --git a/src/ui/src/components/Debug/index.js b/src/ui/src/components/Debug/index.js index a2af7426..cce60b08 100644 --- a/src/ui/src/components/Debug/index.js +++ b/src/ui/src/components/Debug/index.js @@ -19,7 +19,7 @@ import Grid from '@mui/material/Grid'; import TextField from '@mui/material/TextField'; import * as SW from '@mui/material/Switch'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals, TezosLendingPlatform } from 'tezoslendingplatformjs'; import { diff --git a/src/ui/src/reduxContent/borrowComposition/actions.js b/src/ui/src/reduxContent/borrowComposition/actions.js index d531b887..949ae484 100644 --- a/src/ui/src/reduxContent/borrowComposition/actions.js +++ b/src/ui/src/reduxContent/borrowComposition/actions.js @@ -1,4 +1,4 @@ -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import { decimalify } from '../../util'; diff --git a/src/ui/src/reduxContent/market/actions.js b/src/ui/src/reduxContent/market/actions.js index bd3b99c4..e70a4754 100644 --- a/src/ui/src/reduxContent/market/actions.js +++ b/src/ui/src/reduxContent/market/actions.js @@ -1,4 +1,4 @@ -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { TezosLendingPlatform } from 'tezoslendingplatformjs'; import { GET_ALL_MARKET_DATA, GET_BORROWED_MARKET_DATA, GET_MARKET_DATA, GET_SUPPLIED_MARKET_DATA @@ -67,6 +67,10 @@ export const allMarketAction = (account, markets) => (dispatch) => { return { ...token }; }); dispatch({ type: GET_ALL_MARKET_DATA, payload: formattedTokens }); + // eslint-disable-next-line no-use-before-define + dispatch(suppliedMarketAction(formattedTokens)); + // eslint-disable-next-line no-use-before-define + dispatch(borrowedMarketAction(formattedTokens)); }; /** diff --git a/src/ui/src/reduxContent/supplyComposition/actions.js b/src/ui/src/reduxContent/supplyComposition/actions.js index 887e2556..8cb3508b 100644 --- a/src/ui/src/reduxContent/supplyComposition/actions.js +++ b/src/ui/src/reduxContent/supplyComposition/actions.js @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ /* eslint-disable no-unused-expressions */ -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import { decimalify } from '../../util'; diff --git a/src/ui/src/util/index.js b/src/ui/src/util/index.js index a8933b18..bf29a9ed 100644 --- a/src/ui/src/util/index.js +++ b/src/ui/src/util/index.js @@ -1,6 +1,6 @@ import { TezosToolkit, OpKind } from '@taquito/taquito'; import { BeaconWallet } from '@taquito/beacon-wallet'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import bigInt from 'big-integer'; // eslint-disable-next-line import/no-dynamic-require diff --git a/src/ui/src/util/maxAction.js b/src/ui/src/util/maxAction.js index b6f6dd93..d64e3b9d 100644 --- a/src/ui/src/util/maxAction.js +++ b/src/ui/src/util/maxAction.js @@ -1,5 +1,5 @@ /* eslint-disable no-unused-expressions */ -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { decimals } from 'tezoslendingplatformjs'; import { decimalify } from './index'; diff --git a/src/ui/src/util/modalHooks.js b/src/ui/src/util/modalHooks.js index 4eb74e27..1b71c67a 100644 --- a/src/ui/src/util/modalHooks.js +++ b/src/ui/src/util/modalHooks.js @@ -7,6 +7,18 @@ import { useSelector } from 'react-redux'; import { decimalify } from './index'; +const toBigNumberInput = (value) => { + if (value === '' || value === null || value === undefined) { + return '0'; + } + if (typeof value === 'object' && typeof value.toString === 'function') { + return value.toString(); + } + return value; +}; + +const bn = (value) => new BigNumber(toBigNumberInput(value)); + /** * This function is used to ensure a user enters a valid amount to supply. * @@ -22,7 +34,7 @@ export const useSupplyErrorText = (tokenValue, limit, tokenDetails) => { if (!tokenDetails.isListed || tokenDetails.mintPaused) { setErrorText('Supplying is temporarily disabled for this market.'); setDisabled(true); - } else if (new BigNumber(tokenValue).gt(new BigNumber(limit))) { + } else if (bn(tokenValue).gt(bn(limit))) { setText('Insufficient Funds'); setErrorText(''); setDisabled(true); @@ -52,8 +64,8 @@ export const useBorrowErrorText = (tokenValue, borrowLimit, tokenDetails) => { const [errorText, setErrorText] = useState(''); const [disabled, setDisabled] = useState(false); - const limit = Number(new BigNumber(borrowLimit) - .dividedBy(new BigNumber(tokenDetails.usdPrice)) + const limit = Number(bn(borrowLimit) + .dividedBy(bn(tokenDetails.usdPrice)) .toFixed(decimals[tokenDetails.title])); const { allMarkets } = useSelector((state) => state.market); @@ -67,7 +79,7 @@ export const useBorrowErrorText = (tokenValue, borrowLimit, tokenDetails) => { totalBorrowed = decimalify(x.totalBorrowed.toString(), decimals[x.title], decimals[x.title]); } }); - const availableBorrowAmount = new BigNumber(marketSize).minus(new BigNumber(totalBorrowed)).toNumber(); + const availableBorrowAmount = bn(marketSize).minus(bn(totalBorrowed)).toNumber(); useEffect(() => { if (!tokenDetails.isListed || tokenDetails.borrowPaused) { @@ -77,7 +89,7 @@ export const useBorrowErrorText = (tokenValue, borrowLimit, tokenDetails) => { } else if ((Number(tokenValue) > 0) && (Number(tokenValue) > availableBorrowAmount)) { setErrorText('You cannot borrow more than the amount available on the market.'); setDisabled(true); - } else if (new BigNumber(tokenValue).gt(new BigNumber(limit))) { + } else if (bn(tokenValue).gt(bn(limit))) { setText('Insufficient Collateral'); setErrorText('You must supply assets as collateral to increase your borrow limit.'); setDisabled(true); @@ -116,21 +128,21 @@ export const useWithdrawErrorText = (tokenValue, limit, tokenDetails) => { const { borrowing } = useSelector((state) => state.borrowComposition.borrowComposition); const tokenValueUsd = tokenValue - ? new BigNumber(tokenValue).multipliedBy(new BigNumber(tokenDetails.usdPrice)).toNumber() + ? bn(tokenValue).multipliedBy(bn(tokenDetails.usdPrice)).toNumber() : 0; - let pendingSupplyingUsd = new BigNumber(supplying).minus(new BigNumber(tokenValueUsd)).toNumber(); + let pendingSupplyingUsd = bn(supplying).minus(bn(tokenValueUsd)).toNumber(); pendingSupplyingUsd = pendingSupplyingUsd > 0 ? pendingSupplyingUsd : 0; let pendingCollateralizedUsd = collateralized; if (tokenDetails.collateral) { - pendingCollateralizedUsd = new BigNumber(collateralized).minus(new BigNumber(tokenValueUsd)).toNumber(); + pendingCollateralizedUsd = bn(collateralized).minus(bn(tokenValueUsd)).toNumber(); } - const pendingSupplyingUsdLimit = new BigNumber(pendingSupplyingUsd).multipliedBy( - new BigNumber(tokenDetails.collateralFactor) + const pendingSupplyingUsdLimit = bn(pendingSupplyingUsd).multipliedBy( + bn(tokenDetails.collateralFactor) ).toNumber(); - const pendingCollateralizedUsdLimit = new BigNumber(pendingCollateralizedUsd).multipliedBy( - new BigNumber(tokenDetails.collateralFactor) + const pendingCollateralizedUsdLimit = bn(pendingCollateralizedUsd).multipliedBy( + bn(tokenDetails.collateralFactor) ).toNumber(); useEffect(() => { @@ -177,7 +189,7 @@ export const useRepayErrorText = (tokenValue, limit, tokenDetails) => { const [disabled, setDisabled] = useState(false); useEffect(() => { - if (new BigNumber(tokenValue).multipliedBy(new BigNumber(10).pow(new BigNumber(decimals[tokenDetails.title].toString()))).gt(new BigNumber(tokenDetails.walletBalance))) { + if (bn(tokenValue).multipliedBy(bn(10).pow(bn(decimals[tokenDetails.title].toString()))).gt(bn(tokenDetails.walletBalance))) { setErrorText('Insufficient funds for repayment.'); setDisabled(true); } else { @@ -205,13 +217,13 @@ export const useDisableTokenErrorText = (tokenDetails) => { const { borrowedMarkets } = useSelector((state) => state.market); const tokenValueUsd = (tokenDetails.balanceUnderlying > 0) - && new BigNumber( + && bn( decimalify(tokenDetails.balanceUnderlying, decimals[tokenDetails.title], decimals[tokenDetails.title]) - ).multipliedBy(new BigNumber(tokenDetails.usdPrice)).toNumber(); + ).multipliedBy(bn(tokenDetails.usdPrice)).toNumber(); - const pendingCollateralizedUsd = new BigNumber(collateralized).minus(new BigNumber(tokenValueUsd)).toNumber(); - const pendingCollateralizedUsdLimit = new BigNumber(pendingCollateralizedUsd).multipliedBy( - new BigNumber(tokenDetails.collateralFactor) + const pendingCollateralizedUsd = bn(collateralized).minus(bn(tokenValueUsd)).toNumber(); + const pendingCollateralizedUsdLimit = bn(pendingCollateralizedUsd).multipliedBy( + bn(tokenDetails.collateralFactor) ).toNumber(); let isBorrowed; diff --git a/src/util/package-lock.json b/src/util/package-lock.json index bbf9b62a..110b6176 100644 --- a/src/util/package-lock.json +++ b/src/util/package-lock.json @@ -9,11 +9,11 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { - "@taquito/michel-codec": "^24.3.0", - "@taquito/taquito": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/michel-codec": "25.0.0", + "@taquito/taquito": "25.0.0", + "@taquito/utils": "25.0.0", "big-integer": "^1.6.51", - "bignumber.js": "9.0.1", + "bignumber.js": "^10.0.2", "decimal.js": "^10.3.1", "loglevel": "^1.7.1" }, @@ -27,7 +27,10 @@ "eslint-plugin-import": "^2.25.2", "mocha": "^11.0.1", "ts-mocha": "^10.0.0", - "typescript": "^4.4.3" + "typescript": "^4.9.5" + }, + "engines": { + "node": "22.x" } }, "../../ConseilJS": { @@ -361,9 +364,9 @@ } }, "node_modules/@taquito/core": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/core/-/core-24.3.0.tgz", - "integrity": "sha512-NReAUkdJVY8Dsdw0fykJTaYsdEPL5VHh6Ydc9LD96SHW7WowkKxOuYsmcocxSWOjiVmHrsjWR4slAy9QD/gK6w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/core/-/core-25.0.0.tgz", + "integrity": "sha512-TlU+eMEn47mAmIjTFP2U4ReHRU05FsnyVn/c5DQnJC0psZ6LRJXimAIA1KQ94afsCDByewsXLN5fjKwn47l72A==", "license": "Apache-2.0", "dependencies": { "json-stringify-safe": "^5.0.1" @@ -373,25 +376,25 @@ } }, "node_modules/@taquito/http-utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-24.3.0.tgz", - "integrity": "sha512-B/Z92oMr6SDWvYJLaQddPI/UkJvLZ97s2B1RmPQOls8cTRg1m3iWKj/Yaqrj16qJ2DRklVVw5pDAY366TLlrgw==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-25.0.0.tgz", + "integrity": "sha512-/nkwDeTXEW10lSQdyTrLgp9GIWQc2yi6wQLjEFvXveevrMjuA+lfFU8QoOOZxXH0GM42KEmU/y/VA1wcgl+gKQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" }, "engines": { "node": ">=22" } }, "node_modules/@taquito/local-forging": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-24.3.0.tgz", - "integrity": "sha512-cXkJPLR0YPak8dx32cbiAqCwvLNhzebG9Y5Hgup+dm/hKzWE0bhi28lw23UkhG9DbQeCnFDTTAnO8ZCh2YtP3A==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-25.0.0.tgz", + "integrity": "sha512-sFeObpxya59PP5xFFsPWb3zLxASe3QwQqQ1fJWTPCs/Fph7/cxk5Kj0Oco961SC7CVSkG/ayz4/WINmm+oTlPA==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-text-encoding": "^1.0.6" }, @@ -399,34 +402,28 @@ "node": ">=22" } }, - "node_modules/@taquito/local-forging/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/michel-codec": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-24.3.0.tgz", - "integrity": "sha512-iq2mfwiUhFk1q+3o0SIwBYpYU1luJglP5nA3QWlctyYPRVQ4U2EoreNIKSA83PQKBDtdFjHhTcYcGsbJa14j7Q==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-25.0.0.tgz", + "integrity": "sha512-ITM3lM3tEAblPVdzQk5Rv2nLMMOalrXbnIt5b5St8OVYwqaDyfsH3fxSGIVDPxRQyyBdgJ1403aVu6768/8m4Q==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" }, "engines": { "node": ">=22" } }, "node_modules/@taquito/michelson-encoder": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-24.3.0.tgz", - "integrity": "sha512-GwB1x1IhTXVvaXwnkFJII4csS35PnS/LGbMSWYw8JcfBgBk5zqv2U5R++pMgvuSnlCSQ6qWshNYAg3fUck+ePQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-25.0.0.tgz", + "integrity": "sha512-BWwAAwBhY3zngcMK8SkmBWDZ5aNVRnHlHvi7Xu6jnGW109yM3n9awxxCrFD8jOXPb3dly+/pulGnkv28+EvIIQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-json-stable-stringify": "^2.1.0" }, @@ -434,45 +431,33 @@ "node": ">=22" } }, - "node_modules/@taquito/michelson-encoder/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/rpc": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-24.3.0.tgz", - "integrity": "sha512-j0qAcsnXXXYn+599aCDgNDttB6sIljyfNEpx5uW+qAN7ffMhVu+D1J1GEKfwIzRdH2sHGEwhiQjpIqhheMIO+w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-25.0.0.tgz", + "integrity": "sha512-qqV4boldGOavsM6ZzK6xky4xAEyllYDyIO5C16cvkoUzoMCCsWMpRuXa1csSrQc+0IECkkDurNLTbrMJPne9tA==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2" }, "engines": { "node": ">=22" } }, - "node_modules/@taquito/rpc/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/signer": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-24.3.0.tgz", - "integrity": "sha512-v6JRjMlcOjlIQueDWrHB9ytUWEQ6gh2Z8Y+trVOZTjW7buWXkul9hwgsl75ELvOAome5t/6KzNuuHsyImlt2BQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-25.0.0.tgz", + "integrity": "sha512-UDHwWd3O0VwZjbEw0NDsoQoIhoQv+xHxb/XAKW7ruSjUT6OkH5whhHpgTZ+T2eJLPDBZLY1RH8IdSl+6ZFtUXg==", "license": "Apache-2.0", "dependencies": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@scure/bip39": "^2.0.1", + "@noble/hashes": "^2.2.0", + "@scure/bip39": "^2.2.0", "@stablelib/nacl": "^1.0.4", - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.2", "typedarray-to-buffer": "^4.0.0" @@ -482,19 +467,19 @@ } }, "node_modules/@taquito/taquito": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-24.3.0.tgz", - "integrity": "sha512-3PHMi0JucJKejInHV4vmyAcVzb+HTUTbo80N3XOkY2v63Goaq2b4fgGgBIeJo+FchUBKHfJdoYQqOKyNs6h5Sg==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-25.0.0.tgz", + "integrity": "sha512-MBNKXK1CrOlwBrI0IkjWbVcuwY238ZF8B6fuf2qA0uYp+UmVjukUJ4QCvRf+bayWzfiWBbkYP0upY6VGV3C1VQ==", "license": "Apache-2.0", "dependencies": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/local-forging": "^24.3.0", - "@taquito/michel-codec": "^24.3.0", - "@taquito/michelson-encoder": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/local-forging": "^25.0.0", + "@taquito/michel-codec": "^25.0.0", + "@taquito/michelson-encoder": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "rxjs": "^7.8.2" }, @@ -502,21 +487,15 @@ "node": ">=22" } }, - "node_modules/@taquito/taquito/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, "node_modules/@taquito/utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-24.3.0.tgz", - "integrity": "sha512-G2z+1fRg2jpK1qsdfRtdRxLNwtSTfXI2x29HP3qKFhKz+uCoPQfrClfqBSHkJoy6SzxSZhU3BOoQ4x983hhkfQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-25.0.0.tgz", + "integrity": "sha512-I/9hndZcx0yL6f1djPMhgxCpAopbh/E1ta5kYGs3AxDGrYKt0QpbWAvvUV7fwU9kgzHRQlm7fX8DP7zUbz7ntg==", "license": "Apache-2.0", "dependencies": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@taquito/core": "^24.3.0", + "@noble/hashes": "^2.2.0", + "@taquito/core": "^25.0.0", "@types/bs58check": "^2.1.2", "bignumber.js": "^10.0.2", "blakejs": "^1.2.1", @@ -528,55 +507,6 @@ "node": ">=22" } }, - "node_modules/@taquito/utils/node_modules/base-x": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz", - "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==", - "license": "MIT" - }, - "node_modules/@taquito/utils/node_modules/bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", - "license": "MIT" - }, - "node_modules/@taquito/utils/node_modules/blakejs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", - "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", - "license": "MIT" - }, - "node_modules/@taquito/utils/node_modules/bs58": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", - "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", - "license": "MIT", - "dependencies": { - "base-x": "^4.0.0" - } - }, - "node_modules/@taquito/utils/node_modules/bs58check": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-3.0.1.tgz", - "integrity": "sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "^1.2.0", - "bs58": "^5.0.0" - } - }, - "node_modules/@taquito/utils/node_modules/bs58check/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@types/bn.js": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.2.0.tgz", @@ -778,6 +708,12 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/base-x": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==", + "license": "MIT" + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -807,12 +743,10 @@ } }, "node_modules/bignumber.js": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", - "integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==", - "engines": { - "node": "*" - } + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", + "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==", + "license": "MIT" }, "node_modules/binary-extensions": { "version": "2.3.0", @@ -826,10 +760,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/blakejs": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", + "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", + "license": "MIT" + }, "node_modules/bn.js": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.3.tgz", - "integrity": "sha512-EAcmnPkxpntVL+DS7bO1zhcZNvCkxqtkd0ZY53h06GNQ3DEkkGZ/gKgmDv6DdZQGj9BgfSPKtJJ7Dp1GPP8f7w==", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.4.tgz", + "integrity": "sha512-QL7sb18rJ1PbdsKsqPA0guxL563vIMwRHgzNrW/uzQuRGN1Cjqd/wonUBAVqHox9KwzHA6vCbM0lXx3k4iQMow==", "license": "MIT" }, "node_modules/brace-expansion": { @@ -860,6 +800,37 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "node_modules/bs58": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", + "license": "MIT", + "dependencies": { + "base-x": "^4.0.0" + } + }, + "node_modules/bs58check": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-3.0.1.tgz", + "integrity": "sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "^1.2.0", + "bs58": "^5.0.0" + } + }, + "node_modules/bs58check/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/buffer": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", @@ -3324,10 +3295,11 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -3778,180 +3750,111 @@ } }, "@taquito/core": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/core/-/core-24.3.0.tgz", - "integrity": "sha512-NReAUkdJVY8Dsdw0fykJTaYsdEPL5VHh6Ydc9LD96SHW7WowkKxOuYsmcocxSWOjiVmHrsjWR4slAy9QD/gK6w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/core/-/core-25.0.0.tgz", + "integrity": "sha512-TlU+eMEn47mAmIjTFP2U4ReHRU05FsnyVn/c5DQnJC0psZ6LRJXimAIA1KQ94afsCDByewsXLN5fjKwn47l72A==", "requires": { "json-stringify-safe": "^5.0.1" } }, "@taquito/http-utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-24.3.0.tgz", - "integrity": "sha512-B/Z92oMr6SDWvYJLaQddPI/UkJvLZ97s2B1RmPQOls8cTRg1m3iWKj/Yaqrj16qJ2DRklVVw5pDAY366TLlrgw==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-25.0.0.tgz", + "integrity": "sha512-/nkwDeTXEW10lSQdyTrLgp9GIWQc2yi6wQLjEFvXveevrMjuA+lfFU8QoOOZxXH0GM42KEmU/y/VA1wcgl+gKQ==", "requires": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" } }, "@taquito/local-forging": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-24.3.0.tgz", - "integrity": "sha512-cXkJPLR0YPak8dx32cbiAqCwvLNhzebG9Y5Hgup+dm/hKzWE0bhi28lw23UkhG9DbQeCnFDTTAnO8ZCh2YtP3A==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/local-forging/-/local-forging-25.0.0.tgz", + "integrity": "sha512-sFeObpxya59PP5xFFsPWb3zLxASe3QwQqQ1fJWTPCs/Fph7/cxk5Kj0Oco961SC7CVSkG/ayz4/WINmm+oTlPA==", "requires": { - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-text-encoding": "^1.0.6" - }, - "dependencies": { - "bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" - } } }, "@taquito/michel-codec": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-24.3.0.tgz", - "integrity": "sha512-iq2mfwiUhFk1q+3o0SIwBYpYU1luJglP5nA3QWlctyYPRVQ4U2EoreNIKSA83PQKBDtdFjHhTcYcGsbJa14j7Q==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-25.0.0.tgz", + "integrity": "sha512-ITM3lM3tEAblPVdzQk5Rv2nLMMOalrXbnIt5b5St8OVYwqaDyfsH3fxSGIVDPxRQyyBdgJ1403aVu6768/8m4Q==", "requires": { - "@taquito/core": "^24.3.0" + "@taquito/core": "^25.0.0" } }, "@taquito/michelson-encoder": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-24.3.0.tgz", - "integrity": "sha512-GwB1x1IhTXVvaXwnkFJII4csS35PnS/LGbMSWYw8JcfBgBk5zqv2U5R++pMgvuSnlCSQ6qWshNYAg3fUck+ePQ==", - "requires": { - "@taquito/core": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-25.0.0.tgz", + "integrity": "sha512-BWwAAwBhY3zngcMK8SkmBWDZ5aNVRnHlHvi7Xu6jnGW109yM3n9awxxCrFD8jOXPb3dly+/pulGnkv28+EvIIQ==", + "requires": { + "@taquito/core": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "fast-json-stable-stringify": "^2.1.0" - }, - "dependencies": { - "bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" - } } }, "@taquito/rpc": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-24.3.0.tgz", - "integrity": "sha512-j0qAcsnXXXYn+599aCDgNDttB6sIljyfNEpx5uW+qAN7ffMhVu+D1J1GEKfwIzRdH2sHGEwhiQjpIqhheMIO+w==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-25.0.0.tgz", + "integrity": "sha512-qqV4boldGOavsM6ZzK6xky4xAEyllYDyIO5C16cvkoUzoMCCsWMpRuXa1csSrQc+0IECkkDurNLTbrMJPne9tA==", "requires": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2" - }, - "dependencies": { - "bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" - } } }, "@taquito/signer": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-24.3.0.tgz", - "integrity": "sha512-v6JRjMlcOjlIQueDWrHB9ytUWEQ6gh2Z8Y+trVOZTjW7buWXkul9hwgsl75ELvOAome5t/6KzNuuHsyImlt2BQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/signer/-/signer-25.0.0.tgz", + "integrity": "sha512-UDHwWd3O0VwZjbEw0NDsoQoIhoQv+xHxb/XAKW7ruSjUT6OkH5whhHpgTZ+T2eJLPDBZLY1RH8IdSl+6ZFtUXg==", "requires": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@scure/bip39": "^2.0.1", + "@noble/hashes": "^2.2.0", + "@scure/bip39": "^2.2.0", "@stablelib/nacl": "^1.0.4", - "@taquito/core": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/core": "^25.0.0", + "@taquito/utils": "^25.0.0", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.2", "typedarray-to-buffer": "^4.0.0" } }, "@taquito/taquito": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-24.3.0.tgz", - "integrity": "sha512-3PHMi0JucJKejInHV4vmyAcVzb+HTUTbo80N3XOkY2v63Goaq2b4fgGgBIeJo+FchUBKHfJdoYQqOKyNs6h5Sg==", - "requires": { - "@taquito/core": "^24.3.0", - "@taquito/http-utils": "^24.3.0", - "@taquito/local-forging": "^24.3.0", - "@taquito/michel-codec": "^24.3.0", - "@taquito/michelson-encoder": "^24.3.0", - "@taquito/rpc": "^24.3.0", - "@taquito/signer": "^24.3.0", - "@taquito/utils": "^24.3.0", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-25.0.0.tgz", + "integrity": "sha512-MBNKXK1CrOlwBrI0IkjWbVcuwY238ZF8B6fuf2qA0uYp+UmVjukUJ4QCvRf+bayWzfiWBbkYP0upY6VGV3C1VQ==", + "requires": { + "@taquito/core": "^25.0.0", + "@taquito/http-utils": "^25.0.0", + "@taquito/local-forging": "^25.0.0", + "@taquito/michel-codec": "^25.0.0", + "@taquito/michelson-encoder": "^25.0.0", + "@taquito/rpc": "^25.0.0", + "@taquito/signer": "^25.0.0", + "@taquito/utils": "^25.0.0", "bignumber.js": "^10.0.2", "rxjs": "^7.8.2" - }, - "dependencies": { - "bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" - } } }, "@taquito/utils": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-24.3.0.tgz", - "integrity": "sha512-G2z+1fRg2jpK1qsdfRtdRxLNwtSTfXI2x29HP3qKFhKz+uCoPQfrClfqBSHkJoy6SzxSZhU3BOoQ4x983hhkfQ==", + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-25.0.0.tgz", + "integrity": "sha512-I/9hndZcx0yL6f1djPMhgxCpAopbh/E1ta5kYGs3AxDGrYKt0QpbWAvvUV7fwU9kgzHRQlm7fX8DP7zUbz7ntg==", "requires": { "@noble/curves": "^1.9.7", - "@noble/hashes": "^2.0.1", - "@taquito/core": "^24.3.0", + "@noble/hashes": "^2.2.0", + "@taquito/core": "^25.0.0", "@types/bs58check": "^2.1.2", "bignumber.js": "^10.0.2", "blakejs": "^1.2.1", "bs58check": "^3.0.1", "buffer": "^6.0.3", "typedarray-to-buffer": "^4.0.0" - }, - "dependencies": { - "base-x": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz", - "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==" - }, - "bignumber.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", - "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" - }, - "blakejs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", - "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==" - }, - "bs58": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", - "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", - "requires": { - "base-x": "^4.0.0" - } - }, - "bs58check": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-3.0.1.tgz", - "integrity": "sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ==", - "requires": { - "@noble/hashes": "^1.2.0", - "bs58": "^5.0.0" - }, - "dependencies": { - "@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==" - } - } - } } }, "@types/bn.js": { @@ -4106,6 +4009,11 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "base-x": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==" + }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -4117,9 +4025,9 @@ "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==" }, "bignumber.js": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", - "integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==" + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-10.0.2.tgz", + "integrity": "sha512-E8Wp9O06QA6lneJ4aRUXKYf/1GIomqUEmUMwtIOMtDxf1U52ffJY+y7JBk/8wRafA8qOIqLnXQGqonYXZdBnFQ==" }, "binary-extensions": { "version": "2.3.0", @@ -4127,10 +4035,15 @@ "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "dev": true }, + "blakejs": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", + "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==" + }, "bn.js": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.3.tgz", - "integrity": "sha512-EAcmnPkxpntVL+DS7bO1zhcZNvCkxqtkd0ZY53h06GNQ3DEkkGZ/gKgmDv6DdZQGj9BgfSPKtJJ7Dp1GPP8f7w==" + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.4.tgz", + "integrity": "sha512-QL7sb18rJ1PbdsKsqPA0guxL563vIMwRHgzNrW/uzQuRGN1Cjqd/wonUBAVqHox9KwzHA6vCbM0lXx3k4iQMow==" }, "brace-expansion": { "version": "1.1.11", @@ -4157,6 +4070,30 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "bs58": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", + "requires": { + "base-x": "^4.0.0" + } + }, + "bs58check": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-3.0.1.tgz", + "integrity": "sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ==", + "requires": { + "@noble/hashes": "^1.2.0", + "bs58": "^5.0.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==" + } + } + }, "buffer": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", @@ -5923,9 +5860,9 @@ "integrity": "sha512-6dOYeZfS3O9RtRD1caom0sMxgK59b27+IwoNy8RDPsmslSGOyU+mpTamlaIW7aNKi90ZQZ9DFaZL3YRoiSCULQ==" }, "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true }, "unbox-primitive": { diff --git a/src/util/package.json b/src/util/package.json index 651e1739..a3756d8a 100644 --- a/src/util/package.json +++ b/src/util/package.json @@ -3,6 +3,9 @@ "version": "0.0.1", "description": "Typescript util for working with the Tezos Lending Platform", "main": "build/index.js", + "engines": { + "node": "22.x" + }, "scripts": { "postinstall": "npm run build", "start": "node ./build/src/index.js", @@ -23,14 +26,14 @@ "eslint-plugin-import": "^2.25.2", "mocha": "^11.0.1", "ts-mocha": "^10.0.0", - "typescript": "^4.4.3" + "typescript": "^4.9.5" }, "dependencies": { - "@taquito/michel-codec": "^24.3.0", - "@taquito/taquito": "^24.3.0", - "@taquito/utils": "^24.3.0", + "@taquito/michel-codec": "25.0.0", + "@taquito/taquito": "25.0.0", + "@taquito/utils": "25.0.0", "big-integer": "^1.6.51", - "bignumber.js": "9.0.1", + "bignumber.js": "^10.0.2", "decimal.js": "^10.3.1", "loglevel": "^1.7.1" } diff --git a/src/util/src/FToken.ts b/src/util/src/FToken.ts index c1cf539e..6281676a 100644 --- a/src/util/src/FToken.ts +++ b/src/util/src/FToken.ts @@ -3,7 +3,7 @@ import { packDataBytes, unpackDataBytes } from '@taquito/michel-codec'; import { encodeExpr } from '@taquito/utils'; import { getContract, getToolkit } from './toolkit'; import { AssetType, TokenStandard } from './enum'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; import { InterestRateModel } from './contracts/InterestRateModel'; import { Network, ProtocolAddresses, UnderlyingAsset } from './types'; import bigInt from 'big-integer'; diff --git a/src/util/src/TezosLendingPlatform.ts b/src/util/src/TezosLendingPlatform.ts index 48085a8f..9a1c3563 100644 --- a/src/util/src/TezosLendingPlatform.ts +++ b/src/util/src/TezosLendingPlatform.ts @@ -22,7 +22,7 @@ import { PriceFeed } from './PriceFeed'; import bigInt from 'big-integer'; import { tokenNames } from './const'; import log from 'loglevel'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; export namespace TezosLendingPlatform { @@ -94,11 +94,34 @@ export namespace TezosLendingPlatform { const markets: MarketMap = {}; const toolkit = getToolkit(server); const head = await toolkit.rpc.getBlockHeader(); + const recoveryMode = Boolean(protocolAddresses.comptrollerDataSource); await Promise.all( Object.keys(protocolAddresses.fTokens).map(async (asset) => { const fTokenAddress = protocolAddresses.fTokens[asset]; const fTokenType = protocolAddresses.underlying[protocolAddresses.fTokensReverse[fTokenAddress]].tokenStandard; + let oraclePrice: bigInt.BigInteger; + if (recoveryMode) { + try { + oraclePrice = await PriceFeed.GetPrice( + protocolAddresses.fTokensReverse[fTokenAddress], + protocolAddresses.oracle, + head.level, + server, + ); + } catch (priceError) { + log.warn(`Price unavailable for ${asset} in recovery mode, using 0: ${priceError}`); + oraclePrice = bigInt(0); + } + } else { + // Normal operation must fail closed when the oracle is unavailable. + oraclePrice = await PriceFeed.GetPrice( + protocolAddresses.fTokensReverse[fTokenAddress], + protocolAddresses.oracle, + head.level, + server, + ); + } try { const fTokenStorage = await FToken.GetStorage( fTokenAddress, @@ -108,13 +131,7 @@ export namespace TezosLendingPlatform { ); const rateModel = await InterestRateModel.GetStorage( server, - fTokenStorage.interestRateModel, - ); - const oraclePrice = await PriceFeed.GetPrice( - protocolAddresses.fTokensReverse[fTokenAddress], - protocolAddresses.oracle, - head.level, - server, + protocolAddresses.interestRateModel[asset], ); const borrowRate = FToken.getBorrowRate(fTokenStorage, rateModel); const fTokenStorageAfterAccrual = FToken.SimulateAccrueInterest( @@ -490,14 +507,13 @@ export namespace TezosLendingPlatform { protocolAddresses: ProtocolAddresses, pkh: string, ): TransferParams[] { + const recoveryMode = Boolean(protocolAddresses.comptrollerDataSource); let ops: TransferParams[] = []; - if (protocolAddresses.comptrollerDataSource) { - ops = ops.concat(FToken.AccrueInterestOpGroup( - [redeem.underlying], - protocolAddresses, - pkh, - )); + if (recoveryMode) { + // In recovery mode accrue only the redeemed market — Guard handles liquidity checks + ops = ops.concat(FToken.AccrueInterestOpGroup([redeem.underlying as AssetType], protocolAddresses, pkh)); } else { + // Data relevance (updateAccountLiquidityWithView) ops = ops.concat(Comptroller.DataRelevanceOpGroup([], protocolAddresses, pkh)); } // Redeem @@ -524,15 +540,13 @@ export namespace TezosLendingPlatform { protocolAddresses: ProtocolAddresses, pkh: string, ): TransferParams[] { + const recoveryMode = Boolean(protocolAddresses.comptrollerDataSource); let ops: TransferParams[] = []; - // Accrue interest - ops = ops.concat(FToken.AccrueInterestOpGroup( - protocolAddresses.comptrollerDataSource - ? [repayBorrow.underlying] - : Object.keys(protocolAddresses.fTokens) as AssetType[], - protocolAddresses, - pkh, - )); + // In recovery mode accrue only the repaid market; otherwise accrue all markets + const marketsToAccrue = recoveryMode + ? [repayBorrow.underlying as AssetType] + : Object.keys(protocolAddresses.fTokens) as AssetType[]; + ops = ops.concat(FToken.AccrueInterestOpGroup(marketsToAccrue, protocolAddresses, pkh)); // Permission const permOp = permissionOperation(repayBorrow.underlying, repayBorrow.amount, false, protocolAddresses, pkh); if (permOp) ops.push(...permOp); diff --git a/src/util/src/types.ts b/src/util/src/types.ts index 6fc20b33..6fbf0ac2 100644 --- a/src/util/src/types.ts +++ b/src/util/src/types.ts @@ -2,7 +2,7 @@ import { AssetType, TokenStandard } from './enum'; import { FToken } from './FToken'; import { InterestRateModel } from './contracts/InterestRateModel'; -import { BigNumber } from 'bignumber.js'; +import BigNumber from 'bignumber.js'; /* * @description diff --git a/src/util/test/FToken.ts b/src/util/test/FToken.ts index 5bd79883..b830e007 100644 --- a/src/util/test/FToken.ts +++ b/src/util/test/FToken.ts @@ -1,4 +1,4 @@ -import { BigNumber } from "bignumber.js"; +import BigNumber from "bignumber.js"; import bigInt from "big-integer"; import { FToken } from "../src/FToken"; import { InterestRateModel } from "../src/contracts/InterestRateModel"; diff --git a/src/util/test/RecoveryMod.ts b/src/util/test/RecoveryMod.ts index 584c8595..7283a002 100644 --- a/src/util/test/RecoveryMod.ts +++ b/src/util/test/RecoveryMod.ts @@ -1,7 +1,11 @@ import { expect } from 'chai'; -import { describe, it } from 'mocha'; +import { afterEach, beforeEach, describe, it } from 'mocha'; +import bigInt from 'big-integer'; import { Comptroller } from '../src/Comptroller'; import { AssetType, TokenStandard } from '../src/enum'; +import { FToken } from '../src/FToken'; +import { InterestRateModel } from '../src/contracts/InterestRateModel'; +import { PriceFeed } from '../src/PriceFeed'; import { TezosLendingPlatform } from '../src/TezosLendingPlatform'; import { Network, ProtocolAddresses } from '../src/types'; @@ -86,6 +90,126 @@ describe('recovery operation groups', () => { }); }); +describe('oracle failures', () => { + const toolkitModule = require('../src/toolkit'); + const originalGetToolkit = toolkitModule.getToolkit; + const originalGetPrice = PriceFeed.GetPrice; + const originalGetFTokenStorage = FToken.GetStorage; + const originalGetInterestRateStorage = InterestRateModel.GetStorage; + const oracleError = new Error('oracle unavailable'); + const scale = bigInt('1000000000000000000'); + + function fTokenStorage(): FToken.Storage { + return { + accrualBlockNumber: 1, + administrator: 'tz1-admin', + supply: { + totalSupply: bigInt(100), + supplyRatePerBlock: bigInt(0), + }, + borrow: { + totalBorrows: bigInt(0), + borrowIndex: scale, + borrowRateMaxMantissa: scale, + borrowRatePerBlock: bigInt(0), + }, + comptrollerAddress: 'KT1-guard', + expScale: scale, + halfExpScale: scale.divide(2), + initialExchangeRateMantissa: scale, + protocolSeizeShareMantissa: bigInt(0), + interestRateModel: 'KT1-rate-model', + pendingAdministrator: undefined, + reserveFactorMantissa: bigInt(0), + reserveFactorMaxMantissa: scale, + totalReserves: bigInt(0), + currentCash: bigInt(100), + }; + } + + const rateModel: InterestRateModel.Storage = { + blockRate: bigInt(0), + blockMultiplier: bigInt(0), + jumpMultiplier: bigInt(0), + kink: scale, + scale, + }; + const comptrollerStorage = { + markets: { + [AssetType.XTZ]: { + assetType: AssetType.XTZ, + borrowPaused: true, + collateralFactor: 0, + isListed: true, + mintPaused: true, + redeemPaused: false, + price: bigInt(0), + updateLevel: 1, + }, + }, + } as Comptroller.Storage; + + beforeEach(() => { + toolkitModule.getToolkit = () => ({ + rpc: { + getBlockHeader: async () => ({ level: 10 }), + }, + }); + (PriceFeed as any).GetPrice = async () => { + throw oracleError; + }; + (FToken as any).GetStorage = async () => fTokenStorage(); + (InterestRateModel as any).GetStorage = async () => rateModel; + }); + + afterEach(() => { + toolkitModule.getToolkit = originalGetToolkit; + (PriceFeed as any).GetPrice = originalGetPrice; + (FToken as any).GetStorage = originalGetFTokenStorage; + (InterestRateModel as any).GetStorage = originalGetInterestRateStorage; + }); + + it('keeps repayment and withdrawal available in recovery mode when getPrice fails', async () => { + const addresses = protocolAddresses(true); + addresses.fTokens = { [AssetType.XTZ]: fXTZ }; + addresses.fTokensReverse = { [fXTZ]: AssetType.XTZ }; + addresses.interestRateModel = { [AssetType.XTZ]: 'KT1-rate-model' }; + + const markets = await TezosLendingPlatform.GetMarkets(comptrollerStorage, addresses, 'https://rpc.example'); + const redeemOperations = TezosLendingPlatform.RedeemOpGroup( + { underlying: AssetType.XTZ, amount: 10, amountInUnderlying: false }, + AssetType.XTZ, + addresses, + 'tz1-user', + ); + const repayOperations = TezosLendingPlatform.RepayBorrowOpGroup( + { underlying: AssetType.XTZ, amount: 10 }, + addresses, + 'tz1-user', + ); + + expect(markets[AssetType.XTZ].currentPrice.toString()).to.equal('0'); + expect(entrypoints(redeemOperations)).to.deep.equal(['accrueInterest', 'redeem']); + expect(entrypoints(repayOperations)).to.deep.equal(['accrueInterest', 'repayBorrow']); + }); + + it('does not suppress getPrice failures outside recovery mode', async () => { + const addresses = protocolAddresses(false); + addresses.fTokens = { [AssetType.XTZ]: fXTZ }; + addresses.fTokensReverse = { [fXTZ]: AssetType.XTZ }; + addresses.interestRateModel = { [AssetType.XTZ]: 'KT1-rate-model' }; + let thrown: unknown; + + try { + await TezosLendingPlatform.GetMarkets(comptrollerStorage, addresses, 'https://rpc.example'); + } catch (error) { + thrown = error; + } + + expect(thrown).to.equal(oracleError); + }); +}); + describe('Guard and legacy market storage', () => { const legacyMarket = { name: AssetType.XTZ,