mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add legacy_tester for existing funC contracts (#588)
* Add legacy_tester for existing funC contracts * Add storage-contracts and pragma options
This commit is contained in:
parent
13b9f460af
commit
6b49d6a382
70 changed files with 14495 additions and 0 deletions
676
crypto/func/auto-tests/legacy_tests/whales-nominators/LICENSE
Normal file
676
crypto/func/auto-tests/legacy_tests/whales-nominators/LICENSE
Normal file
|
@ -0,0 +1,676 @@
|
|||
AUTHOR: https://github.com/ton-foundation/ton-nominators
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -0,0 +1,100 @@
|
|||
;;
|
||||
;; Errors
|
||||
;;
|
||||
|
||||
int error::invalid_address() asm "70 PUSHINT";
|
||||
int error::invalid_message() asm "72 PUSHINT";
|
||||
int error::access_denied() asm "73 PUSHINT";
|
||||
int error::internal_error() asm "74 PUSHINT";
|
||||
int error::already_deployed() asm "75 PUSHINT";
|
||||
int error::too_low_value() asm "76 PUSHINT";
|
||||
int error::invalid_stake_value() asm "77 PUSHINT";
|
||||
int error::unknown_text_command() asm "78 PUSHINT";
|
||||
|
||||
;;
|
||||
;; Members
|
||||
;;
|
||||
|
||||
int op::stake_deposit() asm "2077040623 PUSHINT";
|
||||
int op::stake_deposit::response() asm "3326208306 PUSHINT";
|
||||
int op::stake_withdraw() asm "3665837821 PUSHINT";
|
||||
int op::stake_withdraw::delayed() asm "1958425639 PUSHINT";
|
||||
int op::stake_withdraw::response() asm "601104865 PUSHINT";
|
||||
int op::donate() asm "1203495973 PUSHINT";
|
||||
int op::donate::response() asm "3095625004 PUSHINT";
|
||||
;;
|
||||
;; Owner
|
||||
;;
|
||||
|
||||
int op::upgrade() asm "3690657815 PUSHINT";
|
||||
int op::upgrade::response() asm "1395540087 PUSHINT";
|
||||
int op::update() asm "37541164 PUSHINT";
|
||||
int op::update::response() asm "839996522 PUSHINT";
|
||||
|
||||
;;
|
||||
;; Controller
|
||||
;;
|
||||
|
||||
int op::stake_send() asm "2718326572 PUSHINT";
|
||||
int op::accept_stakes() asm "2577928699 PUSHINT";
|
||||
int op::accept_withdraws() asm "2711607604 PUSHINT";
|
||||
int op::stake_recover() asm "1699565966 PUSHINT";
|
||||
int op::withdraw_unowned() asm "622684824 PUSHINT";
|
||||
int op::withdraw_unowned::response() asm "488052159 PUSHINT";
|
||||
int op::force_kick() asm "1396625244 PUSHINT";
|
||||
int op::force_kick::notification() asm "2060499266 PUSHINT";
|
||||
|
||||
;;
|
||||
;; Elector
|
||||
;;
|
||||
|
||||
int elector::refund::request() asm "0x47657424 PUSHINT";
|
||||
int elector::refund::response() asm "0xf96f7324 PUSHINT";
|
||||
|
||||
int elector::stake::request() asm "0x4e73744b PUSHINT";
|
||||
int elector::stake::response() asm "0xf374484c PUSHINT";
|
||||
int elector::stake::response::fail() asm "0xee6f454c PUSHINT";
|
||||
|
||||
;;
|
||||
;; Send Mode
|
||||
;;
|
||||
|
||||
int send_mode::default() asm "0 PUSHINT";
|
||||
int send_mode::separate_gas() asm "1 PUSHINT";
|
||||
int send_mode::ignore_errors() asm "2 PUSHINT";
|
||||
int send_mode::carry_remaining_balance() asm "128 PUSHINT";
|
||||
int send_mode::carry_remaining_value() asm "64 PUSHINT";
|
||||
int send_mode::destroy_if_zero() asm "64 PUSHINT";
|
||||
|
||||
;;
|
||||
;; Coins
|
||||
;;
|
||||
|
||||
int coins::1() asm "1000000000 PUSHINT";
|
||||
int coins::100() asm "100000000000 PUSHINT";
|
||||
|
||||
;;
|
||||
;; Fees
|
||||
;;
|
||||
|
||||
int fees::storage_reserve() asm "1000000000 PUSHINT"; ;; 1 TON
|
||||
int fees::receipt() asm "100000000 PUSHINT"; ;; 0.1 TON
|
||||
int fees::op() asm "100000000 PUSHINT"; ;; 0.1 TON
|
||||
int fees::deploy() asm "5000000000 PUSHINT"; ;; 5 TON
|
||||
int fees::stake_fees() asm "2000000000 PUSHINT"; ;; 2 TON
|
||||
|
||||
;;
|
||||
;; Parameters
|
||||
;;
|
||||
|
||||
int params::min_op() asm "100000000 PUSHINT"; ;; 0.1 TON
|
||||
int params::min_stake() asm "1000000000 PUSHINT"; ;; 1 TON
|
||||
int params::min_fee() asm "1000000000 PUSHINT"; ;; 1 TON
|
||||
int params::pending_op() asm "5000000000 PUSHINT"; ;; 5 TON
|
||||
int params::ppc_precision() asm "10000000000000 PUSHINT"; ;; 10^13
|
||||
|
||||
;;
|
||||
;; Members
|
||||
;;
|
||||
|
||||
int owner_id() asm "0 PUSHINT";
|
|
@ -0,0 +1,125 @@
|
|||
;;
|
||||
;; Related contracts
|
||||
;;
|
||||
|
||||
_ get_proxy() method_id {
|
||||
load_base_data();
|
||||
return ctx_proxy;
|
||||
}
|
||||
|
||||
_ get_owner() method_id {
|
||||
load_base_data();
|
||||
return ctx_owner;
|
||||
}
|
||||
|
||||
_ get_controller() method_id {
|
||||
load_base_data();
|
||||
return ctx_controller;
|
||||
}
|
||||
|
||||
;;
|
||||
;; Balances for controller
|
||||
;;
|
||||
|
||||
_ get_unowned() method_id {
|
||||
load_base_data();
|
||||
var [balance, extra] = get_balance();
|
||||
return max(balance - owned_balance(), 0);
|
||||
}
|
||||
|
||||
_ get_available() method_id {
|
||||
load_base_data();
|
||||
return ctx_balance - ctx_balance_sent;
|
||||
}
|
||||
|
||||
;;
|
||||
;; Pool and staking status
|
||||
;;
|
||||
|
||||
_ get_staking_status() method_id {
|
||||
load_base_data();
|
||||
load_validator_data();
|
||||
|
||||
var querySent = proxy_stored_query_id != 0;
|
||||
var unlocked = (proxy_stake_until == 0) | (proxy_stake_until < now());
|
||||
var until_val = proxy_stake_until;
|
||||
if ((proxy_stake_at != 0) & (proxy_stake_until != 0)) {
|
||||
until_val = lockup_lift_time(proxy_stake_at, proxy_stake_until);
|
||||
unlocked = unlocked & (until_val < now());
|
||||
}
|
||||
return (proxy_stake_at, until_val, proxy_stake_sent, querySent, unlocked, ctx_locked);
|
||||
}
|
||||
|
||||
_ get_pool_status() method_id {
|
||||
load_base_data();
|
||||
load_member(owner_id());
|
||||
return (ctx_balance, ctx_balance_sent, ctx_balance_pending_deposits, ctx_balance_pending_withdraw, ctx_balance_withdraw);
|
||||
}
|
||||
|
||||
;;
|
||||
;; Params
|
||||
;;
|
||||
_ get_params() method_id {
|
||||
load_base_data();
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
return (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price);
|
||||
}
|
||||
|
||||
;;
|
||||
;; Members
|
||||
;;
|
||||
|
||||
_ get_member_balance(slice address) method_id {
|
||||
load_base_data();
|
||||
load_member(parse_work_addr(address));
|
||||
|
||||
member_update_balance();
|
||||
return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
|
||||
}
|
||||
|
||||
_ get_members_raw() method_id {
|
||||
load_base_data();
|
||||
return ctx_nominators;
|
||||
}
|
||||
|
||||
_ get_members() method_id {
|
||||
load_base_data();
|
||||
|
||||
;; Init with owner
|
||||
load_member(owner_id());
|
||||
member_update_balance();
|
||||
var list = nil;
|
||||
list = cons([ctx_owner, ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
|
||||
|
||||
;; Iterate all members
|
||||
var id = -1;
|
||||
do {
|
||||
(id, var cs, var f) = ctx_nominators.udict_get_next?(256, id);
|
||||
|
||||
;; NOTE: One line condition doesn't work
|
||||
if (f) {
|
||||
if (id != owner_id()) {
|
||||
;; For some reason loading member from slice doesn't work
|
||||
load_member(id);
|
||||
member_update_balance();
|
||||
list = cons([serialize_work_addr(id), ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
|
||||
}
|
||||
}
|
||||
} until (~ f);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
_ get_member(slice address) method_id {
|
||||
load_base_data();
|
||||
load_member(parse_work_addr(address));
|
||||
member_update_balance();
|
||||
return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
|
||||
}
|
||||
|
||||
_ supported_interfaces() method_id {
|
||||
return (
|
||||
123515602279859691144772641439386770278, ;; org.ton.introspection.v0
|
||||
256184278959413194623484780286929323492 ;; com.tonwhales.nominators:v0
|
||||
);
|
||||
}
|
|
@ -0,0 +1,297 @@
|
|||
;;
|
||||
;; Low level operations
|
||||
;;
|
||||
|
||||
() add_member_pending_withdraw(int delta) impure inline {
|
||||
ctx_balance_pending_withdraw = ctx_balance_pending_withdraw + delta;
|
||||
ctx_member_pending_withdraw = ctx_member_pending_withdraw + delta;
|
||||
}
|
||||
() set_member_pending_withdraw(int value) impure inline {
|
||||
add_member_pending_withdraw(value - ctx_member_pending_withdraw);
|
||||
}
|
||||
|
||||
() add_member_pending_deposit(int delta) impure inline {
|
||||
ctx_member_pending_deposit = ctx_member_pending_deposit + delta;
|
||||
ctx_balance_pending_deposits = ctx_balance_pending_deposits + delta;
|
||||
}
|
||||
() set_member_pending_deposit(int value) impure inline {
|
||||
add_member_pending_deposit(value - ctx_member_pending_deposit);
|
||||
}
|
||||
|
||||
int compose_profit(int a, int b) {
|
||||
;; (a + 1) * (b + 1) - 1
|
||||
return (((a + params::ppc_precision()) * (b + params::ppc_precision())) / params::ppc_precision()) - params::ppc_precision(); ;; NOTE: Rounded down
|
||||
}
|
||||
|
||||
int apply_profit(int value, int value_profit, int profit) {
|
||||
return ((params::ppc_precision() + profit) * value) / (params::ppc_precision() + value_profit); ;; NOTE: Rounded down
|
||||
}
|
||||
|
||||
;;
|
||||
;; Deposit
|
||||
;;
|
||||
|
||||
() member_update_balance() impure {
|
||||
|
||||
;; Update profit (for non-owner)
|
||||
if (ctx_member != owner_id()) {
|
||||
if (ctx_profit_per_coin != ctx_member_profit_per_coin) {
|
||||
int new_balance = apply_profit(ctx_member_balance, ctx_member_profit_per_coin, ctx_profit_per_coin);
|
||||
int delta_balance = new_balance - ctx_member_balance;
|
||||
ctx_member_balance = ctx_member_balance + delta_balance;
|
||||
ctx_member_profit_per_coin = ctx_profit_per_coin;
|
||||
}
|
||||
}
|
||||
|
||||
;; Update pending withdraw
|
||||
if (ctx_member_pending_withdraw_all) {
|
||||
if (ctx_member_pending_withdraw != ctx_member_balance) {
|
||||
set_member_pending_withdraw(ctx_member_balance);
|
||||
}
|
||||
} else {
|
||||
if (ctx_member_pending_withdraw > ctx_member_balance) {
|
||||
set_member_pending_withdraw(ctx_member_balance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
() member_reset_pending_withdraw() impure {
|
||||
set_member_pending_withdraw(0);
|
||||
ctx_member_pending_withdraw_all = false;
|
||||
}
|
||||
|
||||
() member_stake_deposit(int value) impure {
|
||||
throw_unless(error::invalid_stake_value(), value > 0);
|
||||
|
||||
;; Update balances
|
||||
member_update_balance();
|
||||
|
||||
;; Reset pending withdrawal
|
||||
member_reset_pending_withdraw();
|
||||
|
||||
;; Add deposit to pending
|
||||
;; NOTE: We are not adding directly deposit to member's balance
|
||||
;; and we are always confirming acception of deposit to a pool
|
||||
;; via sending accept message. This could be done on- and off-chain.
|
||||
;; This could be useful to make private nominator pools or black lists.
|
||||
;; Anyone always could withdraw their deposits though.
|
||||
add_member_pending_deposit(value);
|
||||
}
|
||||
|
||||
() member_accept_stake() impure {
|
||||
|
||||
;; Checks if there are pending deposits
|
||||
throw_unless(error::invalid_message(), ctx_member_pending_deposit > 0);
|
||||
|
||||
;; Check if not locked
|
||||
throw_if(error::invalid_message(), ctx_locked);
|
||||
|
||||
;; Recalculate balance
|
||||
member_update_balance();
|
||||
|
||||
;; Move deposit to member's balance
|
||||
var amount = ctx_member_pending_deposit;
|
||||
set_member_pending_deposit(0);
|
||||
|
||||
|
||||
ctx_member_balance = ctx_member_balance + amount;
|
||||
ctx_balance = ctx_balance + amount;
|
||||
}
|
||||
|
||||
;;
|
||||
;; Withdraw
|
||||
;;
|
||||
|
||||
(int, int) member_stake_withdraw(int value) impure {
|
||||
|
||||
;; Check input
|
||||
throw_unless(error::invalid_stake_value(), value >= 0);
|
||||
|
||||
;; Update balances
|
||||
member_update_balance();
|
||||
|
||||
;; Reset pending withdrawal: would be overwritten later
|
||||
member_reset_pending_withdraw();
|
||||
|
||||
;; Pre-flight withdraw check
|
||||
throw_unless(error::invalid_stake_value(), value >= 0);
|
||||
throw_unless(error::invalid_stake_value(), ctx_member_balance + ctx_member_withdraw + ctx_member_pending_deposit >= value);
|
||||
|
||||
;; Check withdraw all
|
||||
var withdraw_all = false;
|
||||
if (value == 0) {
|
||||
withdraw_all = true;
|
||||
value = ctx_member_pending_deposit + ctx_member_balance + ctx_member_withdraw;
|
||||
}
|
||||
|
||||
;; Trying to withdraw immediatelly
|
||||
var remaining = value;
|
||||
var withdrawed = 0;
|
||||
|
||||
;; Try to withdraw from pending deposit
|
||||
if ((remaining > 0) & (ctx_member_pending_deposit >= 0)) {
|
||||
int delta = min(ctx_member_pending_deposit, remaining);
|
||||
add_member_pending_deposit(- delta);
|
||||
withdrawed = withdrawed + delta;
|
||||
remaining = remaining - delta;
|
||||
}
|
||||
|
||||
;; Try to withdraw from withdraw balance
|
||||
if ((remaining > 0) & ctx_member_withdraw > 0) {
|
||||
int delta = min(ctx_member_withdraw, remaining);
|
||||
ctx_member_withdraw = ctx_member_withdraw - delta;
|
||||
ctx_balance_withdraw = ctx_balance_withdraw - delta;
|
||||
withdrawed = withdrawed + delta;
|
||||
remaining = remaining - delta;
|
||||
}
|
||||
|
||||
;; Try to withdraw from balance
|
||||
if ((remaining > 0) & (~ ctx_locked) & (ctx_member_balance > 0)) {
|
||||
int delta = min(ctx_member_balance, remaining);
|
||||
ctx_member_balance = ctx_member_balance - delta;
|
||||
ctx_balance = ctx_balance - delta;
|
||||
withdrawed = withdrawed + delta;
|
||||
remaining = remaining - delta;
|
||||
}
|
||||
|
||||
;; Add to pending withdrawals
|
||||
if (remaining > 0) {
|
||||
add_member_pending_withdraw(remaining);
|
||||
ctx_member_pending_withdraw_all = withdraw_all;
|
||||
}
|
||||
|
||||
;; Return withdraw result
|
||||
return (withdrawed, remaining == 0);
|
||||
}
|
||||
|
||||
() member_accept_withdraw() impure {
|
||||
|
||||
;; Checks if there are pending withdrawals
|
||||
throw_unless(error::invalid_message(), ctx_member_pending_withdraw > 0);
|
||||
|
||||
;; Check if not locked
|
||||
throw_if(error::invalid_message(), ctx_locked);
|
||||
|
||||
;; Recalculate balance
|
||||
member_update_balance();
|
||||
|
||||
;; Move deposit to member's balance
|
||||
var amount = ctx_member_pending_withdraw;
|
||||
|
||||
ctx_member_balance = ctx_member_balance - amount;
|
||||
ctx_member_withdraw = ctx_member_withdraw + amount;
|
||||
ctx_balance = ctx_balance - amount;
|
||||
ctx_balance_withdraw = ctx_balance_withdraw + amount;
|
||||
ctx_balance_pending_withdraw = ctx_balance_pending_withdraw - amount;
|
||||
ctx_member_pending_withdraw = 0;
|
||||
ctx_member_pending_withdraw_all = false;
|
||||
}
|
||||
|
||||
() distribute_profit(int profit) impure {
|
||||
|
||||
;; Load extras
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
|
||||
;; Load owner balances
|
||||
load_member(0);
|
||||
|
||||
;; Loss
|
||||
if (profit < 0) {
|
||||
|
||||
;; Stakes
|
||||
var owner_stake = ctx_member_balance;
|
||||
var nominators_stake = ctx_balance - owner_stake;
|
||||
|
||||
;; Distribute loss to everyone
|
||||
var cycleProfitPerCoin = profit * params::ppc_precision() / ctx_balance;
|
||||
var nominators_profit = (nominators_stake * cycleProfitPerCoin) / params::ppc_precision();
|
||||
var owner_profit = profit - nominators_profit;
|
||||
|
||||
;; Update balances
|
||||
ctx_balance = ctx_balance + profit;
|
||||
ctx_member_balance = ctx_member_balance + owner_profit;
|
||||
ctx_profit_per_coin = compose_profit(ctx_profit_per_coin, cycleProfitPerCoin);
|
||||
|
||||
;; Persist
|
||||
store_member();
|
||||
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Profit
|
||||
if (profit > 0) {
|
||||
|
||||
;; Stakes
|
||||
var owner_stake = ctx_member_balance;
|
||||
var nominators_stake = ctx_balance - owner_stake;
|
||||
|
||||
;; Distribute profit
|
||||
var cycleProfitPerCoin = profit * params::ppc_precision() * (100 * 100 - pool_fee) / (ctx_balance * 100 * 100);
|
||||
var nominators_profit = (nominators_stake * cycleProfitPerCoin) / params::ppc_precision();
|
||||
var owner_profit = profit - nominators_profit;
|
||||
|
||||
;; Update balances
|
||||
ctx_balance = ctx_balance + profit;
|
||||
ctx_member_balance = ctx_member_balance + owner_profit;
|
||||
ctx_profit_per_coin = compose_profit(ctx_profit_per_coin, cycleProfitPerCoin);
|
||||
|
||||
;; Persist
|
||||
store_member();
|
||||
|
||||
return ();
|
||||
}
|
||||
}
|
||||
|
||||
;;
|
||||
;; Validator
|
||||
;;
|
||||
|
||||
() on_locked() impure {
|
||||
if (~ ctx_locked) {
|
||||
|
||||
;; Allow locking only on no pending withdrawals
|
||||
throw_unless(error::invalid_message(), ctx_balance_pending_withdraw == 0);
|
||||
|
||||
;; Update state
|
||||
ctx_locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
() on_unlocked() impure {
|
||||
if (ctx_locked) {
|
||||
|
||||
;; Update state
|
||||
ctx_locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
int available_to_stake() {
|
||||
return ctx_balance - ctx_balance_sent;
|
||||
}
|
||||
|
||||
int owned_balance() {
|
||||
return ctx_balance - ctx_balance_sent + ctx_balance_pending_deposits + ctx_balance_withdraw + fees::storage_reserve();
|
||||
}
|
||||
|
||||
() on_stake_sent(int stake) impure {
|
||||
ctx_balance_sent = ctx_balance_sent + stake;
|
||||
}
|
||||
|
||||
() on_stake_sent_failed(int stake) impure {
|
||||
ctx_balance_sent = ctx_balance_sent - stake;
|
||||
}
|
||||
|
||||
() on_stake_recovered(int stake) impure {
|
||||
|
||||
;; Calculate profit
|
||||
;; NOTE: ctx_locked is true meaning that ctx_balance
|
||||
;; have the same value as was when stake was sent
|
||||
;; balances are going to be unlocked after profit distribution
|
||||
var profit = stake - ctx_balance_sent;
|
||||
|
||||
;; Distribute profit
|
||||
distribute_profit(profit);
|
||||
|
||||
;; Reset sent amount
|
||||
ctx_balance_sent = 0;
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
() op_deposit(int member, int value) impure {
|
||||
|
||||
;; Read extras
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
throw_unless(error::invalid_message(), enabled);
|
||||
|
||||
;; Read stake value
|
||||
int fee = receipt_price + deposit_fee;
|
||||
int stake = value - fee;
|
||||
throw_unless(error::invalid_stake_value(), stake >= min_stake);
|
||||
|
||||
;; Load nominators
|
||||
load_member(member);
|
||||
|
||||
;; Add deposit
|
||||
member_stake_deposit(stake);
|
||||
|
||||
;; Resolve address
|
||||
var address = ctx_owner;
|
||||
if (member != owner_id()) {
|
||||
address = serialize_work_addr(member);
|
||||
}
|
||||
|
||||
;; Send receipt
|
||||
if (ctx_query_id == 0) {
|
||||
send_text_message(
|
||||
address,
|
||||
receipt_price,
|
||||
send_mode::default(),
|
||||
begin_cell()
|
||||
.store_accepted_stake(stake)
|
||||
);
|
||||
} else {
|
||||
send_empty_std_message(
|
||||
address,
|
||||
receipt_price,
|
||||
send_mode::default(),
|
||||
op::stake_deposit::response(),
|
||||
ctx_query_id
|
||||
);
|
||||
}
|
||||
|
||||
;; Persist
|
||||
store_member();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_withdraw(int member, int value, int stake) impure {
|
||||
|
||||
;; Read extras
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
|
||||
;; Check fee
|
||||
int fee = receipt_price + withdraw_fee;
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::too_low_value(), value == fee);
|
||||
|
||||
;; Load member
|
||||
load_member(member);
|
||||
|
||||
;; Try to withdraw immediatelly
|
||||
var (withdrawed, all) = member_stake_withdraw(stake);
|
||||
|
||||
;; Resolve address
|
||||
var address = ctx_owner;
|
||||
if (member != owner_id()) {
|
||||
address = serialize_work_addr(member);
|
||||
}
|
||||
|
||||
;; Send receipt
|
||||
if (ctx_query_id == 0) {
|
||||
send_text_message(
|
||||
address,
|
||||
withdrawed + receipt_price,
|
||||
send_mode::default(),
|
||||
all ? begin_cell().store_withdraw_completed() : begin_cell().store_withdraw_delayed()
|
||||
);
|
||||
} else {
|
||||
send_empty_std_message(
|
||||
address,
|
||||
withdrawed + receipt_price,
|
||||
send_mode::default(),
|
||||
all ? op::stake_withdraw::response() : op::stake_withdraw::delayed(),
|
||||
ctx_query_id
|
||||
);
|
||||
}
|
||||
|
||||
;; Persist
|
||||
store_member();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_donate(int value) impure {
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::invalid_message(), value >= 2 * coins::1());
|
||||
|
||||
;; Distribute profit to everyone
|
||||
distribute_profit(value - coins::1());
|
||||
|
||||
;; Persist
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_upgrade(int value, slice in_msg) impure {
|
||||
|
||||
;; Read extras
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
throw_unless(error::invalid_message(), udpates_enabled);
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::too_low_value(), value >= fees::deploy());
|
||||
|
||||
;; Upgrade code
|
||||
var code = in_msg~load_ref();
|
||||
in_msg.end_parse();
|
||||
set_code(code);
|
||||
|
||||
;; Send receipt
|
||||
send_empty_std_message(
|
||||
ctx_owner,
|
||||
0,
|
||||
send_mode::carry_remaining_value(),
|
||||
op::upgrade::response(),
|
||||
ctx_query_id
|
||||
);
|
||||
}
|
||||
|
||||
() op_update(int value, slice in_msg) impure {
|
||||
|
||||
;; Read extras
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::too_low_value(), value >= fees::deploy());
|
||||
|
||||
;; Check extras
|
||||
var newExtras = in_msg~load_ref();
|
||||
var es = newExtras.begin_parse();
|
||||
var new_enabled = es~load_int(1);
|
||||
var new_udpates_enabled = es~load_int(1);
|
||||
var new_min_stake = es~load_coins();
|
||||
var new_deposit_fee = es~load_coins();
|
||||
var new_withdraw_fee = es~load_coins();
|
||||
var new_pool_fee = es~load_coins();
|
||||
var new_receipt_price = es~load_coins();
|
||||
es.end_parse();
|
||||
|
||||
;; Once upgrades are disabled: prohibit re-enabling
|
||||
throw_if(error::invalid_message(), (~ udpates_enabled) & new_udpates_enabled);
|
||||
|
||||
;; At least min_stake
|
||||
throw_unless(error::invalid_message(), new_min_stake >= params::min_stake());
|
||||
;; At least op fee
|
||||
throw_unless(error::invalid_message(), new_deposit_fee >= fees::op());
|
||||
throw_unless(error::invalid_message(), new_withdraw_fee >= fees::op());
|
||||
;; Must be in 0...10000
|
||||
throw_unless(error::invalid_message(), new_pool_fee <= 100 * 100);
|
||||
;; At least receipt price
|
||||
throw_unless(error::invalid_message(), new_receipt_price >= fees::receipt());
|
||||
|
||||
;; Persist extras
|
||||
ctx_extras = (new_enabled, new_udpates_enabled, new_min_stake, new_deposit_fee, new_withdraw_fee, new_pool_fee, new_receipt_price);
|
||||
store_base_data();
|
||||
|
||||
;; Send receipt
|
||||
send_empty_std_message(
|
||||
ctx_owner,
|
||||
0,
|
||||
send_mode::carry_remaining_value(),
|
||||
op::update::response(),
|
||||
ctx_query_id
|
||||
);
|
||||
}
|
|
@ -0,0 +1,414 @@
|
|||
;;
|
||||
;; Stake Sending
|
||||
;;
|
||||
|
||||
() op_controller_stake_send(int value, slice in_msg) impure {
|
||||
|
||||
;; Parse message
|
||||
var stake = in_msg~load_coins();
|
||||
var validator_pubkey = in_msg~load_uint(256);
|
||||
var stake_at = in_msg~load_uint(32);
|
||||
var max_factor = in_msg~load_uint(32);
|
||||
var adnl_addr = in_msg~load_uint(256);
|
||||
var signature_ref = in_msg~load_ref();
|
||||
var signature = signature_ref.begin_parse().preload_bits(512);
|
||||
in_msg.end_parse();
|
||||
|
||||
;; Check message value
|
||||
throw_unless(error::invalid_message(), value >= fees::stake_fees());
|
||||
|
||||
;; Allow only single request to elector
|
||||
if (proxy_stored_query_id != 0) {
|
||||
throw(error::invalid_message());
|
||||
}
|
||||
|
||||
;; Allow update only for current stake
|
||||
if ((proxy_stake_at != 0) & (proxy_stake_at != stake_at)) {
|
||||
throw(error::invalid_message());
|
||||
}
|
||||
|
||||
;; Check stake value
|
||||
var availableStake = available_to_stake();
|
||||
throw_unless(error::invalid_stake_value(), availableStake >= stake);
|
||||
|
||||
;; Parameters
|
||||
var (electedFor, stakeHeldFor) = get_stake_parameters();
|
||||
|
||||
;; Lock stakes
|
||||
on_locked();
|
||||
|
||||
;; Update operation state
|
||||
proxy_stake_at = stake_at;
|
||||
proxy_stake_until = stake_at + electedFor + stakeHeldFor;
|
||||
proxy_stake_sent = proxy_stake_sent + stake;
|
||||
proxy_stored_query_id = ctx_query_id;
|
||||
proxy_stored_query_op = elector::stake::request();
|
||||
proxy_stored_query_stake = stake;
|
||||
|
||||
;; Update balances
|
||||
on_stake_sent(stake);
|
||||
|
||||
;; Send message to elector
|
||||
send_std_message(
|
||||
ctx_proxy,
|
||||
stake + coins::1(),
|
||||
send_mode::separate_gas(),
|
||||
elector::stake::request(),
|
||||
proxy_stored_query_id,
|
||||
begin_cell()
|
||||
.store_uint(validator_pubkey, 256)
|
||||
.store_uint(stake_at, 32)
|
||||
.store_uint(max_factor, 32)
|
||||
.store_uint(adnl_addr, 256)
|
||||
.store_ref(signature_ref)
|
||||
);
|
||||
|
||||
;; Persist
|
||||
store_validator_data();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_elector_stake_response(int value, slice in_msg) impure {
|
||||
|
||||
;; Check response
|
||||
if (ctx_query_id != proxy_stored_query_id) {
|
||||
;; How to handle invalid? How it is possible?
|
||||
return ();
|
||||
}
|
||||
if (proxy_stored_query_op != elector::stake::request()) {
|
||||
;; How to handle invalid? How it is possible?
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Reset active query
|
||||
proxy_stored_query_id = 0;
|
||||
proxy_stored_query_op = 0;
|
||||
proxy_stored_query_stake = 0;
|
||||
|
||||
;; Persist
|
||||
store_validator_data();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_elector_stake_response_fail(int value, slice in_msg) impure {
|
||||
|
||||
;; Load reason
|
||||
var reason = in_msg~load_uint(32);
|
||||
|
||||
;; Check response
|
||||
if (ctx_query_id != proxy_stored_query_id) {
|
||||
;; How to handle invalid? How it is possible?
|
||||
return ();
|
||||
}
|
||||
if (proxy_stored_query_op != elector::stake::request()) {
|
||||
;; How to handle invalid? How it is possible?
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Update balances
|
||||
on_stake_sent_failed(proxy_stored_query_stake);
|
||||
|
||||
;; Update proxy state
|
||||
proxy_stake_sent = proxy_stake_sent - proxy_stored_query_stake;
|
||||
|
||||
;; Reset stake at since sent stake became zero
|
||||
if (proxy_stake_sent == 0) {
|
||||
proxy_stake_at = 0;
|
||||
proxy_stake_until = 0;
|
||||
proxy_stake_sent = 0;
|
||||
on_unlocked();
|
||||
}
|
||||
|
||||
;; Reset query
|
||||
proxy_stored_query_id = 0;
|
||||
proxy_stored_query_op = 0;
|
||||
proxy_stored_query_stake = 0;
|
||||
|
||||
;; Persist
|
||||
store_validator_data();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
;;
|
||||
;; Recover
|
||||
;;
|
||||
|
||||
() op_stake_recover(int value) impure {
|
||||
|
||||
;; NOTE: We never block stake recover operation
|
||||
;; in case of misbehaviour of something anyone always can get
|
||||
;; coins from elector after lockup period is up
|
||||
|
||||
;; Allow request only if stake is exited lockup period
|
||||
if ((proxy_stake_until != 0) & (now() < proxy_stake_until)) {
|
||||
throw(error::invalid_message());
|
||||
}
|
||||
|
||||
;; Double check that validation session and lockup was lifted
|
||||
if ((proxy_stake_until != 0) & (proxy_stake_at != 0)) {
|
||||
throw_unless(error::invalid_message(), lockup_lift_time(proxy_stake_at, proxy_stake_until) <= now());
|
||||
}
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::too_low_value(), value >= fees::stake_fees());
|
||||
|
||||
;; Send message to elector
|
||||
send_empty_std_message(
|
||||
ctx_proxy,
|
||||
0,
|
||||
send_mode::carry_remaining_value(),
|
||||
elector::refund::request(),
|
||||
proxy_stored_query_id
|
||||
);
|
||||
|
||||
;; Persist
|
||||
store_validator_data();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_elector_recover_response(int value, slice in_msg) impure {
|
||||
|
||||
if ((proxy_stake_until != 0) & (now() > proxy_stake_until)) {
|
||||
|
||||
;; Reset state: all stake is returned
|
||||
proxy_stake_sent = 0;
|
||||
proxy_stake_at = 0;
|
||||
proxy_stake_until = 0;
|
||||
|
||||
;; Reset query too
|
||||
proxy_stored_query_id = 0;
|
||||
proxy_stored_query_op = 0;
|
||||
proxy_stored_query_stake = 0;
|
||||
|
||||
;; Handle stake recovered event
|
||||
;; NOTE: Any stake recovery outside this condition might be just a noise and
|
||||
;; effect of various race condirtions that doesn't carry any substantianal vakue
|
||||
on_stake_recovered(value - fees::stake_fees());
|
||||
|
||||
;; Reset lock state
|
||||
;; NOTE: MUST be after on_stake_recovered since it adjusts withdrawals and
|
||||
;; modifies global balance
|
||||
on_unlocked();
|
||||
}
|
||||
|
||||
;; Persist
|
||||
store_validator_data();
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
;;
|
||||
;; Withdraw unowned
|
||||
;;
|
||||
|
||||
() op_controller_withdraw_unowned(int value, slice in_msg) impure {
|
||||
|
||||
;; Reserve owned
|
||||
raw_reserve(owned_balance(), 0);
|
||||
|
||||
;; Send message to controller
|
||||
send_empty_std_message(
|
||||
ctx_controller,
|
||||
0,
|
||||
send_mode::carry_remaining_balance(),
|
||||
op::withdraw_unowned::response(),
|
||||
ctx_query_id
|
||||
);
|
||||
}
|
||||
|
||||
;;
|
||||
;; Process pending
|
||||
;;
|
||||
|
||||
() op_controller_accept_stakes(int value, slice in_msg) impure {
|
||||
|
||||
;; Check if enought value
|
||||
throw_unless(error::invalid_message(), value >= params::pending_op());
|
||||
|
||||
;; Check if not locked
|
||||
throw_if(error::invalid_message(), ctx_locked);
|
||||
|
||||
;; Parse message
|
||||
var members = in_msg~load_dict();
|
||||
in_msg.end_parse();
|
||||
|
||||
;; Process operations
|
||||
var member = -1;
|
||||
do {
|
||||
(member, var cs, var f) = members.udict_get_next?(256, member);
|
||||
if (f) {
|
||||
;; Accept member's stake
|
||||
load_member(member);
|
||||
member_accept_stake();
|
||||
store_member();
|
||||
}
|
||||
} until (~ f);
|
||||
|
||||
;; Persist
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_controller_accept_withdraws(int value, slice in_msg) impure {
|
||||
|
||||
;; Check if enought value
|
||||
throw_unless(error::invalid_message(), value >= params::pending_op());
|
||||
|
||||
;; Check if not locked
|
||||
throw_if(error::invalid_message(), ctx_locked);
|
||||
|
||||
;; Parse message
|
||||
var members = in_msg~load_dict();
|
||||
in_msg.end_parse();
|
||||
|
||||
;; Process operations
|
||||
var member = -1;
|
||||
do {
|
||||
(member, var cs, var f) = members.udict_get_next?(256, member);
|
||||
if (f) {
|
||||
;; Accept member's stake
|
||||
load_member(member);
|
||||
member_accept_withdraw();
|
||||
store_member();
|
||||
}
|
||||
} until (~ f);
|
||||
|
||||
;; Persist
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
() op_controller_force_kick(int value, slice in_msg) impure {
|
||||
|
||||
;; Check if enought value
|
||||
throw_unless(error::invalid_message(), value >= params::pending_op());
|
||||
|
||||
;; Check if not locked
|
||||
throw_if(error::invalid_message(), ctx_locked);
|
||||
|
||||
;; Parse message
|
||||
var members = in_msg~load_dict();
|
||||
in_msg.end_parse();
|
||||
|
||||
;; Process operations
|
||||
var member = -1;
|
||||
do {
|
||||
(member, var cs, var f) = members.udict_get_next?(256, member);
|
||||
if (f) {
|
||||
|
||||
;; Reject owner kicking
|
||||
throw_if(error::invalid_message(), member == owner_id());
|
||||
|
||||
;; Kick member from a pool
|
||||
load_member(member);
|
||||
|
||||
;; Withdraw everything
|
||||
var (withdrawed, all) = member_stake_withdraw(0);
|
||||
throw_unless(error::invalid_message(), withdrawed > 0);
|
||||
throw_unless(error::invalid_message(), all);
|
||||
|
||||
;; Forced kick
|
||||
send_empty_std_message(
|
||||
serialize_work_addr(member),
|
||||
withdrawed,
|
||||
send_mode::default(),
|
||||
op::force_kick::notification(),
|
||||
ctx_query_id
|
||||
);
|
||||
|
||||
;; Persist membership
|
||||
store_member();
|
||||
}
|
||||
} until (~ f);
|
||||
|
||||
;; Persist
|
||||
store_base_data();
|
||||
}
|
||||
|
||||
;;
|
||||
;; Top Level
|
||||
;;
|
||||
|
||||
() op_controller(int flags, int value, slice in_msg) impure {
|
||||
if (flags & 1) {
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::invalid_message(), value >= params::min_op());
|
||||
|
||||
;; Parse operation
|
||||
int op = in_msg~load_uint(32);
|
||||
int query_id = in_msg~load_uint(64);
|
||||
int gas_limit = in_msg~load_coins();
|
||||
set_gas_limit(gas_limit);
|
||||
ctx_query_id = query_id;
|
||||
throw_unless(error::invalid_message(), ctx_query_id > 0);
|
||||
|
||||
;; Send stake
|
||||
if (op == op::stake_send()) {
|
||||
op_controller_stake_send(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Recover stake
|
||||
if (op == op::stake_recover()) {
|
||||
op_stake_recover(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Withdraw unowned
|
||||
if (op == op::withdraw_unowned()) {
|
||||
op_controller_withdraw_unowned(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Accept stakes
|
||||
if (op == op::accept_stakes()) {
|
||||
op_controller_accept_stakes(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Accept withdraws
|
||||
if (op == op::accept_withdraws()) {
|
||||
op_controller_accept_withdraws(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Kick from pool
|
||||
if (op == op::force_kick()) {
|
||||
op_controller_force_kick(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Unknown message
|
||||
throw(error::invalid_message());
|
||||
}
|
||||
|
||||
() op_elector(int flags, int value, slice in_msg) impure {
|
||||
int op = in_msg~load_uint(32);
|
||||
int query_id = in_msg~load_uint(64);
|
||||
ctx_query_id = query_id;
|
||||
|
||||
;; Bounced
|
||||
;; It seems that handling doesn't make sence sicne there are no throws (?)
|
||||
;; in elector contract
|
||||
if (flags & 1) {
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Stake response
|
||||
if (op == elector::stake::response()) {
|
||||
op_elector_stake_response(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
if (op == elector::stake::response::fail()) {
|
||||
op_elector_stake_response_fail(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Refund response
|
||||
if (op == elector::refund::response()) {
|
||||
op_elector_recover_response(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Ignore
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
(slice, (int)) ~parse_text_command(slice in_msg) {
|
||||
int op = 0;
|
||||
;; 3 possible commands deposit, recover, withdraw
|
||||
int first_char = in_msg~load_uint(8);
|
||||
|
||||
;; Deposit
|
||||
if( first_char == 68 ) { ;; D
|
||||
throw_unless(error::unknown_text_command(), in_msg~load_uint(48) == 111533580577140); ;; eposit
|
||||
op = op::stake_deposit();
|
||||
}
|
||||
|
||||
;; Withdraw
|
||||
if( first_char == 87 ) { ;; W
|
||||
throw_unless(error::unknown_text_command(), in_msg~load_uint(56) == 29682864265257335); ;; ithdraw
|
||||
op = op::stake_withdraw();
|
||||
}
|
||||
|
||||
;; Recover
|
||||
if( first_char == 82 ) { ;; R
|
||||
throw_unless(error::unknown_text_command(), in_msg~load_uint(48) == 111477746197874); ;; ecover
|
||||
op = op::stake_recover();
|
||||
}
|
||||
|
||||
return (in_msg, (op));
|
||||
}
|
||||
|
||||
() op_nominators(int member, int flags, int value, slice in_msg) impure {
|
||||
|
||||
;; Ignore bounced
|
||||
if (flags & 1) {
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::invalid_message(), value >= params::min_op());
|
||||
|
||||
;; Parse operation
|
||||
int op = in_msg~load_uint(32);
|
||||
|
||||
;; Text operations
|
||||
if (op == 0) {
|
||||
ctx_query_id = 0;
|
||||
op = in_msg~parse_text_command();
|
||||
|
||||
;; Deposit stake
|
||||
if (op == op::stake_deposit()) {
|
||||
op_deposit(member, value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Withdraw stake
|
||||
if (op == op::stake_withdraw()) {
|
||||
op_withdraw(member, value, 0);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Recover stake
|
||||
if (op == op::stake_recover()) {
|
||||
load_validator_data();
|
||||
op_stake_recover(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Unknown message
|
||||
throw(error::invalid_message());
|
||||
return ();
|
||||
}
|
||||
|
||||
int query_id = in_msg~load_uint(64);
|
||||
int gas_limit = in_msg~load_coins();
|
||||
set_gas_limit(gas_limit);
|
||||
ctx_query_id = query_id;
|
||||
throw_unless(error::invalid_message(), ctx_query_id > 0);
|
||||
|
||||
;; Deposit stake
|
||||
if (op == op::stake_deposit()) {
|
||||
op_deposit(member, value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Withdraw stake
|
||||
if (op == op::stake_withdraw()) {
|
||||
int stake = in_msg~load_coins();
|
||||
in_msg.end_parse();
|
||||
op_withdraw(member, value, stake);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Recover stake
|
||||
if (op == op::stake_recover()) {
|
||||
load_validator_data();
|
||||
op_stake_recover(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Donate stake
|
||||
if (op == op::donate()) {
|
||||
op_donate(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Unknown message
|
||||
throw(error::invalid_message());
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
() op_owner(int flags, int value, slice in_msg) impure {
|
||||
|
||||
;; Ignore bounced
|
||||
if (flags & 1) {
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Check value
|
||||
throw_unless(error::invalid_message(), value >= params::min_op());
|
||||
|
||||
;; Parse operation
|
||||
int op = in_msg~load_uint(32);
|
||||
int query_id = in_msg~load_uint(64);
|
||||
int gas_limit = in_msg~load_coins();
|
||||
set_gas_limit(gas_limit);
|
||||
ctx_query_id = query_id;
|
||||
throw_unless(error::invalid_message(), ctx_query_id > 0);
|
||||
|
||||
;; Upgrade
|
||||
if (op == op::upgrade()) {
|
||||
op_upgrade(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Upgrade
|
||||
if (op == op::update()) {
|
||||
op_update(value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Add stake
|
||||
if (op == op::stake_deposit()) {
|
||||
op_deposit(owner_id(), value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Withdraw stake
|
||||
if (op == op::stake_withdraw()) {
|
||||
int stake = in_msg~load_coins();
|
||||
in_msg.end_parse();
|
||||
op_withdraw(owner_id(), value, stake);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Recover stake
|
||||
if (op == op::stake_recover()) {
|
||||
load_validator_data();
|
||||
op_stake_recover(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Donate stake
|
||||
if (op == op::donate()) {
|
||||
op_donate(value);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Unknown message
|
||||
throw(error::invalid_message());
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
global int ctx_query_id;
|
||||
|
||||
global int ctx_locked;
|
||||
global slice ctx_owner;
|
||||
global slice ctx_controller;
|
||||
global slice ctx_proxy;
|
||||
global cell ctx_proxy_state;
|
||||
|
||||
global int ctx_profit_per_coin;
|
||||
global int ctx_balance;
|
||||
global int ctx_balance_sent;
|
||||
global int ctx_balance_withdraw;
|
||||
global int ctx_balance_pending_withdraw;
|
||||
global int ctx_balance_pending_deposits;
|
||||
|
||||
global cell ctx_nominators;
|
||||
|
||||
;; var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
global (int, int, int, int, int, int, int) ctx_extras;
|
||||
|
||||
() load_base_data() impure {
|
||||
var ds = get_data().begin_parse();
|
||||
ctx_locked = ds~load_int(1);
|
||||
|
||||
ctx_owner = ds~load_msg_addr();
|
||||
ctx_controller = ds~load_msg_addr();
|
||||
ctx_proxy = ds~load_msg_addr();
|
||||
|
||||
cell balance_cell = ds~load_ref();
|
||||
ctx_nominators = ds~load_dict();
|
||||
ctx_proxy_state = ds~load_ref();
|
||||
cell extras_cell = null();
|
||||
if (ds.slice_refs() > 0) {
|
||||
extras_cell = ds~load_ref();
|
||||
}
|
||||
ds.end_parse();
|
||||
|
||||
var bs = balance_cell.begin_parse();
|
||||
ctx_profit_per_coin = bs~load_int(128);
|
||||
ctx_balance = bs~load_coins();
|
||||
ctx_balance_sent = bs~load_coins();
|
||||
ctx_balance_withdraw = bs~load_coins();
|
||||
ctx_balance_pending_withdraw = bs~load_coins();
|
||||
ctx_balance_pending_deposits = bs~load_coins();
|
||||
bs.end_parse();
|
||||
|
||||
;; Parsing extras (enabled, upgrades_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price)
|
||||
ctx_extras = (
|
||||
true, ;; Enabled
|
||||
true, ;; Upgrades enabled
|
||||
params::min_stake(), ;; Min Stake
|
||||
fees::op(), ;; Deposit fee
|
||||
fees::op(), ;; Withdraw fee
|
||||
10 * 100, ;; Pool fee (%),
|
||||
fees::receipt()
|
||||
);
|
||||
if (~ extras_cell.null?()) {
|
||||
var ec = extras_cell.begin_parse();
|
||||
var enabled = ec~load_int(1);
|
||||
var udpates_enabled = ec~load_int(1);
|
||||
var min_stake = ec~load_coins();
|
||||
var deposit_fee = ec~load_coins();
|
||||
var withdraw_fee = ec~load_coins();
|
||||
var pool_fee = ec~load_coins();
|
||||
var receipt_price = ec~load_coins();
|
||||
ctx_extras = (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price);
|
||||
ec.end_parse();
|
||||
}
|
||||
}
|
||||
|
||||
() store_base_data() impure {
|
||||
var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
|
||||
set_data(begin_cell()
|
||||
.store_int(ctx_locked, 1)
|
||||
.store_slice(ctx_owner)
|
||||
.store_slice(ctx_controller)
|
||||
.store_slice(ctx_proxy)
|
||||
.store_ref(begin_cell()
|
||||
.store_int(ctx_profit_per_coin, 128)
|
||||
.store_coins(ctx_balance)
|
||||
.store_coins(ctx_balance_sent)
|
||||
.store_coins(ctx_balance_withdraw)
|
||||
.store_coins(ctx_balance_pending_withdraw)
|
||||
.store_coins(ctx_balance_pending_deposits)
|
||||
.end_cell())
|
||||
.store_dict(ctx_nominators)
|
||||
.store_ref(ctx_proxy_state)
|
||||
.store_ref(begin_cell()
|
||||
.store_int(enabled, 1)
|
||||
.store_int(udpates_enabled, 1)
|
||||
.store_coins(min_stake)
|
||||
.store_coins(deposit_fee)
|
||||
.store_coins(withdraw_fee)
|
||||
.store_coins(pool_fee)
|
||||
.store_coins(receipt_price)
|
||||
.end_cell())
|
||||
.end_cell());
|
||||
commit();
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
;;
|
||||
;; Members
|
||||
;;
|
||||
|
||||
global int ctx_member;
|
||||
global int ctx_member_balance;
|
||||
global int ctx_member_pending_withdraw;
|
||||
global int ctx_member_pending_withdraw_all;
|
||||
global int ctx_member_pending_deposit;
|
||||
global int ctx_member_withdraw;
|
||||
global int ctx_member_profit_per_coin;
|
||||
global int ctx_member_exist;
|
||||
|
||||
slice load_member_slice(slice cs) impure {
|
||||
ctx_member_profit_per_coin = cs~load_int(128);
|
||||
ctx_member_balance = cs~load_coins();
|
||||
ctx_member_pending_withdraw = cs~load_coins();
|
||||
ctx_member_pending_withdraw_all = cs~load_int(1);
|
||||
ctx_member_pending_deposit = cs~load_coins();
|
||||
ctx_member_withdraw = cs~load_coins();
|
||||
ctx_member_exist = true;
|
||||
return cs;
|
||||
}
|
||||
|
||||
() load_member(int member) impure {
|
||||
var (cs, found) = ctx_nominators.udict_get?(256, member);
|
||||
ctx_member = member;
|
||||
if (found) {
|
||||
cs = load_member_slice(cs);
|
||||
cs.end_parse();
|
||||
ctx_member_exist = true;
|
||||
} else {
|
||||
ctx_member_balance = 0;
|
||||
ctx_member_pending_withdraw = 0;
|
||||
ctx_member_pending_withdraw_all = false;
|
||||
ctx_member_pending_deposit = 0;
|
||||
ctx_member_profit_per_coin = 0;
|
||||
ctx_member_withdraw = 0;
|
||||
ctx_member_exist = false;
|
||||
}
|
||||
}
|
||||
|
||||
() store_member() impure {
|
||||
var shouldExist = (ctx_member_balance > 0) | (ctx_member_pending_deposit > 0) | (ctx_member_withdraw > 0);
|
||||
if ((~ shouldExist) & ctx_member_exist) {
|
||||
;; Compiler crashes when single lined
|
||||
var (changed, _) = udict_delete?(ctx_nominators, 256, ctx_member);
|
||||
ctx_nominators = changed;
|
||||
} elseif (shouldExist) {
|
||||
var data = begin_cell()
|
||||
.store_int(ctx_member_profit_per_coin, 128)
|
||||
.store_coins(ctx_member_balance)
|
||||
.store_coins(ctx_member_pending_withdraw)
|
||||
.store_int(ctx_member_pending_withdraw_all, 1)
|
||||
.store_coins(ctx_member_pending_deposit)
|
||||
.store_coins(ctx_member_withdraw);
|
||||
|
||||
;; Compiler crashes when single lined
|
||||
var changed = udict_set_builder(ctx_nominators, 256, ctx_member, data);
|
||||
ctx_nominators = changed;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
global int proxy_stake_at;
|
||||
global int proxy_stake_until;
|
||||
global int proxy_stake_sent;
|
||||
global int proxy_stored_query_id;
|
||||
global int proxy_stored_query_op;
|
||||
global int proxy_stored_query_stake;
|
||||
|
||||
() load_validator_data() impure {
|
||||
var cs = ctx_proxy_state.begin_parse();
|
||||
proxy_stake_at = cs~load_uint(32);
|
||||
proxy_stake_until = cs~load_uint(32);
|
||||
proxy_stake_sent = cs~load_coins();
|
||||
proxy_stored_query_id = cs~load_uint(64);
|
||||
proxy_stored_query_op = cs~load_uint(32);
|
||||
proxy_stored_query_stake = cs~load_coins();
|
||||
cs.end_parse();
|
||||
}
|
||||
|
||||
() store_validator_data() impure {
|
||||
ctx_proxy_state = begin_cell()
|
||||
.store_uint(proxy_stake_at, 32)
|
||||
.store_uint(proxy_stake_until, 32)
|
||||
.store_coins(proxy_stake_sent)
|
||||
.store_uint(proxy_stored_query_id, 64)
|
||||
.store_uint(proxy_stored_query_op, 32)
|
||||
.store_coins(proxy_stored_query_stake)
|
||||
.end_cell();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
(int, int) get_stake_parameters() {
|
||||
return (1000, 100);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
(int, int) get_stake_parameters() {
|
||||
var cs = config_param(15).begin_parse();
|
||||
int electedFor = cs~load_uint(32);
|
||||
cs~skip_bits(64);
|
||||
int stakeHeldFor = cs~load_uint(32);
|
||||
return (electedFor, stakeHeldFor);
|
||||
}
|
||||
|
||||
(int, int) get_previous_cycle() {
|
||||
var cs = config_param(32).begin_parse();
|
||||
cs~skip_bits(8); ;; Header
|
||||
int timeSince = cs~load_uint(32);
|
||||
int timeUntil = cs~load_uint(32);
|
||||
return (timeSince, timeUntil);
|
||||
}
|
||||
|
||||
(int, int) get_current_cycle() {
|
||||
var cs = config_param(34).begin_parse();
|
||||
cs~skip_bits(8); ;; Header
|
||||
int timeSince = cs~load_uint(32);
|
||||
int timeUntil = cs~load_uint(32);
|
||||
return (timeSince, timeUntil);
|
||||
}
|
||||
|
||||
int lockup_lift_time(int stake_at, int stake_untill) {
|
||||
|
||||
;; Resolve previous cycle parameters
|
||||
var (timeSince, timeUntil) = get_previous_cycle();
|
||||
|
||||
;; If previous cycle looks as a valid one
|
||||
if (stake_at <= timeSince) {
|
||||
return timeSince + (stake_untill - stake_at);
|
||||
}
|
||||
|
||||
;; Check current cycle
|
||||
var (timeSince, timeUntil) = get_current_cycle();
|
||||
|
||||
;; If current cycle could be the one we joined validation
|
||||
if (stake_at <= timeSince) {
|
||||
return timeSince + (stake_untill - stake_at);
|
||||
}
|
||||
|
||||
return stake_untill;
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
;;
|
||||
;; Basic workchain addresses
|
||||
;;
|
||||
|
||||
int parse_work_addr(slice cs) {
|
||||
(int sender_wc, slice sender_addr) = parse_var_addr(cs);
|
||||
throw_unless(error::invalid_address(), 0 == sender_wc);
|
||||
return sender_addr~load_uint(256);
|
||||
}
|
||||
|
||||
(slice) serialize_work_addr(int addr) {
|
||||
return (begin_cell()
|
||||
.store_uint(2, 2) ;; Is std address
|
||||
.store_uint(0, 1) ;; Non-unicast
|
||||
.store_uint(0, 8) ;; Basic workchain
|
||||
.store_uint(addr, 256) ;; Address hash
|
||||
).end_cell().begin_parse();
|
||||
}
|
||||
|
||||
;;
|
||||
;; Custom Commands
|
||||
;;
|
||||
|
||||
(int) equal_slices (slice s1, slice s2) asm "SDEQ";
|
||||
builder store_builder(builder to, builder what) asm(what to) "STB";
|
||||
builder store_builder_ref(builder to, builder what) asm(what to) "STBREFR";
|
||||
(slice, cell) load_maybe_cell(slice s) asm( -> 1 0) "LDDICT";
|
||||
(int) mod (int x, int y) asm "MOD";
|
||||
builder store_coins(builder b, int x) asm "STGRAMS";
|
||||
(slice, int) load_coins(slice s) asm( -> 1 0) "LDGRAMS";
|
||||
|
||||
|
||||
;;
|
||||
;; Events
|
||||
;;
|
||||
|
||||
() send_std_message(
|
||||
slice to_addr,
|
||||
int value,
|
||||
int mode,
|
||||
int op,
|
||||
int query_id,
|
||||
builder content
|
||||
) impure {
|
||||
|
||||
var body = begin_cell()
|
||||
.store_uint(op, 32)
|
||||
.store_uint(query_id, 64)
|
||||
.store_builder(content)
|
||||
.end_cell();
|
||||
|
||||
var msg = begin_cell()
|
||||
.store_uint(0x10, 6)
|
||||
.store_slice(to_addr)
|
||||
.store_coins(value)
|
||||
.store_uint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1)
|
||||
.store_ref(body)
|
||||
.end_cell();
|
||||
|
||||
send_raw_message(msg, mode);
|
||||
}
|
||||
|
||||
() send_empty_std_message(
|
||||
slice to_addr,
|
||||
int value,
|
||||
int mode,
|
||||
int op,
|
||||
int query_id
|
||||
) impure {
|
||||
|
||||
var body = begin_cell()
|
||||
.store_uint(op, 32)
|
||||
.store_uint(query_id, 64)
|
||||
.end_cell();
|
||||
|
||||
var msg = begin_cell()
|
||||
.store_uint(0x10, 6)
|
||||
.store_slice(to_addr)
|
||||
.store_coins(value)
|
||||
.store_uint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1)
|
||||
.store_ref(body)
|
||||
.end_cell();
|
||||
|
||||
send_raw_message(msg, mode);
|
||||
}
|
||||
|
||||
() send_text_message(
|
||||
slice to_addr,
|
||||
int value,
|
||||
int mode,
|
||||
builder content
|
||||
) impure {
|
||||
|
||||
var body = begin_cell()
|
||||
.store_uint(0, 32)
|
||||
.store_builder(content)
|
||||
.end_cell();
|
||||
|
||||
var msg = begin_cell()
|
||||
.store_uint(0x10, 6)
|
||||
.store_slice(to_addr)
|
||||
.store_coins(value)
|
||||
.store_uint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1)
|
||||
.store_ref(body)
|
||||
.end_cell();
|
||||
|
||||
send_raw_message(msg, mode);
|
||||
}
|
||||
|
||||
;;
|
||||
;; Generate
|
||||
;;
|
||||
|
||||
(int) new_query_id() inline {
|
||||
return now() + mod(cur_lt(), 4294967296);
|
||||
}
|
||||
|
||||
;;
|
||||
;; Text Utils
|
||||
;;
|
||||
|
||||
(int, int) encode_number_to_text(int number) {
|
||||
int len = 0;
|
||||
int value = 0;
|
||||
int mult = 1;
|
||||
do {
|
||||
(number, int res) = number.divmod(10);
|
||||
value = value + (res + 48) * mult;
|
||||
mult = mult * 256;
|
||||
len = len + 1;
|
||||
} until (number == 0);
|
||||
return (len, value);
|
||||
}
|
||||
|
||||
builder store_coins_string(builder msg, int amount) {
|
||||
(int ceil, int res) = divmod(amount, 1000000000);
|
||||
(int cl, int cv) = encode_number_to_text(ceil);
|
||||
msg = msg.store_uint(cv, cl * 8 );
|
||||
msg = msg.store_uint(46, 8); ;; "."
|
||||
(int rl, int rv) = encode_number_to_text(res);
|
||||
;; repeat( 9 - rl ) {
|
||||
;; msg = msg.store_uint(48, 8); ;; " "
|
||||
;; }
|
||||
return msg.store_uint(rv, rl * 8);
|
||||
}
|
||||
|
||||
|
||||
;; 'Stake'
|
||||
builder store_text_stake(builder b) inline {
|
||||
return b.store_uint(358434827109, 40);
|
||||
}
|
||||
|
||||
;; ' '
|
||||
builder store_text_space(builder b) inline {
|
||||
return b.store_uint(32, 8);
|
||||
}
|
||||
|
||||
;; 'accepted'
|
||||
builder store_text_accepted(builder b) inline {
|
||||
return b.store_uint(7017561931702887780, 64);
|
||||
}
|
||||
|
||||
;; Stake 123.333 accepted
|
||||
builder store_accepted_stake(builder b, int amount) inline {
|
||||
return b.store_text_stake()
|
||||
.store_text_space()
|
||||
.store_coins_string(amount)
|
||||
.store_text_space()
|
||||
.store_text_accepted();
|
||||
}
|
||||
|
||||
;; 'Withdraw completed'
|
||||
builder store_withdraw_completed(builder b) inline {
|
||||
return b.store_uint(7614653257073527469736132165096662684165476, 144);
|
||||
}
|
||||
|
||||
;; 'Withdraw requested. Please, retry the command when your balance is ready.'
|
||||
builder store_withdraw_delayed(builder b) inline {
|
||||
return b
|
||||
.store_uint(1949351233810823032252520485584178069312463918, 152) ;; 'Withdraw requested.'
|
||||
.store_text_space()
|
||||
.store_uint(555062058613674355757418046597367430905687018487295295368960255172568430, 240) ;; 'Please, retry the command when'
|
||||
.store_text_space()
|
||||
.store_uint(45434371896731988359547695118970428857702208118225198, 176); ;; 'your balance is ready.'
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
#include "stdlib.fc";
|
||||
#include "modules/constants.fc";
|
||||
#include "modules/utils-config.fc";
|
||||
#include "modules/utils.fc";
|
||||
;; #include "modules/utils-config-mock.fc";
|
||||
#include "modules/store-base.fc";
|
||||
#include "modules/store-nominators.fc";
|
||||
#include "modules/store-validator.fc";
|
||||
#include "modules/model.fc";
|
||||
#include "modules/op-controller.fc";
|
||||
#include "modules/op-owner.fc";
|
||||
#include "modules/op-common.fc";
|
||||
#include "modules/op-nominators.fc";
|
||||
#include "modules/get.fc";
|
||||
|
||||
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
|
||||
|
||||
;; Prepare message context
|
||||
var cs = in_msg_cell.begin_parse();
|
||||
var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
slice s_addr = cs~load_msg_addr();
|
||||
load_base_data();
|
||||
|
||||
;; Handle controller messages
|
||||
if (equal_slices(s_addr, ctx_controller)) {
|
||||
load_validator_data();
|
||||
op_controller(flags, msg_value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Handle elector messages
|
||||
if (equal_slices(s_addr, ctx_proxy)) {
|
||||
load_validator_data();
|
||||
op_elector(flags, msg_value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Handle owner messages
|
||||
if (equal_slices(s_addr, ctx_owner)) {
|
||||
op_owner(flags, msg_value, in_msg);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Nominators
|
||||
var address = parse_work_addr(s_addr);
|
||||
op_nominators(address, flags, msg_value, in_msg);
|
||||
}
|
||||
|
||||
() recv_external(slice in_msg) impure {
|
||||
;; Do not accept external messages
|
||||
throw(error::invalid_message());
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
(int) equal_slices (slice s1, slice s2) asm "SDEQ";
|
||||
|
||||
() recv_internal(cell in_msg_cell, slice in_msg) {
|
||||
|
||||
;; Parse message
|
||||
var cs = in_msg_cell.begin_parse();
|
||||
var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
slice s_addr = cs~load_msg_addr();
|
||||
|
||||
;; Parse data
|
||||
var ds = get_data().begin_parse();
|
||||
slice address_0 = ds~load_msg_addr();
|
||||
slice address_1 = ds~load_msg_addr();
|
||||
ds~skip_bits(64);
|
||||
ds.end_parse();
|
||||
|
||||
;; Resolve addresses address
|
||||
slice src = null();
|
||||
slice dst = null();
|
||||
if (equal_slices(s_addr, address_0)) {
|
||||
src = address_0;
|
||||
dst = address_1;
|
||||
} elseif (equal_slices(s_addr, address_1)) {
|
||||
src = address_1;
|
||||
dst = address_0;
|
||||
}
|
||||
|
||||
;; Bounce while keeping storage fee on unknown
|
||||
;; Useful fro deploy
|
||||
if (null?(src)) {
|
||||
raw_reserve(1000000000, 2);
|
||||
var msg = begin_cell()
|
||||
.store_uint(0x10, 6)
|
||||
.store_slice(s_addr)
|
||||
.store_grams(0)
|
||||
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
|
||||
.end_cell();
|
||||
send_raw_message(msg, 128);
|
||||
return ();
|
||||
}
|
||||
|
||||
;; Process messages
|
||||
raw_reserve(1000000000, 2);
|
||||
var msg = begin_cell()
|
||||
.store_uint(flags, 4)
|
||||
.store_uint(0, 2)
|
||||
.store_slice(dst)
|
||||
.store_grams(0)
|
||||
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1);
|
||||
|
||||
;; Content
|
||||
if(msg.builder_bits() + 1 + in_msg.slice_bits() > 1023) {
|
||||
msg = msg.store_uint(1,1)
|
||||
.store_ref(begin_cell().store_slice(in_msg).end_cell());
|
||||
} else {
|
||||
msg = msg.store_uint(0,1)
|
||||
.store_slice(in_msg);
|
||||
}
|
||||
|
||||
;; Send message
|
||||
send_raw_message(msg.end_cell(), 128);
|
||||
}
|
||||
|
||||
() recv_external(slice in_msg) impure {
|
||||
;; Do not accept external messages
|
||||
throw(72);
|
||||
}
|
212
crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc
Normal file
212
crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc
Normal file
|
@ -0,0 +1,212 @@
|
|||
;; Standard library for funC
|
||||
;;
|
||||
|
||||
forall X -> tuple cons(X head, tuple tail) asm "CONS";
|
||||
forall X -> (X, tuple) uncons(tuple list) asm "UNCONS";
|
||||
forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS";
|
||||
forall X -> X car(tuple list) asm "CAR";
|
||||
tuple cdr(tuple list) asm "CDR";
|
||||
tuple empty_tuple() asm "NIL";
|
||||
forall X -> tuple tpush(tuple t, X value) asm "TPUSH";
|
||||
forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH";
|
||||
forall X -> [X] single(X x) asm "SINGLE";
|
||||
forall X -> X unsingle([X] t) asm "UNSINGLE";
|
||||
forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR";
|
||||
forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR";
|
||||
forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE";
|
||||
forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE";
|
||||
forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE";
|
||||
forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE";
|
||||
forall X -> X first(tuple t) asm "FIRST";
|
||||
forall X -> X second(tuple t) asm "SECOND";
|
||||
forall X -> X third(tuple t) asm "THIRD";
|
||||
forall X -> X fourth(tuple t) asm "3 INDEX";
|
||||
forall X, Y -> X pair_first([X, Y] p) asm "FIRST";
|
||||
forall X, Y -> Y pair_second([X, Y] p) asm "SECOND";
|
||||
forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST";
|
||||
forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND";
|
||||
forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD";
|
||||
forall X -> X null() asm "PUSHNULL";
|
||||
forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP";
|
||||
|
||||
int now() asm "NOW";
|
||||
slice my_address() asm "MYADDR";
|
||||
[int, cell] get_balance() asm "BALANCE";
|
||||
int cur_lt() asm "LTIME";
|
||||
int block_lt() asm "BLOCKLT";
|
||||
|
||||
int cell_hash(cell c) asm "HASHCU";
|
||||
int slice_hash(slice s) asm "HASHSU";
|
||||
int string_hash(slice s) asm "SHA256U";
|
||||
|
||||
int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU";
|
||||
int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS";
|
||||
|
||||
(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE";
|
||||
(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE";
|
||||
(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||
(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||
|
||||
;; () throw_if(int excno, int cond) impure asm "THROWARGIF";
|
||||
|
||||
() dump_stack() impure asm "DUMPSTK";
|
||||
|
||||
cell get_data() asm "c4 PUSH";
|
||||
() set_data(cell c) impure asm "c4 POP";
|
||||
cont get_c3() impure asm "c3 PUSH";
|
||||
() set_c3(cont c) impure asm "c3 POP";
|
||||
cont bless(slice s) impure asm "BLESS";
|
||||
|
||||
() accept_message() impure asm "ACCEPT";
|
||||
() set_gas_limit(int limit) impure asm "SETGASLIMIT";
|
||||
() commit() impure asm "COMMIT";
|
||||
() buy_gas(int gram) impure asm "BUYGAS";
|
||||
|
||||
int min(int x, int y) asm "MIN";
|
||||
int max(int x, int y) asm "MAX";
|
||||
(int, int) minmax(int x, int y) asm "MINMAX";
|
||||
int abs(int x) asm "ABS";
|
||||
|
||||
slice begin_parse(cell c) asm "CTOS";
|
||||
() end_parse(slice s) impure asm "ENDS";
|
||||
(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF";
|
||||
cell preload_ref(slice s) asm "PLDREF";
|
||||
;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX";
|
||||
;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX";
|
||||
;; int preload_int(slice s, int len) asm "PLDIX";
|
||||
;; int preload_uint(slice s, int len) asm "PLDUX";
|
||||
;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX";
|
||||
;; slice preload_bits(slice s, int len) asm "PLDSLICEX";
|
||||
(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS";
|
||||
slice skip_bits(slice s, int len) asm "SDSKIPFIRST";
|
||||
(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST";
|
||||
slice first_bits(slice s, int len) asm "SDCUTFIRST";
|
||||
slice skip_last_bits(slice s, int len) asm "SDSKIPLAST";
|
||||
(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST";
|
||||
slice slice_last(slice s, int len) asm "SDCUTLAST";
|
||||
(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT";
|
||||
cell preload_dict(slice s) asm "PLDDICT";
|
||||
slice skip_dict(slice s) asm "SKIPDICT";
|
||||
|
||||
(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF";
|
||||
cell preload_maybe_ref(slice s) asm "PLDOPTREF";
|
||||
builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF";
|
||||
|
||||
int cell_depth(cell c) asm "CDEPTH";
|
||||
|
||||
int slice_refs(slice s) asm "SREFS";
|
||||
int slice_bits(slice s) asm "SBITS";
|
||||
(int, int) slice_bits_refs(slice s) asm "SBITREFS";
|
||||
int slice_empty?(slice s) asm "SEMPTY";
|
||||
int slice_data_empty?(slice s) asm "SDEMPTY";
|
||||
int slice_refs_empty?(slice s) asm "SREMPTY";
|
||||
int slice_depth(slice s) asm "SDEPTH";
|
||||
|
||||
int builder_refs(builder b) asm "BREFS";
|
||||
int builder_bits(builder b) asm "BBITS";
|
||||
int builder_depth(builder b) asm "BDEPTH";
|
||||
|
||||
builder begin_cell() asm "NEWC";
|
||||
cell end_cell(builder b) asm "ENDC";
|
||||
builder store_ref(builder b, cell c) asm(c b) "STREF";
|
||||
;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX";
|
||||
;; builder store_int(builder b, int x, int len) asm(x b len) "STIX";
|
||||
builder store_slice(builder b, slice s) asm "STSLICER";
|
||||
builder store_grams(builder b, int x) asm "STGRAMS";
|
||||
builder store_dict(builder b, cell c) asm(c b) "STDICT";
|
||||
|
||||
(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR";
|
||||
tuple parse_addr(slice s) asm "PARSEMSGADDR";
|
||||
(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR";
|
||||
(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR";
|
||||
|
||||
cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF";
|
||||
(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF";
|
||||
cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF";
|
||||
(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF";
|
||||
cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF";
|
||||
(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF";
|
||||
(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF";
|
||||
(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF";
|
||||
(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF";
|
||||
(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";
|
||||
(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";
|
||||
(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT";
|
||||
(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT";
|
||||
(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT";
|
||||
(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT";
|
||||
(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT";
|
||||
(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT";
|
||||
cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET";
|
||||
(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET";
|
||||
cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET";
|
||||
(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET";
|
||||
cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET";
|
||||
(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET";
|
||||
(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD";
|
||||
(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE";
|
||||
(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD";
|
||||
(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE";
|
||||
cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB";
|
||||
(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB";
|
||||
cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB";
|
||||
(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB";
|
||||
cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB";
|
||||
(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB";
|
||||
(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB";
|
||||
(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB";
|
||||
(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB";
|
||||
(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB";
|
||||
(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
|
||||
(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
|
||||
(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
|
||||
(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
|
||||
(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
|
||||
(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
|
||||
(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2";
|
||||
(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2";
|
||||
(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2";
|
||||
(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2";
|
||||
(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2";
|
||||
(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2";
|
||||
cell new_dict() asm "NEWDICT";
|
||||
int dict_empty?(cell c) asm "DICTEMPTY";
|
||||
|
||||
(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2";
|
||||
(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET";
|
||||
(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL";
|
||||
|
||||
cell config_param(int x) asm "CONFIGOPTPARAM";
|
||||
int cell_null?(cell c) asm "ISNULL";
|
||||
|
||||
() raw_reserve(int amount, int mode) impure asm "RAWRESERVE";
|
||||
() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX";
|
||||
() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG";
|
||||
() set_code(cell new_code) impure asm "SETCODE";
|
||||
|
||||
int random() impure asm "RANDU256";
|
||||
int rand(int range) impure asm "RAND";
|
||||
int get_seed() impure asm "RANDSEED";
|
||||
int set_seed() impure asm "SETRAND";
|
||||
() randomize(int x) impure asm "ADDRAND";
|
||||
() randomize_lt() impure asm "LTIME" "ADDRAND";
|
||||
|
||||
|
||||
int equal_slices (slice a, slice b) asm "SDEQ";
|
||||
int builder_null?(builder b) asm "ISNULL";
|
Loading…
Add table
Add a link
Reference in a new issue