diff --git a/package.json b/package.json index d935a0c1..1a0fe028 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ "test": "yarn workspaces run test" }, "workspaces": { - "packages": [ - "packages/helpers", + "packages": [ "packages/registry", "packages/fee-controller", "packages/authorizer", diff --git a/packages/helpers/.prettierrc.js b/packages/helpers/.prettierrc.js deleted file mode 100644 index 01dbc74e..00000000 --- a/packages/helpers/.prettierrc.js +++ /dev/null @@ -1,9 +0,0 @@ -const ts = require('eslint-config-mimic/prettier') -const solidity = require('solhint-config-mimic/prettier') - -module.exports = { - overrides: [ - ts, - solidity - ] -} diff --git a/packages/helpers/LICENSE b/packages/helpers/LICENSE deleted file mode 100644 index f288702d..00000000 --- a/packages/helpers/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/packages/helpers/README.md b/packages/helpers/README.md deleted file mode 100644 index 6221d7bc..00000000 --- a/packages/helpers/README.md +++ /dev/null @@ -1,70 +0,0 @@ -

- Mimic Finance -

- -

DeFi automation platform

- -

- - NPM - - - CI Helpers - - - Discord - - - GLP 3.0 - -

- -

- Content • - Setup • - Security • - License -

- ---- - -## Content - -This package contains a bunch of Solidity and TypeScript helpers used among all Mimic v3 repositories. - -## Setup - -To set up this project you'll need [git](https://git-scm.com) and [yarn](https://classic.yarnpkg.com) installed. -From your command line: - -```bash -# Clone this repository -$ git clone https://github.com/mimic-fi/v3-core - -# Go into the repository's package -$ cd v3-core/packages/helpers - -# Install dependencies -$ yarn - -# Run tests to make sure everything is set up correctly -$ yarn test -``` - -## Security - -To read more about our auditing and related security processes please refer to the [security section](https://docs.mimic.fi/miscellaneous/security) of our docs site. - -However, if you found any potential issue in any of our smart contracts or in any piece of code you consider critical -for the safety of the protocol, please contact us through security@mimic.fi. - -## License - -GPL 3.0 - ---- - -> Website [mimic.fi](https://mimic.fi)  ·  -> GitHub [@mimic-fi](https://github.com/mimic-fi)  ·  -> Twitter [@mimicfi](https://twitter.com/mimicfi)  ·  -> Discord [mimic](https://discord.mimic.fi) diff --git a/packages/helpers/contracts/math/FixedPoint.sol b/packages/helpers/contracts/math/FixedPoint.sol deleted file mode 100644 index df98dac3..00000000 --- a/packages/helpers/contracts/math/FixedPoint.sol +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -/** - * @title FixedPoint - * @dev Math library to operate with fixed point values with 18 decimals - */ -library FixedPoint { - // 1 in fixed point value: 18 decimal places - uint256 internal constant ONE = 1e18; - - /** - * @dev Multiplication overflow - */ - error FixedPointMulOverflow(uint256 a, uint256 b); - - /** - * @dev Division by zero - */ - error FixedPointZeroDivision(); - - /** - * @dev Division internal error - */ - error FixedPointDivInternal(uint256 a, uint256 aInflated); - - /** - * @dev Multiplies two fixed point numbers rounding down - */ - function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { - unchecked { - uint256 product = a * b; - if (a != 0 && product / a != b) revert FixedPointMulOverflow(a, b); - return product / ONE; - } - } - - /** - * @dev Multiplies two fixed point numbers rounding up - */ - function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { - unchecked { - uint256 product = a * b; - if (a != 0 && product / a != b) revert FixedPointMulOverflow(a, b); - return product == 0 ? 0 : (((product - 1) / ONE) + 1); - } - } - - /** - * @dev Divides two fixed point numbers rounding down - */ - function divDown(uint256 a, uint256 b) internal pure returns (uint256) { - unchecked { - if (b == 0) revert FixedPointZeroDivision(); - if (a == 0) return 0; - uint256 aInflated = a * ONE; - if (aInflated / a != ONE) revert FixedPointDivInternal(a, aInflated); - return aInflated / b; - } - } - - /** - * @dev Divides two fixed point numbers rounding up - */ - function divUp(uint256 a, uint256 b) internal pure returns (uint256) { - unchecked { - if (b == 0) revert FixedPointZeroDivision(); - if (a == 0) return 0; - uint256 aInflated = a * ONE; - if (aInflated / a != ONE) revert FixedPointDivInternal(a, aInflated); - return ((aInflated - 1) / b) + 1; - } - } -} diff --git a/packages/helpers/contracts/mocks/FeedMock.sol b/packages/helpers/contracts/mocks/FeedMock.sol deleted file mode 100644 index 827d1bd4..00000000 --- a/packages/helpers/contracts/mocks/FeedMock.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -contract FeedMock { - uint8 public decimals; - int256 public price; - - constructor(int256 _price, uint8 _decimals) { - price = _price; - decimals = _decimals; - } - - function latestRoundData() external view returns (uint80, int256 answer, uint256, uint256, uint80) { - return (0, price, 0, 0, 0); - } -} diff --git a/packages/helpers/contracts/mocks/TokenMock.sol b/packages/helpers/contracts/mocks/TokenMock.sol deleted file mode 100644 index 919b95fb..00000000 --- a/packages/helpers/contracts/mocks/TokenMock.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; - -contract TokenMock is ERC20 { - uint8 internal _decimals; - - constructor(string memory symbol, uint8 dec) ERC20(symbol, symbol) { - _decimals = dec; - } - - function mint(address account, uint256 amount) external { - _mint(account, amount); - } - - function decimals() public view override returns (uint8) { - return _decimals; - } -} diff --git a/packages/helpers/contracts/mocks/WrappedNativeTokenMock.sol b/packages/helpers/contracts/mocks/WrappedNativeTokenMock.sol deleted file mode 100644 index 966e4ce0..00000000 --- a/packages/helpers/contracts/mocks/WrappedNativeTokenMock.sol +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import '../utils/IWrappedNativeToken.sol'; - -contract WrappedNativeTokenMock is IWrappedNativeToken { - uint8 public decimals = 18; - string public name = 'Wrapped Native Token'; - string public symbol = 'WNT'; - - event Deposit(address indexed to, uint256 amount); - event Withdrawal(address indexed from, uint256 amount); - - mapping (address => uint256) public override balanceOf; - mapping (address => mapping (address => uint256)) public override allowance; - - receive() external payable { - deposit(); - } - - function deposit() public payable override { - balanceOf[msg.sender] += msg.value; - emit Deposit(msg.sender, msg.value); - } - - function withdraw(uint256 amount) public override { - require(balanceOf[msg.sender] >= amount, 'WNT_NOT_ENOUGH_BALANCE'); - balanceOf[msg.sender] -= amount; - payable(msg.sender).transfer(amount); - emit Withdrawal(msg.sender, amount); - } - - function totalSupply() public view override returns (uint256) { - return address(this).balance; - } - - function approve(address spender, uint256 amount) public override returns (bool) { - allowance[msg.sender][spender] = amount; - emit Approval(msg.sender, spender, amount); - return true; - } - - function transfer(address to, uint256 amount) public override returns (bool) { - return transferFrom(msg.sender, to, amount); - } - - function transferFrom(address from, address to, uint256 amount) public override returns (bool) { - require(balanceOf[from] >= amount, 'NOT_ENOUGH_BALANCE'); - - if (from != msg.sender && allowance[from][msg.sender] != type(uint256).max) { - require(allowance[from][msg.sender] >= amount, 'NOT_ENOUGH_ALLOWANCE'); - allowance[from][msg.sender] -= amount; - } - - balanceOf[from] -= amount; - balanceOf[to] += amount; - emit Transfer(from, to, amount); - return true; - } -} diff --git a/packages/helpers/contracts/test/math/FixedPointMock.sol b/packages/helpers/contracts/test/math/FixedPointMock.sol deleted file mode 100644 index ae3be55d..00000000 --- a/packages/helpers/contracts/test/math/FixedPointMock.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import '../../math/FixedPoint.sol'; - -contract FixedPointMock { - using FixedPoint for uint256; - - function mulUp(uint256 a, uint256 b) external pure returns (uint256) { - return a.mulUp(b); - } - - function mulDown(uint256 a, uint256 b) external pure returns (uint256) { - return a.mulDown(b); - } - - function divUp(uint256 a, uint256 b) external pure returns (uint256) { - return a.divUp(b); - } - - function divDown(uint256 a, uint256 b) external pure returns (uint256) { - return a.divDown(b); - } -} diff --git a/packages/helpers/contracts/test/utils/ArraysMock.sol b/packages/helpers/contracts/test/utils/ArraysMock.sol deleted file mode 100644 index eb6ed216..00000000 --- a/packages/helpers/contracts/test/utils/ArraysMock.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '../../utils/Arrays.sol'; - -library ArraysMock { - function from1(address a, address b) external pure returns (address[] memory result) { - return Arrays.from(a, b); - } - - function from2(address a, address[] memory b, address c) external pure returns (address[] memory result) { - return Arrays.from(a, b, c); - } - - function from3(uint24 a, uint24[] memory b) external pure returns (uint24[] memory result) { - return Arrays.from(a, b); - } - - function from4(bytes32 a, bytes32[] memory b) external pure returns (bytes32[] memory result) { - return Arrays.from(a, b); - } -} diff --git a/packages/helpers/contracts/test/utils/BytesHelpersMock.sol b/packages/helpers/contracts/test/utils/BytesHelpersMock.sol deleted file mode 100644 index 6607c5d1..00000000 --- a/packages/helpers/contracts/test/utils/BytesHelpersMock.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '../../utils/BytesHelpers.sol'; - -library BytesHelpersMock { - function concat1(bytes memory self, address value) external pure returns (bytes memory) { - return BytesHelpers.concat(self, value); - } - - function concat2(bytes memory self, uint24 value) external pure returns (bytes memory) { - return BytesHelpers.concat(self, value); - } - - function toUint256(bytes memory self, uint256 start) external pure returns (uint256) { - return BytesHelpers.toUint256(self, start); - } -} diff --git a/packages/helpers/contracts/test/utils/DenominationsMock.sol b/packages/helpers/contracts/test/utils/DenominationsMock.sol deleted file mode 100644 index ee07532b..00000000 --- a/packages/helpers/contracts/test/utils/DenominationsMock.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '../../utils/Denominations.sol'; - -// solhint-disable func-name-mixedcase - -contract DenominationsMock { - function NATIVE_TOKEN() external pure returns (address) { - return Denominations.NATIVE_TOKEN; - } -} diff --git a/packages/helpers/contracts/test/utils/ERC20HelpersMock.sol b/packages/helpers/contracts/test/utils/ERC20HelpersMock.sol deleted file mode 100644 index 9cf16fdf..00000000 --- a/packages/helpers/contracts/test/utils/ERC20HelpersMock.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '../../utils/ERC20Helpers.sol'; - -contract ERC20HelpersMock { - receive() external payable { - // solhint-disable-previous-line no-empty-blocks - } - - function approve(address token, address to, uint256 amount) external { - ERC20Helpers.approve(token, to, amount); - } - - function transfer(address token, address to, uint256 amount) external { - ERC20Helpers.transfer(token, to, amount); - } - - function balanceOf(address token, address account) external view returns (uint256) { - return ERC20Helpers.balanceOf(token, account); - } -} diff --git a/packages/helpers/contracts/test/utils/EnumerableMapAddressToAddressMock.sol b/packages/helpers/contracts/test/utils/EnumerableMapAddressToAddressMock.sol deleted file mode 100644 index ea0ee0ed..00000000 --- a/packages/helpers/contracts/test/utils/EnumerableMapAddressToAddressMock.sol +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import '../../utils/EnumerableMap.sol'; - -// solhint-disable func-name-mixedcase - -contract EnumerableMapAddressToAddressMock { - using EnumerableMap for EnumerableMap.AddressToAddressMap; - - event OperationResult(bool result); - - EnumerableMap.AddressToAddressMap private _map; - - function length() public view returns (uint256) { - return _map.length(); - } - - function contains(address key) public view returns (bool) { - return _map.contains(key); - } - - function set(address key, address value) public { - bool result = _map.set(key, value); - emit OperationResult(result); - } - - function remove(address key) public { - bool result = _map.remove(key); - emit OperationResult(result); - } - - function at(uint256 index) public view returns (address key, address value) { - return _map.at(index); - } - - function get(address key) public view returns (address) { - return _map.get(key); - } - - function tryGet(address key) public view returns (bool exists, address value) { - return _map.tryGet(key); - } - - function keys() public view returns (address[] memory) { - return _map.keys(); - } - - function values() public view returns (address[] memory) { - return _map.values(); - } -} diff --git a/packages/helpers/contracts/test/utils/EnumerableMapAddressToUintMock.sol b/packages/helpers/contracts/test/utils/EnumerableMapAddressToUintMock.sol deleted file mode 100644 index 5951f6be..00000000 --- a/packages/helpers/contracts/test/utils/EnumerableMapAddressToUintMock.sol +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import '../../utils/EnumerableMap.sol'; - -// solhint-disable func-name-mixedcase - -contract EnumerableMapAddressToUintMock { - using EnumerableMap for EnumerableMap.AddressToUintMap; - - event OperationResult(bool result); - - EnumerableMap.AddressToUintMap private _map; - - function set(address key, uint256 value) public { - bool result = _map.set(key, value); - emit OperationResult(result); - } - - function remove(address key) public { - bool result = _map.remove(key); - emit OperationResult(result); - } - - function length() public view returns (uint256) { - return _map.length(); - } - - function contains(address key) public view returns (bool) { - return _map.contains(key); - } - - function at(uint256 index) public view returns (address key, uint256 value) { - return _map.at(index); - } - - function get(address key) public view returns (uint256) { - return _map.get(key); - } - - function tryGet(address key) public view returns (bool exists, uint256 value) { - return _map.tryGet(key); - } - - function keys() public view returns (address[] memory) { - return _map.keys(); - } - - function values() public view returns (uint256[] memory) { - return _map.values(); - } -} diff --git a/packages/helpers/contracts/utils/Arrays.sol b/packages/helpers/contracts/utils/Arrays.sol deleted file mode 100644 index 40db8c89..00000000 --- a/packages/helpers/contracts/utils/Arrays.sol +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -/** - * @title Arrays - * @dev Helper methods to operate arrays - */ -library Arrays { - /** - * @dev Builds an array of addresses based on the given ones - */ - function from(address a, address b) internal pure returns (address[] memory result) { - result = new address[](2); - result[0] = a; - result[1] = b; - } - - /** - * @dev Builds an array of addresses based on the given ones - */ - function from(address a, address[] memory b, address c) internal pure returns (address[] memory result) { - result = new address[](b.length + 2); - result[0] = a; - for (uint256 i = 0; i < b.length; i++) { - result[i + 1] = b[i]; - } - result[b.length + 1] = c; - } - - /** - * @dev Builds an array of uint24s based on the given ones - */ - function from(uint24 a, uint24[] memory b) internal pure returns (uint24[] memory result) { - result = new uint24[](b.length + 1); - result[0] = a; - for (uint256 i = 0; i < b.length; i++) { - result[i + 1] = b[i]; - } - } - - /** - * @dev Builds an array of bytes32 based on the given ones - */ - function from(bytes32 a, bytes32[] memory b) internal pure returns (bytes32[] memory result) { - result = new bytes32[](b.length + 1); - result[0] = a; - for (uint256 i = 0; i < b.length; i++) { - result[i + 1] = b[i]; - } - } -} diff --git a/packages/helpers/contracts/utils/BytesHelpers.sol b/packages/helpers/contracts/utils/BytesHelpers.sol deleted file mode 100644 index 4d6076ec..00000000 --- a/packages/helpers/contracts/utils/BytesHelpers.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -/** - * @title BytesHelpers - * @dev Provides a list of Bytes helper methods - */ -library BytesHelpers { - /** - * @dev The length is shorter than start plus 32 - */ - error BytesOutOfBounds(uint256 start, uint256 length); - - /** - * @dev Concatenates an address to a bytes array - */ - function concat(bytes memory self, address value) internal pure returns (bytes memory) { - return abi.encodePacked(self, value); - } - - /** - * @dev Concatenates an uint24 to a bytes array - */ - function concat(bytes memory self, uint24 value) internal pure returns (bytes memory) { - return abi.encodePacked(self, value); - } - - /** - * @dev Decodes a bytes array into an uint256 - */ - function toUint256(bytes memory self) internal pure returns (uint256) { - return toUint256(self, 0); - } - - /** - * @dev Reads an uint256 from a bytes array starting at a given position - */ - function toUint256(bytes memory self, uint256 start) internal pure returns (uint256 result) { - if (self.length < start + 32) revert BytesOutOfBounds(start, self.length); - assembly { - result := mload(add(add(self, 0x20), start)) - } - } -} diff --git a/packages/helpers/contracts/utils/Denominations.sol b/packages/helpers/contracts/utils/Denominations.sol deleted file mode 100644 index 333c8c3e..00000000 --- a/packages/helpers/contracts/utils/Denominations.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -/** - * @title Denominations - * @dev Provides a list of ground denominations for those tokens that cannot be represented by an ERC20. - * For now, the only needed is the native token that could be ETH, MATIC, or other depending on the layer being operated. - */ -library Denominations { - address internal constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; - - // Fiat currencies follow https://en.wikipedia.org/wiki/ISO_4217 - address internal constant USD = address(840); - - function isNativeToken(address token) internal pure returns (bool) { - return token == NATIVE_TOKEN; - } -} diff --git a/packages/helpers/contracts/utils/ERC20Helpers.sol b/packages/helpers/contracts/utils/ERC20Helpers.sol deleted file mode 100644 index 1b1bf56e..00000000 --- a/packages/helpers/contracts/utils/ERC20Helpers.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; - -import './Denominations.sol'; - -/** - * @title ERC20Helpers - * @dev Provides a list of ERC20 helper methods - */ -library ERC20Helpers { - function approve(address token, address to, uint256 amount) internal { - SafeERC20.forceApprove(IERC20(token), to, amount); - } - - function transfer(address token, address to, uint256 amount) internal { - if (Denominations.isNativeToken(token)) Address.sendValue(payable(to), amount); - else SafeERC20.safeTransfer(IERC20(token), to, amount); - } - - function balanceOf(address token, address account) internal view returns (uint256) { - if (Denominations.isNativeToken(token)) return address(account).balance; - else return IERC20(token).balanceOf(address(account)); - } -} diff --git a/packages/helpers/contracts/utils/EnumerableMap.sol b/packages/helpers/contracts/utils/EnumerableMap.sol deleted file mode 100644 index a932a23a..00000000 --- a/packages/helpers/contracts/utils/EnumerableMap.sol +++ /dev/null @@ -1,244 +0,0 @@ -// SPDX-License-Identifier: MIT - -// Based on the EnumerableMap library from OpenZeppelin Contracts - -pragma solidity ^0.8.0; - -import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; - -/** - * @dev Library for managing an enumerable variant of Solidity's - * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] - * type. - * - * Maps have the following properties: - * - * - Entries are added, removed, and checked for existence in constant time - * (O(1)). - * - Entries are enumerated in O(n). No guarantees are made on the ordering. - * - * ``` - * contract Example { - * // Add the library methods - * using EnumerableMap for EnumerableMap.AddressToAddressMap; - * - * // Declare a set state variable - * EnumerableMap.AddressToAddressMap private myMap; - * } - * ``` - */ - -library EnumerableMap { - using EnumerableSet for EnumerableSet.AddressSet; - - /** - * @dev Address to uint map - * @param _keys Set of map keys - * @param _values Map of values - */ - struct AddressToUintMap { - EnumerableSet.AddressSet _keys; - mapping (address => uint256) _values; - } - - /** - * @dev The key doesn't exist in the map - */ - error EnumerableMapNonExistentKey(address key); - - /** - * @dev Adds a key-value pair to a map, or updates the value for an existing - * key. O(1). - * - * Returns true if the key was added to the map, that is if it was not - * already present. - */ - function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { - map._values[key] = value; - return map._keys.add(key); - } - - /** - * @dev Removes a key-value pair from a map. O(1). - * - * Returns true if the key was removed from the map, that is if it was present. - */ - function remove(AddressToUintMap storage map, address key) internal returns (bool) { - delete map._values[key]; - return map._keys.remove(key); - } - - /** - * @dev Returns the number of key-value pairs in the map. O(1). - */ - function length(AddressToUintMap storage map) internal view returns (uint256) { - return map._keys.length(); - } - - /** - * @dev Returns true if the key is in the map. O(1). - */ - function contains(AddressToUintMap storage map, address key) internal view returns (bool) { - return map._keys.contains(key); - } - - /** - * @dev Return the entire set of keys - */ - function keys(AddressToUintMap storage map) internal view returns (address[] memory) { - return map._keys.values(); - } - - /** - * @dev Return the entire set of values - */ - function values(AddressToUintMap storage map) internal view returns (uint256[] memory items) { - items = new uint256[](length(map)); - for (uint256 i = 0; i < items.length; i++) { - address key = map._keys.at(i); - items[i] = map._values[key]; - } - } - - /** - * @dev Returns the key-value pair stored at position `index` in the map. O(1). - * - * Note that there are no guarantees on the ordering of entries inside the - * array, and it may change when more entries are added or removed. - * - * Requirements: - * - * - `index` must be strictly lower than {length}. - */ - function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { - address key = map._keys.at(index); - return (key, map._values[key]); - } - - /** - * @dev Returns the value associated with `key`. O(1). - * - * Requirements: - * - * - `key` must be in the map. - */ - function get(AddressToUintMap storage map, address key) internal view returns (uint256) { - uint256 value = map._values[key]; - if (value == 0 && !contains(map, key)) revert EnumerableMapNonExistentKey(key); - return value; - } - - /** - * @dev Tries to returns the value associated with `key`. O(1). - * Does not revert if `key` is not in the map. - */ - function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { - uint256 value = map._values[key]; - if (value == 0) { - return (contains(map, key), 0); - } else { - return (true, value); - } - } - - // AddressToAddressMap - - struct AddressToAddressMap { - EnumerableSet.AddressSet _keys; - mapping (address => address) _values; - } - - /** - * @dev Adds a key-value pair to a map, or updates the value for an existing key. O(1). - * - * Returns true if the key was added to the map, that is if it was not - * already present. - */ - function set(AddressToAddressMap storage map, address key, address value) internal returns (bool) { - map._values[key] = value; - return map._keys.add(key); - } - - /** - * @dev Removes a key-value pair from a map. O(1). - * - * Returns true if the key was removed from the map, that is if it was present. - */ - function remove(AddressToAddressMap storage map, address key) internal returns (bool) { - delete map._values[key]; - return map._keys.remove(key); - } - - /** - * @dev Returns the number of key-value pairs in the map. O(1). - */ - function length(AddressToAddressMap storage map) internal view returns (uint256) { - return map._keys.length(); - } - - /** - * @dev Returns true if the key is in the map. O(1). - */ - function contains(AddressToAddressMap storage map, address key) internal view returns (bool) { - return map._keys.contains(key); - } - - /** - * @dev Return the entire set of keys - */ - function keys(AddressToAddressMap storage map) internal view returns (address[] memory) { - return map._keys.values(); - } - - /** - * @dev Return the entire set of values - */ - function values(AddressToAddressMap storage map) internal view returns (address[] memory items) { - items = new address[](length(map)); - for (uint256 i = 0; i < items.length; i++) { - address key = map._keys.at(i); - items[i] = map._values[key]; - } - } - - /** - * @dev Returns the key-value pair stored at position `index` in the map. O(1). - * - * Note that there are no guarantees on the ordering of entries inside the - * array, and it may change when more entries are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function at(AddressToAddressMap storage map, uint256 index) internal view returns (address, address) { - address key = map._keys.at(index); - return (key, map._values[key]); - } - - /** - * @dev Returns the value associated with `key`. O(1). - * - * Requirements: - * - * - `key` must be in the map. - */ - function get(AddressToAddressMap storage map, address key) internal view returns (address) { - address value = map._values[key]; - if (value == address(0) && !contains(map, key)) revert EnumerableMapNonExistentKey(key); - return value; - } - - /** - * @dev Tries to returns the value associated with `key`. O(1). - * Does not revert if `key` is not in the map. - */ - function tryGet(AddressToAddressMap storage map, address key) internal view returns (bool, address) { - address value = map._values[key]; - if (value == address(0)) { - return (contains(map, key), address(0)); - } else { - return (true, value); - } - } -} diff --git a/packages/helpers/contracts/utils/IWrappedNativeToken.sol b/packages/helpers/contracts/utils/IWrappedNativeToken.sol deleted file mode 100644 index 414a0445..00000000 --- a/packages/helpers/contracts/utils/IWrappedNativeToken.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pragma solidity ^0.8.0; - -import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; - -/** - * @title IWrappedNativeToken - */ -interface IWrappedNativeToken is IERC20 { - /** - * @dev Wraps msg.value into the wrapped-native token - */ - function deposit() external payable; - - /** - * @dev Unwraps requested amount to the native token - */ - function withdraw(uint256 amount) external; -} diff --git a/packages/helpers/hardhat.config.ts b/packages/helpers/hardhat.config.ts deleted file mode 100644 index 6b4bec75..00000000 --- a/packages/helpers/hardhat.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import '@nomiclabs/hardhat-ethers' -import '@nomiclabs/hardhat-waffle' - -export default { - solidity: { - version: '0.8.17', - settings: { - optimizer: { - enabled: true, - runs: 10000, - }, - }, - }, -} diff --git a/packages/helpers/index.ts b/packages/helpers/index.ts deleted file mode 100644 index 2d0247aa..00000000 --- a/packages/helpers/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './src/addresses' -export * from './src/asserts' -export * from './src/blocks' -export * from './src/constants' -export * from './src/contracts' -export * from './src/mocks' -export * from './src/numbers' -export * from './src/signers' -export * from './src/tests' -export * from './src/time' diff --git a/packages/helpers/package.json b/packages/helpers/package.json deleted file mode 100644 index 56b5a7e9..00000000 --- a/packages/helpers/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@mimic-fi/v3-helpers", - "version": "0.1.12", - "license": "GPL-3.0", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "files": [ - "artifacts/contracts/**/*", - "!artifacts/contracts/test/*", - "contracts/**/*", - "!contracts/test/*", - "dist" - ], - "scripts": { - "build": "yarn compile && rm -rf dist && tsc", - "compile": "hardhat compile", - "lint": "yarn lint:solidity && yarn lint:typescript", - "lint:solidity": "solhint 'contracts/**/*.sol' --config ../../node_modules/solhint-config-mimic/index.js", - "lint:typescript": "eslint . --ext .ts", - "test": "hardhat test", - "prepare": "yarn build" - }, - "dependencies": { - "@nomiclabs/hardhat-ethers": "^2.2.3", - "@nomiclabs/hardhat-waffle": "2.0.3", - "@types/chai": "^4.3.5", - "@types/mocha": "^10.0.1", - "@types/sinon-chai": "^3.2.3", - "chai": "^4.3.7", - "decimal.js": "~10.4.3", - "ethers": "~5.6.0", - "hardhat": "^2.14.1", - "mocha": "^6.2.3" - }, - "devDependencies": { - "eslint-config-mimic": "^0.0.2", - "ethereum-waffle": "^3.4.4", - "solhint-config-mimic": "^0.0.3", - "ts-node": "^10.9.1", - "typescript": "~4.3.4" - }, - "eslintConfig": { - "extends": "eslint-config-mimic", - "ignorePatterns": ["dist"] - } -} diff --git a/packages/helpers/src/addresses/chainlink/arbitrum.ts b/packages/helpers/src/addresses/chainlink/arbitrum.ts deleted file mode 100644 index 7bc0b751..00000000 --- a/packages/helpers/src/addresses/chainlink/arbitrum.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const DAI_USD = '0xc5C8E77B397E531B8EC06BFb0048328B30E9eCfB' -export const ETH_USD = '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612' -export const USDC_USD = '0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3' -export const USDT_USD = '0x3f3f5dF88dC9F13eac63DF89EC16ef6e7E25DdE7' diff --git a/packages/helpers/src/addresses/chainlink/avalanche.ts b/packages/helpers/src/addresses/chainlink/avalanche.ts deleted file mode 100644 index 1b9e6d27..00000000 --- a/packages/helpers/src/addresses/chainlink/avalanche.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const AVAX_USD = '0x0A77230d17318075983913bC2145DB16C7366156' -export const ETH_USD = '0x976B3D034E162d8bD72D6b9C989d545b839003b0' -export const DAI_USD = '0x51D7180edA2260cc4F6e4EebB82FEF5c3c2B8300' -export const USDC_USD = '0xF096872672F44d6EBA71458D74fe67F9a77a23B9' -export const USDT_USD = '0xEBE676ee90Fe1112671f19b6B7459bC678B67e8a' diff --git a/packages/helpers/src/addresses/chainlink/base.ts b/packages/helpers/src/addresses/chainlink/base.ts deleted file mode 100644 index a520b41b..00000000 --- a/packages/helpers/src/addresses/chainlink/base.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_USD = '0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70' -export const DAI_USD = '0x591e79239a7d679378eC8c847e5038150364C78F' -export const USDC_USD = '0x7e860098F58bBFC8648a4311b374B1D669a2bc6B' -export const USDT_USD = '0xf19d560eB8d2ADf07BD6D13ed03e1D11215721F9' diff --git a/packages/helpers/src/addresses/chainlink/bsc.ts b/packages/helpers/src/addresses/chainlink/bsc.ts deleted file mode 100644 index e1edab08..00000000 --- a/packages/helpers/src/addresses/chainlink/bsc.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const BNB_USD = '0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE' -export const ETH_USD = '0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e' -export const DAI_USD = '0x132d3C0B1D2cEa0BC552588063bdBb210FDeecfA' -export const USDC_USD = '0x51597f405303C4377E36123cBc172b13269EA163' -export const USDT_USD = '0xB97Ad0E74fa7d920791E90258A6E2085088b4320' diff --git a/packages/helpers/src/addresses/chainlink/denominations.ts b/packages/helpers/src/addresses/chainlink/denominations.ts deleted file mode 100644 index a5c24343..00000000 --- a/packages/helpers/src/addresses/chainlink/denominations.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USD = '0x0000000000000000000000000000000000000348' diff --git a/packages/helpers/src/addresses/chainlink/fantom.ts b/packages/helpers/src/addresses/chainlink/fantom.ts deleted file mode 100644 index 64ea4034..00000000 --- a/packages/helpers/src/addresses/chainlink/fantom.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const FTM_USD = '0xf4766552D15AE4d256Ad41B6cf2933482B0680dc' -export const ETH_USD = '0x11DdD3d147E5b83D01cee7070027092397d63658' -export const DAI_USD = '0x91d5DEFAFfE2854C7D02F50c80FA1fdc8A721e52' -export const USDC_USD = '0x2553f4eeb82d5A26427b8d1106C51499CBa5D99c' -export const USDT_USD = '0xF64b636c5dFe1d3555A847341cDC449f612307d0' diff --git a/packages/helpers/src/addresses/chainlink/gnosis.ts b/packages/helpers/src/addresses/chainlink/gnosis.ts deleted file mode 100644 index 56127e3b..00000000 --- a/packages/helpers/src/addresses/chainlink/gnosis.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const DAI_USD = '0x678df3415fc31947dA4324eC63212874be5a82f8' -export const ETH_USD = '0xa767f745331D267c7751297D982b050c93985627' -export const USDC_USD = '0x26C31ac71010aF62E6B486D1132E266D6298857D' -export const USDT_USD = '0x68811D7DF835B1c33e6EEae8E7C141eF48d48cc7' diff --git a/packages/helpers/src/addresses/chainlink/goerli.ts b/packages/helpers/src/addresses/chainlink/goerli.ts deleted file mode 100644 index 7a837211..00000000 --- a/packages/helpers/src/addresses/chainlink/goerli.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_USD = '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e' diff --git a/packages/helpers/src/addresses/chainlink/index.ts b/packages/helpers/src/addresses/chainlink/index.ts deleted file mode 100644 index 31fecf39..00000000 --- a/packages/helpers/src/addresses/chainlink/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * as arbitrum from './arbitrum' -export * as avalanche from './avalanche' -export * as bsc from './bsc' -export * as denominations from './denominations' -export * as fantom from './fantom' -export * as gnosis from './gnosis' -export * as goerli from './goerli' -export * as mainnet from './mainnet' -export * as mumbai from './mumbai' -export * as optimism from './optimism' -export * as polygon from './polygon' diff --git a/packages/helpers/src/addresses/chainlink/mainnet.ts b/packages/helpers/src/addresses/chainlink/mainnet.ts deleted file mode 100644 index 4e8bb3ac..00000000 --- a/packages/helpers/src/addresses/chainlink/mainnet.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USDC_ETH = '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4' -export const USDT_ETH = '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46' -export const DAI_ETH = '0x773616E4d11A78F511299002da57A0a94577F1f4' -export const MANA_ETH = '0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9' -export const BAL_ETH = '0xC1438AA3823A6Ba0C159CfA8D98dF5A994bA120b' -export const ETH_USD = '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419' diff --git a/packages/helpers/src/addresses/chainlink/mumbai.ts b/packages/helpers/src/addresses/chainlink/mumbai.ts deleted file mode 100644 index 3fe0fde1..00000000 --- a/packages/helpers/src/addresses/chainlink/mumbai.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const MATIC_USD = '0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada' diff --git a/packages/helpers/src/addresses/chainlink/optimism.ts b/packages/helpers/src/addresses/chainlink/optimism.ts deleted file mode 100644 index 6c96f185..00000000 --- a/packages/helpers/src/addresses/chainlink/optimism.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const DAI_USD = '0x8dBa75e83DA73cc766A7e5a0ee71F656BAb470d6' -export const ETH_USD = '0x13e3Ee699D1909E989722E753853AE30b17e08c5' -export const USDC_USD = '0x16a9FA2FDa030272Ce99B29CF780dFA30361E0f3' -export const USDT_USD = '0xECef79E109e997bCA29c1c0897ec9d7b03647F5E' diff --git a/packages/helpers/src/addresses/chainlink/polygon.ts b/packages/helpers/src/addresses/chainlink/polygon.ts deleted file mode 100644 index ed23acd6..00000000 --- a/packages/helpers/src/addresses/chainlink/polygon.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const DAI_USD = '0x4746DeC9e833A82EC7C2C1356372CcF2cfcD2F3D' -export const ETH_USD = '0xF9680D99D6C9589e2a93a78A04A279e509205945' -export const USDC_USD = '0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7' -export const USDT_USD = '0x0A6513e40db6EB1b165753AD52E80663aeA50545' -export const MATIC_USD = '0xAB594600376Ec9fD91F8e885dADF0CE036862dE0' diff --git a/packages/helpers/src/addresses/hop/arbitrum.ts b/packages/helpers/src/addresses/hop/arbitrum.ts deleted file mode 100644 index 009790dd..00000000 --- a/packages/helpers/src/addresses/hop/arbitrum.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_AMM = '0x33ceb27b39d2Bb7D2e61F7564d3Df29344020417' -export const DAI_AMM = '0xe7F40BF16AB09f4a6906Ac2CAA4094aD2dA48Cc2' -export const USDC_AMM = '0xe22D2beDb3Eca35E6397e0C6D62857094aA26F52' -export const USDT_AMM = '0xCB0a4177E0A60247C0ad18Be87f8eDfF6DD30283' diff --git a/packages/helpers/src/addresses/hop/base.ts b/packages/helpers/src/addresses/hop/base.ts deleted file mode 100644 index 5d6b15c7..00000000 --- a/packages/helpers/src/addresses/hop/base.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_AMM = '0x10541b07d8Ad2647Dc6cD67abd4c03575dade261' -export const USDC_AMM = '0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F' diff --git a/packages/helpers/src/addresses/hop/gnosis.ts b/packages/helpers/src/addresses/hop/gnosis.ts deleted file mode 100644 index 6babdd95..00000000 --- a/packages/helpers/src/addresses/hop/gnosis.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH_AMM = '0x03D7f750777eC48d39D080b020D83Eb2CB4e3547' -export const DAI_AMM = '0x6C928f435d1F3329bABb42d69CCF043e3900EcF1' -export const USDC_AMM = '0x76b22b8C1079A44F1211D867D68b1eda76a635A7' -export const USDT_AMM = '0x49094a1B3463c4e2E82ca41b8e6A023bdd6E222f' diff --git a/packages/helpers/src/addresses/hop/goerli.ts b/packages/helpers/src/addresses/hop/goerli.ts deleted file mode 100644 index 389e6ab2..00000000 --- a/packages/helpers/src/addresses/hop/goerli.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_BRIDGE = '0xC8A4FB931e8D77df8497790381CA7d228E68a41b' -export const USDC_BRIDGE = '0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F' diff --git a/packages/helpers/src/addresses/hop/index.ts b/packages/helpers/src/addresses/hop/index.ts deleted file mode 100644 index c9eca721..00000000 --- a/packages/helpers/src/addresses/hop/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * as arbitrum from './arbitrum' -export * as base from './base' -export * as gnosis from './gnosis' -export * as goerli from './goerli' -export * as mainnet from './mainnet' -export * as mumbai from './mumbai' -export * as optimism from './optimism' -export * as polygon from './polygon' diff --git a/packages/helpers/src/addresses/hop/mainnet.ts b/packages/helpers/src/addresses/hop/mainnet.ts deleted file mode 100644 index 8b63cf6a..00000000 --- a/packages/helpers/src/addresses/hop/mainnet.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_BRIDGE = '0xb8901acB165ed027E32754E0FFe830802919727f' -export const DAI_BRIDGE = '0x3d4Cc8A61c7528Fd86C55cfe061a78dCBA48EDd1' -export const USDC_BRIDGE = '0x3666f603Cc164936C1b87e207F36BEBa4AC5f18a' -export const USDT_BRIDGE = '0x3E4a3a4796d16c0Cd582C382691998f7c06420B6' diff --git a/packages/helpers/src/addresses/hop/mumbai.ts b/packages/helpers/src/addresses/hop/mumbai.ts deleted file mode 100644 index e3773fc3..00000000 --- a/packages/helpers/src/addresses/hop/mumbai.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USDC_AMM = '0xa81D244A1814468C734E5b4101F7b9c0c577a8fC' -export const WETH_AMM = '0x0e0E3d2C5c292161999474247956EF542caBF8dd' diff --git a/packages/helpers/src/addresses/hop/optimism.ts b/packages/helpers/src/addresses/hop/optimism.ts deleted file mode 100644 index b95a75e7..00000000 --- a/packages/helpers/src/addresses/hop/optimism.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_AMM = '0x86cA30bEF97fB651b8d866D45503684b90cb3312' -export const DAI_AMM = '0xb3C68a491608952Cb1257FC9909a537a0173b63B' -export const USDC_AMM = '0x2ad09850b0CA4c7c1B33f5AcD6cBAbCaB5d6e796' -export const USDT_AMM = '0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F' diff --git a/packages/helpers/src/addresses/hop/polygon.ts b/packages/helpers/src/addresses/hop/polygon.ts deleted file mode 100644 index 5a4801e5..00000000 --- a/packages/helpers/src/addresses/hop/polygon.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ETH_AMM = '0xc315239cFb05F1E130E7E28E603CEa4C014c57f0' -export const DAI_AMM = '0x28529fec439cfF6d7D1D5917e956dEE62Cd3BE5c' -export const USDC_AMM = '0x76b22b8C1079A44F1211D867D68b1eda76a635A7' -export const USDT_AMM = '0x8741Ba6225A6BF91f9D73531A98A89807857a2B3' diff --git a/packages/helpers/src/addresses/index.ts b/packages/helpers/src/addresses/index.ts deleted file mode 100644 index a62c699b..00000000 --- a/packages/helpers/src/addresses/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * as chainlink from './chainlink' -export * as hop from './hop' -export * as protocols from './protocols' -export * as tokens from './tokens' diff --git a/packages/helpers/src/addresses/protocols/arbitrum.ts b/packages/helpers/src/addresses/protocols/arbitrum.ts deleted file mode 100644 index b58f7e07..00000000 --- a/packages/helpers/src/addresses/protocols/arbitrum.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const UNISWAP_V3_ROUTER = '0xE592427A0AEce92De3Edee1F18E0157C05861564' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0xe432150cce91c13a887f7D836923d5597adD8E31' -export const CONNEXT_ENTRYPOINT = '0xEE9deC2712cCE65174B561151701Bf54b99C24C8' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/aurora.ts b/packages/helpers/src/addresses/protocols/aurora.ts deleted file mode 100644 index 3911e342..00000000 --- a/packages/helpers/src/addresses/protocols/aurora.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' diff --git a/packages/helpers/src/addresses/protocols/avalanche.ts b/packages/helpers/src/addresses/protocols/avalanche.ts deleted file mode 100644 index d7753fd7..00000000 --- a/packages/helpers/src/addresses/protocols/avalanche.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const SUSHI_SWAP_ROUTER = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0x5029C0EFf6C34351a0CEc334542cDb22c7928f78' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/base.ts b/packages/helpers/src/addresses/protocols/base.ts deleted file mode 100644 index 0177da57..00000000 --- a/packages/helpers/src/addresses/protocols/base.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' -export const PARASWAP_V5_AUGUSTUS = '0x59C7C832e96D2568bea6db468C1aAdcbbDa08A52' - -export const AXELAR_GATEWAY = '0xe432150cce91c13a887f7D836923d5597adD8E31' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/bsc.ts b/packages/helpers/src/addresses/protocols/bsc.ts deleted file mode 100644 index 00a5682f..00000000 --- a/packages/helpers/src/addresses/protocols/bsc.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const SUSHI_SWAP_ROUTER = '0xc35dadb65012ec5796536bd9864ed8773abc74c4' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0x304acf330bbE08d1e512eefaa92F6a57871fD895' -export const CONNEXT_ENTRYPOINT = '0xCd401c10afa37d641d2F594852DA94C700e4F2CE' diff --git a/packages/helpers/src/addresses/protocols/fantom.ts b/packages/helpers/src/addresses/protocols/fantom.ts deleted file mode 100644 index cc98b6e5..00000000 --- a/packages/helpers/src/addresses/protocols/fantom.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const SUSHI_SWAP_ROUTER = '0xc35dadb65012ec5796536bd9864ed8773abc74c4' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0x304acf330bbE08d1e512eefaa92F6a57871fD895' diff --git a/packages/helpers/src/addresses/protocols/gnosis.ts b/packages/helpers/src/addresses/protocols/gnosis.ts deleted file mode 100644 index e86df542..00000000 --- a/packages/helpers/src/addresses/protocols/gnosis.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const HONEY_SWAP_ROUTER = '0x1c232f01118cb8b424793ae03f870aa7d0ac7f77' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const CONNEXT_ENTRYPOINT = '0x5bB83e95f63217CDa6aE3D181BA580Ef377D2109' diff --git a/packages/helpers/src/addresses/protocols/index.ts b/packages/helpers/src/addresses/protocols/index.ts deleted file mode 100644 index 830065d7..00000000 --- a/packages/helpers/src/addresses/protocols/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export * as arbitrum from './arbitrum' -export * as aurora from './aurora' -export * as avalanche from './avalanche' -export * as base from './base' -export * as bsc from './bsc' -export * as fantom from './fantom' -export * as gnosis from './gnosis' -export * as mainnet from './mainnet' -export * as optimism from './optimism' -export * as polygon from './polygon' -export * as zkevm from './zkevm' -export * as zksync from './zksync' diff --git a/packages/helpers/src/addresses/protocols/mainnet.ts b/packages/helpers/src/addresses/protocols/mainnet.ts deleted file mode 100644 index 219de5f1..00000000 --- a/packages/helpers/src/addresses/protocols/mainnet.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const UNISWAP_V2_ROUTER = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D' -export const UNISWAP_V3_ROUTER = '0xE592427A0AEce92De3Edee1F18E0157C05861564' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0x4F4495243837681061C4743b74B3eEdf548D56A5' -export const CONNEXT_ENTRYPOINT = '0x8898B472C54c31894e3B9bb83cEA802a5d0e63C6' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/optimism.ts b/packages/helpers/src/addresses/protocols/optimism.ts deleted file mode 100644 index 71eb415a..00000000 --- a/packages/helpers/src/addresses/protocols/optimism.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const UNISWAP_V3_ROUTER = '0xE592427A0AEce92De3Edee1F18E0157C05861564' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const CONNEXT_ENTRYPOINT = '0x8f7492DE823025b4CfaAB1D34c58963F2af5DEDA' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/polygon.ts b/packages/helpers/src/addresses/protocols/polygon.ts deleted file mode 100644 index 24c0afde..00000000 --- a/packages/helpers/src/addresses/protocols/polygon.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const QUICK_SWAP_ROUTER = '0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff' -export const UNISWAP_V3_ROUTER = '0xE592427A0AEce92De3Edee1F18E0157C05861564' -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' - -export const AXELAR_GATEWAY = '0x6f015F16De9fC8791b234eF68D486d2bF203FBA8' -export const CONNEXT_ENTRYPOINT = '0x11984dc4465481512eb5b777E44061C158CF2259' -export const WORMHOLE_CIRCLE_RELAYER = '0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2' diff --git a/packages/helpers/src/addresses/protocols/zkevm.ts b/packages/helpers/src/addresses/protocols/zkevm.ts deleted file mode 100644 index 64d500e9..00000000 --- a/packages/helpers/src/addresses/protocols/zkevm.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const BALANCER_V2_VAULT = '0xBA12222222228d8Ba445958a75a0704d566BF2C8' -export const PARASWAP_V5_AUGUSTUS = '0xb83b554730d29ce4cb55bb42206c3e2c03e4a40a' diff --git a/packages/helpers/src/addresses/protocols/zksync.ts b/packages/helpers/src/addresses/protocols/zksync.ts deleted file mode 100644 index 3911e342..00000000 --- a/packages/helpers/src/addresses/protocols/zksync.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const ONE_INCH_V5_ROUTER = '0x1111111254EEB25477B68fb85Ed929f73A960582' diff --git a/packages/helpers/src/addresses/tokens/arbitrum.ts b/packages/helpers/src/addresses/tokens/arbitrum.ts deleted file mode 100644 index 2431341c..00000000 --- a/packages/helpers/src/addresses/tokens/arbitrum.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1' -export const DAI = '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1' -export const USDCe = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' -export const USDC = '0xaf88d065e77c8cc2239327c5edb3a432268e5831' -export const USDT = '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9' diff --git a/packages/helpers/src/addresses/tokens/aurora.ts b/packages/helpers/src/addresses/tokens/aurora.ts deleted file mode 100644 index 98d3b9ac..00000000 --- a/packages/helpers/src/addresses/tokens/aurora.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB' -export const USDCe = '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802' -export const USDT = '0x4988a896b1227218e4A686fdE5EabdcAbd91571f' -export const DAI = '0xe3520349F477A5F6EB06107066048508498A291b' diff --git a/packages/helpers/src/addresses/tokens/avalanche.ts b/packages/helpers/src/addresses/tokens/avalanche.ts deleted file mode 100644 index cacaaf31..00000000 --- a/packages/helpers/src/addresses/tokens/avalanche.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WAVAX = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7' -export const WETH = '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB' -export const DAI = '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70' -export const USDC = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' -export const USDT = '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7' diff --git a/packages/helpers/src/addresses/tokens/base.ts b/packages/helpers/src/addresses/tokens/base.ts deleted file mode 100644 index 9d674972..00000000 --- a/packages/helpers/src/addresses/tokens/base.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0x4200000000000000000000000000000000000006' -export const DAI = '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb' -export const USDC = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' diff --git a/packages/helpers/src/addresses/tokens/bsc.ts b/packages/helpers/src/addresses/tokens/bsc.ts deleted file mode 100644 index 344389bf..00000000 --- a/packages/helpers/src/addresses/tokens/bsc.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WBNB = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' -export const WETH = '0x2170Ed0880ac9A755fd29B2688956BD959F933F8' -export const DAI = '0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3' -export const USDCe = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' -export const USDT = '0x55d398326f99059ff775485246999027b3197955' -export const PSP = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5' diff --git a/packages/helpers/src/addresses/tokens/fantom.ts b/packages/helpers/src/addresses/tokens/fantom.ts deleted file mode 100644 index 97f67bba..00000000 --- a/packages/helpers/src/addresses/tokens/fantom.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WFTM = '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83' -export const WETH = '0x74b23882a30290451A17c44f4F05243b6b58C76d' -export const DAI = '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E' -export const USDCe = '0x28a92dde19d9989f39a49905d7c9c2fac7799bdf' -export const USDT = '0x049d68029688eabf473097a2fc38ef61633a3c7a' -export const PSP = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5' diff --git a/packages/helpers/src/addresses/tokens/gnosis.ts b/packages/helpers/src/addresses/tokens/gnosis.ts deleted file mode 100644 index cbc293d7..00000000 --- a/packages/helpers/src/addresses/tokens/gnosis.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WXDAI = '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d' -export const WETH = '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1' -export const USDC = '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' -export const USDT = '0x4ECaBa5870353805a9F068101A40E0f32ed605C6' diff --git a/packages/helpers/src/addresses/tokens/goerli.ts b/packages/helpers/src/addresses/tokens/goerli.ts deleted file mode 100644 index b96e84b9..00000000 --- a/packages/helpers/src/addresses/tokens/goerli.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USDC = '0x98339D8C260052B7ad81c28c16C0b98420f2B46a' -export const WETH = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6' diff --git a/packages/helpers/src/addresses/tokens/index.ts b/packages/helpers/src/addresses/tokens/index.ts deleted file mode 100644 index 58f0ad4c..00000000 --- a/packages/helpers/src/addresses/tokens/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * as arbitrum from './arbitrum' -export * as aurora from './aurora' -export * as avalanche from './avalanche' -export * as base from './base' -export * as bsc from './bsc' -export * as fantom from './fantom' -export * as gnosis from './gnosis' -export * as goerli from './goerli' -export * as mainnet from './mainnet' -export * as mumbai from './mumbai' -export * as optimism from './optimism' -export * as polygon from './polygon' -export * as zkevm from './zkevm' -export * as zksync from './zksync' diff --git a/packages/helpers/src/addresses/tokens/mainnet.ts b/packages/helpers/src/addresses/tokens/mainnet.ts deleted file mode 100644 index 4503c4e8..00000000 --- a/packages/helpers/src/addresses/tokens/mainnet.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' -export const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7' -export const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' -export const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F' -export const MANA = '0x0F5D2fB29fb7d3CFeE444a200298f468908cC942' -export const PSP = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5' -export const BAL = '0xba100000625a3754423978a60c9317c58a424e3D' -export const AURA_BAL = '0x616e8bfa43f920657b3497dbf40d6b1a02d4608d' diff --git a/packages/helpers/src/addresses/tokens/mumbai.ts b/packages/helpers/src/addresses/tokens/mumbai.ts deleted file mode 100644 index 9300b59f..00000000 --- a/packages/helpers/src/addresses/tokens/mumbai.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const USDC = '0x6D4dd09982853F08d9966aC3cA4Eb5885F16f2b2' -export const WETH = '0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa' -export const WMATIC = '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889' diff --git a/packages/helpers/src/addresses/tokens/optimism.ts b/packages/helpers/src/addresses/tokens/optimism.ts deleted file mode 100644 index d5872e0b..00000000 --- a/packages/helpers/src/addresses/tokens/optimism.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0x4200000000000000000000000000000000000006' -export const DAI = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' -export const USDC = '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85' -export const USDCe = '0x7F5c764cBc14f9669B88837ca1490cCa17c31607' -export const USDT = '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58' -export const BAL = '0xfe8b128ba8c78aabc59d4c64cee7ff28e9379921' diff --git a/packages/helpers/src/addresses/tokens/polygon.ts b/packages/helpers/src/addresses/tokens/polygon.ts deleted file mode 100644 index 4fb5f167..00000000 --- a/packages/helpers/src/addresses/tokens/polygon.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WMATIC = '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270' -export const WETH = '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619' -export const USDC = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' -export const USDCe = '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' -export const USDT = '0xc2132d05d31c914a87c6611c10748aeb04b58e8f' -export const DAI = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' -export const PSP = '0x42d61d766b85431666b39b89c43011f24451bff6' diff --git a/packages/helpers/src/addresses/tokens/zkevm.ts b/packages/helpers/src/addresses/tokens/zkevm.ts deleted file mode 100644 index 05f9c744..00000000 --- a/packages/helpers/src/addresses/tokens/zkevm.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9' -export const DAI = '0xc5015b9d9161dca7e18e32f6f25c4ad850731fd4' -export const USDCe = '0x37eAA0eF3549a5Bb7D431be78a3D99BD360d19e5' -export const USDT = '0x1e4a5963abfd975d8c9021ce480b42188849d41d' diff --git a/packages/helpers/src/addresses/tokens/zksync.ts b/packages/helpers/src/addresses/tokens/zksync.ts deleted file mode 100644 index 8f1553af..00000000 --- a/packages/helpers/src/addresses/tokens/zksync.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable no-secrets/no-secrets */ - -export const WETH = '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91' -export const USDCe = '0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4' -export const USDT = '0x493257fD37EDB34451f62EDf8D2a0C418852bA4C' diff --git a/packages/helpers/src/asserts.ts b/packages/helpers/src/asserts.ts deleted file mode 100644 index fbb69401..00000000 --- a/packages/helpers/src/asserts.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { expect } from 'chai' -import { BigNumber, Contract, ContractTransaction } from 'ethers' -import { Interface, LogDescription } from 'ethers/lib/utils' - -import { pct } from './numbers' - -// Ported from @openzeppelin/test-helpers to use with Ethers. The Test Helpers don't -// yet have Typescript typings, so we're being lax about them here. -// See https://github.com/OpenZeppelin/openzeppelin-test-helpers/issues/122 - -/* eslint-disable @typescript-eslint/no-explicit-any */ - -export function assertAlmostEqual(actual: BigNumber, expected: BigNumber, error: number): void { - const abs = pct(expected, error) - expect(actual).to.be.at.least(expected.sub(abs)) - expect(actual).to.be.at.most(expected.add(abs)) -} - -export async function assertEvent(tx: ContractTransaction, eventName: string, eventArgs = {}): Promise { - const receipt = await tx.wait() - - if (receipt.events == undefined) { - throw new Error('No events found in receipt') - } - - const events = receipt.events.filter((e) => e.event === eventName) - expect(events.length > 0).to.equal(true, `No '${eventName}' events found`) - - const exceptions: Array = [] - const event = events.find(function (e) { - for (const [k, v] of Object.entries(eventArgs)) { - try { - if (e.args == undefined) { - throw new Error('Event has no arguments') - } - - contains(e.args, k, v) - } catch (error) { - exceptions.push(error as string) - return false - } - } - return true - }) - - if (event === undefined) { - // Each event entry may have failed to match for different reasons, - // throw the first one - throw exceptions[0] - } - - return event -} - -export async function assertIndirectEvent( - tx: ContractTransaction, - emitter: Interface, - eventName: string, - eventArgs = {} -): Promise { - const receipt = await tx.wait() - const decodedEvents = receipt.logs - .map((log) => { - try { - return emitter.parseLog(log) - } catch { - return undefined - } - }) - .filter((e): e is LogDescription => e !== undefined) - - const expectedEvents = decodedEvents.filter((event) => event.name === eventName) - expect(expectedEvents.length > 0).to.equal(true, `No '${eventName}' events found`) - - const exceptions: Array = [] - const event = expectedEvents.find(function (e) { - for (const [k, v] of Object.entries(eventArgs)) { - try { - if (e.args == undefined) { - throw new Error('Event has no arguments') - } - - contains(e.args, k, v) - } catch (error) { - exceptions.push(error as string) - return false - } - } - return true - }) - - if (event === undefined) { - // Each event entry may have failed to match for different reasons, - // throw the first one - throw exceptions[0] - } - - return event -} - -export async function assertNoEvent(tx: ContractTransaction, eventName: string): Promise { - const receipt = await tx.wait() - if (receipt.events != undefined) { - const events = receipt.events.filter((e) => e.event === eventName) - expect(events.length > 0).to.equal(false, `'${eventName}' event found`) - } -} - -export async function assertNoIndirectEvent( - tx: ContractTransaction, - emitter: Interface, - eventName: string -): Promise { - const receipt = await tx.wait() - const decodedEvents = receipt.logs - .map((log) => { - try { - return emitter.parseLog(log) - } catch { - return undefined - } - }) - .filter((e): e is LogDescription => e !== undefined) - - const events = decodedEvents.filter((event) => event.name === eventName) - expect(events.length > 0).to.equal(false, `'${eventName}' event found`) -} - -function contains(args: { [key: string]: any | undefined }, key: string, value: any) { - expect(key in args).to.equal(true, `Event argument '${key}' not found`) - - if (value === null) { - expect(args[key]).to.equal(null, `expected event argument '${key}' to be null but got ${args[key]}`) - } else if (BigNumber.isBigNumber(args[key]) || BigNumber.isBigNumber(value)) { - const actual = BigNumber.isBigNumber(args[key]) ? args[key].toString() : args[key] - const expected = BigNumber.isBigNumber(value) ? value.toString() : value - - expect(args[key]).to.equal(value, `expected event argument '${key}' to have value ${expected} but got ${actual}`) - } else { - const expected = typeof args[key] === 'string' && typeof value === 'object' && value.address ? value.address : value - expect(args[key]).to.be.deep.equal( - expected, - `expected event argument '${key}' to have value ${value} but got ${args[key]}` - ) - } -} - -export type NAry = N | N[] - -export type PermissionAssertion = { - name: string - roles: string[] - account: NAry<{ address: string } | string> -} - -export async function assertPermissions(target: Contract, assertions: PermissionAssertion[]): Promise { - for (const assertion of assertions) { - const accounts = Array.isArray(assertion.account) ? assertion.account : [assertion.account] - for (const account of accounts) { - const address = typeof account === 'string' ? account : account.address - for (const fn in target.interface.functions) { - const fnName = target.interface.functions[fn].name - const role = target.interface.getSighash(fnName) - const should = assertion.roles.includes(fnName) - const message = `expected "${assertion.name}" ${address} ${should ? 'to' : 'not to'} have "${fn}" rights` - expect(await target.isAuthorized(address, role)).to.be.equal(should, message) - } - } - } -} diff --git a/packages/helpers/src/blocks.ts b/packages/helpers/src/blocks.ts deleted file mode 100644 index a25e2a38..00000000 --- a/packages/helpers/src/blocks.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { BigNumber } from 'ethers' - -import { bn } from './numbers' - -export const incrementBlocks = async (blocks: number): Promise => { - const { ethers } = await import('hardhat') - for (let i = 0; i < blocks; i++) await ethers.provider.send('evm_mine', []) -} - -export const currentBlock = async (): Promise<{ number: number; timestamp: number }> => { - const { network } = await import('hardhat') - return network.provider.send('eth_getBlockByNumber', ['latest', true]) -} - -export const currentBlockNumber = async (): Promise => { - const { number } = await currentBlock() - return bn(number) -} diff --git a/packages/helpers/src/constants.ts b/packages/helpers/src/constants.ts deleted file mode 100644 index e9ab4617..00000000 --- a/packages/helpers/src/constants.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BigNumber } from 'ethers' - -import { bn } from './numbers' - -export const maxUint = (e: number): BigNumber => bn(2).pow(e).sub(1) - -export const MAX_UINT256: BigNumber = maxUint(256) - -export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' -export const ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF' -export const NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' - -export const ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000' -export const ONES_BYTES32 = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' diff --git a/packages/helpers/src/contracts.ts b/packages/helpers/src/contracts.ts deleted file mode 100644 index fa1c3404..00000000 --- a/packages/helpers/src/contracts.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address' -import { Contract, ContractFactory } from 'ethers' -import { getContractAddress } from 'ethers/lib/utils' -import { Artifacts } from 'hardhat/internal/artifacts' -import { Artifact, LinkReferences } from 'hardhat/types' -import path from 'path' - -import { getSigner } from './signers' - -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ - -export type Libraries = { [key: string]: string } - -export type ArtifactLike = { abi: any; bytecode: string; linkReferences?: LinkReferences } - -const MINIMAL_PROXY_BYTECODE = `0x3d602d80600a3d3981f3363d3d373d3d3d363d73_IMP_5af43d82803e903d91602b57fd5bf3` - -export async function deploy( - nameOrArtifact: string | ArtifactLike, - args: Array = [], - from?: SignerWithAddress, - libraries?: Libraries -): Promise { - if (!args) args = [] - if (!from) from = await getSigner() - const factory = await getFactoryContract(nameOrArtifact, libraries) - const instance = await factory.connect(from).deploy(...args) - return instance.deployed() -} - -export async function deployProxy( - nameOrArtifact: string | ArtifactLike, - args: Array = [], - initArgs: Array = [], - initName = 'initialize', - from?: SignerWithAddress, - libraries?: Libraries -): Promise { - const implementation = await deploy(nameOrArtifact, args, from, libraries) - const proxyBytecode = MINIMAL_PROXY_BYTECODE.replace('_IMP_', implementation.address.slice(2)) - - if (!from) from = await getSigner() - const addressQuery = { from: from.address, nonce: await from.getTransactionCount() } - await from.sendTransaction({ data: proxyBytecode }) - const instance = await instanceAt(nameOrArtifact, await getContractAddress(addressQuery)) - await instance[initName](...initArgs) - return instance -} - -export async function getCreationCode( - nameOrArtifact: string | ArtifactLike, - args: Array = [], - libraries?: Libraries -): Promise { - if (!args) args = [] - const contractFactory = await getFactoryContract(nameOrArtifact, libraries) - const transaction = await contractFactory.getDeployTransaction(...args) - return transaction.data?.toString() || '0x' -} - -async function getFactoryContract( - nameOrArtifact: string | ArtifactLike, - libraries: Libraries | undefined -): Promise { - const artifact = typeof nameOrArtifact === 'string' ? await getArtifact(nameOrArtifact) : nameOrArtifact - if (libraries !== undefined) artifact.bytecode = linkBytecode(artifact, libraries) - return getFactoryContractForBytecode(nameOrArtifact, artifact.bytecode) -} - -async function getFactoryContractForBytecode( - nameOrArtifact: string | ArtifactLike, - bytecode: string -): Promise { - const artifact = typeof nameOrArtifact === 'string' ? await getArtifact(nameOrArtifact) : nameOrArtifact - const { ethers } = await import('hardhat') - return ethers.getContractFactory(artifact.abi, bytecode) -} - -export async function instanceAt(nameOrArtifact: string | any, address: string): Promise { - const { ethers } = await import('hardhat') - const artifact = typeof nameOrArtifact === 'string' ? await getArtifact(nameOrArtifact) : nameOrArtifact - return ethers.getContractAt(artifact.abi, address) -} - -export async function getArtifact(contractName: string): Promise { - const artifactsPath = !contractName.includes('/') - ? path.resolve('./artifacts') - : path.dirname(require.resolve(`${contractName}.json`)) - const artifacts = new Artifacts(artifactsPath) - return artifacts.readArtifact(contractName.split('/').slice(-1)[0]) -} - -export function linkBytecode(artifact: ArtifactLike, libraries: Libraries): string { - let bytecode = artifact.bytecode.replace('0x', '') - for (const [, fileReferences] of Object.entries(artifact.linkReferences || {})) { - for (const [library, fixups] of Object.entries(fileReferences)) { - const address = libraries[library] - if (address === undefined) continue - for (const fixup of fixups) { - const pre = bytecode.substring(0, fixup.start * 2) - const post = bytecode.substring((fixup.start + fixup.length) * 2) - bytecode = pre + address.replace('0x', '') + post - } - } - } - return `0x${bytecode}` -} diff --git a/packages/helpers/src/mocks.ts b/packages/helpers/src/mocks.ts deleted file mode 100644 index f5366cdd..00000000 --- a/packages/helpers/src/mocks.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Contract } from 'ethers' - -import { deploy } from './contracts' -import { BigNumberish } from './numbers' - -/* eslint-disable no-secrets/no-secrets */ - -export async function deployWrappedNativeTokenMock(): Promise { - return deploy('@mimic-fi/v3-helpers/artifacts/contracts/mocks/WrappedNativeTokenMock.sol/WrappedNativeTokenMock') -} - -export async function deployTokenMock(symbol: string, decimals = 18): Promise { - return deploy('@mimic-fi/v3-helpers/artifacts/contracts/mocks/TokenMock.sol/TokenMock', [symbol, decimals]) -} - -export async function deployFeedMock(price: BigNumberish, decimals = 18): Promise { - return deploy('@mimic-fi/v3-helpers/artifacts/contracts/mocks/FeedMock.sol/FeedMock', [price, decimals]) -} diff --git a/packages/helpers/src/numbers.ts b/packages/helpers/src/numbers.ts deleted file mode 100644 index d6ea0333..00000000 --- a/packages/helpers/src/numbers.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Decimal } from 'decimal.js' -import { BigNumber } from 'ethers' - -const SCALING_FACTOR = 1e18 - -export type BigNumberish = string | number | BigNumber - -export const decimal = (x: BigNumberish | Decimal): Decimal => new Decimal(x.toString()) - -export const fp = (x: number | string | Decimal): BigNumber => bn(decimal(x).mul(SCALING_FACTOR)) - -export const toWBTC = (x: number | string | Decimal): BigNumber => fp(x).div(1e10) - -export const toUSDC = (x: number | string | Decimal): BigNumber => fp(x).div(1e12) - -export const toUSDT = toUSDC - -export const pct = (x: BigNumber, p: number): BigNumber => x.mul(fp(p)).div(fp(1)) - -export const bn = (x: BigNumberish | Decimal): BigNumber => { - if (BigNumber.isBigNumber(x)) return x - const stringified = parseScientific(x.toString()) - const integer = stringified.split('.')[0] - return BigNumber.from(integer) -} - -function parseScientific(num: string): string { - // If the number is not in scientific notation return it as it is - if (!/\d+\.?\d*e[+-]*\d+/i.test(num)) return num - - // Remove the sign - const numberSign = Math.sign(Number(num)) - num = Math.abs(Number(num)).toString() - - // Parse into coefficient and exponent - const [coefficient, exponent] = num.toLowerCase().split('e') - let zeros = Math.abs(Number(exponent)) - const exponentSign = Math.sign(Number(exponent)) - const [integer, decimals] = (coefficient.indexOf('.') != -1 ? coefficient : `${coefficient}.`).split('.') - - if (exponentSign === -1) { - zeros -= integer.length - num = - zeros < 0 - ? integer.slice(0, zeros) + '.' + integer.slice(zeros) + decimals - : '0.' + '0'.repeat(zeros) + integer + decimals - } else { - if (decimals) zeros -= decimals.length - num = - zeros < 0 - ? integer + decimals.slice(0, zeros) + '.' + decimals.slice(zeros) - : integer + decimals + '0'.repeat(zeros) - } - - return numberSign < 0 ? '-' + num : num -} diff --git a/packages/helpers/src/signers.ts b/packages/helpers/src/signers.ts deleted file mode 100644 index c5ae6988..00000000 --- a/packages/helpers/src/signers.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { BigNumber } from 'ethers' - -import { getForkedNetwork } from './tests' - -const WHALES: { [key: string]: string } = { - mainnet: '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503', -} - -export async function getSigner(indexOrAddress: number | string = 0): Promise { - if (typeof indexOrAddress === 'string') { - const { ethers } = await import('hardhat') - const signer = ethers.provider.getSigner(indexOrAddress) - return SignerWithAddress.create(signer) - } else { - const signers = await getSigners() - return signers[indexOrAddress] - } -} - -export async function getSigners(size?: number, offset = 0): Promise { - const { ethers } = await import('hardhat') - const signers = await ethers.getSigners() - return size ? signers.slice(offset, offset + size) : signers -} - -export async function impersonate(address: string, balance?: BigNumber): Promise { - const { network, ethers } = await import('hardhat') - await network.provider.request({ method: 'hardhat_impersonateAccount', params: [address] }) - - if (balance) { - const rawHexBalance = ethers.utils.hexlify(balance) - const hexBalance = rawHexBalance.replace('0x0', '0x') - await network.provider.request({ method: 'hardhat_setBalance', params: [address, hexBalance] }) - } - - return getSigner(address) -} - -export async function impersonateWhale(balance?: BigNumber): Promise { - const hre = await import('hardhat') - const network = getForkedNetwork(hre) - const address = WHALES[network] - if (!address) throw Error(`Could not find whale address for network ${network}`) - return impersonate(address, balance) -} diff --git a/packages/helpers/src/tests.ts b/packages/helpers/src/tests.ts deleted file mode 100644 index c705a241..00000000 --- a/packages/helpers/src/tests.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { TASK_TEST_GET_TEST_FILES, TASK_TEST_RUN_MOCHA_TESTS } from 'hardhat/builtin-tasks/task-names' -import { HardhatNetworkConfig, HardhatRuntimeEnvironment, HttpNetworkConfig, RunSuperFunction } from 'hardhat/types' - -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ - -export async function overrideTestTask( - args: any, - hre: HardhatRuntimeEnvironment, - run: RunSuperFunction -): Promise { - const files = await hre.run(TASK_TEST_GET_TEST_FILES, { testFiles: args.testFiles }) - if (hre.network.name === 'hardhat' && args.fork) await runForkTests(args, files, hre, run) - else await runNormalTests(args, files, hre, run) -} - -async function runNormalTests( - args: any, - files: string[], - hre: HardhatRuntimeEnvironment, - run: RunSuperFunction -): Promise { - console.log('Running normal tests...') - if (args.fork) throw Error('Cannot run normal tests with a forked network') - args.testFiles = files.filter((file: string) => file.endsWith('.test.ts')) - if (args.testFiles.length == 0) return hre.run(TASK_TEST_RUN_MOCHA_TESTS, { testFiles: [] }) - - await run(args) -} - -async function runForkTests( - args: any, - files: string[], - hre: HardhatRuntimeEnvironment, - run: RunSuperFunction -): Promise { - console.log(`Running fork tests on ${args.fork}...`) - if (args.fork === 'hardhat') throw Error('Cannot fork local networks') - - args.testFiles = files.filter((file: string) => file.endsWith(`.${args.fork}.ts`) || file.endsWith(`.fork.ts`)) - if (args.testFiles.length == 0) return hre.run(TASK_TEST_RUN_MOCHA_TESTS, { testFiles: [] }) - - const forkingNetworkName = Object.keys(hre.config.networks).find((networkName) => networkName === args.fork) - if (!forkingNetworkName) throw Error(`Could not find a config for network ${args.fork} to be forked`) - - const forkingNetworkConfig = hre.config.networks[forkingNetworkName] as HttpNetworkConfig - if (!forkingNetworkConfig.url) throw Error(`Could not find a RPC url in network config for ${forkingNetworkName}`) - - if (args.chainId) hre.config.networks.hardhat.chainId = args.chainId - - await hre.network.provider.request({ - method: 'hardhat_reset', - params: [{ forking: { jsonRpcUrl: forkingNetworkConfig.url, blockNumber: args.blockNumber } }], - }) - - const config = hre.network.config as HardhatNetworkConfig - config.forking = { enabled: true, blockNumber: args.blockNumber, url: forkingNetworkConfig.url, httpHeaders: {} } - - await run(args) -} - -export function getForkedNetwork(hre: HardhatRuntimeEnvironment): string { - const config = hre.network.config as HardhatNetworkConfig - if (!config.forking || !config.forking.url) throw Error(`No forks found on network ${hre.network.name}`) - - const network = Object.entries(hre.config.networks).find(([, networkConfig]) => { - const httpNetworkConfig = networkConfig as HttpNetworkConfig - return httpNetworkConfig.url && httpNetworkConfig.url === config?.forking?.url - }) - - if (!network) throw Error(`No network found matching fork from ${config.forking.url}`) - return network[0] -} diff --git a/packages/helpers/src/time.ts b/packages/helpers/src/time.ts deleted file mode 100644 index 0b794dd2..00000000 --- a/packages/helpers/src/time.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { BigNumber } from 'ethers' - -import { currentBlock } from './blocks' -import { BigNumberish, bn } from './numbers' - -export const SECOND = 1 -export const MINUTE = SECOND * 60 -export const HOUR = MINUTE * 60 -export const DAY = HOUR * 24 -export const WEEK = DAY * 7 -export const MONTH = DAY * 30 -export const YEAR = MONTH * 12 - -export const currentTimestamp = async (): Promise => { - const { timestamp } = await currentBlock() - return bn(timestamp) -} - -export const advanceTime = async (seconds: BigNumberish): Promise => { - const { ethers } = await import('hardhat') - await ethers.provider.send('evm_increaseTime', [parseInt(seconds.toString())]) - await ethers.provider.send('evm_mine', []) -} - -export const setNextBlockTimestamp = async (timestamp: BigNumberish): Promise => { - const { ethers } = await import('hardhat') - await ethers.provider.send('evm_setNextBlockTimestamp', [parseInt(timestamp.toString())]) -} diff --git a/packages/helpers/test/contracts/math/FixedPoint.test.ts b/packages/helpers/test/contracts/math/FixedPoint.test.ts deleted file mode 100644 index 602bd902..00000000 --- a/packages/helpers/test/contracts/math/FixedPoint.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' - -import { deploy } from '../../../src/contracts' -import { fp } from '../../../src/numbers' - -describe('FixedPoint', () => { - let library: Contract - - beforeEach('deploy lib', async () => { - library = await deploy('FixedPointMock') - }) - - describe('mulUp', () => { - it('computes mul up correctly', async () => { - expect(await library.mulUp(1, 1)).to.be.equal(1) - expect(await library.mulUp(fp(2), 0)).to.be.equal(0) - expect(await library.mulUp(fp(2), fp(2))).to.be.equal(fp(4)) - expect(await library.mulUp(fp(4), fp(2))).to.be.equal(fp(8)) - }) - }) - - describe('mulDown', () => { - it('computes mul down correctly', async () => { - expect(await library.mulDown(1, 1)).to.be.equal(0) - expect(await library.mulDown(fp(2), 0)).to.be.equal(0) - expect(await library.mulDown(fp(2), fp(2))).to.be.equal(fp(4)) - expect(await library.mulDown(fp(4), fp(2))).to.be.equal(fp(8)) - }) - }) - - describe('divUp', () => { - it('computes div up correctly', async () => { - expect(await library.divUp(1, 1)).to.be.equal(fp(1)) - expect(await library.divUp(0, fp(2))).to.be.equal(0) - expect(await library.divUp(fp(2), fp(2))).to.be.equal(fp(1)) - await expect(library.divUp(fp(2), 0)).to.be.revertedWith('FixedPointZeroDivision') - }) - }) - - describe('divDown', () => { - it('computes div down correctly', async () => { - expect(await library.divDown(1, 1)).to.be.equal(fp(1)) - expect(await library.divDown(0, fp(2))).to.be.equal(0) - expect(await library.divDown(fp(2), fp(2))).to.be.equal(fp(1)) - await expect(library.divDown(fp(2), 0)).to.be.revertedWith('FixedPointZeroDivision') - }) - }) -}) diff --git a/packages/helpers/test/contracts/utils/Arrays.test.ts b/packages/helpers/test/contracts/utils/Arrays.test.ts deleted file mode 100644 index 65c501fa..00000000 --- a/packages/helpers/test/contracts/utils/Arrays.test.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' - -import { deploy } from '../../../' - -describe('Arrays', () => { - let library: Contract - - beforeEach('deploy lib', async () => { - library = await deploy('ArraysMock') - }) - - describe('from (addresses)', () => { - const ADDR_1 = '0x0000000000000000000000000000000000000001' - const ADDR_2 = '0x0000000000000000000000000000000000000002' - const ADDR_3 = '0x0000000000000000000000000000000000000003' - const ADDR_4 = '0x0000000000000000000000000000000000000004' - - it('concatenates two addresses correctly', async () => { - const result = await library.from1(ADDR_1, ADDR_2) - - expect(result.length).to.be.equal(2) - expect(result[0]).to.be.equal(ADDR_1) - expect(result[1]).to.be.equal(ADDR_2) - }) - - it('concatenates two addresses with an array correctly', async () => { - const result = await library.from2(ADDR_1, [ADDR_2, ADDR_3], ADDR_4) - - expect(result.length).to.be.equal(4) - expect(result[0]).to.be.equal(ADDR_1) - expect(result[1]).to.be.equal(ADDR_2) - expect(result[2]).to.be.equal(ADDR_3) - expect(result[3]).to.be.equal(ADDR_4) - }) - }) - - describe('from (integers)', () => { - it('concatenates correctly', async () => { - const result = await library.from3(1, []) - - expect(result.length).to.be.equal(1) - expect(result[0]).to.be.equal(1) - }) - - it('concatenates correctly', async () => { - const result = await library.from3(1, [2]) - - expect(result.length).to.be.equal(2) - expect(result[0]).to.be.equal(1) - expect(result[1]).to.be.equal(2) - }) - - it('concatenates correctly', async () => { - const result = await library.from3(1, [2, 3]) - - expect(result.length).to.be.equal(3) - expect(result[0]).to.be.equal(1) - expect(result[1]).to.be.equal(2) - expect(result[2]).to.be.equal(3) - }) - }) - - describe('from (bytes32)', () => { - const VALUE_1 = '0x0000000000000000000000000000000000000000000000000000000000000001' - const VALUE_2 = '0x0000000000000000000000000000000000000000000000000000000000000002' - const VALUE_3 = '0x0000000000000000000000000000000000000000000000000000000000000003' - - it('concatenates two addresses correctly', async () => { - const result = await library.from4(VALUE_1, [VALUE_2, VALUE_3]) - - expect(result.length).to.be.equal(3) - expect(result[0]).to.be.equal(VALUE_1) - expect(result[1]).to.be.equal(VALUE_2) - expect(result[2]).to.be.equal(VALUE_3) - }) - }) -}) diff --git a/packages/helpers/test/contracts/utils/BytesHelpers.test.ts b/packages/helpers/test/contracts/utils/BytesHelpers.test.ts deleted file mode 100644 index 6dbcf6bf..00000000 --- a/packages/helpers/test/contracts/utils/BytesHelpers.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' -import { hexlify, hexZeroPad } from 'ethers/lib/utils' - -import { deploy } from '../../../' - -describe('BytesHelpers', () => { - let library: Contract - - beforeEach('deploy lib', async () => { - library = await deploy('BytesHelpersMock') - }) - - describe('toUint256', () => { - const bytes = - '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002' - - it('extracts an uint256 correctly', async () => { - expect(await library.toUint256(bytes, 0)).to.be.equal(1) - expect(await library.toUint256(bytes, 32)).to.be.equal(2) - }) - - it('reverts if out of bounds', async () => { - await expect(library.toUint256(bytes, 64)).to.be.revertedWith('BytesOutOfBounds') - await expect(library.toUint256(bytes, 33)).to.be.revertedWith('BytesOutOfBounds') - }) - }) - - describe('concat', () => { - const array = '0xabcdef' - - it('concatenates an address with a bytes array', async () => { - const address = '0xffffffffffffffffffffffffffffffffffffffff' - const result = await library.concat1(array, address) - - expect(result).to.be.equal(array + address.slice(2)) - }) - - it('concatenates an uint24 with a bytes array', async () => { - const number = 5 - const result = await library.concat2(array, number) - - expect(result).to.be.equal(array + hexZeroPad(hexlify(number), 3).slice(2)) - }) - }) -}) diff --git a/packages/helpers/test/contracts/utils/Denominations.test.ts b/packages/helpers/test/contracts/utils/Denominations.test.ts deleted file mode 100644 index ad06a61f..00000000 --- a/packages/helpers/test/contracts/utils/Denominations.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' - -import { NATIVE_TOKEN_ADDRESS } from '../../../src/constants' -import { deploy } from '../../../src/contracts' - -describe('Denominations', () => { - let library: Contract - - beforeEach('deploy lib', async () => { - library = await deploy('DenominationsMock') - }) - - it('uses the expected native token address', async () => { - expect(await library.NATIVE_TOKEN()).to.be.equal(NATIVE_TOKEN_ADDRESS) - }) -}) diff --git a/packages/helpers/test/contracts/utils/ERC20Helpers.test.ts b/packages/helpers/test/contracts/utils/ERC20Helpers.test.ts deleted file mode 100644 index 3b7d0f59..00000000 --- a/packages/helpers/test/contracts/utils/ERC20Helpers.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' -import { ethers } from 'hardhat' - -import { NATIVE_TOKEN_ADDRESS, ZERO_ADDRESS } from '../../../src/constants' -import { deploy } from '../../../src/contracts' -import { deployTokenMock } from '../../../src/mocks' -import { getSigner } from '../../../src/signers' - -describe('ERC20Helpers', () => { - let library: Contract, someone: string - - beforeEach('deploy lib', async () => { - someone = (await getSigner(1)).address - library = await deploy('ERC20HelpersMock') - }) - - describe('balanceOf', () => { - context('when the token is the native token', () => { - const token = NATIVE_TOKEN_ADDRESS - - it('returns the account balance correctly', async () => { - expect(await library.balanceOf(token, ZERO_ADDRESS)).to.be.eq(0) - expect(await library.balanceOf(token, someone)).to.be.equal(await ethers.provider.getBalance(someone)) - }) - }) - - context('when the token is an ERC20 token', () => { - let token: Contract - - beforeEach('deploy token', async () => { - token = await deployTokenMock('TKN') - await token.mint(someone, 10) - }) - - it('returns the account balance correctly', async () => { - expect(await library.balanceOf(token.address, ZERO_ADDRESS)).to.be.eq(0) - expect(await library.balanceOf(token.address, someone)).to.be.equal(10) - }) - }) - }) - - describe('transfer', () => { - const amount = 10 - - context('when the token is the native token', () => { - const token = NATIVE_TOKEN_ADDRESS - - beforeEach('fund library', async () => { - const signer = await getSigner() - await signer.sendTransaction({ to: library.address, value: amount }) - }) - - it('transfers value correctly', async () => { - const previousLibraryBalance = await library.balanceOf(token, library.address) - const previousRecipientBalance = await library.balanceOf(token, someone) - - await library.transfer(token, someone, amount) - - const currentLibraryBalance = await library.balanceOf(token, library.address) - expect(currentLibraryBalance).to.be.equal(previousLibraryBalance.sub(amount)) - - const currentRecipientBalance = await library.balanceOf(token, someone) - expect(currentRecipientBalance).to.be.equal(previousRecipientBalance.add(amount)) - }) - }) - - context('when the token is an ERC20 token', () => { - let token: Contract - - beforeEach('deploy token', async () => { - token = await deployTokenMock('TKN') - }) - - beforeEach('fund library', async () => { - await token.mint(library.address, amount) - }) - - it('transfers tokens correctly', async () => { - const previousLibraryBalance = await library.balanceOf(token.address, library.address) - const previousRecipientBalance = await library.balanceOf(token.address, someone) - - await library.transfer(token.address, someone, amount) - - const currentLibraryBalance = await library.balanceOf(token.address, library.address) - expect(currentLibraryBalance).to.be.equal(previousLibraryBalance.sub(amount)) - - const currentRecipientBalance = await library.balanceOf(token.address, someone) - expect(currentRecipientBalance).to.be.equal(previousRecipientBalance.add(amount)) - }) - }) - }) - - describe('approve', () => { - context('when the token is the native token', () => { - const token = NATIVE_TOKEN_ADDRESS - - it('reverts', async () => { - await expect(library.approve(token, someone, 10)).to.be.reverted - }) - }) - - context('when the token is an ERC20 token', () => { - let token: Contract - - beforeEach('deploy token', async () => { - token = await deployTokenMock('TKN') - }) - - it('updates allowance correctly', async () => { - await library.approve(token.address, someone, 10) - expect(await token.allowance(library.address, someone)).to.be.equal(10) - - await library.approve(token.address, someone, 20) - expect(await token.allowance(library.address, someone)).to.be.equal(20) - - await library.approve(token.address, someone, 0) - expect(await token.allowance(library.address, someone)).to.be.equal(0) - }) - }) - }) -}) diff --git a/packages/helpers/test/contracts/utils/EnumerableMap.test.ts b/packages/helpers/test/contracts/utils/EnumerableMap.test.ts deleted file mode 100644 index 50b95157..00000000 --- a/packages/helpers/test/contracts/utils/EnumerableMap.test.ts +++ /dev/null @@ -1,321 +0,0 @@ -import { expect } from 'chai' -import { Contract } from 'ethers' - -import { assertEvent, deploy, ZERO_ADDRESS } from '../../..' - -/* eslint-disable no-secrets/no-secrets */ - -describe('EnumerableMap', () => { - let map: Contract - - const keyA = '0x8B40ECf815AC8d53aB4AD2a00248DE77296344Db' - const keyB = '0x638141Eb8905D9A55D81610f45bC2B47120059e7' - const keyC = '0x7571A57e94F046725612f786Aa9bf44ce6b56894' - - describe('AddressToUintMap', () => { - const valueA = '10' - const valueB = '20' - const valueC = '30' - - beforeEach('deploy map', async () => { - map = await deploy('EnumerableMapAddressToUintMock') - }) - - async function expectMembersMatch(keys, values) { - expect(keys.length).to.equal(values.length) - - await Promise.all(keys.map(async (key) => expect(await map.contains(key)).to.equal(true))) - - expect(await map.length()).to.be.equal(keys.length) - - expect( - (await Promise.all(keys.map((key) => map.get(key)))).map((value) => value.toString()) - ).to.have.same.members(values) - - await Promise.all( - keys.map(async (key, index) => { - const value = values[index] - const entry = await map.at(index) - expect(entry.key).to.be.equal(key) - expect(entry.value).to.be.equal(value) - }) - ) - - expect(await map.keys()).to.have.same.members(keys) - - expect((await map.values()).map((value) => value.toString())).to.have.same.members(values) - } - - it('starts empty', async () => { - expect(await map.contains(keyA)).to.equal(false) - - await expectMembersMatch([], []) - }) - - describe('set', () => { - it('adds a key', async () => { - const tx = await map.set(keyA, valueA) - await assertEvent(tx, 'OperationResult', { result: true }) - - await expectMembersMatch([keyA], [valueA]) - }) - - it('adds several keys', async () => { - await map.set(keyA, valueA) - await map.set(keyB, valueB) - - await expectMembersMatch([keyA, keyB], [valueA, valueB]) - expect(await map.contains(keyC)).to.equal(false) - }) - - it('returns false when adding keys already in the set', async () => { - await map.set(keyA, valueA) - - const tx = await map.set(keyA, valueA) - await assertEvent(tx, 'OperationResult', { result: false }) - - await expectMembersMatch([keyA], [valueA]) - }) - - it('updates values for keys already in the set', async () => { - await map.set(keyA, valueA) - - await map.set(keyA, valueB) - - await expectMembersMatch([keyA], [valueB]) - }) - }) - - describe('remove', () => { - it('removes added keys', async () => { - await map.set(keyA, valueA) - - const tx = await map.remove(keyA) - await assertEvent(tx, 'OperationResult', { result: true }) - - expect(await map.contains(keyA)).to.equal(false) - await expectMembersMatch([], []) - }) - - it('returns false when removing keys not in the set', async () => { - const tx = await map.remove(keyA) - await assertEvent(tx, 'OperationResult', { result: false }) - - expect(await map.contains(keyA)).to.equal(false) - }) - - it('adds and removes multiple keys', async () => { - await map.set(keyA, valueA) - await map.set(keyC, valueC) - await expectMembersMatch([keyA, keyC], [valueA, valueC]) // [A, C] - - await map.remove(keyA) - await map.remove(keyB) - await expectMembersMatch([keyC], [valueC]) // [C] - - await map.set(keyB, valueB) - await expectMembersMatch([keyC, keyB], [valueC, valueB]) // [C, B] - - await map.set(keyA, valueA) - await map.remove(keyC) - await expectMembersMatch([keyA, keyB], [valueA, valueB]) // [A, B] - - await map.set(keyA, valueA) - await map.set(keyB, valueB) - await expectMembersMatch([keyA, keyB], [valueA, valueB]) // [A, B] - - await map.set(keyC, valueC) - await map.remove(keyA) - await expectMembersMatch([keyC, keyB], [valueC, valueB]) // [C, B] - - await map.set(keyA, valueA) - await map.remove(keyB) - await expectMembersMatch([keyC, keyA], [valueC, valueA]) // [C, A] - - expect(await map.contains(keyB)).to.equal(false) - }) - }) - - describe('read', () => { - beforeEach(async () => { - await map.set(keyA, valueA) - }) - - describe('get', () => { - it('existing value', async () => { - expect((await map.get(keyA)).toString()).to.be.equal(valueA.toString()) - }) - - it('missing value', async () => { - await expect(map.get(keyB)).to.be.revertedWith('EnumerableMapNonExistentKey') - }) - }) - - describe('tryGet', () => { - it('existing value', async () => { - const { exists, value } = await map.tryGet(keyA) - expect(exists).to.be.equal(true) - expect(value).to.be.equal(valueA) - }) - - it('missing value', async () => { - const { exists, value } = await map.tryGet(keyB) - expect(exists).to.be.equal(false) - expect(value).to.be.equal(ZERO_ADDRESS) - }) - }) - }) - }) - - describe('AddressToAddressMap', () => { - const valueA = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' - const valueB = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' - const valueC = '0xf584F8728B874a6a5c7A8d4d387C9aae9172D621' - - beforeEach('deploy map', async () => { - map = await deploy('EnumerableMapAddressToAddressMock') - }) - - async function expectMembersMatch(keys, values) { - expect(keys.length).to.equal(values.length) - - await Promise.all(keys.map(async (key) => expect(await map.contains(key)).to.equal(true))) - - expect(await map.length()).to.be.equal(keys.length) - - expect(await Promise.all(keys.map((key) => map.get(key)))).to.have.same.members(values) - - await Promise.all( - keys.map(async (key, index) => { - const value = values[index] - const entry = await map.at(index) - expect(entry.key).to.be.equal(key) - expect(entry.value).to.be.equal(value) - }) - ) - - expect(await map.keys()).to.have.same.members(keys) - expect(await map.values()).to.have.same.members(values) - } - - it('starts empty', async () => { - expect(await map.contains(keyA)).to.equal(false) - - await expectMembersMatch([], []) - }) - - describe('set', () => { - it('adds a key', async () => { - const tx = await map.set(keyA, valueA) - await assertEvent(tx, 'OperationResult', { result: true }) - - await expectMembersMatch([keyA], [valueA]) - }) - - it('adds several keys', async () => { - await map.set(keyA, valueA) - await map.set(keyB, valueB) - - await expectMembersMatch([keyA, keyB], [valueA, valueB]) - expect(await map.contains(keyC)).to.equal(false) - }) - - it('returns false when adding keys already in the set', async () => { - await map.set(keyA, valueA) - - const tx = await map.set(keyA, valueA) - await assertEvent(tx, 'OperationResult', { result: false }) - - await expectMembersMatch([keyA], [valueA]) - }) - - it('updates values for keys already in the set', async () => { - await map.set(keyA, valueA) - - await map.set(keyA, valueB) - - await expectMembersMatch([keyA], [valueB]) - }) - }) - - describe('remove', () => { - it('removes added keys', async () => { - await map.set(keyA, valueA) - - const tx = await map.remove(keyA) - await assertEvent(tx, 'OperationResult', { result: true }) - - expect(await map.contains(keyA)).to.equal(false) - await expectMembersMatch([], []) - }) - - it('returns false when removing keys not in the set', async () => { - const tx = await map.remove(keyA) - await assertEvent(tx, 'OperationResult', { result: false }) - - expect(await map.contains(keyA)).to.equal(false) - }) - - it('adds and removes multiple keys', async () => { - await map.set(keyA, valueA) - await map.set(keyC, valueC) - await expectMembersMatch([keyA, keyC], [valueA, valueC]) // [A, C] - - await map.remove(keyA) - await map.remove(keyB) - await expectMembersMatch([keyC], [valueC]) // [C] - - await map.set(keyB, valueB) - await expectMembersMatch([keyC, keyB], [valueC, valueB]) // [C, B] - - await map.set(keyA, valueA) - await map.remove(keyC) - await expectMembersMatch([keyA, keyB], [valueA, valueB]) // [A, B] - - await map.set(keyA, valueA) - await map.set(keyB, valueB) - await expectMembersMatch([keyA, keyB], [valueA, valueB]) // [A, B] - - await map.set(keyC, valueC) - await map.remove(keyA) - await expectMembersMatch([keyC, keyB], [valueC, valueB]) // [C, B] - - await map.set(keyA, valueA) - await map.remove(keyB) - await expectMembersMatch([keyC, keyA], [valueC, valueA]) // [C, A] - - expect(await map.contains(keyB)).to.equal(false) - }) - }) - - describe('read', () => { - beforeEach(async () => { - await map.set(keyA, valueA) - }) - - describe('get', () => { - it('existing value', async () => { - expect((await map.get(keyA)).toString()).to.be.equal(valueA.toString()) - }) - - it('missing value', async () => { - await expect(map.get(keyB)).to.be.revertedWith('EnumerableMapNonExistentKey') - }) - }) - - describe('tryGet', () => { - it('existing value', async () => { - const { exists, value } = await map.tryGet(keyA) - expect(exists).to.be.equal(true) - expect(value).to.be.equal(valueA) - }) - - it('missing value', async () => { - const { exists, value } = await map.tryGet(keyB) - expect(exists).to.be.equal(false) - expect(value).to.be.equal(ZERO_ADDRESS) - }) - }) - }) - }) -}) diff --git a/packages/helpers/tests.ts b/packages/helpers/tests.ts deleted file mode 100644 index c4dfb7bd..00000000 --- a/packages/helpers/tests.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { TASK_TEST } from 'hardhat/builtin-tasks/task-names' -import { task, types } from 'hardhat/config' - -import { overrideTestTask } from './src/tests' - -task(TASK_TEST) - .addOptionalParam('fork', 'Optional network name to be forked in case of running fork tests.') - .addOptionalParam('forkIgnoreUnknownTxType', 'Optional flag to ignore unknown tx types.', false, types.boolean) - .addOptionalParam('chainId', 'Optional chain ID to overwrite hardhat local network ID.', undefined, types.int) - .addOptionalParam('blockNumber', 'Optional block number to fork in case of running fork tests.', undefined, types.int) - .setAction(overrideTestTask) diff --git a/packages/helpers/tsconfig.json b/packages/helpers/tsconfig.json deleted file mode 100644 index 6aa7a321..00000000 --- a/packages/helpers/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "target": "es2019", - "module": "commonjs", - "rootDir": ".", - "outDir": "dist", - "esModuleInterop": true, - "strict": true - }, - "files": [ - "index.ts", - "tests.ts", - "hardhat.config.ts" - ] -}