├── .gitignore ├── abi ├── FastPriceFeed.json ├── PositionManager.json ├── PositionRouter.json ├── PriceFeedExt.json └── Vault.json ├── common.js ├── config.js ├── package-lock.json ├── package.json ├── startExecutePosition.js ├── web3.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .vscode 3 | **/.DS_Store 4 | .env -------------------------------------------------------------------------------- /abi/FastPriceFeed.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "FastPriceFeed", 4 | "sourceName": "contracts/oracle/FastPriceFeed.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "uint256", 10 | "name": "_priceDuration", 11 | "type": "uint256" 12 | }, 13 | { 14 | "internalType": "uint256", 15 | "name": "_maxPriceUpdateDelay", 16 | "type": "uint256" 17 | }, 18 | { 19 | "internalType": "uint256", 20 | "name": "_minBlockInterval", 21 | "type": "uint256" 22 | }, 23 | { 24 | "internalType": "uint256", 25 | "name": "_maxDeviationBasisPoints", 26 | "type": "uint256" 27 | }, 28 | { 29 | "internalType": "address", 30 | "name": "_fastPriceEvents", 31 | "type": "address" 32 | }, 33 | { 34 | "internalType": "address", 35 | "name": "_tokenManager", 36 | "type": "address" 37 | } 38 | ], 39 | "stateMutability": "nonpayable", 40 | "type": "constructor" 41 | }, 42 | { 43 | "anonymous": false, 44 | "inputs": [ 45 | { 46 | "indexed": false, 47 | "internalType": "address", 48 | "name": "signer", 49 | "type": "address" 50 | } 51 | ], 52 | "name": "DisableFastPrice", 53 | "type": "event" 54 | }, 55 | { 56 | "anonymous": false, 57 | "inputs": [ 58 | { 59 | "indexed": false, 60 | "internalType": "address", 61 | "name": "signer", 62 | "type": "address" 63 | } 64 | ], 65 | "name": "EnableFastPrice", 66 | "type": "event" 67 | }, 68 | { 69 | "anonymous": false, 70 | "inputs": [ 71 | { 72 | "indexed": false, 73 | "internalType": "address", 74 | "name": "token", 75 | "type": "address" 76 | }, 77 | { 78 | "indexed": false, 79 | "internalType": "uint256", 80 | "name": "refPrice", 81 | "type": "uint256" 82 | }, 83 | { 84 | "indexed": false, 85 | "internalType": "uint256", 86 | "name": "fastPrice", 87 | "type": "uint256" 88 | }, 89 | { 90 | "indexed": false, 91 | "internalType": "uint256", 92 | "name": "cumulativeRefDelta", 93 | "type": "uint256" 94 | }, 95 | { 96 | "indexed": false, 97 | "internalType": "uint256", 98 | "name": "cumulativeFastDelta", 99 | "type": "uint256" 100 | } 101 | ], 102 | "name": "MaxCumulativeDeltaDiffExceeded", 103 | "type": "event" 104 | }, 105 | { 106 | "anonymous": false, 107 | "inputs": [ 108 | { 109 | "indexed": false, 110 | "internalType": "address", 111 | "name": "token", 112 | "type": "address" 113 | }, 114 | { 115 | "indexed": false, 116 | "internalType": "uint256", 117 | "name": "refPrice", 118 | "type": "uint256" 119 | }, 120 | { 121 | "indexed": false, 122 | "internalType": "uint256", 123 | "name": "fastPrice", 124 | "type": "uint256" 125 | }, 126 | { 127 | "indexed": false, 128 | "internalType": "uint256", 129 | "name": "cumulativeRefDelta", 130 | "type": "uint256" 131 | }, 132 | { 133 | "indexed": false, 134 | "internalType": "uint256", 135 | "name": "cumulativeFastDelta", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "PriceData", 140 | "type": "event" 141 | }, 142 | { 143 | "inputs": [], 144 | "name": "BASIS_POINTS_DIVISOR", 145 | "outputs": [ 146 | { 147 | "internalType": "uint256", 148 | "name": "", 149 | "type": "uint256" 150 | } 151 | ], 152 | "stateMutability": "view", 153 | "type": "function" 154 | }, 155 | { 156 | "inputs": [], 157 | "name": "BITMASK_32", 158 | "outputs": [ 159 | { 160 | "internalType": "uint256", 161 | "name": "", 162 | "type": "uint256" 163 | } 164 | ], 165 | "stateMutability": "view", 166 | "type": "function" 167 | }, 168 | { 169 | "inputs": [], 170 | "name": "CUMULATIVE_DELTA_PRECISION", 171 | "outputs": [ 172 | { 173 | "internalType": "uint256", 174 | "name": "", 175 | "type": "uint256" 176 | } 177 | ], 178 | "stateMutability": "view", 179 | "type": "function" 180 | }, 181 | { 182 | "inputs": [], 183 | "name": "MAX_CUMULATIVE_FAST_DELTA", 184 | "outputs": [ 185 | { 186 | "internalType": "uint256", 187 | "name": "", 188 | "type": "uint256" 189 | } 190 | ], 191 | "stateMutability": "view", 192 | "type": "function" 193 | }, 194 | { 195 | "inputs": [], 196 | "name": "MAX_CUMULATIVE_REF_DELTA", 197 | "outputs": [ 198 | { 199 | "internalType": "uint256", 200 | "name": "", 201 | "type": "uint256" 202 | } 203 | ], 204 | "stateMutability": "view", 205 | "type": "function" 206 | }, 207 | { 208 | "inputs": [], 209 | "name": "MAX_PRICE_DURATION", 210 | "outputs": [ 211 | { 212 | "internalType": "uint256", 213 | "name": "", 214 | "type": "uint256" 215 | } 216 | ], 217 | "stateMutability": "view", 218 | "type": "function" 219 | }, 220 | { 221 | "inputs": [], 222 | "name": "MAX_REF_PRICE", 223 | "outputs": [ 224 | { 225 | "internalType": "uint256", 226 | "name": "", 227 | "type": "uint256" 228 | } 229 | ], 230 | "stateMutability": "view", 231 | "type": "function" 232 | }, 233 | { 234 | "inputs": [], 235 | "name": "PRICE_PRECISION", 236 | "outputs": [ 237 | { 238 | "internalType": "uint256", 239 | "name": "", 240 | "type": "uint256" 241 | } 242 | ], 243 | "stateMutability": "view", 244 | "type": "function" 245 | }, 246 | { 247 | "inputs": [], 248 | "name": "disableFastPrice", 249 | "outputs": [], 250 | "stateMutability": "nonpayable", 251 | "type": "function" 252 | }, 253 | { 254 | "inputs": [], 255 | "name": "disableFastPriceVoteCount", 256 | "outputs": [ 257 | { 258 | "internalType": "uint256", 259 | "name": "", 260 | "type": "uint256" 261 | } 262 | ], 263 | "stateMutability": "view", 264 | "type": "function" 265 | }, 266 | { 267 | "inputs": [ 268 | { 269 | "internalType": "address", 270 | "name": "", 271 | "type": "address" 272 | } 273 | ], 274 | "name": "disableFastPriceVotes", 275 | "outputs": [ 276 | { 277 | "internalType": "bool", 278 | "name": "", 279 | "type": "bool" 280 | } 281 | ], 282 | "stateMutability": "view", 283 | "type": "function" 284 | }, 285 | { 286 | "inputs": [], 287 | "name": "enableFastPrice", 288 | "outputs": [], 289 | "stateMutability": "nonpayable", 290 | "type": "function" 291 | }, 292 | { 293 | "inputs": [], 294 | "name": "fastPriceEvents", 295 | "outputs": [ 296 | { 297 | "internalType": "address", 298 | "name": "", 299 | "type": "address" 300 | } 301 | ], 302 | "stateMutability": "view", 303 | "type": "function" 304 | }, 305 | { 306 | "inputs": [ 307 | { 308 | "internalType": "address", 309 | "name": "_token", 310 | "type": "address" 311 | } 312 | ], 313 | "name": "favorFastPrice", 314 | "outputs": [ 315 | { 316 | "internalType": "bool", 317 | "name": "", 318 | "type": "bool" 319 | } 320 | ], 321 | "stateMutability": "view", 322 | "type": "function" 323 | }, 324 | { 325 | "inputs": [ 326 | { 327 | "internalType": "address", 328 | "name": "_token", 329 | "type": "address" 330 | }, 331 | { 332 | "internalType": "uint256", 333 | "name": "_refPrice", 334 | "type": "uint256" 335 | }, 336 | { 337 | "internalType": "bool", 338 | "name": "_maximise", 339 | "type": "bool" 340 | } 341 | ], 342 | "name": "getPrice", 343 | "outputs": [ 344 | { 345 | "internalType": "uint256", 346 | "name": "", 347 | "type": "uint256" 348 | } 349 | ], 350 | "stateMutability": "view", 351 | "type": "function" 352 | }, 353 | { 354 | "inputs": [ 355 | { 356 | "internalType": "address", 357 | "name": "_token", 358 | "type": "address" 359 | } 360 | ], 361 | "name": "getPriceData", 362 | "outputs": [ 363 | { 364 | "internalType": "uint256", 365 | "name": "", 366 | "type": "uint256" 367 | }, 368 | { 369 | "internalType": "uint256", 370 | "name": "", 371 | "type": "uint256" 372 | }, 373 | { 374 | "internalType": "uint256", 375 | "name": "", 376 | "type": "uint256" 377 | }, 378 | { 379 | "internalType": "uint256", 380 | "name": "", 381 | "type": "uint256" 382 | } 383 | ], 384 | "stateMutability": "view", 385 | "type": "function" 386 | }, 387 | { 388 | "inputs": [], 389 | "name": "gov", 390 | "outputs": [ 391 | { 392 | "internalType": "address", 393 | "name": "", 394 | "type": "address" 395 | } 396 | ], 397 | "stateMutability": "view", 398 | "type": "function" 399 | }, 400 | { 401 | "inputs": [ 402 | { 403 | "internalType": "uint256", 404 | "name": "_minAuthorizations", 405 | "type": "uint256" 406 | }, 407 | { 408 | "internalType": "address[]", 409 | "name": "_signers", 410 | "type": "address[]" 411 | }, 412 | { 413 | "internalType": "address[]", 414 | "name": "_updaters", 415 | "type": "address[]" 416 | } 417 | ], 418 | "name": "initialize", 419 | "outputs": [], 420 | "stateMutability": "nonpayable", 421 | "type": "function" 422 | }, 423 | { 424 | "inputs": [], 425 | "name": "isInitialized", 426 | "outputs": [ 427 | { 428 | "internalType": "bool", 429 | "name": "", 430 | "type": "bool" 431 | } 432 | ], 433 | "stateMutability": "view", 434 | "type": "function" 435 | }, 436 | { 437 | "inputs": [ 438 | { 439 | "internalType": "address", 440 | "name": "", 441 | "type": "address" 442 | } 443 | ], 444 | "name": "isSigner", 445 | "outputs": [ 446 | { 447 | "internalType": "bool", 448 | "name": "", 449 | "type": "bool" 450 | } 451 | ], 452 | "stateMutability": "view", 453 | "type": "function" 454 | }, 455 | { 456 | "inputs": [], 457 | "name": "isSpreadEnabled", 458 | "outputs": [ 459 | { 460 | "internalType": "bool", 461 | "name": "", 462 | "type": "bool" 463 | } 464 | ], 465 | "stateMutability": "view", 466 | "type": "function" 467 | }, 468 | { 469 | "inputs": [ 470 | { 471 | "internalType": "address", 472 | "name": "", 473 | "type": "address" 474 | } 475 | ], 476 | "name": "isUpdater", 477 | "outputs": [ 478 | { 479 | "internalType": "bool", 480 | "name": "", 481 | "type": "bool" 482 | } 483 | ], 484 | "stateMutability": "view", 485 | "type": "function" 486 | }, 487 | { 488 | "inputs": [], 489 | "name": "lastUpdatedAt", 490 | "outputs": [ 491 | { 492 | "internalType": "uint256", 493 | "name": "", 494 | "type": "uint256" 495 | } 496 | ], 497 | "stateMutability": "view", 498 | "type": "function" 499 | }, 500 | { 501 | "inputs": [], 502 | "name": "lastUpdatedBlock", 503 | "outputs": [ 504 | { 505 | "internalType": "uint256", 506 | "name": "", 507 | "type": "uint256" 508 | } 509 | ], 510 | "stateMutability": "view", 511 | "type": "function" 512 | }, 513 | { 514 | "inputs": [ 515 | { 516 | "internalType": "address", 517 | "name": "", 518 | "type": "address" 519 | } 520 | ], 521 | "name": "maxCumulativeDeltaDiffs", 522 | "outputs": [ 523 | { 524 | "internalType": "uint256", 525 | "name": "", 526 | "type": "uint256" 527 | } 528 | ], 529 | "stateMutability": "view", 530 | "type": "function" 531 | }, 532 | { 533 | "inputs": [], 534 | "name": "maxDeviationBasisPoints", 535 | "outputs": [ 536 | { 537 | "internalType": "uint256", 538 | "name": "", 539 | "type": "uint256" 540 | } 541 | ], 542 | "stateMutability": "view", 543 | "type": "function" 544 | }, 545 | { 546 | "inputs": [], 547 | "name": "maxPriceUpdateDelay", 548 | "outputs": [ 549 | { 550 | "internalType": "uint256", 551 | "name": "", 552 | "type": "uint256" 553 | } 554 | ], 555 | "stateMutability": "view", 556 | "type": "function" 557 | }, 558 | { 559 | "inputs": [], 560 | "name": "maxTimeDeviation", 561 | "outputs": [ 562 | { 563 | "internalType": "uint256", 564 | "name": "", 565 | "type": "uint256" 566 | } 567 | ], 568 | "stateMutability": "view", 569 | "type": "function" 570 | }, 571 | { 572 | "inputs": [], 573 | "name": "minAuthorizations", 574 | "outputs": [ 575 | { 576 | "internalType": "uint256", 577 | "name": "", 578 | "type": "uint256" 579 | } 580 | ], 581 | "stateMutability": "view", 582 | "type": "function" 583 | }, 584 | { 585 | "inputs": [], 586 | "name": "minBlockInterval", 587 | "outputs": [ 588 | { 589 | "internalType": "uint256", 590 | "name": "", 591 | "type": "uint256" 592 | } 593 | ], 594 | "stateMutability": "view", 595 | "type": "function" 596 | }, 597 | { 598 | "inputs": [ 599 | { 600 | "internalType": "address", 601 | "name": "", 602 | "type": "address" 603 | } 604 | ], 605 | "name": "priceData", 606 | "outputs": [ 607 | { 608 | "internalType": "uint160", 609 | "name": "refPrice", 610 | "type": "uint160" 611 | }, 612 | { 613 | "internalType": "uint32", 614 | "name": "refTime", 615 | "type": "uint32" 616 | }, 617 | { 618 | "internalType": "uint32", 619 | "name": "cumulativeRefDelta", 620 | "type": "uint32" 621 | }, 622 | { 623 | "internalType": "uint32", 624 | "name": "cumulativeFastDelta", 625 | "type": "uint32" 626 | } 627 | ], 628 | "stateMutability": "view", 629 | "type": "function" 630 | }, 631 | { 632 | "inputs": [], 633 | "name": "priceDataInterval", 634 | "outputs": [ 635 | { 636 | "internalType": "uint256", 637 | "name": "", 638 | "type": "uint256" 639 | } 640 | ], 641 | "stateMutability": "view", 642 | "type": "function" 643 | }, 644 | { 645 | "inputs": [], 646 | "name": "priceDuration", 647 | "outputs": [ 648 | { 649 | "internalType": "uint256", 650 | "name": "", 651 | "type": "uint256" 652 | } 653 | ], 654 | "stateMutability": "view", 655 | "type": "function" 656 | }, 657 | { 658 | "inputs": [ 659 | { 660 | "internalType": "address", 661 | "name": "", 662 | "type": "address" 663 | } 664 | ], 665 | "name": "prices", 666 | "outputs": [ 667 | { 668 | "internalType": "uint256", 669 | "name": "", 670 | "type": "uint256" 671 | } 672 | ], 673 | "stateMutability": "view", 674 | "type": "function" 675 | }, 676 | { 677 | "inputs": [ 678 | { 679 | "internalType": "uint256[]", 680 | "name": "_priceBitArray", 681 | "type": "uint256[]" 682 | }, 683 | { 684 | "internalType": "uint256", 685 | "name": "_timestamp", 686 | "type": "uint256" 687 | } 688 | ], 689 | "name": "setCompactedPrices", 690 | "outputs": [], 691 | "stateMutability": "nonpayable", 692 | "type": "function" 693 | }, 694 | { 695 | "inputs": [ 696 | { 697 | "internalType": "address", 698 | "name": "_fastPriceEvents", 699 | "type": "address" 700 | } 701 | ], 702 | "name": "setFastPriceEvents", 703 | "outputs": [], 704 | "stateMutability": "nonpayable", 705 | "type": "function" 706 | }, 707 | { 708 | "inputs": [ 709 | { 710 | "internalType": "address", 711 | "name": "_gov", 712 | "type": "address" 713 | } 714 | ], 715 | "name": "setGov", 716 | "outputs": [], 717 | "stateMutability": "nonpayable", 718 | "type": "function" 719 | }, 720 | { 721 | "inputs": [ 722 | { 723 | "internalType": "bool", 724 | "name": "_isSpreadEnabled", 725 | "type": "bool" 726 | } 727 | ], 728 | "name": "setIsSpreadEnabled", 729 | "outputs": [], 730 | "stateMutability": "nonpayable", 731 | "type": "function" 732 | }, 733 | { 734 | "inputs": [ 735 | { 736 | "internalType": "uint256", 737 | "name": "_lastUpdatedAt", 738 | "type": "uint256" 739 | } 740 | ], 741 | "name": "setLastUpdatedAt", 742 | "outputs": [], 743 | "stateMutability": "nonpayable", 744 | "type": "function" 745 | }, 746 | { 747 | "inputs": [ 748 | { 749 | "internalType": "address[]", 750 | "name": "_tokens", 751 | "type": "address[]" 752 | }, 753 | { 754 | "internalType": "uint256[]", 755 | "name": "_maxCumulativeDeltaDiffs", 756 | "type": "uint256[]" 757 | } 758 | ], 759 | "name": "setMaxCumulativeDeltaDiffs", 760 | "outputs": [], 761 | "stateMutability": "nonpayable", 762 | "type": "function" 763 | }, 764 | { 765 | "inputs": [ 766 | { 767 | "internalType": "uint256", 768 | "name": "_maxDeviationBasisPoints", 769 | "type": "uint256" 770 | } 771 | ], 772 | "name": "setMaxDeviationBasisPoints", 773 | "outputs": [], 774 | "stateMutability": "nonpayable", 775 | "type": "function" 776 | }, 777 | { 778 | "inputs": [ 779 | { 780 | "internalType": "uint256", 781 | "name": "_maxPriceUpdateDelay", 782 | "type": "uint256" 783 | } 784 | ], 785 | "name": "setMaxPriceUpdateDelay", 786 | "outputs": [], 787 | "stateMutability": "nonpayable", 788 | "type": "function" 789 | }, 790 | { 791 | "inputs": [ 792 | { 793 | "internalType": "uint256", 794 | "name": "_maxTimeDeviation", 795 | "type": "uint256" 796 | } 797 | ], 798 | "name": "setMaxTimeDeviation", 799 | "outputs": [], 800 | "stateMutability": "nonpayable", 801 | "type": "function" 802 | }, 803 | { 804 | "inputs": [ 805 | { 806 | "internalType": "uint256", 807 | "name": "_minAuthorizations", 808 | "type": "uint256" 809 | } 810 | ], 811 | "name": "setMinAuthorizations", 812 | "outputs": [], 813 | "stateMutability": "nonpayable", 814 | "type": "function" 815 | }, 816 | { 817 | "inputs": [ 818 | { 819 | "internalType": "uint256", 820 | "name": "_minBlockInterval", 821 | "type": "uint256" 822 | } 823 | ], 824 | "name": "setMinBlockInterval", 825 | "outputs": [], 826 | "stateMutability": "nonpayable", 827 | "type": "function" 828 | }, 829 | { 830 | "inputs": [ 831 | { 832 | "internalType": "uint256", 833 | "name": "_priceDataInterval", 834 | "type": "uint256" 835 | } 836 | ], 837 | "name": "setPriceDataInterval", 838 | "outputs": [], 839 | "stateMutability": "nonpayable", 840 | "type": "function" 841 | }, 842 | { 843 | "inputs": [ 844 | { 845 | "internalType": "uint256", 846 | "name": "_priceDuration", 847 | "type": "uint256" 848 | } 849 | ], 850 | "name": "setPriceDuration", 851 | "outputs": [], 852 | "stateMutability": "nonpayable", 853 | "type": "function" 854 | }, 855 | { 856 | "inputs": [ 857 | { 858 | "internalType": "address[]", 859 | "name": "_tokens", 860 | "type": "address[]" 861 | }, 862 | { 863 | "internalType": "uint256[]", 864 | "name": "_prices", 865 | "type": "uint256[]" 866 | }, 867 | { 868 | "internalType": "uint256", 869 | "name": "_timestamp", 870 | "type": "uint256" 871 | } 872 | ], 873 | "name": "setPrices", 874 | "outputs": [], 875 | "stateMutability": "nonpayable", 876 | "type": "function" 877 | }, 878 | { 879 | "inputs": [ 880 | { 881 | "internalType": "uint256", 882 | "name": "_priceBits", 883 | "type": "uint256" 884 | }, 885 | { 886 | "internalType": "uint256", 887 | "name": "_timestamp", 888 | "type": "uint256" 889 | } 890 | ], 891 | "name": "setPricesWithBits", 892 | "outputs": [], 893 | "stateMutability": "nonpayable", 894 | "type": "function" 895 | }, 896 | { 897 | "inputs": [ 898 | { 899 | "internalType": "address", 900 | "name": "_positionRouter", 901 | "type": "address" 902 | }, 903 | { 904 | "internalType": "uint256", 905 | "name": "_priceBits", 906 | "type": "uint256" 907 | }, 908 | { 909 | "internalType": "uint256", 910 | "name": "_timestamp", 911 | "type": "uint256" 912 | }, 913 | { 914 | "internalType": "uint256", 915 | "name": "_endIndexForIncreasePositions", 916 | "type": "uint256" 917 | }, 918 | { 919 | "internalType": "uint256", 920 | "name": "_endIndexForDecreasePositions", 921 | "type": "uint256" 922 | }, 923 | { 924 | "internalType": "uint256", 925 | "name": "_maxIncreasePositions", 926 | "type": "uint256" 927 | }, 928 | { 929 | "internalType": "uint256", 930 | "name": "_maxDecreasePositions", 931 | "type": "uint256" 932 | } 933 | ], 934 | "name": "setPricesWithBitsAndExecute", 935 | "outputs": [], 936 | "stateMutability": "nonpayable", 937 | "type": "function" 938 | }, 939 | { 940 | "inputs": [ 941 | { 942 | "internalType": "address", 943 | "name": "_account", 944 | "type": "address" 945 | }, 946 | { 947 | "internalType": "bool", 948 | "name": "_isActive", 949 | "type": "bool" 950 | } 951 | ], 952 | "name": "setSigner", 953 | "outputs": [], 954 | "stateMutability": "nonpayable", 955 | "type": "function" 956 | }, 957 | { 958 | "inputs": [ 959 | { 960 | "internalType": "uint256", 961 | "name": "_spreadBasisPointsIfChainError", 962 | "type": "uint256" 963 | } 964 | ], 965 | "name": "setSpreadBasisPointsIfChainError", 966 | "outputs": [], 967 | "stateMutability": "nonpayable", 968 | "type": "function" 969 | }, 970 | { 971 | "inputs": [ 972 | { 973 | "internalType": "uint256", 974 | "name": "_spreadBasisPointsIfInactive", 975 | "type": "uint256" 976 | } 977 | ], 978 | "name": "setSpreadBasisPointsIfInactive", 979 | "outputs": [], 980 | "stateMutability": "nonpayable", 981 | "type": "function" 982 | }, 983 | { 984 | "inputs": [ 985 | { 986 | "internalType": "address", 987 | "name": "_tokenManager", 988 | "type": "address" 989 | } 990 | ], 991 | "name": "setTokenManager", 992 | "outputs": [], 993 | "stateMutability": "nonpayable", 994 | "type": "function" 995 | }, 996 | { 997 | "inputs": [ 998 | { 999 | "internalType": "address[]", 1000 | "name": "_tokens", 1001 | "type": "address[]" 1002 | }, 1003 | { 1004 | "internalType": "uint256[]", 1005 | "name": "_tokenPrecisions", 1006 | "type": "uint256[]" 1007 | } 1008 | ], 1009 | "name": "setTokens", 1010 | "outputs": [], 1011 | "stateMutability": "nonpayable", 1012 | "type": "function" 1013 | }, 1014 | { 1015 | "inputs": [ 1016 | { 1017 | "internalType": "address", 1018 | "name": "_account", 1019 | "type": "address" 1020 | }, 1021 | { 1022 | "internalType": "bool", 1023 | "name": "_isActive", 1024 | "type": "bool" 1025 | } 1026 | ], 1027 | "name": "setUpdater", 1028 | "outputs": [], 1029 | "stateMutability": "nonpayable", 1030 | "type": "function" 1031 | }, 1032 | { 1033 | "inputs": [ 1034 | { 1035 | "internalType": "address", 1036 | "name": "_vaultPriceFeed", 1037 | "type": "address" 1038 | } 1039 | ], 1040 | "name": "setVaultPriceFeed", 1041 | "outputs": [], 1042 | "stateMutability": "nonpayable", 1043 | "type": "function" 1044 | }, 1045 | { 1046 | "inputs": [], 1047 | "name": "spreadBasisPointsIfChainError", 1048 | "outputs": [ 1049 | { 1050 | "internalType": "uint256", 1051 | "name": "", 1052 | "type": "uint256" 1053 | } 1054 | ], 1055 | "stateMutability": "view", 1056 | "type": "function" 1057 | }, 1058 | { 1059 | "inputs": [], 1060 | "name": "spreadBasisPointsIfInactive", 1061 | "outputs": [ 1062 | { 1063 | "internalType": "uint256", 1064 | "name": "", 1065 | "type": "uint256" 1066 | } 1067 | ], 1068 | "stateMutability": "view", 1069 | "type": "function" 1070 | }, 1071 | { 1072 | "inputs": [], 1073 | "name": "tokenManager", 1074 | "outputs": [ 1075 | { 1076 | "internalType": "address", 1077 | "name": "", 1078 | "type": "address" 1079 | } 1080 | ], 1081 | "stateMutability": "view", 1082 | "type": "function" 1083 | }, 1084 | { 1085 | "inputs": [ 1086 | { 1087 | "internalType": "uint256", 1088 | "name": "", 1089 | "type": "uint256" 1090 | } 1091 | ], 1092 | "name": "tokenPrecisions", 1093 | "outputs": [ 1094 | { 1095 | "internalType": "uint256", 1096 | "name": "", 1097 | "type": "uint256" 1098 | } 1099 | ], 1100 | "stateMutability": "view", 1101 | "type": "function" 1102 | }, 1103 | { 1104 | "inputs": [ 1105 | { 1106 | "internalType": "uint256", 1107 | "name": "", 1108 | "type": "uint256" 1109 | } 1110 | ], 1111 | "name": "tokens", 1112 | "outputs": [ 1113 | { 1114 | "internalType": "address", 1115 | "name": "", 1116 | "type": "address" 1117 | } 1118 | ], 1119 | "stateMutability": "view", 1120 | "type": "function" 1121 | }, 1122 | { 1123 | "inputs": [], 1124 | "name": "vaultPriceFeed", 1125 | "outputs": [ 1126 | { 1127 | "internalType": "address", 1128 | "name": "", 1129 | "type": "address" 1130 | } 1131 | ], 1132 | "stateMutability": "view", 1133 | "type": "function" 1134 | } 1135 | ], 1136 | "bytecode": "0x60806040526000805460ff60a81b19168155600f5534801561002057600080fd5b5060405162002f0938038062002f09833981810160405260c081101561004557600080fd5b508051602082015160408301516060840151608085015160a090950151600080546001600160a01b0319163317905593949293919290916107088611156100be5760405162461bcd60e51b815260040180806020018281038252602581526020018062002ee46025913960400191505060405180910390fd5b600695909555600793909355600a91909155600d55600280546001600160a01b039283166001600160a01b03199182161790915560038054929093169116179055612dd5806200010f6000396000f3fe608060405234801561001057600080fd5b50600436106102e55760003560e01c806372279ba11161018f57806372279ba11461077c57806374bfed89146107c8578063776d16c1146107d0578063782661bc146107ed5780637cb2b79c146109125780637df73e27146109385780637fbc79c61461095e5780637fece36814610a88578063807c9782146103e357806382553aad14610abc5780638b7677f414610ad957806395082d2514610af6578063a2b47c1614610afe578063a374242514610b06578063a6eca89614610b2c578063b0a2566614610b34578063b3606b5614610b3c578063b70c7b7014610b44578063c8390a4814610b61578063c84a912414610c84578063cab44b7614610c8c578063ce98dfa814610cea578063cfad57a214610d09578063cfed246b14610d2f578063d6a153f114610d55578063d925351a14610d72578063de0d1b9414610d8f578063dfb481c914610dac578063e64559ad14610db4578063e68a22c014610dbc578063eeaa783a14610dc4578063f90ce5ba14610dcc576102e5565b806303b04936146102ea57806303cd25711461032457806303f4d7dc1461033e5780630604ddea146103e35780630e9272ea146103eb578063126082cf1461040f57806312d43a511461041757806314dd2dce1461041f578063162ac4e01461043c57806317835d1c146104625780631a15339114610485578063238aafb7146104b3578063287800c9146104d95780632a709b14146104e15780632e9cd94b146104e957806331cb61051461050657806332e5f9fa14610534578063392e53cd1461057e5780633aa08f861461058657806344c231931461058e5780634bd66c1c146103e35780634c0e31c8146105ab5780634d11fb4a146106ce5780634f64b2be146106eb5780634fdfb0861461070857806354aea1271461072e578063668d3d6514610736578063695d41841461073e5780636c56fd05146107465780636ccd47c41461076c578063715c753614610774575b600080fd5b6103106004803603602081101561030057600080fd5b50356001600160a01b0316610dd4565b604080519115158252519081900360200190f35b61032c610de9565b60408051918252519081900360200190f35b6103e16004803603604081101561035457600080fd5b810190602081018135600160201b81111561036e57600080fd5b82018360208201111561038057600080fd5b803590602001918460208302840111600160201b831117156103a157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250610def915050565b005b61032c610f66565b6103f3610f6e565b604080516001600160a01b039092168252519081900360200190f35b61032c610f7d565b6103f3610f83565b6103e16004803603602081101561043557600080fd5b5035610f92565b6103e16004803603602081101561045257600080fd5b50356001600160a01b0316610fe4565b6103e16004803603604081101561047857600080fd5b5080359060200135611053565b6103e16004803603604081101561049b57600080fd5b506001600160a01b03813516906020013515156110af565b6103e1600480360360208110156104c957600080fd5b50356001600160a01b0316611127565b61032c611196565b6103f361119c565b6103e1600480360360208110156104ff57600080fd5b50356111ab565b6103e16004803603604081101561051c57600080fd5b506001600160a01b03813516906020013515156111fd565b6103e1600480360360e081101561054a57600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a08101359060c00135611275565b61031061147d565b61032c61148d565b6103e1600480360360208110156105a457600080fd5b5035611493565b6103e1600480360360408110156105c157600080fd5b810190602081018135600160201b8111156105db57600080fd5b8201836020820111156105ed57600080fd5b803590602001918460208302840111600160201b8311171561060e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561065d57600080fd5b82018360208201111561066f57600080fd5b803590602001918460208302840111600160201b8311171561069057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611526945050505050565b61032c600480360360208110156106e457600080fd5b50356115d1565b6103f36004803603602081101561070157600080fd5b50356115ef565b6103106004803603602081101561071e57600080fd5b50356001600160a01b0316611616565b61032c61162b565b61032c611631565b610310611637565b6103106004803603602081101561075c57600080fd5b50356001600160a01b0316611647565b6103e16116d2565b61032c6117e5565b6107a26004803603602081101561079257600080fd5b50356001600160a01b03166117eb565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61032c611869565b6103e1600480360360208110156107e657600080fd5b503561186f565b6103e16004803603606081101561080357600080fd5b810190602081018135600160201b81111561081d57600080fd5b82018360208201111561082f57600080fd5b803590602001918460208302840111600160201b8311171561085057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561089f57600080fd5b8201836020820111156108b157600080fd5b803590602001918460208302840111600160201b831117156108d257600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050913592506118c1915050565b6103e16004803603602081101561092857600080fd5b50356001600160a01b031661198f565b6103106004803603602081101561094e57600080fd5b50356001600160a01b03166119fe565b6103e16004803603606081101561097457600080fd5b81359190810190604081016020820135600160201b81111561099557600080fd5b8201836020820111156109a757600080fd5b803590602001918460208302840111600160201b831117156109c857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610a1757600080fd5b820183602082011115610a2957600080fd5b803590602001918460208302840111600160201b83111715610a4a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611a13945050505050565b61032c60048036036060811015610a9e57600080fd5b506001600160a01b0381351690602081013590604001351515611b6c565b6103e160048036036020811015610ad257600080fd5b5035611cf2565b6103e160048036036020811015610aef57600080fd5b5035611d44565b61032c611d96565b61032c611da6565b61032c60048036036020811015610b1c57600080fd5b50356001600160a01b0316611dad565b61032c611dbf565b61032c611dc5565b61032c611dcb565b6103e160048036036020811015610b5a57600080fd5b5035611dd1565b6103e160048036036040811015610b7757600080fd5b810190602081018135600160201b811115610b9157600080fd5b820183602082011115610ba357600080fd5b803590602001918460208302840111600160201b83111715610bc457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610c1357600080fd5b820183602082011115610c2557600080fd5b803590602001918460208302840111600160201b83111715610c4657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611e23945050505050565b6103e1611eed565b610cb260048036036020811015610ca257600080fd5b50356001600160a01b0316612004565b604080516001600160a01b03909516855263ffffffff9384166020860152918316848301529091166060830152519081900360800190f35b6103e160048036036020811015610d0057600080fd5b50351515612043565b6103e160048036036020811015610d1f57600080fd5b50356001600160a01b03166120ae565b61032c60048036036020811015610d4557600080fd5b50356001600160a01b031661211d565b6103e160048036036020811015610d6b57600080fd5b503561212f565b6103e160048036036020811015610d8857600080fd5b5035612181565b6103e160048036036020811015610da557600080fd5b50356121d3565b61032c612225565b61032c61222b565b61032c612231565b6103f361223c565b61032c61224b565b60156020526000908152604090205460ff1681565b60065481565b3360009081526010602052604090205460ff16610e41576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b6000610e4c82612251565b90508015610f60576002546001546001600160a01b03918216911660005b8551811015610f5c576000868281518110610e8157fe5b6020026020010151905060005b6008811015610f5257601654600884028201908110610eb35750505050505050610f62565b60168054602084029185831c63ffffffff169160009190600889028701908110610ed957fe5b6000918252602082200154601780546001600160a01b0390921693509060088a028801908110610f0557fe5b60009182526020822001549150610f3282610f2c8668327cb2734119d3b7a9601e1b61235d565b906123bf565b9050610f4083828c8e6123fe565b505060019094019350610e8e92505050565b5050600101610e6a565b5050505b505b5050565b63ffffffff81565b6002546001600160a01b031681565b61271081565b6000546001600160a01b031681565b6000546001600160a01b03163314610fdf576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600455565b6000546001600160a01b03163314611031576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526010602052604090205460ff166110a5576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b610f628282612693565b6000546001600160a01b031633146110fc576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601060205260409020805460ff1916911515919091179055565b6000546001600160a01b03163314611174576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600e5481565b6003546001600160a01b031681565b6003546001600160a01b031633146111f8576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600c55565b6000546001600160a01b0316331461124a576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b3360009081526010602052604090205460ff166112c7576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b6112d18686612693565b6000879050600061134984836001600160a01b0316639b5786206040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b505050506040513d602081101561134157600080fd5b505190612769565b9050600061138c84846001600160a01b0316631bca8cf06040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561131757600080fd5b90508187111561139a578196505b808611156113a6578095505b60408051629a208160e81b81526004810189905233602482015290516001600160a01b03851691639a20810091604480830192600092919082900301818387803b1580156113f357600080fd5b505af1158015611407573d6000803e3d6000fd5b50506040805163f3883d8b60e01b8152600481018a905233602482015290516001600160a01b038716935063f3883d8b9250604480830192600092919082900301818387803b15801561145957600080fd5b505af115801561146d573d6000803e3d6000fd5b5050505050505050505050505050565b600054600160a01b900460ff1681565b600b5481565b6000546001600160a01b031633146114e0576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6107088111156115215760405162461bcd60e51b8152600401808060200182810382526025815260200180612c1b6025913960400191505060405180910390fd5b600655565b6003546001600160a01b03163314611573576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b60005b8251811015610f6057600083828151811061158d57fe5b602002602001015190508282815181106115a357fe5b6020908102919091018101516001600160a01b03909216600090815260139091526040902055600101611576565b601781815481106115de57fe5b600091825260209091200154905081565b601681815481106115fc57fe5b6000918252602090912001546001600160a01b0316905081565b60106020526000908152604090205460ff1681565b60045481565b61070881565b600054600160a81b900460ff1681565b60008054600160a81b900460ff1615611662575060006116cd565b600e54600f5410611675575060006116cd565b600080611681846117eb565b93509350505081811180156116b657506001600160a01b0384166000908152601360205260409020546116b482846127c1565b115b156116c6576000925050506116cd565b6001925050505b919050565b3360009081526014602052604090205460ff16611724576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b3360009081526015602052604090205460ff16611788576040805162461bcd60e51b815260206004820152601e60248201527f466173745072696365466565643a20616c726561647920656e61626c65640000604482015290519081900360640190fd5b336000908152601560205260409020805460ff19169055600f546117ad9060016127c1565b600f556040805133815290517f9fe0c305c33aa92757a537936872a60be0d91549a4303cc99fd8b7fce8a002759181900360200190a1565b600d5481565b6000806000806117f9612b13565b505050506001600160a01b039182166000908152601260209081526040918290208251608081018452905494851680825263ffffffff600160a01b87048116938301849052600160c01b87048116948301859052600160e01b909604909516606090910181905293949093919250565b60085481565b6000546001600160a01b031633146118bc576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600b55565b3360009081526010602052604090205460ff16611913576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600061191e82612251565b90508015611989576002546001546001600160a01b03918216911660005b865181101561198557600087828151811061195357fe5b6020026020010151905061197c8188848151811061196d57fe5b602002602001015185876123fe565b5060010161193c565b5050505b50505050565b6003546001600160a01b031633146119dc576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60146020526000908152604090205460ff1681565b6000546001600160a01b03163314611a60576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600054600160a01b900460ff1615611aa95760405162461bcd60e51b8152600401808060200182810382526022815260200180612d7e6022913960400191505060405180910390fd5b6000805460ff60a01b1916600160a01b178155600e8490555b8251811015611b15576000838281518110611ad957fe5b6020908102919091018101516001600160a01b03166000908152601490915260409020805460ff19166001908117909155919091019050611ac2565b5060005b8151811015611989576000828281518110611b3057fe5b6020908102919091018101516001600160a01b03166000908152601090915260409020805460ff19166001908117909155919091019050611b19565b6000611b8560075460045461276990919063ffffffff16565b421115611be0578115611bc057611bb9612710610f2c611bb260095461271061276990919063ffffffff16565b869061235d565b9050611ceb565b611bb9612710610f2c611bb26009546127106127c190919063ffffffff16565b600654600454611bef91612769565b421115611c3c578115611c1c57611bb9612710610f2c611bb260085461271061276990919063ffffffff16565b611bb9612710610f2c611bb26008546127106127c190919063ffffffff16565b6001600160a01b03841660009081526011602052604090205480611c635783915050611ceb565b6000818511611c7b57611c7682866127c1565b611c85565b611c8585836127c1565b9050611c9785610f2c8361271061235d565b90506000611ca487611647565b1580611cb15750600d5482115b90508015611ce5578415611cd857828611611ccc5782611cce565b855b9350505050611ceb565b828610611ccc5782611cce565b50909150505b9392505050565b6003546001600160a01b03163314611d3f576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600d55565b6000546001600160a01b03163314611d91576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600755565b68327cb2734119d3b7a9601e1b81565b6298968081565b60136020526000908152604090205481565b60095481565b600f5481565b600a5481565b6000546001600160a01b03163314611e1e576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600855565b6000546001600160a01b03163314611e70576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b8051825114611ec6576040805162461bcd60e51b815260206004820152601e60248201527f466173745072696365466565643a20696e76616c6964206c656e677468730000604482015290519081900360640190fd5b8151611ed9906016906020850190612b3a565b508051610f60906017906020840190612b9f565b3360009081526014602052604090205460ff16611f3f576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b3360009081526015602052604090205460ff1615611fa3576040805162461bcd60e51b815260206004820152601c60248201527b11985cdd141c9a58d9519959590e88185b1c9958591e481d9bdd195960221b604482015290519081900360640190fd5b336000908152601560205260409020805460ff19166001908117909155600f54611fcc91612769565b600f556040805133815290517f4c0c5fabf50e808e3bc8d19577d305e3a7163eea7e8a74a50caa8896694cd44b9181900360200190a1565b6012602052600090815260409020546001600160a01b0381169063ffffffff600160a01b8204811691600160c01b8104821691600160e01b9091041684565b6000546001600160a01b03163314612090576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b60008054911515600160a81b0260ff60a81b19909216919091179055565b6000546001600160a01b031633146120fb576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60116020526000908152604090205481565b6000546001600160a01b0316331461217c576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600a55565b6003546001600160a01b031633146121ce576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600e55565b6000546001600160a01b03163314612220576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600955565b600c5481565b60075481565b6001600160a01b0381565b6001546001600160a01b031681565b60055481565b600a54600090156122aa57600a5460055461226d9043906127c1565b10156122aa5760405162461bcd60e51b815260040180806020018281038252602e815260200180612d27602e913960400191505060405180910390fd5b600b546122b742826127c1565b83116122f45760405162461bcd60e51b815260040180806020018281038252602d815260200180612cfa602d913960400191505060405180910390fd5b6122fe4282612769565b831061233b5760405162461bcd60e51b815260040180806020018281038252602f815260200180612caa602f913960400191505060405180910390fd5b60045483101561234f5760009150506116cd565b505060045543600555600190565b60008261236c575060006123b9565b8282028284828161237957fe5b04146123b65760405162461bcd60e51b8152600401808060200182810382526021815260200180612cd96021913960400191505060405180910390fd5b90505b92915050565b60006123b683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250612803565b6001600160a01b0382161561266d576000826001600160a01b03166356bf9de4866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561245c57600080fd5b505afa158015612470573d6000803e3d6000fd5b505050506040513d602081101561248657600080fd5b50516001600160a01b0386166000908152601160205260408120549192508080806124b08a6117eb565b935093509350935060008411156125775760008487116124d9576124d485886127c1565b6124e3565b6124e387866127c1565b905060008a87116124fd576124f88b886127c1565b612507565b612507878c6127c1565b905061251e600c54426123bf90919063ffffffff16565b600c5461252c9087906123bf565b1461253a5760009350600092505b61255561254e87610f2c856298968061235d565b8590612769565b935061257261256b88610f2c846298968061235d565b8490612769565b925050505b81811180156125a657506001600160a01b038a166000908152601360205260409020546125a482846127c1565b115b1561260357604080516001600160a01b038c16815260208101889052808201879052606081018490526080810183905290517fe582322b389ad06b2bbf619cd6da3f16a288ec873ea0fa6df4d72f3d9480b4479181900360a00190a15b61260f8a8784846128a5565b604080516001600160a01b038c16815260208101889052808201879052606081018490526080810183905290517f23b9387f81fca646aac1dc4487ede045c65f5f7445482906565f01e05afdb3a89181900360a00190a15050505050505b6001600160a01b0384166000908152601160205260409020839055611989818585612a3b565b600061269e82612251565b90508015610f60576002546001546001600160a01b03918216911660005b6008811015610f5c57601654819081106126da575050505050610f62565b60168054602084029189831c63ffffffff169160009190869081106126fb57fe5b6000918252602082200154601780546001600160a01b039092169350908790811061272257fe5b6000918252602082200154915061274982610f2c8668327cb2734119d3b7a9601e1b61235d565b905061275783828a8c6123fe565b5050600190940193506126bc92505050565b6000828201838110156123b6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60006123b683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612ab9565b6000818361288f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561285457818101518382015260200161283c565b50505050905090810190601f1680156128815780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161289b57fe5b0495945050505050565b6001600160a01b038310612900576040805162461bcd60e51b815260206004820152601f60248201527f466173745072696365466565643a20696e76616c696420726566507269636500604482015290519081900360640190fd5b63ffffffff82106129425760405162461bcd60e51b8152600401808060200182810382526029815260200180612d556029913960400191505060405180910390fd5b63ffffffff81106129845760405162461bcd60e51b815260040180806020018281038252602a815260200180612c40602a913960400191505060405180910390fd5b604080516080810182526001600160a01b03948516815263ffffffff4281166020808401918252958216838501908152948216606084019081529787166000908152601290965292909420905181549251935196518516600160e01b026001600160e01b03978616600160c01b0263ffffffff60c01b1995909616600160a01b0263ffffffff60a01b19929097166001600160a01b0319909416939093171694909417919091169190911792909216919091179055565b6001600160a01b038316612a4e57610f60565b826001600160a01b031663e0409c7183836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015612aa557600080fd5b505af1158015611985573d6000803e3d6000fd5b60008184841115612b0b5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561285457818101518382015260200161283c565b505050900390565b60408051608081018252600080825260208201819052918101829052606081019190915290565b828054828255906000526020600020908101928215612b8f579160200282015b82811115612b8f57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612b5a565b50612b9b929150612be6565b5090565b828054828255906000526020600020908101928215612bda579160200282015b82811115612bda578251825591602001919060010190612bbf565b50612b9b929150612c05565b5b80821115612b9b5780546001600160a01b0319168155600101612be7565b5b80821115612b9b5760008155600101612c0656fe466173745072696365466565643a20696e76616c6964205f70726963654475726174696f6e466173745072696365466565643a20696e76616c69642063756d756c61746976654661737444656c7461476f7665726e61626c653a20666f7262696464656e0000000000000000000000466173745072696365466565643a20666f7262696464656e0000000000000000466173745072696365466565643a205f74696d657374616d70206578636565647320616c6c6f7765642072616e6765536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77466173745072696365466565643a205f74696d657374616d702062656c6f7720616c6c6f7765642072616e6765466173745072696365466565643a206d696e426c6f636b496e74657276616c206e6f742079657420706173736564466173745072696365466565643a20696e76616c69642063756d756c617469766552656644656c7461466173745072696365466565643a20616c726561647920696e697469616c697a6564a264697066735822122022799291e1b6a46586afa22726fbcd83d4f577c3ed514e7cbcd27223f3f95ddc64736f6c634300060c0033466173745072696365466565643a20696e76616c6964205f70726963654475726174696f6e", 1137 | "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106102e55760003560e01c806372279ba11161018f57806372279ba11461077c57806374bfed89146107c8578063776d16c1146107d0578063782661bc146107ed5780637cb2b79c146109125780637df73e27146109385780637fbc79c61461095e5780637fece36814610a88578063807c9782146103e357806382553aad14610abc5780638b7677f414610ad957806395082d2514610af6578063a2b47c1614610afe578063a374242514610b06578063a6eca89614610b2c578063b0a2566614610b34578063b3606b5614610b3c578063b70c7b7014610b44578063c8390a4814610b61578063c84a912414610c84578063cab44b7614610c8c578063ce98dfa814610cea578063cfad57a214610d09578063cfed246b14610d2f578063d6a153f114610d55578063d925351a14610d72578063de0d1b9414610d8f578063dfb481c914610dac578063e64559ad14610db4578063e68a22c014610dbc578063eeaa783a14610dc4578063f90ce5ba14610dcc576102e5565b806303b04936146102ea57806303cd25711461032457806303f4d7dc1461033e5780630604ddea146103e35780630e9272ea146103eb578063126082cf1461040f57806312d43a511461041757806314dd2dce1461041f578063162ac4e01461043c57806317835d1c146104625780631a15339114610485578063238aafb7146104b3578063287800c9146104d95780632a709b14146104e15780632e9cd94b146104e957806331cb61051461050657806332e5f9fa14610534578063392e53cd1461057e5780633aa08f861461058657806344c231931461058e5780634bd66c1c146103e35780634c0e31c8146105ab5780634d11fb4a146106ce5780634f64b2be146106eb5780634fdfb0861461070857806354aea1271461072e578063668d3d6514610736578063695d41841461073e5780636c56fd05146107465780636ccd47c41461076c578063715c753614610774575b600080fd5b6103106004803603602081101561030057600080fd5b50356001600160a01b0316610dd4565b604080519115158252519081900360200190f35b61032c610de9565b60408051918252519081900360200190f35b6103e16004803603604081101561035457600080fd5b810190602081018135600160201b81111561036e57600080fd5b82018360208201111561038057600080fd5b803590602001918460208302840111600160201b831117156103a157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250610def915050565b005b61032c610f66565b6103f3610f6e565b604080516001600160a01b039092168252519081900360200190f35b61032c610f7d565b6103f3610f83565b6103e16004803603602081101561043557600080fd5b5035610f92565b6103e16004803603602081101561045257600080fd5b50356001600160a01b0316610fe4565b6103e16004803603604081101561047857600080fd5b5080359060200135611053565b6103e16004803603604081101561049b57600080fd5b506001600160a01b03813516906020013515156110af565b6103e1600480360360208110156104c957600080fd5b50356001600160a01b0316611127565b61032c611196565b6103f361119c565b6103e1600480360360208110156104ff57600080fd5b50356111ab565b6103e16004803603604081101561051c57600080fd5b506001600160a01b03813516906020013515156111fd565b6103e1600480360360e081101561054a57600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a08101359060c00135611275565b61031061147d565b61032c61148d565b6103e1600480360360208110156105a457600080fd5b5035611493565b6103e1600480360360408110156105c157600080fd5b810190602081018135600160201b8111156105db57600080fd5b8201836020820111156105ed57600080fd5b803590602001918460208302840111600160201b8311171561060e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561065d57600080fd5b82018360208201111561066f57600080fd5b803590602001918460208302840111600160201b8311171561069057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611526945050505050565b61032c600480360360208110156106e457600080fd5b50356115d1565b6103f36004803603602081101561070157600080fd5b50356115ef565b6103106004803603602081101561071e57600080fd5b50356001600160a01b0316611616565b61032c61162b565b61032c611631565b610310611637565b6103106004803603602081101561075c57600080fd5b50356001600160a01b0316611647565b6103e16116d2565b61032c6117e5565b6107a26004803603602081101561079257600080fd5b50356001600160a01b03166117eb565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61032c611869565b6103e1600480360360208110156107e657600080fd5b503561186f565b6103e16004803603606081101561080357600080fd5b810190602081018135600160201b81111561081d57600080fd5b82018360208201111561082f57600080fd5b803590602001918460208302840111600160201b8311171561085057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561089f57600080fd5b8201836020820111156108b157600080fd5b803590602001918460208302840111600160201b831117156108d257600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050913592506118c1915050565b6103e16004803603602081101561092857600080fd5b50356001600160a01b031661198f565b6103106004803603602081101561094e57600080fd5b50356001600160a01b03166119fe565b6103e16004803603606081101561097457600080fd5b81359190810190604081016020820135600160201b81111561099557600080fd5b8201836020820111156109a757600080fd5b803590602001918460208302840111600160201b831117156109c857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610a1757600080fd5b820183602082011115610a2957600080fd5b803590602001918460208302840111600160201b83111715610a4a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611a13945050505050565b61032c60048036036060811015610a9e57600080fd5b506001600160a01b0381351690602081013590604001351515611b6c565b6103e160048036036020811015610ad257600080fd5b5035611cf2565b6103e160048036036020811015610aef57600080fd5b5035611d44565b61032c611d96565b61032c611da6565b61032c60048036036020811015610b1c57600080fd5b50356001600160a01b0316611dad565b61032c611dbf565b61032c611dc5565b61032c611dcb565b6103e160048036036020811015610b5a57600080fd5b5035611dd1565b6103e160048036036040811015610b7757600080fd5b810190602081018135600160201b811115610b9157600080fd5b820183602082011115610ba357600080fd5b803590602001918460208302840111600160201b83111715610bc457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610c1357600080fd5b820183602082011115610c2557600080fd5b803590602001918460208302840111600160201b83111715610c4657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611e23945050505050565b6103e1611eed565b610cb260048036036020811015610ca257600080fd5b50356001600160a01b0316612004565b604080516001600160a01b03909516855263ffffffff9384166020860152918316848301529091166060830152519081900360800190f35b6103e160048036036020811015610d0057600080fd5b50351515612043565b6103e160048036036020811015610d1f57600080fd5b50356001600160a01b03166120ae565b61032c60048036036020811015610d4557600080fd5b50356001600160a01b031661211d565b6103e160048036036020811015610d6b57600080fd5b503561212f565b6103e160048036036020811015610d8857600080fd5b5035612181565b6103e160048036036020811015610da557600080fd5b50356121d3565b61032c612225565b61032c61222b565b61032c612231565b6103f361223c565b61032c61224b565b60156020526000908152604090205460ff1681565b60065481565b3360009081526010602052604090205460ff16610e41576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b6000610e4c82612251565b90508015610f60576002546001546001600160a01b03918216911660005b8551811015610f5c576000868281518110610e8157fe5b6020026020010151905060005b6008811015610f5257601654600884028201908110610eb35750505050505050610f62565b60168054602084029185831c63ffffffff169160009190600889028701908110610ed957fe5b6000918252602082200154601780546001600160a01b0390921693509060088a028801908110610f0557fe5b60009182526020822001549150610f3282610f2c8668327cb2734119d3b7a9601e1b61235d565b906123bf565b9050610f4083828c8e6123fe565b505060019094019350610e8e92505050565b5050600101610e6a565b5050505b505b5050565b63ffffffff81565b6002546001600160a01b031681565b61271081565b6000546001600160a01b031681565b6000546001600160a01b03163314610fdf576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600455565b6000546001600160a01b03163314611031576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526010602052604090205460ff166110a5576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b610f628282612693565b6000546001600160a01b031633146110fc576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601060205260409020805460ff1916911515919091179055565b6000546001600160a01b03163314611174576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600e5481565b6003546001600160a01b031681565b6003546001600160a01b031633146111f8576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600c55565b6000546001600160a01b0316331461124a576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b3360009081526010602052604090205460ff166112c7576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b6112d18686612693565b6000879050600061134984836001600160a01b0316639b5786206040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b505050506040513d602081101561134157600080fd5b505190612769565b9050600061138c84846001600160a01b0316631bca8cf06040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561131757600080fd5b90508187111561139a578196505b808611156113a6578095505b60408051629a208160e81b81526004810189905233602482015290516001600160a01b03851691639a20810091604480830192600092919082900301818387803b1580156113f357600080fd5b505af1158015611407573d6000803e3d6000fd5b50506040805163f3883d8b60e01b8152600481018a905233602482015290516001600160a01b038716935063f3883d8b9250604480830192600092919082900301818387803b15801561145957600080fd5b505af115801561146d573d6000803e3d6000fd5b5050505050505050505050505050565b600054600160a01b900460ff1681565b600b5481565b6000546001600160a01b031633146114e0576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b6107088111156115215760405162461bcd60e51b8152600401808060200182810382526025815260200180612c1b6025913960400191505060405180910390fd5b600655565b6003546001600160a01b03163314611573576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b60005b8251811015610f6057600083828151811061158d57fe5b602002602001015190508282815181106115a357fe5b6020908102919091018101516001600160a01b03909216600090815260139091526040902055600101611576565b601781815481106115de57fe5b600091825260209091200154905081565b601681815481106115fc57fe5b6000918252602090912001546001600160a01b0316905081565b60106020526000908152604090205460ff1681565b60045481565b61070881565b600054600160a81b900460ff1681565b60008054600160a81b900460ff1615611662575060006116cd565b600e54600f5410611675575060006116cd565b600080611681846117eb565b93509350505081811180156116b657506001600160a01b0384166000908152601360205260409020546116b482846127c1565b115b156116c6576000925050506116cd565b6001925050505b919050565b3360009081526014602052604090205460ff16611724576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b3360009081526015602052604090205460ff16611788576040805162461bcd60e51b815260206004820152601e60248201527f466173745072696365466565643a20616c726561647920656e61626c65640000604482015290519081900360640190fd5b336000908152601560205260409020805460ff19169055600f546117ad9060016127c1565b600f556040805133815290517f9fe0c305c33aa92757a537936872a60be0d91549a4303cc99fd8b7fce8a002759181900360200190a1565b600d5481565b6000806000806117f9612b13565b505050506001600160a01b039182166000908152601260209081526040918290208251608081018452905494851680825263ffffffff600160a01b87048116938301849052600160c01b87048116948301859052600160e01b909604909516606090910181905293949093919250565b60085481565b6000546001600160a01b031633146118bc576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600b55565b3360009081526010602052604090205460ff16611913576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600061191e82612251565b90508015611989576002546001546001600160a01b03918216911660005b865181101561198557600087828151811061195357fe5b6020026020010151905061197c8188848151811061196d57fe5b602002602001015185876123fe565b5060010161193c565b5050505b50505050565b6003546001600160a01b031633146119dc576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60146020526000908152604090205460ff1681565b6000546001600160a01b03163314611a60576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600054600160a01b900460ff1615611aa95760405162461bcd60e51b8152600401808060200182810382526022815260200180612d7e6022913960400191505060405180910390fd5b6000805460ff60a01b1916600160a01b178155600e8490555b8251811015611b15576000838281518110611ad957fe5b6020908102919091018101516001600160a01b03166000908152601490915260409020805460ff19166001908117909155919091019050611ac2565b5060005b8151811015611989576000828281518110611b3057fe5b6020908102919091018101516001600160a01b03166000908152601090915260409020805460ff19166001908117909155919091019050611b19565b6000611b8560075460045461276990919063ffffffff16565b421115611be0578115611bc057611bb9612710610f2c611bb260095461271061276990919063ffffffff16565b869061235d565b9050611ceb565b611bb9612710610f2c611bb26009546127106127c190919063ffffffff16565b600654600454611bef91612769565b421115611c3c578115611c1c57611bb9612710610f2c611bb260085461271061276990919063ffffffff16565b611bb9612710610f2c611bb26008546127106127c190919063ffffffff16565b6001600160a01b03841660009081526011602052604090205480611c635783915050611ceb565b6000818511611c7b57611c7682866127c1565b611c85565b611c8585836127c1565b9050611c9785610f2c8361271061235d565b90506000611ca487611647565b1580611cb15750600d5482115b90508015611ce5578415611cd857828611611ccc5782611cce565b855b9350505050611ceb565b828610611ccc5782611cce565b50909150505b9392505050565b6003546001600160a01b03163314611d3f576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600d55565b6000546001600160a01b03163314611d91576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600755565b68327cb2734119d3b7a9601e1b81565b6298968081565b60136020526000908152604090205481565b60095481565b600f5481565b600a5481565b6000546001600160a01b03163314611e1e576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600855565b6000546001600160a01b03163314611e70576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b8051825114611ec6576040805162461bcd60e51b815260206004820152601e60248201527f466173745072696365466565643a20696e76616c6964206c656e677468730000604482015290519081900360640190fd5b8151611ed9906016906020850190612b3a565b508051610f60906017906020840190612b9f565b3360009081526014602052604090205460ff16611f3f576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b3360009081526015602052604090205460ff1615611fa3576040805162461bcd60e51b815260206004820152601c60248201527b11985cdd141c9a58d9519959590e88185b1c9958591e481d9bdd195960221b604482015290519081900360640190fd5b336000908152601560205260409020805460ff19166001908117909155600f54611fcc91612769565b600f556040805133815290517f4c0c5fabf50e808e3bc8d19577d305e3a7163eea7e8a74a50caa8896694cd44b9181900360200190a1565b6012602052600090815260409020546001600160a01b0381169063ffffffff600160a01b8204811691600160c01b8104821691600160e01b9091041684565b6000546001600160a01b03163314612090576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b60008054911515600160a81b0260ff60a81b19909216919091179055565b6000546001600160a01b031633146120fb576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60116020526000908152604090205481565b6000546001600160a01b0316331461217c576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600a55565b6003546001600160a01b031633146121ce576040805162461bcd60e51b81526020600482015260186024820152600080516020612c8a833981519152604482015290519081900360640190fd5b600e55565b6000546001600160a01b03163314612220576040805162461bcd60e51b81526020600482015260156024820152600080516020612c6a833981519152604482015290519081900360640190fd5b600955565b600c5481565b60075481565b6001600160a01b0381565b6001546001600160a01b031681565b60055481565b600a54600090156122aa57600a5460055461226d9043906127c1565b10156122aa5760405162461bcd60e51b815260040180806020018281038252602e815260200180612d27602e913960400191505060405180910390fd5b600b546122b742826127c1565b83116122f45760405162461bcd60e51b815260040180806020018281038252602d815260200180612cfa602d913960400191505060405180910390fd5b6122fe4282612769565b831061233b5760405162461bcd60e51b815260040180806020018281038252602f815260200180612caa602f913960400191505060405180910390fd5b60045483101561234f5760009150506116cd565b505060045543600555600190565b60008261236c575060006123b9565b8282028284828161237957fe5b04146123b65760405162461bcd60e51b8152600401808060200182810382526021815260200180612cd96021913960400191505060405180910390fd5b90505b92915050565b60006123b683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250612803565b6001600160a01b0382161561266d576000826001600160a01b03166356bf9de4866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561245c57600080fd5b505afa158015612470573d6000803e3d6000fd5b505050506040513d602081101561248657600080fd5b50516001600160a01b0386166000908152601160205260408120549192508080806124b08a6117eb565b935093509350935060008411156125775760008487116124d9576124d485886127c1565b6124e3565b6124e387866127c1565b905060008a87116124fd576124f88b886127c1565b612507565b612507878c6127c1565b905061251e600c54426123bf90919063ffffffff16565b600c5461252c9087906123bf565b1461253a5760009350600092505b61255561254e87610f2c856298968061235d565b8590612769565b935061257261256b88610f2c846298968061235d565b8490612769565b925050505b81811180156125a657506001600160a01b038a166000908152601360205260409020546125a482846127c1565b115b1561260357604080516001600160a01b038c16815260208101889052808201879052606081018490526080810183905290517fe582322b389ad06b2bbf619cd6da3f16a288ec873ea0fa6df4d72f3d9480b4479181900360a00190a15b61260f8a8784846128a5565b604080516001600160a01b038c16815260208101889052808201879052606081018490526080810183905290517f23b9387f81fca646aac1dc4487ede045c65f5f7445482906565f01e05afdb3a89181900360a00190a15050505050505b6001600160a01b0384166000908152601160205260409020839055611989818585612a3b565b600061269e82612251565b90508015610f60576002546001546001600160a01b03918216911660005b6008811015610f5c57601654819081106126da575050505050610f62565b60168054602084029189831c63ffffffff169160009190869081106126fb57fe5b6000918252602082200154601780546001600160a01b039092169350908790811061272257fe5b6000918252602082200154915061274982610f2c8668327cb2734119d3b7a9601e1b61235d565b905061275783828a8c6123fe565b5050600190940193506126bc92505050565b6000828201838110156123b6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60006123b683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612ab9565b6000818361288f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561285457818101518382015260200161283c565b50505050905090810190601f1680156128815780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161289b57fe5b0495945050505050565b6001600160a01b038310612900576040805162461bcd60e51b815260206004820152601f60248201527f466173745072696365466565643a20696e76616c696420726566507269636500604482015290519081900360640190fd5b63ffffffff82106129425760405162461bcd60e51b8152600401808060200182810382526029815260200180612d556029913960400191505060405180910390fd5b63ffffffff81106129845760405162461bcd60e51b815260040180806020018281038252602a815260200180612c40602a913960400191505060405180910390fd5b604080516080810182526001600160a01b03948516815263ffffffff4281166020808401918252958216838501908152948216606084019081529787166000908152601290965292909420905181549251935196518516600160e01b026001600160e01b03978616600160c01b0263ffffffff60c01b1995909616600160a01b0263ffffffff60a01b19929097166001600160a01b0319909416939093171694909417919091169190911792909216919091179055565b6001600160a01b038316612a4e57610f60565b826001600160a01b031663e0409c7183836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015612aa557600080fd5b505af1158015611985573d6000803e3d6000fd5b60008184841115612b0b5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561285457818101518382015260200161283c565b505050900390565b60408051608081018252600080825260208201819052918101829052606081019190915290565b828054828255906000526020600020908101928215612b8f579160200282015b82811115612b8f57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612b5a565b50612b9b929150612be6565b5090565b828054828255906000526020600020908101928215612bda579160200282015b82811115612bda578251825591602001919060010190612bbf565b50612b9b929150612c05565b5b80821115612b9b5780546001600160a01b0319168155600101612be7565b5b80821115612b9b5760008155600101612c0656fe466173745072696365466565643a20696e76616c6964205f70726963654475726174696f6e466173745072696365466565643a20696e76616c69642063756d756c61746976654661737444656c7461476f7665726e61626c653a20666f7262696464656e0000000000000000000000466173745072696365466565643a20666f7262696464656e0000000000000000466173745072696365466565643a205f74696d657374616d70206578636565647320616c6c6f7765642072616e6765536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77466173745072696365466565643a205f74696d657374616d702062656c6f7720616c6c6f7765642072616e6765466173745072696365466565643a206d696e426c6f636b496e74657276616c206e6f742079657420706173736564466173745072696365466565643a20696e76616c69642063756d756c617469766552656644656c7461466173745072696365466565643a20616c726561647920696e697469616c697a6564a264697066735822122022799291e1b6a46586afa22726fbcd83d4f577c3ed514e7cbcd27223f3f95ddc64736f6c634300060c0033", 1138 | "linkReferences": {}, 1139 | "deployedLinkReferences": {} 1140 | } 1141 | -------------------------------------------------------------------------------- /abi/PriceFeedExt.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "PriceFeedExt", 4 | "sourceName": "contracts/core/PriceFeedExt.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "string", 10 | "name": "_description", 11 | "type": "string" 12 | }, 13 | { 14 | "internalType": "uint8", 15 | "name": "_decimals", 16 | "type": "uint8" 17 | } 18 | ], 19 | "stateMutability": "nonpayable", 20 | "type": "constructor" 21 | }, 22 | { 23 | "inputs": [], 24 | "name": "aggregator", 25 | "outputs": [ 26 | { 27 | "internalType": "address", 28 | "name": "", 29 | "type": "address" 30 | } 31 | ], 32 | "stateMutability": "view", 33 | "type": "function" 34 | }, 35 | { 36 | "inputs": [], 37 | "name": "decimals", 38 | "outputs": [ 39 | { 40 | "internalType": "uint8", 41 | "name": "", 42 | "type": "uint8" 43 | } 44 | ], 45 | "stateMutability": "view", 46 | "type": "function" 47 | }, 48 | { 49 | "inputs": [], 50 | "name": "description", 51 | "outputs": [ 52 | { 53 | "internalType": "string", 54 | "name": "", 55 | "type": "string" 56 | } 57 | ], 58 | "stateMutability": "view", 59 | "type": "function" 60 | }, 61 | { 62 | "inputs": [ 63 | { 64 | "internalType": "uint80", 65 | "name": "_roundId", 66 | "type": "uint80" 67 | } 68 | ], 69 | "name": "getRoundData", 70 | "outputs": [ 71 | { 72 | "internalType": "uint80", 73 | "name": "", 74 | "type": "uint80" 75 | }, 76 | { 77 | "internalType": "int256", 78 | "name": "", 79 | "type": "int256" 80 | }, 81 | { 82 | "internalType": "uint256", 83 | "name": "", 84 | "type": "uint256" 85 | }, 86 | { 87 | "internalType": "uint256", 88 | "name": "", 89 | "type": "uint256" 90 | }, 91 | { 92 | "internalType": "uint80", 93 | "name": "", 94 | "type": "uint80" 95 | } 96 | ], 97 | "stateMutability": "view", 98 | "type": "function" 99 | }, 100 | { 101 | "inputs": [], 102 | "name": "gov", 103 | "outputs": [ 104 | { 105 | "internalType": "address", 106 | "name": "", 107 | "type": "address" 108 | } 109 | ], 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "inputs": [ 115 | { 116 | "internalType": "address", 117 | "name": "user", 118 | "type": "address" 119 | } 120 | ], 121 | "name": "isAdmin", 122 | "outputs": [ 123 | { 124 | "internalType": "bool", 125 | "name": "", 126 | "type": "bool" 127 | } 128 | ], 129 | "stateMutability": "view", 130 | "type": "function" 131 | }, 132 | { 133 | "inputs": [], 134 | "name": "latestAnswer", 135 | "outputs": [ 136 | { 137 | "internalType": "int256", 138 | "name": "", 139 | "type": "int256" 140 | } 141 | ], 142 | "stateMutability": "view", 143 | "type": "function" 144 | }, 145 | { 146 | "inputs": [], 147 | "name": "latestRound", 148 | "outputs": [ 149 | { 150 | "internalType": "uint80", 151 | "name": "", 152 | "type": "uint80" 153 | } 154 | ], 155 | "stateMutability": "view", 156 | "type": "function" 157 | }, 158 | { 159 | "inputs": [ 160 | { 161 | "internalType": "address", 162 | "name": "user", 163 | "type": "address" 164 | }, 165 | { 166 | "internalType": "bool", 167 | "name": "set", 168 | "type": "bool" 169 | } 170 | ], 171 | "name": "setAdmin", 172 | "outputs": [], 173 | "stateMutability": "nonpayable", 174 | "type": "function" 175 | }, 176 | { 177 | "inputs": [ 178 | { 179 | "internalType": "uint8", 180 | "name": "newDecimals", 181 | "type": "uint8" 182 | } 183 | ], 184 | "name": "setDecimals", 185 | "outputs": [], 186 | "stateMutability": "nonpayable", 187 | "type": "function" 188 | }, 189 | { 190 | "inputs": [ 191 | { 192 | "internalType": "string", 193 | "name": "newDescription", 194 | "type": "string" 195 | } 196 | ], 197 | "name": "setDescription", 198 | "outputs": [], 199 | "stateMutability": "nonpayable", 200 | "type": "function" 201 | }, 202 | { 203 | "inputs": [ 204 | { 205 | "internalType": "address", 206 | "name": "newGov", 207 | "type": "address" 208 | } 209 | ], 210 | "name": "setGov", 211 | "outputs": [], 212 | "stateMutability": "nonpayable", 213 | "type": "function" 214 | }, 215 | { 216 | "inputs": [ 217 | { 218 | "internalType": "int256", 219 | "name": "_answer", 220 | "type": "int256" 221 | } 222 | ], 223 | "name": "transmit", 224 | "outputs": [], 225 | "stateMutability": "nonpayable", 226 | "type": "function" 227 | } 228 | ] 229 | } 230 | -------------------------------------------------------------------------------- /abi/Vault.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Vault", 4 | "sourceName": "contracts/core/Vault.sol", 5 | "abi": [ 6 | { 7 | "inputs": [], 8 | "stateMutability": "nonpayable", 9 | "type": "constructor" 10 | }, 11 | { 12 | "anonymous": false, 13 | "inputs": [ 14 | { 15 | "indexed": false, 16 | "internalType": "address", 17 | "name": "account", 18 | "type": "address" 19 | }, 20 | { 21 | "indexed": false, 22 | "internalType": "address", 23 | "name": "token", 24 | "type": "address" 25 | }, 26 | { 27 | "indexed": false, 28 | "internalType": "uint256", 29 | "name": "tokenAmount", 30 | "type": "uint256" 31 | }, 32 | { 33 | "indexed": false, 34 | "internalType": "uint256", 35 | "name": "usdgAmount", 36 | "type": "uint256" 37 | }, 38 | { 39 | "indexed": false, 40 | "internalType": "uint256", 41 | "name": "feeBasisPoints", 42 | "type": "uint256" 43 | } 44 | ], 45 | "name": "BuyUSDG", 46 | "type": "event" 47 | }, 48 | { 49 | "anonymous": false, 50 | "inputs": [ 51 | { 52 | "indexed": false, 53 | "internalType": "bytes32", 54 | "name": "key", 55 | "type": "bytes32" 56 | }, 57 | { 58 | "indexed": false, 59 | "internalType": "uint256", 60 | "name": "size", 61 | "type": "uint256" 62 | }, 63 | { 64 | "indexed": false, 65 | "internalType": "uint256", 66 | "name": "collateral", 67 | "type": "uint256" 68 | }, 69 | { 70 | "indexed": false, 71 | "internalType": "uint256", 72 | "name": "averagePrice", 73 | "type": "uint256" 74 | }, 75 | { 76 | "indexed": false, 77 | "internalType": "uint256", 78 | "name": "entryFundingRate", 79 | "type": "uint256" 80 | }, 81 | { 82 | "indexed": false, 83 | "internalType": "uint256", 84 | "name": "reserveAmount", 85 | "type": "uint256" 86 | }, 87 | { 88 | "indexed": false, 89 | "internalType": "int256", 90 | "name": "realisedPnl", 91 | "type": "int256" 92 | } 93 | ], 94 | "name": "ClosePosition", 95 | "type": "event" 96 | }, 97 | { 98 | "anonymous": false, 99 | "inputs": [ 100 | { 101 | "indexed": false, 102 | "internalType": "address", 103 | "name": "token", 104 | "type": "address" 105 | }, 106 | { 107 | "indexed": false, 108 | "internalType": "uint256", 109 | "name": "feeUsd", 110 | "type": "uint256" 111 | }, 112 | { 113 | "indexed": false, 114 | "internalType": "uint256", 115 | "name": "feeTokens", 116 | "type": "uint256" 117 | } 118 | ], 119 | "name": "CollectMarginFees", 120 | "type": "event" 121 | }, 122 | { 123 | "anonymous": false, 124 | "inputs": [ 125 | { 126 | "indexed": false, 127 | "internalType": "address", 128 | "name": "token", 129 | "type": "address" 130 | }, 131 | { 132 | "indexed": false, 133 | "internalType": "uint256", 134 | "name": "feeUsd", 135 | "type": "uint256" 136 | }, 137 | { 138 | "indexed": false, 139 | "internalType": "uint256", 140 | "name": "feeTokens", 141 | "type": "uint256" 142 | } 143 | ], 144 | "name": "CollectSwapFees", 145 | "type": "event" 146 | }, 147 | { 148 | "anonymous": false, 149 | "inputs": [ 150 | { 151 | "indexed": false, 152 | "internalType": "address", 153 | "name": "token", 154 | "type": "address" 155 | }, 156 | { 157 | "indexed": false, 158 | "internalType": "uint256", 159 | "name": "amount", 160 | "type": "uint256" 161 | } 162 | ], 163 | "name": "DecreaseGuaranteedUsd", 164 | "type": "event" 165 | }, 166 | { 167 | "anonymous": false, 168 | "inputs": [ 169 | { 170 | "indexed": false, 171 | "internalType": "address", 172 | "name": "token", 173 | "type": "address" 174 | }, 175 | { 176 | "indexed": false, 177 | "internalType": "uint256", 178 | "name": "amount", 179 | "type": "uint256" 180 | } 181 | ], 182 | "name": "DecreasePoolAmount", 183 | "type": "event" 184 | }, 185 | { 186 | "anonymous": false, 187 | "inputs": [ 188 | { 189 | "indexed": false, 190 | "internalType": "bytes32", 191 | "name": "key", 192 | "type": "bytes32" 193 | }, 194 | { 195 | "indexed": false, 196 | "internalType": "address", 197 | "name": "account", 198 | "type": "address" 199 | }, 200 | { 201 | "indexed": false, 202 | "internalType": "address", 203 | "name": "collateralToken", 204 | "type": "address" 205 | }, 206 | { 207 | "indexed": false, 208 | "internalType": "address", 209 | "name": "indexToken", 210 | "type": "address" 211 | }, 212 | { 213 | "indexed": false, 214 | "internalType": "uint256", 215 | "name": "collateralDelta", 216 | "type": "uint256" 217 | }, 218 | { 219 | "indexed": false, 220 | "internalType": "uint256", 221 | "name": "sizeDelta", 222 | "type": "uint256" 223 | }, 224 | { 225 | "indexed": false, 226 | "internalType": "bool", 227 | "name": "isLong", 228 | "type": "bool" 229 | }, 230 | { 231 | "indexed": false, 232 | "internalType": "uint256", 233 | "name": "price", 234 | "type": "uint256" 235 | }, 236 | { 237 | "indexed": false, 238 | "internalType": "uint256", 239 | "name": "fee", 240 | "type": "uint256" 241 | } 242 | ], 243 | "name": "DecreasePosition", 244 | "type": "event" 245 | }, 246 | { 247 | "anonymous": false, 248 | "inputs": [ 249 | { 250 | "indexed": false, 251 | "internalType": "address", 252 | "name": "token", 253 | "type": "address" 254 | }, 255 | { 256 | "indexed": false, 257 | "internalType": "uint256", 258 | "name": "amount", 259 | "type": "uint256" 260 | } 261 | ], 262 | "name": "DecreaseReservedAmount", 263 | "type": "event" 264 | }, 265 | { 266 | "anonymous": false, 267 | "inputs": [ 268 | { 269 | "indexed": false, 270 | "internalType": "address", 271 | "name": "token", 272 | "type": "address" 273 | }, 274 | { 275 | "indexed": false, 276 | "internalType": "uint256", 277 | "name": "amount", 278 | "type": "uint256" 279 | } 280 | ], 281 | "name": "DecreaseUsdgAmount", 282 | "type": "event" 283 | }, 284 | { 285 | "anonymous": false, 286 | "inputs": [ 287 | { 288 | "indexed": false, 289 | "internalType": "address", 290 | "name": "token", 291 | "type": "address" 292 | }, 293 | { 294 | "indexed": false, 295 | "internalType": "uint256", 296 | "name": "amount", 297 | "type": "uint256" 298 | } 299 | ], 300 | "name": "DirectPoolDeposit", 301 | "type": "event" 302 | }, 303 | { 304 | "anonymous": false, 305 | "inputs": [ 306 | { 307 | "indexed": false, 308 | "internalType": "address", 309 | "name": "token", 310 | "type": "address" 311 | }, 312 | { 313 | "indexed": false, 314 | "internalType": "uint256", 315 | "name": "amount", 316 | "type": "uint256" 317 | } 318 | ], 319 | "name": "IncreaseGuaranteedUsd", 320 | "type": "event" 321 | }, 322 | { 323 | "anonymous": false, 324 | "inputs": [ 325 | { 326 | "indexed": false, 327 | "internalType": "address", 328 | "name": "token", 329 | "type": "address" 330 | }, 331 | { 332 | "indexed": false, 333 | "internalType": "uint256", 334 | "name": "amount", 335 | "type": "uint256" 336 | } 337 | ], 338 | "name": "IncreasePoolAmount", 339 | "type": "event" 340 | }, 341 | { 342 | "anonymous": false, 343 | "inputs": [ 344 | { 345 | "indexed": false, 346 | "internalType": "bytes32", 347 | "name": "key", 348 | "type": "bytes32" 349 | }, 350 | { 351 | "indexed": false, 352 | "internalType": "address", 353 | "name": "account", 354 | "type": "address" 355 | }, 356 | { 357 | "indexed": false, 358 | "internalType": "address", 359 | "name": "collateralToken", 360 | "type": "address" 361 | }, 362 | { 363 | "indexed": false, 364 | "internalType": "address", 365 | "name": "indexToken", 366 | "type": "address" 367 | }, 368 | { 369 | "indexed": false, 370 | "internalType": "uint256", 371 | "name": "collateralDelta", 372 | "type": "uint256" 373 | }, 374 | { 375 | "indexed": false, 376 | "internalType": "uint256", 377 | "name": "sizeDelta", 378 | "type": "uint256" 379 | }, 380 | { 381 | "indexed": false, 382 | "internalType": "bool", 383 | "name": "isLong", 384 | "type": "bool" 385 | }, 386 | { 387 | "indexed": false, 388 | "internalType": "uint256", 389 | "name": "price", 390 | "type": "uint256" 391 | }, 392 | { 393 | "indexed": false, 394 | "internalType": "uint256", 395 | "name": "fee", 396 | "type": "uint256" 397 | } 398 | ], 399 | "name": "IncreasePosition", 400 | "type": "event" 401 | }, 402 | { 403 | "anonymous": false, 404 | "inputs": [ 405 | { 406 | "indexed": false, 407 | "internalType": "address", 408 | "name": "token", 409 | "type": "address" 410 | }, 411 | { 412 | "indexed": false, 413 | "internalType": "uint256", 414 | "name": "amount", 415 | "type": "uint256" 416 | } 417 | ], 418 | "name": "IncreaseReservedAmount", 419 | "type": "event" 420 | }, 421 | { 422 | "anonymous": false, 423 | "inputs": [ 424 | { 425 | "indexed": false, 426 | "internalType": "address", 427 | "name": "token", 428 | "type": "address" 429 | }, 430 | { 431 | "indexed": false, 432 | "internalType": "uint256", 433 | "name": "amount", 434 | "type": "uint256" 435 | } 436 | ], 437 | "name": "IncreaseUsdgAmount", 438 | "type": "event" 439 | }, 440 | { 441 | "anonymous": false, 442 | "inputs": [ 443 | { 444 | "indexed": false, 445 | "internalType": "bytes32", 446 | "name": "key", 447 | "type": "bytes32" 448 | }, 449 | { 450 | "indexed": false, 451 | "internalType": "address", 452 | "name": "account", 453 | "type": "address" 454 | }, 455 | { 456 | "indexed": false, 457 | "internalType": "address", 458 | "name": "collateralToken", 459 | "type": "address" 460 | }, 461 | { 462 | "indexed": false, 463 | "internalType": "address", 464 | "name": "indexToken", 465 | "type": "address" 466 | }, 467 | { 468 | "indexed": false, 469 | "internalType": "bool", 470 | "name": "isLong", 471 | "type": "bool" 472 | }, 473 | { 474 | "indexed": false, 475 | "internalType": "uint256", 476 | "name": "size", 477 | "type": "uint256" 478 | }, 479 | { 480 | "indexed": false, 481 | "internalType": "uint256", 482 | "name": "collateral", 483 | "type": "uint256" 484 | }, 485 | { 486 | "indexed": false, 487 | "internalType": "uint256", 488 | "name": "reserveAmount", 489 | "type": "uint256" 490 | }, 491 | { 492 | "indexed": false, 493 | "internalType": "int256", 494 | "name": "realisedPnl", 495 | "type": "int256" 496 | }, 497 | { 498 | "indexed": false, 499 | "internalType": "uint256", 500 | "name": "markPrice", 501 | "type": "uint256" 502 | } 503 | ], 504 | "name": "LiquidatePosition", 505 | "type": "event" 506 | }, 507 | { 508 | "anonymous": false, 509 | "inputs": [ 510 | { 511 | "indexed": false, 512 | "internalType": "address", 513 | "name": "account", 514 | "type": "address" 515 | }, 516 | { 517 | "indexed": false, 518 | "internalType": "address", 519 | "name": "token", 520 | "type": "address" 521 | }, 522 | { 523 | "indexed": false, 524 | "internalType": "uint256", 525 | "name": "usdgAmount", 526 | "type": "uint256" 527 | }, 528 | { 529 | "indexed": false, 530 | "internalType": "uint256", 531 | "name": "tokenAmount", 532 | "type": "uint256" 533 | }, 534 | { 535 | "indexed": false, 536 | "internalType": "uint256", 537 | "name": "feeBasisPoints", 538 | "type": "uint256" 539 | } 540 | ], 541 | "name": "SellUSDG", 542 | "type": "event" 543 | }, 544 | { 545 | "anonymous": false, 546 | "inputs": [ 547 | { 548 | "indexed": false, 549 | "internalType": "address", 550 | "name": "account", 551 | "type": "address" 552 | }, 553 | { 554 | "indexed": false, 555 | "internalType": "address", 556 | "name": "tokenIn", 557 | "type": "address" 558 | }, 559 | { 560 | "indexed": false, 561 | "internalType": "address", 562 | "name": "tokenOut", 563 | "type": "address" 564 | }, 565 | { 566 | "indexed": false, 567 | "internalType": "uint256", 568 | "name": "amountIn", 569 | "type": "uint256" 570 | }, 571 | { 572 | "indexed": false, 573 | "internalType": "uint256", 574 | "name": "amountOut", 575 | "type": "uint256" 576 | }, 577 | { 578 | "indexed": false, 579 | "internalType": "uint256", 580 | "name": "amountOutAfterFees", 581 | "type": "uint256" 582 | }, 583 | { 584 | "indexed": false, 585 | "internalType": "uint256", 586 | "name": "feeBasisPoints", 587 | "type": "uint256" 588 | } 589 | ], 590 | "name": "Swap", 591 | "type": "event" 592 | }, 593 | { 594 | "anonymous": false, 595 | "inputs": [ 596 | { 597 | "indexed": false, 598 | "internalType": "address", 599 | "name": "token", 600 | "type": "address" 601 | }, 602 | { 603 | "indexed": false, 604 | "internalType": "uint256", 605 | "name": "fundingRate", 606 | "type": "uint256" 607 | } 608 | ], 609 | "name": "UpdateFundingRate", 610 | "type": "event" 611 | }, 612 | { 613 | "anonymous": false, 614 | "inputs": [ 615 | { 616 | "indexed": false, 617 | "internalType": "bytes32", 618 | "name": "key", 619 | "type": "bytes32" 620 | }, 621 | { 622 | "indexed": false, 623 | "internalType": "bool", 624 | "name": "hasProfit", 625 | "type": "bool" 626 | }, 627 | { 628 | "indexed": false, 629 | "internalType": "uint256", 630 | "name": "delta", 631 | "type": "uint256" 632 | } 633 | ], 634 | "name": "UpdatePnl", 635 | "type": "event" 636 | }, 637 | { 638 | "anonymous": false, 639 | "inputs": [ 640 | { 641 | "indexed": false, 642 | "internalType": "bytes32", 643 | "name": "key", 644 | "type": "bytes32" 645 | }, 646 | { 647 | "indexed": false, 648 | "internalType": "uint256", 649 | "name": "size", 650 | "type": "uint256" 651 | }, 652 | { 653 | "indexed": false, 654 | "internalType": "uint256", 655 | "name": "collateral", 656 | "type": "uint256" 657 | }, 658 | { 659 | "indexed": false, 660 | "internalType": "uint256", 661 | "name": "averagePrice", 662 | "type": "uint256" 663 | }, 664 | { 665 | "indexed": false, 666 | "internalType": "uint256", 667 | "name": "entryFundingRate", 668 | "type": "uint256" 669 | }, 670 | { 671 | "indexed": false, 672 | "internalType": "uint256", 673 | "name": "reserveAmount", 674 | "type": "uint256" 675 | }, 676 | { 677 | "indexed": false, 678 | "internalType": "int256", 679 | "name": "realisedPnl", 680 | "type": "int256" 681 | }, 682 | { 683 | "indexed": false, 684 | "internalType": "uint256", 685 | "name": "markPrice", 686 | "type": "uint256" 687 | } 688 | ], 689 | "name": "UpdatePosition", 690 | "type": "event" 691 | }, 692 | { 693 | "inputs": [], 694 | "name": "BASIS_POINTS_DIVISOR", 695 | "outputs": [ 696 | { 697 | "internalType": "uint256", 698 | "name": "", 699 | "type": "uint256" 700 | } 701 | ], 702 | "stateMutability": "view", 703 | "type": "function" 704 | }, 705 | { 706 | "inputs": [], 707 | "name": "FUNDING_RATE_PRECISION", 708 | "outputs": [ 709 | { 710 | "internalType": "uint256", 711 | "name": "", 712 | "type": "uint256" 713 | } 714 | ], 715 | "stateMutability": "view", 716 | "type": "function" 717 | }, 718 | { 719 | "inputs": [], 720 | "name": "MAX_FEE_BASIS_POINTS", 721 | "outputs": [ 722 | { 723 | "internalType": "uint256", 724 | "name": "", 725 | "type": "uint256" 726 | } 727 | ], 728 | "stateMutability": "view", 729 | "type": "function" 730 | }, 731 | { 732 | "inputs": [], 733 | "name": "MAX_FUNDING_RATE_FACTOR", 734 | "outputs": [ 735 | { 736 | "internalType": "uint256", 737 | "name": "", 738 | "type": "uint256" 739 | } 740 | ], 741 | "stateMutability": "view", 742 | "type": "function" 743 | }, 744 | { 745 | "inputs": [], 746 | "name": "MAX_LIQUIDATION_FEE_USD", 747 | "outputs": [ 748 | { 749 | "internalType": "uint256", 750 | "name": "", 751 | "type": "uint256" 752 | } 753 | ], 754 | "stateMutability": "view", 755 | "type": "function" 756 | }, 757 | { 758 | "inputs": [], 759 | "name": "MIN_FUNDING_RATE_INTERVAL", 760 | "outputs": [ 761 | { 762 | "internalType": "uint256", 763 | "name": "", 764 | "type": "uint256" 765 | } 766 | ], 767 | "stateMutability": "view", 768 | "type": "function" 769 | }, 770 | { 771 | "inputs": [], 772 | "name": "MIN_LEVERAGE", 773 | "outputs": [ 774 | { 775 | "internalType": "uint256", 776 | "name": "", 777 | "type": "uint256" 778 | } 779 | ], 780 | "stateMutability": "view", 781 | "type": "function" 782 | }, 783 | { 784 | "inputs": [], 785 | "name": "PRICE_PRECISION", 786 | "outputs": [ 787 | { 788 | "internalType": "uint256", 789 | "name": "", 790 | "type": "uint256" 791 | } 792 | ], 793 | "stateMutability": "view", 794 | "type": "function" 795 | }, 796 | { 797 | "inputs": [], 798 | "name": "USDG_DECIMALS", 799 | "outputs": [ 800 | { 801 | "internalType": "uint256", 802 | "name": "", 803 | "type": "uint256" 804 | } 805 | ], 806 | "stateMutability": "view", 807 | "type": "function" 808 | }, 809 | { 810 | "inputs": [ 811 | { 812 | "internalType": "address", 813 | "name": "_router", 814 | "type": "address" 815 | } 816 | ], 817 | "name": "addRouter", 818 | "outputs": [], 819 | "stateMutability": "nonpayable", 820 | "type": "function" 821 | }, 822 | { 823 | "inputs": [ 824 | { 825 | "internalType": "uint256", 826 | "name": "_amount", 827 | "type": "uint256" 828 | }, 829 | { 830 | "internalType": "address", 831 | "name": "_tokenDiv", 832 | "type": "address" 833 | }, 834 | { 835 | "internalType": "address", 836 | "name": "_tokenMul", 837 | "type": "address" 838 | } 839 | ], 840 | "name": "adjustForDecimals", 841 | "outputs": [ 842 | { 843 | "internalType": "uint256", 844 | "name": "", 845 | "type": "uint256" 846 | } 847 | ], 848 | "stateMutability": "view", 849 | "type": "function" 850 | }, 851 | { 852 | "inputs": [ 853 | { 854 | "internalType": "uint256", 855 | "name": "", 856 | "type": "uint256" 857 | } 858 | ], 859 | "name": "allWhitelistedTokens", 860 | "outputs": [ 861 | { 862 | "internalType": "address", 863 | "name": "", 864 | "type": "address" 865 | } 866 | ], 867 | "stateMutability": "view", 868 | "type": "function" 869 | }, 870 | { 871 | "inputs": [], 872 | "name": "allWhitelistedTokensLength", 873 | "outputs": [ 874 | { 875 | "internalType": "uint256", 876 | "name": "", 877 | "type": "uint256" 878 | } 879 | ], 880 | "stateMutability": "view", 881 | "type": "function" 882 | }, 883 | { 884 | "inputs": [ 885 | { 886 | "internalType": "address", 887 | "name": "", 888 | "type": "address" 889 | }, 890 | { 891 | "internalType": "address", 892 | "name": "", 893 | "type": "address" 894 | } 895 | ], 896 | "name": "approvedRouters", 897 | "outputs": [ 898 | { 899 | "internalType": "bool", 900 | "name": "", 901 | "type": "bool" 902 | } 903 | ], 904 | "stateMutability": "view", 905 | "type": "function" 906 | }, 907 | { 908 | "inputs": [ 909 | { 910 | "internalType": "address", 911 | "name": "", 912 | "type": "address" 913 | } 914 | ], 915 | "name": "bufferAmounts", 916 | "outputs": [ 917 | { 918 | "internalType": "uint256", 919 | "name": "", 920 | "type": "uint256" 921 | } 922 | ], 923 | "stateMutability": "view", 924 | "type": "function" 925 | }, 926 | { 927 | "inputs": [ 928 | { 929 | "internalType": "address", 930 | "name": "_token", 931 | "type": "address" 932 | }, 933 | { 934 | "internalType": "address", 935 | "name": "_receiver", 936 | "type": "address" 937 | } 938 | ], 939 | "name": "buyUSDG", 940 | "outputs": [ 941 | { 942 | "internalType": "uint256", 943 | "name": "", 944 | "type": "uint256" 945 | } 946 | ], 947 | "stateMutability": "nonpayable", 948 | "type": "function" 949 | }, 950 | { 951 | "inputs": [ 952 | { 953 | "internalType": "address", 954 | "name": "_token", 955 | "type": "address" 956 | } 957 | ], 958 | "name": "clearTokenConfig", 959 | "outputs": [], 960 | "stateMutability": "nonpayable", 961 | "type": "function" 962 | }, 963 | { 964 | "inputs": [ 965 | { 966 | "internalType": "address", 967 | "name": "", 968 | "type": "address" 969 | } 970 | ], 971 | "name": "cumulativeFundingRates", 972 | "outputs": [ 973 | { 974 | "internalType": "uint256", 975 | "name": "", 976 | "type": "uint256" 977 | } 978 | ], 979 | "stateMutability": "view", 980 | "type": "function" 981 | }, 982 | { 983 | "inputs": [ 984 | { 985 | "internalType": "address", 986 | "name": "_account", 987 | "type": "address" 988 | }, 989 | { 990 | "internalType": "address", 991 | "name": "_collateralToken", 992 | "type": "address" 993 | }, 994 | { 995 | "internalType": "address", 996 | "name": "_indexToken", 997 | "type": "address" 998 | }, 999 | { 1000 | "internalType": "uint256", 1001 | "name": "_collateralDelta", 1002 | "type": "uint256" 1003 | }, 1004 | { 1005 | "internalType": "uint256", 1006 | "name": "_sizeDelta", 1007 | "type": "uint256" 1008 | }, 1009 | { 1010 | "internalType": "bool", 1011 | "name": "_isLong", 1012 | "type": "bool" 1013 | }, 1014 | { 1015 | "internalType": "address", 1016 | "name": "_receiver", 1017 | "type": "address" 1018 | } 1019 | ], 1020 | "name": "decreasePosition", 1021 | "outputs": [ 1022 | { 1023 | "internalType": "uint256", 1024 | "name": "", 1025 | "type": "uint256" 1026 | } 1027 | ], 1028 | "stateMutability": "nonpayable", 1029 | "type": "function" 1030 | }, 1031 | { 1032 | "inputs": [ 1033 | { 1034 | "internalType": "address", 1035 | "name": "_token", 1036 | "type": "address" 1037 | } 1038 | ], 1039 | "name": "directPoolDeposit", 1040 | "outputs": [], 1041 | "stateMutability": "nonpayable", 1042 | "type": "function" 1043 | }, 1044 | { 1045 | "inputs": [], 1046 | "name": "errorController", 1047 | "outputs": [ 1048 | { 1049 | "internalType": "address", 1050 | "name": "", 1051 | "type": "address" 1052 | } 1053 | ], 1054 | "stateMutability": "view", 1055 | "type": "function" 1056 | }, 1057 | { 1058 | "inputs": [ 1059 | { 1060 | "internalType": "uint256", 1061 | "name": "", 1062 | "type": "uint256" 1063 | } 1064 | ], 1065 | "name": "errors", 1066 | "outputs": [ 1067 | { 1068 | "internalType": "string", 1069 | "name": "", 1070 | "type": "string" 1071 | } 1072 | ], 1073 | "stateMutability": "view", 1074 | "type": "function" 1075 | }, 1076 | { 1077 | "inputs": [ 1078 | { 1079 | "internalType": "address", 1080 | "name": "", 1081 | "type": "address" 1082 | } 1083 | ], 1084 | "name": "feeReserves", 1085 | "outputs": [ 1086 | { 1087 | "internalType": "uint256", 1088 | "name": "", 1089 | "type": "uint256" 1090 | } 1091 | ], 1092 | "stateMutability": "view", 1093 | "type": "function" 1094 | }, 1095 | { 1096 | "inputs": [], 1097 | "name": "fundingInterval", 1098 | "outputs": [ 1099 | { 1100 | "internalType": "uint256", 1101 | "name": "", 1102 | "type": "uint256" 1103 | } 1104 | ], 1105 | "stateMutability": "view", 1106 | "type": "function" 1107 | }, 1108 | { 1109 | "inputs": [], 1110 | "name": "fundingRateFactor", 1111 | "outputs": [ 1112 | { 1113 | "internalType": "uint256", 1114 | "name": "", 1115 | "type": "uint256" 1116 | } 1117 | ], 1118 | "stateMutability": "view", 1119 | "type": "function" 1120 | }, 1121 | { 1122 | "inputs": [ 1123 | { 1124 | "internalType": "address", 1125 | "name": "_indexToken", 1126 | "type": "address" 1127 | }, 1128 | { 1129 | "internalType": "uint256", 1130 | "name": "_size", 1131 | "type": "uint256" 1132 | }, 1133 | { 1134 | "internalType": "uint256", 1135 | "name": "_averagePrice", 1136 | "type": "uint256" 1137 | }, 1138 | { 1139 | "internalType": "bool", 1140 | "name": "_isLong", 1141 | "type": "bool" 1142 | }, 1143 | { 1144 | "internalType": "uint256", 1145 | "name": "_lastIncreasedTime", 1146 | "type": "uint256" 1147 | } 1148 | ], 1149 | "name": "getDelta", 1150 | "outputs": [ 1151 | { 1152 | "internalType": "bool", 1153 | "name": "", 1154 | "type": "bool" 1155 | }, 1156 | { 1157 | "internalType": "uint256", 1158 | "name": "", 1159 | "type": "uint256" 1160 | } 1161 | ], 1162 | "stateMutability": "view", 1163 | "type": "function" 1164 | }, 1165 | { 1166 | "inputs": [ 1167 | { 1168 | "internalType": "address", 1169 | "name": "_collateralToken", 1170 | "type": "address" 1171 | }, 1172 | { 1173 | "internalType": "address", 1174 | "name": "_indexToken", 1175 | "type": "address" 1176 | }, 1177 | { 1178 | "internalType": "bool", 1179 | "name": "_isLong", 1180 | "type": "bool" 1181 | } 1182 | ], 1183 | "name": "getEntryFundingRate", 1184 | "outputs": [ 1185 | { 1186 | "internalType": "uint256", 1187 | "name": "", 1188 | "type": "uint256" 1189 | } 1190 | ], 1191 | "stateMutability": "view", 1192 | "type": "function" 1193 | }, 1194 | { 1195 | "inputs": [ 1196 | { 1197 | "internalType": "address", 1198 | "name": "_token", 1199 | "type": "address" 1200 | }, 1201 | { 1202 | "internalType": "uint256", 1203 | "name": "_usdgDelta", 1204 | "type": "uint256" 1205 | }, 1206 | { 1207 | "internalType": "uint256", 1208 | "name": "_feeBasisPoints", 1209 | "type": "uint256" 1210 | }, 1211 | { 1212 | "internalType": "uint256", 1213 | "name": "_taxBasisPoints", 1214 | "type": "uint256" 1215 | }, 1216 | { 1217 | "internalType": "bool", 1218 | "name": "_increment", 1219 | "type": "bool" 1220 | } 1221 | ], 1222 | "name": "getFeeBasisPoints", 1223 | "outputs": [ 1224 | { 1225 | "internalType": "uint256", 1226 | "name": "", 1227 | "type": "uint256" 1228 | } 1229 | ], 1230 | "stateMutability": "view", 1231 | "type": "function" 1232 | }, 1233 | { 1234 | "inputs": [ 1235 | { 1236 | "internalType": "address", 1237 | "name": "_account", 1238 | "type": "address" 1239 | }, 1240 | { 1241 | "internalType": "address", 1242 | "name": "_collateralToken", 1243 | "type": "address" 1244 | }, 1245 | { 1246 | "internalType": "address", 1247 | "name": "_indexToken", 1248 | "type": "address" 1249 | }, 1250 | { 1251 | "internalType": "bool", 1252 | "name": "_isLong", 1253 | "type": "bool" 1254 | }, 1255 | { 1256 | "internalType": "uint256", 1257 | "name": "_size", 1258 | "type": "uint256" 1259 | }, 1260 | { 1261 | "internalType": "uint256", 1262 | "name": "_entryFundingRate", 1263 | "type": "uint256" 1264 | } 1265 | ], 1266 | "name": "getFundingFee", 1267 | "outputs": [ 1268 | { 1269 | "internalType": "uint256", 1270 | "name": "", 1271 | "type": "uint256" 1272 | } 1273 | ], 1274 | "stateMutability": "view", 1275 | "type": "function" 1276 | }, 1277 | { 1278 | "inputs": [ 1279 | { 1280 | "internalType": "address", 1281 | "name": "_token", 1282 | "type": "address" 1283 | } 1284 | ], 1285 | "name": "getGlobalShortDelta", 1286 | "outputs": [ 1287 | { 1288 | "internalType": "bool", 1289 | "name": "", 1290 | "type": "bool" 1291 | }, 1292 | { 1293 | "internalType": "uint256", 1294 | "name": "", 1295 | "type": "uint256" 1296 | } 1297 | ], 1298 | "stateMutability": "view", 1299 | "type": "function" 1300 | }, 1301 | { 1302 | "inputs": [ 1303 | { 1304 | "internalType": "address", 1305 | "name": "_token", 1306 | "type": "address" 1307 | } 1308 | ], 1309 | "name": "getMaxPrice", 1310 | "outputs": [ 1311 | { 1312 | "internalType": "uint256", 1313 | "name": "", 1314 | "type": "uint256" 1315 | } 1316 | ], 1317 | "stateMutability": "view", 1318 | "type": "function" 1319 | }, 1320 | { 1321 | "inputs": [ 1322 | { 1323 | "internalType": "address", 1324 | "name": "_token", 1325 | "type": "address" 1326 | } 1327 | ], 1328 | "name": "getMinPrice", 1329 | "outputs": [ 1330 | { 1331 | "internalType": "uint256", 1332 | "name": "", 1333 | "type": "uint256" 1334 | } 1335 | ], 1336 | "stateMutability": "view", 1337 | "type": "function" 1338 | }, 1339 | { 1340 | "inputs": [ 1341 | { 1342 | "internalType": "address", 1343 | "name": "_indexToken", 1344 | "type": "address" 1345 | }, 1346 | { 1347 | "internalType": "uint256", 1348 | "name": "_size", 1349 | "type": "uint256" 1350 | }, 1351 | { 1352 | "internalType": "uint256", 1353 | "name": "_averagePrice", 1354 | "type": "uint256" 1355 | }, 1356 | { 1357 | "internalType": "bool", 1358 | "name": "_isLong", 1359 | "type": "bool" 1360 | }, 1361 | { 1362 | "internalType": "uint256", 1363 | "name": "_nextPrice", 1364 | "type": "uint256" 1365 | }, 1366 | { 1367 | "internalType": "uint256", 1368 | "name": "_sizeDelta", 1369 | "type": "uint256" 1370 | }, 1371 | { 1372 | "internalType": "uint256", 1373 | "name": "_lastIncreasedTime", 1374 | "type": "uint256" 1375 | } 1376 | ], 1377 | "name": "getNextAveragePrice", 1378 | "outputs": [ 1379 | { 1380 | "internalType": "uint256", 1381 | "name": "", 1382 | "type": "uint256" 1383 | } 1384 | ], 1385 | "stateMutability": "view", 1386 | "type": "function" 1387 | }, 1388 | { 1389 | "inputs": [ 1390 | { 1391 | "internalType": "address", 1392 | "name": "_token", 1393 | "type": "address" 1394 | } 1395 | ], 1396 | "name": "getNextFundingRate", 1397 | "outputs": [ 1398 | { 1399 | "internalType": "uint256", 1400 | "name": "", 1401 | "type": "uint256" 1402 | } 1403 | ], 1404 | "stateMutability": "view", 1405 | "type": "function" 1406 | }, 1407 | { 1408 | "inputs": [ 1409 | { 1410 | "internalType": "address", 1411 | "name": "_indexToken", 1412 | "type": "address" 1413 | }, 1414 | { 1415 | "internalType": "uint256", 1416 | "name": "_nextPrice", 1417 | "type": "uint256" 1418 | }, 1419 | { 1420 | "internalType": "uint256", 1421 | "name": "_sizeDelta", 1422 | "type": "uint256" 1423 | } 1424 | ], 1425 | "name": "getNextGlobalShortAveragePrice", 1426 | "outputs": [ 1427 | { 1428 | "internalType": "uint256", 1429 | "name": "", 1430 | "type": "uint256" 1431 | } 1432 | ], 1433 | "stateMutability": "view", 1434 | "type": "function" 1435 | }, 1436 | { 1437 | "inputs": [ 1438 | { 1439 | "internalType": "address", 1440 | "name": "_account", 1441 | "type": "address" 1442 | }, 1443 | { 1444 | "internalType": "address", 1445 | "name": "_collateralToken", 1446 | "type": "address" 1447 | }, 1448 | { 1449 | "internalType": "address", 1450 | "name": "_indexToken", 1451 | "type": "address" 1452 | }, 1453 | { 1454 | "internalType": "bool", 1455 | "name": "_isLong", 1456 | "type": "bool" 1457 | } 1458 | ], 1459 | "name": "getPosition", 1460 | "outputs": [ 1461 | { 1462 | "internalType": "uint256", 1463 | "name": "", 1464 | "type": "uint256" 1465 | }, 1466 | { 1467 | "internalType": "uint256", 1468 | "name": "", 1469 | "type": "uint256" 1470 | }, 1471 | { 1472 | "internalType": "uint256", 1473 | "name": "", 1474 | "type": "uint256" 1475 | }, 1476 | { 1477 | "internalType": "uint256", 1478 | "name": "", 1479 | "type": "uint256" 1480 | }, 1481 | { 1482 | "internalType": "uint256", 1483 | "name": "", 1484 | "type": "uint256" 1485 | }, 1486 | { 1487 | "internalType": "uint256", 1488 | "name": "", 1489 | "type": "uint256" 1490 | }, 1491 | { 1492 | "internalType": "bool", 1493 | "name": "", 1494 | "type": "bool" 1495 | }, 1496 | { 1497 | "internalType": "uint256", 1498 | "name": "", 1499 | "type": "uint256" 1500 | } 1501 | ], 1502 | "stateMutability": "view", 1503 | "type": "function" 1504 | }, 1505 | { 1506 | "inputs": [ 1507 | { 1508 | "internalType": "address", 1509 | "name": "_account", 1510 | "type": "address" 1511 | }, 1512 | { 1513 | "internalType": "address", 1514 | "name": "_collateralToken", 1515 | "type": "address" 1516 | }, 1517 | { 1518 | "internalType": "address", 1519 | "name": "_indexToken", 1520 | "type": "address" 1521 | }, 1522 | { 1523 | "internalType": "bool", 1524 | "name": "_isLong", 1525 | "type": "bool" 1526 | } 1527 | ], 1528 | "name": "getPositionDelta", 1529 | "outputs": [ 1530 | { 1531 | "internalType": "bool", 1532 | "name": "", 1533 | "type": "bool" 1534 | }, 1535 | { 1536 | "internalType": "uint256", 1537 | "name": "", 1538 | "type": "uint256" 1539 | } 1540 | ], 1541 | "stateMutability": "view", 1542 | "type": "function" 1543 | }, 1544 | { 1545 | "inputs": [ 1546 | { 1547 | "internalType": "address", 1548 | "name": "_account", 1549 | "type": "address" 1550 | }, 1551 | { 1552 | "internalType": "address", 1553 | "name": "_collateralToken", 1554 | "type": "address" 1555 | }, 1556 | { 1557 | "internalType": "address", 1558 | "name": "_indexToken", 1559 | "type": "address" 1560 | }, 1561 | { 1562 | "internalType": "bool", 1563 | "name": "_isLong", 1564 | "type": "bool" 1565 | }, 1566 | { 1567 | "internalType": "uint256", 1568 | "name": "_sizeDelta", 1569 | "type": "uint256" 1570 | } 1571 | ], 1572 | "name": "getPositionFee", 1573 | "outputs": [ 1574 | { 1575 | "internalType": "uint256", 1576 | "name": "", 1577 | "type": "uint256" 1578 | } 1579 | ], 1580 | "stateMutability": "view", 1581 | "type": "function" 1582 | }, 1583 | { 1584 | "inputs": [ 1585 | { 1586 | "internalType": "address", 1587 | "name": "_account", 1588 | "type": "address" 1589 | }, 1590 | { 1591 | "internalType": "address", 1592 | "name": "_collateralToken", 1593 | "type": "address" 1594 | }, 1595 | { 1596 | "internalType": "address", 1597 | "name": "_indexToken", 1598 | "type": "address" 1599 | }, 1600 | { 1601 | "internalType": "bool", 1602 | "name": "_isLong", 1603 | "type": "bool" 1604 | } 1605 | ], 1606 | "name": "getPositionKey", 1607 | "outputs": [ 1608 | { 1609 | "internalType": "bytes32", 1610 | "name": "", 1611 | "type": "bytes32" 1612 | } 1613 | ], 1614 | "stateMutability": "pure", 1615 | "type": "function" 1616 | }, 1617 | { 1618 | "inputs": [ 1619 | { 1620 | "internalType": "address", 1621 | "name": "_account", 1622 | "type": "address" 1623 | }, 1624 | { 1625 | "internalType": "address", 1626 | "name": "_collateralToken", 1627 | "type": "address" 1628 | }, 1629 | { 1630 | "internalType": "address", 1631 | "name": "_indexToken", 1632 | "type": "address" 1633 | }, 1634 | { 1635 | "internalType": "bool", 1636 | "name": "_isLong", 1637 | "type": "bool" 1638 | } 1639 | ], 1640 | "name": "getPositionLeverage", 1641 | "outputs": [ 1642 | { 1643 | "internalType": "uint256", 1644 | "name": "", 1645 | "type": "uint256" 1646 | } 1647 | ], 1648 | "stateMutability": "view", 1649 | "type": "function" 1650 | }, 1651 | { 1652 | "inputs": [ 1653 | { 1654 | "internalType": "address", 1655 | "name": "_token", 1656 | "type": "address" 1657 | }, 1658 | { 1659 | "internalType": "uint256", 1660 | "name": "_usdgAmount", 1661 | "type": "uint256" 1662 | } 1663 | ], 1664 | "name": "getRedemptionAmount", 1665 | "outputs": [ 1666 | { 1667 | "internalType": "uint256", 1668 | "name": "", 1669 | "type": "uint256" 1670 | } 1671 | ], 1672 | "stateMutability": "view", 1673 | "type": "function" 1674 | }, 1675 | { 1676 | "inputs": [ 1677 | { 1678 | "internalType": "address", 1679 | "name": "_token", 1680 | "type": "address" 1681 | } 1682 | ], 1683 | "name": "getRedemptionCollateral", 1684 | "outputs": [ 1685 | { 1686 | "internalType": "uint256", 1687 | "name": "", 1688 | "type": "uint256" 1689 | } 1690 | ], 1691 | "stateMutability": "view", 1692 | "type": "function" 1693 | }, 1694 | { 1695 | "inputs": [ 1696 | { 1697 | "internalType": "address", 1698 | "name": "_token", 1699 | "type": "address" 1700 | } 1701 | ], 1702 | "name": "getRedemptionCollateralUsd", 1703 | "outputs": [ 1704 | { 1705 | "internalType": "uint256", 1706 | "name": "", 1707 | "type": "uint256" 1708 | } 1709 | ], 1710 | "stateMutability": "view", 1711 | "type": "function" 1712 | }, 1713 | { 1714 | "inputs": [ 1715 | { 1716 | "internalType": "address", 1717 | "name": "_token", 1718 | "type": "address" 1719 | } 1720 | ], 1721 | "name": "getTargetUsdgAmount", 1722 | "outputs": [ 1723 | { 1724 | "internalType": "uint256", 1725 | "name": "", 1726 | "type": "uint256" 1727 | } 1728 | ], 1729 | "stateMutability": "view", 1730 | "type": "function" 1731 | }, 1732 | { 1733 | "inputs": [ 1734 | { 1735 | "internalType": "address", 1736 | "name": "_token", 1737 | "type": "address" 1738 | } 1739 | ], 1740 | "name": "getUtilisation", 1741 | "outputs": [ 1742 | { 1743 | "internalType": "uint256", 1744 | "name": "", 1745 | "type": "uint256" 1746 | } 1747 | ], 1748 | "stateMutability": "view", 1749 | "type": "function" 1750 | }, 1751 | { 1752 | "inputs": [ 1753 | { 1754 | "internalType": "address", 1755 | "name": "", 1756 | "type": "address" 1757 | } 1758 | ], 1759 | "name": "globalShortAveragePrices", 1760 | "outputs": [ 1761 | { 1762 | "internalType": "uint256", 1763 | "name": "", 1764 | "type": "uint256" 1765 | } 1766 | ], 1767 | "stateMutability": "view", 1768 | "type": "function" 1769 | }, 1770 | { 1771 | "inputs": [ 1772 | { 1773 | "internalType": "address", 1774 | "name": "", 1775 | "type": "address" 1776 | } 1777 | ], 1778 | "name": "globalShortSizes", 1779 | "outputs": [ 1780 | { 1781 | "internalType": "uint256", 1782 | "name": "", 1783 | "type": "uint256" 1784 | } 1785 | ], 1786 | "stateMutability": "view", 1787 | "type": "function" 1788 | }, 1789 | { 1790 | "inputs": [], 1791 | "name": "gov", 1792 | "outputs": [ 1793 | { 1794 | "internalType": "address", 1795 | "name": "", 1796 | "type": "address" 1797 | } 1798 | ], 1799 | "stateMutability": "view", 1800 | "type": "function" 1801 | }, 1802 | { 1803 | "inputs": [ 1804 | { 1805 | "internalType": "address", 1806 | "name": "", 1807 | "type": "address" 1808 | } 1809 | ], 1810 | "name": "guaranteedUsd", 1811 | "outputs": [ 1812 | { 1813 | "internalType": "uint256", 1814 | "name": "", 1815 | "type": "uint256" 1816 | } 1817 | ], 1818 | "stateMutability": "view", 1819 | "type": "function" 1820 | }, 1821 | { 1822 | "inputs": [], 1823 | "name": "hasDynamicFees", 1824 | "outputs": [ 1825 | { 1826 | "internalType": "bool", 1827 | "name": "", 1828 | "type": "bool" 1829 | } 1830 | ], 1831 | "stateMutability": "view", 1832 | "type": "function" 1833 | }, 1834 | { 1835 | "inputs": [], 1836 | "name": "inManagerMode", 1837 | "outputs": [ 1838 | { 1839 | "internalType": "bool", 1840 | "name": "", 1841 | "type": "bool" 1842 | } 1843 | ], 1844 | "stateMutability": "view", 1845 | "type": "function" 1846 | }, 1847 | { 1848 | "inputs": [], 1849 | "name": "inPrivateLiquidationMode", 1850 | "outputs": [ 1851 | { 1852 | "internalType": "bool", 1853 | "name": "", 1854 | "type": "bool" 1855 | } 1856 | ], 1857 | "stateMutability": "view", 1858 | "type": "function" 1859 | }, 1860 | { 1861 | "inputs": [], 1862 | "name": "includeAmmPrice", 1863 | "outputs": [ 1864 | { 1865 | "internalType": "bool", 1866 | "name": "", 1867 | "type": "bool" 1868 | } 1869 | ], 1870 | "stateMutability": "view", 1871 | "type": "function" 1872 | }, 1873 | { 1874 | "inputs": [ 1875 | { 1876 | "internalType": "address", 1877 | "name": "_account", 1878 | "type": "address" 1879 | }, 1880 | { 1881 | "internalType": "address", 1882 | "name": "_collateralToken", 1883 | "type": "address" 1884 | }, 1885 | { 1886 | "internalType": "address", 1887 | "name": "_indexToken", 1888 | "type": "address" 1889 | }, 1890 | { 1891 | "internalType": "uint256", 1892 | "name": "_sizeDelta", 1893 | "type": "uint256" 1894 | }, 1895 | { 1896 | "internalType": "bool", 1897 | "name": "_isLong", 1898 | "type": "bool" 1899 | } 1900 | ], 1901 | "name": "increasePosition", 1902 | "outputs": [], 1903 | "stateMutability": "nonpayable", 1904 | "type": "function" 1905 | }, 1906 | { 1907 | "inputs": [ 1908 | { 1909 | "internalType": "address", 1910 | "name": "_router", 1911 | "type": "address" 1912 | }, 1913 | { 1914 | "internalType": "address", 1915 | "name": "_usdg", 1916 | "type": "address" 1917 | }, 1918 | { 1919 | "internalType": "address", 1920 | "name": "_priceFeed", 1921 | "type": "address" 1922 | }, 1923 | { 1924 | "internalType": "uint256", 1925 | "name": "_liquidationFeeUsd", 1926 | "type": "uint256" 1927 | }, 1928 | { 1929 | "internalType": "uint256", 1930 | "name": "_fundingRateFactor", 1931 | "type": "uint256" 1932 | }, 1933 | { 1934 | "internalType": "uint256", 1935 | "name": "_stableFundingRateFactor", 1936 | "type": "uint256" 1937 | } 1938 | ], 1939 | "name": "initialize", 1940 | "outputs": [], 1941 | "stateMutability": "nonpayable", 1942 | "type": "function" 1943 | }, 1944 | { 1945 | "inputs": [], 1946 | "name": "isInitialized", 1947 | "outputs": [ 1948 | { 1949 | "internalType": "bool", 1950 | "name": "", 1951 | "type": "bool" 1952 | } 1953 | ], 1954 | "stateMutability": "view", 1955 | "type": "function" 1956 | }, 1957 | { 1958 | "inputs": [], 1959 | "name": "isLeverageEnabled", 1960 | "outputs": [ 1961 | { 1962 | "internalType": "bool", 1963 | "name": "", 1964 | "type": "bool" 1965 | } 1966 | ], 1967 | "stateMutability": "view", 1968 | "type": "function" 1969 | }, 1970 | { 1971 | "inputs": [ 1972 | { 1973 | "internalType": "address", 1974 | "name": "", 1975 | "type": "address" 1976 | } 1977 | ], 1978 | "name": "isLiquidator", 1979 | "outputs": [ 1980 | { 1981 | "internalType": "bool", 1982 | "name": "", 1983 | "type": "bool" 1984 | } 1985 | ], 1986 | "stateMutability": "view", 1987 | "type": "function" 1988 | }, 1989 | { 1990 | "inputs": [ 1991 | { 1992 | "internalType": "address", 1993 | "name": "", 1994 | "type": "address" 1995 | } 1996 | ], 1997 | "name": "isManager", 1998 | "outputs": [ 1999 | { 2000 | "internalType": "bool", 2001 | "name": "", 2002 | "type": "bool" 2003 | } 2004 | ], 2005 | "stateMutability": "view", 2006 | "type": "function" 2007 | }, 2008 | { 2009 | "inputs": [], 2010 | "name": "isSwapEnabled", 2011 | "outputs": [ 2012 | { 2013 | "internalType": "bool", 2014 | "name": "", 2015 | "type": "bool" 2016 | } 2017 | ], 2018 | "stateMutability": "view", 2019 | "type": "function" 2020 | }, 2021 | { 2022 | "inputs": [ 2023 | { 2024 | "internalType": "address", 2025 | "name": "", 2026 | "type": "address" 2027 | } 2028 | ], 2029 | "name": "lastFundingTimes", 2030 | "outputs": [ 2031 | { 2032 | "internalType": "uint256", 2033 | "name": "", 2034 | "type": "uint256" 2035 | } 2036 | ], 2037 | "stateMutability": "view", 2038 | "type": "function" 2039 | }, 2040 | { 2041 | "inputs": [ 2042 | { 2043 | "internalType": "address", 2044 | "name": "_account", 2045 | "type": "address" 2046 | }, 2047 | { 2048 | "internalType": "address", 2049 | "name": "_collateralToken", 2050 | "type": "address" 2051 | }, 2052 | { 2053 | "internalType": "address", 2054 | "name": "_indexToken", 2055 | "type": "address" 2056 | }, 2057 | { 2058 | "internalType": "bool", 2059 | "name": "_isLong", 2060 | "type": "bool" 2061 | }, 2062 | { 2063 | "internalType": "address", 2064 | "name": "_feeReceiver", 2065 | "type": "address" 2066 | } 2067 | ], 2068 | "name": "liquidatePosition", 2069 | "outputs": [], 2070 | "stateMutability": "nonpayable", 2071 | "type": "function" 2072 | }, 2073 | { 2074 | "inputs": [], 2075 | "name": "liquidationFeeUsd", 2076 | "outputs": [ 2077 | { 2078 | "internalType": "uint256", 2079 | "name": "", 2080 | "type": "uint256" 2081 | } 2082 | ], 2083 | "stateMutability": "view", 2084 | "type": "function" 2085 | }, 2086 | { 2087 | "inputs": [], 2088 | "name": "marginFeeBasisPoints", 2089 | "outputs": [ 2090 | { 2091 | "internalType": "uint256", 2092 | "name": "", 2093 | "type": "uint256" 2094 | } 2095 | ], 2096 | "stateMutability": "view", 2097 | "type": "function" 2098 | }, 2099 | { 2100 | "inputs": [], 2101 | "name": "maxGasPrice", 2102 | "outputs": [ 2103 | { 2104 | "internalType": "uint256", 2105 | "name": "", 2106 | "type": "uint256" 2107 | } 2108 | ], 2109 | "stateMutability": "view", 2110 | "type": "function" 2111 | }, 2112 | { 2113 | "inputs": [ 2114 | { 2115 | "internalType": "address", 2116 | "name": "", 2117 | "type": "address" 2118 | } 2119 | ], 2120 | "name": "maxGlobalShortSizes", 2121 | "outputs": [ 2122 | { 2123 | "internalType": "uint256", 2124 | "name": "", 2125 | "type": "uint256" 2126 | } 2127 | ], 2128 | "stateMutability": "view", 2129 | "type": "function" 2130 | }, 2131 | { 2132 | "inputs": [], 2133 | "name": "maxLeverage", 2134 | "outputs": [ 2135 | { 2136 | "internalType": "uint256", 2137 | "name": "", 2138 | "type": "uint256" 2139 | } 2140 | ], 2141 | "stateMutability": "view", 2142 | "type": "function" 2143 | }, 2144 | { 2145 | "inputs": [ 2146 | { 2147 | "internalType": "address", 2148 | "name": "", 2149 | "type": "address" 2150 | } 2151 | ], 2152 | "name": "maxUsdgAmounts", 2153 | "outputs": [ 2154 | { 2155 | "internalType": "uint256", 2156 | "name": "", 2157 | "type": "uint256" 2158 | } 2159 | ], 2160 | "stateMutability": "view", 2161 | "type": "function" 2162 | }, 2163 | { 2164 | "inputs": [ 2165 | { 2166 | "internalType": "address", 2167 | "name": "", 2168 | "type": "address" 2169 | } 2170 | ], 2171 | "name": "minProfitBasisPoints", 2172 | "outputs": [ 2173 | { 2174 | "internalType": "uint256", 2175 | "name": "", 2176 | "type": "uint256" 2177 | } 2178 | ], 2179 | "stateMutability": "view", 2180 | "type": "function" 2181 | }, 2182 | { 2183 | "inputs": [], 2184 | "name": "minProfitTime", 2185 | "outputs": [ 2186 | { 2187 | "internalType": "uint256", 2188 | "name": "", 2189 | "type": "uint256" 2190 | } 2191 | ], 2192 | "stateMutability": "view", 2193 | "type": "function" 2194 | }, 2195 | { 2196 | "inputs": [], 2197 | "name": "mintBurnFeeBasisPoints", 2198 | "outputs": [ 2199 | { 2200 | "internalType": "uint256", 2201 | "name": "", 2202 | "type": "uint256" 2203 | } 2204 | ], 2205 | "stateMutability": "view", 2206 | "type": "function" 2207 | }, 2208 | { 2209 | "inputs": [ 2210 | { 2211 | "internalType": "address", 2212 | "name": "", 2213 | "type": "address" 2214 | } 2215 | ], 2216 | "name": "poolAmounts", 2217 | "outputs": [ 2218 | { 2219 | "internalType": "uint256", 2220 | "name": "", 2221 | "type": "uint256" 2222 | } 2223 | ], 2224 | "stateMutability": "view", 2225 | "type": "function" 2226 | }, 2227 | { 2228 | "inputs": [ 2229 | { 2230 | "internalType": "bytes32", 2231 | "name": "", 2232 | "type": "bytes32" 2233 | } 2234 | ], 2235 | "name": "positions", 2236 | "outputs": [ 2237 | { 2238 | "internalType": "uint256", 2239 | "name": "size", 2240 | "type": "uint256" 2241 | }, 2242 | { 2243 | "internalType": "uint256", 2244 | "name": "collateral", 2245 | "type": "uint256" 2246 | }, 2247 | { 2248 | "internalType": "uint256", 2249 | "name": "averagePrice", 2250 | "type": "uint256" 2251 | }, 2252 | { 2253 | "internalType": "uint256", 2254 | "name": "entryFundingRate", 2255 | "type": "uint256" 2256 | }, 2257 | { 2258 | "internalType": "uint256", 2259 | "name": "reserveAmount", 2260 | "type": "uint256" 2261 | }, 2262 | { 2263 | "internalType": "int256", 2264 | "name": "realisedPnl", 2265 | "type": "int256" 2266 | }, 2267 | { 2268 | "internalType": "uint256", 2269 | "name": "lastIncreasedTime", 2270 | "type": "uint256" 2271 | } 2272 | ], 2273 | "stateMutability": "view", 2274 | "type": "function" 2275 | }, 2276 | { 2277 | "inputs": [], 2278 | "name": "priceFeed", 2279 | "outputs": [ 2280 | { 2281 | "internalType": "address", 2282 | "name": "", 2283 | "type": "address" 2284 | } 2285 | ], 2286 | "stateMutability": "view", 2287 | "type": "function" 2288 | }, 2289 | { 2290 | "inputs": [ 2291 | { 2292 | "internalType": "address", 2293 | "name": "_router", 2294 | "type": "address" 2295 | } 2296 | ], 2297 | "name": "removeRouter", 2298 | "outputs": [], 2299 | "stateMutability": "nonpayable", 2300 | "type": "function" 2301 | }, 2302 | { 2303 | "inputs": [ 2304 | { 2305 | "internalType": "address", 2306 | "name": "", 2307 | "type": "address" 2308 | } 2309 | ], 2310 | "name": "reservedAmounts", 2311 | "outputs": [ 2312 | { 2313 | "internalType": "uint256", 2314 | "name": "", 2315 | "type": "uint256" 2316 | } 2317 | ], 2318 | "stateMutability": "view", 2319 | "type": "function" 2320 | }, 2321 | { 2322 | "inputs": [], 2323 | "name": "router", 2324 | "outputs": [ 2325 | { 2326 | "internalType": "address", 2327 | "name": "", 2328 | "type": "address" 2329 | } 2330 | ], 2331 | "stateMutability": "view", 2332 | "type": "function" 2333 | }, 2334 | { 2335 | "inputs": [ 2336 | { 2337 | "internalType": "address", 2338 | "name": "_token", 2339 | "type": "address" 2340 | }, 2341 | { 2342 | "internalType": "address", 2343 | "name": "_receiver", 2344 | "type": "address" 2345 | } 2346 | ], 2347 | "name": "sellUSDG", 2348 | "outputs": [ 2349 | { 2350 | "internalType": "uint256", 2351 | "name": "", 2352 | "type": "uint256" 2353 | } 2354 | ], 2355 | "stateMutability": "nonpayable", 2356 | "type": "function" 2357 | }, 2358 | { 2359 | "inputs": [ 2360 | { 2361 | "internalType": "address", 2362 | "name": "_token", 2363 | "type": "address" 2364 | }, 2365 | { 2366 | "internalType": "uint256", 2367 | "name": "_amount", 2368 | "type": "uint256" 2369 | } 2370 | ], 2371 | "name": "setBufferAmount", 2372 | "outputs": [], 2373 | "stateMutability": "nonpayable", 2374 | "type": "function" 2375 | }, 2376 | { 2377 | "inputs": [ 2378 | { 2379 | "internalType": "uint256", 2380 | "name": "_errorCode", 2381 | "type": "uint256" 2382 | }, 2383 | { 2384 | "internalType": "string", 2385 | "name": "_error", 2386 | "type": "string" 2387 | } 2388 | ], 2389 | "name": "setError", 2390 | "outputs": [], 2391 | "stateMutability": "nonpayable", 2392 | "type": "function" 2393 | }, 2394 | { 2395 | "inputs": [ 2396 | { 2397 | "internalType": "address", 2398 | "name": "_errorController", 2399 | "type": "address" 2400 | } 2401 | ], 2402 | "name": "setErrorController", 2403 | "outputs": [], 2404 | "stateMutability": "nonpayable", 2405 | "type": "function" 2406 | }, 2407 | { 2408 | "inputs": [ 2409 | { 2410 | "internalType": "uint256", 2411 | "name": "_taxBasisPoints", 2412 | "type": "uint256" 2413 | }, 2414 | { 2415 | "internalType": "uint256", 2416 | "name": "_stableTaxBasisPoints", 2417 | "type": "uint256" 2418 | }, 2419 | { 2420 | "internalType": "uint256", 2421 | "name": "_mintBurnFeeBasisPoints", 2422 | "type": "uint256" 2423 | }, 2424 | { 2425 | "internalType": "uint256", 2426 | "name": "_swapFeeBasisPoints", 2427 | "type": "uint256" 2428 | }, 2429 | { 2430 | "internalType": "uint256", 2431 | "name": "_stableSwapFeeBasisPoints", 2432 | "type": "uint256" 2433 | }, 2434 | { 2435 | "internalType": "uint256", 2436 | "name": "_marginFeeBasisPoints", 2437 | "type": "uint256" 2438 | }, 2439 | { 2440 | "internalType": "uint256", 2441 | "name": "_liquidationFeeUsd", 2442 | "type": "uint256" 2443 | }, 2444 | { 2445 | "internalType": "uint256", 2446 | "name": "_minProfitTime", 2447 | "type": "uint256" 2448 | }, 2449 | { 2450 | "internalType": "bool", 2451 | "name": "_hasDynamicFees", 2452 | "type": "bool" 2453 | } 2454 | ], 2455 | "name": "setFees", 2456 | "outputs": [], 2457 | "stateMutability": "nonpayable", 2458 | "type": "function" 2459 | }, 2460 | { 2461 | "inputs": [ 2462 | { 2463 | "internalType": "uint256", 2464 | "name": "_fundingInterval", 2465 | "type": "uint256" 2466 | }, 2467 | { 2468 | "internalType": "uint256", 2469 | "name": "_fundingRateFactor", 2470 | "type": "uint256" 2471 | }, 2472 | { 2473 | "internalType": "uint256", 2474 | "name": "_stableFundingRateFactor", 2475 | "type": "uint256" 2476 | } 2477 | ], 2478 | "name": "setFundingRate", 2479 | "outputs": [], 2480 | "stateMutability": "nonpayable", 2481 | "type": "function" 2482 | }, 2483 | { 2484 | "inputs": [ 2485 | { 2486 | "internalType": "address", 2487 | "name": "_gov", 2488 | "type": "address" 2489 | } 2490 | ], 2491 | "name": "setGov", 2492 | "outputs": [], 2493 | "stateMutability": "nonpayable", 2494 | "type": "function" 2495 | }, 2496 | { 2497 | "inputs": [ 2498 | { 2499 | "internalType": "bool", 2500 | "name": "_inManagerMode", 2501 | "type": "bool" 2502 | } 2503 | ], 2504 | "name": "setInManagerMode", 2505 | "outputs": [], 2506 | "stateMutability": "nonpayable", 2507 | "type": "function" 2508 | }, 2509 | { 2510 | "inputs": [ 2511 | { 2512 | "internalType": "bool", 2513 | "name": "_inPrivateLiquidationMode", 2514 | "type": "bool" 2515 | } 2516 | ], 2517 | "name": "setInPrivateLiquidationMode", 2518 | "outputs": [], 2519 | "stateMutability": "nonpayable", 2520 | "type": "function" 2521 | }, 2522 | { 2523 | "inputs": [ 2524 | { 2525 | "internalType": "bool", 2526 | "name": "_isLeverageEnabled", 2527 | "type": "bool" 2528 | } 2529 | ], 2530 | "name": "setIsLeverageEnabled", 2531 | "outputs": [], 2532 | "stateMutability": "nonpayable", 2533 | "type": "function" 2534 | }, 2535 | { 2536 | "inputs": [ 2537 | { 2538 | "internalType": "bool", 2539 | "name": "_isSwapEnabled", 2540 | "type": "bool" 2541 | } 2542 | ], 2543 | "name": "setIsSwapEnabled", 2544 | "outputs": [], 2545 | "stateMutability": "nonpayable", 2546 | "type": "function" 2547 | }, 2548 | { 2549 | "inputs": [ 2550 | { 2551 | "internalType": "address", 2552 | "name": "_liquidator", 2553 | "type": "address" 2554 | }, 2555 | { 2556 | "internalType": "bool", 2557 | "name": "_isActive", 2558 | "type": "bool" 2559 | } 2560 | ], 2561 | "name": "setLiquidator", 2562 | "outputs": [], 2563 | "stateMutability": "nonpayable", 2564 | "type": "function" 2565 | }, 2566 | { 2567 | "inputs": [ 2568 | { 2569 | "internalType": "address", 2570 | "name": "_manager", 2571 | "type": "address" 2572 | }, 2573 | { 2574 | "internalType": "bool", 2575 | "name": "_isManager", 2576 | "type": "bool" 2577 | } 2578 | ], 2579 | "name": "setManager", 2580 | "outputs": [], 2581 | "stateMutability": "nonpayable", 2582 | "type": "function" 2583 | }, 2584 | { 2585 | "inputs": [ 2586 | { 2587 | "internalType": "uint256", 2588 | "name": "_maxGasPrice", 2589 | "type": "uint256" 2590 | } 2591 | ], 2592 | "name": "setMaxGasPrice", 2593 | "outputs": [], 2594 | "stateMutability": "nonpayable", 2595 | "type": "function" 2596 | }, 2597 | { 2598 | "inputs": [ 2599 | { 2600 | "internalType": "address", 2601 | "name": "_token", 2602 | "type": "address" 2603 | }, 2604 | { 2605 | "internalType": "uint256", 2606 | "name": "_amount", 2607 | "type": "uint256" 2608 | } 2609 | ], 2610 | "name": "setMaxGlobalShortSize", 2611 | "outputs": [], 2612 | "stateMutability": "nonpayable", 2613 | "type": "function" 2614 | }, 2615 | { 2616 | "inputs": [ 2617 | { 2618 | "internalType": "uint256", 2619 | "name": "_maxLeverage", 2620 | "type": "uint256" 2621 | } 2622 | ], 2623 | "name": "setMaxLeverage", 2624 | "outputs": [], 2625 | "stateMutability": "nonpayable", 2626 | "type": "function" 2627 | }, 2628 | { 2629 | "inputs": [ 2630 | { 2631 | "internalType": "address", 2632 | "name": "_priceFeed", 2633 | "type": "address" 2634 | } 2635 | ], 2636 | "name": "setPriceFeed", 2637 | "outputs": [], 2638 | "stateMutability": "nonpayable", 2639 | "type": "function" 2640 | }, 2641 | { 2642 | "inputs": [ 2643 | { 2644 | "internalType": "address", 2645 | "name": "_token", 2646 | "type": "address" 2647 | }, 2648 | { 2649 | "internalType": "uint256", 2650 | "name": "_tokenDecimals", 2651 | "type": "uint256" 2652 | }, 2653 | { 2654 | "internalType": "uint256", 2655 | "name": "_tokenWeight", 2656 | "type": "uint256" 2657 | }, 2658 | { 2659 | "internalType": "uint256", 2660 | "name": "_minProfitBps", 2661 | "type": "uint256" 2662 | }, 2663 | { 2664 | "internalType": "uint256", 2665 | "name": "_maxUsdgAmount", 2666 | "type": "uint256" 2667 | }, 2668 | { 2669 | "internalType": "bool", 2670 | "name": "_isStable", 2671 | "type": "bool" 2672 | }, 2673 | { 2674 | "internalType": "bool", 2675 | "name": "_isShortable", 2676 | "type": "bool" 2677 | } 2678 | ], 2679 | "name": "setTokenConfig", 2680 | "outputs": [], 2681 | "stateMutability": "nonpayable", 2682 | "type": "function" 2683 | }, 2684 | { 2685 | "inputs": [ 2686 | { 2687 | "internalType": "address", 2688 | "name": "_token", 2689 | "type": "address" 2690 | }, 2691 | { 2692 | "internalType": "uint256", 2693 | "name": "_amount", 2694 | "type": "uint256" 2695 | } 2696 | ], 2697 | "name": "setUsdgAmount", 2698 | "outputs": [], 2699 | "stateMutability": "nonpayable", 2700 | "type": "function" 2701 | }, 2702 | { 2703 | "inputs": [ 2704 | { 2705 | "internalType": "contract IVaultUtils", 2706 | "name": "_vaultUtils", 2707 | "type": "address" 2708 | } 2709 | ], 2710 | "name": "setVaultUtils", 2711 | "outputs": [], 2712 | "stateMutability": "nonpayable", 2713 | "type": "function" 2714 | }, 2715 | { 2716 | "inputs": [ 2717 | { 2718 | "internalType": "address", 2719 | "name": "", 2720 | "type": "address" 2721 | } 2722 | ], 2723 | "name": "shortableTokens", 2724 | "outputs": [ 2725 | { 2726 | "internalType": "bool", 2727 | "name": "", 2728 | "type": "bool" 2729 | } 2730 | ], 2731 | "stateMutability": "view", 2732 | "type": "function" 2733 | }, 2734 | { 2735 | "inputs": [], 2736 | "name": "stableFundingRateFactor", 2737 | "outputs": [ 2738 | { 2739 | "internalType": "uint256", 2740 | "name": "", 2741 | "type": "uint256" 2742 | } 2743 | ], 2744 | "stateMutability": "view", 2745 | "type": "function" 2746 | }, 2747 | { 2748 | "inputs": [], 2749 | "name": "stableSwapFeeBasisPoints", 2750 | "outputs": [ 2751 | { 2752 | "internalType": "uint256", 2753 | "name": "", 2754 | "type": "uint256" 2755 | } 2756 | ], 2757 | "stateMutability": "view", 2758 | "type": "function" 2759 | }, 2760 | { 2761 | "inputs": [], 2762 | "name": "stableTaxBasisPoints", 2763 | "outputs": [ 2764 | { 2765 | "internalType": "uint256", 2766 | "name": "", 2767 | "type": "uint256" 2768 | } 2769 | ], 2770 | "stateMutability": "view", 2771 | "type": "function" 2772 | }, 2773 | { 2774 | "inputs": [ 2775 | { 2776 | "internalType": "address", 2777 | "name": "", 2778 | "type": "address" 2779 | } 2780 | ], 2781 | "name": "stableTokens", 2782 | "outputs": [ 2783 | { 2784 | "internalType": "bool", 2785 | "name": "", 2786 | "type": "bool" 2787 | } 2788 | ], 2789 | "stateMutability": "view", 2790 | "type": "function" 2791 | }, 2792 | { 2793 | "inputs": [ 2794 | { 2795 | "internalType": "address", 2796 | "name": "_tokenIn", 2797 | "type": "address" 2798 | }, 2799 | { 2800 | "internalType": "address", 2801 | "name": "_tokenOut", 2802 | "type": "address" 2803 | }, 2804 | { 2805 | "internalType": "address", 2806 | "name": "_receiver", 2807 | "type": "address" 2808 | } 2809 | ], 2810 | "name": "swap", 2811 | "outputs": [ 2812 | { 2813 | "internalType": "uint256", 2814 | "name": "", 2815 | "type": "uint256" 2816 | } 2817 | ], 2818 | "stateMutability": "nonpayable", 2819 | "type": "function" 2820 | }, 2821 | { 2822 | "inputs": [], 2823 | "name": "swapFeeBasisPoints", 2824 | "outputs": [ 2825 | { 2826 | "internalType": "uint256", 2827 | "name": "", 2828 | "type": "uint256" 2829 | } 2830 | ], 2831 | "stateMutability": "view", 2832 | "type": "function" 2833 | }, 2834 | { 2835 | "inputs": [], 2836 | "name": "taxBasisPoints", 2837 | "outputs": [ 2838 | { 2839 | "internalType": "uint256", 2840 | "name": "", 2841 | "type": "uint256" 2842 | } 2843 | ], 2844 | "stateMutability": "view", 2845 | "type": "function" 2846 | }, 2847 | { 2848 | "inputs": [ 2849 | { 2850 | "internalType": "address", 2851 | "name": "", 2852 | "type": "address" 2853 | } 2854 | ], 2855 | "name": "tokenBalances", 2856 | "outputs": [ 2857 | { 2858 | "internalType": "uint256", 2859 | "name": "", 2860 | "type": "uint256" 2861 | } 2862 | ], 2863 | "stateMutability": "view", 2864 | "type": "function" 2865 | }, 2866 | { 2867 | "inputs": [ 2868 | { 2869 | "internalType": "address", 2870 | "name": "", 2871 | "type": "address" 2872 | } 2873 | ], 2874 | "name": "tokenDecimals", 2875 | "outputs": [ 2876 | { 2877 | "internalType": "uint256", 2878 | "name": "", 2879 | "type": "uint256" 2880 | } 2881 | ], 2882 | "stateMutability": "view", 2883 | "type": "function" 2884 | }, 2885 | { 2886 | "inputs": [ 2887 | { 2888 | "internalType": "address", 2889 | "name": "_token", 2890 | "type": "address" 2891 | }, 2892 | { 2893 | "internalType": "uint256", 2894 | "name": "_tokenAmount", 2895 | "type": "uint256" 2896 | } 2897 | ], 2898 | "name": "tokenToUsdMin", 2899 | "outputs": [ 2900 | { 2901 | "internalType": "uint256", 2902 | "name": "", 2903 | "type": "uint256" 2904 | } 2905 | ], 2906 | "stateMutability": "view", 2907 | "type": "function" 2908 | }, 2909 | { 2910 | "inputs": [ 2911 | { 2912 | "internalType": "address", 2913 | "name": "", 2914 | "type": "address" 2915 | } 2916 | ], 2917 | "name": "tokenWeights", 2918 | "outputs": [ 2919 | { 2920 | "internalType": "uint256", 2921 | "name": "", 2922 | "type": "uint256" 2923 | } 2924 | ], 2925 | "stateMutability": "view", 2926 | "type": "function" 2927 | }, 2928 | { 2929 | "inputs": [], 2930 | "name": "totalTokenWeights", 2931 | "outputs": [ 2932 | { 2933 | "internalType": "uint256", 2934 | "name": "", 2935 | "type": "uint256" 2936 | } 2937 | ], 2938 | "stateMutability": "view", 2939 | "type": "function" 2940 | }, 2941 | { 2942 | "inputs": [ 2943 | { 2944 | "internalType": "address", 2945 | "name": "_collateralToken", 2946 | "type": "address" 2947 | }, 2948 | { 2949 | "internalType": "address", 2950 | "name": "_indexToken", 2951 | "type": "address" 2952 | } 2953 | ], 2954 | "name": "updateCumulativeFundingRate", 2955 | "outputs": [], 2956 | "stateMutability": "nonpayable", 2957 | "type": "function" 2958 | }, 2959 | { 2960 | "inputs": [ 2961 | { 2962 | "internalType": "address", 2963 | "name": "_newVault", 2964 | "type": "address" 2965 | }, 2966 | { 2967 | "internalType": "address", 2968 | "name": "_token", 2969 | "type": "address" 2970 | }, 2971 | { 2972 | "internalType": "uint256", 2973 | "name": "_amount", 2974 | "type": "uint256" 2975 | } 2976 | ], 2977 | "name": "upgradeVault", 2978 | "outputs": [], 2979 | "stateMutability": "nonpayable", 2980 | "type": "function" 2981 | }, 2982 | { 2983 | "inputs": [ 2984 | { 2985 | "internalType": "address", 2986 | "name": "_token", 2987 | "type": "address" 2988 | }, 2989 | { 2990 | "internalType": "uint256", 2991 | "name": "_usdAmount", 2992 | "type": "uint256" 2993 | }, 2994 | { 2995 | "internalType": "uint256", 2996 | "name": "_price", 2997 | "type": "uint256" 2998 | } 2999 | ], 3000 | "name": "usdToToken", 3001 | "outputs": [ 3002 | { 3003 | "internalType": "uint256", 3004 | "name": "", 3005 | "type": "uint256" 3006 | } 3007 | ], 3008 | "stateMutability": "view", 3009 | "type": "function" 3010 | }, 3011 | { 3012 | "inputs": [ 3013 | { 3014 | "internalType": "address", 3015 | "name": "_token", 3016 | "type": "address" 3017 | }, 3018 | { 3019 | "internalType": "uint256", 3020 | "name": "_usdAmount", 3021 | "type": "uint256" 3022 | } 3023 | ], 3024 | "name": "usdToTokenMax", 3025 | "outputs": [ 3026 | { 3027 | "internalType": "uint256", 3028 | "name": "", 3029 | "type": "uint256" 3030 | } 3031 | ], 3032 | "stateMutability": "view", 3033 | "type": "function" 3034 | }, 3035 | { 3036 | "inputs": [ 3037 | { 3038 | "internalType": "address", 3039 | "name": "_token", 3040 | "type": "address" 3041 | }, 3042 | { 3043 | "internalType": "uint256", 3044 | "name": "_usdAmount", 3045 | "type": "uint256" 3046 | } 3047 | ], 3048 | "name": "usdToTokenMin", 3049 | "outputs": [ 3050 | { 3051 | "internalType": "uint256", 3052 | "name": "", 3053 | "type": "uint256" 3054 | } 3055 | ], 3056 | "stateMutability": "view", 3057 | "type": "function" 3058 | }, 3059 | { 3060 | "inputs": [], 3061 | "name": "usdg", 3062 | "outputs": [ 3063 | { 3064 | "internalType": "address", 3065 | "name": "", 3066 | "type": "address" 3067 | } 3068 | ], 3069 | "stateMutability": "view", 3070 | "type": "function" 3071 | }, 3072 | { 3073 | "inputs": [ 3074 | { 3075 | "internalType": "address", 3076 | "name": "", 3077 | "type": "address" 3078 | } 3079 | ], 3080 | "name": "usdgAmounts", 3081 | "outputs": [ 3082 | { 3083 | "internalType": "uint256", 3084 | "name": "", 3085 | "type": "uint256" 3086 | } 3087 | ], 3088 | "stateMutability": "view", 3089 | "type": "function" 3090 | }, 3091 | { 3092 | "inputs": [], 3093 | "name": "useSwapPricing", 3094 | "outputs": [ 3095 | { 3096 | "internalType": "bool", 3097 | "name": "", 3098 | "type": "bool" 3099 | } 3100 | ], 3101 | "stateMutability": "view", 3102 | "type": "function" 3103 | }, 3104 | { 3105 | "inputs": [ 3106 | { 3107 | "internalType": "address", 3108 | "name": "_account", 3109 | "type": "address" 3110 | }, 3111 | { 3112 | "internalType": "address", 3113 | "name": "_collateralToken", 3114 | "type": "address" 3115 | }, 3116 | { 3117 | "internalType": "address", 3118 | "name": "_indexToken", 3119 | "type": "address" 3120 | }, 3121 | { 3122 | "internalType": "bool", 3123 | "name": "_isLong", 3124 | "type": "bool" 3125 | }, 3126 | { 3127 | "internalType": "bool", 3128 | "name": "_raise", 3129 | "type": "bool" 3130 | } 3131 | ], 3132 | "name": "validateLiquidation", 3133 | "outputs": [ 3134 | { 3135 | "internalType": "uint256", 3136 | "name": "", 3137 | "type": "uint256" 3138 | }, 3139 | { 3140 | "internalType": "uint256", 3141 | "name": "", 3142 | "type": "uint256" 3143 | } 3144 | ], 3145 | "stateMutability": "view", 3146 | "type": "function" 3147 | }, 3148 | { 3149 | "inputs": [], 3150 | "name": "vaultUtils", 3151 | "outputs": [ 3152 | { 3153 | "internalType": "contract IVaultUtils", 3154 | "name": "", 3155 | "type": "address" 3156 | } 3157 | ], 3158 | "stateMutability": "view", 3159 | "type": "function" 3160 | }, 3161 | { 3162 | "inputs": [], 3163 | "name": "whitelistedTokenCount", 3164 | "outputs": [ 3165 | { 3166 | "internalType": "uint256", 3167 | "name": "", 3168 | "type": "uint256" 3169 | } 3170 | ], 3171 | "stateMutability": "view", 3172 | "type": "function" 3173 | }, 3174 | { 3175 | "inputs": [ 3176 | { 3177 | "internalType": "address", 3178 | "name": "", 3179 | "type": "address" 3180 | } 3181 | ], 3182 | "name": "whitelistedTokens", 3183 | "outputs": [ 3184 | { 3185 | "internalType": "bool", 3186 | "name": "", 3187 | "type": "bool" 3188 | } 3189 | ], 3190 | "stateMutability": "view", 3191 | "type": "function" 3192 | }, 3193 | { 3194 | "inputs": [ 3195 | { 3196 | "internalType": "address", 3197 | "name": "_token", 3198 | "type": "address" 3199 | }, 3200 | { 3201 | "internalType": "address", 3202 | "name": "_receiver", 3203 | "type": "address" 3204 | } 3205 | ], 3206 | "name": "withdrawFees", 3207 | "outputs": [ 3208 | { 3209 | "internalType": "uint256", 3210 | "name": "", 3211 | "type": "uint256" 3212 | } 3213 | ], 3214 | "stateMutability": "nonpayable", 3215 | "type": "function" 3216 | } 3217 | ] 3218 | } 3219 | -------------------------------------------------------------------------------- /common.js: -------------------------------------------------------------------------------- 1 | 2 | async function sleep(ms) { 3 | await new Promise(resolve => setTimeout(resolve, ms)) 4 | } 5 | 6 | module.exports = { sleep } 7 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | const chainConfig = { 2 | bsctestnet: { 3 | nativeCurrency: { 4 | label: "TBNB", 5 | decimals: 18, 6 | }, 7 | chainId: 97, 8 | rpcUrls: ["https://data-seed-prebsc-1-s3.binance.org:8545/"], 9 | blockExplorer: "https://testnet.bscscan.com" 10 | }, 11 | ethereum: { 12 | nativeCurrency: { 13 | label: "ETH", 14 | decimals: 18, 15 | }, 16 | chainId: 1, 17 | rpcUrls: ["https://mainnet.infura.io/v3/"], 18 | blockExplorer: "https://etherscan.io" 19 | }, 20 | bsc: { 21 | nativeCurrency: { 22 | label: "BNB", 23 | decimals: 18, 24 | }, 25 | chainId: 56, 26 | rpcUrls: ["https://bsc-dataseed1.binance.org"], 27 | blockExplorer: "https://bscscan.com" 28 | }, 29 | core: { 30 | nativeCurrency: { 31 | label: "CORE", 32 | decimals: 18, 33 | }, 34 | chainId: 1116, 35 | rpcUrls: ["https://rpc.coredao.org/"], 36 | blockExplorer: "https://scan.coredao.org/" 37 | }, 38 | cronos: { 39 | nativeCurrency: { 40 | label: "CRO", 41 | decimals: 18, 42 | }, 43 | chainId: 25, 44 | rpcUrls: ["https://node.croswap.com/rpc"], 45 | blockExplorer: "https://cronoscan.com" 46 | }, 47 | goerli_ethereum: { 48 | nativeCurrency: { 49 | label: "Goerli ETH", 50 | decimals: 18, 51 | }, 52 | chainId: 5, 53 | rpcUrls: ["https://goerli.blockpi.network/v1/rpc/public"], 54 | blockExplorer: "https://goerli.etherscan.io" 55 | }, 56 | } 57 | 58 | module.exports = chainConfig -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ExecutePosition", 3 | "version": "1.0.0", 4 | "description": "price feed USDT on core chain", 5 | "main": "startExecutePosition.js", 6 | "scripts": { 7 | "start": "node startExecutePosition.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "bignumber.js": "^9.1.1", 14 | "fs": "^0.0.1-security", 15 | "web3": "^1.8.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /startExecutePosition.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const BN = require('bignumber.js') 3 | 4 | BN.config({ 5 | EXPONENTIAL_AT: [-10, 100] 6 | }) 7 | 8 | const { newContract, newWeb3, queryContract, executeContract, getGasEstimation } = require('./web3') 9 | const { sleep } = require('./common') 10 | const tokenArray = require('../GMX-POLO-SmartContract/scripts/core/tokens.js') 11 | 12 | async function main() { 13 | const pvkey = fs.readFileSync('.env').toString().trim() 14 | const PriceFeedExt = JSON.parse(fs.readFileSync('./abi/PriceFeedExt.json').toString()) 15 | const FastPriceFeed = JSON.parse(fs.readFileSync('./abi/FastPriceFeed.json').toString()) 16 | const PositionRouter = JSON.parse(fs.readFileSync('./abi/PositionRouter.json').toString()) 17 | const PositionManager = JSON.parse(fs.readFileSync('./abi/PositionManager.json').toString()) 18 | const Vault = JSON.parse(fs.readFileSync('./abi/Vault.json').toString()) 19 | let coreData = JSON.parse(fs.readFileSync('../GMX-POLO-SmartContract/scripts/deploy-core.json').toString()) 20 | addresses = {} 21 | for (let i of coreData){ 22 | addresses[i.name] = i.imple 23 | } 24 | const priceFeedInfo = addresses.FastPriceFeed 25 | const positionRouterInfo = addresses.PositionRouter 26 | const positionManagerInfo = addresses.PositionManager 27 | const vaultInfo = addresses.Vault 28 | 29 | const coreContext = await newWeb3('goerli_ethereum', pvkey) 30 | console.log("Starting position router server by", coreContext.address) 31 | 32 | const fastPriceFeedContract = await newContract(coreContext, FastPriceFeed.abi, priceFeedInfo) 33 | const positionRouterContract = await newContract(coreContext, PositionRouter.abi, positionRouterInfo) 34 | const positionManagerContract = await newContract(coreContext, PositionManager.abi, positionManagerInfo) 35 | const vaultContract = await newContract(coreContext, Vault.abi, vaultInfo) 36 | 37 | let tokens = [] 38 | let precisions = [] 39 | 40 | for (let i = 0; ; i++) { 41 | try { 42 | tokens = [...tokens, await queryContract(fastPriceFeedContract.methods.tokens(i))] 43 | precisions = [...precisions, await queryContract(fastPriceFeedContract.methods.tokenPrecisions(i))] 44 | } catch { 45 | break 46 | } 47 | } 48 | 49 | console.log('detected tokens') 50 | let priceFeeds = [] 51 | for (let i = 0; i < tokens.length; i++) { 52 | const addr = tokens[i] 53 | let foundItem 54 | for (const token in tokenArray['core']) { 55 | if (tokenArray['core'][token].address.toLowerCase() === addr.toLowerCase()) { 56 | foundItem = tokenArray['core'][token] 57 | break 58 | } 59 | } 60 | 61 | if (foundItem) { 62 | console.log(i + 1, 'token', addr) 63 | console.log(i + 1, 'precision', precisions[i].toString()) 64 | console.log('') 65 | console.log(foundItem) 66 | 67 | priceFeeds = [...priceFeeds, foundItem.priceFeed] 68 | } 69 | console.log('') 70 | } 71 | 72 | let priceFeederContracts = [] 73 | for (const p of priceFeeds) { 74 | priceFeederContracts = [...priceFeederContracts, await newContract(coreContext, PriceFeedExt.abi, p)] 75 | } 76 | 77 | while (1) { 78 | const testing = 0 79 | try { 80 | let priceBits = BN(0) 81 | let ta = [] 82 | let pr = [] 83 | 84 | for (let i = 0; i < precisions.length; i++) { 85 | const pc = (await queryContract(priceFeederContracts[i].methods.latestAnswer())) 86 | const t = await queryContract(fastPriceFeedContract.methods.tokens(i)) 87 | const p = await queryContract(fastPriceFeedContract.methods.tokenPrecisions(i)) 88 | 89 | ta = [...ta, t] 90 | pr = [...pr, p.toString()] 91 | 92 | if (pc.toString() === '0') { 93 | throw new Error(`${tokens[i]}: price could not be obtained`) 94 | } 95 | 96 | priceBits = priceBits.plus(BN(pc).times(precisions[i]).div('100000000').integerValue().times(BN(2).pow(32 * i))) 97 | } 98 | 99 | let startIncreaseIdx = await queryContract(positionRouterContract.methods.increasePositionRequestKeysStart()) 100 | startIncreaseIdx = parseInt(startIncreaseIdx.toString()) 101 | let endIncreaseIdx 102 | { 103 | for (i = startIncreaseIdx; ; i++) { 104 | try { 105 | await queryContract(positionRouterContract.methods.increasePositionRequestKeys(i)) 106 | } catch { 107 | break; 108 | } 109 | } 110 | endIncreaseIdx = i 111 | } 112 | 113 | console.log('Position increase >>>', 'start:', startIncreaseIdx, "end:", endIncreaseIdx) 114 | 115 | let startDecreaseIdx = await queryContract(positionRouterContract.methods.decreasePositionRequestKeysStart()) 116 | startDecreaseIdx = parseInt(startDecreaseIdx.toString()) 117 | let endDecreaseIdx 118 | { 119 | for (i = startDecreaseIdx; ; i++) { 120 | try { 121 | await queryContract(positionRouterContract.methods.decreasePositionRequestKeys(i)) 122 | } catch { 123 | break; 124 | } 125 | } 126 | endDecreaseIdx = i 127 | } 128 | 129 | console.log('Position decrease >>>', 'start:', startDecreaseIdx, "end:", endDecreaseIdx) 130 | 131 | if (testing > 0) { 132 | if (endIncreaseIdx > 0) { 133 | const key = await queryContract(positionRouterContract.methods.increasePositionRequestKeys(endIncreaseIdx - 1)) 134 | const isLeverageEnabled = await queryContract(positionRouterContract.methods.isLeverageEnabled()) 135 | const minBlockDelayKeeper = await queryContract(positionRouterContract.methods.minBlockDelayKeeper()) 136 | const isPositionKeeper = await queryContract(positionRouterContract.methods.isPositionKeeper(coreContext.address)) 137 | const request = await queryContract(positionRouterContract.methods.increasePositionRequests(key)) 138 | const isUpdater = await queryContract(fastPriceFeedContract.methods.isUpdater(coreContext.address)) 139 | const isLiquidator = await queryContract(positionManagerContract.methods.isLiquidator(coreContext.address)) 140 | 141 | const account = '0x2A567DDf64eDE5782f416A1e729504a31990f957' 142 | const collateralToken = '0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23' 143 | const indexToken = '0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23' 144 | const isLong = true 145 | const positionKey = await queryContract(vaultContract.methods.getPositionKey(account, collateralToken, indexToken, isLong)) 146 | const position = await queryContract(vaultContract.methods.positions(positionKey)) 147 | const maxLeverage = await queryContract(vaultContract.methods.maxLeverage()) 148 | console.log('address', coreContext.address) 149 | console.log('minBlockDelayKeeper', minBlockDelayKeeper.toString()) 150 | console.log('isLeverageEnabled', isLeverageEnabled) 151 | console.log('isPositionKeeper', isPositionKeeper) 152 | console.log('isUpdater', isUpdater) 153 | console.log('isLiquidator', isLiquidator) 154 | console.log('key', key) 155 | console.log('request', request) 156 | console.log('tokens', ta) 157 | console.log('precisions', pr) 158 | console.log('positionKey', positionKey) 159 | console.log('position', position) 160 | console.log('max leverage', maxLeverage.toString()) 161 | 162 | // const reserveAmount = await queryContract(vaultContract.methods.reservedAmounts('0x191E94fa59739e188dcE837F7f6978d84727AD01')) 163 | // const poolAmount = await queryContract(vaultContract.methods.poolAmounts('0x191E94fa59739e188dcE837F7f6978d84727AD01')) 164 | // console.log('reserveAmount', reserveAmount.toString()) 165 | // console.log('poolAmount', poolAmount.toString()) 166 | if (startIncreaseIdx < endIncreaseIdx || true) { 167 | try { 168 | // const gas = await getGasEstimation(positionManagerContract.methods.liquidatePosition(account, collateralToken, indexToken, isLong, coreContext.address), coreContext.address) 169 | const gas = await getGasEstimation(positionRouterContract.methods.executeIncreasePosition(key, coreContext.address), coreContext.address) 170 | // const gas = await getGasEstimation(fastPriceFeedContract.methods.setPricesWithBitsAndExecute( 171 | // positionRouterInfo, 172 | // priceBits.toString(), 173 | // Math.floor((new Date()).getTime() / 1000), 174 | // endIncreaseIdx, 175 | // endDecreaseIdx, 176 | // endIncreaseIdx - startIncreaseIdx, 177 | // endDecreaseIdx - startDecreaseIdx 178 | // ), 179 | // coreContext.address 180 | // ) 181 | console.log('gas', gas.toString()) 182 | } catch (err) { 183 | console.log(err) 184 | } 185 | } 186 | } 187 | } else { 188 | if (startIncreaseIdx < endIncreaseIdx || startDecreaseIdx < endDecreaseIdx) { 189 | console.log("Eagle", priceBits, 190 | Math.floor((new Date()).getTime() / 1000), 191 | endIncreaseIdx, 192 | endDecreaseIdx, 193 | endIncreaseIdx - startIncreaseIdx, 194 | endDecreaseIdx - startDecreaseIdx); 195 | 196 | try { 197 | await executeContract(coreContext, fastPriceFeedContract._address, fastPriceFeedContract.methods.setPricesWithBitsAndExecute( 198 | positionRouterInfo, 199 | priceBits, 200 | Math.floor((new Date()).getTime() / 1000), 201 | endIncreaseIdx, 202 | endDecreaseIdx, 203 | endIncreaseIdx - startIncreaseIdx, 204 | endDecreaseIdx - startDecreaseIdx 205 | ) 206 | ) 207 | } catch (err) { 208 | console.log(err) 209 | } 210 | } 211 | } 212 | } catch (err) { 213 | console.log(err) 214 | console.log("Waiting 30s for RPC") 215 | await sleep(30000) 216 | process.exit(); 217 | } 218 | 219 | console.log(coreContext.address, coreContext.web3.utils.fromWei(await coreContext.web3.eth.getBalance(coreContext.address)), "Goerli Ethereum") 220 | 221 | if (testing > 0) { 222 | await sleep(60000) 223 | } else { 224 | await sleep(3000) 225 | } 226 | } 227 | } 228 | 229 | main() 230 | .then(() => { }) 231 | .catch(err => { 232 | console.log(err) 233 | process.exit(); 234 | }) -------------------------------------------------------------------------------- /web3.js: -------------------------------------------------------------------------------- 1 | const chainConfig = require("./config") 2 | 3 | const Web3 = require("web3") 4 | const BN = require('bignumber.js') 5 | 6 | BN.config({ 7 | EXPONENTIAL_AT: [-10, 64], 8 | }) 9 | 10 | function getBN() { 11 | return BN 12 | } 13 | 14 | async function newWeb3(chain, pvkey) { 15 | const web3 = new Web3(chainConfig[chain].rpcUrls[0]) 16 | const address = await web3.eth.accounts.privateKeyToAccount(pvkey).address 17 | await web3.eth.accounts.wallet.add(pvkey) 18 | 19 | return { 20 | web3: web3, 21 | address: address, 22 | pvkey: pvkey 23 | } 24 | } 25 | 26 | async function newContract(web3Context, abi, address) { 27 | return await new web3Context.web3.eth.Contract(abi, address); 28 | }; 29 | 30 | async function queryContract(tx) { 31 | return await tx.call(); 32 | }; 33 | 34 | async function getGasEstimation(tx, address) { 35 | return tx? await tx.estimateGas({ from: address }): '35000'; 36 | } 37 | 38 | async function getGasPrice(web3Context) { 39 | return await web3Context.web3.eth.getGasPrice() 40 | } 41 | 42 | async function executeTransactionBySign(web3Context, contractAddress, tx, value) { 43 | const networkId = await web3Context.web3.eth.net.getId() 44 | // { 45 | // address: '0x8f4DF07B38E5203eb81Ab4C523DeEAb0AC1f2749', 46 | // privateKey: '0x76d7....c21d', 47 | // signTransaction: [Function: signTransaction], 48 | // sign: [Function: sign], 49 | // encrypt: [Function: encrypt] 50 | // } 51 | const address = web3Context.address 52 | const gas = await getGasEstimation(tx, address) 53 | const gasPrice = await getGasPrice(web3Context) 54 | 55 | const data = tx?.encodeABI() 56 | const nonce = await web3Context.web3.eth.getTransactionCount(address); 57 | 58 | const signedTx = await web3Context.web3.eth.accounts.signTransaction( 59 | { 60 | to: contractAddress, 61 | data, 62 | gas, 63 | gasPrice, 64 | nonce, 65 | value: value !== undefined? value: "0", 66 | chainId: networkId, 67 | }, 68 | web3Context.pvkey 69 | ); 70 | const receipt = await web3Context.web3.eth.sendSignedTransaction(signedTx.rawTransaction); 71 | 72 | console.log(`Transaction:`, receipt) 73 | return receipt; 74 | }; 75 | 76 | async function executeContractByRaw(web3Context, contractAddress, tx, value) { 77 | const networkId = await web3Context.web3.eth.net.getId() 78 | const address = web3Context.address 79 | const gas = await getGasEstimation(tx, address) 80 | const gasPrice = await getGasPrice(web3Context) 81 | const data = tx?.encodeABI() 82 | const nonce = await web3Context.web3.eth.getTransactionCount(address); 83 | const txData = { 84 | from: address, 85 | to: contractAddress, 86 | data: data, 87 | gas, 88 | gasPrice, 89 | nonce, 90 | value: value !== undefined? value: "0", 91 | chainId: networkId, 92 | }; 93 | 94 | const receipt = await web3Context.web3.eth.sendTransaction(txData); 95 | console.log(`Transaction:`, receipt) 96 | return receipt; 97 | }; 98 | 99 | async function executeContract(web3Context, contractAddress, tx, value) { 100 | try { 101 | return await executeTransactionBySign(web3Context, contractAddress, tx, value) 102 | } catch (err) { 103 | console.log(err) 104 | } 105 | } 106 | 107 | module.exports = {getBN, newWeb3, newContract, queryContract, getGasEstimation, getGasPrice, executeTransactionBySign, executeContractByRaw, executeContract} --------------------------------------------------------------------------------