├── .gitignore ├── LICENSE ├── README.md ├── abis ├── CurveRegistry.json ├── CurveTokenV1.json ├── CurveTokenV2.json ├── ERC20.json └── StableSwap.json ├── package.json ├── prettier.config.js ├── schema.graphql ├── src ├── entities │ ├── index.ts │ ├── pool.ts │ ├── system.ts │ ├── token.ts │ └── utils.ts └── mapping │ ├── registry.ts │ └── swap.ts ├── subgraph.yaml └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | /generated 3 | /build -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ProtoFire 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Curve Subgraph 2 | ============== 3 | 4 | This subgraph provides information about the following Curve liquidity pools: 5 | 6 | 1. Compound pool 7 | 2. USDT pool 8 | 3. PAX pool, with lending on yearn.finance 9 | 4. Y Pool 10 | 5. BUSD pool 11 | 6. sUSD pool (v2) 12 | 7. renBTC pool 13 | 8. sBTC pool 14 | 9. HBTC pool 15 | 10. Tri-pool 16 | 11. GUSD metapool 17 | 12. HUSD metapool 18 | 13. USDK metapool 19 | 14. USDN metapool 20 | 15. LinkUSD metapool 21 | 16. MUSD metapool 22 | 17. RSV metapool 23 | 18. tBTC metapool 24 | 25 | 26 | Note: this subgraph doesn't provide transfer data about neither ERC20 nor LP tokens because that would imply indexing 27 | a lot of events and would cost too much indexing time; it just covers basic token description including address, name, 28 | symbol and decimal precision. 29 | 30 | 31 | # Queries 32 | 33 | ## General system summary 34 | 35 | ```graphql 36 | { 37 | systemInfo(id: "current") { 38 | # Total number of pools registered 39 | poolCount 40 | 41 | # Total number of tokens registered as LP, composing or underlying coins 42 | tokenCount 43 | } 44 | } 45 | ``` 46 | 47 | 48 | ## List all supported pools 49 | 50 | ```graphql 51 | { 52 | pools(orderBy: addedAt) { 53 | # StableSwap contract address 54 | address 55 | 56 | # Composing coins 57 | coinCount 58 | 59 | coins { 60 | address 61 | name 62 | symbol 63 | decimals 64 | } 65 | 66 | # Current balances 67 | balances 68 | 69 | # LP token information 70 | poolToken { 71 | name 72 | symbol 73 | address 74 | } 75 | 76 | # Pool parameters 77 | A 78 | fee 79 | adminFee 80 | virtualPrice 81 | 82 | # Pool's events 83 | events { 84 | # ... 85 | } 86 | } 87 | } 88 | ``` 89 | 90 | Note: pool events that are indexed include exchanges, add/remove liquidity, transfer ownership and pool parameters 91 | changelogs (A coeff, fee and admin fee changes) 92 | 93 | -------------------------------------------------------------------------------- /abis/CurveRegistry.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "name": "deadline", 8 | "type": "uint256" 9 | }, 10 | { 11 | "indexed": true, 12 | "name": "admin", 13 | "type": "address" 14 | } 15 | ], 16 | "name": "CommitNewAdmin", 17 | "type": "event" 18 | }, 19 | { 20 | "anonymous": false, 21 | "inputs": [ 22 | { 23 | "indexed": true, 24 | "name": "admin", 25 | "type": "address" 26 | } 27 | ], 28 | "name": "NewAdmin", 29 | "type": "event" 30 | }, 31 | { 32 | "anonymous": false, 33 | "inputs": [ 34 | { 35 | "indexed": true, 36 | "name": "buyer", 37 | "type": "address" 38 | }, 39 | { 40 | "indexed": true, 41 | "name": "pool", 42 | "type": "address" 43 | }, 44 | { 45 | "indexed": false, 46 | "name": "token_sold", 47 | "type": "address" 48 | }, 49 | { 50 | "indexed": false, 51 | "name": "token_bought", 52 | "type": "address" 53 | }, 54 | { 55 | "indexed": false, 56 | "name": "amount_sold", 57 | "type": "uint256" 58 | }, 59 | { 60 | "indexed": false, 61 | "name": "amount_bought", 62 | "type": "uint256" 63 | } 64 | ], 65 | "name": "TokenExchange", 66 | "type": "event" 67 | }, 68 | { 69 | "anonymous": false, 70 | "inputs": [ 71 | { 72 | "indexed": true, 73 | "name": "pool", 74 | "type": "address" 75 | }, 76 | { 77 | "indexed": false, 78 | "name": "rate_method_id", 79 | "type": "bytes" 80 | } 81 | ], 82 | "name": "PoolAdded", 83 | "type": "event" 84 | }, 85 | { 86 | "anonymous": false, 87 | "inputs": [ 88 | { 89 | "indexed": true, 90 | "name": "pool", 91 | "type": "address" 92 | } 93 | ], 94 | "name": "PoolRemoved", 95 | "type": "event" 96 | }, 97 | { 98 | "constant": false, 99 | "inputs": [ 100 | { 101 | "name": "_returns_none", 102 | "type": "address[4]" 103 | } 104 | ], 105 | "outputs": [], 106 | "payable": false, 107 | "type": "constructor", 108 | "name": "constructor" 109 | }, 110 | { 111 | "constant": false, 112 | "payable": true, 113 | "type": "fallback" 114 | }, 115 | { 116 | "constant": true, 117 | "inputs": [ 118 | { 119 | "name": "_from", 120 | "type": "address" 121 | }, 122 | { 123 | "name": "_to", 124 | "type": "address" 125 | } 126 | ], 127 | "name": "find_pool_for_coins", 128 | "outputs": [ 129 | { 130 | "name": "", 131 | "type": "address" 132 | } 133 | ], 134 | "payable": false, 135 | "type": "function" 136 | }, 137 | { 138 | "constant": true, 139 | "inputs": [ 140 | { 141 | "name": "_from", 142 | "type": "address" 143 | }, 144 | { 145 | "name": "_to", 146 | "type": "address" 147 | }, 148 | { 149 | "name": "i", 150 | "type": "uint256" 151 | } 152 | ], 153 | "name": "find_pool_for_coins", 154 | "outputs": [ 155 | { 156 | "name": "", 157 | "type": "address" 158 | } 159 | ], 160 | "payable": false, 161 | "type": "function" 162 | }, 163 | { 164 | "constant": true, 165 | "gas": 45681, 166 | "inputs": [ 167 | { 168 | "name": "_pool", 169 | "type": "address" 170 | } 171 | ], 172 | "name": "get_pool_coins", 173 | "outputs": [ 174 | { 175 | "components": [ 176 | { 177 | "name": "coins", 178 | "type": "address[8]" 179 | }, 180 | { 181 | "name": "underlying_coins", 182 | "type": "address[8]" 183 | }, 184 | { 185 | "name": "decimals", 186 | "type": "uint256[8]" 187 | }, 188 | { 189 | "name": "underlying_decimals", 190 | "type": "uint256[8]" 191 | } 192 | ], 193 | "name": "", 194 | "type": "tuple" 195 | } 196 | ], 197 | "payable": false, 198 | "type": "function" 199 | }, 200 | { 201 | "constant": true, 202 | "gas": 87733, 203 | "inputs": [ 204 | { 205 | "name": "_pool", 206 | "type": "address" 207 | } 208 | ], 209 | "name": "get_pool_info", 210 | "outputs": [ 211 | { 212 | "components": [ 213 | { 214 | "name": "balances", 215 | "type": "uint256[8]" 216 | }, 217 | { 218 | "name": "underlying_balances", 219 | "type": "uint256[8]" 220 | }, 221 | { 222 | "name": "decimals", 223 | "type": "uint256[8]" 224 | }, 225 | { 226 | "name": "underlying_decimals", 227 | "type": "uint256[8]" 228 | }, 229 | { 230 | "name": "lp_token", 231 | "type": "address" 232 | }, 233 | { 234 | "name": "A", 235 | "type": "uint256" 236 | }, 237 | { 238 | "name": "fee", 239 | "type": "uint256" 240 | } 241 | ], 242 | "name": "", 243 | "type": "tuple" 244 | } 245 | ], 246 | "payable": false, 247 | "type": "function" 248 | }, 249 | { 250 | "constant": true, 251 | "gas": 44706, 252 | "inputs": [ 253 | { 254 | "name": "_pool", 255 | "type": "address" 256 | } 257 | ], 258 | "name": "get_pool_rates", 259 | "outputs": [ 260 | { 261 | "name": "", 262 | "type": "uint256[8]" 263 | } 264 | ], 265 | "payable": false, 266 | "type": "function" 267 | }, 268 | { 269 | "constant": true, 270 | "gas": 50163, 271 | "inputs": [ 272 | { 273 | "name": "_pool", 274 | "type": "address" 275 | }, 276 | { 277 | "name": "_from", 278 | "type": "address" 279 | }, 280 | { 281 | "name": "_to", 282 | "type": "address" 283 | } 284 | ], 285 | "name": "estimate_gas_used", 286 | "outputs": [ 287 | { 288 | "name": "", 289 | "type": "uint256" 290 | } 291 | ], 292 | "payable": false, 293 | "type": "function" 294 | }, 295 | { 296 | "constant": true, 297 | "gas": 45192, 298 | "inputs": [ 299 | { 300 | "name": "_pool", 301 | "type": "address" 302 | }, 303 | { 304 | "name": "_from", 305 | "type": "address" 306 | }, 307 | { 308 | "name": "_to", 309 | "type": "address" 310 | }, 311 | { 312 | "name": "_amount", 313 | "type": "uint256" 314 | } 315 | ], 316 | "name": "get_exchange_amount", 317 | "outputs": [ 318 | { 319 | "name": "", 320 | "type": "uint256" 321 | } 322 | ], 323 | "payable": false, 324 | "type": "function" 325 | }, 326 | { 327 | "constant": false, 328 | "gas": 198813, 329 | "inputs": [ 330 | { 331 | "name": "_pool", 332 | "type": "address" 333 | }, 334 | { 335 | "name": "_from", 336 | "type": "address" 337 | }, 338 | { 339 | "name": "_to", 340 | "type": "address" 341 | }, 342 | { 343 | "name": "_amount", 344 | "type": "uint256" 345 | }, 346 | { 347 | "name": "_expected", 348 | "type": "uint256" 349 | } 350 | ], 351 | "name": "exchange", 352 | "outputs": [ 353 | { 354 | "name": "", 355 | "type": "bool" 356 | } 357 | ], 358 | "payable": true, 359 | "type": "function" 360 | }, 361 | { 362 | "constant": true, 363 | "gas": 135410, 364 | "inputs": [ 365 | { 366 | "name": "_pool", 367 | "type": "address" 368 | }, 369 | { 370 | "name": "_from", 371 | "type": "address" 372 | }, 373 | { 374 | "name": "_to", 375 | "type": "address" 376 | }, 377 | { 378 | "name": "_amount", 379 | "type": "uint256" 380 | } 381 | ], 382 | "name": "get_input_amount", 383 | "outputs": [ 384 | { 385 | "name": "", 386 | "type": "uint256" 387 | } 388 | ], 389 | "payable": false, 390 | "type": "function" 391 | }, 392 | { 393 | "constant": true, 394 | "gas": 138709, 395 | "inputs": [ 396 | { 397 | "name": "_pool", 398 | "type": "address" 399 | }, 400 | { 401 | "name": "_from", 402 | "type": "address" 403 | }, 404 | { 405 | "name": "_to", 406 | "type": "address" 407 | }, 408 | { 409 | "name": "_amounts", 410 | "type": "uint256[100]" 411 | } 412 | ], 413 | "name": "get_exchange_amounts", 414 | "outputs": [ 415 | { 416 | "name": "", 417 | "type": "uint256[100]" 418 | } 419 | ], 420 | "payable": false, 421 | "type": "function" 422 | }, 423 | { 424 | "constant": false, 425 | "gas": 10290194, 426 | "inputs": [ 427 | { 428 | "name": "_pool", 429 | "type": "address" 430 | }, 431 | { 432 | "name": "_n_coins", 433 | "type": "int128" 434 | }, 435 | { 436 | "name": "_lp_token", 437 | "type": "address" 438 | }, 439 | { 440 | "name": "_calculator", 441 | "type": "address" 442 | }, 443 | { 444 | "name": "_rate_method_id", 445 | "type": "bytes32" 446 | }, 447 | { 448 | "name": "_decimals", 449 | "type": "bytes32" 450 | }, 451 | { 452 | "name": "_underlying_decimals", 453 | "type": "bytes32" 454 | } 455 | ], 456 | "name": "add_pool", 457 | "outputs": [], 458 | "payable": false, 459 | "type": "function" 460 | }, 461 | { 462 | "constant": false, 463 | "gas": 10273690, 464 | "inputs": [ 465 | { 466 | "name": "_pool", 467 | "type": "address" 468 | }, 469 | { 470 | "name": "_n_coins", 471 | "type": "int128" 472 | }, 473 | { 474 | "name": "_lp_token", 475 | "type": "address" 476 | }, 477 | { 478 | "name": "_calculator", 479 | "type": "address" 480 | }, 481 | { 482 | "name": "_rate_method_id", 483 | "type": "bytes32" 484 | }, 485 | { 486 | "name": "_decimals", 487 | "type": "bytes32" 488 | }, 489 | { 490 | "name": "_use_rates", 491 | "type": "bytes32" 492 | } 493 | ], 494 | "name": "add_pool_without_underlying", 495 | "outputs": [], 496 | "payable": false, 497 | "type": "function" 498 | }, 499 | { 500 | "constant": false, 501 | "gas": 317792223500, 502 | "inputs": [ 503 | { 504 | "name": "_pool", 505 | "type": "address" 506 | } 507 | ], 508 | "name": "remove_pool", 509 | "outputs": [], 510 | "payable": false, 511 | "type": "function" 512 | }, 513 | { 514 | "constant": false, 515 | "gas": 36818, 516 | "inputs": [ 517 | { 518 | "name": "_addr", 519 | "type": "address" 520 | }, 521 | { 522 | "name": "_is_returns_none", 523 | "type": "bool" 524 | } 525 | ], 526 | "name": "set_returns_none", 527 | "outputs": [], 528 | "payable": false, 529 | "type": "function" 530 | }, 531 | { 532 | "constant": false, 533 | "gas": 356796, 534 | "inputs": [ 535 | { 536 | "name": "_addr", 537 | "type": "address[10]" 538 | }, 539 | { 540 | "name": "_amount", 541 | "type": "uint256[10]" 542 | } 543 | ], 544 | "name": "set_coin_gas_estimates", 545 | "outputs": [], 546 | "payable": false, 547 | "type": "function" 548 | }, 549 | { 550 | "constant": false, 551 | "gas": 36911, 552 | "inputs": [ 553 | { 554 | "name": "_pool", 555 | "type": "address" 556 | }, 557 | { 558 | "name": "_estimator", 559 | "type": "address" 560 | } 561 | ], 562 | "name": "set_gas_estimate_contract", 563 | "outputs": [], 564 | "payable": false, 565 | "type": "function" 566 | }, 567 | { 568 | "constant": false, 569 | "gas": 37019, 570 | "inputs": [ 571 | { 572 | "name": "_pool", 573 | "type": "address" 574 | }, 575 | { 576 | "name": "_calculator", 577 | "type": "address" 578 | } 579 | ], 580 | "name": "set_calculator", 581 | "outputs": [], 582 | "payable": false, 583 | "type": "function" 584 | }, 585 | { 586 | "constant": true, 587 | "gas": 1953, 588 | "inputs": [ 589 | { 590 | "name": "_pool", 591 | "type": "address" 592 | } 593 | ], 594 | "name": "get_calculator", 595 | "outputs": [ 596 | { 597 | "name": "", 598 | "type": "address" 599 | } 600 | ], 601 | "payable": false, 602 | "type": "function" 603 | }, 604 | { 605 | "constant": false, 606 | "gas": 74452, 607 | "inputs": [ 608 | { 609 | "name": "_new_admin", 610 | "type": "address" 611 | } 612 | ], 613 | "name": "commit_transfer_ownership", 614 | "outputs": [], 615 | "payable": false, 616 | "type": "function" 617 | }, 618 | { 619 | "constant": false, 620 | "gas": 60590, 621 | "inputs": [], 622 | "name": "apply_transfer_ownership", 623 | "outputs": [], 624 | "payable": false, 625 | "type": "function" 626 | }, 627 | { 628 | "constant": false, 629 | "gas": 21865, 630 | "inputs": [], 631 | "name": "revert_transfer_ownership", 632 | "outputs": [], 633 | "payable": false, 634 | "type": "function" 635 | }, 636 | { 637 | "constant": false, 638 | "gas": 4854, 639 | "inputs": [ 640 | { 641 | "name": "_token", 642 | "type": "address" 643 | } 644 | ], 645 | "name": "claim_token_balance", 646 | "outputs": [], 647 | "payable": false, 648 | "type": "function" 649 | }, 650 | { 651 | "constant": false, 652 | "gas": 36726, 653 | "inputs": [], 654 | "name": "claim_eth_balance", 655 | "outputs": [], 656 | "payable": false, 657 | "type": "function" 658 | }, 659 | { 660 | "constant": true, 661 | "gas": 1901, 662 | "inputs": [], 663 | "name": "admin", 664 | "outputs": [ 665 | { 666 | "name": "", 667 | "type": "address" 668 | } 669 | ], 670 | "payable": false, 671 | "type": "function" 672 | }, 673 | { 674 | "constant": true, 675 | "gas": 2130, 676 | "inputs": [ 677 | { 678 | "name": "arg0", 679 | "type": "int128" 680 | } 681 | ], 682 | "name": "pool_list", 683 | "outputs": [ 684 | { 685 | "name": "", 686 | "type": "address" 687 | } 688 | ], 689 | "payable": false, 690 | "type": "function" 691 | }, 692 | { 693 | "constant": true, 694 | "gas": 1961, 695 | "inputs": [], 696 | "name": "pool_count", 697 | "outputs": [ 698 | { 699 | "name": "", 700 | "type": "uint256" 701 | } 702 | ], 703 | "payable": false, 704 | "type": "function" 705 | } 706 | ] -------------------------------------------------------------------------------- /abis/CurveTokenV1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Transfer", 4 | "inputs": [ 5 | { 6 | "type": "address", 7 | "name": "_from", 8 | "indexed": true 9 | }, 10 | { 11 | "type": "address", 12 | "name": "_to", 13 | "indexed": true 14 | }, 15 | { 16 | "type": "uint256", 17 | "name": "_value", 18 | "indexed": false 19 | } 20 | ], 21 | "anonymous": false, 22 | "type": "event" 23 | }, 24 | { 25 | "name": "Approval", 26 | "inputs": [ 27 | { 28 | "type": "address", 29 | "name": "_owner", 30 | "indexed": true 31 | }, 32 | { 33 | "type": "address", 34 | "name": "_spender", 35 | "indexed": true 36 | }, 37 | { 38 | "type": "uint256", 39 | "name": "_value", 40 | "indexed": false 41 | } 42 | ], 43 | "anonymous": false, 44 | "type": "event" 45 | }, 46 | { 47 | "outputs": [], 48 | "inputs": [ 49 | { 50 | "type": "string", 51 | "name": "_name" 52 | }, 53 | { 54 | "type": "string", 55 | "name": "_symbol" 56 | }, 57 | { 58 | "type": "uint256", 59 | "name": "_decimals" 60 | }, 61 | { 62 | "type": "uint256", 63 | "name": "_supply" 64 | } 65 | ], 66 | "constant": false, 67 | "payable": false, 68 | "type": "constructor" 69 | }, 70 | { 71 | "name": "set_minter", 72 | "outputs": [], 73 | "inputs": [ 74 | { 75 | "type": "address", 76 | "name": "_minter" 77 | } 78 | ], 79 | "constant": false, 80 | "payable": false, 81 | "type": "function", 82 | "gas": 36247 83 | }, 84 | { 85 | "name": "totalSupply", 86 | "outputs": [ 87 | { 88 | "type": "uint256", 89 | "name": "out" 90 | } 91 | ], 92 | "inputs": [], 93 | "constant": true, 94 | "payable": false, 95 | "type": "function", 96 | "gas": 1181 97 | }, 98 | { 99 | "name": "allowance", 100 | "outputs": [ 101 | { 102 | "type": "uint256", 103 | "name": "out" 104 | } 105 | ], 106 | "inputs": [ 107 | { 108 | "type": "address", 109 | "name": "_owner" 110 | }, 111 | { 112 | "type": "address", 113 | "name": "_spender" 114 | } 115 | ], 116 | "constant": true, 117 | "payable": false, 118 | "type": "function", 119 | "gas": 1519 120 | }, 121 | { 122 | "name": "transfer", 123 | "outputs": [ 124 | { 125 | "type": "bool", 126 | "name": "out" 127 | } 128 | ], 129 | "inputs": [ 130 | { 131 | "type": "address", 132 | "name": "_to" 133 | }, 134 | { 135 | "type": "uint256", 136 | "name": "_value" 137 | } 138 | ], 139 | "constant": false, 140 | "payable": false, 141 | "type": "function", 142 | "gas": 74802 143 | }, 144 | { 145 | "name": "transferFrom", 146 | "outputs": [ 147 | { 148 | "type": "bool", 149 | "name": "out" 150 | } 151 | ], 152 | "inputs": [ 153 | { 154 | "type": "address", 155 | "name": "_from" 156 | }, 157 | { 158 | "type": "address", 159 | "name": "_to" 160 | }, 161 | { 162 | "type": "uint256", 163 | "name": "_value" 164 | } 165 | ], 166 | "constant": false, 167 | "payable": false, 168 | "type": "function", 169 | "gas": 111953 170 | }, 171 | { 172 | "name": "approve", 173 | "outputs": [ 174 | { 175 | "type": "bool", 176 | "name": "out" 177 | } 178 | ], 179 | "inputs": [ 180 | { 181 | "type": "address", 182 | "name": "_spender" 183 | }, 184 | { 185 | "type": "uint256", 186 | "name": "_value" 187 | } 188 | ], 189 | "constant": false, 190 | "payable": false, 191 | "type": "function", 192 | "gas": 39012 193 | }, 194 | { 195 | "name": "mint", 196 | "outputs": [], 197 | "inputs": [ 198 | { 199 | "type": "address", 200 | "name": "_to" 201 | }, 202 | { 203 | "type": "uint256", 204 | "name": "_value" 205 | } 206 | ], 207 | "constant": false, 208 | "payable": false, 209 | "type": "function", 210 | "gas": 75733 211 | }, 212 | { 213 | "name": "burn", 214 | "outputs": [], 215 | "inputs": [ 216 | { 217 | "type": "uint256", 218 | "name": "_value" 219 | } 220 | ], 221 | "constant": false, 222 | "payable": false, 223 | "type": "function", 224 | "gas": 76623 225 | }, 226 | { 227 | "name": "burnFrom", 228 | "outputs": [], 229 | "inputs": [ 230 | { 231 | "type": "address", 232 | "name": "_to" 233 | }, 234 | { 235 | "type": "uint256", 236 | "name": "_value" 237 | } 238 | ], 239 | "constant": false, 240 | "payable": false, 241 | "type": "function", 242 | "gas": 76696 243 | }, 244 | { 245 | "name": "name", 246 | "outputs": [ 247 | { 248 | "type": "string", 249 | "name": "out" 250 | } 251 | ], 252 | "inputs": [], 253 | "constant": true, 254 | "payable": false, 255 | "type": "function", 256 | "gas": 7853 257 | }, 258 | { 259 | "name": "symbol", 260 | "outputs": [ 261 | { 262 | "type": "string", 263 | "name": "out" 264 | } 265 | ], 266 | "inputs": [], 267 | "constant": true, 268 | "payable": false, 269 | "type": "function", 270 | "gas": 6906 271 | }, 272 | { 273 | "name": "decimals", 274 | "outputs": [ 275 | { 276 | "type": "uint256", 277 | "name": "out" 278 | } 279 | ], 280 | "inputs": [], 281 | "constant": true, 282 | "payable": false, 283 | "type": "function", 284 | "gas": 1511 285 | }, 286 | { 287 | "name": "balanceOf", 288 | "outputs": [ 289 | { 290 | "type": "uint256", 291 | "name": "out" 292 | } 293 | ], 294 | "inputs": [ 295 | { 296 | "type": "address", 297 | "name": "arg0" 298 | } 299 | ], 300 | "constant": true, 301 | "payable": false, 302 | "type": "function", 303 | "gas": 1695 304 | } 305 | ] 306 | -------------------------------------------------------------------------------- /abis/CurveTokenV2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Transfer", 4 | "inputs": [ 5 | { 6 | "type": "address", 7 | "name": "_from", 8 | "indexed": true 9 | }, 10 | { 11 | "type": "address", 12 | "name": "_to", 13 | "indexed": true 14 | }, 15 | { 16 | "type": "uint256", 17 | "name": "_value", 18 | "indexed": false 19 | } 20 | ], 21 | "anonymous": false, 22 | "type": "event" 23 | }, 24 | { 25 | "name": "Approval", 26 | "inputs": [ 27 | { 28 | "type": "address", 29 | "name": "_owner", 30 | "indexed": true 31 | }, 32 | { 33 | "type": "address", 34 | "name": "_spender", 35 | "indexed": true 36 | }, 37 | { 38 | "type": "uint256", 39 | "name": "_value", 40 | "indexed": false 41 | } 42 | ], 43 | "anonymous": false, 44 | "type": "event" 45 | }, 46 | { 47 | "outputs": [], 48 | "inputs": [ 49 | { 50 | "type": "string", 51 | "name": "_name" 52 | }, 53 | { 54 | "type": "string", 55 | "name": "_symbol" 56 | }, 57 | { 58 | "type": "uint256", 59 | "name": "_decimals" 60 | }, 61 | { 62 | "type": "uint256", 63 | "name": "_supply" 64 | } 65 | ], 66 | "stateMutability": "nonpayable", 67 | "type": "constructor" 68 | }, 69 | { 70 | "name": "set_minter", 71 | "outputs": [], 72 | "inputs": [ 73 | { 74 | "type": "address", 75 | "name": "_minter" 76 | } 77 | ], 78 | "stateMutability": "nonpayable", 79 | "type": "function", 80 | "gas": 36247 81 | }, 82 | { 83 | "name": "set_name", 84 | "outputs": [], 85 | "inputs": [ 86 | { 87 | "type": "string", 88 | "name": "_name" 89 | }, 90 | { 91 | "type": "string", 92 | "name": "_symbol" 93 | } 94 | ], 95 | "stateMutability": "nonpayable", 96 | "type": "function", 97 | "gas": 178069 98 | }, 99 | { 100 | "name": "totalSupply", 101 | "outputs": [ 102 | { 103 | "type": "uint256", 104 | "name": "" 105 | } 106 | ], 107 | "inputs": [], 108 | "stateMutability": "view", 109 | "type": "function", 110 | "gas": 1211 111 | }, 112 | { 113 | "name": "allowance", 114 | "outputs": [ 115 | { 116 | "type": "uint256", 117 | "name": "" 118 | } 119 | ], 120 | "inputs": [ 121 | { 122 | "type": "address", 123 | "name": "_owner" 124 | }, 125 | { 126 | "type": "address", 127 | "name": "_spender" 128 | } 129 | ], 130 | "stateMutability": "view", 131 | "type": "function", 132 | "gas": 1549 133 | }, 134 | { 135 | "name": "transfer", 136 | "outputs": [ 137 | { 138 | "type": "bool", 139 | "name": "" 140 | } 141 | ], 142 | "inputs": [ 143 | { 144 | "type": "address", 145 | "name": "_to" 146 | }, 147 | { 148 | "type": "uint256", 149 | "name": "_value" 150 | } 151 | ], 152 | "stateMutability": "nonpayable", 153 | "type": "function", 154 | "gas": 74832 155 | }, 156 | { 157 | "name": "transferFrom", 158 | "outputs": [ 159 | { 160 | "type": "bool", 161 | "name": "" 162 | } 163 | ], 164 | "inputs": [ 165 | { 166 | "type": "address", 167 | "name": "_from" 168 | }, 169 | { 170 | "type": "address", 171 | "name": "_to" 172 | }, 173 | { 174 | "type": "uint256", 175 | "name": "_value" 176 | } 177 | ], 178 | "stateMutability": "nonpayable", 179 | "type": "function", 180 | "gas": 111983 181 | }, 182 | { 183 | "name": "approve", 184 | "outputs": [ 185 | { 186 | "type": "bool", 187 | "name": "" 188 | } 189 | ], 190 | "inputs": [ 191 | { 192 | "type": "address", 193 | "name": "_spender" 194 | }, 195 | { 196 | "type": "uint256", 197 | "name": "_value" 198 | } 199 | ], 200 | "stateMutability": "nonpayable", 201 | "type": "function", 202 | "gas": 39078 203 | }, 204 | { 205 | "name": "mint", 206 | "outputs": [ 207 | { 208 | "type": "bool", 209 | "name": "" 210 | } 211 | ], 212 | "inputs": [ 213 | { 214 | "type": "address", 215 | "name": "_to" 216 | }, 217 | { 218 | "type": "uint256", 219 | "name": "_value" 220 | } 221 | ], 222 | "stateMutability": "nonpayable", 223 | "type": "function", 224 | "gas": 75808 225 | }, 226 | { 227 | "name": "burnFrom", 228 | "outputs": [ 229 | { 230 | "type": "bool", 231 | "name": "" 232 | } 233 | ], 234 | "inputs": [ 235 | { 236 | "type": "address", 237 | "name": "_to" 238 | }, 239 | { 240 | "type": "uint256", 241 | "name": "_value" 242 | } 243 | ], 244 | "stateMutability": "nonpayable", 245 | "type": "function", 246 | "gas": 75826 247 | }, 248 | { 249 | "name": "name", 250 | "outputs": [ 251 | { 252 | "type": "string", 253 | "name": "" 254 | } 255 | ], 256 | "inputs": [], 257 | "stateMutability": "view", 258 | "type": "function", 259 | "gas": 7823 260 | }, 261 | { 262 | "name": "symbol", 263 | "outputs": [ 264 | { 265 | "type": "string", 266 | "name": "" 267 | } 268 | ], 269 | "inputs": [], 270 | "stateMutability": "view", 271 | "type": "function", 272 | "gas": 6876 273 | }, 274 | { 275 | "name": "decimals", 276 | "outputs": [ 277 | { 278 | "type": "uint256", 279 | "name": "" 280 | } 281 | ], 282 | "inputs": [], 283 | "stateMutability": "view", 284 | "type": "function", 285 | "gas": 1481 286 | }, 287 | { 288 | "name": "balanceOf", 289 | "outputs": [ 290 | { 291 | "type": "uint256", 292 | "name": "" 293 | } 294 | ], 295 | "inputs": [ 296 | { 297 | "type": "address", 298 | "name": "arg0" 299 | } 300 | ], 301 | "stateMutability": "view", 302 | "type": "function", 303 | "gas": 1665 304 | } 305 | ] 306 | -------------------------------------------------------------------------------- /abis/ERC20.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "name": "_spender", 21 | "type": "address" 22 | }, 23 | { 24 | "name": "_value", 25 | "type": "uint256" 26 | } 27 | ], 28 | "name": "approve", 29 | "outputs": [ 30 | { 31 | "name": "", 32 | "type": "bool" 33 | } 34 | ], 35 | "payable": false, 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [], 42 | "name": "totalSupply", 43 | "outputs": [ 44 | { 45 | "name": "", 46 | "type": "uint256" 47 | } 48 | ], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { 57 | "name": "_from", 58 | "type": "address" 59 | }, 60 | { 61 | "name": "_to", 62 | "type": "address" 63 | }, 64 | { 65 | "name": "_value", 66 | "type": "uint256" 67 | } 68 | ], 69 | "name": "transferFrom", 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "bool" 74 | } 75 | ], 76 | "payable": false, 77 | "stateMutability": "nonpayable", 78 | "type": "function" 79 | }, 80 | { 81 | "constant": true, 82 | "inputs": [], 83 | "name": "decimals", 84 | "outputs": [ 85 | { 86 | "name": "", 87 | "type": "uint8" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [ 97 | { 98 | "name": "_owner", 99 | "type": "address" 100 | } 101 | ], 102 | "name": "balanceOf", 103 | "outputs": [ 104 | { 105 | "name": "balance", 106 | "type": "uint256" 107 | } 108 | ], 109 | "payable": false, 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "constant": true, 115 | "inputs": [], 116 | "name": "symbol", 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "string" 121 | } 122 | ], 123 | "payable": false, 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "constant": false, 129 | "inputs": [ 130 | { 131 | "name": "_to", 132 | "type": "address" 133 | }, 134 | { 135 | "name": "_value", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "transfer", 140 | "outputs": [ 141 | { 142 | "name": "", 143 | "type": "bool" 144 | } 145 | ], 146 | "payable": false, 147 | "stateMutability": "nonpayable", 148 | "type": "function" 149 | }, 150 | { 151 | "constant": true, 152 | "inputs": [ 153 | { 154 | "name": "_owner", 155 | "type": "address" 156 | }, 157 | { 158 | "name": "_spender", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "allowance", 163 | "outputs": [ 164 | { 165 | "name": "", 166 | "type": "uint256" 167 | } 168 | ], 169 | "payable": false, 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "payable": true, 175 | "stateMutability": "payable", 176 | "type": "fallback" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "owner", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "spender", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "value", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "Approval", 198 | "type": "event" 199 | }, 200 | { 201 | "anonymous": false, 202 | "inputs": [ 203 | { 204 | "indexed": true, 205 | "name": "from", 206 | "type": "address" 207 | }, 208 | { 209 | "indexed": true, 210 | "name": "to", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": false, 215 | "name": "value", 216 | "type": "uint256" 217 | } 218 | ], 219 | "name": "Transfer", 220 | "type": "event" 221 | } 222 | ] 223 | -------------------------------------------------------------------------------- /abis/StableSwap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "TokenExchange", 4 | "inputs": [ 5 | { 6 | "type": "address", 7 | "name": "buyer", 8 | "indexed": true 9 | }, 10 | { 11 | "type": "int128", 12 | "name": "sold_id", 13 | "indexed": false 14 | }, 15 | { 16 | "type": "uint256", 17 | "name": "tokens_sold", 18 | "indexed": false 19 | }, 20 | { 21 | "type": "int128", 22 | "name": "bought_id", 23 | "indexed": false 24 | }, 25 | { 26 | "type": "uint256", 27 | "name": "tokens_bought", 28 | "indexed": false 29 | } 30 | ], 31 | "anonymous": false, 32 | "type": "event" 33 | }, 34 | { 35 | "name": "TokenExchangeUnderlying", 36 | "inputs": [ 37 | { 38 | "type": "address", 39 | "name": "buyer", 40 | "indexed": true 41 | }, 42 | { 43 | "type": "int128", 44 | "name": "sold_id", 45 | "indexed": false 46 | }, 47 | { 48 | "type": "uint256", 49 | "name": "tokens_sold", 50 | "indexed": false 51 | }, 52 | { 53 | "type": "int128", 54 | "name": "bought_id", 55 | "indexed": false 56 | }, 57 | { 58 | "type": "uint256", 59 | "name": "tokens_bought", 60 | "indexed": false 61 | } 62 | ], 63 | "anonymous": false, 64 | "type": "event" 65 | }, 66 | { 67 | "name": "AddLiquidity", 68 | "inputs": [ 69 | { 70 | "type": "address", 71 | "name": "provider", 72 | "indexed": true 73 | }, 74 | { 75 | "type": "uint256[2]", 76 | "name": "token_amounts", 77 | "indexed": false 78 | }, 79 | { 80 | "type": "uint256[2]", 81 | "name": "fees", 82 | "indexed": false 83 | }, 84 | { 85 | "type": "uint256", 86 | "name": "invariant", 87 | "indexed": false 88 | }, 89 | { 90 | "type": "uint256", 91 | "name": "token_supply", 92 | "indexed": false 93 | } 94 | ], 95 | "anonymous": false, 96 | "type": "event" 97 | }, 98 | { 99 | "name": "RemoveLiquidity", 100 | "inputs": [ 101 | { 102 | "type": "address", 103 | "name": "provider", 104 | "indexed": true 105 | }, 106 | { 107 | "type": "uint256[2]", 108 | "name": "token_amounts", 109 | "indexed": false 110 | }, 111 | { 112 | "type": "uint256[2]", 113 | "name": "fees", 114 | "indexed": false 115 | }, 116 | { 117 | "type": "uint256", 118 | "name": "token_supply", 119 | "indexed": false 120 | } 121 | ], 122 | "anonymous": false, 123 | "type": "event" 124 | }, 125 | { 126 | "name": "RemoveLiquidityImbalance", 127 | "inputs": [ 128 | { 129 | "type": "address", 130 | "name": "provider", 131 | "indexed": true 132 | }, 133 | { 134 | "type": "uint256[2]", 135 | "name": "token_amounts", 136 | "indexed": false 137 | }, 138 | { 139 | "type": "uint256[2]", 140 | "name": "fees", 141 | "indexed": false 142 | }, 143 | { 144 | "type": "uint256", 145 | "name": "invariant", 146 | "indexed": false 147 | }, 148 | { 149 | "type": "uint256", 150 | "name": "token_supply", 151 | "indexed": false 152 | } 153 | ], 154 | "anonymous": false, 155 | "type": "event" 156 | }, 157 | { 158 | "name": "CommitNewAdmin", 159 | "inputs": [ 160 | { 161 | "type": "uint256", 162 | "name": "deadline", 163 | "indexed": true, 164 | "unit": "sec" 165 | }, 166 | { 167 | "type": "address", 168 | "name": "admin", 169 | "indexed": true 170 | } 171 | ], 172 | "anonymous": false, 173 | "type": "event" 174 | }, 175 | { 176 | "name": "NewAdmin", 177 | "inputs": [ 178 | { 179 | "type": "address", 180 | "name": "admin", 181 | "indexed": true 182 | } 183 | ], 184 | "anonymous": false, 185 | "type": "event" 186 | }, 187 | { 188 | "name": "CommitNewParameters", 189 | "inputs": [ 190 | { 191 | "type": "uint256", 192 | "name": "deadline", 193 | "indexed": true, 194 | "unit": "sec" 195 | }, 196 | { 197 | "type": "uint256", 198 | "name": "A", 199 | "indexed": false 200 | }, 201 | { 202 | "type": "uint256", 203 | "name": "fee", 204 | "indexed": false 205 | }, 206 | { 207 | "type": "uint256", 208 | "name": "admin_fee", 209 | "indexed": false 210 | } 211 | ], 212 | "anonymous": false, 213 | "type": "event" 214 | }, 215 | { 216 | "name": "NewParameters", 217 | "inputs": [ 218 | { 219 | "type": "uint256", 220 | "name": "A", 221 | "indexed": false 222 | }, 223 | { 224 | "type": "uint256", 225 | "name": "fee", 226 | "indexed": false 227 | }, 228 | { 229 | "type": "uint256", 230 | "name": "admin_fee", 231 | "indexed": false 232 | } 233 | ], 234 | "anonymous": false, 235 | "type": "event" 236 | }, 237 | { 238 | "name": "get_virtual_price", 239 | "outputs": [ 240 | { 241 | "type": "uint256", 242 | "name": "out" 243 | } 244 | ], 245 | "inputs": [], 246 | "constant": true, 247 | "payable": false, 248 | "type": "function", 249 | "gas": 1084167 250 | }, 251 | { 252 | "name": "calc_token_amount", 253 | "outputs": [ 254 | { 255 | "type": "uint256", 256 | "name": "out" 257 | } 258 | ], 259 | "inputs": [ 260 | { 261 | "type": "uint256[2]", 262 | "name": "amounts" 263 | }, 264 | { 265 | "type": "bool", 266 | "name": "deposit" 267 | } 268 | ], 269 | "constant": true, 270 | "payable": false, 271 | "type": "function", 272 | "gas": 4239939 273 | }, 274 | { 275 | "name": "get_dy", 276 | "outputs": [ 277 | { 278 | "type": "uint256", 279 | "name": "out" 280 | } 281 | ], 282 | "inputs": [ 283 | { 284 | "type": "int128", 285 | "name": "i" 286 | }, 287 | { 288 | "type": "int128", 289 | "name": "j" 290 | }, 291 | { 292 | "type": "uint256", 293 | "name": "dx" 294 | } 295 | ], 296 | "constant": true, 297 | "payable": false, 298 | "type": "function", 299 | "gas": 2543681 300 | }, 301 | { 302 | "name": "get_dy_underlying", 303 | "outputs": [ 304 | { 305 | "type": "uint256", 306 | "name": "out" 307 | } 308 | ], 309 | "inputs": [ 310 | { 311 | "type": "int128", 312 | "name": "i" 313 | }, 314 | { 315 | "type": "int128", 316 | "name": "j" 317 | }, 318 | { 319 | "type": "uint256", 320 | "name": "dx" 321 | } 322 | ], 323 | "constant": true, 324 | "payable": false, 325 | "type": "function", 326 | "gas": 2543506 327 | }, 328 | { 329 | "name": "coins", 330 | "outputs": [ 331 | { 332 | "type": "address", 333 | "name": "out" 334 | } 335 | ], 336 | "inputs": [ 337 | { 338 | "type": "int128", 339 | "name": "arg0" 340 | } 341 | ], 342 | "constant": true, 343 | "payable": false, 344 | "type": "function", 345 | "gas": 2190 346 | }, 347 | { 348 | "name": "underlying_coins", 349 | "outputs": [ 350 | { 351 | "type": "address", 352 | "name": "out" 353 | } 354 | ], 355 | "inputs": [ 356 | { 357 | "type": "int128", 358 | "name": "arg0" 359 | } 360 | ], 361 | "constant": true, 362 | "payable": false, 363 | "type": "function", 364 | "gas": 2220 365 | }, 366 | { 367 | "name": "balances", 368 | "outputs": [ 369 | { 370 | "type": "uint256", 371 | "name": "out" 372 | } 373 | ], 374 | "inputs": [ 375 | { 376 | "type": "int128", 377 | "name": "arg0" 378 | } 379 | ], 380 | "constant": true, 381 | "payable": false, 382 | "type": "function", 383 | "gas": 2250 384 | }, 385 | { 386 | "name": "A", 387 | "outputs": [ 388 | { 389 | "type": "uint256", 390 | "name": "out" 391 | } 392 | ], 393 | "inputs": [], 394 | "constant": true, 395 | "payable": false, 396 | "type": "function", 397 | "gas": 2081 398 | }, 399 | { 400 | "name": "fee", 401 | "outputs": [ 402 | { 403 | "type": "uint256", 404 | "name": "out" 405 | } 406 | ], 407 | "inputs": [], 408 | "constant": true, 409 | "payable": false, 410 | "type": "function", 411 | "gas": 2111 412 | }, 413 | { 414 | "name": "admin_fee", 415 | "outputs": [ 416 | { 417 | "type": "uint256", 418 | "name": "out" 419 | } 420 | ], 421 | "inputs": [], 422 | "constant": true, 423 | "payable": false, 424 | "type": "function", 425 | "gas": 2141 426 | }, 427 | { 428 | "name": "owner", 429 | "outputs": [ 430 | { 431 | "type": "address", 432 | "name": "out" 433 | } 434 | ], 435 | "inputs": [], 436 | "constant": true, 437 | "payable": false, 438 | "type": "function", 439 | "gas": 2171 440 | }, 441 | { 442 | "name": "admin_actions_deadline", 443 | "outputs": [ 444 | { 445 | "type": "uint256", 446 | "unit": "sec", 447 | "name": "out" 448 | } 449 | ], 450 | "inputs": [], 451 | "constant": true, 452 | "payable": false, 453 | "type": "function", 454 | "gas": 2201 455 | }, 456 | { 457 | "name": "transfer_ownership_deadline", 458 | "outputs": [ 459 | { 460 | "type": "uint256", 461 | "unit": "sec", 462 | "name": "out" 463 | } 464 | ], 465 | "inputs": [], 466 | "constant": true, 467 | "payable": false, 468 | "type": "function", 469 | "gas": 2231 470 | }, 471 | { 472 | "name": "future_A", 473 | "outputs": [ 474 | { 475 | "type": "uint256", 476 | "name": "out" 477 | } 478 | ], 479 | "inputs": [], 480 | "constant": true, 481 | "payable": false, 482 | "type": "function", 483 | "gas": 2261 484 | }, 485 | { 486 | "name": "future_fee", 487 | "outputs": [ 488 | { 489 | "type": "uint256", 490 | "name": "out" 491 | } 492 | ], 493 | "inputs": [], 494 | "constant": true, 495 | "payable": false, 496 | "type": "function", 497 | "gas": 2291 498 | }, 499 | { 500 | "name": "future_admin_fee", 501 | "outputs": [ 502 | { 503 | "type": "uint256", 504 | "name": "out" 505 | } 506 | ], 507 | "inputs": [], 508 | "constant": true, 509 | "payable": false, 510 | "type": "function", 511 | "gas": 2321 512 | }, 513 | { 514 | "name": "future_owner", 515 | "outputs": [ 516 | { 517 | "type": "address", 518 | "name": "out" 519 | } 520 | ], 521 | "inputs": [], 522 | "constant": true, 523 | "payable": false, 524 | "type": "function", 525 | "gas": 2351 526 | } 527 | ] 528 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "curve-subgraph", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "private": true, 6 | "scripts": { 7 | "auth": "graph auth https://api.thegraph.com/deploy/", 8 | "build": "graph build", 9 | "codegen": "graph codegen", 10 | "create-local": "graph create --node http://localhost:8020/ protofire/curve", 11 | "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ protofire/curve", 12 | "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 protofire/curve", 13 | "remove-local": "graph remove --node http://localhost:8020/ protofire/curve" 14 | }, 15 | "dependencies": { 16 | "@graphprotocol/graph-cli": "0.19.0", 17 | "@graphprotocol/graph-ts": "0.19.0", 18 | "@protofire/subgraph-toolkit": "0.1.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = require('@protofire/subgraph-toolkit/prettier.config.js') 2 | -------------------------------------------------------------------------------- /schema.graphql: -------------------------------------------------------------------------------- 1 | type SystemInfo @entity { 2 | id: ID! 3 | 4 | registryOwner: Bytes 5 | 6 | exchangeCount: BigInt! 7 | poolCount: BigInt! 8 | tokenCount: BigInt! 9 | 10 | updated: BigInt! 11 | updatedAtBlock: BigInt! 12 | updatedAtTransaction: Bytes! 13 | } 14 | 15 | type Pool @entity { 16 | id: ID! 17 | 18 | " Swap contract address " 19 | address: Bytes! 20 | 21 | " Number of coins composing the pool " 22 | coinCount: Int! 23 | 24 | " Wrapped coins involved in the pool " 25 | coins: [Token!]! 26 | 27 | " Plain coins (ERC20) " 28 | underlyingCoins: [Token!]! 29 | 30 | balances: [BigInt!]! 31 | 32 | " Address of the token representing LP share " 33 | poolToken: Token 34 | 35 | " Amplification coefficient multiplied by n * (n - 1) " 36 | A: BigInt! 37 | 38 | " Fee to charge for exchanges " 39 | fee: BigDecimal! 40 | 41 | " " 42 | adminFee: BigDecimal! 43 | 44 | " Average dollar value of pool token " 45 | virtualPrice: BigDecimal! 46 | 47 | rateMethodId: Bytes 48 | 49 | " Admins address " 50 | owner: Bytes! 51 | 52 | addedAt: BigInt! 53 | addedAtBlock: BigInt! 54 | addedAtTransaction: Bytes! 55 | 56 | removedAt: BigInt 57 | removedAtBlock: BigInt 58 | removedAtTransaction: Bytes 59 | 60 | events: [PoolEvent!] @derivedFrom(field: "pool") 61 | 62 | exchanges: [Exchange!] @derivedFrom(field: "pool") 63 | } 64 | 65 | interface PoolEvent @entity { 66 | pool: Pool! 67 | 68 | block: BigInt! 69 | timestamp: BigInt! 70 | transaction: Bytes! 71 | } 72 | 73 | type FeeChangeChangelog implements PoolEvent @entity { 74 | id: ID! 75 | pool: Pool! 76 | value: BigDecimal! 77 | 78 | block: BigInt! 79 | timestamp: BigInt! 80 | transaction: Bytes! 81 | } 82 | 83 | type AdminFeeChangelog implements PoolEvent @entity { 84 | id: ID! 85 | pool: Pool! 86 | value: BigDecimal! 87 | 88 | block: BigInt! 89 | timestamp: BigInt! 90 | transaction: Bytes! 91 | } 92 | 93 | type AmplificationCoeffChangelog implements PoolEvent @entity { 94 | id: ID! 95 | pool: Pool! 96 | value: BigInt! 97 | 98 | block: BigInt! 99 | timestamp: BigInt! 100 | transaction: Bytes! 101 | } 102 | 103 | type AddLiquidityEvent implements PoolEvent @entity { 104 | id: ID! 105 | pool: Pool! 106 | provider: Bytes! 107 | tokenAmounts: [BigInt!]! 108 | fees: [BigInt!]! 109 | invariant: BigInt! 110 | tokenSupply: BigInt! 111 | 112 | block: BigInt! 113 | timestamp: BigInt! 114 | transaction: Bytes! 115 | } 116 | 117 | type RemoveLiquidityEvent implements PoolEvent @entity { 118 | id: ID! 119 | pool: Pool! 120 | provider: Bytes! 121 | tokenAmounts: [BigInt!]! 122 | fees: [BigInt!]! 123 | invariant: BigInt 124 | tokenSupply: BigInt! 125 | 126 | block: BigInt! 127 | timestamp: BigInt! 128 | transaction: Bytes! 129 | } 130 | 131 | interface Exchange { 132 | pool: Pool! 133 | 134 | buyer: Bytes! 135 | soldId: BigInt! 136 | tokensSold: BigInt! 137 | boughtId: BigInt! 138 | tokensBought: BigInt! 139 | 140 | block: BigInt! 141 | timestamp: BigInt! 142 | transaction: Bytes! 143 | } 144 | 145 | type TokenExchange implements Exchange @entity { 146 | id: ID! 147 | pool: Pool! 148 | buyer: Bytes! 149 | soldId: BigInt! 150 | tokensSold: BigInt! 151 | boughtId: BigInt! 152 | tokensBought: BigInt! 153 | 154 | block: BigInt! 155 | timestamp: BigInt! 156 | transaction: Bytes! 157 | } 158 | 159 | type UnderlyingTokenExchange implements Exchange @entity { 160 | id: ID! 161 | pool: Pool! 162 | buyer: Bytes! 163 | soldId: BigInt! 164 | tokensSold: BigInt! 165 | boughtId: BigInt! 166 | tokensBought: BigInt! 167 | 168 | block: BigInt! 169 | timestamp: BigInt! 170 | transaction: Bytes! 171 | } 172 | 173 | type TransferOwnershipEvent implements PoolEvent @entity { 174 | id: ID! 175 | pool: Pool! 176 | newAdmin: Bytes! 177 | 178 | block: BigInt! 179 | timestamp: BigInt! 180 | transaction: Bytes! 181 | } 182 | 183 | type Token @entity { 184 | id: ID! 185 | address: Bytes! 186 | decimals: BigInt! 187 | name: String 188 | symbol: String 189 | } 190 | -------------------------------------------------------------------------------- /src/entities/index.ts: -------------------------------------------------------------------------------- 1 | export { getSystemInfo } from './system' 2 | 3 | export { getOrCreatePool, getBalances } from './pool' 4 | export { getOrCreateToken } from './token' 5 | 6 | export { toFeeDecimal } from './utils' 7 | -------------------------------------------------------------------------------- /src/entities/pool.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts' 2 | import { decimal, integer, ZERO_ADDRESS } from '@protofire/subgraph-toolkit' 3 | 4 | import { StableSwap } from '../../generated/Curve/StableSwap' 5 | import { Pool } from '../../generated/schema' 6 | 7 | import { getOrCreateToken, getSystemInfo, toFeeDecimal } from './index' 8 | 9 | class PoolInfo { 10 | coins: Address[] 11 | underlyingCoins: Address[] 12 | balances: BigInt[] 13 | A: BigInt 14 | fee: BigInt 15 | adminFee: BigInt 16 | owner: Address 17 | virtualPrice: BigInt 18 | } 19 | 20 | export function getOrCreatePool(address: Address, block: ethereum.Block, tx: ethereum.Transaction): Pool { 21 | let pool = Pool.load(address.toHexString()) 22 | 23 | if (pool == null) { 24 | let info = getPoolInfo(address) 25 | 26 | pool = new Pool(address.toHexString()) 27 | pool.address = address 28 | pool.balances = info.balances 29 | pool.coinCount = info.coins.length 30 | pool.coins = registerTokens(info.coins, block, tx) 31 | pool.underlyingCoins = registerTokens(info.underlyingCoins, block, tx) 32 | 33 | pool.A = info.A 34 | pool.fee = toFeeDecimal(info.fee) 35 | pool.adminFee = toFeeDecimal(info.adminFee) 36 | 37 | pool.owner = info.owner 38 | 39 | pool.virtualPrice = decimal.fromBigInt(info.virtualPrice) 40 | 41 | pool.addedAt = block.timestamp 42 | pool.addedAtBlock = block.number 43 | pool.addedAtTransaction = tx.hash 44 | 45 | pool.save() 46 | 47 | let system = getSystemInfo(block, tx) 48 | system.poolCount = system.poolCount.plus(integer.ONE) 49 | system.save() 50 | } 51 | 52 | return pool as Pool 53 | } 54 | 55 | // Gets poll info from swap contract 56 | export function getPoolInfo(swap: Address): PoolInfo { 57 | let swapContract = StableSwap.bind(swap) 58 | 59 | let coins: Address[] = [] 60 | let underlyingCoins: Address[] = [] 61 | let balances: BigInt[] = [] 62 | 63 | let c: ethereum.CallResult
64 | let u: ethereum.CallResult 65 | let b: ethereum.CallResult