diff --git a/javascript/solana.js/package-lock.json b/javascript/solana.js/package-lock.json index 1bb4663..37e8678 100644 --- a/javascript/solana.js/package-lock.json +++ b/javascript/solana.js/package-lock.json @@ -9,10 +9,10 @@ "version": "2.0.62", "license": "MIT", "dependencies": { - "@project-serum/anchor": "^0.25.0", + "@project-serum/anchor": "^0.26.0", "@project-serum/borsh": "^0.2.5", - "@solana/spl-token": "^0.3.5", - "@solana/web3.js": "^1.70.3", + "@solana/spl-token": "^0.3.6", + "@solana/web3.js": "^1.73.0", "@switchboard-xyz/common": "^2.1.8", "big.js": "^6.2.1", "bn.js": "^5.2.1", @@ -26,7 +26,7 @@ "@types/expect": "^24.3.0", "@types/lodash": "^4.14.191", "@types/mocha": "^10.0.0", - "@types/node": "^18.11.0", + "@types/node": "^18.11.18", "anchor-client-gen": "^0.25.0", "chai": "^4.3.7", "chalk": "^4.1.2", @@ -36,8 +36,8 @@ "shx": "^0.3.4", "ts-mocha": "^10.0.0", "ts-node": "^10.9.1", - "typedoc": "^0.23.16", - "typescript": "^4.8.4" + "typedoc": "^0.23.23", + "typescript": "^4.9.4" }, "engines": { "node": ">=16.0.0", @@ -149,6 +149,21 @@ "node": ">=6.9.0" } }, + "node_modules/@coral-xyz/borsh": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.26.0.tgz", + "integrity": "sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ==", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.68.0" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -345,17 +360,17 @@ } }, "node_modules/@project-serum/anchor": { - "version": "0.25.0", - "resolved": "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.25.0.tgz", - "integrity": "sha1-iO5IQzNgBc9aZMgGNs5ibwmW9QM= sha512-E6A5Y/ijqpfMJ5psJvbw0kVTzLZFUcOFgs6eSM2M2iWE1lVRF18T6hWZVNl6zqZsoz98jgnNHtVGJMs+ds9A7A==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.26.0.tgz", + "integrity": "sha512-Nq+COIjE1135T7qfnOHEn7E0q39bQTgXLFk837/rgFe6Hkew9WML7eHsS+lSYD2p3OJaTiUOHTAq1lHy36oIqQ==", "dependencies": { - "@project-serum/borsh": "^0.2.5", - "@solana/web3.js": "^1.36.0", + "@coral-xyz/borsh": "^0.26.0", + "@solana/web3.js": "^1.68.0", "base64-js": "^1.5.1", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", - "camelcase": "^5.3.1", + "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", @@ -369,20 +384,15 @@ "node": ">=11" } }, - "node_modules/@project-serum/anchor/node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/@project-serum/anchor/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" + "node_modules/@project-serum/anchor/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/@project-serum/anchor/node_modules/superstruct": { @@ -392,8 +402,8 @@ }, "node_modules/@project-serum/borsh": { "version": "0.2.5", - "resolved": "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz", - "integrity": "sha1-YFkoeqYk7Ou/wO3TXkwo/5h9hmM= sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", + "resolved": "https://registry.npmjs.org/@project-serum/borsh/-/borsh-0.2.5.tgz", + "integrity": "sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" @@ -514,9 +524,9 @@ } }, "node_modules/@solana/spl-token": { - "version": "0.3.5", - "resolved": "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.5.tgz", - "integrity": "sha1-yr+fktdVWJQgtG5Fe5sQqHnnVao= sha512-0bGC6n415lGjKu02gkLOIpP1wzndSP0SHwN9PefJ+wKAhmfU1rl3AV1Pa41uap2kzSCD6F9642ngNO8KXPvh/g==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz", + "integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==", "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", @@ -553,9 +563,9 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.70.3", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.70.3.tgz", - "integrity": "sha512-9JAFXAWB3yhUHnoahzemTz4TcsGqmITPArNlm9795e+LA/DYkIEJIXIosV4ImzDMfqolymZeRgG3O8ewNgYTTA==", + "version": "1.73.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.73.0.tgz", + "integrity": "sha512-YrgX3Py7ylh8NYkbanoINUPCj//bWUjYZ5/WPy9nQ9SK3Cl7QWCR+NmbDjmC/fTspZGR+VO9LTQslM++jr5PRw==", "dependencies": { "@babel/runtime": "^7.12.5", "@noble/ed25519": "^1.7.0", @@ -578,22 +588,6 @@ "node": ">=12.20.0" } }, - "node_modules/@solana/web3.js/node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/@solana/web3.js/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" - } - }, "node_modules/@switchboard-xyz/common": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/@switchboard-xyz/common/-/common-2.1.8.tgz", @@ -694,11 +688,6 @@ "@types/node": "*" } }, - "node_modules/@types/connect/node_modules/@types/node": { - "version": "18.11.2", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.2.tgz", - "integrity": "sha1-xZt2QYMlMSZP2j8bphA2Lcmn38g= sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==" - }, "node_modules/@types/expect": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/@types/expect/-/expect-24.3.0.tgz", @@ -765,9 +754,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.11.0", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.0.tgz", - "integrity": "sha1-84xxOSR6HWGfbMbyewcmBq98KJ0= sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w==" + "version": "18.11.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -789,11 +778,6 @@ "@types/node": "*" } }, - "node_modules/@types/ws/node_modules/@types/node": { - "version": "18.11.2", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.2.tgz", - "integrity": "sha1-xZt2QYMlMSZP2j8bphA2Lcmn38g= sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==" - }, "node_modules/@types/yargs": { "version": "17.0.14", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.14.tgz", @@ -1064,6 +1048,41 @@ "anchor-client-gen": "dist/main.js" } }, + "node_modules/anchor-client-gen/node_modules/@project-serum/anchor": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.25.0.tgz", + "integrity": "sha512-E6A5Y/ijqpfMJ5psJvbw0kVTzLZFUcOFgs6eSM2M2iWE1lVRF18T6hWZVNl6zqZsoz98jgnNHtVGJMs+ds9A7A==", + "dev": true, + "dependencies": { + "@project-serum/borsh": "^0.2.5", + "@solana/web3.js": "^1.36.0", + "base64-js": "^1.5.1", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^5.3.1", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "js-sha256": "^0.9.0", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/anchor-client-gen/node_modules/@project-serum/anchor/node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/anchor-client-gen/node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz", @@ -1076,6 +1095,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/anchor-client-gen/node_modules/superstruct": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", + "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==", + "dev": true + }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -1206,6 +1231,14 @@ "integrity": "sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4= sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/base-x": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", + "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz", @@ -1289,22 +1322,6 @@ "text-encoding-utf-8": "^1.0.2" } }, - "node_modules/borsh/node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/borsh/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" - } - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -1332,6 +1349,14 @@ "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA= sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "node_modules/bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "dependencies": { + "base-x": "^3.0.2" + } + }, "node_modules/buffer": { "version": "6.0.1", "resolved": "https://registry.yarnpkg.com/buffer/-/buffer-6.0.1.tgz", @@ -1395,6 +1420,7 @@ "version": "5.3.1", "resolved": "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA= sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, "engines": { "node": ">=6" } @@ -3182,9 +3208,9 @@ } }, "node_modules/marked": { - "version": "4.1.1", - "resolved": "https://registry.yarnpkg.com/marked/-/marked-4.1.1.tgz", - "integrity": "sha1-L3CaRGKr9looPyRT3BxCqxd9MC4= sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==", + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.2.5.tgz", + "integrity": "sha512-jPueVhumq7idETHkb203WDD4fMA3yV9emQ5vLwop58lu8bTclMghBWcYAavlDqIEMaisADinV1TooIFCfqOsYQ==", "dev": true, "bin": { "marked": "bin/marked.js" @@ -3219,6 +3245,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/meow/node_modules/type-fest": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", + "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz", @@ -4922,18 +4960,6 @@ "node": ">=4" } }, - "node_modules/type-fest": { - "version": "0.18.1", - "resolved": "https://registry.yarnpkg.com/type-fest/-/type-fest-0.18.1.tgz", - "integrity": "sha1-20vBUaSiz07r+a3V23VQjbbMhB8= sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", @@ -4944,14 +4970,14 @@ } }, "node_modules/typedoc": { - "version": "0.23.16", - "resolved": "https://registry.yarnpkg.com/typedoc/-/typedoc-0.23.16.tgz", - "integrity": "sha1-CYga2nJcIZCsXTuw7a3MW/7aS/4= sha512-rumYsCeNRXlyuZVzefD7050n7ptL2uudsCJg50dY0v/stKniqIlRpvx/F/6expC0/Q6Dbab+g/JpZuB7Sw90FA==", + "version": "0.23.23", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.23.tgz", + "integrity": "sha512-cg1YQWj+/BU6wq74iott513U16fbrPCbyYs04PHZgvoKJIc6EY4xNobyDZh4KMfRGW8Yjv6wwIzQyoqopKOUGw==", "dev": true, "dependencies": { "lunr": "^2.3.9", - "marked": "^4.0.19", - "minimatch": "^5.1.0", + "marked": "^4.2.4", + "minimatch": "^5.1.1", "shiki": "^0.11.1" }, "bin": { @@ -4961,13 +4987,13 @@ "node": ">= 14.14" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x" } }, "node_modules/typedoc/node_modules/minimatch": { - "version": "5.1.0", - "resolved": "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha1-Fxe0ZPSXGxRPaqvo8tC45FEeCcc= sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -4977,9 +5003,9 @@ } }, "node_modules/typescript": { - "version": "4.8.4", - "resolved": "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha1-xGSryhWWaVl75flriUNQCyOOYOY= sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -5342,6 +5368,15 @@ "regenerator-runtime": "^0.13.4" } }, + "@coral-xyz/borsh": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.26.0.tgz", + "integrity": "sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ==", + "requires": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + } + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -5489,17 +5524,17 @@ } }, "@project-serum/anchor": { - "version": "0.25.0", - "resolved": "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.25.0.tgz", - "integrity": "sha1-iO5IQzNgBc9aZMgGNs5ibwmW9QM= sha512-E6A5Y/ijqpfMJ5psJvbw0kVTzLZFUcOFgs6eSM2M2iWE1lVRF18T6hWZVNl6zqZsoz98jgnNHtVGJMs+ds9A7A==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.26.0.tgz", + "integrity": "sha512-Nq+COIjE1135T7qfnOHEn7E0q39bQTgXLFk837/rgFe6Hkew9WML7eHsS+lSYD2p3OJaTiUOHTAq1lHy36oIqQ==", "requires": { - "@project-serum/borsh": "^0.2.5", - "@solana/web3.js": "^1.36.0", + "@coral-xyz/borsh": "^0.26.0", + "@solana/web3.js": "^1.68.0", "base64-js": "^1.5.1", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", - "camelcase": "^5.3.1", + "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", @@ -5510,21 +5545,10 @@ "toml": "^3.0.0" }, "dependencies": { - "base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "requires": { - "base-x": "^3.0.2" - } + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==" }, "superstruct": { "version": "0.15.5", @@ -5535,8 +5559,8 @@ }, "@project-serum/borsh": { "version": "0.2.5", - "resolved": "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz", - "integrity": "sha1-YFkoeqYk7Ou/wO3TXkwo/5h9hmM= sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", + "resolved": "https://registry.npmjs.org/@project-serum/borsh/-/borsh-0.2.5.tgz", + "integrity": "sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", "requires": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" @@ -5633,9 +5657,9 @@ } }, "@solana/spl-token": { - "version": "0.3.5", - "resolved": "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.5.tgz", - "integrity": "sha1-yr+fktdVWJQgtG5Fe5sQqHnnVao= sha512-0bGC6n415lGjKu02gkLOIpP1wzndSP0SHwN9PefJ+wKAhmfU1rl3AV1Pa41uap2kzSCD6F9642ngNO8KXPvh/g==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz", + "integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==", "requires": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", @@ -5654,9 +5678,9 @@ } }, "@solana/web3.js": { - "version": "1.70.3", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.70.3.tgz", - "integrity": "sha512-9JAFXAWB3yhUHnoahzemTz4TcsGqmITPArNlm9795e+LA/DYkIEJIXIosV4ImzDMfqolymZeRgG3O8ewNgYTTA==", + "version": "1.73.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.73.0.tgz", + "integrity": "sha512-YrgX3Py7ylh8NYkbanoINUPCj//bWUjYZ5/WPy9nQ9SK3Cl7QWCR+NmbDjmC/fTspZGR+VO9LTQslM++jr5PRw==", "requires": { "@babel/runtime": "^7.12.5", "@noble/ed25519": "^1.7.0", @@ -5674,24 +5698,6 @@ "node-fetch": "2", "rpc-websockets": "^7.5.0", "superstruct": "^0.14.2" - }, - "dependencies": { - "base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "requires": { - "base-x": "^3.0.2" - } - } } }, "@switchboard-xyz/common": { @@ -5785,13 +5791,6 @@ "integrity": "sha1-X89q5EXkAh0fwiGaSHPMc6O7KtE= sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", "requires": { "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "18.11.2", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.2.tgz", - "integrity": "sha1-xZt2QYMlMSZP2j8bphA2Lcmn38g= sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==" - } } }, "@types/expect": { @@ -5859,9 +5858,9 @@ "dev": true }, "@types/node": { - "version": "18.11.0", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.0.tgz", - "integrity": "sha1-84xxOSR6HWGfbMbyewcmBq98KJ0= sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w==" + "version": "18.11.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, "@types/normalize-package-data": { "version": "2.4.1", @@ -5881,13 +5880,6 @@ "integrity": "sha1-98OQo296Bnmqad4tUBMZ9PjZtwI= sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", "requires": { "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "18.11.2", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-18.11.2.tgz", - "integrity": "sha1-xZt2QYMlMSZP2j8bphA2Lcmn38g= sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==" - } } }, "@types/yargs": { @@ -6058,11 +6050,48 @@ "ts-morph": "^14.0.0" }, "dependencies": { + "@project-serum/anchor": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.25.0.tgz", + "integrity": "sha512-E6A5Y/ijqpfMJ5psJvbw0kVTzLZFUcOFgs6eSM2M2iWE1lVRF18T6hWZVNl6zqZsoz98jgnNHtVGJMs+ds9A7A==", + "dev": true, + "requires": { + "@project-serum/borsh": "^0.2.5", + "@solana/web3.js": "^1.36.0", + "base64-js": "^1.5.1", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^5.3.1", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "js-sha256": "^0.9.0", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + } + } + }, "camelcase": { "version": "6.3.0", "resolved": "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha1-VoW5XrIJrJwMF3Rnd4ychN9Yupo= sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true + }, + "superstruct": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", + "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==", + "dev": true } } }, @@ -6159,6 +6188,14 @@ "integrity": "sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4= sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "base-x": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", + "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz", @@ -6209,24 +6246,6 @@ "bn.js": "^5.2.0", "bs58": "^4.0.0", "text-encoding-utf-8": "^1.0.2" - }, - "dependencies": { - "base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "requires": { - "base-x": "^3.0.2" - } - } } }, "brace-expansion": { @@ -6253,6 +6272,14 @@ "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA= sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "requires": { + "base-x": "^3.0.2" + } + }, "buffer": { "version": "6.0.1", "resolved": "https://registry.yarnpkg.com/buffer/-/buffer-6.0.1.tgz", @@ -6291,7 +6318,8 @@ "camelcase": { "version": "5.3.1", "resolved": "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA= sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + "integrity": "sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA= sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true }, "camelcase-keys": { "version": "6.2.2", @@ -7635,9 +7663,9 @@ "dev": true }, "marked": { - "version": "4.1.1", - "resolved": "https://registry.yarnpkg.com/marked/-/marked-4.1.1.tgz", - "integrity": "sha1-L3CaRGKr9looPyRT3BxCqxd9MC4= sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==", + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.2.5.tgz", + "integrity": "sha512-jPueVhumq7idETHkb203WDD4fMA3yV9emQ5vLwop58lu8bTclMghBWcYAavlDqIEMaisADinV1TooIFCfqOsYQ==", "dev": true }, "meow": { @@ -7658,6 +7686,14 @@ "trim-newlines": "^3.0.0", "type-fest": "^0.18.0", "yargs-parser": "^20.2.3" + }, + "dependencies": { + "type-fest": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", + "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", + "dev": true + } } }, "merge-stream": { @@ -8898,12 +8934,6 @@ "integrity": "sha1-dkb7XxiHHPu3dJ5pvTmmOI63RQw= sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, - "type-fest": { - "version": "0.18.1", - "resolved": "https://registry.yarnpkg.com/type-fest/-/type-fest-0.18.1.tgz", - "integrity": "sha1-20vBUaSiz07r+a3V23VQjbbMhB8= sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", - "dev": true - }, "typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", @@ -8914,21 +8944,21 @@ } }, "typedoc": { - "version": "0.23.16", - "resolved": "https://registry.yarnpkg.com/typedoc/-/typedoc-0.23.16.tgz", - "integrity": "sha1-CYga2nJcIZCsXTuw7a3MW/7aS/4= sha512-rumYsCeNRXlyuZVzefD7050n7ptL2uudsCJg50dY0v/stKniqIlRpvx/F/6expC0/Q6Dbab+g/JpZuB7Sw90FA==", + "version": "0.23.23", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.23.tgz", + "integrity": "sha512-cg1YQWj+/BU6wq74iott513U16fbrPCbyYs04PHZgvoKJIc6EY4xNobyDZh4KMfRGW8Yjv6wwIzQyoqopKOUGw==", "dev": true, "requires": { "lunr": "^2.3.9", - "marked": "^4.0.19", - "minimatch": "^5.1.0", + "marked": "^4.2.4", + "minimatch": "^5.1.1", "shiki": "^0.11.1" }, "dependencies": { "minimatch": { - "version": "5.1.0", - "resolved": "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha1-Fxe0ZPSXGxRPaqvo8tC45FEeCcc= sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", "dev": true, "requires": { "brace-expansion": "^2.0.1" @@ -8937,9 +8967,9 @@ } }, "typescript": { - "version": "4.8.4", - "resolved": "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha1-xGSryhWWaVl75flriUNQCyOOYOY= sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true }, "uri-js": { diff --git a/javascript/solana.js/package.json b/javascript/solana.js/package.json index a02c731..ee96d3d 100644 --- a/javascript/solana.js/package.json +++ b/javascript/solana.js/package.json @@ -59,10 +59,10 @@ "fix": "gts fix" }, "dependencies": { - "@project-serum/anchor": "^0.25.0", + "@project-serum/anchor": "^0.26.0", "@project-serum/borsh": "^0.2.5", - "@solana/spl-token": "^0.3.5", - "@solana/web3.js": "^1.70.3", + "@solana/spl-token": "^0.3.6", + "@solana/web3.js": "^1.73.0", "@switchboard-xyz/common": "^2.1.8", "big.js": "^6.2.1", "bn.js": "^5.2.1", @@ -76,7 +76,7 @@ "@types/expect": "^24.3.0", "@types/lodash": "^4.14.191", "@types/mocha": "^10.0.0", - "@types/node": "^18.11.0", + "@types/node": "^18.11.18", "anchor-client-gen": "^0.25.0", "chai": "^4.3.7", "chalk": "^4.1.2", @@ -86,8 +86,8 @@ "shx": "^0.3.4", "ts-mocha": "^10.0.0", "ts-node": "^10.9.1", - "typedoc": "^0.23.16", - "typescript": "^4.8.4" + "typedoc": "^0.23.23", + "typescript": "^4.9.4" }, "pre-commit": [ "build" diff --git a/javascript/solana.js/src/SwitchboardProgram.ts b/javascript/solana.js/src/SwitchboardProgram.ts index 790092f..d50a41e 100644 --- a/javascript/solana.js/src/SwitchboardProgram.ts +++ b/javascript/solana.js/src/SwitchboardProgram.ts @@ -296,7 +296,7 @@ export class SwitchboardProgram { return this._program.programId; } /** - * The Switchboard Program ID for the currently connected cluster. + * The Switchboard Program IDL. */ public get idl(): anchor.Idl { return this._program.idl; diff --git a/javascript/solana.js/src/accounts/aggregatorAccount.ts b/javascript/solana.js/src/accounts/aggregatorAccount.ts index 0c49803..9585c62 100644 --- a/javascript/solana.js/src/accounts/aggregatorAccount.ts +++ b/javascript/solana.js/src/accounts/aggregatorAccount.ts @@ -31,6 +31,7 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token'; import { AggregatorHistoryBuffer } from './aggregatorHistoryBuffer'; import { CrankAccount } from './crankAccount'; import assert from 'assert'; +import { BN } from 'bn.js'; /** * Account type holding a data feed's update configuration, job accounts, and its current result. @@ -1802,6 +1803,51 @@ export class AggregatorAccount extends Account { return aggregators; } + + /** + * Calculates the required priority fee for a given aggregator + * + * Multiplier = the minimum of maxPriorityFeeMultiplier and (timestamp - lastUpdatedTimestamp) / priorityFeeBumpPeriod + * Fee = baseFee + basePriorityFee + priorityFeeBump * multiplier + * + * @param aggregator - the current aggregator state including its last updated timestamp and priority fee config + * @param timestamp - optional, the current unix timestamp. can provide the SolanaClock timestamp for better accuracy + * @param baseFee - optional, the Solana compute unit base fee + * + * @returns the solana priority fee to include in the save_result action + */ + public static calculatePriorityFee( + aggregator: types.AggregatorAccountData, + timestamp = Math.round(Date.now() / 1000), + baseFee = 5000 // base compute unit price + ): number { + // parse defaults + const lastUpdateTimestamp = + aggregator.latestConfirmedRound.roundOpenTimestamp.gt(new BN(0)) + ? aggregator.latestConfirmedRound.roundOpenTimestamp.toNumber() + : timestamp; // on first update this would cause max multiplier + const priorityFeeBumpPeriod = Math.max(1, aggregator.priorityFeeBumpPeriod); // cant divide by 0 + const maxPriorityFeeMultiplier = Math.max( + 1, + aggregator.maxPriorityFeeMultiplier + ); + + // calculate staleness multiplier + const multiplier = Math.min( + (timestamp - lastUpdateTimestamp) / priorityFeeBumpPeriod, + maxPriorityFeeMultiplier + ); + + const feeBump = aggregator.priorityFeeBump * multiplier; + const fee = baseFee + aggregator.basePriorityFee + feeBump; + if (Number.isNaN(fee)) { + return 0; + } + + // Should we enforce some upper limit? Like 1 SOL? + // Probably not, gives MEV bots a floor + return Math.round(fee); + } } /** diff --git a/javascript/solana.js/test/priority-fees.spec.ts b/javascript/solana.js/test/priority-fees.spec.ts new file mode 100644 index 0000000..deaa14f --- /dev/null +++ b/javascript/solana.js/test/priority-fees.spec.ts @@ -0,0 +1,84 @@ +/* eslint-disable no-unused-vars */ +import 'mocha'; +import assert from 'assert'; + +import { AggregatorAccount, types } from '../src'; +import { BN } from 'bn.js'; + +describe('Priority Fees Tests', () => { + const defaultState = AggregatorAccount.default(); + + const startingTimestamp = 100; + const basePriorityFee = 1000; // always bump fee by 1000 lamports + const priorityFeeBump = 500; // bump fee by 500 lamports for every period the feed is stale + const priorityFeeBumpPeriod = 30; // bump fee by priorityFeeBump every 30s + const maxPriorityFeeMultiplier = 10; // the max fee multiplier is 10 * 500 lamports + + const aggregatorFields: types.AggregatorAccountDataFields = { + ...defaultState, + basePriorityFee: basePriorityFee, + priorityFeeBump: priorityFeeBump, + priorityFeeBumpPeriod: priorityFeeBumpPeriod, + maxPriorityFeeMultiplier: maxPriorityFeeMultiplier, + latestConfirmedRound: { + ...defaultState.latestConfirmedRound, + roundOpenTimestamp: new BN(startingTimestamp), + }, + }; + const aggregator = new types.AggregatorAccountData(aggregatorFields); + + it('Calculates the priority fee with no staleness', async () => { + // no staleness + const noStalenessFee = AggregatorAccount.calculatePriorityFee( + aggregator, + startingTimestamp + ); + const expectedNoStalenessFee = Math.round(5000 + basePriorityFee); + assert( + expectedNoStalenessFee === noStalenessFee, + `priorityFee mismatch with no staleness, expected ${expectedNoStalenessFee}, received ${noStalenessFee}` + ); + }); + + it('Calculates the priority fee with staleness multiplier', async () => { + // with staleness + const multipliers = [0.5, 1, 1.33333, 1.8323232, 2, 5, 10]; + for (const multiplier of multipliers) { + const priorityFee = AggregatorAccount.calculatePriorityFee( + aggregator, + startingTimestamp + multiplier * priorityFeeBumpPeriod + ); + const expectedPriorityFee = Math.round( + 5000 + basePriorityFee + multiplier * priorityFeeBump + ); + assert( + expectedPriorityFee === priorityFee, + `priorityFee mismatch for multiplier ${multiplier}, expected ${expectedPriorityFee}, received ${priorityFee}` + ); + } + }); + + it('Calculates the priority fee with max multiplier', async () => { + // with max multiplier + const expectedPriorityFee = Math.round( + 5000 + basePriorityFee + maxPriorityFeeMultiplier * priorityFeeBump + ); // should never exceed this + + const multipliers = [ + maxPriorityFeeMultiplier + 1, + maxPriorityFeeMultiplier * 2, + maxPriorityFeeMultiplier * 10, + ]; + + for (const multiplier of multipliers) { + const priorityFee = AggregatorAccount.calculatePriorityFee( + aggregator, + startingTimestamp + multiplier * priorityFeeBumpPeriod + ); + assert( + expectedPriorityFee === priorityFee, + `priorityFee mismatch for max multiplier, expected ${expectedPriorityFee}, received ${priorityFee}` + ); + } + }); +});