├── .babelrc ├── .github ├── CODEOWNERS ├── actions │ └── setup │ │ └── action.yml └── workflows │ └── test.yml ├── .gitignore ├── .yarnrc ├── LICENSE ├── README.md ├── package.json ├── setupTests.js ├── src ├── abis │ ├── json │ │ ├── ERC20ABI.json │ │ ├── JoePairABI.json │ │ ├── RocketJoeStakingABI.json │ │ ├── RouterABI.json │ │ ├── StableJoeStakingABI.json │ │ ├── VeJoeABI.json │ │ ├── VeJoeStakingABI.json │ │ ├── WNativeABI.json │ │ ├── XJoeStakingABI.json │ │ └── index.ts │ └── ts │ │ ├── ERC20.ts │ │ ├── JoePair.ts │ │ ├── RocketJoeStaking.ts │ │ ├── Router.ts │ │ ├── StableJoeStaking.ts │ │ ├── VeJoe.ts │ │ ├── VeJoeStaking.ts │ │ ├── WNative.ts │ │ ├── XJoeStaking.ts │ │ └── index.ts ├── constants.ts ├── declarations.d.ts ├── entities │ ├── currency.ts │ ├── fractions │ │ ├── currencyAmount.ts │ │ ├── fraction.ts │ │ ├── index.ts │ │ ├── percent.ts │ │ ├── price.ts │ │ └── tokenAmount.ts │ ├── index.ts │ ├── pair.ts │ ├── route.ts │ ├── token.ts │ └── trade.ts ├── errors.ts ├── fetcher.ts ├── index.ts ├── router.ts ├── subgraphs.ts └── utils.ts ├── test ├── abis.test.ts ├── currency.test.ts ├── data.test.ts ├── entities.test.ts ├── fraction.test.ts ├── miscellaneous.test.ts ├── pair.test.ts ├── route.test.ts ├── router.test.ts ├── token.test.ts └── trade.test.ts ├── tsconfig.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [] // "transform-jsbi-to-bigint" 3 | } 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Global Owners 2 | 3 | * @cryptofish7 @0xmurloc 4 | -------------------------------------------------------------------------------- /.github/actions/setup/action.yml: -------------------------------------------------------------------------------- 1 | name: Setup 2 | runs: 3 | using: composite 4 | steps: 5 | - uses: actions/checkout@v3 6 | 7 | - uses: actions/setup-node@v3 8 | with: 9 | node-version: 16 10 | registry-url: https://registry.npmjs.org 11 | cache: yarn 12 | 13 | - uses: actions/cache@v3 14 | id: install-cache 15 | with: 16 | path: node_modules/ 17 | key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }} 18 | 19 | - if: steps.install-cache.outputs.cache-hit != 'true' 20 | run: yarn install --frozen-lockfile --ignore-scripts 21 | shell: bash 22 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | # manual trigger 9 | workflow_dispatch: 10 | 11 | jobs: 12 | lint: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: ./.github/actions/setup 17 | - run: yarn lint 18 | 19 | unit-tests: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v3 23 | - uses: ./.github/actions/setup 24 | - run: yarn test 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | yarn-error.log -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | ignore-scripts true 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Noah Zinsmeister 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trader Joe SDK 2 | This repo contains tools for developing with [TraderJoe XYZ](https://www.traderjoexyz.com). 3 | 4 | ## Running 5 | This project uses standard npm and yarn workflows. 6 | 7 | Install dependencies 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | Compile 14 | ```sh 15 | yarn build 16 | ``` 17 | 18 | ## Installation 19 | This project is available as an npm package. Add to your project with `npm install @traderjoe-xyz/sdk` 20 | 21 | ## Attribution 22 | This code was adapted from this Uniswap repo: [uniswap-sdk](https://github.com/Uniswap/sdk). 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@traderjoe-xyz/sdk", 3 | "license": "MIT", 4 | "version": "4.0.7", 5 | "description": "🛠 An SDK for building applications on top of Trader Joe.", 6 | "main": "dist/index.js", 7 | "typings": "dist/index.d.ts", 8 | "files": [ 9 | "dist" 10 | ], 11 | "repository": "https://github.com/traderjoe-xyz/joe-sdk", 12 | "keywords": [ 13 | "traderjoe-xyz", 14 | "avalanche" 15 | ], 16 | "module": "dist/sdk.esm.js", 17 | "scripts": { 18 | "lint": "tsdx lint src test", 19 | "build": "tsdx build", 20 | "start": "tsdx watch", 21 | "test": "tsdx test", 22 | "prepublishOnly": "tsdx build" 23 | }, 24 | "dependencies": { 25 | "big.js": "^5.2.2", 26 | "decimal.js-light": "^2.5.0", 27 | "jsbi": "^3.1.1", 28 | "tiny-invariant": "^1.1.0", 29 | "tiny-warning": "^1.0.3", 30 | "toformat": "^2.0.0" 31 | }, 32 | "peerDependencies": { 33 | "viem": ">=0.3.35" 34 | }, 35 | "devDependencies": { 36 | "@types/big.js": "^4.0.5", 37 | "@types/jest": "^24.0.25", 38 | "babel-plugin-transform-jsbi-to-bigint": "^1.3.1", 39 | "tsdx": "^0.14.1", 40 | "viem": "^0.3.35", 41 | "yarn-deduplicate": "^6.0.2" 42 | }, 43 | "resolutions": { 44 | "tsdx/typescript": "^4.9.4", 45 | "tsdx/@typescript-eslint/eslint-plugin": "^5.49.0", 46 | "tsdx/@typescript-eslint/parser": "^5.49.0" 47 | }, 48 | "engines": { 49 | "node": ">=10" 50 | }, 51 | "prettier": { 52 | "printWidth": 120, 53 | "semi": false, 54 | "singleQuote": true 55 | }, 56 | "jest": { 57 | "setupFilesAfterEnv": [ 58 | "./setupTests.js" 59 | ] 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /setupTests.js: -------------------------------------------------------------------------------- 1 | const { TextEncoder, TextDecoder } = require('util') 2 | global.TextEncoder = TextEncoder 3 | global.TextDecoder = TextDecoder 4 | -------------------------------------------------------------------------------- /src/abis/json/ERC20ABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "string", 6 | "name": "name_", 7 | "type": "string" 8 | }, 9 | { 10 | "internalType": "string", 11 | "name": "symbol_", 12 | "type": "string" 13 | } 14 | ], 15 | "stateMutability": "nonpayable", 16 | "type": "constructor" 17 | }, 18 | { 19 | "anonymous": false, 20 | "inputs": [ 21 | { 22 | "indexed": true, 23 | "internalType": "address", 24 | "name": "owner", 25 | "type": "address" 26 | }, 27 | { 28 | "indexed": true, 29 | "internalType": "address", 30 | "name": "spender", 31 | "type": "address" 32 | }, 33 | { 34 | "indexed": false, 35 | "internalType": "uint256", 36 | "name": "value", 37 | "type": "uint256" 38 | } 39 | ], 40 | "name": "Approval", 41 | "type": "event" 42 | }, 43 | { 44 | "anonymous": false, 45 | "inputs": [ 46 | { 47 | "indexed": true, 48 | "internalType": "address", 49 | "name": "from", 50 | "type": "address" 51 | }, 52 | { 53 | "indexed": true, 54 | "internalType": "address", 55 | "name": "to", 56 | "type": "address" 57 | }, 58 | { 59 | "indexed": false, 60 | "internalType": "uint256", 61 | "name": "value", 62 | "type": "uint256" 63 | } 64 | ], 65 | "name": "Transfer", 66 | "type": "event" 67 | }, 68 | { 69 | "inputs": [ 70 | { 71 | "internalType": "address", 72 | "name": "owner", 73 | "type": "address" 74 | }, 75 | { 76 | "internalType": "address", 77 | "name": "spender", 78 | "type": "address" 79 | } 80 | ], 81 | "name": "allowance", 82 | "outputs": [ 83 | { 84 | "internalType": "uint256", 85 | "name": "", 86 | "type": "uint256" 87 | } 88 | ], 89 | "stateMutability": "view", 90 | "type": "function" 91 | }, 92 | { 93 | "inputs": [ 94 | { 95 | "internalType": "address", 96 | "name": "spender", 97 | "type": "address" 98 | }, 99 | { 100 | "internalType": "uint256", 101 | "name": "amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "name": "approve", 106 | "outputs": [ 107 | { 108 | "internalType": "bool", 109 | "name": "", 110 | "type": "bool" 111 | } 112 | ], 113 | "stateMutability": "nonpayable", 114 | "type": "function" 115 | }, 116 | { 117 | "inputs": [ 118 | { 119 | "internalType": "address", 120 | "name": "account", 121 | "type": "address" 122 | } 123 | ], 124 | "name": "balanceOf", 125 | "outputs": [ 126 | { 127 | "internalType": "uint256", 128 | "name": "", 129 | "type": "uint256" 130 | } 131 | ], 132 | "stateMutability": "view", 133 | "type": "function" 134 | }, 135 | { 136 | "inputs": [], 137 | "name": "decimals", 138 | "outputs": [ 139 | { 140 | "internalType": "uint8", 141 | "name": "", 142 | "type": "uint8" 143 | } 144 | ], 145 | "stateMutability": "view", 146 | "type": "function" 147 | }, 148 | { 149 | "inputs": [ 150 | { 151 | "internalType": "address", 152 | "name": "spender", 153 | "type": "address" 154 | }, 155 | { 156 | "internalType": "uint256", 157 | "name": "subtractedValue", 158 | "type": "uint256" 159 | } 160 | ], 161 | "name": "decreaseAllowance", 162 | "outputs": [ 163 | { 164 | "internalType": "bool", 165 | "name": "", 166 | "type": "bool" 167 | } 168 | ], 169 | "stateMutability": "nonpayable", 170 | "type": "function" 171 | }, 172 | { 173 | "inputs": [ 174 | { 175 | "internalType": "address", 176 | "name": "spender", 177 | "type": "address" 178 | }, 179 | { 180 | "internalType": "uint256", 181 | "name": "addedValue", 182 | "type": "uint256" 183 | } 184 | ], 185 | "name": "increaseAllowance", 186 | "outputs": [ 187 | { 188 | "internalType": "bool", 189 | "name": "", 190 | "type": "bool" 191 | } 192 | ], 193 | "stateMutability": "nonpayable", 194 | "type": "function" 195 | }, 196 | { 197 | "inputs": [], 198 | "name": "name", 199 | "outputs": [ 200 | { 201 | "internalType": "string", 202 | "name": "", 203 | "type": "string" 204 | } 205 | ], 206 | "stateMutability": "view", 207 | "type": "function" 208 | }, 209 | { 210 | "inputs": [], 211 | "name": "symbol", 212 | "outputs": [ 213 | { 214 | "internalType": "string", 215 | "name": "", 216 | "type": "string" 217 | } 218 | ], 219 | "stateMutability": "view", 220 | "type": "function" 221 | }, 222 | { 223 | "inputs": [], 224 | "name": "totalSupply", 225 | "outputs": [ 226 | { 227 | "internalType": "uint256", 228 | "name": "", 229 | "type": "uint256" 230 | } 231 | ], 232 | "stateMutability": "view", 233 | "type": "function" 234 | }, 235 | { 236 | "inputs": [ 237 | { 238 | "internalType": "address", 239 | "name": "recipient", 240 | "type": "address" 241 | }, 242 | { 243 | "internalType": "uint256", 244 | "name": "amount", 245 | "type": "uint256" 246 | } 247 | ], 248 | "name": "transfer", 249 | "outputs": [ 250 | { 251 | "internalType": "bool", 252 | "name": "", 253 | "type": "bool" 254 | } 255 | ], 256 | "stateMutability": "nonpayable", 257 | "type": "function" 258 | }, 259 | { 260 | "inputs": [ 261 | { 262 | "internalType": "address", 263 | "name": "sender", 264 | "type": "address" 265 | }, 266 | { 267 | "internalType": "address", 268 | "name": "recipient", 269 | "type": "address" 270 | }, 271 | { 272 | "internalType": "uint256", 273 | "name": "amount", 274 | "type": "uint256" 275 | } 276 | ], 277 | "name": "transferFrom", 278 | "outputs": [ 279 | { 280 | "internalType": "bool", 281 | "name": "", 282 | "type": "bool" 283 | } 284 | ], 285 | "stateMutability": "nonpayable", 286 | "type": "function" 287 | } 288 | ] 289 | -------------------------------------------------------------------------------- /src/abis/json/JoePairABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, 3 | { 4 | "anonymous": false, 5 | "inputs": [ 6 | { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, 7 | { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, 8 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 9 | ], 10 | "name": "Approval", 11 | "type": "event" 12 | }, 13 | { 14 | "anonymous": false, 15 | "inputs": [ 16 | { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, 17 | { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, 18 | { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }, 19 | { "indexed": true, "internalType": "address", "name": "to", "type": "address" } 20 | ], 21 | "name": "Burn", 22 | "type": "event" 23 | }, 24 | { 25 | "anonymous": false, 26 | "inputs": [ 27 | { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, 28 | { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, 29 | { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" } 30 | ], 31 | "name": "Mint", 32 | "type": "event" 33 | }, 34 | { 35 | "anonymous": false, 36 | "inputs": [ 37 | { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, 38 | { "indexed": false, "internalType": "uint256", "name": "amount0In", "type": "uint256" }, 39 | { "indexed": false, "internalType": "uint256", "name": "amount1In", "type": "uint256" }, 40 | { "indexed": false, "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, 41 | { "indexed": false, "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, 42 | { "indexed": true, "internalType": "address", "name": "to", "type": "address" } 43 | ], 44 | "name": "Swap", 45 | "type": "event" 46 | }, 47 | { 48 | "anonymous": false, 49 | "inputs": [ 50 | { "indexed": false, "internalType": "uint112", "name": "reserve0", "type": "uint112" }, 51 | { "indexed": false, "internalType": "uint112", "name": "reserve1", "type": "uint112" } 52 | ], 53 | "name": "Sync", 54 | "type": "event" 55 | }, 56 | { 57 | "anonymous": false, 58 | "inputs": [ 59 | { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, 60 | { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, 61 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 62 | ], 63 | "name": "Transfer", 64 | "type": "event" 65 | }, 66 | { 67 | "inputs": [], 68 | "name": "DOMAIN_SEPARATOR", 69 | "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], 70 | "stateMutability": "view", 71 | "type": "function" 72 | }, 73 | { 74 | "inputs": [], 75 | "name": "MINIMUM_LIQUIDITY", 76 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 77 | "stateMutability": "view", 78 | "type": "function" 79 | }, 80 | { 81 | "inputs": [], 82 | "name": "PERMIT_TYPEHASH", 83 | "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], 84 | "stateMutability": "view", 85 | "type": "function" 86 | }, 87 | { 88 | "inputs": [ 89 | { "internalType": "address", "name": "", "type": "address" }, 90 | { "internalType": "address", "name": "", "type": "address" } 91 | ], 92 | "name": "allowance", 93 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 94 | "stateMutability": "view", 95 | "type": "function" 96 | }, 97 | { 98 | "inputs": [ 99 | { "internalType": "address", "name": "spender", "type": "address" }, 100 | { "internalType": "uint256", "name": "value", "type": "uint256" } 101 | ], 102 | "name": "approve", 103 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 104 | "stateMutability": "nonpayable", 105 | "type": "function" 106 | }, 107 | { 108 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }], 109 | "name": "balanceOf", 110 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 111 | "stateMutability": "view", 112 | "type": "function" 113 | }, 114 | { 115 | "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], 116 | "name": "burn", 117 | "outputs": [ 118 | { "internalType": "uint256", "name": "amount0", "type": "uint256" }, 119 | { "internalType": "uint256", "name": "amount1", "type": "uint256" } 120 | ], 121 | "stateMutability": "nonpayable", 122 | "type": "function" 123 | }, 124 | { 125 | "inputs": [], 126 | "name": "decimals", 127 | "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], 128 | "stateMutability": "view", 129 | "type": "function" 130 | }, 131 | { 132 | "inputs": [], 133 | "name": "factory", 134 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 135 | "stateMutability": "view", 136 | "type": "function" 137 | }, 138 | { 139 | "inputs": [], 140 | "name": "getReserves", 141 | "outputs": [ 142 | { "internalType": "uint112", "name": "_reserve0", "type": "uint112" }, 143 | { "internalType": "uint112", "name": "_reserve1", "type": "uint112" }, 144 | { "internalType": "uint32", "name": "_blockTimestampLast", "type": "uint32" } 145 | ], 146 | "stateMutability": "view", 147 | "type": "function" 148 | }, 149 | { 150 | "inputs": [ 151 | { "internalType": "address", "name": "_token0", "type": "address" }, 152 | { "internalType": "address", "name": "_token1", "type": "address" } 153 | ], 154 | "name": "initialize", 155 | "outputs": [], 156 | "stateMutability": "nonpayable", 157 | "type": "function" 158 | }, 159 | { 160 | "inputs": [], 161 | "name": "kLast", 162 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 163 | "stateMutability": "view", 164 | "type": "function" 165 | }, 166 | { 167 | "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], 168 | "name": "mint", 169 | "outputs": [{ "internalType": "uint256", "name": "liquidity", "type": "uint256" }], 170 | "stateMutability": "nonpayable", 171 | "type": "function" 172 | }, 173 | { 174 | "inputs": [], 175 | "name": "name", 176 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 177 | "stateMutability": "view", 178 | "type": "function" 179 | }, 180 | { 181 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }], 182 | "name": "nonces", 183 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 184 | "stateMutability": "view", 185 | "type": "function" 186 | }, 187 | { 188 | "inputs": [ 189 | { "internalType": "address", "name": "owner", "type": "address" }, 190 | { "internalType": "address", "name": "spender", "type": "address" }, 191 | { "internalType": "uint256", "name": "value", "type": "uint256" }, 192 | { "internalType": "uint256", "name": "deadline", "type": "uint256" }, 193 | { "internalType": "uint8", "name": "v", "type": "uint8" }, 194 | { "internalType": "bytes32", "name": "r", "type": "bytes32" }, 195 | { "internalType": "bytes32", "name": "s", "type": "bytes32" } 196 | ], 197 | "name": "permit", 198 | "outputs": [], 199 | "stateMutability": "nonpayable", 200 | "type": "function" 201 | }, 202 | { 203 | "inputs": [], 204 | "name": "price0CumulativeLast", 205 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 206 | "stateMutability": "view", 207 | "type": "function" 208 | }, 209 | { 210 | "inputs": [], 211 | "name": "price1CumulativeLast", 212 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 213 | "stateMutability": "view", 214 | "type": "function" 215 | }, 216 | { 217 | "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], 218 | "name": "skim", 219 | "outputs": [], 220 | "stateMutability": "nonpayable", 221 | "type": "function" 222 | }, 223 | { 224 | "inputs": [ 225 | { "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, 226 | { "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, 227 | { "internalType": "address", "name": "to", "type": "address" }, 228 | { "internalType": "bytes", "name": "data", "type": "bytes" } 229 | ], 230 | "name": "swap", 231 | "outputs": [], 232 | "stateMutability": "nonpayable", 233 | "type": "function" 234 | }, 235 | { 236 | "inputs": [], 237 | "name": "symbol", 238 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 239 | "stateMutability": "view", 240 | "type": "function" 241 | }, 242 | { "inputs": [], "name": "sync", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 243 | { 244 | "inputs": [], 245 | "name": "token0", 246 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 247 | "stateMutability": "view", 248 | "type": "function" 249 | }, 250 | { 251 | "inputs": [], 252 | "name": "token1", 253 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 254 | "stateMutability": "view", 255 | "type": "function" 256 | }, 257 | { 258 | "inputs": [], 259 | "name": "totalSupply", 260 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 261 | "stateMutability": "view", 262 | "type": "function" 263 | }, 264 | { 265 | "inputs": [ 266 | { "internalType": "address", "name": "to", "type": "address" }, 267 | { "internalType": "uint256", "name": "value", "type": "uint256" } 268 | ], 269 | "name": "transfer", 270 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 271 | "stateMutability": "nonpayable", 272 | "type": "function" 273 | }, 274 | { 275 | "inputs": [ 276 | { "internalType": "address", "name": "from", "type": "address" }, 277 | { "internalType": "address", "name": "to", "type": "address" }, 278 | { "internalType": "uint256", "name": "value", "type": "uint256" } 279 | ], 280 | "name": "transferFrom", 281 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 282 | "stateMutability": "nonpayable", 283 | "type": "function" 284 | } 285 | ] 286 | -------------------------------------------------------------------------------- /src/abis/json/RocketJoeStakingABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "address", 8 | "name": "user", 9 | "type": "address" 10 | }, 11 | { 12 | "indexed": false, 13 | "internalType": "uint256", 14 | "name": "amount", 15 | "type": "uint256" 16 | } 17 | ], 18 | "name": "Deposit", 19 | "type": "event" 20 | }, 21 | { 22 | "anonymous": false, 23 | "inputs": [ 24 | { 25 | "indexed": true, 26 | "internalType": "address", 27 | "name": "user", 28 | "type": "address" 29 | }, 30 | { 31 | "indexed": false, 32 | "internalType": "uint256", 33 | "name": "amount", 34 | "type": "uint256" 35 | } 36 | ], 37 | "name": "EmergencyWithdraw", 38 | "type": "event" 39 | }, 40 | { 41 | "anonymous": false, 42 | "inputs": [ 43 | { 44 | "indexed": true, 45 | "internalType": "address", 46 | "name": "previousOwner", 47 | "type": "address" 48 | }, 49 | { 50 | "indexed": true, 51 | "internalType": "address", 52 | "name": "newOwner", 53 | "type": "address" 54 | } 55 | ], 56 | "name": "OwnershipTransferred", 57 | "type": "event" 58 | }, 59 | { 60 | "anonymous": false, 61 | "inputs": [ 62 | { 63 | "indexed": true, 64 | "internalType": "address", 65 | "name": "user", 66 | "type": "address" 67 | }, 68 | { 69 | "indexed": false, 70 | "internalType": "uint256", 71 | "name": "_rJoePerSec", 72 | "type": "uint256" 73 | } 74 | ], 75 | "name": "UpdateEmissionRate", 76 | "type": "event" 77 | }, 78 | { 79 | "anonymous": false, 80 | "inputs": [ 81 | { 82 | "indexed": true, 83 | "internalType": "address", 84 | "name": "user", 85 | "type": "address" 86 | }, 87 | { 88 | "indexed": false, 89 | "internalType": "uint256", 90 | "name": "amount", 91 | "type": "uint256" 92 | } 93 | ], 94 | "name": "Withdraw", 95 | "type": "event" 96 | }, 97 | { 98 | "inputs": [], 99 | "name": "MAX_EMISSION_RATE", 100 | "outputs": [ 101 | { 102 | "internalType": "uint256", 103 | "name": "", 104 | "type": "uint256" 105 | } 106 | ], 107 | "stateMutability": "view", 108 | "type": "function" 109 | }, 110 | { 111 | "inputs": [], 112 | "name": "accRJoePerShare", 113 | "outputs": [ 114 | { 115 | "internalType": "uint256", 116 | "name": "", 117 | "type": "uint256" 118 | } 119 | ], 120 | "stateMutability": "view", 121 | "type": "function" 122 | }, 123 | { 124 | "inputs": [ 125 | { 126 | "internalType": "uint256", 127 | "name": "_amount", 128 | "type": "uint256" 129 | } 130 | ], 131 | "name": "deposit", 132 | "outputs": [], 133 | "stateMutability": "nonpayable", 134 | "type": "function" 135 | }, 136 | { 137 | "inputs": [], 138 | "name": "emergencyWithdraw", 139 | "outputs": [], 140 | "stateMutability": "nonpayable", 141 | "type": "function" 142 | }, 143 | { 144 | "inputs": [ 145 | { 146 | "internalType": "contract IERC20Upgradeable", 147 | "name": "_joe", 148 | "type": "address" 149 | }, 150 | { 151 | "internalType": "contract RocketJoeToken", 152 | "name": "_rJoe", 153 | "type": "address" 154 | }, 155 | { 156 | "internalType": "uint256", 157 | "name": "_rJoePerSec", 158 | "type": "uint256" 159 | }, 160 | { 161 | "internalType": "uint256", 162 | "name": "_startTime", 163 | "type": "uint256" 164 | } 165 | ], 166 | "name": "initialize", 167 | "outputs": [], 168 | "stateMutability": "nonpayable", 169 | "type": "function" 170 | }, 171 | { 172 | "inputs": [], 173 | "name": "joe", 174 | "outputs": [ 175 | { 176 | "internalType": "contract IERC20Upgradeable", 177 | "name": "", 178 | "type": "address" 179 | } 180 | ], 181 | "stateMutability": "view", 182 | "type": "function" 183 | }, 184 | { 185 | "inputs": [], 186 | "name": "lastRewardTimestamp", 187 | "outputs": [ 188 | { 189 | "internalType": "uint256", 190 | "name": "", 191 | "type": "uint256" 192 | } 193 | ], 194 | "stateMutability": "view", 195 | "type": "function" 196 | }, 197 | { 198 | "inputs": [], 199 | "name": "owner", 200 | "outputs": [ 201 | { 202 | "internalType": "address", 203 | "name": "", 204 | "type": "address" 205 | } 206 | ], 207 | "stateMutability": "view", 208 | "type": "function" 209 | }, 210 | { 211 | "inputs": [ 212 | { 213 | "internalType": "address", 214 | "name": "_user", 215 | "type": "address" 216 | } 217 | ], 218 | "name": "pendingRJoe", 219 | "outputs": [ 220 | { 221 | "internalType": "uint256", 222 | "name": "", 223 | "type": "uint256" 224 | } 225 | ], 226 | "stateMutability": "view", 227 | "type": "function" 228 | }, 229 | { 230 | "inputs": [], 231 | "name": "rJoe", 232 | "outputs": [ 233 | { 234 | "internalType": "contract RocketJoeToken", 235 | "name": "", 236 | "type": "address" 237 | } 238 | ], 239 | "stateMutability": "view", 240 | "type": "function" 241 | }, 242 | { 243 | "inputs": [], 244 | "name": "rJoePerSec", 245 | "outputs": [ 246 | { 247 | "internalType": "uint256", 248 | "name": "", 249 | "type": "uint256" 250 | } 251 | ], 252 | "stateMutability": "view", 253 | "type": "function" 254 | }, 255 | { 256 | "inputs": [], 257 | "name": "renounceOwnership", 258 | "outputs": [], 259 | "stateMutability": "nonpayable", 260 | "type": "function" 261 | }, 262 | { 263 | "inputs": [], 264 | "name": "totalJoeStaked", 265 | "outputs": [ 266 | { 267 | "internalType": "uint256", 268 | "name": "", 269 | "type": "uint256" 270 | } 271 | ], 272 | "stateMutability": "view", 273 | "type": "function" 274 | }, 275 | { 276 | "inputs": [ 277 | { 278 | "internalType": "address", 279 | "name": "newOwner", 280 | "type": "address" 281 | } 282 | ], 283 | "name": "transferOwnership", 284 | "outputs": [], 285 | "stateMutability": "nonpayable", 286 | "type": "function" 287 | }, 288 | { 289 | "inputs": [ 290 | { 291 | "internalType": "uint256", 292 | "name": "_rJoePerSec", 293 | "type": "uint256" 294 | } 295 | ], 296 | "name": "updateEmissionRate", 297 | "outputs": [], 298 | "stateMutability": "nonpayable", 299 | "type": "function" 300 | }, 301 | { 302 | "inputs": [], 303 | "name": "updatePool", 304 | "outputs": [], 305 | "stateMutability": "nonpayable", 306 | "type": "function" 307 | }, 308 | { 309 | "inputs": [ 310 | { 311 | "internalType": "address", 312 | "name": "", 313 | "type": "address" 314 | } 315 | ], 316 | "name": "userInfo", 317 | "outputs": [ 318 | { 319 | "internalType": "uint256", 320 | "name": "amount", 321 | "type": "uint256" 322 | }, 323 | { 324 | "internalType": "uint256", 325 | "name": "rewardDebt", 326 | "type": "uint256" 327 | } 328 | ], 329 | "stateMutability": "view", 330 | "type": "function" 331 | }, 332 | { 333 | "inputs": [ 334 | { 335 | "internalType": "uint256", 336 | "name": "_amount", 337 | "type": "uint256" 338 | } 339 | ], 340 | "name": "withdraw", 341 | "outputs": [], 342 | "stateMutability": "nonpayable", 343 | "type": "function" 344 | } 345 | ] 346 | -------------------------------------------------------------------------------- /src/abis/json/StableJoeStakingABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 6 | { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, 7 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 8 | ], 9 | "name": "ClaimReward", 10 | "type": "event" 11 | }, 12 | { 13 | "anonymous": false, 14 | "inputs": [ 15 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 16 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, 17 | { "indexed": false, "internalType": "uint256", "name": "fee", "type": "uint256" } 18 | ], 19 | "name": "Deposit", 20 | "type": "event" 21 | }, 22 | { 23 | "anonymous": false, 24 | "inputs": [ 25 | { "indexed": false, "internalType": "uint256", "name": "newFee", "type": "uint256" }, 26 | { "indexed": false, "internalType": "uint256", "name": "oldFee", "type": "uint256" } 27 | ], 28 | "name": "DepositFeeChanged", 29 | "type": "event" 30 | }, 31 | { 32 | "anonymous": false, 33 | "inputs": [ 34 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 35 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 36 | ], 37 | "name": "EmergencyWithdraw", 38 | "type": "event" 39 | }, 40 | { 41 | "anonymous": false, 42 | "inputs": [ 43 | { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, 44 | { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } 45 | ], 46 | "name": "OwnershipTransferred", 47 | "type": "event" 48 | }, 49 | { 50 | "anonymous": false, 51 | "inputs": [{ "indexed": false, "internalType": "address", "name": "token", "type": "address" }], 52 | "name": "RewardTokenAdded", 53 | "type": "event" 54 | }, 55 | { 56 | "anonymous": false, 57 | "inputs": [{ "indexed": false, "internalType": "address", "name": "token", "type": "address" }], 58 | "name": "RewardTokenRemoved", 59 | "type": "event" 60 | }, 61 | { 62 | "anonymous": false, 63 | "inputs": [ 64 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 65 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 66 | ], 67 | "name": "Withdraw", 68 | "type": "event" 69 | }, 70 | { 71 | "inputs": [], 72 | "name": "ACC_REWARD_PER_SHARE_PRECISION", 73 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 74 | "stateMutability": "view", 75 | "type": "function" 76 | }, 77 | { 78 | "inputs": [], 79 | "name": "DEPOSIT_FEE_PERCENT_PRECISION", 80 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 81 | "stateMutability": "view", 82 | "type": "function" 83 | }, 84 | { 85 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 86 | "name": "accRewardPerShare", 87 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 88 | "stateMutability": "view", 89 | "type": "function" 90 | }, 91 | { 92 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "_rewardToken", "type": "address" }], 93 | "name": "addRewardToken", 94 | "outputs": [], 95 | "stateMutability": "nonpayable", 96 | "type": "function" 97 | }, 98 | { 99 | "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], 100 | "name": "deposit", 101 | "outputs": [], 102 | "stateMutability": "nonpayable", 103 | "type": "function" 104 | }, 105 | { 106 | "inputs": [], 107 | "name": "depositFeePercent", 108 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 109 | "stateMutability": "view", 110 | "type": "function" 111 | }, 112 | { "inputs": [], "name": "emergencyWithdraw", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 113 | { 114 | "inputs": [], 115 | "name": "feeCollector", 116 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 117 | "stateMutability": "view", 118 | "type": "function" 119 | }, 120 | { 121 | "inputs": [ 122 | { "internalType": "address", "name": "_user", "type": "address" }, 123 | { "internalType": "contract IERC20Upgradeable", "name": "_rewardToken", "type": "address" } 124 | ], 125 | "name": "getUserInfo", 126 | "outputs": [ 127 | { "internalType": "uint256", "name": "", "type": "uint256" }, 128 | { "internalType": "uint256", "name": "", "type": "uint256" } 129 | ], 130 | "stateMutability": "view", 131 | "type": "function" 132 | }, 133 | { 134 | "inputs": [ 135 | { "internalType": "contract IERC20Upgradeable", "name": "_rewardToken", "type": "address" }, 136 | { "internalType": "contract IERC20Upgradeable", "name": "_joe", "type": "address" }, 137 | { "internalType": "address", "name": "_feeCollector", "type": "address" }, 138 | { "internalType": "uint256", "name": "_depositFeePercent", "type": "uint256" } 139 | ], 140 | "name": "initialize", 141 | "outputs": [], 142 | "stateMutability": "nonpayable", 143 | "type": "function" 144 | }, 145 | { 146 | "inputs": [], 147 | "name": "internalJoeBalance", 148 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 149 | "stateMutability": "view", 150 | "type": "function" 151 | }, 152 | { 153 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 154 | "name": "isRewardToken", 155 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 156 | "stateMutability": "view", 157 | "type": "function" 158 | }, 159 | { 160 | "inputs": [], 161 | "name": "joe", 162 | "outputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 163 | "stateMutability": "view", 164 | "type": "function" 165 | }, 166 | { 167 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 168 | "name": "lastRewardBalance", 169 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "inputs": [], 175 | "name": "owner", 176 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 177 | "stateMutability": "view", 178 | "type": "function" 179 | }, 180 | { 181 | "inputs": [ 182 | { "internalType": "address", "name": "_user", "type": "address" }, 183 | { "internalType": "contract IERC20Upgradeable", "name": "_token", "type": "address" } 184 | ], 185 | "name": "pendingReward", 186 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 187 | "stateMutability": "view", 188 | "type": "function" 189 | }, 190 | { 191 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "_rewardToken", "type": "address" }], 192 | "name": "removeRewardToken", 193 | "outputs": [], 194 | "stateMutability": "nonpayable", 195 | "type": "function" 196 | }, 197 | { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 198 | { 199 | "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 200 | "name": "rewardTokens", 201 | "outputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 202 | "stateMutability": "view", 203 | "type": "function" 204 | }, 205 | { 206 | "inputs": [], 207 | "name": "rewardTokensLength", 208 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 209 | "stateMutability": "view", 210 | "type": "function" 211 | }, 212 | { 213 | "inputs": [{ "internalType": "uint256", "name": "_depositFeePercent", "type": "uint256" }], 214 | "name": "setDepositFeePercent", 215 | "outputs": [], 216 | "stateMutability": "nonpayable", 217 | "type": "function" 218 | }, 219 | { 220 | "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], 221 | "name": "transferOwnership", 222 | "outputs": [], 223 | "stateMutability": "nonpayable", 224 | "type": "function" 225 | }, 226 | { 227 | "inputs": [{ "internalType": "contract IERC20Upgradeable", "name": "_token", "type": "address" }], 228 | "name": "updateReward", 229 | "outputs": [], 230 | "stateMutability": "nonpayable", 231 | "type": "function" 232 | }, 233 | { 234 | "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], 235 | "name": "withdraw", 236 | "outputs": [], 237 | "stateMutability": "nonpayable", 238 | "type": "function" 239 | } 240 | ] 241 | -------------------------------------------------------------------------------- /src/abis/json/VeJoeABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, 6 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 7 | ], 8 | "name": "Burn", 9 | "type": "event" 10 | }, 11 | { 12 | "anonymous": false, 13 | "inputs": [ 14 | { "indexed": true, "internalType": "address", "name": "beneficiary", "type": "address" }, 15 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 16 | ], 17 | "name": "Mint", 18 | "type": "event" 19 | }, 20 | { 21 | "anonymous": false, 22 | "inputs": [ 23 | { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, 24 | { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } 25 | ], 26 | "name": "OwnershipTransferred", 27 | "type": "event" 28 | }, 29 | { 30 | "anonymous": false, 31 | "inputs": [ 32 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 33 | { "indexed": false, "internalType": "address", "name": "boostedMasterChef", "type": "address" } 34 | ], 35 | "name": "UpdateBoostedMasterChefJoe", 36 | "type": "event" 37 | }, 38 | { 39 | "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], 40 | "name": "balanceOf", 41 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 42 | "stateMutability": "view", 43 | "type": "function" 44 | }, 45 | { 46 | "inputs": [], 47 | "name": "boostedMasterChef", 48 | "outputs": [{ "internalType": "contract IBoostedMasterChefJoe", "name": "", "type": "address" }], 49 | "stateMutability": "view", 50 | "type": "function" 51 | }, 52 | { 53 | "inputs": [ 54 | { "internalType": "address", "name": "_from", "type": "address" }, 55 | { "internalType": "uint256", "name": "_amount", "type": "uint256" } 56 | ], 57 | "name": "burnFrom", 58 | "outputs": [], 59 | "stateMutability": "nonpayable", 60 | "type": "function" 61 | }, 62 | { 63 | "inputs": [], 64 | "name": "decimals", 65 | "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], 66 | "stateMutability": "view", 67 | "type": "function" 68 | }, 69 | { 70 | "inputs": [ 71 | { "internalType": "address", "name": "_to", "type": "address" }, 72 | { "internalType": "uint256", "name": "_amount", "type": "uint256" } 73 | ], 74 | "name": "mint", 75 | "outputs": [], 76 | "stateMutability": "nonpayable", 77 | "type": "function" 78 | }, 79 | { 80 | "inputs": [], 81 | "name": "name", 82 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 83 | "stateMutability": "view", 84 | "type": "function" 85 | }, 86 | { 87 | "inputs": [], 88 | "name": "owner", 89 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 90 | "stateMutability": "view", 91 | "type": "function" 92 | }, 93 | { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 94 | { 95 | "inputs": [{ "internalType": "address", "name": "_boostedMasterChef", "type": "address" }], 96 | "name": "setBoostedMasterChefJoe", 97 | "outputs": [], 98 | "stateMutability": "nonpayable", 99 | "type": "function" 100 | }, 101 | { 102 | "inputs": [], 103 | "name": "symbol", 104 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 105 | "stateMutability": "view", 106 | "type": "function" 107 | }, 108 | { 109 | "inputs": [], 110 | "name": "totalSupply", 111 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 112 | "stateMutability": "view", 113 | "type": "function" 114 | }, 115 | { 116 | "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], 117 | "name": "transferOwnership", 118 | "outputs": [], 119 | "stateMutability": "nonpayable", 120 | "type": "function" 121 | } 122 | ] 123 | -------------------------------------------------------------------------------- /src/abis/json/VeJoeStakingABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 6 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 7 | ], 8 | "name": "Claim", 9 | "type": "event" 10 | }, 11 | { 12 | "anonymous": false, 13 | "inputs": [ 14 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 15 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 16 | ], 17 | "name": "Deposit", 18 | "type": "event" 19 | }, 20 | { 21 | "anonymous": false, 22 | "inputs": [ 23 | { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, 24 | { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } 25 | ], 26 | "name": "OwnershipTransferred", 27 | "type": "event" 28 | }, 29 | { 30 | "anonymous": false, 31 | "inputs": [ 32 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 33 | { "indexed": false, "internalType": "uint256", "name": "maxCapPct", "type": "uint256" } 34 | ], 35 | "name": "UpdateMaxCapPct", 36 | "type": "event" 37 | }, 38 | { 39 | "anonymous": false, 40 | "inputs": [ 41 | { "indexed": false, "internalType": "uint256", "name": "lastRewardTimestamp", "type": "uint256" }, 42 | { "indexed": false, "internalType": "uint256", "name": "accVeJoePerShare", "type": "uint256" } 43 | ], 44 | "name": "UpdateRewardVars", 45 | "type": "event" 46 | }, 47 | { 48 | "anonymous": false, 49 | "inputs": [ 50 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 51 | { "indexed": false, "internalType": "uint256", "name": "speedUpThreshold", "type": "uint256" } 52 | ], 53 | "name": "UpdateSpeedUpThreshold", 54 | "type": "event" 55 | }, 56 | { 57 | "anonymous": false, 58 | "inputs": [ 59 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 60 | { "indexed": false, "internalType": "uint256", "name": "veJoePerSharePerSec", "type": "uint256" } 61 | ], 62 | "name": "UpdateVeJoePerSharePerSec", 63 | "type": "event" 64 | }, 65 | { 66 | "anonymous": false, 67 | "inputs": [ 68 | { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, 69 | { "indexed": false, "internalType": "uint256", "name": "withdrawAmount", "type": "uint256" }, 70 | { "indexed": false, "internalType": "uint256", "name": "burnAmount", "type": "uint256" } 71 | ], 72 | "name": "Withdraw", 73 | "type": "event" 74 | }, 75 | { 76 | "inputs": [], 77 | "name": "ACC_VEJOE_PER_SHARE_PRECISION", 78 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 79 | "stateMutability": "view", 80 | "type": "function" 81 | }, 82 | { 83 | "inputs": [], 84 | "name": "VEJOE_PER_SHARE_PER_SEC_PRECISION", 85 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 86 | "stateMutability": "view", 87 | "type": "function" 88 | }, 89 | { 90 | "inputs": [], 91 | "name": "accVeJoePerShare", 92 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 93 | "stateMutability": "view", 94 | "type": "function" 95 | }, 96 | { "inputs": [], "name": "claim", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 97 | { 98 | "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], 99 | "name": "deposit", 100 | "outputs": [], 101 | "stateMutability": "nonpayable", 102 | "type": "function" 103 | }, 104 | { 105 | "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], 106 | "name": "getPendingVeJoe", 107 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 108 | "stateMutability": "view", 109 | "type": "function" 110 | }, 111 | { 112 | "inputs": [ 113 | { "internalType": "contract IERC20Upgradeable", "name": "_joe", "type": "address" }, 114 | { "internalType": "contract VeJoeToken", "name": "_veJoe", "type": "address" }, 115 | { "internalType": "uint256", "name": "_veJoePerSharePerSec", "type": "uint256" }, 116 | { "internalType": "uint256", "name": "_speedUpVeJoePerSharePerSec", "type": "uint256" }, 117 | { "internalType": "uint256", "name": "_speedUpThreshold", "type": "uint256" }, 118 | { "internalType": "uint256", "name": "_speedUpDuration", "type": "uint256" }, 119 | { "internalType": "uint256", "name": "_maxCapPct", "type": "uint256" } 120 | ], 121 | "name": "initialize", 122 | "outputs": [], 123 | "stateMutability": "nonpayable", 124 | "type": "function" 125 | }, 126 | { 127 | "inputs": [], 128 | "name": "joe", 129 | "outputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], 130 | "stateMutability": "view", 131 | "type": "function" 132 | }, 133 | { 134 | "inputs": [], 135 | "name": "lastRewardTimestamp", 136 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 137 | "stateMutability": "view", 138 | "type": "function" 139 | }, 140 | { 141 | "inputs": [], 142 | "name": "maxCapPct", 143 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 144 | "stateMutability": "view", 145 | "type": "function" 146 | }, 147 | { 148 | "inputs": [], 149 | "name": "owner", 150 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 151 | "stateMutability": "view", 152 | "type": "function" 153 | }, 154 | { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 155 | { 156 | "inputs": [{ "internalType": "uint256", "name": "_maxCapPct", "type": "uint256" }], 157 | "name": "setMaxCapPct", 158 | "outputs": [], 159 | "stateMutability": "nonpayable", 160 | "type": "function" 161 | }, 162 | { 163 | "inputs": [{ "internalType": "uint256", "name": "_speedUpThreshold", "type": "uint256" }], 164 | "name": "setSpeedUpThreshold", 165 | "outputs": [], 166 | "stateMutability": "nonpayable", 167 | "type": "function" 168 | }, 169 | { 170 | "inputs": [{ "internalType": "uint256", "name": "_veJoePerSharePerSec", "type": "uint256" }], 171 | "name": "setVeJoePerSharePerSec", 172 | "outputs": [], 173 | "stateMutability": "nonpayable", 174 | "type": "function" 175 | }, 176 | { 177 | "inputs": [], 178 | "name": "speedUpDuration", 179 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 180 | "stateMutability": "view", 181 | "type": "function" 182 | }, 183 | { 184 | "inputs": [], 185 | "name": "speedUpThreshold", 186 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 187 | "stateMutability": "view", 188 | "type": "function" 189 | }, 190 | { 191 | "inputs": [], 192 | "name": "speedUpVeJoePerSharePerSec", 193 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 194 | "stateMutability": "view", 195 | "type": "function" 196 | }, 197 | { 198 | "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], 199 | "name": "transferOwnership", 200 | "outputs": [], 201 | "stateMutability": "nonpayable", 202 | "type": "function" 203 | }, 204 | { "inputs": [], "name": "updateRewardVars", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, 205 | { 206 | "inputs": [], 207 | "name": "upperLimitMaxCapPct", 208 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 209 | "stateMutability": "view", 210 | "type": "function" 211 | }, 212 | { 213 | "inputs": [], 214 | "name": "upperLimitVeJoePerSharePerSec", 215 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 216 | "stateMutability": "view", 217 | "type": "function" 218 | }, 219 | { 220 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }], 221 | "name": "userInfos", 222 | "outputs": [ 223 | { "internalType": "uint256", "name": "balance", "type": "uint256" }, 224 | { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }, 225 | { "internalType": "uint256", "name": "lastClaimTimestamp", "type": "uint256" }, 226 | { "internalType": "uint256", "name": "speedUpEndTimestamp", "type": "uint256" } 227 | ], 228 | "stateMutability": "view", 229 | "type": "function" 230 | }, 231 | { 232 | "inputs": [], 233 | "name": "veJoe", 234 | "outputs": [{ "internalType": "contract VeJoeToken", "name": "", "type": "address" }], 235 | "stateMutability": "view", 236 | "type": "function" 237 | }, 238 | { 239 | "inputs": [], 240 | "name": "veJoePerSharePerSec", 241 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 242 | "stateMutability": "view", 243 | "type": "function" 244 | }, 245 | { 246 | "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], 247 | "name": "withdraw", 248 | "outputs": [], 249 | "stateMutability": "nonpayable", 250 | "type": "function" 251 | } 252 | ] 253 | -------------------------------------------------------------------------------- /src/abis/json/WNativeABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { "indexed": true, "internalType": "address", "name": "src", "type": "address" }, 6 | { "indexed": true, "internalType": "address", "name": "guy", "type": "address" }, 7 | { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } 8 | ], 9 | "name": "Approval", 10 | "type": "event" 11 | }, 12 | { 13 | "anonymous": false, 14 | "inputs": [ 15 | { "indexed": true, "internalType": "address", "name": "dst", "type": "address" }, 16 | { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } 17 | ], 18 | "name": "Deposit", 19 | "type": "event" 20 | }, 21 | { 22 | "anonymous": false, 23 | "inputs": [ 24 | { "indexed": true, "internalType": "address", "name": "src", "type": "address" }, 25 | { "indexed": true, "internalType": "address", "name": "dst", "type": "address" }, 26 | { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } 27 | ], 28 | "name": "Transfer", 29 | "type": "event" 30 | }, 31 | { 32 | "anonymous": false, 33 | "inputs": [ 34 | { "indexed": true, "internalType": "address", "name": "src", "type": "address" }, 35 | { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } 36 | ], 37 | "name": "Withdrawal", 38 | "type": "event" 39 | }, 40 | { "payable": true, "stateMutability": "payable", "type": "fallback" }, 41 | { 42 | "constant": true, 43 | "inputs": [ 44 | { "internalType": "address", "name": "", "type": "address" }, 45 | { "internalType": "address", "name": "", "type": "address" } 46 | ], 47 | "name": "allowance", 48 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { "internalType": "address", "name": "guy", "type": "address" }, 57 | { "internalType": "uint256", "name": "wad", "type": "uint256" } 58 | ], 59 | "name": "approve", 60 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 61 | "payable": false, 62 | "stateMutability": "nonpayable", 63 | "type": "function" 64 | }, 65 | { 66 | "constant": true, 67 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }], 68 | "name": "balanceOf", 69 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 70 | "payable": false, 71 | "stateMutability": "view", 72 | "type": "function" 73 | }, 74 | { 75 | "constant": true, 76 | "inputs": [], 77 | "name": "decimals", 78 | "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], 79 | "payable": false, 80 | "stateMutability": "view", 81 | "type": "function" 82 | }, 83 | { 84 | "constant": false, 85 | "inputs": [], 86 | "name": "deposit", 87 | "outputs": [], 88 | "payable": true, 89 | "stateMutability": "payable", 90 | "type": "function" 91 | }, 92 | { 93 | "constant": true, 94 | "inputs": [], 95 | "name": "name", 96 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 97 | "payable": false, 98 | "stateMutability": "view", 99 | "type": "function" 100 | }, 101 | { 102 | "constant": true, 103 | "inputs": [], 104 | "name": "symbol", 105 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 106 | "payable": false, 107 | "stateMutability": "view", 108 | "type": "function" 109 | }, 110 | { 111 | "constant": true, 112 | "inputs": [], 113 | "name": "totalSupply", 114 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 115 | "payable": false, 116 | "stateMutability": "view", 117 | "type": "function" 118 | }, 119 | { 120 | "constant": false, 121 | "inputs": [ 122 | { "internalType": "address", "name": "dst", "type": "address" }, 123 | { "internalType": "uint256", "name": "wad", "type": "uint256" } 124 | ], 125 | "name": "transfer", 126 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 127 | "payable": false, 128 | "stateMutability": "nonpayable", 129 | "type": "function" 130 | }, 131 | { 132 | "constant": false, 133 | "inputs": [ 134 | { "internalType": "address", "name": "src", "type": "address" }, 135 | { "internalType": "address", "name": "dst", "type": "address" }, 136 | { "internalType": "uint256", "name": "wad", "type": "uint256" } 137 | ], 138 | "name": "transferFrom", 139 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 140 | "payable": false, 141 | "stateMutability": "nonpayable", 142 | "type": "function" 143 | }, 144 | { 145 | "constant": false, 146 | "inputs": [{ "internalType": "uint256", "name": "wad", "type": "uint256" }], 147 | "name": "withdraw", 148 | "outputs": [], 149 | "payable": false, 150 | "stateMutability": "nonpayable", 151 | "type": "function" 152 | } 153 | ] 154 | -------------------------------------------------------------------------------- /src/abis/json/XJoeStakingABI.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [{ "internalType": "contract IERC20", "name": "_joe", "type": "address" }], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": [ 10 | { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, 11 | { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, 12 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 13 | ], 14 | "name": "Approval", 15 | "type": "event" 16 | }, 17 | { 18 | "anonymous": false, 19 | "inputs": [ 20 | { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, 21 | { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, 22 | { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } 23 | ], 24 | "name": "Transfer", 25 | "type": "event" 26 | }, 27 | { 28 | "inputs": [ 29 | { "internalType": "address", "name": "owner", "type": "address" }, 30 | { "internalType": "address", "name": "spender", "type": "address" } 31 | ], 32 | "name": "allowance", 33 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 34 | "stateMutability": "view", 35 | "type": "function" 36 | }, 37 | { 38 | "inputs": [ 39 | { "internalType": "address", "name": "spender", "type": "address" }, 40 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 41 | ], 42 | "name": "approve", 43 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 44 | "stateMutability": "nonpayable", 45 | "type": "function" 46 | }, 47 | { 48 | "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], 49 | "name": "balanceOf", 50 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 51 | "stateMutability": "view", 52 | "type": "function" 53 | }, 54 | { 55 | "inputs": [], 56 | "name": "decimals", 57 | "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], 58 | "stateMutability": "view", 59 | "type": "function" 60 | }, 61 | { 62 | "inputs": [ 63 | { "internalType": "address", "name": "spender", "type": "address" }, 64 | { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } 65 | ], 66 | "name": "decreaseAllowance", 67 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 68 | "stateMutability": "nonpayable", 69 | "type": "function" 70 | }, 71 | { 72 | "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], 73 | "name": "enter", 74 | "outputs": [], 75 | "stateMutability": "nonpayable", 76 | "type": "function" 77 | }, 78 | { 79 | "inputs": [ 80 | { "internalType": "address", "name": "spender", "type": "address" }, 81 | { "internalType": "uint256", "name": "addedValue", "type": "uint256" } 82 | ], 83 | "name": "increaseAllowance", 84 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 85 | "stateMutability": "nonpayable", 86 | "type": "function" 87 | }, 88 | { 89 | "inputs": [], 90 | "name": "joe", 91 | "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], 92 | "stateMutability": "view", 93 | "type": "function" 94 | }, 95 | { 96 | "inputs": [{ "internalType": "uint256", "name": "_share", "type": "uint256" }], 97 | "name": "leave", 98 | "outputs": [], 99 | "stateMutability": "nonpayable", 100 | "type": "function" 101 | }, 102 | { 103 | "inputs": [], 104 | "name": "name", 105 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 106 | "stateMutability": "view", 107 | "type": "function" 108 | }, 109 | { 110 | "inputs": [], 111 | "name": "symbol", 112 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 113 | "stateMutability": "view", 114 | "type": "function" 115 | }, 116 | { 117 | "inputs": [], 118 | "name": "totalSupply", 119 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 120 | "stateMutability": "view", 121 | "type": "function" 122 | }, 123 | { 124 | "inputs": [ 125 | { "internalType": "address", "name": "recipient", "type": "address" }, 126 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 127 | ], 128 | "name": "transfer", 129 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 130 | "stateMutability": "nonpayable", 131 | "type": "function" 132 | }, 133 | { 134 | "inputs": [ 135 | { "internalType": "address", "name": "sender", "type": "address" }, 136 | { "internalType": "address", "name": "recipient", "type": "address" }, 137 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 138 | ], 139 | "name": "transferFrom", 140 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 141 | "stateMutability": "nonpayable", 142 | "type": "function" 143 | } 144 | ] 145 | -------------------------------------------------------------------------------- /src/abis/json/index.ts: -------------------------------------------------------------------------------- 1 | export { default as ERC20ABI } from './ERC20ABI.json' 2 | export { default as JoePairABI } from './JoePairABI.json' 3 | export { default as RocketJoeStakingABI } from './RocketJoeStakingABI.json' 4 | export { default as RouterABI } from './RouterABI.json' 5 | export { default as StableJoeStakingABI } from './StableJoeStakingABI.json' 6 | export { default as VeJoeABI } from './VeJoeABI.json' 7 | export { default as WNativeABI } from './WNativeABI.json' 8 | export { default as VeJoeStakingABI } from './VeJoeStakingABI.json' 9 | export { default as XJoeStakingABI } from './XJoeStakingABI.json' 10 | -------------------------------------------------------------------------------- /src/abis/ts/ERC20.ts: -------------------------------------------------------------------------------- 1 | export const ERC20ABI = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: 'string', 6 | name: 'name_', 7 | type: 'string' 8 | }, 9 | { 10 | internalType: 'string', 11 | name: 'symbol_', 12 | type: 'string' 13 | } 14 | ], 15 | stateMutability: 'nonpayable', 16 | type: 'constructor' 17 | }, 18 | { 19 | anonymous: false, 20 | inputs: [ 21 | { 22 | indexed: true, 23 | internalType: 'address', 24 | name: 'owner', 25 | type: 'address' 26 | }, 27 | { 28 | indexed: true, 29 | internalType: 'address', 30 | name: 'spender', 31 | type: 'address' 32 | }, 33 | { 34 | indexed: false, 35 | internalType: 'uint256', 36 | name: 'value', 37 | type: 'uint256' 38 | } 39 | ], 40 | name: 'Approval', 41 | type: 'event' 42 | }, 43 | { 44 | anonymous: false, 45 | inputs: [ 46 | { 47 | indexed: true, 48 | internalType: 'address', 49 | name: 'from', 50 | type: 'address' 51 | }, 52 | { 53 | indexed: true, 54 | internalType: 'address', 55 | name: 'to', 56 | type: 'address' 57 | }, 58 | { 59 | indexed: false, 60 | internalType: 'uint256', 61 | name: 'value', 62 | type: 'uint256' 63 | } 64 | ], 65 | name: 'Transfer', 66 | type: 'event' 67 | }, 68 | { 69 | inputs: [ 70 | { 71 | internalType: 'address', 72 | name: 'owner', 73 | type: 'address' 74 | }, 75 | { 76 | internalType: 'address', 77 | name: 'spender', 78 | type: 'address' 79 | } 80 | ], 81 | name: 'allowance', 82 | outputs: [ 83 | { 84 | internalType: 'uint256', 85 | name: '', 86 | type: 'uint256' 87 | } 88 | ], 89 | stateMutability: 'view', 90 | type: 'function' 91 | }, 92 | { 93 | inputs: [ 94 | { 95 | internalType: 'address', 96 | name: 'spender', 97 | type: 'address' 98 | }, 99 | { 100 | internalType: 'uint256', 101 | name: 'amount', 102 | type: 'uint256' 103 | } 104 | ], 105 | name: 'approve', 106 | outputs: [ 107 | { 108 | internalType: 'bool', 109 | name: '', 110 | type: 'bool' 111 | } 112 | ], 113 | stateMutability: 'nonpayable', 114 | type: 'function' 115 | }, 116 | { 117 | inputs: [ 118 | { 119 | internalType: 'address', 120 | name: 'account', 121 | type: 'address' 122 | } 123 | ], 124 | name: 'balanceOf', 125 | outputs: [ 126 | { 127 | internalType: 'uint256', 128 | name: '', 129 | type: 'uint256' 130 | } 131 | ], 132 | stateMutability: 'view', 133 | type: 'function' 134 | }, 135 | { 136 | inputs: [], 137 | name: 'decimals', 138 | outputs: [ 139 | { 140 | internalType: 'uint8', 141 | name: '', 142 | type: 'uint8' 143 | } 144 | ], 145 | stateMutability: 'view', 146 | type: 'function' 147 | }, 148 | { 149 | inputs: [ 150 | { 151 | internalType: 'address', 152 | name: 'spender', 153 | type: 'address' 154 | }, 155 | { 156 | internalType: 'uint256', 157 | name: 'subtractedValue', 158 | type: 'uint256' 159 | } 160 | ], 161 | name: 'decreaseAllowance', 162 | outputs: [ 163 | { 164 | internalType: 'bool', 165 | name: '', 166 | type: 'bool' 167 | } 168 | ], 169 | stateMutability: 'nonpayable', 170 | type: 'function' 171 | }, 172 | { 173 | inputs: [ 174 | { 175 | internalType: 'address', 176 | name: 'spender', 177 | type: 'address' 178 | }, 179 | { 180 | internalType: 'uint256', 181 | name: 'addedValue', 182 | type: 'uint256' 183 | } 184 | ], 185 | name: 'increaseAllowance', 186 | outputs: [ 187 | { 188 | internalType: 'bool', 189 | name: '', 190 | type: 'bool' 191 | } 192 | ], 193 | stateMutability: 'nonpayable', 194 | type: 'function' 195 | }, 196 | { 197 | inputs: [], 198 | name: 'name', 199 | outputs: [ 200 | { 201 | internalType: 'string', 202 | name: '', 203 | type: 'string' 204 | } 205 | ], 206 | stateMutability: 'view', 207 | type: 'function' 208 | }, 209 | { 210 | inputs: [], 211 | name: 'symbol', 212 | outputs: [ 213 | { 214 | internalType: 'string', 215 | name: '', 216 | type: 'string' 217 | } 218 | ], 219 | stateMutability: 'view', 220 | type: 'function' 221 | }, 222 | { 223 | inputs: [], 224 | name: 'totalSupply', 225 | outputs: [ 226 | { 227 | internalType: 'uint256', 228 | name: '', 229 | type: 'uint256' 230 | } 231 | ], 232 | stateMutability: 'view', 233 | type: 'function' 234 | }, 235 | { 236 | inputs: [ 237 | { 238 | internalType: 'address', 239 | name: 'recipient', 240 | type: 'address' 241 | }, 242 | { 243 | internalType: 'uint256', 244 | name: 'amount', 245 | type: 'uint256' 246 | } 247 | ], 248 | name: 'transfer', 249 | outputs: [ 250 | { 251 | internalType: 'bool', 252 | name: '', 253 | type: 'bool' 254 | } 255 | ], 256 | stateMutability: 'nonpayable', 257 | type: 'function' 258 | }, 259 | { 260 | inputs: [ 261 | { 262 | internalType: 'address', 263 | name: 'sender', 264 | type: 'address' 265 | }, 266 | { 267 | internalType: 'address', 268 | name: 'recipient', 269 | type: 'address' 270 | }, 271 | { 272 | internalType: 'uint256', 273 | name: 'amount', 274 | type: 'uint256' 275 | } 276 | ], 277 | name: 'transferFrom', 278 | outputs: [ 279 | { 280 | internalType: 'bool', 281 | name: '', 282 | type: 'bool' 283 | } 284 | ], 285 | stateMutability: 'nonpayable', 286 | type: 'function' 287 | } 288 | ] as const 289 | -------------------------------------------------------------------------------- /src/abis/ts/JoePair.ts: -------------------------------------------------------------------------------- 1 | export const JoePairABI = [ 2 | { inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, 3 | { 4 | anonymous: false, 5 | inputs: [ 6 | { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, 7 | { indexed: true, internalType: 'address', name: 'spender', type: 'address' }, 8 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 9 | ], 10 | name: 'Approval', 11 | type: 'event' 12 | }, 13 | { 14 | anonymous: false, 15 | inputs: [ 16 | { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, 17 | { indexed: false, internalType: 'uint256', name: 'amount0', type: 'uint256' }, 18 | { indexed: false, internalType: 'uint256', name: 'amount1', type: 'uint256' }, 19 | { indexed: true, internalType: 'address', name: 'to', type: 'address' } 20 | ], 21 | name: 'Burn', 22 | type: 'event' 23 | }, 24 | { 25 | anonymous: false, 26 | inputs: [ 27 | { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, 28 | { indexed: false, internalType: 'uint256', name: 'amount0', type: 'uint256' }, 29 | { indexed: false, internalType: 'uint256', name: 'amount1', type: 'uint256' } 30 | ], 31 | name: 'Mint', 32 | type: 'event' 33 | }, 34 | { 35 | anonymous: false, 36 | inputs: [ 37 | { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, 38 | { indexed: false, internalType: 'uint256', name: 'amount0In', type: 'uint256' }, 39 | { indexed: false, internalType: 'uint256', name: 'amount1In', type: 'uint256' }, 40 | { indexed: false, internalType: 'uint256', name: 'amount0Out', type: 'uint256' }, 41 | { indexed: false, internalType: 'uint256', name: 'amount1Out', type: 'uint256' }, 42 | { indexed: true, internalType: 'address', name: 'to', type: 'address' } 43 | ], 44 | name: 'Swap', 45 | type: 'event' 46 | }, 47 | { 48 | anonymous: false, 49 | inputs: [ 50 | { indexed: false, internalType: 'uint112', name: 'reserve0', type: 'uint112' }, 51 | { indexed: false, internalType: 'uint112', name: 'reserve1', type: 'uint112' } 52 | ], 53 | name: 'Sync', 54 | type: 'event' 55 | }, 56 | { 57 | anonymous: false, 58 | inputs: [ 59 | { indexed: true, internalType: 'address', name: 'from', type: 'address' }, 60 | { indexed: true, internalType: 'address', name: 'to', type: 'address' }, 61 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 62 | ], 63 | name: 'Transfer', 64 | type: 'event' 65 | }, 66 | { 67 | inputs: [], 68 | name: 'DOMAIN_SEPARATOR', 69 | outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], 70 | stateMutability: 'view', 71 | type: 'function' 72 | }, 73 | { 74 | inputs: [], 75 | name: 'MINIMUM_LIQUIDITY', 76 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 77 | stateMutability: 'view', 78 | type: 'function' 79 | }, 80 | { 81 | inputs: [], 82 | name: 'PERMIT_TYPEHASH', 83 | outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], 84 | stateMutability: 'view', 85 | type: 'function' 86 | }, 87 | { 88 | inputs: [ 89 | { internalType: 'address', name: '', type: 'address' }, 90 | { internalType: 'address', name: '', type: 'address' } 91 | ], 92 | name: 'allowance', 93 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 94 | stateMutability: 'view', 95 | type: 'function' 96 | }, 97 | { 98 | inputs: [ 99 | { internalType: 'address', name: 'spender', type: 'address' }, 100 | { internalType: 'uint256', name: 'value', type: 'uint256' } 101 | ], 102 | name: 'approve', 103 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 104 | stateMutability: 'nonpayable', 105 | type: 'function' 106 | }, 107 | { 108 | inputs: [{ internalType: 'address', name: '', type: 'address' }], 109 | name: 'balanceOf', 110 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 111 | stateMutability: 'view', 112 | type: 'function' 113 | }, 114 | { 115 | inputs: [{ internalType: 'address', name: 'to', type: 'address' }], 116 | name: 'burn', 117 | outputs: [ 118 | { internalType: 'uint256', name: 'amount0', type: 'uint256' }, 119 | { internalType: 'uint256', name: 'amount1', type: 'uint256' } 120 | ], 121 | stateMutability: 'nonpayable', 122 | type: 'function' 123 | }, 124 | { 125 | inputs: [], 126 | name: 'decimals', 127 | outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], 128 | stateMutability: 'view', 129 | type: 'function' 130 | }, 131 | { 132 | inputs: [], 133 | name: 'factory', 134 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 135 | stateMutability: 'view', 136 | type: 'function' 137 | }, 138 | { 139 | inputs: [], 140 | name: 'getReserves', 141 | outputs: [ 142 | { internalType: 'uint112', name: '_reserve0', type: 'uint112' }, 143 | { internalType: 'uint112', name: '_reserve1', type: 'uint112' }, 144 | { internalType: 'uint32', name: '_blockTimestampLast', type: 'uint32' } 145 | ], 146 | stateMutability: 'view', 147 | type: 'function' 148 | }, 149 | { 150 | inputs: [ 151 | { internalType: 'address', name: '_token0', type: 'address' }, 152 | { internalType: 'address', name: '_token1', type: 'address' } 153 | ], 154 | name: 'initialize', 155 | outputs: [], 156 | stateMutability: 'nonpayable', 157 | type: 'function' 158 | }, 159 | { 160 | inputs: [], 161 | name: 'kLast', 162 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 163 | stateMutability: 'view', 164 | type: 'function' 165 | }, 166 | { 167 | inputs: [{ internalType: 'address', name: 'to', type: 'address' }], 168 | name: 'mint', 169 | outputs: [{ internalType: 'uint256', name: 'liquidity', type: 'uint256' }], 170 | stateMutability: 'nonpayable', 171 | type: 'function' 172 | }, 173 | { 174 | inputs: [], 175 | name: 'name', 176 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 177 | stateMutability: 'view', 178 | type: 'function' 179 | }, 180 | { 181 | inputs: [{ internalType: 'address', name: '', type: 'address' }], 182 | name: 'nonces', 183 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 184 | stateMutability: 'view', 185 | type: 'function' 186 | }, 187 | { 188 | inputs: [ 189 | { internalType: 'address', name: 'owner', type: 'address' }, 190 | { internalType: 'address', name: 'spender', type: 'address' }, 191 | { internalType: 'uint256', name: 'value', type: 'uint256' }, 192 | { internalType: 'uint256', name: 'deadline', type: 'uint256' }, 193 | { internalType: 'uint8', name: 'v', type: 'uint8' }, 194 | { internalType: 'bytes32', name: 'r', type: 'bytes32' }, 195 | { internalType: 'bytes32', name: 's', type: 'bytes32' } 196 | ], 197 | name: 'permit', 198 | outputs: [], 199 | stateMutability: 'nonpayable', 200 | type: 'function' 201 | }, 202 | { 203 | inputs: [], 204 | name: 'price0CumulativeLast', 205 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 206 | stateMutability: 'view', 207 | type: 'function' 208 | }, 209 | { 210 | inputs: [], 211 | name: 'price1CumulativeLast', 212 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 213 | stateMutability: 'view', 214 | type: 'function' 215 | }, 216 | { 217 | inputs: [{ internalType: 'address', name: 'to', type: 'address' }], 218 | name: 'skim', 219 | outputs: [], 220 | stateMutability: 'nonpayable', 221 | type: 'function' 222 | }, 223 | { 224 | inputs: [ 225 | { internalType: 'uint256', name: 'amount0Out', type: 'uint256' }, 226 | { internalType: 'uint256', name: 'amount1Out', type: 'uint256' }, 227 | { internalType: 'address', name: 'to', type: 'address' }, 228 | { internalType: 'bytes', name: 'data', type: 'bytes' } 229 | ], 230 | name: 'swap', 231 | outputs: [], 232 | stateMutability: 'nonpayable', 233 | type: 'function' 234 | }, 235 | { 236 | inputs: [], 237 | name: 'symbol', 238 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 239 | stateMutability: 'view', 240 | type: 'function' 241 | }, 242 | { inputs: [], name: 'sync', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 243 | { 244 | inputs: [], 245 | name: 'token0', 246 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 247 | stateMutability: 'view', 248 | type: 'function' 249 | }, 250 | { 251 | inputs: [], 252 | name: 'token1', 253 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 254 | stateMutability: 'view', 255 | type: 'function' 256 | }, 257 | { 258 | inputs: [], 259 | name: 'totalSupply', 260 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 261 | stateMutability: 'view', 262 | type: 'function' 263 | }, 264 | { 265 | inputs: [ 266 | { internalType: 'address', name: 'to', type: 'address' }, 267 | { internalType: 'uint256', name: 'value', type: 'uint256' } 268 | ], 269 | name: 'transfer', 270 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 271 | stateMutability: 'nonpayable', 272 | type: 'function' 273 | }, 274 | { 275 | inputs: [ 276 | { internalType: 'address', name: 'from', type: 'address' }, 277 | { internalType: 'address', name: 'to', type: 'address' }, 278 | { internalType: 'uint256', name: 'value', type: 'uint256' } 279 | ], 280 | name: 'transferFrom', 281 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 282 | stateMutability: 'nonpayable', 283 | type: 'function' 284 | } 285 | ] as const 286 | -------------------------------------------------------------------------------- /src/abis/ts/RocketJoeStaking.ts: -------------------------------------------------------------------------------- 1 | export const RocketJoeStakingABI = [ 2 | { 3 | anonymous: false, 4 | inputs: [ 5 | { 6 | indexed: true, 7 | internalType: 'address', 8 | name: 'user', 9 | type: 'address' 10 | }, 11 | { 12 | indexed: false, 13 | internalType: 'uint256', 14 | name: 'amount', 15 | type: 'uint256' 16 | } 17 | ], 18 | name: 'Deposit', 19 | type: 'event' 20 | }, 21 | { 22 | anonymous: false, 23 | inputs: [ 24 | { 25 | indexed: true, 26 | internalType: 'address', 27 | name: 'user', 28 | type: 'address' 29 | }, 30 | { 31 | indexed: false, 32 | internalType: 'uint256', 33 | name: 'amount', 34 | type: 'uint256' 35 | } 36 | ], 37 | name: 'EmergencyWithdraw', 38 | type: 'event' 39 | }, 40 | { 41 | anonymous: false, 42 | inputs: [ 43 | { 44 | indexed: true, 45 | internalType: 'address', 46 | name: 'previousOwner', 47 | type: 'address' 48 | }, 49 | { 50 | indexed: true, 51 | internalType: 'address', 52 | name: 'newOwner', 53 | type: 'address' 54 | } 55 | ], 56 | name: 'OwnershipTransferred', 57 | type: 'event' 58 | }, 59 | { 60 | anonymous: false, 61 | inputs: [ 62 | { 63 | indexed: true, 64 | internalType: 'address', 65 | name: 'user', 66 | type: 'address' 67 | }, 68 | { 69 | indexed: false, 70 | internalType: 'uint256', 71 | name: '_rJoePerSec', 72 | type: 'uint256' 73 | } 74 | ], 75 | name: 'UpdateEmissionRate', 76 | type: 'event' 77 | }, 78 | { 79 | anonymous: false, 80 | inputs: [ 81 | { 82 | indexed: true, 83 | internalType: 'address', 84 | name: 'user', 85 | type: 'address' 86 | }, 87 | { 88 | indexed: false, 89 | internalType: 'uint256', 90 | name: 'amount', 91 | type: 'uint256' 92 | } 93 | ], 94 | name: 'Withdraw', 95 | type: 'event' 96 | }, 97 | { 98 | inputs: [], 99 | name: 'MAX_EMISSION_RATE', 100 | outputs: [ 101 | { 102 | internalType: 'uint256', 103 | name: '', 104 | type: 'uint256' 105 | } 106 | ], 107 | stateMutability: 'view', 108 | type: 'function' 109 | }, 110 | { 111 | inputs: [], 112 | name: 'accRJoePerShare', 113 | outputs: [ 114 | { 115 | internalType: 'uint256', 116 | name: '', 117 | type: 'uint256' 118 | } 119 | ], 120 | stateMutability: 'view', 121 | type: 'function' 122 | }, 123 | { 124 | inputs: [ 125 | { 126 | internalType: 'uint256', 127 | name: '_amount', 128 | type: 'uint256' 129 | } 130 | ], 131 | name: 'deposit', 132 | outputs: [], 133 | stateMutability: 'nonpayable', 134 | type: 'function' 135 | }, 136 | { 137 | inputs: [], 138 | name: 'emergencyWithdraw', 139 | outputs: [], 140 | stateMutability: 'nonpayable', 141 | type: 'function' 142 | }, 143 | { 144 | inputs: [ 145 | { 146 | internalType: 'contract IERC20Upgradeable', 147 | name: '_joe', 148 | type: 'address' 149 | }, 150 | { 151 | internalType: 'contract RocketJoeToken', 152 | name: '_rJoe', 153 | type: 'address' 154 | }, 155 | { 156 | internalType: 'uint256', 157 | name: '_rJoePerSec', 158 | type: 'uint256' 159 | }, 160 | { 161 | internalType: 'uint256', 162 | name: '_startTime', 163 | type: 'uint256' 164 | } 165 | ], 166 | name: 'initialize', 167 | outputs: [], 168 | stateMutability: 'nonpayable', 169 | type: 'function' 170 | }, 171 | { 172 | inputs: [], 173 | name: 'joe', 174 | outputs: [ 175 | { 176 | internalType: 'contract IERC20Upgradeable', 177 | name: '', 178 | type: 'address' 179 | } 180 | ], 181 | stateMutability: 'view', 182 | type: 'function' 183 | }, 184 | { 185 | inputs: [], 186 | name: 'lastRewardTimestamp', 187 | outputs: [ 188 | { 189 | internalType: 'uint256', 190 | name: '', 191 | type: 'uint256' 192 | } 193 | ], 194 | stateMutability: 'view', 195 | type: 'function' 196 | }, 197 | { 198 | inputs: [], 199 | name: 'owner', 200 | outputs: [ 201 | { 202 | internalType: 'address', 203 | name: '', 204 | type: 'address' 205 | } 206 | ], 207 | stateMutability: 'view', 208 | type: 'function' 209 | }, 210 | { 211 | inputs: [ 212 | { 213 | internalType: 'address', 214 | name: '_user', 215 | type: 'address' 216 | } 217 | ], 218 | name: 'pendingRJoe', 219 | outputs: [ 220 | { 221 | internalType: 'uint256', 222 | name: '', 223 | type: 'uint256' 224 | } 225 | ], 226 | stateMutability: 'view', 227 | type: 'function' 228 | }, 229 | { 230 | inputs: [], 231 | name: 'rJoe', 232 | outputs: [ 233 | { 234 | internalType: 'contract RocketJoeToken', 235 | name: '', 236 | type: 'address' 237 | } 238 | ], 239 | stateMutability: 'view', 240 | type: 'function' 241 | }, 242 | { 243 | inputs: [], 244 | name: 'rJoePerSec', 245 | outputs: [ 246 | { 247 | internalType: 'uint256', 248 | name: '', 249 | type: 'uint256' 250 | } 251 | ], 252 | stateMutability: 'view', 253 | type: 'function' 254 | }, 255 | { 256 | inputs: [], 257 | name: 'renounceOwnership', 258 | outputs: [], 259 | stateMutability: 'nonpayable', 260 | type: 'function' 261 | }, 262 | { 263 | inputs: [], 264 | name: 'totalJoeStaked', 265 | outputs: [ 266 | { 267 | internalType: 'uint256', 268 | name: '', 269 | type: 'uint256' 270 | } 271 | ], 272 | stateMutability: 'view', 273 | type: 'function' 274 | }, 275 | { 276 | inputs: [ 277 | { 278 | internalType: 'address', 279 | name: 'newOwner', 280 | type: 'address' 281 | } 282 | ], 283 | name: 'transferOwnership', 284 | outputs: [], 285 | stateMutability: 'nonpayable', 286 | type: 'function' 287 | }, 288 | { 289 | inputs: [ 290 | { 291 | internalType: 'uint256', 292 | name: '_rJoePerSec', 293 | type: 'uint256' 294 | } 295 | ], 296 | name: 'updateEmissionRate', 297 | outputs: [], 298 | stateMutability: 'nonpayable', 299 | type: 'function' 300 | }, 301 | { 302 | inputs: [], 303 | name: 'updatePool', 304 | outputs: [], 305 | stateMutability: 'nonpayable', 306 | type: 'function' 307 | }, 308 | { 309 | inputs: [ 310 | { 311 | internalType: 'address', 312 | name: '', 313 | type: 'address' 314 | } 315 | ], 316 | name: 'userInfo', 317 | outputs: [ 318 | { 319 | internalType: 'uint256', 320 | name: 'amount', 321 | type: 'uint256' 322 | }, 323 | { 324 | internalType: 'uint256', 325 | name: 'rewardDebt', 326 | type: 'uint256' 327 | } 328 | ], 329 | stateMutability: 'view', 330 | type: 'function' 331 | }, 332 | { 333 | inputs: [ 334 | { 335 | internalType: 'uint256', 336 | name: '_amount', 337 | type: 'uint256' 338 | } 339 | ], 340 | name: 'withdraw', 341 | outputs: [], 342 | stateMutability: 'nonpayable', 343 | type: 'function' 344 | } 345 | ] as const 346 | -------------------------------------------------------------------------------- /src/abis/ts/StableJoeStaking.ts: -------------------------------------------------------------------------------- 1 | export const StableJoeStakingABI = [ 2 | { 3 | anonymous: false, 4 | inputs: [ 5 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 6 | { indexed: true, internalType: 'address', name: 'rewardToken', type: 'address' }, 7 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' } 8 | ], 9 | name: 'ClaimReward', 10 | type: 'event' 11 | }, 12 | { 13 | anonymous: false, 14 | inputs: [ 15 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 16 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' }, 17 | { indexed: false, internalType: 'uint256', name: 'fee', type: 'uint256' } 18 | ], 19 | name: 'Deposit', 20 | type: 'event' 21 | }, 22 | { 23 | anonymous: false, 24 | inputs: [ 25 | { indexed: false, internalType: 'uint256', name: 'newFee', type: 'uint256' }, 26 | { indexed: false, internalType: 'uint256', name: 'oldFee', type: 'uint256' } 27 | ], 28 | name: 'DepositFeeChanged', 29 | type: 'event' 30 | }, 31 | { 32 | anonymous: false, 33 | inputs: [ 34 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 35 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' } 36 | ], 37 | name: 'EmergencyWithdraw', 38 | type: 'event' 39 | }, 40 | { 41 | anonymous: false, 42 | inputs: [ 43 | { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, 44 | { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' } 45 | ], 46 | name: 'OwnershipTransferred', 47 | type: 'event' 48 | }, 49 | { 50 | anonymous: false, 51 | inputs: [{ indexed: false, internalType: 'address', name: 'token', type: 'address' }], 52 | name: 'RewardTokenAdded', 53 | type: 'event' 54 | }, 55 | { 56 | anonymous: false, 57 | inputs: [{ indexed: false, internalType: 'address', name: 'token', type: 'address' }], 58 | name: 'RewardTokenRemoved', 59 | type: 'event' 60 | }, 61 | { 62 | anonymous: false, 63 | inputs: [ 64 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 65 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' } 66 | ], 67 | name: 'Withdraw', 68 | type: 'event' 69 | }, 70 | { 71 | inputs: [], 72 | name: 'ACC_REWARD_PER_SHARE_PRECISION', 73 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 74 | stateMutability: 'view', 75 | type: 'function' 76 | }, 77 | { 78 | inputs: [], 79 | name: 'DEPOSIT_FEE_PERCENT_PRECISION', 80 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 81 | stateMutability: 'view', 82 | type: 'function' 83 | }, 84 | { 85 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 86 | name: 'accRewardPerShare', 87 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 88 | stateMutability: 'view', 89 | type: 'function' 90 | }, 91 | { 92 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '_rewardToken', type: 'address' }], 93 | name: 'addRewardToken', 94 | outputs: [], 95 | stateMutability: 'nonpayable', 96 | type: 'function' 97 | }, 98 | { 99 | inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], 100 | name: 'deposit', 101 | outputs: [], 102 | stateMutability: 'nonpayable', 103 | type: 'function' 104 | }, 105 | { 106 | inputs: [], 107 | name: 'depositFeePercent', 108 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 109 | stateMutability: 'view', 110 | type: 'function' 111 | }, 112 | { inputs: [], name: 'emergencyWithdraw', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 113 | { 114 | inputs: [], 115 | name: 'feeCollector', 116 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 117 | stateMutability: 'view', 118 | type: 'function' 119 | }, 120 | { 121 | inputs: [ 122 | { internalType: 'address', name: '_user', type: 'address' }, 123 | { internalType: 'contract IERC20Upgradeable', name: '_rewardToken', type: 'address' } 124 | ], 125 | name: 'getUserInfo', 126 | outputs: [ 127 | { internalType: 'uint256', name: '', type: 'uint256' }, 128 | { internalType: 'uint256', name: '', type: 'uint256' } 129 | ], 130 | stateMutability: 'view', 131 | type: 'function' 132 | }, 133 | { 134 | inputs: [ 135 | { internalType: 'contract IERC20Upgradeable', name: '_rewardToken', type: 'address' }, 136 | { internalType: 'contract IERC20Upgradeable', name: '_joe', type: 'address' }, 137 | { internalType: 'address', name: '_feeCollector', type: 'address' }, 138 | { internalType: 'uint256', name: '_depositFeePercent', type: 'uint256' } 139 | ], 140 | name: 'initialize', 141 | outputs: [], 142 | stateMutability: 'nonpayable', 143 | type: 'function' 144 | }, 145 | { 146 | inputs: [], 147 | name: 'internalJoeBalance', 148 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 149 | stateMutability: 'view', 150 | type: 'function' 151 | }, 152 | { 153 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 154 | name: 'isRewardToken', 155 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 156 | stateMutability: 'view', 157 | type: 'function' 158 | }, 159 | { 160 | inputs: [], 161 | name: 'joe', 162 | outputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 163 | stateMutability: 'view', 164 | type: 'function' 165 | }, 166 | { 167 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 168 | name: 'lastRewardBalance', 169 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 170 | stateMutability: 'view', 171 | type: 'function' 172 | }, 173 | { 174 | inputs: [], 175 | name: 'owner', 176 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 177 | stateMutability: 'view', 178 | type: 'function' 179 | }, 180 | { 181 | inputs: [ 182 | { internalType: 'address', name: '_user', type: 'address' }, 183 | { internalType: 'contract IERC20Upgradeable', name: '_token', type: 'address' } 184 | ], 185 | name: 'pendingReward', 186 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 187 | stateMutability: 'view', 188 | type: 'function' 189 | }, 190 | { 191 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '_rewardToken', type: 'address' }], 192 | name: 'removeRewardToken', 193 | outputs: [], 194 | stateMutability: 'nonpayable', 195 | type: 'function' 196 | }, 197 | { inputs: [], name: 'renounceOwnership', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 198 | { 199 | inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 200 | name: 'rewardTokens', 201 | outputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 202 | stateMutability: 'view', 203 | type: 'function' 204 | }, 205 | { 206 | inputs: [], 207 | name: 'rewardTokensLength', 208 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 209 | stateMutability: 'view', 210 | type: 'function' 211 | }, 212 | { 213 | inputs: [{ internalType: 'uint256', name: '_depositFeePercent', type: 'uint256' }], 214 | name: 'setDepositFeePercent', 215 | outputs: [], 216 | stateMutability: 'nonpayable', 217 | type: 'function' 218 | }, 219 | { 220 | inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], 221 | name: 'transferOwnership', 222 | outputs: [], 223 | stateMutability: 'nonpayable', 224 | type: 'function' 225 | }, 226 | { 227 | inputs: [{ internalType: 'contract IERC20Upgradeable', name: '_token', type: 'address' }], 228 | name: 'updateReward', 229 | outputs: [], 230 | stateMutability: 'nonpayable', 231 | type: 'function' 232 | }, 233 | { 234 | inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], 235 | name: 'withdraw', 236 | outputs: [], 237 | stateMutability: 'nonpayable', 238 | type: 'function' 239 | } 240 | ] as const 241 | -------------------------------------------------------------------------------- /src/abis/ts/VeJoe.ts: -------------------------------------------------------------------------------- 1 | export const VeJoeABI = [ 2 | { 3 | anonymous: false, 4 | inputs: [ 5 | { indexed: true, internalType: 'address', name: 'account', type: 'address' }, 6 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 7 | ], 8 | name: 'Burn', 9 | type: 'event' 10 | }, 11 | { 12 | anonymous: false, 13 | inputs: [ 14 | { indexed: true, internalType: 'address', name: 'beneficiary', type: 'address' }, 15 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 16 | ], 17 | name: 'Mint', 18 | type: 'event' 19 | }, 20 | { 21 | anonymous: false, 22 | inputs: [ 23 | { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, 24 | { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' } 25 | ], 26 | name: 'OwnershipTransferred', 27 | type: 'event' 28 | }, 29 | { 30 | anonymous: false, 31 | inputs: [ 32 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 33 | { indexed: false, internalType: 'address', name: 'boostedMasterChef', type: 'address' } 34 | ], 35 | name: 'UpdateBoostedMasterChefJoe', 36 | type: 'event' 37 | }, 38 | { 39 | inputs: [{ internalType: 'address', name: 'account', type: 'address' }], 40 | name: 'balanceOf', 41 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 42 | stateMutability: 'view', 43 | type: 'function' 44 | }, 45 | { 46 | inputs: [], 47 | name: 'boostedMasterChef', 48 | outputs: [{ internalType: 'contract IBoostedMasterChefJoe', name: '', type: 'address' }], 49 | stateMutability: 'view', 50 | type: 'function' 51 | }, 52 | { 53 | inputs: [ 54 | { internalType: 'address', name: '_from', type: 'address' }, 55 | { internalType: 'uint256', name: '_amount', type: 'uint256' } 56 | ], 57 | name: 'burnFrom', 58 | outputs: [], 59 | stateMutability: 'nonpayable', 60 | type: 'function' 61 | }, 62 | { 63 | inputs: [], 64 | name: 'decimals', 65 | outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], 66 | stateMutability: 'view', 67 | type: 'function' 68 | }, 69 | { 70 | inputs: [ 71 | { internalType: 'address', name: '_to', type: 'address' }, 72 | { internalType: 'uint256', name: '_amount', type: 'uint256' } 73 | ], 74 | name: 'mint', 75 | outputs: [], 76 | stateMutability: 'nonpayable', 77 | type: 'function' 78 | }, 79 | { 80 | inputs: [], 81 | name: 'name', 82 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 83 | stateMutability: 'view', 84 | type: 'function' 85 | }, 86 | { 87 | inputs: [], 88 | name: 'owner', 89 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 90 | stateMutability: 'view', 91 | type: 'function' 92 | }, 93 | { inputs: [], name: 'renounceOwnership', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 94 | { 95 | inputs: [{ internalType: 'address', name: '_boostedMasterChef', type: 'address' }], 96 | name: 'setBoostedMasterChefJoe', 97 | outputs: [], 98 | stateMutability: 'nonpayable', 99 | type: 'function' 100 | }, 101 | { 102 | inputs: [], 103 | name: 'symbol', 104 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 105 | stateMutability: 'view', 106 | type: 'function' 107 | }, 108 | { 109 | inputs: [], 110 | name: 'totalSupply', 111 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 112 | stateMutability: 'view', 113 | type: 'function' 114 | }, 115 | { 116 | inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], 117 | name: 'transferOwnership', 118 | outputs: [], 119 | stateMutability: 'nonpayable', 120 | type: 'function' 121 | } 122 | ] as const 123 | -------------------------------------------------------------------------------- /src/abis/ts/VeJoeStaking.ts: -------------------------------------------------------------------------------- 1 | export const VeJoeStakingABI = [ 2 | { 3 | anonymous: false, 4 | inputs: [ 5 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 6 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' } 7 | ], 8 | name: 'Claim', 9 | type: 'event' 10 | }, 11 | { 12 | anonymous: false, 13 | inputs: [ 14 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 15 | { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' } 16 | ], 17 | name: 'Deposit', 18 | type: 'event' 19 | }, 20 | { 21 | anonymous: false, 22 | inputs: [ 23 | { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, 24 | { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' } 25 | ], 26 | name: 'OwnershipTransferred', 27 | type: 'event' 28 | }, 29 | { 30 | anonymous: false, 31 | inputs: [ 32 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 33 | { indexed: false, internalType: 'uint256', name: 'maxCapPct', type: 'uint256' } 34 | ], 35 | name: 'UpdateMaxCapPct', 36 | type: 'event' 37 | }, 38 | { 39 | anonymous: false, 40 | inputs: [ 41 | { indexed: false, internalType: 'uint256', name: 'lastRewardTimestamp', type: 'uint256' }, 42 | { indexed: false, internalType: 'uint256', name: 'accVeJoePerShare', type: 'uint256' } 43 | ], 44 | name: 'UpdateRewardVars', 45 | type: 'event' 46 | }, 47 | { 48 | anonymous: false, 49 | inputs: [ 50 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 51 | { indexed: false, internalType: 'uint256', name: 'speedUpThreshold', type: 'uint256' } 52 | ], 53 | name: 'UpdateSpeedUpThreshold', 54 | type: 'event' 55 | }, 56 | { 57 | anonymous: false, 58 | inputs: [ 59 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 60 | { indexed: false, internalType: 'uint256', name: 'veJoePerSharePerSec', type: 'uint256' } 61 | ], 62 | name: 'UpdateVeJoePerSharePerSec', 63 | type: 'event' 64 | }, 65 | { 66 | anonymous: false, 67 | inputs: [ 68 | { indexed: true, internalType: 'address', name: 'user', type: 'address' }, 69 | { indexed: false, internalType: 'uint256', name: 'withdrawAmount', type: 'uint256' }, 70 | { indexed: false, internalType: 'uint256', name: 'burnAmount', type: 'uint256' } 71 | ], 72 | name: 'Withdraw', 73 | type: 'event' 74 | }, 75 | { 76 | inputs: [], 77 | name: 'ACC_VEJOE_PER_SHARE_PRECISION', 78 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 79 | stateMutability: 'view', 80 | type: 'function' 81 | }, 82 | { 83 | inputs: [], 84 | name: 'VEJOE_PER_SHARE_PER_SEC_PRECISION', 85 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 86 | stateMutability: 'view', 87 | type: 'function' 88 | }, 89 | { 90 | inputs: [], 91 | name: 'accVeJoePerShare', 92 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 93 | stateMutability: 'view', 94 | type: 'function' 95 | }, 96 | { inputs: [], name: 'claim', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 97 | { 98 | inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], 99 | name: 'deposit', 100 | outputs: [], 101 | stateMutability: 'nonpayable', 102 | type: 'function' 103 | }, 104 | { 105 | inputs: [{ internalType: 'address', name: '_user', type: 'address' }], 106 | name: 'getPendingVeJoe', 107 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 108 | stateMutability: 'view', 109 | type: 'function' 110 | }, 111 | { 112 | inputs: [ 113 | { internalType: 'contract IERC20Upgradeable', name: '_joe', type: 'address' }, 114 | { internalType: 'contract VeJoeToken', name: '_veJoe', type: 'address' }, 115 | { internalType: 'uint256', name: '_veJoePerSharePerSec', type: 'uint256' }, 116 | { internalType: 'uint256', name: '_speedUpVeJoePerSharePerSec', type: 'uint256' }, 117 | { internalType: 'uint256', name: '_speedUpThreshold', type: 'uint256' }, 118 | { internalType: 'uint256', name: '_speedUpDuration', type: 'uint256' }, 119 | { internalType: 'uint256', name: '_maxCapPct', type: 'uint256' } 120 | ], 121 | name: 'initialize', 122 | outputs: [], 123 | stateMutability: 'nonpayable', 124 | type: 'function' 125 | }, 126 | { 127 | inputs: [], 128 | name: 'joe', 129 | outputs: [{ internalType: 'contract IERC20Upgradeable', name: '', type: 'address' }], 130 | stateMutability: 'view', 131 | type: 'function' 132 | }, 133 | { 134 | inputs: [], 135 | name: 'lastRewardTimestamp', 136 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 137 | stateMutability: 'view', 138 | type: 'function' 139 | }, 140 | { 141 | inputs: [], 142 | name: 'maxCapPct', 143 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 144 | stateMutability: 'view', 145 | type: 'function' 146 | }, 147 | { 148 | inputs: [], 149 | name: 'owner', 150 | outputs: [{ internalType: 'address', name: '', type: 'address' }], 151 | stateMutability: 'view', 152 | type: 'function' 153 | }, 154 | { inputs: [], name: 'renounceOwnership', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 155 | { 156 | inputs: [{ internalType: 'uint256', name: '_maxCapPct', type: 'uint256' }], 157 | name: 'setMaxCapPct', 158 | outputs: [], 159 | stateMutability: 'nonpayable', 160 | type: 'function' 161 | }, 162 | { 163 | inputs: [{ internalType: 'uint256', name: '_speedUpThreshold', type: 'uint256' }], 164 | name: 'setSpeedUpThreshold', 165 | outputs: [], 166 | stateMutability: 'nonpayable', 167 | type: 'function' 168 | }, 169 | { 170 | inputs: [{ internalType: 'uint256', name: '_veJoePerSharePerSec', type: 'uint256' }], 171 | name: 'setVeJoePerSharePerSec', 172 | outputs: [], 173 | stateMutability: 'nonpayable', 174 | type: 'function' 175 | }, 176 | { 177 | inputs: [], 178 | name: 'speedUpDuration', 179 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 180 | stateMutability: 'view', 181 | type: 'function' 182 | }, 183 | { 184 | inputs: [], 185 | name: 'speedUpThreshold', 186 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 187 | stateMutability: 'view', 188 | type: 'function' 189 | }, 190 | { 191 | inputs: [], 192 | name: 'speedUpVeJoePerSharePerSec', 193 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 194 | stateMutability: 'view', 195 | type: 'function' 196 | }, 197 | { 198 | inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], 199 | name: 'transferOwnership', 200 | outputs: [], 201 | stateMutability: 'nonpayable', 202 | type: 'function' 203 | }, 204 | { inputs: [], name: 'updateRewardVars', outputs: [], stateMutability: 'nonpayable', type: 'function' }, 205 | { 206 | inputs: [], 207 | name: 'upperLimitMaxCapPct', 208 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 209 | stateMutability: 'view', 210 | type: 'function' 211 | }, 212 | { 213 | inputs: [], 214 | name: 'upperLimitVeJoePerSharePerSec', 215 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 216 | stateMutability: 'view', 217 | type: 'function' 218 | }, 219 | { 220 | inputs: [{ internalType: 'address', name: '', type: 'address' }], 221 | name: 'userInfos', 222 | outputs: [ 223 | { internalType: 'uint256', name: 'balance', type: 'uint256' }, 224 | { internalType: 'uint256', name: 'rewardDebt', type: 'uint256' }, 225 | { internalType: 'uint256', name: 'lastClaimTimestamp', type: 'uint256' }, 226 | { internalType: 'uint256', name: 'speedUpEndTimestamp', type: 'uint256' } 227 | ], 228 | stateMutability: 'view', 229 | type: 'function' 230 | }, 231 | { 232 | inputs: [], 233 | name: 'veJoe', 234 | outputs: [{ internalType: 'contract VeJoeToken', name: '', type: 'address' }], 235 | stateMutability: 'view', 236 | type: 'function' 237 | }, 238 | { 239 | inputs: [], 240 | name: 'veJoePerSharePerSec', 241 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 242 | stateMutability: 'view', 243 | type: 'function' 244 | }, 245 | { 246 | inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], 247 | name: 'withdraw', 248 | outputs: [], 249 | stateMutability: 'nonpayable', 250 | type: 'function' 251 | } 252 | ] as const 253 | -------------------------------------------------------------------------------- /src/abis/ts/WNative.ts: -------------------------------------------------------------------------------- 1 | export const WNativeABI = [ 2 | { 3 | anonymous: false, 4 | inputs: [ 5 | { indexed: true, internalType: 'address', name: 'src', type: 'address' }, 6 | { indexed: true, internalType: 'address', name: 'guy', type: 'address' }, 7 | { indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' } 8 | ], 9 | name: 'Approval', 10 | type: 'event' 11 | }, 12 | { 13 | anonymous: false, 14 | inputs: [ 15 | { indexed: true, internalType: 'address', name: 'dst', type: 'address' }, 16 | { indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' } 17 | ], 18 | name: 'Deposit', 19 | type: 'event' 20 | }, 21 | { 22 | anonymous: false, 23 | inputs: [ 24 | { indexed: true, internalType: 'address', name: 'src', type: 'address' }, 25 | { indexed: true, internalType: 'address', name: 'dst', type: 'address' }, 26 | { indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' } 27 | ], 28 | name: 'Transfer', 29 | type: 'event' 30 | }, 31 | { 32 | anonymous: false, 33 | inputs: [ 34 | { indexed: true, internalType: 'address', name: 'src', type: 'address' }, 35 | { indexed: false, internalType: 'uint256', name: 'wad', type: 'uint256' } 36 | ], 37 | name: 'Withdrawal', 38 | type: 'event' 39 | }, 40 | { payable: true, stateMutability: 'payable', type: 'fallback' }, 41 | { 42 | constant: true, 43 | inputs: [ 44 | { internalType: 'address', name: '', type: 'address' }, 45 | { internalType: 'address', name: '', type: 'address' } 46 | ], 47 | name: 'allowance', 48 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 49 | payable: false, 50 | stateMutability: 'view', 51 | type: 'function' 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { internalType: 'address', name: 'guy', type: 'address' }, 57 | { internalType: 'uint256', name: 'wad', type: 'uint256' } 58 | ], 59 | name: 'approve', 60 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 61 | payable: false, 62 | stateMutability: 'nonpayable', 63 | type: 'function' 64 | }, 65 | { 66 | constant: true, 67 | inputs: [{ internalType: 'address', name: '', type: 'address' }], 68 | name: 'balanceOf', 69 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 70 | payable: false, 71 | stateMutability: 'view', 72 | type: 'function' 73 | }, 74 | { 75 | constant: true, 76 | inputs: [], 77 | name: 'decimals', 78 | outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], 79 | payable: false, 80 | stateMutability: 'view', 81 | type: 'function' 82 | }, 83 | { 84 | constant: false, 85 | inputs: [], 86 | name: 'deposit', 87 | outputs: [], 88 | payable: true, 89 | stateMutability: 'payable', 90 | type: 'function' 91 | }, 92 | { 93 | constant: true, 94 | inputs: [], 95 | name: 'name', 96 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 97 | payable: false, 98 | stateMutability: 'view', 99 | type: 'function' 100 | }, 101 | { 102 | constant: true, 103 | inputs: [], 104 | name: 'symbol', 105 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 106 | payable: false, 107 | stateMutability: 'view', 108 | type: 'function' 109 | }, 110 | { 111 | constant: true, 112 | inputs: [], 113 | name: 'totalSupply', 114 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 115 | payable: false, 116 | stateMutability: 'view', 117 | type: 'function' 118 | }, 119 | { 120 | constant: false, 121 | inputs: [ 122 | { internalType: 'address', name: 'dst', type: 'address' }, 123 | { internalType: 'uint256', name: 'wad', type: 'uint256' } 124 | ], 125 | name: 'transfer', 126 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 127 | payable: false, 128 | stateMutability: 'nonpayable', 129 | type: 'function' 130 | }, 131 | { 132 | constant: false, 133 | inputs: [ 134 | { internalType: 'address', name: 'src', type: 'address' }, 135 | { internalType: 'address', name: 'dst', type: 'address' }, 136 | { internalType: 'uint256', name: 'wad', type: 'uint256' } 137 | ], 138 | name: 'transferFrom', 139 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 140 | payable: false, 141 | stateMutability: 'nonpayable', 142 | type: 'function' 143 | }, 144 | { 145 | constant: false, 146 | inputs: [{ internalType: 'uint256', name: 'wad', type: 'uint256' }], 147 | name: 'withdraw', 148 | outputs: [], 149 | payable: false, 150 | stateMutability: 'nonpayable', 151 | type: 'function' 152 | } 153 | ] as const 154 | -------------------------------------------------------------------------------- /src/abis/ts/XJoeStaking.ts: -------------------------------------------------------------------------------- 1 | export const XJoeStakingABI = [ 2 | { 3 | inputs: [{ internalType: 'contract IERC20', name: '_joe', type: 'address' }], 4 | stateMutability: 'nonpayable', 5 | type: 'constructor' 6 | }, 7 | { 8 | anonymous: false, 9 | inputs: [ 10 | { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, 11 | { indexed: true, internalType: 'address', name: 'spender', type: 'address' }, 12 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 13 | ], 14 | name: 'Approval', 15 | type: 'event' 16 | }, 17 | { 18 | anonymous: false, 19 | inputs: [ 20 | { indexed: true, internalType: 'address', name: 'from', type: 'address' }, 21 | { indexed: true, internalType: 'address', name: 'to', type: 'address' }, 22 | { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } 23 | ], 24 | name: 'Transfer', 25 | type: 'event' 26 | }, 27 | { 28 | inputs: [ 29 | { internalType: 'address', name: 'owner', type: 'address' }, 30 | { internalType: 'address', name: 'spender', type: 'address' } 31 | ], 32 | name: 'allowance', 33 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 34 | stateMutability: 'view', 35 | type: 'function' 36 | }, 37 | { 38 | inputs: [ 39 | { internalType: 'address', name: 'spender', type: 'address' }, 40 | { internalType: 'uint256', name: 'amount', type: 'uint256' } 41 | ], 42 | name: 'approve', 43 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 44 | stateMutability: 'nonpayable', 45 | type: 'function' 46 | }, 47 | { 48 | inputs: [{ internalType: 'address', name: 'account', type: 'address' }], 49 | name: 'balanceOf', 50 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 51 | stateMutability: 'view', 52 | type: 'function' 53 | }, 54 | { 55 | inputs: [], 56 | name: 'decimals', 57 | outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], 58 | stateMutability: 'view', 59 | type: 'function' 60 | }, 61 | { 62 | inputs: [ 63 | { internalType: 'address', name: 'spender', type: 'address' }, 64 | { internalType: 'uint256', name: 'subtractedValue', type: 'uint256' } 65 | ], 66 | name: 'decreaseAllowance', 67 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 68 | stateMutability: 'nonpayable', 69 | type: 'function' 70 | }, 71 | { 72 | inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], 73 | name: 'enter', 74 | outputs: [], 75 | stateMutability: 'nonpayable', 76 | type: 'function' 77 | }, 78 | { 79 | inputs: [ 80 | { internalType: 'address', name: 'spender', type: 'address' }, 81 | { internalType: 'uint256', name: 'addedValue', type: 'uint256' } 82 | ], 83 | name: 'increaseAllowance', 84 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 85 | stateMutability: 'nonpayable', 86 | type: 'function' 87 | }, 88 | { 89 | inputs: [], 90 | name: 'joe', 91 | outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }], 92 | stateMutability: 'view', 93 | type: 'function' 94 | }, 95 | { 96 | inputs: [{ internalType: 'uint256', name: '_share', type: 'uint256' }], 97 | name: 'leave', 98 | outputs: [], 99 | stateMutability: 'nonpayable', 100 | type: 'function' 101 | }, 102 | { 103 | inputs: [], 104 | name: 'name', 105 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 106 | stateMutability: 'view', 107 | type: 'function' 108 | }, 109 | { 110 | inputs: [], 111 | name: 'symbol', 112 | outputs: [{ internalType: 'string', name: '', type: 'string' }], 113 | stateMutability: 'view', 114 | type: 'function' 115 | }, 116 | { 117 | inputs: [], 118 | name: 'totalSupply', 119 | outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], 120 | stateMutability: 'view', 121 | type: 'function' 122 | }, 123 | { 124 | inputs: [ 125 | { internalType: 'address', name: 'recipient', type: 'address' }, 126 | { internalType: 'uint256', name: 'amount', type: 'uint256' } 127 | ], 128 | name: 'transfer', 129 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 130 | stateMutability: 'nonpayable', 131 | type: 'function' 132 | }, 133 | { 134 | inputs: [ 135 | { internalType: 'address', name: 'sender', type: 'address' }, 136 | { internalType: 'address', name: 'recipient', type: 'address' }, 137 | { internalType: 'uint256', name: 'amount', type: 'uint256' } 138 | ], 139 | name: 'transferFrom', 140 | outputs: [{ internalType: 'bool', name: '', type: 'bool' }], 141 | stateMutability: 'nonpayable', 142 | type: 'function' 143 | } 144 | ] as const 145 | -------------------------------------------------------------------------------- /src/abis/ts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ERC20' 2 | export * from './JoePair' 3 | export * from './RocketJoeStaking' 4 | export * from './Router' 5 | export * from './StableJoeStaking' 6 | export * from './VeJoe' 7 | export * from './VeJoeStaking' 8 | export * from './WNative' 9 | export * from './XJoeStaking' 10 | -------------------------------------------------------------------------------- /src/declarations.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'toformat' 2 | -------------------------------------------------------------------------------- /src/entities/currency.ts: -------------------------------------------------------------------------------- 1 | import JSBI from 'jsbi' 2 | import { Token } from './token' 3 | import { SolidityType } from '../constants' 4 | import { validateSolidityTypeInstance } from '../utils' 5 | 6 | /** 7 | * Represents the native currency of the chain on which it resides, e.g. ETH, AVAX 8 | */ 9 | export class NativeCurrency { 10 | public readonly decimals: number 11 | public readonly symbol?: string 12 | public readonly name?: string 13 | public readonly isNative: true = true 14 | public readonly isToken: false = false 15 | public readonly chainId: number 16 | 17 | /** 18 | * Constructs an instance of the base class `NativeCurrency`. 19 | * @param chainId the chain ID on which this currency resides 20 | * @param decimals decimals of the currency 21 | * @param symbol symbol of the currency 22 | * @param name of the currency 23 | */ 24 | constructor(chainId: number, decimals: number, symbol?: string, name?: string) { 25 | validateSolidityTypeInstance(JSBI.BigInt(decimals), SolidityType.uint8) 26 | this.chainId = chainId 27 | this.decimals = decimals 28 | this.symbol = symbol 29 | this.name = name 30 | } 31 | 32 | public equals(other: NativeCurrency): boolean { 33 | return other.isNative && other.chainId === this.chainId 34 | } 35 | } 36 | 37 | /* 38 | * CNATIVE is the main usage of a 'native' currency, i.e. ETH, AVAX, BNB 39 | */ 40 | export class CNATIVE extends NativeCurrency { 41 | constructor(chainId: number) { 42 | const symbol = [43113, 43114].includes(chainId) ? 'AVAX' : 56 === chainId ? 'BNB' : 97 === chainId ? 'tBNB' : 'ETH' 43 | const name = [43113, 43114].includes(chainId) ? 'Avalanche' : [56, 97].includes(chainId) ? 'BNB' : 'Ethereum' 44 | super(chainId, 18, symbol, name) 45 | } 46 | public equals(other: NativeCurrency): boolean { 47 | return other.isNative && other.chainId === this.chainId 48 | } 49 | 50 | private static _etherCache: { [chainId: number]: CNATIVE } = {} 51 | 52 | public static onChain(chainId: number): CNATIVE { 53 | return this._etherCache[chainId] ?? (this._etherCache[chainId] = new CNATIVE(chainId)) 54 | } 55 | } 56 | 57 | /** 58 | * for backward compatibility 59 | */ 60 | const CAVAX = CNATIVE.onChain(43114) 61 | export { CAVAX } 62 | 63 | /** 64 | * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies 65 | */ 66 | export type Currency = NativeCurrency | Token 67 | -------------------------------------------------------------------------------- /src/entities/fractions/currencyAmount.ts: -------------------------------------------------------------------------------- 1 | import { currencyEquals } from '../token' 2 | import { Currency, CNATIVE } from '../currency' 3 | import invariant from 'tiny-invariant' 4 | import JSBI from 'jsbi' 5 | import _Big from 'big.js' 6 | import toFormat from 'toformat' 7 | 8 | import { BigintIsh, Rounding, TEN, SolidityType } from '../../constants' 9 | import { parseBigintIsh, validateSolidityTypeInstance } from '../../utils' 10 | import { Fraction } from './fraction' 11 | 12 | const Big = toFormat(_Big) 13 | 14 | export class CurrencyAmount extends Fraction { 15 | public readonly currency: Currency 16 | 17 | /** 18 | * Helper that calls the constructor with the CNATIVE currency 19 | * @param chainId the chain on which the CNATIVE exists 20 | * @param rawAmount CNATIVE amount in wei 21 | */ 22 | public static ether(chainId: number, amount: BigintIsh): CurrencyAmount { 23 | return new CurrencyAmount(CNATIVE.onChain(chainId), amount) 24 | } 25 | 26 | // amount _must_ be raw, i.e. in the native representation 27 | protected constructor(currency: Currency, amount: BigintIsh) { 28 | const parsedAmount = parseBigintIsh(amount) 29 | validateSolidityTypeInstance(parsedAmount, SolidityType.uint256) 30 | 31 | super(parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(currency.decimals))) 32 | this.currency = currency 33 | } 34 | 35 | public get raw(): JSBI { 36 | return this.numerator 37 | } 38 | 39 | public add(other: CurrencyAmount): CurrencyAmount { 40 | invariant(currencyEquals(this.currency, other.currency), 'TOKEN') 41 | return new CurrencyAmount(this.currency, JSBI.add(this.raw, other.raw)) 42 | } 43 | 44 | public subtract(other: CurrencyAmount): CurrencyAmount { 45 | invariant(currencyEquals(this.currency, other.currency), 'TOKEN') 46 | return new CurrencyAmount(this.currency, JSBI.subtract(this.raw, other.raw)) 47 | } 48 | 49 | public toSignificant( 50 | significantDigits: number = 6, 51 | format?: object, 52 | rounding: Rounding = Rounding.ROUND_DOWN 53 | ): string { 54 | return super.toSignificant(significantDigits, format, rounding) 55 | } 56 | 57 | public toFixed( 58 | decimalPlaces: number = this.currency.decimals, 59 | format?: object, 60 | rounding: Rounding = Rounding.ROUND_DOWN 61 | ): string { 62 | invariant(decimalPlaces <= this.currency.decimals, 'DECIMALS') 63 | return super.toFixed(decimalPlaces, format, rounding) 64 | } 65 | 66 | public toExact(format: object = { groupSeparator: '' }): string { 67 | Big.DP = this.currency.decimals 68 | return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(format) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/entities/fractions/fraction.ts: -------------------------------------------------------------------------------- 1 | import invariant from 'tiny-invariant' 2 | import JSBI from 'jsbi' 3 | import _Decimal from 'decimal.js-light' 4 | import _Big, { RoundingMode } from 'big.js' 5 | import toFormat from 'toformat' 6 | 7 | import { BigintIsh, Rounding } from '../../constants' 8 | import { ONE } from '../../constants' 9 | import { parseBigintIsh } from '../../utils' 10 | 11 | const Decimal = toFormat(_Decimal) 12 | const Big = toFormat(_Big) 13 | 14 | const toSignificantRounding = { 15 | [Rounding.ROUND_DOWN]: Decimal.ROUND_DOWN, 16 | [Rounding.ROUND_HALF_UP]: Decimal.ROUND_HALF_UP, 17 | [Rounding.ROUND_UP]: Decimal.ROUND_UP 18 | } 19 | 20 | const toFixedRounding = { 21 | [Rounding.ROUND_DOWN]: RoundingMode.RoundDown, 22 | [Rounding.ROUND_HALF_UP]: RoundingMode.RoundHalfUp, 23 | [Rounding.ROUND_UP]: RoundingMode.RoundUp 24 | } 25 | 26 | export class Fraction { 27 | public readonly numerator: JSBI 28 | public readonly denominator: JSBI 29 | 30 | public constructor(numerator: BigintIsh, denominator: BigintIsh = ONE) { 31 | this.numerator = parseBigintIsh(numerator) 32 | this.denominator = parseBigintIsh(denominator) 33 | } 34 | 35 | // performs floor division 36 | public get quotient(): JSBI { 37 | return JSBI.divide(this.numerator, this.denominator) 38 | } 39 | 40 | // remainder after floor division 41 | public get remainder(): Fraction { 42 | return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator) 43 | } 44 | 45 | public invert(): Fraction { 46 | return new Fraction(this.denominator, this.numerator) 47 | } 48 | 49 | public add(other: Fraction | BigintIsh): Fraction { 50 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 51 | if (JSBI.equal(this.denominator, otherParsed.denominator)) { 52 | return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator) 53 | } 54 | return new Fraction( 55 | JSBI.add( 56 | JSBI.multiply(this.numerator, otherParsed.denominator), 57 | JSBI.multiply(otherParsed.numerator, this.denominator) 58 | ), 59 | JSBI.multiply(this.denominator, otherParsed.denominator) 60 | ) 61 | } 62 | 63 | public subtract(other: Fraction | BigintIsh): Fraction { 64 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 65 | if (JSBI.equal(this.denominator, otherParsed.denominator)) { 66 | return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator) 67 | } 68 | return new Fraction( 69 | JSBI.subtract( 70 | JSBI.multiply(this.numerator, otherParsed.denominator), 71 | JSBI.multiply(otherParsed.numerator, this.denominator) 72 | ), 73 | JSBI.multiply(this.denominator, otherParsed.denominator) 74 | ) 75 | } 76 | 77 | public lessThan(other: Fraction | BigintIsh): boolean { 78 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 79 | return JSBI.lessThan( 80 | JSBI.multiply(this.numerator, otherParsed.denominator), 81 | JSBI.multiply(otherParsed.numerator, this.denominator) 82 | ) 83 | } 84 | 85 | public equalTo(other: Fraction | BigintIsh): boolean { 86 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 87 | return JSBI.equal( 88 | JSBI.multiply(this.numerator, otherParsed.denominator), 89 | JSBI.multiply(otherParsed.numerator, this.denominator) 90 | ) 91 | } 92 | 93 | public greaterThan(other: Fraction | BigintIsh): boolean { 94 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 95 | return JSBI.greaterThan( 96 | JSBI.multiply(this.numerator, otherParsed.denominator), 97 | JSBI.multiply(otherParsed.numerator, this.denominator) 98 | ) 99 | } 100 | 101 | public multiply(other: Fraction | BigintIsh): Fraction { 102 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 103 | return new Fraction( 104 | JSBI.multiply(this.numerator, otherParsed.numerator), 105 | JSBI.multiply(this.denominator, otherParsed.denominator) 106 | ) 107 | } 108 | 109 | public divide(other: Fraction | BigintIsh): Fraction { 110 | const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) 111 | return new Fraction( 112 | JSBI.multiply(this.numerator, otherParsed.denominator), 113 | JSBI.multiply(this.denominator, otherParsed.numerator) 114 | ) 115 | } 116 | 117 | public toSignificant( 118 | significantDigits: number, 119 | format: object = { groupSeparator: '' }, 120 | rounding: Rounding = Rounding.ROUND_HALF_UP 121 | ): string { 122 | invariant(Number.isInteger(significantDigits), `${significantDigits} is not an integer.`) 123 | invariant(significantDigits > 0, `${significantDigits} is not positive.`) 124 | 125 | Decimal.set({ precision: significantDigits + 1, rounding: toSignificantRounding[rounding] }) 126 | const quotient = new Decimal(this.numerator.toString()) 127 | .div(this.denominator.toString()) 128 | .toSignificantDigits(significantDigits) 129 | return quotient.toFormat(quotient.decimalPlaces(), format) 130 | } 131 | 132 | public toFixed( 133 | decimalPlaces: number, 134 | format: object = { groupSeparator: '' }, 135 | rounding: Rounding = Rounding.ROUND_HALF_UP 136 | ): string { 137 | invariant(Number.isInteger(decimalPlaces), `${decimalPlaces} is not an integer.`) 138 | invariant(decimalPlaces >= 0, `${decimalPlaces} is negative.`) 139 | 140 | Big.DP = decimalPlaces 141 | Big.RM = toFixedRounding[rounding] 142 | return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format) 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/entities/fractions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './fraction' 2 | export * from './percent' 3 | export * from './tokenAmount' 4 | export * from './currencyAmount' 5 | export * from './price' 6 | -------------------------------------------------------------------------------- /src/entities/fractions/percent.ts: -------------------------------------------------------------------------------- 1 | import { Rounding, _100 } from '../../constants' 2 | import { Fraction } from './fraction' 3 | 4 | const _100_PERCENT = new Fraction(_100) 5 | 6 | export class Percent extends Fraction { 7 | public toSignificant(significantDigits: number = 5, format?: object, rounding?: Rounding): string { 8 | return this.multiply(_100_PERCENT).toSignificant(significantDigits, format, rounding) 9 | } 10 | 11 | public toFixed(decimalPlaces: number = 2, format?: object, rounding?: Rounding): string { 12 | return this.multiply(_100_PERCENT).toFixed(decimalPlaces, format, rounding) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/entities/fractions/price.ts: -------------------------------------------------------------------------------- 1 | import { Token } from '../token' 2 | import { TokenAmount } from './tokenAmount' 3 | import { currencyEquals } from '../token' 4 | import invariant from 'tiny-invariant' 5 | import JSBI from 'jsbi' 6 | 7 | import { BigintIsh, Rounding, TEN } from '../../constants' 8 | import { Currency } from '../currency' 9 | import { Route } from '../route' 10 | import { Fraction } from './fraction' 11 | import { CurrencyAmount } from './currencyAmount' 12 | 13 | export class Price extends Fraction { 14 | public readonly baseCurrency: Currency // input i.e. denominator 15 | public readonly quoteCurrency: Currency // output i.e. numerator 16 | public readonly scalar: Fraction // used to adjust the raw fraction w/r/t the decimals of the {base,quote}Token 17 | 18 | public static fromRoute(route: Route): Price { 19 | const prices: Price[] = [] 20 | for (const [i, pair] of route.pairs.entries()) { 21 | prices.push( 22 | route.path[i].equals(pair.token0) 23 | ? new Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.raw, pair.reserve1.raw) 24 | : new Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.raw, pair.reserve0.raw) 25 | ) 26 | } 27 | return prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]) 28 | } 29 | 30 | // denominator and numerator _must_ be raw, i.e. in the native representation 31 | public constructor(baseCurrency: Currency, quoteCurrency: Currency, denominator: BigintIsh, numerator: BigintIsh) { 32 | super(numerator, denominator) 33 | 34 | this.baseCurrency = baseCurrency 35 | this.quoteCurrency = quoteCurrency 36 | this.scalar = new Fraction( 37 | JSBI.exponentiate(TEN, JSBI.BigInt(baseCurrency.decimals)), 38 | JSBI.exponentiate(TEN, JSBI.BigInt(quoteCurrency.decimals)) 39 | ) 40 | } 41 | 42 | public get raw(): Fraction { 43 | return new Fraction(this.numerator, this.denominator) 44 | } 45 | 46 | public get adjusted(): Fraction { 47 | return super.multiply(this.scalar) 48 | } 49 | 50 | public invert(): Price { 51 | return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator) 52 | } 53 | 54 | public multiply(other: Price): Price { 55 | invariant(currencyEquals(this.quoteCurrency, other.baseCurrency), 'TOKEN') 56 | const fraction = super.multiply(other) 57 | return new Price(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator) 58 | } 59 | 60 | // performs floor division on overflow 61 | public quote(currencyAmount: CurrencyAmount): CurrencyAmount { 62 | invariant(currencyEquals(currencyAmount.currency, this.baseCurrency), 'TOKEN') 63 | if (this.quoteCurrency instanceof Token) { 64 | return new TokenAmount(this.quoteCurrency, super.multiply(currencyAmount.raw).quotient) 65 | } 66 | return CurrencyAmount.ether(currencyAmount.currency.chainId, super.multiply(currencyAmount.raw).quotient) 67 | } 68 | 69 | public toSignificant(significantDigits: number = 6, format?: object, rounding?: Rounding): string { 70 | return this.adjusted.toSignificant(significantDigits, format, rounding) 71 | } 72 | 73 | public toFixed(decimalPlaces: number = 4, format?: object, rounding?: Rounding): string { 74 | return this.adjusted.toFixed(decimalPlaces, format, rounding) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/entities/fractions/tokenAmount.ts: -------------------------------------------------------------------------------- 1 | import { CurrencyAmount } from './currencyAmount' 2 | import { Token } from '../token' 3 | import invariant from 'tiny-invariant' 4 | import JSBI from 'jsbi' 5 | 6 | import { BigintIsh } from '../../constants' 7 | 8 | export class TokenAmount extends CurrencyAmount { 9 | public readonly token: Token 10 | 11 | // amount _must_ be raw, i.e. in the native representation 12 | public constructor(token: Token, amount: BigintIsh) { 13 | super(token, amount) 14 | this.token = token 15 | } 16 | 17 | public add(other: TokenAmount): TokenAmount { 18 | invariant(this.token.equals(other.token), 'TOKEN') 19 | return new TokenAmount(this.token, JSBI.add(this.raw, other.raw)) 20 | } 21 | 22 | public subtract(other: TokenAmount): TokenAmount { 23 | invariant(this.token.equals(other.token), 'TOKEN') 24 | return new TokenAmount(this.token, JSBI.subtract(this.raw, other.raw)) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './token' 2 | export * from './pair' 3 | export * from './route' 4 | export * from './trade' 5 | export * from './currency' 6 | 7 | export * from './fractions' 8 | -------------------------------------------------------------------------------- /src/entities/pair.ts: -------------------------------------------------------------------------------- 1 | import { Price } from './fractions/price' 2 | import { TokenAmount } from './fractions/tokenAmount' 3 | import invariant from 'tiny-invariant' 4 | import JSBI from 'jsbi' 5 | import { getAddress, keccak256, encodePacked, toBytes, pad, ByteArray, slice, concat } from 'viem' 6 | 7 | import { 8 | BigintIsh, 9 | FACTORY_ADDRESS, 10 | INIT_CODE_HASH, 11 | MINIMUM_LIQUIDITY, 12 | ZERO, 13 | ONE, 14 | FIVE, 15 | _997, 16 | _1000, 17 | ChainId 18 | } from '../constants' 19 | import { sqrt, parseBigintIsh } from '../utils' 20 | import { InsufficientReservesError, InsufficientInputAmountError } from '../errors' 21 | import { Token } from './token' 22 | 23 | let PAIR_ADDRESS_CACHE: { [token0Address: string]: { [token1Address: string]: string } } = {} 24 | 25 | export class Pair { 26 | public readonly liquidityToken: Token 27 | private readonly tokenAmounts: [TokenAmount, TokenAmount] 28 | 29 | public static getAddress(tokenA: Token, tokenB: Token, chainId: ChainId): string { 30 | const tokens = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA] // does safety checks 31 | 32 | if (PAIR_ADDRESS_CACHE?.[tokens[0].address]?.[tokens[1].address] === undefined) { 33 | const from = toBytes(getAddress(FACTORY_ADDRESS[chainId])) 34 | const salt = pad( 35 | keccak256( 36 | encodePacked(['address', 'address'], [getAddress(tokens[0].address), getAddress(tokens[1].address)]), 37 | 'bytes' 38 | ), 39 | { 40 | size: 32 41 | } 42 | ) as ByteArray 43 | const bytecodeHash = toBytes(INIT_CODE_HASH[chainId]) 44 | PAIR_ADDRESS_CACHE = { 45 | ...PAIR_ADDRESS_CACHE, 46 | [tokens[0].address]: { 47 | ...PAIR_ADDRESS_CACHE?.[tokens[0].address], 48 | [tokens[1].address]: getAddress(slice(keccak256(concat([toBytes('0xff'), from, salt, bytecodeHash])), 12)) 49 | } 50 | } 51 | } 52 | 53 | return PAIR_ADDRESS_CACHE[tokens[0].address][tokens[1].address] 54 | } 55 | 56 | public constructor(tokenAmountA: TokenAmount, tokenAmountB: TokenAmount, chainId: ChainId) { 57 | const tokenAmounts = tokenAmountA.token.sortsBefore(tokenAmountB.token) // does safety checks 58 | ? [tokenAmountA, tokenAmountB] 59 | : [tokenAmountB, tokenAmountA] 60 | this.liquidityToken = new Token( 61 | tokenAmounts[0].token.chainId, 62 | Pair.getAddress(tokenAmounts[0].token, tokenAmounts[1].token, chainId), 63 | 18, 64 | 'JLP', 65 | 'Joe Liquidity' 66 | ) 67 | this.tokenAmounts = tokenAmounts as [TokenAmount, TokenAmount] 68 | } 69 | 70 | /** 71 | * Returns true if the token is either token0 or token1 72 | * @param token to check 73 | */ 74 | public involvesToken(token: Token): boolean { 75 | return token.equals(this.token0) || token.equals(this.token1) 76 | } 77 | 78 | /** 79 | * Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0 80 | */ 81 | public get token0Price(): Price { 82 | return new Price(this.token0, this.token1, this.tokenAmounts[0].raw, this.tokenAmounts[1].raw) 83 | } 84 | 85 | /** 86 | * Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1 87 | */ 88 | public get token1Price(): Price { 89 | return new Price(this.token1, this.token0, this.tokenAmounts[1].raw, this.tokenAmounts[0].raw) 90 | } 91 | 92 | /** 93 | * Return the price of the given token in terms of the other token in the pair. 94 | * @param token token to return price of 95 | */ 96 | public priceOf(token: Token): Price { 97 | invariant(this.involvesToken(token), 'TOKEN') 98 | return token.equals(this.token0) ? this.token0Price : this.token1Price 99 | } 100 | 101 | /** 102 | * Returns the chain ID of the tokens in the pair. 103 | */ 104 | public get chainId(): ChainId { 105 | return this.token0.chainId 106 | } 107 | 108 | public get token0(): Token { 109 | return this.tokenAmounts[0].token 110 | } 111 | 112 | public get token1(): Token { 113 | return this.tokenAmounts[1].token 114 | } 115 | 116 | public get reserve0(): TokenAmount { 117 | return this.tokenAmounts[0] 118 | } 119 | 120 | public get reserve1(): TokenAmount { 121 | return this.tokenAmounts[1] 122 | } 123 | 124 | public reserveOf(token: Token): TokenAmount { 125 | invariant(this.involvesToken(token), 'TOKEN') 126 | return token.equals(this.token0) ? this.reserve0 : this.reserve1 127 | } 128 | 129 | public getOutputAmount(inputAmount: TokenAmount, chainId: ChainId): [TokenAmount, Pair] { 130 | invariant(this.involvesToken(inputAmount.token), 'TOKEN') 131 | if (JSBI.equal(this.reserve0.raw, ZERO) || JSBI.equal(this.reserve1.raw, ZERO)) { 132 | throw new InsufficientReservesError() 133 | } 134 | const inputReserve = this.reserveOf(inputAmount.token) 135 | const outputReserve = this.reserveOf(inputAmount.token.equals(this.token0) ? this.token1 : this.token0) 136 | const inputAmountWithFee = JSBI.multiply(inputAmount.raw, _997) 137 | const numerator = JSBI.multiply(inputAmountWithFee, outputReserve.raw) 138 | const denominator = JSBI.add(JSBI.multiply(inputReserve.raw, _1000), inputAmountWithFee) 139 | const outputAmount = new TokenAmount( 140 | inputAmount.token.equals(this.token0) ? this.token1 : this.token0, 141 | JSBI.divide(numerator, denominator) 142 | ) 143 | if (JSBI.equal(outputAmount.raw, ZERO)) { 144 | throw new InsufficientInputAmountError() 145 | } 146 | return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount), chainId)] 147 | } 148 | 149 | public getInputAmount(outputAmount: TokenAmount, chainId: ChainId): [TokenAmount, Pair] { 150 | invariant(this.involvesToken(outputAmount.token), 'TOKEN') 151 | if ( 152 | JSBI.equal(this.reserve0.raw, ZERO) || 153 | JSBI.equal(this.reserve1.raw, ZERO) || 154 | JSBI.greaterThanOrEqual(outputAmount.raw, this.reserveOf(outputAmount.token).raw) 155 | ) { 156 | throw new InsufficientReservesError() 157 | } 158 | 159 | const outputReserve = this.reserveOf(outputAmount.token) 160 | const inputReserve = this.reserveOf(outputAmount.token.equals(this.token0) ? this.token1 : this.token0) 161 | const numerator = JSBI.multiply(JSBI.multiply(inputReserve.raw, outputAmount.raw), _1000) 162 | const denominator = JSBI.multiply(JSBI.subtract(outputReserve.raw, outputAmount.raw), _997) 163 | const inputAmount = new TokenAmount( 164 | outputAmount.token.equals(this.token0) ? this.token1 : this.token0, 165 | JSBI.add(JSBI.divide(numerator, denominator), ONE) 166 | ) 167 | return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount), chainId)] 168 | } 169 | 170 | public getLiquidityMinted( 171 | totalSupply: TokenAmount, 172 | tokenAmountA: TokenAmount, 173 | tokenAmountB: TokenAmount 174 | ): TokenAmount { 175 | invariant(totalSupply.token.equals(this.liquidityToken), 'LIQUIDITY') 176 | const tokenAmounts = tokenAmountA.token.sortsBefore(tokenAmountB.token) // does safety checks 177 | ? [tokenAmountA, tokenAmountB] 178 | : [tokenAmountB, tokenAmountA] 179 | invariant(tokenAmounts[0].token.equals(this.token0) && tokenAmounts[1].token.equals(this.token1), 'TOKEN') 180 | 181 | let liquidity: JSBI 182 | if (JSBI.equal(totalSupply.raw, ZERO)) { 183 | liquidity = JSBI.subtract(sqrt(JSBI.multiply(tokenAmounts[0].raw, tokenAmounts[1].raw)), MINIMUM_LIQUIDITY) 184 | } else { 185 | const amount0 = JSBI.divide(JSBI.multiply(tokenAmounts[0].raw, totalSupply.raw), this.reserve0.raw) 186 | const amount1 = JSBI.divide(JSBI.multiply(tokenAmounts[1].raw, totalSupply.raw), this.reserve1.raw) 187 | liquidity = JSBI.lessThanOrEqual(amount0, amount1) ? amount0 : amount1 188 | } 189 | if (!JSBI.greaterThan(liquidity, ZERO)) { 190 | throw new InsufficientInputAmountError() 191 | } 192 | return new TokenAmount(this.liquidityToken, liquidity) 193 | } 194 | 195 | public getLiquidityValue( 196 | token: Token, 197 | totalSupply: TokenAmount, 198 | liquidity: TokenAmount, 199 | feeOn: boolean = false, 200 | kLast?: BigintIsh 201 | ): TokenAmount { 202 | invariant(this.involvesToken(token), 'TOKEN') 203 | invariant(totalSupply.token.equals(this.liquidityToken), 'TOTAL_SUPPLY') 204 | invariant(liquidity.token.equals(this.liquidityToken), 'LIQUIDITY') 205 | invariant(JSBI.lessThanOrEqual(liquidity.raw, totalSupply.raw), 'LIQUIDITY') 206 | 207 | let totalSupplyAdjusted: TokenAmount 208 | if (!feeOn) { 209 | totalSupplyAdjusted = totalSupply 210 | } else { 211 | invariant(!!kLast, 'K_LAST') 212 | const kLastParsed = parseBigintIsh(kLast) 213 | if (!JSBI.equal(kLastParsed, ZERO)) { 214 | const rootK = sqrt(JSBI.multiply(this.reserve0.raw, this.reserve1.raw)) 215 | const rootKLast = sqrt(kLastParsed) 216 | if (JSBI.greaterThan(rootK, rootKLast)) { 217 | const numerator = JSBI.multiply(totalSupply.raw, JSBI.subtract(rootK, rootKLast)) 218 | const denominator = JSBI.add(JSBI.multiply(rootK, FIVE), rootKLast) 219 | const feeLiquidity = JSBI.divide(numerator, denominator) 220 | totalSupplyAdjusted = totalSupply.add(new TokenAmount(this.liquidityToken, feeLiquidity)) 221 | } else { 222 | totalSupplyAdjusted = totalSupply 223 | } 224 | } else { 225 | totalSupplyAdjusted = totalSupply 226 | } 227 | } 228 | 229 | return new TokenAmount( 230 | token, 231 | JSBI.divide(JSBI.multiply(liquidity.raw, this.reserveOf(token).raw), totalSupplyAdjusted.raw) 232 | ) 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /src/entities/route.ts: -------------------------------------------------------------------------------- 1 | import { ChainId } from '../constants' 2 | import invariant from 'tiny-invariant' 3 | 4 | import { Currency } from './currency' 5 | import { Token, WAVAX } from './token' 6 | import { Pair } from './pair' 7 | import { Price } from './fractions/price' 8 | 9 | export class Route { 10 | public readonly pairs: Pair[] 11 | public readonly path: Token[] 12 | public readonly input: Currency 13 | public readonly output: Currency 14 | public readonly midPrice: Price 15 | 16 | public constructor(pairs: Pair[], input: Currency, output?: Currency) { 17 | invariant(pairs.length > 0, 'PAIRS') 18 | invariant( 19 | pairs.every(pair => pair.chainId === pairs[0].chainId), 20 | 'CHAIN_IDS' 21 | ) 22 | invariant( 23 | (input instanceof Token && pairs[0].involvesToken(input)) || 24 | (input.isNative && pairs[0].involvesToken(WAVAX[pairs[0].chainId])), 25 | 'INPUT' 26 | ) 27 | invariant( 28 | typeof output === 'undefined' || 29 | (output instanceof Token && pairs[pairs.length - 1].involvesToken(output)) || 30 | (output.isNative && pairs[pairs.length - 1].involvesToken(WAVAX[pairs[0].chainId])), 31 | 'OUTPUT' 32 | ) 33 | 34 | const path: Token[] = [input instanceof Token ? input : WAVAX[pairs[0].chainId]] 35 | for (const [i, pair] of pairs.entries()) { 36 | const currentInput = path[i] 37 | invariant(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), 'PATH') 38 | const output = currentInput.equals(pair.token0) ? pair.token1 : pair.token0 39 | path.push(output) 40 | } 41 | 42 | this.pairs = pairs 43 | this.path = path 44 | this.midPrice = Price.fromRoute(this) 45 | this.input = input 46 | this.output = output ?? path[path.length - 1] 47 | } 48 | 49 | public get chainId(): ChainId { 50 | return this.pairs[0].chainId 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/entities/token.ts: -------------------------------------------------------------------------------- 1 | import invariant from 'tiny-invariant' 2 | import { ChainId } from '../constants' 3 | import { validateAndParseAddress } from '../utils' 4 | import { Currency } from './currency' 5 | 6 | /** 7 | * Represents an ERC20 token with a unique address and some metadata. 8 | */ 9 | export class Token { 10 | public readonly decimals: number 11 | public readonly symbol?: string 12 | public readonly name?: string 13 | public readonly isNative: false = false 14 | public readonly isToken: true = true 15 | public readonly chainId: number 16 | 17 | /** 18 | * The contract address on the chain on which this token lives 19 | */ 20 | public readonly address: string 21 | 22 | public constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string) { 23 | this.chainId = chainId 24 | this.decimals = decimals 25 | this.symbol = symbol 26 | this.name = name 27 | this.address = validateAndParseAddress(address) 28 | } 29 | 30 | /** 31 | * Returns true if the two tokens are equivalent, i.e. have the same chainId and address. 32 | * @param other other token to compare 33 | */ 34 | public equals(other: Token): boolean { 35 | // short circuit on reference equality 36 | if (this === other) { 37 | return true 38 | } 39 | return this.chainId === other.chainId && this.address === other.address 40 | } 41 | 42 | /** 43 | * Returns true if the address of this token sorts before the address of the other token 44 | * @param other other token to compare 45 | * @throws if the tokens have the same address 46 | * @throws if the tokens are on different chains 47 | */ 48 | public sortsBefore(other: Token): boolean { 49 | invariant(this.chainId === other.chainId, 'CHAIN_IDS') 50 | invariant(this.address !== other.address, 'ADDRESSES') 51 | return this.address.toLowerCase() < other.address.toLowerCase() 52 | } 53 | } 54 | 55 | /** 56 | * Compares two currencies for equality 57 | */ 58 | export function currencyEquals(currencyA: Currency, currencyB: Currency): boolean { 59 | if (currencyA instanceof Token && currencyB instanceof Token) { 60 | return currencyA.equals(currencyB) 61 | } else if (currencyA instanceof Token) { 62 | return false 63 | } else if (currencyB instanceof Token) { 64 | return false 65 | } else { 66 | return currencyA === currencyB 67 | } 68 | } 69 | 70 | export const WNATIVE = { 71 | [ChainId.FUJI]: new Token(ChainId.FUJI, '0xd00ae08403B9bbb9124bB305C09058E32C39A48c', 18, 'WAVAX', 'Wrapped AVAX'), 72 | [ChainId.AVALANCHE]: new Token( 73 | ChainId.AVALANCHE, 74 | '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 75 | 18, 76 | 'WAVAX', 77 | 'Wrapped AVAX' 78 | ), 79 | [ChainId.ARBITRUM_ONE]: new Token( 80 | ChainId.ARBITRUM_ONE, 81 | '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', 82 | 18, 83 | 'WETH', 84 | 'Wrapped ETH' 85 | ), 86 | [ChainId.ARB_GOERLI]: new Token( 87 | ChainId.ARB_GOERLI, 88 | '0xaE4EC9901c3076D0DdBe76A520F9E90a6227aCB7', 89 | 18, 90 | 'WETH', 91 | 'Wrapped ETH' 92 | ), 93 | [ChainId.BNB_CHAIN]: new Token( 94 | ChainId.BNB_CHAIN, 95 | '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 96 | 18, 97 | 'WBNB', 98 | 'Wrapped BNB' 99 | ), 100 | [ChainId.BNB_TESTNET]: new Token( 101 | ChainId.BNB_TESTNET, 102 | '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', 103 | 18, 104 | 'WBNB', 105 | 'Wrapped BNB' 106 | ) 107 | } 108 | 109 | export const WAVAX = WNATIVE 110 | -------------------------------------------------------------------------------- /src/errors.ts: -------------------------------------------------------------------------------- 1 | // see https://stackoverflow.com/a/41102306 2 | const CAN_SET_PROTOTYPE = 'setPrototypeOf' in Object 3 | 4 | /** 5 | * Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be 6 | * obtained by sending any amount of input. 7 | */ 8 | export class InsufficientReservesError extends Error { 9 | public readonly isInsufficientReservesError: true = true 10 | 11 | public constructor() { 12 | super() 13 | this.name = this.constructor.name 14 | if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) 15 | } 16 | } 17 | 18 | /** 19 | * Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less 20 | * than the price of a single unit of output after fees. 21 | */ 22 | export class InsufficientInputAmountError extends Error { 23 | public readonly isInsufficientInputAmountError: true = true 24 | 25 | public constructor() { 26 | super() 27 | this.name = this.constructor.name 28 | if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/fetcher.ts: -------------------------------------------------------------------------------- 1 | import { TokenAmount } from './entities/fractions/tokenAmount' 2 | import { Pair } from './entities/pair' 3 | import invariant from 'tiny-invariant' 4 | import { ERC20ABI, JoePairABI } from './abis/ts' 5 | import { ChainId } from './constants' 6 | import { Token } from './entities/token' 7 | import { getAddress } from 'viem' 8 | import { getDefaultPublicClient } from './utils' 9 | 10 | let TOKEN_DECIMALS_CACHE: { [chainId: number]: { [address: string]: number } } = {} 11 | 12 | /** 13 | * Contains methods for constructing instances of pairs and tokens from on-chain data. 14 | */ 15 | export abstract class Fetcher { 16 | /** 17 | * Cannot be constructed. 18 | */ 19 | private constructor() {} 20 | 21 | /** 22 | * Fetch information for a given token on the given chain, using the given viem public client. 23 | * @param chainId chain of the token 24 | * @param address address of the token on the chain 25 | * @param client client used to fetch the token 26 | * @param symbol optional symbol of the token 27 | * @param name optional name of the token 28 | */ 29 | public static async fetchTokenData( 30 | chainId: ChainId, 31 | address: string, 32 | client = getDefaultPublicClient(chainId), 33 | symbol?: string, 34 | name?: string 35 | ): Promise { 36 | const parsedDecimals = 37 | typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === 'number' 38 | ? TOKEN_DECIMALS_CACHE[chainId][address] 39 | : await client 40 | .readContract({ 41 | abi: ERC20ABI, 42 | functionName: 'decimals', 43 | address: getAddress(address) 44 | }) 45 | .then((decimals: number): number => { 46 | TOKEN_DECIMALS_CACHE = { 47 | ...TOKEN_DECIMALS_CACHE, 48 | [chainId]: { 49 | ...TOKEN_DECIMALS_CACHE?.[chainId], 50 | [address]: decimals 51 | } 52 | } 53 | return decimals 54 | }) 55 | return new Token(chainId, address, parsedDecimals, symbol, name) 56 | } 57 | 58 | /** 59 | * Fetches information about a pair and constructs a pair from the given two tokens. 60 | * @param tokenA first token 61 | * @param tokenB second token 62 | * @param provider the provider to use to fetch the data 63 | */ 64 | public static async fetchPairData( 65 | tokenA: Token, 66 | tokenB: Token, 67 | client = getDefaultPublicClient(tokenA.chainId) 68 | ): Promise { 69 | invariant(tokenA.chainId === tokenB.chainId, 'CHAIN_ID') 70 | const address = Pair.getAddress(tokenA, tokenB, tokenA.chainId) 71 | const [reserves0, reserves1] = await client.readContract({ 72 | abi: JoePairABI, 73 | functionName: 'getReserves', 74 | address: getAddress(address) 75 | }) 76 | const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0] 77 | return new Pair(new TokenAmount(tokenA, balances[0]), new TokenAmount(tokenB, balances[1]), tokenA.chainId) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import JSBI from 'jsbi' 2 | export { JSBI } 3 | 4 | export { 5 | BigintIsh, 6 | ChainId, 7 | TradeType, 8 | Rounding, 9 | FACTORY_ADDRESS, 10 | JOE_ADDRESS, 11 | BAR_ADDRESS, 12 | MAKER_ADDRESS, 13 | ROLL_ADDRESS, 14 | ROUTER_ADDRESS, 15 | MASTERCHEF_ADDRESS, 16 | MASTERCHEF_V3_ADDRESS, 17 | ZAP_ADDRESS, 18 | BORINGHELPER_ADDRESS, 19 | BORINGHELPER_MCV3_ADDRESS, 20 | BORINGHELPER_BMCJ_ADDRESS, 21 | BORINGTOKENSCANNER_ADDRESS, 22 | BORINGDASHBOARD_ADDRESS, 23 | INIT_CODE_HASH, 24 | MINIMUM_LIQUIDITY, 25 | UNITROLLER_ADDRESS, 26 | JAVAX_ADDRESS, 27 | JOELENS_ADDRESS, 28 | FARMLENS_ADDRESS, 29 | FARMLENSV2_ADDRESS, 30 | MAXIMILLION_ADDRESS, 31 | LOCKING_WRAPPER_ADDRESS, 32 | ROCKET_JOE_TOKEN_ADDRESS, 33 | LAUNCH_EVENT_LENS_ADDRESS, 34 | ROCKET_JOE_STAKING_ADDRESS, 35 | STABLE_JOE_STAKING_ADDRESS, 36 | SJOE_REWARD_TOKEN, 37 | MONEY_MAKER_ADDRESS, 38 | VEJOE_STAKING_ADDRESS, 39 | VEJOE_TOKEN_ADDRESS, 40 | BOOSTED_MASTERCHEF_ADDRESS 41 | } from './constants' 42 | 43 | export * from './errors' 44 | export * from './entities' 45 | export * from './router' 46 | export * from './fetcher' 47 | export * from './abis/ts' 48 | 49 | export * from './subgraphs' 50 | -------------------------------------------------------------------------------- /src/router.ts: -------------------------------------------------------------------------------- 1 | import { TradeType } from './constants' 2 | import invariant from 'tiny-invariant' 3 | import { validateAndParseAddress } from './utils' 4 | import { CurrencyAmount, Percent, Trade } from './entities' 5 | 6 | /** 7 | * Options for producing the arguments to send call to the router. 8 | */ 9 | export interface TradeOptions { 10 | /** 11 | * How much the execution price is allowed to move unfavorably from the trade execution price. 12 | */ 13 | allowedSlippage: Percent 14 | /** 15 | * How long the swap is valid until it expires, in seconds. 16 | * This will be used to produce a `deadline` parameter which is computed from when the swap call parameters 17 | * are generated. 18 | */ 19 | ttl: number 20 | /** 21 | * The account that should receive the output of the swap. 22 | */ 23 | recipient: string 24 | 25 | /** 26 | * Whether any of the tokens in the path are fee on transfer tokens, which should be handled with special methods 27 | */ 28 | feeOnTransfer?: boolean 29 | } 30 | 31 | export interface TradeOptionsDeadline extends Omit { 32 | /** 33 | * When the transaction expires. 34 | * This is an atlernate to specifying the ttl, for when you do not want to use local time. 35 | */ 36 | deadline: number 37 | } 38 | 39 | /** 40 | * The parameters to use in the call to the Uniswap V2 Router to execute a trade. 41 | */ 42 | export interface SwapParameters { 43 | /** 44 | * The method to call on the Uniswap V2 Router. 45 | */ 46 | methodName: string 47 | /** 48 | * The arguments to pass to the method, all hex encoded. 49 | */ 50 | args: (string | string[])[] 51 | /** 52 | * The amount of wei to send in hex. 53 | */ 54 | value: string 55 | } 56 | 57 | function toHex(currencyAmount: CurrencyAmount) { 58 | return `0x${currencyAmount.raw.toString(16)}` 59 | } 60 | 61 | const ZERO_HEX = '0x0' 62 | 63 | /** 64 | * Represents the Uniswap V2 Router, and has static methods for helping execute trades. 65 | */ 66 | export abstract class Router { 67 | /** 68 | * Cannot be constructed. 69 | */ 70 | private constructor() {} 71 | /** 72 | * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade. 73 | * @param trade to produce call parameters for 74 | * @param options options for the call parameters 75 | */ 76 | public static swapCallParameters(trade: Trade, options: TradeOptions | TradeOptionsDeadline): SwapParameters { 77 | const etherIn = trade.inputAmount.currency.isNative 78 | const etherOut = trade.outputAmount.currency.isNative 79 | // the router does not support both ether in and out 80 | invariant(!(etherIn && etherOut), 'ETHER_IN_OUT') 81 | invariant(!('ttl' in options) || options.ttl > 0, 'TTL') 82 | 83 | const to: string = validateAndParseAddress(options.recipient) 84 | const amountIn: string = toHex(trade.maximumAmountIn(options.allowedSlippage)) 85 | const amountOut: string = toHex(trade.minimumAmountOut(options.allowedSlippage)) 86 | const path: string[] = trade.route.path.map(token => token.address) 87 | const deadline = 88 | 'ttl' in options 89 | ? `0x${(Math.floor(new Date().getTime() / 1000) + options.ttl).toString(16)}` 90 | : `0x${options.deadline.toString(16)}` 91 | 92 | const useFeeOnTransfer = Boolean(options.feeOnTransfer) 93 | 94 | let methodName: string 95 | let args: (string | string[])[] 96 | let value: string 97 | switch (trade.tradeType) { 98 | case TradeType.EXACT_INPUT: 99 | if (etherIn) { 100 | methodName = useFeeOnTransfer 101 | ? 'swapExactAVAXForTokensSupportingFeeOnTransferTokens' 102 | : 'swapExactAVAXForTokens' 103 | // (uint amountOutMin, address[] calldata path, address to, uint deadline) 104 | args = [amountOut, path, to, deadline] 105 | value = amountIn 106 | } else if (etherOut) { 107 | methodName = useFeeOnTransfer 108 | ? 'swapExactTokensForAVAXSupportingFeeOnTransferTokens' 109 | : 'swapExactTokensForAVAX' 110 | // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) 111 | args = [amountIn, amountOut, path, to, deadline] 112 | value = ZERO_HEX 113 | } else { 114 | methodName = useFeeOnTransfer 115 | ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' 116 | : 'swapExactTokensForTokens' 117 | // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) 118 | args = [amountIn, amountOut, path, to, deadline] 119 | value = ZERO_HEX 120 | } 121 | break 122 | case TradeType.EXACT_OUTPUT: 123 | invariant(!useFeeOnTransfer, 'EXACT_OUT_FOT') 124 | if (etherIn) { 125 | methodName = 'swapAVAXForExactTokens' 126 | // (uint amountOut, address[] calldata path, address to, uint deadline) 127 | args = [amountOut, path, to, deadline] 128 | value = amountIn 129 | } else if (etherOut) { 130 | methodName = 'swapTokensForExactAVAX' 131 | // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) 132 | args = [amountOut, amountIn, path, to, deadline] 133 | value = ZERO_HEX 134 | } else { 135 | methodName = 'swapTokensForExactTokens' 136 | // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) 137 | args = [amountOut, amountIn, path, to, deadline] 138 | value = ZERO_HEX 139 | } 140 | break 141 | } 142 | return { 143 | methodName, 144 | args, 145 | value 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/subgraphs.ts: -------------------------------------------------------------------------------- 1 | import { ChainId } from './constants' 2 | 3 | export const EXCHANGE_SUBGRAPH: { [chainId in ChainId]: string } = { 4 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/exchange-fuji', 5 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/exchange', 6 | [ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/joe-v1-arbitrum', 7 | [ChainId.ARB_GOERLI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/joe-v1-arb-goerli', 8 | [ChainId.BNB_CHAIN]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/joe-v1-bnb', 9 | [ChainId.BNB_TESTNET]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/joe-v1-bnbtest' 10 | } 11 | 12 | export const MASTERCHEF_SUBGRAPH: { [chainId in ChainId]: string } = { 13 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/masterchefv2-fuji', 14 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/masterchefv2', 15 | [ChainId.ARBITRUM_ONE]: '', 16 | [ChainId.ARB_GOERLI]: '', 17 | [ChainId.BNB_CHAIN]: '', 18 | [ChainId.BNB_TESTNET]: '' 19 | } 20 | 21 | export const DEXCANDLES_SUBGRAPH: { [chainId in ChainId]: string } = { 22 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/dexcandles-fuji', 23 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/dexcandles', 24 | [ChainId.ARBITRUM_ONE]: '', 25 | [ChainId.ARB_GOERLI]: '', 26 | [ChainId.BNB_CHAIN]: '', 27 | [ChainId.BNB_TESTNET]: '' 28 | } 29 | 30 | export const BAR_SUBGRAPH: { [chainId in ChainId]: string } = { 31 | [ChainId.FUJI]: '', 32 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/bar', 33 | [ChainId.ARBITRUM_ONE]: '', 34 | [ChainId.ARB_GOERLI]: '', 35 | [ChainId.BNB_CHAIN]: '', 36 | [ChainId.BNB_TESTNET]: '' 37 | } 38 | 39 | export const LENDING_SUBGRAPH: { [chainId in ChainId]: string } = { 40 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/lending-fuji', 41 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/lending', 42 | [ChainId.ARBITRUM_ONE]: '', 43 | [ChainId.ARB_GOERLI]: '', 44 | [ChainId.BNB_CHAIN]: '', 45 | [ChainId.BNB_TESTNET]: '' 46 | } 47 | 48 | export const ROCKET_SUBGRAPH: { [chainId in ChainId]: string } = { 49 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/rocket-fuji', 50 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/rocket', 51 | [ChainId.ARBITRUM_ONE]: '', 52 | [ChainId.ARB_GOERLI]: '', 53 | [ChainId.BNB_CHAIN]: '', 54 | [ChainId.BNB_TESTNET]: '' 55 | } 56 | 57 | export const SJOE_SUBGRAPH: { [chainId in ChainId]: string } = { 58 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/sjoe-fuji', 59 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/sjoe', 60 | [ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/sjoe-arbitrum', 61 | [ChainId.ARB_GOERLI]: '', 62 | [ChainId.BNB_CHAIN]: '', 63 | [ChainId.BNB_TESTNET]: '' 64 | } 65 | 66 | export const MONEY_MAKER_SUBGRAPH: { [chainId in ChainId]: string } = { 67 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/moneymaker-fuji', 68 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/money-maker', 69 | [ChainId.ARBITRUM_ONE]: '', 70 | [ChainId.ARB_GOERLI]: '', 71 | [ChainId.BNB_CHAIN]: '', 72 | [ChainId.BNB_TESTNET]: '' 73 | } 74 | 75 | export const VEJOE_SUBGRAPH: { [chainId in ChainId]: string } = { 76 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/vejoe-fuji', 77 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/vejoe', 78 | [ChainId.ARBITRUM_ONE]: '', 79 | [ChainId.ARB_GOERLI]: '', 80 | [ChainId.BNB_CHAIN]: '', 81 | [ChainId.BNB_TESTNET]: '' 82 | } 83 | 84 | export const BOOSTED_MASTERCHEF_SUBGRAPH: { [chainId in ChainId]: string } = { 85 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/boostedmasterchef-fuji', 86 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/boosted-master-chef', 87 | [ChainId.ARBITRUM_ONE]: '', 88 | [ChainId.ARB_GOERLI]: '', 89 | [ChainId.BNB_CHAIN]: '', 90 | [ChainId.BNB_TESTNET]: '' 91 | } 92 | 93 | export const NFT_CONTRACTS_SUBGRAPH: { [chainId in ChainId]: string } = { 94 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/nft-contract-fuji', 95 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/nft-contracts', 96 | [ChainId.ARBITRUM_ONE]: '', 97 | [ChainId.ARB_GOERLI]: '', 98 | [ChainId.BNB_CHAIN]: '', 99 | [ChainId.BNB_TESTNET]: '' 100 | } 101 | 102 | export const JOEPEG_MARKETPLACE_SUBGRAPH: { [chainId in ChainId]: string } = { 103 | [ChainId.FUJI]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/marketplace-fuji', 104 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/marketplace', 105 | [ChainId.ARBITRUM_ONE]: '', 106 | [ChainId.ARB_GOERLI]: '', 107 | [ChainId.BNB_CHAIN]: '', 108 | [ChainId.BNB_TESTNET]: '' 109 | } 110 | 111 | export const FEE_COLLECTOR_SUBGRAPH: { [chainId in ChainId]: string } = { 112 | [ChainId.FUJI]: '', 113 | [ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/fee-collector-avax', 114 | [ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/traderjoe-xyz/fee-collector-arbitrum', 115 | [ChainId.ARB_GOERLI]: '', 116 | [ChainId.BNB_CHAIN]: '', 117 | [ChainId.BNB_TESTNET]: '' 118 | } 119 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import invariant from 'tiny-invariant' 2 | import warning from 'tiny-warning' 3 | import JSBI from 'jsbi' 4 | import { createPublicClient, http, getAddress } from 'viem' 5 | import { arbitrum, arbitrumGoerli, avalanche, avalancheFuji, bsc, bscTestnet } from 'viem/chains' 6 | 7 | import { BigintIsh, ZERO, ONE, TWO, THREE, SolidityType, SOLIDITY_TYPE_MAXIMA, ChainId } from './constants' 8 | 9 | export function validateSolidityTypeInstance(value: JSBI, solidityType: SolidityType): void { 10 | invariant(JSBI.greaterThanOrEqual(value, ZERO), `${value} is not a ${solidityType}.`) 11 | invariant(JSBI.lessThanOrEqual(value, SOLIDITY_TYPE_MAXIMA[solidityType]), `${value} is not a ${solidityType}.`) 12 | } 13 | 14 | // warns if addresses are not checksummed 15 | export function validateAndParseAddress(address: string): string { 16 | try { 17 | const checksummedAddress = getAddress(address) 18 | warning(address === checksummedAddress, `${address} is not checksummed.`) 19 | return checksummedAddress 20 | } catch (error) { 21 | console.error(error) 22 | invariant(false, `${address} is not a valid address.`) 23 | } 24 | } 25 | 26 | export function parseBigintIsh(bigintIsh: BigintIsh): JSBI { 27 | return bigintIsh instanceof JSBI 28 | ? bigintIsh 29 | : typeof bigintIsh === 'bigint' 30 | ? JSBI.BigInt(bigintIsh.toString()) 31 | : JSBI.BigInt(bigintIsh) 32 | } 33 | 34 | // mock the on-chain sqrt function 35 | export function sqrt(y: JSBI): JSBI { 36 | validateSolidityTypeInstance(y, SolidityType.uint256) 37 | let z: JSBI = ZERO 38 | let x: JSBI 39 | if (JSBI.greaterThan(y, THREE)) { 40 | z = y 41 | x = JSBI.add(JSBI.divide(y, TWO), ONE) 42 | while (JSBI.lessThan(x, z)) { 43 | z = x 44 | x = JSBI.divide(JSBI.add(JSBI.divide(y, x), x), TWO) 45 | } 46 | } else if (JSBI.notEqual(y, ZERO)) { 47 | z = ONE 48 | } 49 | return z 50 | } 51 | 52 | // given an array of items sorted by `comparator`, insert an item into its sort index and constrain the size to 53 | // `maxSize` by removing the last item 54 | export function sortedInsert(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null { 55 | invariant(maxSize > 0, 'MAX_SIZE_ZERO') 56 | // this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize 57 | invariant(items.length <= maxSize, 'ITEMS_SIZE') 58 | 59 | // short circuit first item add 60 | if (items.length === 0) { 61 | items.push(add) 62 | return null 63 | } else { 64 | const isFull = items.length === maxSize 65 | // short circuit if full and the additional item does not come before the last item 66 | if (isFull && comparator(items[items.length - 1], add) <= 0) { 67 | return add 68 | } 69 | 70 | let lo = 0, 71 | hi = items.length 72 | 73 | while (lo < hi) { 74 | const mid = (lo + hi) >>> 1 75 | if (comparator(items[mid], add) <= 0) { 76 | lo = mid + 1 77 | } else { 78 | hi = mid 79 | } 80 | } 81 | items.splice(lo, 0, add) 82 | return isFull ? items.pop()! : null 83 | } 84 | } 85 | 86 | export const getDefaultPublicClient = (chainId: ChainId) => { 87 | const chain = getChain(chainId) 88 | return createPublicClient({ 89 | chain, 90 | transport: http() 91 | }) 92 | } 93 | 94 | export const getChain = (chainId: ChainId) => { 95 | switch (chainId) { 96 | case ChainId.ARBITRUM_ONE: 97 | return arbitrum 98 | case ChainId.ARB_GOERLI: 99 | return arbitrumGoerli 100 | case ChainId.AVALANCHE: 101 | return avalanche 102 | case ChainId.FUJI: 103 | return avalancheFuji 104 | case ChainId.BNB_CHAIN: 105 | return bsc 106 | case ChainId.BNB_TESTNET: 107 | return bscTestnet 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /test/abis.test.ts: -------------------------------------------------------------------------------- 1 | import * as abisJson from '../src/abis/json' 2 | import * as abisTs from '../src/abis/ts' 3 | 4 | describe('abis', () => { 5 | it('same number of TS abis as JSON', () => { 6 | expect(Object.keys(abisJson).length).toEqual(Object.keys(abisTs).length) 7 | }) 8 | it.each(Object.keys(abisTs))('%s ABI matches JSON version', abiTs => { 9 | const tsAbis = (abisTs as unknown) as any // Avoid TS errors 10 | const stringifiedTsAbi = JSON.stringify(tsAbis[abiTs]) 11 | 12 | const jsonAbis = (abisJson as unknown) as any // Avoid TS errors 13 | const stringifiedJsonAbi = JSON.stringify(jsonAbis[abiTs]) 14 | expect(stringifiedTsAbi).toEqual(stringifiedJsonAbi) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /test/currency.test.ts: -------------------------------------------------------------------------------- 1 | import { CNATIVE } from '../src' 2 | 3 | describe('NativeCurrency', () => { 4 | describe('CNATIVE', () => { 5 | it('returns AVAX for 43114', () => { 6 | expect(CNATIVE.onChain(43114).symbol === 'AVAX').toBe(true) 7 | }) 8 | it('returns AVAX for 43113', () => { 9 | expect(CNATIVE.onChain(43113).symbol === 'AVAX').toBe(true) 10 | }) 11 | it('returns ETH for 42161', () => { 12 | expect(CNATIVE.onChain(42161).symbol === 'ETH').toBe(true) 13 | }) 14 | it('returns ETH for 421613', () => { 15 | expect(CNATIVE.onChain(421613).symbol === 'ETH').toBe(true) 16 | }) 17 | it('returns BNB for 56', () => { 18 | expect(CNATIVE.onChain(56).symbol === 'BNB').toBe(true) 19 | }) 20 | it('returns BNB for 97', () => { 21 | expect(CNATIVE.onChain(97).symbol === 'tBNB').toBe(true) 22 | }) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /test/data.test.ts: -------------------------------------------------------------------------------- 1 | import { ChainId, WAVAX, Token, Fetcher } from '../src' 2 | 3 | // TODO: replace the provider in these tests 4 | describe.skip('data', () => { 5 | it('Token', async () => { 6 | const token = await Fetcher.fetchTokenData(ChainId.AVALANCHE, '0x6B175474E89094C44Da98b954EedeAC495271d0F') // DAI 7 | expect(token.decimals).toEqual(18) 8 | }) 9 | 10 | it('Token:CACHE', async () => { 11 | const token = await Fetcher.fetchTokenData(ChainId.AVALANCHE, '0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A') // DGD 12 | expect(token.decimals).toEqual(9) 13 | }) 14 | 15 | it('Pair', async () => { 16 | const token = new Token(ChainId.FUJI, '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735', 18) // DAI 17 | const pair = await Fetcher.fetchPairData(WAVAX[ChainId.FUJI], token) 18 | expect(pair.liquidityToken.address).toEqual('0x8B22F85d0c844Cf793690F6D9DFE9F11Ddb35449') 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /test/entities.test.ts: -------------------------------------------------------------------------------- 1 | import invariant from 'tiny-invariant' 2 | import { ChainId, WAVAX as _WAVAX, TradeType, Rounding, Token, TokenAmount, Pair, Route, Trade } from '../src' 3 | 4 | const ADDRESSES = [ 5 | '0x0000000000000000000000000000000000000001', 6 | '0x0000000000000000000000000000000000000002', 7 | '0x0000000000000000000000000000000000000003' 8 | ] 9 | const CHAIN_ID = ChainId.FUJI 10 | const WETH = _WAVAX[ChainId.FUJI] 11 | const DECIMAL_PERMUTATIONS: [number, number, number][] = [ 12 | [0, 0, 0], 13 | [0, 9, 18], 14 | [18, 18, 18] 15 | ] 16 | 17 | function decimalize(amount: number, decimals: number): bigint { 18 | return BigInt(amount) * BigInt(10) ** BigInt(decimals) 19 | } 20 | 21 | describe('entities', () => { 22 | DECIMAL_PERMUTATIONS.forEach(decimals => { 23 | describe(`decimals permutation: ${decimals}`, () => { 24 | let tokens: Token[] 25 | it('Token', () => { 26 | tokens = ADDRESSES.map((address, i) => new Token(CHAIN_ID, address, decimals[i])) 27 | tokens.forEach((token, i) => { 28 | expect(token.chainId).toEqual(CHAIN_ID) 29 | expect(token.address).toEqual(ADDRESSES[i]) 30 | expect(token.decimals).toEqual(decimals[i]) 31 | }) 32 | }) 33 | 34 | let pairs: Pair[] 35 | it('Pair', () => { 36 | pairs = [ 37 | new Pair( 38 | new TokenAmount(tokens[0], decimalize(1, tokens[0].decimals)), 39 | new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)), 40 | CHAIN_ID 41 | ), 42 | new Pair( 43 | new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)), 44 | new TokenAmount(tokens[2], decimalize(1, tokens[2].decimals)), 45 | CHAIN_ID 46 | ), 47 | new Pair( 48 | new TokenAmount(tokens[2], decimalize(1, tokens[2].decimals)), 49 | new TokenAmount(WETH, decimalize(1234, WETH.decimals)), 50 | CHAIN_ID 51 | ) 52 | ] 53 | }) 54 | 55 | let route: Route 56 | it('Route', () => { 57 | route = new Route(pairs, tokens[0]) 58 | expect(route.pairs).toEqual(pairs) 59 | expect(route.path).toEqual(tokens.concat([WETH])) 60 | expect(route.input).toEqual(tokens[0]) 61 | expect(route.output).toEqual(WETH) 62 | }) 63 | 64 | it('Price:Route.midPrice', () => { 65 | invariant(route.input instanceof Token) 66 | invariant(route.output instanceof Token) 67 | expect(route.midPrice.quote(new TokenAmount(route.input, decimalize(1, route.input.decimals)))).toEqual( 68 | new TokenAmount(route.output, decimalize(1234, route.output.decimals)) 69 | ) 70 | expect( 71 | route.midPrice.invert().quote(new TokenAmount(route.output, decimalize(1234, route.output.decimals))) 72 | ).toEqual(new TokenAmount(route.input, decimalize(1, route.input.decimals))) 73 | 74 | expect(route.midPrice.toSignificant(1)).toEqual('1000') 75 | expect(route.midPrice.toSignificant(2)).toEqual('1200') 76 | expect(route.midPrice.toSignificant(3)).toEqual('1230') 77 | expect(route.midPrice.toSignificant(4)).toEqual('1234') 78 | expect(route.midPrice.toSignificant(5)).toEqual('1234') 79 | expect(route.midPrice.toSignificant(5, { groupSeparator: ',' })).toEqual('1,234') 80 | expect(route.midPrice.invert().toSignificant(1)).toEqual('0.0008') 81 | expect(route.midPrice.invert().toSignificant(2)).toEqual('0.00081') 82 | expect(route.midPrice.invert().toSignificant(3)).toEqual('0.00081') 83 | expect(route.midPrice.invert().toSignificant(4)).toEqual('0.0008104') 84 | expect(route.midPrice.invert().toSignificant(4, undefined, Rounding.ROUND_DOWN)).toEqual('0.0008103') 85 | expect(route.midPrice.invert().toSignificant(5)).toEqual('0.00081037') 86 | 87 | expect(route.midPrice.toFixed(0)).toEqual('1234') 88 | expect(route.midPrice.toFixed(1)).toEqual('1234.0') 89 | expect(route.midPrice.toFixed(2)).toEqual('1234.00') 90 | expect(route.midPrice.toFixed(2, { groupSeparator: ',' })).toEqual('1,234.00') 91 | expect(route.midPrice.invert().toFixed(0)).toEqual('0') 92 | expect(route.midPrice.invert().toFixed(1)).toEqual('0.0') 93 | expect(route.midPrice.invert().toFixed(2)).toEqual('0.00') 94 | expect(route.midPrice.invert().toFixed(3)).toEqual('0.001') 95 | expect(route.midPrice.invert().toFixed(4)).toEqual('0.0008') 96 | expect(route.midPrice.invert().toFixed(5)).toEqual('0.00081') 97 | expect(route.midPrice.invert().toFixed(6)).toEqual('0.000810') 98 | expect(route.midPrice.invert().toFixed(7)).toEqual('0.0008104') 99 | expect(route.midPrice.invert().toFixed(7, undefined, Rounding.ROUND_DOWN)).toEqual('0.0008103') 100 | expect(route.midPrice.invert().toFixed(8)).toEqual('0.00081037') 101 | }) 102 | 103 | describe('Trade', () => { 104 | let route: Route 105 | it('TradeType.EXACT_INPUT', () => { 106 | route = new Route( 107 | [ 108 | new Pair( 109 | new TokenAmount(tokens[1], decimalize(5, tokens[1].decimals)), 110 | new TokenAmount(WETH, decimalize(10, WETH.decimals)), 111 | CHAIN_ID 112 | ) 113 | ], 114 | tokens[1] 115 | ) 116 | const inputAmount = new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)) 117 | const expectedOutputAmount = new TokenAmount(WETH, '1662497915624478906') 118 | const trade = new Trade(route, inputAmount, TradeType.EXACT_INPUT, CHAIN_ID) 119 | expect(trade.route).toEqual(route) 120 | expect(trade.tradeType).toEqual(TradeType.EXACT_INPUT) 121 | expect(trade.inputAmount).toEqual(inputAmount) 122 | expect(trade.outputAmount).toEqual(expectedOutputAmount) 123 | 124 | expect(trade.executionPrice.toSignificant(18)).toEqual('1.66249791562447891') 125 | expect(trade.executionPrice.invert().toSignificant(18)).toEqual('0.601504513540621866') 126 | expect(trade.executionPrice.quote(inputAmount)).toEqual(expectedOutputAmount) 127 | expect(trade.executionPrice.invert().quote(expectedOutputAmount)).toEqual(inputAmount) 128 | 129 | expect(trade.nextMidPrice.toSignificant(18)).toEqual('1.38958368072925352') 130 | expect(trade.nextMidPrice.invert().toSignificant(18)).toEqual('0.71964') 131 | 132 | expect(trade.priceImpact.toSignificant(18)).toEqual('16.8751042187760547') 133 | }) 134 | 135 | it('TradeType.EXACT_OUTPUT', () => { 136 | const outputAmount = new TokenAmount(WETH, '1662497915624478906') 137 | const expectedInputAmount = new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)) 138 | const trade = new Trade(route, outputAmount, TradeType.EXACT_OUTPUT, CHAIN_ID) 139 | expect(trade.route).toEqual(route) 140 | expect(trade.tradeType).toEqual(TradeType.EXACT_OUTPUT) 141 | expect(trade.outputAmount).toEqual(outputAmount) 142 | expect(trade.inputAmount).toEqual(expectedInputAmount) 143 | 144 | expect(trade.executionPrice.toSignificant(18)).toEqual('1.66249791562447891') 145 | expect(trade.executionPrice.invert().toSignificant(18)).toEqual('0.601504513540621866') 146 | expect(trade.executionPrice.quote(expectedInputAmount)).toEqual(outputAmount) 147 | expect(trade.executionPrice.invert().quote(outputAmount)).toEqual(expectedInputAmount) 148 | 149 | expect(trade.nextMidPrice.toSignificant(18)).toEqual('1.38958368072925352') 150 | expect(trade.nextMidPrice.invert().toSignificant(18)).toEqual('0.71964') 151 | 152 | expect(trade.priceImpact.toSignificant(18)).toEqual('16.8751042187760547') 153 | }) 154 | 155 | it('minimum TradeType.EXACT_INPUT', () => { 156 | if ([9, 18].includes(tokens[1].decimals)) { 157 | const route = new Route( 158 | [ 159 | new Pair( 160 | new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)), 161 | new TokenAmount( 162 | WETH, 163 | decimalize(10, WETH.decimals) + 164 | (tokens[1].decimals === 9 ? BigInt('30090280812437312') : BigInt('30090270812437322')) 165 | ), 166 | CHAIN_ID 167 | ) 168 | ], 169 | tokens[1] 170 | ) 171 | const outputAmount = new TokenAmount(tokens[1], '1') 172 | const trade = new Trade(route, outputAmount, TradeType.EXACT_INPUT, CHAIN_ID) 173 | 174 | expect(trade.priceImpact.toSignificant(18)).toEqual( 175 | tokens[1].decimals === 9 ? '0.300000099400899902' : '0.3000000000000001' 176 | ) 177 | } 178 | }) 179 | }) 180 | 181 | it('TokenAmount', () => { 182 | const amount = new TokenAmount(WETH, '1234567000000000000000') 183 | expect(amount.toExact()).toEqual('1234.567') 184 | expect(amount.toExact({ groupSeparator: ',' })).toEqual('1,234.567') 185 | }) 186 | }) 187 | }) 188 | }) 189 | -------------------------------------------------------------------------------- /test/fraction.test.ts: -------------------------------------------------------------------------------- 1 | import { Fraction } from '../src' 2 | import JSBI from 'jsbi' 3 | 4 | describe.only('Fraction', () => { 5 | describe('#quotient', () => { 6 | it('floor division', () => { 7 | expect(new Fraction(JSBI.BigInt(8), JSBI.BigInt(3)).quotient).toEqual(JSBI.BigInt(2)) // one below 8 | expect(new Fraction(JSBI.BigInt(12), JSBI.BigInt(4)).quotient).toEqual(JSBI.BigInt(3)) // exact 9 | expect(new Fraction(JSBI.BigInt(16), JSBI.BigInt(5)).quotient).toEqual(JSBI.BigInt(3)) // one above 10 | }) 11 | }) 12 | describe('#remainder', () => { 13 | it('returns fraction after divison', () => { 14 | expect(new Fraction(JSBI.BigInt(8), JSBI.BigInt(3)).remainder).toEqual( 15 | new Fraction(JSBI.BigInt(2), JSBI.BigInt(3)) 16 | ) 17 | expect(new Fraction(JSBI.BigInt(12), JSBI.BigInt(4)).remainder).toEqual( 18 | new Fraction(JSBI.BigInt(0), JSBI.BigInt(4)) 19 | ) 20 | expect(new Fraction(JSBI.BigInt(16), JSBI.BigInt(5)).remainder).toEqual( 21 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(5)) 22 | ) 23 | }) 24 | }) 25 | describe('#invert', () => { 26 | it('flips num and denom', () => { 27 | expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(10)).invert().numerator).toEqual(JSBI.BigInt(10)) 28 | expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(10)).invert().denominator).toEqual(JSBI.BigInt(5)) 29 | }) 30 | }) 31 | describe('#add', () => { 32 | it('multiples denoms and adds nums', () => { 33 | expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).add(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toEqual( 34 | new Fraction(JSBI.BigInt(52), JSBI.BigInt(120)) 35 | ) 36 | }) 37 | 38 | it('same denom', () => { 39 | expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(5)).add(new Fraction(JSBI.BigInt(2), JSBI.BigInt(5)))).toEqual( 40 | new Fraction(JSBI.BigInt(3), JSBI.BigInt(5)) 41 | ) 42 | }) 43 | }) 44 | describe('#subtract', () => { 45 | it('multiples denoms and subtracts nums', () => { 46 | expect( 47 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).subtract(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 48 | ).toEqual(new Fraction(JSBI.BigInt(-28), JSBI.BigInt(120))) 49 | }) 50 | it('same denom', () => { 51 | expect( 52 | new Fraction(JSBI.BigInt(3), JSBI.BigInt(5)).subtract(new Fraction(JSBI.BigInt(2), JSBI.BigInt(5))) 53 | ).toEqual(new Fraction(JSBI.BigInt(1), JSBI.BigInt(5))) 54 | }) 55 | }) 56 | describe('#lessThan', () => { 57 | it('correct', () => { 58 | expect( 59 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 60 | ).toBe(true) 61 | expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( 62 | false 63 | ) 64 | expect( 65 | new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 66 | ).toBe(false) 67 | }) 68 | }) 69 | describe('#equalTo', () => { 70 | it('correct', () => { 71 | expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( 72 | false 73 | ) 74 | expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( 75 | true 76 | ) 77 | expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( 78 | false 79 | ) 80 | }) 81 | }) 82 | describe('#greaterThan', () => { 83 | it('correct', () => { 84 | expect( 85 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 86 | ).toBe(false) 87 | expect( 88 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 89 | ).toBe(false) 90 | expect( 91 | new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 92 | ).toBe(true) 93 | }) 94 | }) 95 | describe('#multiplty', () => { 96 | it('correct', () => { 97 | expect( 98 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 99 | ).toEqual(new Fraction(JSBI.BigInt(4), JSBI.BigInt(120))) 100 | expect( 101 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 102 | ).toEqual(new Fraction(JSBI.BigInt(4), JSBI.BigInt(36))) 103 | expect( 104 | new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 105 | ).toEqual(new Fraction(JSBI.BigInt(20), JSBI.BigInt(144))) 106 | }) 107 | }) 108 | describe('#divide', () => { 109 | it('correct', () => { 110 | expect( 111 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 112 | ).toEqual(new Fraction(JSBI.BigInt(12), JSBI.BigInt(40))) 113 | expect( 114 | new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 115 | ).toEqual(new Fraction(JSBI.BigInt(12), JSBI.BigInt(12))) 116 | expect( 117 | new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) 118 | ).toEqual(new Fraction(JSBI.BigInt(60), JSBI.BigInt(48))) 119 | }) 120 | }) 121 | }) 122 | -------------------------------------------------------------------------------- /test/miscellaneous.test.ts: -------------------------------------------------------------------------------- 1 | import { ChainId, Token, TokenAmount, Pair, InsufficientInputAmountError } from '../src' 2 | import { sortedInsert } from '../src/utils' 3 | 4 | const CHAIN_ID = ChainId.FUJI 5 | 6 | describe('miscellaneous', () => { 7 | it('getLiquidityMinted:0', async () => { 8 | const tokenA = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000001', 18) 9 | const tokenB = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000002', 18) 10 | const pair = new Pair(new TokenAmount(tokenA, '0'), new TokenAmount(tokenB, '0'), CHAIN_ID) 11 | 12 | expect(() => { 13 | pair.getLiquidityMinted( 14 | new TokenAmount(pair.liquidityToken, '0'), 15 | new TokenAmount(tokenA, '1000'), 16 | new TokenAmount(tokenB, '1000') 17 | ) 18 | }).toThrow(InsufficientInputAmountError) 19 | 20 | expect(() => { 21 | pair.getLiquidityMinted( 22 | new TokenAmount(pair.liquidityToken, '0'), 23 | new TokenAmount(tokenA, '1000000'), 24 | new TokenAmount(tokenB, '1') 25 | ) 26 | }).toThrow(InsufficientInputAmountError) 27 | 28 | const liquidity = pair.getLiquidityMinted( 29 | new TokenAmount(pair.liquidityToken, '0'), 30 | new TokenAmount(tokenA, '1001'), 31 | new TokenAmount(tokenB, '1001') 32 | ) 33 | 34 | expect(liquidity.raw.toString()).toEqual('1') 35 | }) 36 | 37 | it('getLiquidityMinted:!0', async () => { 38 | const tokenA = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000001', 18) 39 | const tokenB = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000002', 18) 40 | const pair = new Pair(new TokenAmount(tokenA, '10000'), new TokenAmount(tokenB, '10000'), CHAIN_ID) 41 | 42 | expect( 43 | pair 44 | .getLiquidityMinted( 45 | new TokenAmount(pair.liquidityToken, '10000'), 46 | new TokenAmount(tokenA, '2000'), 47 | new TokenAmount(tokenB, '2000') 48 | ) 49 | .raw.toString() 50 | ).toEqual('2000') 51 | }) 52 | 53 | it('getLiquidityValue:!feeOn', async () => { 54 | const tokenA = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000001', 18) 55 | const tokenB = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000002', 18) 56 | const pair = new Pair(new TokenAmount(tokenA, '1000'), new TokenAmount(tokenB, '1000'), CHAIN_ID) 57 | 58 | { 59 | const liquidityValue = pair.getLiquidityValue( 60 | tokenA, 61 | new TokenAmount(pair.liquidityToken, '1000'), 62 | new TokenAmount(pair.liquidityToken, '1000'), 63 | false 64 | ) 65 | expect(liquidityValue.token.equals(tokenA)).toBe(true) 66 | expect(liquidityValue.raw.toString()).toBe('1000') 67 | } 68 | 69 | // 500 70 | { 71 | const liquidityValue = pair.getLiquidityValue( 72 | tokenA, 73 | new TokenAmount(pair.liquidityToken, '1000'), 74 | new TokenAmount(pair.liquidityToken, '500'), 75 | false 76 | ) 77 | expect(liquidityValue.token.equals(tokenA)).toBe(true) 78 | expect(liquidityValue.raw.toString()).toBe('500') 79 | } 80 | 81 | // tokenB 82 | { 83 | const liquidityValue = pair.getLiquidityValue( 84 | tokenB, 85 | new TokenAmount(pair.liquidityToken, '1000'), 86 | new TokenAmount(pair.liquidityToken, '1000'), 87 | false 88 | ) 89 | expect(liquidityValue.token.equals(tokenB)).toBe(true) 90 | expect(liquidityValue.raw.toString()).toBe('1000') 91 | } 92 | }) 93 | 94 | it('getLiquidityValue:feeOn', async () => { 95 | const tokenA = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000001', 18) 96 | const tokenB = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000002', 18) 97 | const pair = new Pair(new TokenAmount(tokenA, '1000'), new TokenAmount(tokenB, '1000'), CHAIN_ID) 98 | 99 | const liquidityValue = pair.getLiquidityValue( 100 | tokenA, 101 | new TokenAmount(pair.liquidityToken, '500'), 102 | new TokenAmount(pair.liquidityToken, '500'), 103 | true, 104 | '250000' // 500 ** 2 105 | ) 106 | expect(liquidityValue.token.equals(tokenA)).toBe(true) 107 | expect(liquidityValue.raw.toString()).toBe('917') // ceiling(1000 - (500 * (1 / 6))) 108 | }) 109 | 110 | describe('#sortedInsert', () => { 111 | const comp = (a: number, b: number) => a - b 112 | 113 | it('throws if maxSize is 0', () => { 114 | expect(() => sortedInsert([], 1, 0, comp)).toThrow('MAX_SIZE_ZERO') 115 | }) 116 | 117 | it('throws if items.length > maxSize', () => { 118 | expect(() => sortedInsert([1, 2], 1, 1, comp)).toThrow('ITEMS_SIZE') 119 | }) 120 | 121 | it('adds if empty', () => { 122 | const arr: number[] = [] 123 | expect(sortedInsert(arr, 3, 2, comp)).toEqual(null) 124 | expect(arr).toEqual([3]) 125 | }) 126 | 127 | it('adds if not full', () => { 128 | const arr: number[] = [1, 5] 129 | expect(sortedInsert(arr, 3, 3, comp)).toEqual(null) 130 | expect(arr).toEqual([1, 3, 5]) 131 | }) 132 | 133 | it('adds if will not be full after', () => { 134 | const arr: number[] = [1] 135 | expect(sortedInsert(arr, 0, 3, comp)).toEqual(null) 136 | expect(arr).toEqual([0, 1]) 137 | }) 138 | 139 | it('returns add if sorts after last', () => { 140 | const arr = [1, 2, 3] 141 | expect(sortedInsert(arr, 4, 3, comp)).toEqual(4) 142 | expect(arr).toEqual([1, 2, 3]) 143 | }) 144 | 145 | it('removes from end if full', () => { 146 | const arr = [1, 3, 4] 147 | expect(sortedInsert(arr, 2, 3, comp)).toEqual(4) 148 | expect(arr).toEqual([1, 2, 3]) 149 | }) 150 | 151 | it('uses comparator', () => { 152 | const arr = [4, 2, 1] 153 | expect(sortedInsert(arr, 3, 3, (a, b) => comp(a, b) * -1)).toEqual(1) 154 | expect(arr).toEqual([4, 3, 2]) 155 | }) 156 | 157 | describe('maxSize of 1', () => { 158 | it('empty add', () => { 159 | const arr: number[] = [] 160 | expect(sortedInsert(arr, 3, 1, comp)).toEqual(null) 161 | expect(arr).toEqual([3]) 162 | }) 163 | it('full add greater', () => { 164 | const arr: number[] = [2] 165 | expect(sortedInsert(arr, 3, 1, comp)).toEqual(3) 166 | expect(arr).toEqual([2]) 167 | }) 168 | it('full add lesser', () => { 169 | const arr: number[] = [4] 170 | expect(sortedInsert(arr, 3, 1, comp)).toEqual(4) 171 | expect(arr).toEqual([3]) 172 | }) 173 | }) 174 | }) 175 | }) 176 | -------------------------------------------------------------------------------- /test/pair.test.ts: -------------------------------------------------------------------------------- 1 | import { ChainId, Token, Pair, TokenAmount, WAVAX, Price } from '../src' 2 | 3 | describe('Pair', () => { 4 | const USDT = new Token(ChainId.FUJI, '0x3763fB99d772D1D96571F39508e34489F400750c', 6, 'USDT', 'USDT Token') 5 | const JOE = new Token(ChainId.FUJI, '0x477Fd10Db0D80eAFb773cF623B258313C3739413', 18, 'JOE', 'JOE Token') 6 | 7 | const gUSDT = new Token(ChainId.ARB_GOERLI, '0xf450749aeA1c5feF27Ae0237C56FecC43f6bE244', 6, 'USDT', 'Tether Token') 8 | const gUSDC = new Token(ChainId.ARB_GOERLI, '0xb3482A25a12e5261b02E0acc5b96c656358a4086', 6, 'USDC', 'USD Coin') 9 | 10 | describe('constructor', () => { 11 | it('cannot be used for tokens on different chains', () => { 12 | expect( 13 | () => new Pair(new TokenAmount(USDT, '100'), new TokenAmount(WAVAX[ChainId.AVALANCHE], '100'), ChainId.FUJI) 14 | ).toThrow('CHAIN_IDS') 15 | }) 16 | }) 17 | 18 | describe('#getAddress', () => { 19 | it('returns the correct address', () => { 20 | expect(Pair.getAddress(USDT, JOE, ChainId.FUJI)).toEqual('0xd520cF33C013909AFc9Cf158D73F5460753B5ec4') 21 | }) 22 | it('returns the correct address - arb goerli', () => { 23 | expect(Pair.getAddress(gUSDT, gUSDC, ChainId.ARB_GOERLI)).toEqual('0x682d5A31C8BDf110657d92F78467D196007749e3') 24 | }) 25 | }) 26 | 27 | describe('#token0', () => { 28 | it('always is the token that sorts before', () => { 29 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).token0).toEqual(USDT) 30 | expect(new Pair(new TokenAmount(USDT, '100'), new TokenAmount(JOE, '100'), ChainId.FUJI).token0).toEqual(USDT) 31 | }) 32 | }) 33 | describe('#token1', () => { 34 | it('always is the token that sorts after', () => { 35 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).token1).toEqual(JOE) 36 | expect(new Pair(new TokenAmount(USDT, '100'), new TokenAmount(JOE, '100'), ChainId.FUJI).token1).toEqual(JOE) 37 | }) 38 | }) 39 | describe('#reserve0', () => { 40 | it('always comes from the token that sorts before', () => { 41 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '101'), ChainId.FUJI).reserve0).toEqual( 42 | new TokenAmount(USDT, '101') 43 | ) 44 | expect(new Pair(new TokenAmount(USDT, '101'), new TokenAmount(JOE, '100'), ChainId.FUJI).reserve0).toEqual( 45 | new TokenAmount(USDT, '101') 46 | ) 47 | }) 48 | }) 49 | describe('#reserve1', () => { 50 | it('always comes from the token that sorts after', () => { 51 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '101'), ChainId.FUJI).reserve1).toEqual( 52 | new TokenAmount(JOE, '100') 53 | ) 54 | expect(new Pair(new TokenAmount(USDT, '101'), new TokenAmount(JOE, '100'), ChainId.FUJI).reserve1).toEqual( 55 | new TokenAmount(JOE, '100') 56 | ) 57 | }) 58 | }) 59 | 60 | describe('#token0Price', () => { 61 | it('returns price of token0 in terms of token1', () => { 62 | expect(new Pair(new TokenAmount(JOE, '101'), new TokenAmount(USDT, '100'), ChainId.FUJI).token0Price).toEqual( 63 | new Price(USDT, JOE, '100', '101') 64 | ) 65 | expect(new Pair(new TokenAmount(USDT, '100'), new TokenAmount(JOE, '101'), ChainId.FUJI).token0Price).toEqual( 66 | new Price(USDT, JOE, '100', '101') 67 | ) 68 | }) 69 | }) 70 | 71 | describe('#token1Price', () => { 72 | it('returns price of token1 in terms of token0', () => { 73 | expect(new Pair(new TokenAmount(JOE, '101'), new TokenAmount(USDT, '100'), ChainId.FUJI).token1Price).toEqual( 74 | new Price(JOE, USDT, '101', '100') 75 | ) 76 | expect(new Pair(new TokenAmount(USDT, '100'), new TokenAmount(JOE, '101'), ChainId.FUJI).token1Price).toEqual( 77 | new Price(JOE, USDT, '101', '100') 78 | ) 79 | }) 80 | }) 81 | 82 | describe('#priceOf', () => { 83 | const pair = new Pair(new TokenAmount(JOE, '101'), new TokenAmount(USDT, '100'), ChainId.FUJI) 84 | it('returns price of token in terms of other token', () => { 85 | expect(pair.priceOf(USDT)).toEqual(pair.token0Price) 86 | expect(pair.priceOf(JOE)).toEqual(pair.token1Price) 87 | }) 88 | 89 | it('throws if invalid token', () => { 90 | expect(() => pair.priceOf(WAVAX[ChainId.FUJI])).toThrow('TOKEN') 91 | }) 92 | }) 93 | 94 | describe('#reserveOf', () => { 95 | it('returns reserves of the given token', () => { 96 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '101'), ChainId.FUJI).reserveOf(JOE)).toEqual( 97 | new TokenAmount(JOE, '100') 98 | ) 99 | expect(new Pair(new TokenAmount(USDT, '101'), new TokenAmount(JOE, '100'), ChainId.FUJI).reserveOf(JOE)).toEqual( 100 | new TokenAmount(JOE, '100') 101 | ) 102 | }) 103 | 104 | it('throws if not in the pair', () => { 105 | expect(() => 106 | new Pair(new TokenAmount(USDT, '101'), new TokenAmount(JOE, '100'), ChainId.FUJI).reserveOf(WAVAX[ChainId.FUJI]) 107 | ).toThrow('TOKEN') 108 | }) 109 | }) 110 | 111 | describe('#chainId', () => { 112 | it('returns the token0 chainId', () => { 113 | expect(new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).chainId).toEqual( 114 | ChainId.FUJI 115 | ) 116 | expect(new Pair(new TokenAmount(USDT, '100'), new TokenAmount(JOE, '100'), ChainId.FUJI).chainId).toEqual( 117 | ChainId.FUJI 118 | ) 119 | }) 120 | }) 121 | describe('#involvesToken', () => { 122 | expect( 123 | new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).involvesToken(JOE) 124 | ).toEqual(true) 125 | expect( 126 | new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).involvesToken(USDT) 127 | ).toEqual(true) 128 | expect( 129 | new Pair(new TokenAmount(JOE, '100'), new TokenAmount(USDT, '100'), ChainId.FUJI).involvesToken( 130 | WAVAX[ChainId.FUJI] 131 | ) 132 | ).toEqual(false) 133 | }) 134 | }) 135 | -------------------------------------------------------------------------------- /test/route.test.ts: -------------------------------------------------------------------------------- 1 | import { Token, WAVAX, ChainId, Pair, TokenAmount, Route, CNATIVE } from '../src' 2 | 3 | describe('Route', () => { 4 | const token0 = new Token(ChainId.FUJI, '0x0000000000000000000000000000000000000001', 18, 't0') 5 | const token1 = new Token(ChainId.FUJI, '0x0000000000000000000000000000000000000002', 18, 't1') 6 | const weth = WAVAX[ChainId.FUJI] 7 | const pair_0_1 = new Pair(new TokenAmount(token0, '100'), new TokenAmount(token1, '200'), ChainId.FUJI) 8 | const pair_0_weth = new Pair(new TokenAmount(token0, '100'), new TokenAmount(weth, '100'), ChainId.FUJI) 9 | const pair_1_weth = new Pair(new TokenAmount(token1, '175'), new TokenAmount(weth, '100'), ChainId.FUJI) 10 | const CHAIN_ID = ChainId.FUJI 11 | 12 | it('constructs a path from the tokens', () => { 13 | const route = new Route([pair_0_1], token0) 14 | expect(route.pairs).toEqual([pair_0_1]) 15 | expect(route.path).toEqual([token0, token1]) 16 | expect(route.input).toEqual(token0) 17 | expect(route.output).toEqual(token1) 18 | expect(route.chainId).toEqual(ChainId.FUJI) 19 | }) 20 | 21 | it('can have a token as both input and output', () => { 22 | const route = new Route([pair_0_weth, pair_0_1, pair_1_weth], weth) 23 | expect(route.pairs).toEqual([pair_0_weth, pair_0_1, pair_1_weth]) 24 | expect(route.input).toEqual(weth) 25 | expect(route.output).toEqual(weth) 26 | }) 27 | 28 | it('supports ether input', () => { 29 | const route = new Route([pair_0_weth], CNATIVE.onChain(CHAIN_ID)) 30 | expect(route.pairs).toEqual([pair_0_weth]) 31 | expect(route.input).toEqual(CNATIVE.onChain(CHAIN_ID)) 32 | expect(route.output).toEqual(token0) 33 | }) 34 | 35 | it('supports ether output', () => { 36 | const route = new Route([pair_0_weth], token0, CNATIVE.onChain(CHAIN_ID)) 37 | expect(route.pairs).toEqual([pair_0_weth]) 38 | expect(route.input).toEqual(token0) 39 | expect(route.output).toEqual(CNATIVE.onChain(CHAIN_ID)) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /test/router.test.ts: -------------------------------------------------------------------------------- 1 | import invariant from 'tiny-invariant' 2 | import { 3 | ChainId, 4 | CurrencyAmount, 5 | Pair, 6 | Percent, 7 | Route, 8 | Router, 9 | Token, 10 | TokenAmount, 11 | Trade, 12 | WAVAX, 13 | CNATIVE 14 | } from '../src' 15 | import JSBI from 'jsbi' 16 | 17 | const CHAIN_ID = ChainId.FUJI 18 | function checkDeadline(deadline: string[] | string): void { 19 | expect(typeof deadline).toBe('string') 20 | invariant(typeof deadline === 'string') 21 | // less than 5 seconds on the deadline 22 | expect(new Date().getTime() / 1000 - parseInt(deadline)).toBeLessThanOrEqual(5) 23 | } 24 | 25 | describe('Router', () => { 26 | const token0 = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000001', 18, 't0') 27 | const token1 = new Token(CHAIN_ID, '0x0000000000000000000000000000000000000002', 18, 't1') 28 | 29 | const pair_0_1 = new Pair( 30 | new TokenAmount(token0, JSBI.BigInt(1000)), 31 | new TokenAmount(token1, JSBI.BigInt(1000)), 32 | CHAIN_ID 33 | ) 34 | 35 | const pair_weth_0 = new Pair(new TokenAmount(WAVAX[CHAIN_ID], '1000'), new TokenAmount(token0, '1000'), CHAIN_ID) 36 | 37 | describe('#swapCallParameters', () => { 38 | describe('exact in', () => { 39 | it('ether to token1', () => { 40 | const result = Router.swapCallParameters( 41 | Trade.exactIn( 42 | new Route([pair_weth_0, pair_0_1], CNATIVE.onChain(CHAIN_ID), token1), 43 | CurrencyAmount.ether(CHAIN_ID, JSBI.BigInt(100)), 44 | CHAIN_ID 45 | ), 46 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 47 | ) 48 | expect(result.methodName).toEqual('swapExactAVAXForTokens') 49 | expect(result.args.slice(0, -1)).toEqual([ 50 | '0x51', 51 | [WAVAX[CHAIN_ID].address, token0.address, token1.address], 52 | '0x0000000000000000000000000000000000000004' 53 | ]) 54 | expect(result.value).toEqual('0x64') 55 | checkDeadline(result.args[result.args.length - 1]) 56 | }) 57 | 58 | it('deadline specified', () => { 59 | const result = Router.swapCallParameters( 60 | Trade.exactIn( 61 | new Route([pair_weth_0, pair_0_1], CNATIVE.onChain(CHAIN_ID), token1), 62 | CurrencyAmount.ether(CHAIN_ID, JSBI.BigInt(100)), 63 | CHAIN_ID 64 | ), 65 | { 66 | deadline: 50, 67 | recipient: '0x0000000000000000000000000000000000000004', 68 | allowedSlippage: new Percent('1', '100') 69 | } 70 | ) 71 | expect(result.methodName).toEqual('swapExactAVAXForTokens') 72 | expect(result.args).toEqual([ 73 | '0x51', 74 | [WAVAX[CHAIN_ID].address, token0.address, token1.address], 75 | '0x0000000000000000000000000000000000000004', 76 | '0x32' 77 | ]) 78 | expect(result.value).toEqual('0x64') 79 | }) 80 | 81 | it('token1 to ether', () => { 82 | const result = Router.swapCallParameters( 83 | Trade.exactIn( 84 | new Route([pair_0_1, pair_weth_0], token1, CNATIVE.onChain(CHAIN_ID)), 85 | new TokenAmount(token1, JSBI.BigInt(100)), 86 | CHAIN_ID 87 | ), 88 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 89 | ) 90 | expect(result.methodName).toEqual('swapExactTokensForAVAX') 91 | expect(result.args.slice(0, -1)).toEqual([ 92 | '0x64', 93 | '0x51', 94 | [token1.address, token0.address, WAVAX[CHAIN_ID].address], 95 | '0x0000000000000000000000000000000000000004' 96 | ]) 97 | expect(result.value).toEqual('0x0') 98 | checkDeadline(result.args[result.args.length - 1]) 99 | }) 100 | it('token0 to token1', () => { 101 | const result = Router.swapCallParameters( 102 | Trade.exactIn(new Route([pair_0_1], token0, token1), new TokenAmount(token0, JSBI.BigInt(100)), CHAIN_ID), 103 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 104 | ) 105 | expect(result.methodName).toEqual('swapExactTokensForTokens') 106 | expect(result.args.slice(0, -1)).toEqual([ 107 | '0x64', 108 | '0x59', 109 | [token0.address, token1.address], 110 | '0x0000000000000000000000000000000000000004' 111 | ]) 112 | expect(result.value).toEqual('0x0') 113 | checkDeadline(result.args[result.args.length - 1]) 114 | }) 115 | }) 116 | describe('exact out', () => { 117 | it('ether to token1', () => { 118 | const result = Router.swapCallParameters( 119 | Trade.exactOut( 120 | new Route([pair_weth_0, pair_0_1], CNATIVE.onChain(CHAIN_ID), token1), 121 | new TokenAmount(token1, JSBI.BigInt(100)), 122 | CHAIN_ID 123 | ), 124 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 125 | ) 126 | expect(result.methodName).toEqual('swapAVAXForExactTokens') 127 | expect(result.args.slice(0, -1)).toEqual([ 128 | '0x64', 129 | [WAVAX[CHAIN_ID].address, token0.address, token1.address], 130 | '0x0000000000000000000000000000000000000004' 131 | ]) 132 | expect(result.value).toEqual('0x80') 133 | checkDeadline(result.args[result.args.length - 1]) 134 | }) 135 | it('token1 to ether', () => { 136 | const result = Router.swapCallParameters( 137 | Trade.exactOut( 138 | new Route([pair_0_1, pair_weth_0], token1, CNATIVE.onChain(CHAIN_ID)), 139 | CurrencyAmount.ether(CHAIN_ID, JSBI.BigInt(100)), 140 | CHAIN_ID 141 | ), 142 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 143 | ) 144 | expect(result.methodName).toEqual('swapTokensForExactAVAX') 145 | expect(result.args.slice(0, -1)).toEqual([ 146 | '0x64', 147 | '0x80', 148 | [token1.address, token0.address, WAVAX[CHAIN_ID].address], 149 | '0x0000000000000000000000000000000000000004' 150 | ]) 151 | expect(result.value).toEqual('0x0') 152 | checkDeadline(result.args[result.args.length - 1]) 153 | }) 154 | it('token0 to token1', () => { 155 | const result = Router.swapCallParameters( 156 | Trade.exactOut(new Route([pair_0_1], token0, token1), new TokenAmount(token1, JSBI.BigInt(100)), CHAIN_ID), 157 | { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } 158 | ) 159 | expect(result.methodName).toEqual('swapTokensForExactTokens') 160 | expect(result.args.slice(0, -1)).toEqual([ 161 | '0x64', 162 | '0x71', 163 | [token0.address, token1.address], 164 | '0x0000000000000000000000000000000000000004' 165 | ]) 166 | expect(result.value).toEqual('0x0') 167 | checkDeadline(result.args[result.args.length - 1]) 168 | }) 169 | }) 170 | describe('supporting fee on transfer', () => { 171 | describe('exact in', () => { 172 | it('ether to token1', () => { 173 | const result = Router.swapCallParameters( 174 | Trade.exactIn( 175 | new Route([pair_weth_0, pair_0_1], CNATIVE.onChain(CHAIN_ID), token1), 176 | CurrencyAmount.ether(CHAIN_ID, JSBI.BigInt(100)), 177 | CHAIN_ID 178 | ), 179 | { 180 | ttl: 50, 181 | recipient: '0x0000000000000000000000000000000000000004', 182 | allowedSlippage: new Percent('1', '100'), 183 | feeOnTransfer: true 184 | } 185 | ) 186 | expect(result.methodName).toEqual('swapExactAVAXForTokensSupportingFeeOnTransferTokens') 187 | expect(result.args.slice(0, -1)).toEqual([ 188 | '0x51', 189 | [WAVAX[CHAIN_ID].address, token0.address, token1.address], 190 | '0x0000000000000000000000000000000000000004' 191 | ]) 192 | expect(result.value).toEqual('0x64') 193 | checkDeadline(result.args[result.args.length - 1]) 194 | }) 195 | it('token1 to ether', () => { 196 | const result = Router.swapCallParameters( 197 | Trade.exactIn( 198 | new Route([pair_0_1, pair_weth_0], token1, CNATIVE.onChain(CHAIN_ID)), 199 | new TokenAmount(token1, JSBI.BigInt(100)), 200 | CHAIN_ID 201 | ), 202 | { 203 | ttl: 50, 204 | recipient: '0x0000000000000000000000000000000000000004', 205 | allowedSlippage: new Percent('1', '100'), 206 | feeOnTransfer: true 207 | } 208 | ) 209 | expect(result.methodName).toEqual('swapExactTokensForAVAXSupportingFeeOnTransferTokens') 210 | expect(result.args.slice(0, -1)).toEqual([ 211 | '0x64', 212 | '0x51', 213 | [token1.address, token0.address, WAVAX[CHAIN_ID].address], 214 | '0x0000000000000000000000000000000000000004' 215 | ]) 216 | expect(result.value).toEqual('0x0') 217 | checkDeadline(result.args[result.args.length - 1]) 218 | }) 219 | it('token0 to token1', () => { 220 | const result = Router.swapCallParameters( 221 | Trade.exactIn(new Route([pair_0_1], token0, token1), new TokenAmount(token0, JSBI.BigInt(100)), CHAIN_ID), 222 | { 223 | ttl: 50, 224 | recipient: '0x0000000000000000000000000000000000000004', 225 | allowedSlippage: new Percent('1', '100'), 226 | feeOnTransfer: true 227 | } 228 | ) 229 | expect(result.methodName).toEqual('swapExactTokensForTokensSupportingFeeOnTransferTokens') 230 | expect(result.args.slice(0, -1)).toEqual([ 231 | '0x64', 232 | '0x59', 233 | [token0.address, token1.address], 234 | '0x0000000000000000000000000000000000000004' 235 | ]) 236 | expect(result.value).toEqual('0x0') 237 | checkDeadline(result.args[result.args.length - 1]) 238 | }) 239 | }) 240 | describe('exact out', () => { 241 | it('ether to token1', () => { 242 | expect(() => 243 | Router.swapCallParameters( 244 | Trade.exactOut( 245 | new Route([pair_weth_0, pair_0_1], CNATIVE.onChain(CHAIN_ID), token1), 246 | new TokenAmount(token1, JSBI.BigInt(100)), 247 | CHAIN_ID 248 | ), 249 | { 250 | ttl: 50, 251 | recipient: '0x0000000000000000000000000000000000000004', 252 | allowedSlippage: new Percent('1', '100'), 253 | feeOnTransfer: true 254 | } 255 | ) 256 | ).toThrow('EXACT_OUT_FOT') 257 | }) 258 | it('token1 to ether', () => { 259 | expect(() => 260 | Router.swapCallParameters( 261 | Trade.exactOut( 262 | new Route([pair_0_1, pair_weth_0], token1, CNATIVE.onChain(CHAIN_ID)), 263 | CurrencyAmount.ether(CHAIN_ID, JSBI.BigInt(100)), 264 | CHAIN_ID 265 | ), 266 | { 267 | ttl: 50, 268 | recipient: '0x0000000000000000000000000000000000000004', 269 | allowedSlippage: new Percent('1', '100'), 270 | feeOnTransfer: true 271 | } 272 | ) 273 | ).toThrow('EXACT_OUT_FOT') 274 | }) 275 | it('token0 to token1', () => { 276 | expect(() => 277 | Router.swapCallParameters( 278 | Trade.exactOut( 279 | new Route([pair_0_1], token0, token1), 280 | new TokenAmount(token1, JSBI.BigInt(100)), 281 | CHAIN_ID 282 | ), 283 | { 284 | ttl: 50, 285 | recipient: '0x0000000000000000000000000000000000000004', 286 | allowedSlippage: new Percent('1', '100'), 287 | feeOnTransfer: true 288 | } 289 | ) 290 | ).toThrow('EXACT_OUT_FOT') 291 | }) 292 | }) 293 | }) 294 | }) 295 | }) 296 | -------------------------------------------------------------------------------- /test/token.test.ts: -------------------------------------------------------------------------------- 1 | import { ChainId, Token } from '../src' 2 | 3 | describe('Token', () => { 4 | const ADDRESS_ONE = '0x0000000000000000000000000000000000000001' 5 | const ADDRESS_TWO = '0x0000000000000000000000000000000000000002' 6 | 7 | describe('#equals', () => { 8 | it('fails if address differs', () => { 9 | expect(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18).equals(new Token(ChainId.AVALANCHE, ADDRESS_TWO, 18))).toBe( 10 | false 11 | ) 12 | }) 13 | 14 | it('false if chain id differs', () => { 15 | expect(new Token(ChainId.FUJI, ADDRESS_ONE, 18).equals(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18))).toBe(false) 16 | }) 17 | 18 | it('true if only decimals differs', () => { 19 | expect(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 9).equals(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18))).toBe( 20 | true 21 | ) 22 | }) 23 | 24 | it('true if address is the same', () => { 25 | expect(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18).equals(new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18))).toBe( 26 | true 27 | ) 28 | }) 29 | 30 | it('true on reference equality', () => { 31 | const token = new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18) 32 | expect(token.equals(token)).toBe(true) 33 | }) 34 | 35 | it('true even if name/symbol/decimals differ', () => { 36 | const tokenA = new Token(ChainId.AVALANCHE, ADDRESS_ONE, 9, 'abc', 'def') 37 | const tokenB = new Token(ChainId.AVALANCHE, ADDRESS_ONE, 18, 'ghi', 'jkl') 38 | expect(tokenA.equals(tokenB)).toBe(true) 39 | }) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "test"], 3 | "compilerOptions": { 4 | "target": "es2018", 5 | "module": "esnext", 6 | "importHelpers": true, 7 | "declaration": true, 8 | "sourceMap": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "strictFunctionTypes": true, 13 | "strictPropertyInitialization": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": true, 17 | "noUnusedParameters": true, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": true, 20 | "moduleResolution": "node", 21 | "baseUrl": "./", 22 | "paths": { 23 | "*": ["src/*", "node_modules/*"] 24 | }, 25 | "esModuleInterop": true, 26 | "resolveJsonModule": true 27 | } 28 | } 29 | --------------------------------------------------------------------------------