├── LICENSE ├── README.md ├── contract ├── AccessControl.sol ├── DateTime.sol ├── Fund.sol ├── GEBToken DAICO.docx ├── GEBToken.sol ├── PublicRaising.sol ├── Refund.sol ├── SafeMath.sol └── Vote.sol └── whitepaper ├── gebnetwork-whitepaper-en.md ├── gebnetwork-whitepaper-zh.md └── images ├── cross-chain-vertical.jpg ├── daico.jpg ├── data-feed.jpg ├── lightning-swap-vertical.jpg ├── network-structure.jpg ├── oracle.jpg ├── roadmap-horizontal.jpg ├── sharded-pool.jpg ├── swot-en.jpg ├── swot-small.jpg ├── swot.jpg ├── token-distributed-en.jpg ├── token-distributed.jpg └── world.jpg /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DAICO 2 | 3 | # White Paper 4 | - [中文版](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/gebnetwork-whitepaper-zh.md) 5 | - [English](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/gebnetwork-whitepaper-en.md) 6 | -------------------------------------------------------------------------------- /contract/AccessControl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | contract Owner { 4 | //合约拥有者 5 | address public owner; 6 | 7 | //构造函数,将合约的所有权给予发布者 8 | constructor() public { 9 | owner = msg.sender; 10 | } 11 | 12 | //仅有合约的拥有者可以操作 13 | modifier onlyOwner() { 14 | require(msg.sender == owner); 15 | _; 16 | } 17 | 18 | //onlyOwner作为函数执行的前置条件 19 | //仅有合约拥有者可以更换所属权 20 | function newOwner(address to) public onlyOwner { 21 | if(to != address(0)) { 22 | owner = to; 23 | } 24 | } 25 | } 26 | 27 | contract AccessControl is Owner { 28 | 29 | bool public paused = false; 30 | 31 | modifier whenNotPaused() { 32 | require(!paused); 33 | _; 34 | } 35 | 36 | modifier whenPaused { 37 | require(paused); 38 | _; 39 | } 40 | 41 | function pause() external onlyOwner whenNotPaused { 42 | paused = true; 43 | } 44 | 45 | function unpause() public onlyOwner whenPaused { 46 | paused = false; 47 | } 48 | } -------------------------------------------------------------------------------- /contract/DateTime.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | contract DateTime { 4 | /* 5 | * Date and Time utilities for ethereum contracts 6 | * 7 | */ 8 | struct _DateTime { 9 | uint16 year; 10 | uint8 month; 11 | uint8 day; 12 | uint8 hour; 13 | uint8 minute; 14 | uint8 second; 15 | uint8 weekday; 16 | } 17 | 18 | uint constant DAY_IN_SECONDS = 86400; 19 | uint constant YEAR_IN_SECONDS = 31536000; 20 | uint constant LEAP_YEAR_IN_SECONDS = 31622400; 21 | 22 | uint constant HOUR_IN_SECONDS = 3600; 23 | uint constant MINUTE_IN_SECONDS = 60; 24 | 25 | uint16 constant ORIGIN_YEAR = 1970; 26 | 27 | function isLeapYear(uint16 year) public pure returns (bool) { 28 | if (year % 4 != 0) { 29 | return false; 30 | } 31 | if (year % 100 != 0) { 32 | return true; 33 | } 34 | if (year % 400 != 0) { 35 | return false; 36 | } 37 | return true; 38 | } 39 | 40 | function leapYearsBefore(uint year) public pure returns (uint) { 41 | year -= 1; 42 | return year / 4 - year / 100 + year / 400; 43 | } 44 | 45 | function getDaysInMonth(uint8 month, uint16 year) public pure returns (uint8) { 46 | if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { 47 | return 31; 48 | } 49 | else if (month == 4 || month == 6 || month == 9 || month == 11) { 50 | return 30; 51 | } 52 | else if (isLeapYear(year)) { 53 | return 29; 54 | } 55 | else { 56 | return 28; 57 | } 58 | } 59 | 60 | function parseTimestamp(uint timestamp) internal pure returns (_DateTime dt) { 61 | uint secondsAccountedFor = 0; 62 | uint buf; 63 | uint8 i; 64 | 65 | // Year 66 | dt.year = getYear(timestamp); 67 | buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR); 68 | 69 | secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf; 70 | secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf); 71 | 72 | // Month 73 | uint secondsInMonth; 74 | for (i = 1; i <= 12; i++) { 75 | secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year); 76 | if (secondsInMonth + secondsAccountedFor > timestamp) { 77 | dt.month = i; 78 | break; 79 | } 80 | secondsAccountedFor += secondsInMonth; 81 | } 82 | 83 | // Day 84 | for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) { 85 | if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) { 86 | dt.day = i; 87 | break; 88 | } 89 | secondsAccountedFor += DAY_IN_SECONDS; 90 | } 91 | 92 | // Hour 93 | dt.hour = getHour(timestamp); 94 | 95 | // Minute 96 | dt.minute = getMinute(timestamp); 97 | 98 | // Second 99 | dt.second = getSecond(timestamp); 100 | 101 | // Day of week. 102 | dt.weekday = getWeekday(timestamp); 103 | } 104 | 105 | function getYear(uint timestamp) public pure returns (uint16) { 106 | uint secondsAccountedFor = 0; 107 | uint16 year; 108 | uint numLeapYears; 109 | 110 | // Year 111 | year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS); 112 | numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR); 113 | 114 | secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears; 115 | secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears); 116 | 117 | while (secondsAccountedFor > timestamp) { 118 | if (isLeapYear(uint16(year - 1))) { 119 | secondsAccountedFor -= LEAP_YEAR_IN_SECONDS; 120 | } 121 | else { 122 | secondsAccountedFor -= YEAR_IN_SECONDS; 123 | } 124 | year -= 1; 125 | } 126 | return year; 127 | } 128 | 129 | function getMonth(uint timestamp) public pure returns (uint8) { 130 | return parseTimestamp(timestamp).month; 131 | } 132 | 133 | function getDay(uint timestamp) public pure returns (uint8) { 134 | return parseTimestamp(timestamp).day; 135 | } 136 | 137 | function getHour(uint timestamp) public pure returns (uint8) { 138 | return uint8((timestamp / 60 / 60) % 24); 139 | } 140 | 141 | function getMinute(uint timestamp) public pure returns (uint8) { 142 | return uint8((timestamp / 60) % 60); 143 | } 144 | 145 | function getSecond(uint timestamp) public pure returns (uint8) { 146 | return uint8(timestamp % 60); 147 | } 148 | 149 | function getWeekday(uint timestamp) public pure returns (uint8) { 150 | return uint8((timestamp / DAY_IN_SECONDS + 4) % 7); 151 | } 152 | 153 | function toTimestamp(uint16 year, uint8 month, uint8 day) public pure returns (uint timestamp) { 154 | return toTimestamp(year, month, day, 0, 0, 0); 155 | } 156 | 157 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) public pure returns (uint timestamp) { 158 | return toTimestamp(year, month, day, hour, 0, 0); 159 | } 160 | 161 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) public pure returns (uint timestamp) { 162 | return toTimestamp(year, month, day, hour, minute, 0); 163 | } 164 | 165 | function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) public pure returns (uint timestamp) { 166 | uint16 i; 167 | 168 | // Year 169 | for (i = ORIGIN_YEAR; i < year; i++) { 170 | if (isLeapYear(i)) { 171 | timestamp += LEAP_YEAR_IN_SECONDS; 172 | } 173 | else { 174 | timestamp += YEAR_IN_SECONDS; 175 | } 176 | } 177 | 178 | // Month 179 | uint8[12] memory monthDayCounts; 180 | monthDayCounts[0] = 31; 181 | if (isLeapYear(year)) { 182 | monthDayCounts[1] = 29; 183 | } 184 | else { 185 | monthDayCounts[1] = 28; 186 | } 187 | monthDayCounts[2] = 31; 188 | monthDayCounts[3] = 30; 189 | monthDayCounts[4] = 31; 190 | monthDayCounts[5] = 30; 191 | monthDayCounts[6] = 31; 192 | monthDayCounts[7] = 31; 193 | monthDayCounts[8] = 30; 194 | monthDayCounts[9] = 31; 195 | monthDayCounts[10] = 30; 196 | monthDayCounts[11] = 31; 197 | 198 | for (i = 1; i < month; i++) { 199 | timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1]; 200 | } 201 | 202 | // Day 203 | timestamp += DAY_IN_SECONDS * (day - 1); 204 | 205 | // Hour 206 | timestamp += HOUR_IN_SECONDS * (hour); 207 | 208 | // Minute 209 | timestamp += MINUTE_IN_SECONDS * (minute); 210 | 211 | // Second 212 | timestamp += second; 213 | 214 | return timestamp; 215 | } 216 | } -------------------------------------------------------------------------------- /contract/Fund.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | import './AccessControl.sol'; 3 | import './DateTime.sol'; 4 | import './PublicRaising.sol'; 5 | import './GEBToken.sol'; 6 | import './Vote.sol'; 7 | 8 | contract Fund is AccessControl, DateTime { 9 | uint public constant decimals = 18; 10 | uint public constant TAP = 8 ether; 11 | uint public applyTap; 12 | uint public appliedTap; 13 | uint public applyStartTime; 14 | 15 | uint public constant MIN_VALID_VOTES = 100 * 10 ** uint256(decimals); 16 | uint public withdrawalTime; 17 | bool public isContinue = true; 18 | 19 | GEBToken public token; 20 | PublicRaising public raise; 21 | Vote public voteContract; 22 | address public refund; 23 | 24 | constructor(GEBToken _token, PublicRaising _raise, Vote _vote) public { 25 | token = _token; 26 | raise = _raise; 27 | voteContract = _vote; 28 | } 29 | 30 | function timeValidation(uint _time) private view returns(bool) { 31 | bool timeJudge; 32 | if (_time == 0) { 33 | timeJudge = true; 34 | } 35 | else { 36 | _DateTime memory lastTime = parseTimestamp(_time); 37 | _DateTime memory today = parseTimestamp(now); 38 | if (lastTime.year < today.year) { 39 | timeJudge = true; 40 | } 41 | else if (lastTime.year == today.year) { 42 | if (lastTime.month < today.month) { 43 | timeJudge = true; 44 | } 45 | else { 46 | timeJudge = false; 47 | } 48 | } 49 | else { 50 | timeJudge = false; 51 | } 52 | } 53 | return timeJudge; 54 | } 55 | 56 | function addTap(uint _amount) public onlyOwner { 57 | require(appliedTap == 0 && applyTap == 0); 58 | bool timeJudge = timeValidation(applyStartTime); 59 | if (timeJudge) { 60 | applyTap = _amount; 61 | applyStartTime = now; 62 | voteContract.voteStart(now, now + 3 days, MIN_VALID_VOTES, SafeMath.safeDiv(token.totalSupply(), 800)); 63 | } 64 | } 65 | 66 | function vote(bool isApproved) public whenNotPaused { 67 | voteContract.vote(msg.sender, isApproved, token.balanceOf(msg.sender)); 68 | } 69 | 70 | function revokeVote() public whenNotPaused { 71 | voteContract.revokeVote(msg.sender); 72 | } 73 | 74 | modifier onlyTokenContract { 75 | require(msg.sender == address(token)); 76 | _; 77 | } 78 | 79 | function whenTokenTransfer(address _from, address _to, uint _tokens) public onlyTokenContract{ 80 | voteContract.whenTokenTransfer(_from, _to, _tokens); 81 | } 82 | 83 | function finishApplyment() public onlyOwner { 84 | bool applymentSuccess = voteContract.voteStop(); 85 | if(applymentSuccess) { 86 | appliedTap = applyTap; 87 | } 88 | applyTap = 0; 89 | } 90 | 91 | function getTap(address _to) public onlyOwner { 92 | require(_to != address(0) && isContinue); 93 | bool timeJudge = timeValidation(withdrawalTime); 94 | if (timeJudge) { 95 | raise.sendFund(_to, TAP + appliedTap); 96 | appliedTap = 0; 97 | } 98 | } 99 | 100 | function setRefundAddress(address _refund) public onlyOwner { 101 | require(_refund != address(0)); 102 | refund = _refund; 103 | } 104 | 105 | modifier refundContract() { 106 | require(msg.sender == refund); 107 | _; 108 | } 109 | 110 | function programStop() public refundContract { 111 | isContinue = false; 112 | } 113 | } -------------------------------------------------------------------------------- /contract/GEBToken DAICO.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/contract/GEBToken DAICO.docx -------------------------------------------------------------------------------- /contract/GEBToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import './SafeMath.sol'; 4 | import './AccessControl.sol'; 5 | import './Fund.sol'; 6 | import './Refund.sol'; 7 | 8 | contract GEBToken is AccessControl { 9 | string public constant name = "GEB DAICO"; 10 | string public constant symbol = "GEB"; 11 | uint8 public _decimals = 18; 12 | uint256 public _totalSupply = 1000000000 * 10 ** uint256(_decimals); 13 | 14 | mapping(address => uint256) balances; 15 | mapping(address => mapping (address => uint256)) allowed; 16 | 17 | bool voteEnabled = false; 18 | 19 | Fund public fund; 20 | Refund public refund; 21 | 22 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 23 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 24 | 25 | constructor() public { 26 | balances[owner] = _totalSupply; 27 | } 28 | 29 | function totalSupply() public view returns(uint256) { 30 | return _totalSupply; 31 | } 32 | 33 | function decimals() public view returns(uint8) { 34 | return _decimals; 35 | } 36 | 37 | function balanceOf(address _owner) public view returns(uint256) { 38 | return balances[_owner]; 39 | } 40 | 41 | function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { 42 | if (balances[msg.sender] >= _value && _value > 0 43 | && msg.sender != _to && _to != address(0)) { 44 | balances[msg.sender] = SafeMath.safeSub(balances[msg.sender], _value); 45 | balances[_to] = SafeMath.safeAdd(balances[_to], _value); 46 | emit Transfer(msg.sender, _to, _value); 47 | if (voteEnabled) { 48 | fund.whenTokenTransfer(msg.sender, _to, _value); 49 | refund.whenTokenTransfer(msg.sender, _to, _value); 50 | } 51 | return true; 52 | } 53 | else {return false;} 54 | } 55 | 56 | function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { 57 | if(balances[_from] > _value && _value > 0 58 | && _from != _to && _from != address(0) 59 | && _to != address(0) && allowed[_from][msg.sender] > _value) { 60 | balances[_from] = SafeMath.safeSub(balances[_from], _value); 61 | allowed[_from][msg.sender] = SafeMath.safeSub(allowed[_from][msg.sender], _value); 62 | balances[_to] = SafeMath.safeAdd(balances[_to], _value); 63 | emit Transfer(_from, _to, _value); 64 | if (voteEnabled) { 65 | fund.whenTokenTransfer(_from, _to, _value); 66 | refund.whenTokenTransfer(_from, _to, _value); 67 | } 68 | return true; 69 | } 70 | else {return false;} 71 | } 72 | 73 | function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { 74 | allowed[msg.sender][_spender] = _value; 75 | emit Approval(msg.sender, _spender, _value); 76 | return true; 77 | } 78 | 79 | function allowance(address _owner, address _spender) public view returns (uint256) { 80 | return allowed[_owner][_spender]; 81 | } 82 | 83 | function addTotal(uint256 _amount) public whenNotPaused onlyOwner { 84 | _totalSupply = SafeMath.safeAdd(_totalSupply, SafeMath.safeMul(_amount, 10 ** uint256(_decimals))); 85 | balances[owner] = SafeMath.safeAdd(balances[owner], SafeMath.safeMul(_amount, 10 ** uint256(_decimals))); 86 | } 87 | 88 | function setFundAddress(address _fund) public onlyOwner { 89 | require(_fund != address(0)); 90 | fund = Fund(_fund); 91 | } 92 | 93 | function setRefundAddress(address _refund) public onlyOwner { 94 | require(_refund != address(0)); 95 | refund = Refund(_refund); 96 | } 97 | 98 | function setVoteStatus(bool _stat) public onlyOwner { 99 | voteEnabled = _stat; 100 | } 101 | } -------------------------------------------------------------------------------- /contract/PublicRaising.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import './AccessControl.sol'; 4 | import './SafeMath.sol'; 5 | import './GEBToken.sol'; 6 | 7 | contract PublicRaising is AccessControl { 8 | uint public constant decimals = 18; 9 | uint public round; 10 | uint public price; 11 | uint public startTime; 12 | uint public endTime; 13 | uint256 public saleTokens; 14 | uint256 public leftTokensUpperLimit; 15 | 16 | struct raiseParticipant { 17 | address participant; 18 | uint value; 19 | uint tokens; 20 | } 21 | raiseParticipant[] public raiseParticipants; 22 | 23 | bool public inRaising; 24 | 25 | GEBToken public token; 26 | address public fund; 27 | address public refund; 28 | 29 | constructor(GEBToken _token) public { 30 | token = _token; 31 | } 32 | 33 | function newRaisingRound(uint _price, uint _startTime, uint _endTime, uint256 _saleTokens, uint256 _leftTokensUpperLimit) public onlyOwner { 34 | require(!inRaising && _price > 0 && _startTime > 0 && _endTime > 0 && _endTime > _startTime && _leftTokensUpperLimit >= 0); 35 | uint256 tokenWithDecimals = SafeMath.safeMul(_saleTokens, 10 ** uint256(decimals)); 36 | require(token.balanceOf(address(this)) >= tokenWithDecimals); 37 | round = SafeMath.safeAdd(round, 1); 38 | price = _price; 39 | startTime = _startTime; 40 | endTime = _endTime; 41 | saleTokens = tokenWithDecimals; 42 | leftTokensUpperLimit = SafeMath.safeMul(_leftTokensUpperLimit, 10 ** uint256(decimals)); 43 | inRaising = true; 44 | } 45 | 46 | function () payable public whenNotPaused { 47 | require(inRaising && msg.sender != owner); 48 | require(msg.value >= 1 ether); 49 | uint getTokens = SafeMath.safeMul(msg.value, price); 50 | require(saleTokens >= getTokens); 51 | saleTokens = SafeMath.safeSub(saleTokens, getTokens); 52 | raiseParticipants.push(raiseParticipant({participant: msg.sender, value: msg.value, tokens: getTokens})); 53 | } 54 | 55 | function finishRaise() public onlyOwner { 56 | require(!inRaising && now > endTime); 57 | // require(inRaising); 58 | if (saleTokens > leftTokensUpperLimit) { 59 | for (uint i = 0; i < raiseParticipants.length; i++) { 60 | raiseParticipants[i].participant.transfer(raiseParticipants[i].value); 61 | } 62 | } 63 | else { 64 | for (uint j = 0; j < raiseParticipants.length; j++) { 65 | token.transfer(raiseParticipants[j].participant, raiseParticipants[j].tokens); 66 | } 67 | } 68 | delete raiseParticipants; 69 | inRaising = false; 70 | } 71 | 72 | modifier fundAndRefundContract() { 73 | require(msg.sender == fund || msg.sender == refund); 74 | _; 75 | } 76 | 77 | function setFundAddress(address _fund) public onlyOwner { 78 | require(_fund != address(0)); 79 | fund = _fund; 80 | } 81 | 82 | function setRefundAddress(address _refund) public onlyOwner { 83 | require(_refund != address(0)); 84 | refund = _refund; 85 | } 86 | 87 | function sendFund(address _to, uint _value) public fundAndRefundContract { 88 | if (_value > address(this).balance) { 89 | _to.transfer(address(this).balance); 90 | } 91 | else { 92 | _to.transfer(_value); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /contract/Refund.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | import './GEBToken.sol'; 4 | import './PublicRaising.sol'; 5 | import './DateTime.sol'; 6 | import './Fund.sol'; 7 | import './SafeMath.sol'; 8 | import './AccessControl.sol'; 9 | import './Vote.sol'; 10 | 11 | contract Refund is AccessControl, DateTime { 12 | uint public constant decimals = 18; 13 | 14 | // uint[4] public FIRST_REFUND_VOTE_TIME = [uint(1551369600), 1567267200, 1582992000, 1598889600]; 15 | // uint[4] public SECOND_REFUND_VOTE_TIME = [uint(1554048000), 1569859200, 1585670400, 1601481600]; 16 | 17 | uint[4] public FIRST_REFUND_VOTE_TIME = [uint(now), 1567267200, 1582992000, 1598889600]; 18 | uint[4] public SECOND_REFUND_VOTE_TIME = [uint(now), 1569859200, 1585670400, 1601481600]; 19 | uint8 public REFUND_ROUND = 0; 20 | uint8 public REFUND_STAGE = 1; 21 | 22 | bool public firstStageStatus = false; 23 | bool public isValid = true; 24 | 25 | uint public constant MIN_VALID_VOTES = 100 * 10 ** uint256(decimals); 26 | 27 | PublicRaising public raise; 28 | GEBToken public token; 29 | Fund public fund; 30 | Vote public voteContract; 31 | 32 | constructor (PublicRaising _raise, GEBToken _token, Fund _fund, Vote _vote) public { 33 | raise = _raise; 34 | token = _token; 35 | fund = _fund; 36 | voteContract = _vote; 37 | } 38 | 39 | modifier whenValid() { 40 | require(isValid); 41 | _; 42 | } 43 | 44 | uint public REFUND_PRICE; 45 | 46 | function refundVoteStart() public onlyOwner whenValid { 47 | if (REFUND_STAGE == 1) { 48 | require(now <= FIRST_REFUND_VOTE_TIME[REFUND_ROUND]); 49 | voteContract.voteStart(FIRST_REFUND_VOTE_TIME[REFUND_ROUND], FIRST_REFUND_VOTE_TIME[REFUND_ROUND] + 7 days, MIN_VALID_VOTES, SafeMath.safeDiv(token.totalSupply(), 4000)); 50 | voteContract.voteStart(now, now + 7 days, MIN_VALID_VOTES, SafeMath.safeDiv(token.totalSupply(), 4000)); 51 | } 52 | if (REFUND_STAGE == 2) { 53 | require(firstStageStatus && now <= SECOND_REFUND_VOTE_TIME[REFUND_ROUND]); 54 | voteContract.voteStart(SECOND_REFUND_VOTE_TIME[REFUND_ROUND], SECOND_REFUND_VOTE_TIME[REFUND_ROUND] + 7 days, MIN_VALID_VOTES, SafeMath.safeDiv(token.totalSupply(), 4000)); 55 | voteContract.voteStart(now, now + 7 days, MIN_VALID_VOTES, SafeMath.safeDiv(token.totalSupply(), 4000)); 56 | } 57 | } 58 | 59 | function vote(bool _agree) public whenNotPaused whenValid { 60 | voteContract.vote(msg.sender, _agree, token.balanceOf(msg.sender)); 61 | } 62 | 63 | function revokeVote() public whenNotPaused whenValid { 64 | voteContract.revokeVote(msg.sender); 65 | } 66 | 67 | modifier onlyTokenContract { 68 | require(msg.sender == address(token)); 69 | _; 70 | } 71 | 72 | function whenTokenTransfer(address _from, address _to, uint _tokens) public onlyTokenContract { 73 | voteContract.whenTokenTransfer(_from, _to, _tokens); 74 | } 75 | 76 | function voteStatistics() public onlyOwner whenValid { 77 | bool voteResult = voteContract.voteStop(); 78 | if (REFUND_STAGE == 1) { 79 | if (!voteResult) { 80 | if (REFUND_ROUND == 3) { 81 | isValid = false; 82 | } 83 | else { 84 | REFUND_ROUND = uint8(SafeMath.safeAdd(REFUND_ROUND, 1)); 85 | } 86 | } 87 | else { 88 | firstStageStatus = true; 89 | REFUND_STAGE = 2; 90 | } 91 | } 92 | else if (REFUND_STAGE == 2) { 93 | if (!voteResult) { 94 | if (REFUND_ROUND == 3) { 95 | isValid = false; 96 | } 97 | else { 98 | REFUND_ROUND = uint8(SafeMath.safeAdd(REFUND_ROUND, 1)); 99 | } 100 | REFUND_STAGE = 1; 101 | firstStageStatus = false; 102 | } 103 | else { 104 | isValid = false; 105 | fund.programStop(); 106 | } 107 | } 108 | else { 109 | revert(); 110 | } 111 | } 112 | 113 | function setRefundPrice(uint _price) public onlyOwner { 114 | require(_price > 0 && !isValid); 115 | REFUND_PRICE = _price; 116 | } 117 | 118 | function refund() public whenNotPaused { 119 | require(!isValid && REFUND_PRICE != 0); 120 | raise.sendFund(msg.sender, SafeMath.safeDiv(token.balanceOf(msg.sender), REFUND_PRICE)); 121 | } 122 | 123 | function programSuccess() public onlyOwner whenValid { 124 | isValid = false; 125 | } 126 | 127 | } -------------------------------------------------------------------------------- /contract/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | library SafeMath { 3 | function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { 4 | uint256 c = a * b; 5 | assert(a == 0 || c / a == b); 6 | return c; 7 | } 8 | 9 | function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { 10 | uint256 c = a / b; 11 | return c; 12 | } 13 | 14 | function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { 15 | assert(a >= b); 16 | return a - b; 17 | } 18 | 19 | function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { 20 | uint256 c = a + b; 21 | assert(c >= a); 22 | return c; 23 | } 24 | } -------------------------------------------------------------------------------- /contract/Vote.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23;import './SafeMath.sol'; 2 | contract Vote { 3 | struct singleVote { 4 | uint voteTime; 5 | bool agree; 6 | uint weight; 7 | } 8 | struct totalVotes { 9 | uint startTime; 10 | uint endTime; 11 | uint agreeCount; 12 | uint disagreeCount; 13 | uint minValidWeight; 14 | uint maxSingleWeight; 15 | bool inVoting; 16 | mapping(address => singleVote) voteByAddress; 17 | } 18 | mapping(address => totalVotes) public totalVotesByAddress; 19 | 20 | function voteStart(uint _startTime, uint _endTime, uint _minWeight, uint _maxSingleWeight) public { 21 | require(_endTime > _startTime && !totalVotesByAddress[msg.sender].inVoting && now <= _startTime); 22 | totalVotesByAddress[msg.sender].startTime = _startTime; 23 | totalVotesByAddress[msg.sender].endTime = _endTime; 24 | totalVotesByAddress[msg.sender].inVoting = true; 25 | totalVotesByAddress[msg.sender].minValidWeight = _minWeight; 26 | totalVotesByAddress[msg.sender].maxSingleWeight = _maxSingleWeight; 27 | } 28 | 29 | function vote(address _voteAddress, bool _agree, uint _weight) public { 30 | require(totalVotesByAddress[msg.sender].inVoting); 31 | require(now >= totalVotesByAddress[msg.sender].startTime && now <= totalVotesByAddress[msg.sender].endTime); 32 | require(totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].voteTime < totalVotesByAddress[msg.sender].startTime); 33 | if (_weight > totalVotesByAddress[msg.sender].maxSingleWeight) { 34 | _weight = totalVotesByAddress[msg.sender].maxSingleWeight; 35 | } 36 | if(_agree) { 37 | totalVotesByAddress[msg.sender].agreeCount = SafeMath.safeAdd(totalVotesByAddress[msg.sender].agreeCount, _weight); 38 | } 39 | else { 40 | totalVotesByAddress[msg.sender].disagreeCount = SafeMath.safeAdd(totalVotesByAddress[msg.sender].disagreeCount , _weight); 41 | } 42 | totalVotesByAddress[msg.sender].voteByAddress[_voteAddress] = singleVote({voteTime: now, agree: _agree, weight: _weight}); 43 | } 44 | 45 | function revokeVote(address _voteAddress) public { 46 | require(totalVotesByAddress[msg.sender].inVoting); 47 | require(now >= totalVotesByAddress[msg.sender].startTime && now <= totalVotesByAddress[msg.sender].endTime); 48 | require(totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].voteTime >= totalVotesByAddress[msg.sender].startTime 49 | && totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].voteTime <= totalVotesByAddress[msg.sender].endTime); 50 | if (totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].agree) { 51 | totalVotesByAddress[msg.sender].agreeCount = SafeMath.safeSub(totalVotesByAddress[msg.sender].agreeCount, 52 | totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].weight); 53 | } 54 | else { 55 | totalVotesByAddress[msg.sender].disagreeCount = SafeMath.safeSub(totalVotesByAddress[msg.sender].disagreeCount, 56 | totalVotesByAddress[msg.sender].voteByAddress[_voteAddress].weight); 57 | } 58 | delete totalVotesByAddress[msg.sender].voteByAddress[_voteAddress]; 59 | } 60 | 61 | function voteStop() public returns(bool) { 62 | require(totalVotesByAddress[msg.sender].inVoting); 63 | // require(now > totalVotesByAddress[msg.sender].endTime && totalVotesByAddress[msg.sender].inVoting); 64 | bool result; 65 | if (SafeMath.safeAdd(totalVotesByAddress[msg.sender].agreeCount, totalVotesByAddress[msg.sender].disagreeCount) 66 | < totalVotesByAddress[msg.sender].minValidWeight) { 67 | result = false; 68 | } 69 | else { 70 | if (totalVotesByAddress[msg.sender].agreeCount < totalVotesByAddress[msg.sender].disagreeCount) { 71 | result = false; 72 | } 73 | else { 74 | result = true; 75 | } 76 | } 77 | delete totalVotesByAddress[msg.sender]; 78 | return result; 79 | } 80 | 81 | function whenTokenTransfer(address _from, address _to, uint _tokens) public { 82 | if (totalVotesByAddress[msg.sender].inVoting) { 83 | singleVote memory from = totalVotesByAddress[msg.sender].voteByAddress[_from]; 84 | singleVote memory to = totalVotesByAddress[msg.sender].voteByAddress[_to]; 85 | uint _weight = _tokens; 86 | if (_weight > totalVotesByAddress[msg.sender].maxSingleWeight) { 87 | _weight = totalVotesByAddress[msg.sender].maxSingleWeight; 88 | } 89 | if (from.voteTime > totalVotesByAddress[msg.sender].startTime && from.voteTime < totalVotesByAddress[msg.sender].endTime) { 90 | totalVotesByAddress[msg.sender].voteByAddress[_from].weight = SafeMath.safeSub(from.weight, _weight); 91 | if (from.agree) { 92 | totalVotesByAddress[msg.sender].agreeCount = SafeMath.safeSub(totalVotesByAddress[msg.sender].agreeCount, _weight); 93 | } 94 | else { 95 | totalVotesByAddress[msg.sender].disagreeCount = SafeMath.safeSub(totalVotesByAddress[msg.sender].disagreeCount, _weight); 96 | } 97 | } 98 | if (to.voteTime > totalVotesByAddress[msg.sender].startTime && to.voteTime < totalVotesByAddress[msg.sender].endTime) { 99 | totalVotesByAddress[msg.sender].voteByAddress[_to].weight = SafeMath.safeAdd(to.weight, _weight); 100 | if (to.agree) { 101 | totalVotesByAddress[msg.sender].agreeCount = SafeMath.safeAdd(totalVotesByAddress[msg.sender].agreeCount, _weight); 102 | } 103 | else { 104 | totalVotesByAddress[msg.sender].disagreeCount = SafeMath.safeAdd(totalVotesByAddress[msg.sender].disagreeCount, _weight); 105 | } 106 | } 107 | } 108 | } 109 | } 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /whitepaper/gebnetwork-whitepaper-zh.md: -------------------------------------------------------------------------------- 1 | #

GEB Network

2 | 3 | ##

去中心化的抵押借贷及OTC交易协议

4 | 5 | ##

摘要

6 |   我们描述了一种基于以太坊区块链的去中心化的抵押借贷及OTC交易协议。该协议会成为构建一个全球性的点对点抵押借贷及OTC交易网络的开放标准和基石,为基于该协议构建的DApp提供了可靠的互操作性。任何DApp都可以通过内嵌一系列免费,公开的以太坊智能合约模板来执行抵押借贷及OTC交易。基于该协议构建的DApp可以建立自己的流动性池,也可以从共享的流动性池中获取交易订单,并通过撮合交易收取手续费获利。一个分散的陪审员网络将被用于仲裁可能出现的交易纠纷,并通过代币经济激励保证网络的公正性。该协议保证了不偏袒协议的任何一方,协议本身不收取任何费用。一个去中心化自治组织(DAO)将负责管理协议的升级并确保协议的安全性和兼容性。
7 | 8 | #### 目录 9 | - [1. GEB Network简介](#1-geb-network简介) 10 | - [1.1. 背景介绍](#11-背景介绍) 11 | - [1.2. 什么是 GEB Network](#12-什么是-geb-network) 12 | - [1.3. GEB Network的主要特点](#13-geb-network的主要特点) 13 | - [1.4. GEB Network的商业模式](#14-geb-network的商业模式) 14 | - [2. 现有方案的问题](#2-现有方案的问题) 15 | - [2.1. 线下交易](#21-线下交易) 16 | - [2.2. 中心化的OTC交易所](#22-中心化的otc交易所) 17 | - [2.3. 中心化的抵押贷款机构](#23-中心化的抵押贷款机构) 18 | - [2.4. GEB协议的优势](#24-geb协议的优势) 19 | - [2.4.1. 对协议参与者](#241-对协议参与者) 20 | - [2.4.2. 竞争对手比较](#242-竞争对手比较) 21 | - [3. GEB协议详述](#3-geb协议详述) 22 | - [3.1. 协议流程](#31-协议流程) 23 | - [3.1.1. OTC交易协议](#311-otc交易协议) 24 | - [3.1.2. 抵押借贷协议](#312-抵押借贷协议) 25 | - [3.2. 交易订单格式](#32-交易订单格式) 26 | - [3.2.1. OTC交易订单](#321-otc交易订单) 27 | - [3.2.2. 抵押贷款交易订单](#322-抵押贷款交易订单) 28 | - [3.3. 价格、利率、清算与保护机制](#33-价格利率清算与保护机制) 29 | - [3.4. 黑天鹅事件](#34-黑天鹅事件) 30 | - [3.5. 智能合约技术](#35-智能合约技术) 31 | - [3.5.1. 签名认证](#351-签名认证) 32 | - [3.5.2. 时间锁定](#352-时间锁定) 33 | - [3.5.3. 填充和部分填充订单](#353-填充和部分填充订单) 34 | - [3.5.4. 过期时间](#354-过期时间) 35 | - [3.5.5. 取消订单](#355-取消订单) 36 | - [3.5.6. WETH合约](#356-weth合约) 37 | - [3.6. 非以太坊加密货币兼容](#36-非以太坊加密货币兼容) 38 | - [3.6.1. 双向挂钩(2-way peg)技术【当前方案】](#361-双向挂钩2-way-peg技术当前方案) 39 | - [3.6.2. 闪电原子交换(Lighting atomic swap)技术【演进方案】](#362-闪电原子交换lighting-atomic-swap技术演进方案) 40 | - [4. GEB协议代币](#4-geb协议代币) 41 | - [4.1. GEB代币经济模型](#41-geb代币经济模型) 42 | - [4.2. GEB代币用例](#42-geb代币用例) 43 | - [4.3. GEB代币增发](#43-geb代币增发) 44 | - [4.4. Aragon DAO治理](#44-aragon-dao治理) 45 | - [4.5. 首次代币发行](#45-首次代币发行) 46 | - [4.5.1. 代币发行计划——IEO【备选1】](#451-代币发行计划ieo备选1) 47 | - [4.5.2. 代币发行计划——DAICO【备选2】](#452-代币发行计划daico备选2) 48 | - [4.5.3. 代币分配计划](#453-代币分配计划) 49 | - [4.5.4. 资金取款](#454-资金取款) 50 | - [4.6. GEB投资基金](#46-geb投资基金) 51 | - [5. GEB协议生态](#5-geb协议生态) 52 | - [5.1. GEB Network整体架构](#51-geb-network整体架构) 53 | - [5.2. 陪审员网络](#52-陪审员网络) 54 | - [5.2.1. 陪审员申请](#521-陪审员申请) 55 | - [5.2.2. 仲裁流程](#522-仲裁流程) 56 | - [5.2.3. 经济激励与保证金](#523-经济激励与保证金) 57 | - [5.2.4. 退出机制](#524-退出机制) 58 | - [5.3. 交易商网络](#53-交易商网络) 59 | - [5.4. 去中心化身份认证](#54-去中心化身份认证) 60 | - [5.4.1. DID与DID文档](#541-did与did文档) 61 | - [5.4.2. GEB Connect](#542-geb-connect) 62 | - [5.5. 共享流动性池](#55-共享流动性池) 63 | - [5.5.1. 共享订单](#551-共享订单) 64 | - [5.5.2. 微服务与集群](#552-微服务与集群) 65 | - [5.6. 可信预言机集合](#56-可信预言机集合) 66 | - [5.7. GEB开源软件](#57-geb开源软件) 67 | - [6. 协议安全分析](#6-协议安全分析) 68 | - [6.1. 法币转移风险](#61-法币转移风险) 69 | - [6.2. 预言机攻击](#62-预言机攻击) 70 | - [6.3. 中间人攻击](#63-中间人攻击) 71 | - [6.4. 女巫攻击或拒绝服务攻击](#64-女巫攻击或拒绝服务攻击) 72 | - [6.5. Penny-Spend 攻击](#65-penny-spend-攻击) 73 | - [6.6. 信心攻击](#66-信心攻击) 74 | - [6.7. 智能合约代码审核](#67-智能合约代码审核) 75 | - [7. 市场分析](#7-市场分析) 76 | - [7.1. 加密货币市场现状](#71-加密货币市场现状) 77 | - [7.2. 世界各国对区块链的态度](#72-世界各国对区块链的态度) 78 | - [7.3. SWOT分析](#73-swot分析) 79 | - [8. 路线图](#8-路线图) 80 | - [9. 团队介绍](#9-团队介绍) 81 | - [10. 顾问](#10-顾问) 82 | - [11. 参考文献](#11-参考文献) 83 | 84 | ## 1. GEB Network简介 85 | 86 | ### 1.1. 背景介绍 87 |   数字经济正在快速增长。2012年,波士顿咨询集团评估仅G20国家数字经济的潜力为4.2万亿美元。此外,2015年牛津大学经济学系与埃森哲的联合研究得出结论,到2020年,数字经济将为全球国内生产总值贡献1.36万亿美元。数字经济的快速增长增加了对在线支付的需求,而加密货币正在成为日益流行的满足数字经济要求的支付解决方案。
88 |   区块链代表着由去中心化、不可篡改、无需信任等一系列特性所构建的价值传输网络。区块链技术能够在网络中建立点对点之间的可靠信任,使得价值传递过程脱离对中介的依赖,既公开信息又保护隐私,既共同决策又保护个体权益,这种机制提高了价值交互的效率并降低了交易成本。
89 |   今天,世界上已经有数千种加密货币,任何人都可以安全地持有加密货币。但是,在世界的很多地方,加密货币与法币之间的交易依然困难并且成本高昂,这阻碍了加密货币的普及并扭曲了交易价格。目前,加密货币与法币的交易主要通过中心化的OTC交易平台进行。大多数国家缺乏加密货币立法,这意味着此类交易平台不需要获得许可证,也不受监管。因此,用户在此类平台进行交易往往承受了较高的资金安全与隐私泄露风险,与此同时,交易平台有可能操纵交易价格以获取超额利润。
90 |   在Poloniex, Bitfinex等中心化的加密货币交易所,USDT被当作USD的数字替代品进行交易。然而,USDT作为由Tether公司发行的一种中心化的锚定美元的数字货币,长期以来存在诸多严重问题,主要包括:
91 | 1. Tether公司可能破产
92 | 2. Tether公司开设账户的银行可能破产
93 | 3. 银行可能冻结Tether公司的资金
94 | 4. Tether公司可能超发USDT
95 | 5. 手续费贵,到账速度慢,提现困难
96 | 6. Tether公司曾爆出账户被盗的安全问题
97 | 98 |   显而易见的是,如果用户能够安全方便地进行加密货币和法币之间的交易,对USDT类的法币的数字替代品的需求将会显著下降。
99 |   加密货币领域另一个显著的问题是没有一个去中心化的服务可以让加密货币持有者安全地通过抵押加密货币借入法币,而这已经成为一个显著的需求,特别是对于持有大量加密货币并对加密货币价格看涨的用户。而全球的法币投资者也在寻找低风险,高收益的投资渠道,他们向来非常青睐有抵押的借贷市场。中心化的抵押贷款服务商经常利用自己的垄断优势获取超额利润,也更容易受到来自市场价格波动,经营管理不善,内部人员贪腐,监管政策变化等因素的影响。此外,对于隐私泄露风险的忧虑也将促使用户向去中心化的服务转移。
100 |   在GEB Network,我们相信交易应该直接在有关各方之间进行,而不需要使用中介,人们应该可以自由地管理自己的资产,而不受第三方的干扰。GEB协议实现了个人之间无需信任第三方进行加密货币和法币的交易和抵押借贷的想法。GEB Network白皮书详细描述了该协议的技术细节,以及我们的后续开发计划。
101 | 102 | ### 1.2. 什么是 GEB Network 103 |   GEB Network项目的目标是通过GEB协议创建一个去中心的抵押借贷及OTC交易网络。GEB协议允许用户在没有中间人的情况下进行加密货币与法币之间的交易,或者以加密货币作为抵押借入法币,并使用智能合约来防止欺诈行为。加入GEB Network的用户可以从加密货币市场的发展中受益,同时缓解由加密货币价格波动,不诚实的交易商等因素带来的风险。
104 |   GEB Network项目的关键要素是GEB交易市场节点。GEB协议使用一种我们称之为“链下订单中继链上结算”的混合技术实现了交易的效率与安全的平衡。在这种方法中,带加密签名的交易订单是通过链下通道发送的,感兴趣的交易对手可以将一个或多个交易订单注入智能合约中,以便确保使用智能合约完成交易。GEB协议显著降低了做市商的交易摩擦成本,因为交易意图可以通过链下发送,而链上交易只有在价值转移时才会发生。我们通过开放GEB交易市场节点申请和将GEB协议设计为应用程序无关的方式扩展GEB Network。
105 |   GEB Network为交易商和用户提供了显著的优势。GEB交易市场将为用户提供准确的市场数据,以及公平,透明,安全和低费率的OTC交易和抵押借贷服务。每个GEB交易市场节点代表一个独立的商业机构,并将从其提供的各种金融服务中获得收入。我们的使命是促进加密货币社区的健康发展。
106 | 107 | ### 1.3. GEB Network的主要特点 108 | - 支持加密货币与法币的交易和抵押借贷 109 | - 支持ETH,ERC20,BTC,BCH,未来计划支持更多种加密货币 110 | - 使用代币经济模型构建分布式商业网络 111 | - 用户必须通过去中心化的身份认证才能进行交易 112 | - 交易双方无需信任任何一个第三方中介,交易的安全性通过协议保证 113 | - 交易协议通过一组部署在以太坊上的智能合约(DEX Contract)实现 114 | - 通过带时间锁定的智能合约(Timelock Contract)解决交易对手恶意退出风险 115 | - 仅支持不可逆转的法币转账方式,以最大限度的降低退款风险(参见https://en.bitcoin.it/wiki/Payment_methods) 116 | - 分散的陪审员网络作为主要的交易保护机制 117 | - 限制交易金额(50ETH)以降低整体风险敞口 118 | - 智能合约持有所有交易详情,并由交易双方签名,如有争议,将用作证据 119 | - 通过ethereum-alarm-clock定时调用价格预言机合约,从可信预言机集合(trusted-oracles-set)获取抵押代币实时价格 120 | - 通过强制清算机制解决抵押物价格下跌的风险 121 | - 通过协议代币增发机制解决抵押物价格快速跌破债务金额(来不及强制清算)的风险 122 | - 使用Aragon软件进行去中心化治理 123 | - 使用Zeppelin_OS安全地构建和管理智能合约 124 | - 使用开源许可证(AGPL)发布源代码 125 | 126 | ### 1.4. GEB Network的商业模式 127 |   GEB Network不是一家公司,而是一个旨在填补加密货币生态系统缺口的开源项目。GEB基金会是由GEB团队于2018年6月在新加坡成立的非盈利机构。设立GEB基金会的目的是保证GEB项目的可持续性,去中心化治理的有效性,募集资金的安全性和透明性,以及协助创业公司在GEB协议上进行开发与商业创新。
128 |   GEB基金会建立了完善的激励机制来推动GEB Network的健康发展,主要包括:
129 | - 交易市场节点需要通过审核并向GEB基金会抵押一定数量的GEB Token作为保证金,交易市场可以通过收取交易手续费获利。 130 | - 陪审员节点需要通过审核并向GEB基金会抵押一定数量的GEB Token作为保证金。每次仲裁结束,裁决结果合理的陪审员会获得代币奖励,裁决结果不合理的陪审员会遭受代币损失(详见5.2.3)。 131 | - 用户使用GEB Token支付OTC交易手续费可以享受50%折扣优惠,优惠部分由GEB Token增发补足。 132 | - 用户使用GEB Token作为抵押物借款可以享受50%的手续费优惠,并且获得更高的抵押率和更低的清算线,优惠部分由GEB Token增发补足。 133 | - GEB Token持有者可以参与GEB协议治理,对协议开发者提出的协议改进提案进行投票。 134 | 135 |

136 | ## 2. 现有方案的问题 137 | 138 | ### 2.1. 线下交易 139 |   交易双方通过Facebook,Telegram,微信,QQ等软件约定交易数量,交易价格,交易时间地点,交易没有第三方参与。这种方法一般适用于同城交易,且具有较高的资金安全风险,甚至存在人身安全风险。由于加密货币的匿名性,一旦一方违约,另一方的权益很难得到保障,事后取证和举证更是困难重重。除了个别国家以发放牌照的方式将加密货币交易纳入监管框架,多数国家和地区的加密货币交易都没有法律保护,这也提高了交易者遭遇欺诈风险的概率。
140 | 141 | ### 2.2. 中心化的OTC交易所 142 |   Localbitcoins,otcbtc,huobi等OTC交易平台向用户提供C2C模式的加密货币/法币交易服务。这是一种类似于Ebay和Taobao的担保交易模式。加密货币出售方在平台上发布出售广告,并将相应数量的加密货币转入交易平台提供的地址。购买方填写并提交购买订单后,需要将法币转入出售方指定的账户。待出售方确认法币到账以后,交易平台将加密货币转入购买方地址。如果交易过程中出现纠纷,由交易平台进行仲裁。
143 |   这种交易方式依赖于对中心化交易平台的信任,而这种模型的脆弱性已经被反复证明(Mt.Gox,CoinCheck,Bithumb等知名交易所均曾被黑客入侵)。具体而言,中心化交易平台对用户存在如下风险:
144 | 1. 交易平台破产
145 | 2. 交易平台挪用用户资金
146 | 3. 交易平台遭受黑客攻击
147 | 4. 合规/监管风险
148 | 5. 交易平台操纵价格
149 | 6. 交易平台垄断市场,收取高额手续费
150 | 151 | ### 2.3. 中心化的抵押贷款机构 152 |   中心化的抵押贷款机构通常只能服务于特定的地区和人群。在银行等传统机构办理抵押贷款通常流程繁琐,成本高昂,并且充满了不公平和不透明的条款。目前,世界上绝大部分贷款机构还不能接受加密货币作为抵押物。我们希望加密货币持有者能从世界的任何地方获得贷款,而不依赖于当地的银行和抵押贷款机构。
153 |   今天,不平等影响了全球抵押贷款市场,贷款市场受政府货币政策控制,不同的风险水平和法币通胀率造成了国家和地区之间的利率差异。例如,巴西的房地产抵押贷款可能会有32%的年利率(通胀调整),而欧洲的类似贷款可能会有0.5%~5%的年利率。另一方面,通过设置准入门槛和对资金,征信数据,市场渠道等资源的垄断,银行和抵押贷款机构通常在存款人和借款人之间收取高额的利差(中国的信用卡年化利率在20%左右,而同期一年定期存款的利率仅为1.75%)。当区块链技术和抵押贷款市场结合时,真正的革命可能发生。借助GEB Network,抵押贷款市场将对所有贷款人和借款人开放,贷款将不受国界,司法管辖区和银行系统的限制。法币持有者可以安全地向任何人贷款,并获得他们满意的利率。加密货币持有者可以在世界的任何地方方便地获得贷款,并且只需承担低于银行等传统金融机构给出的利率。由于加密货币不受某个国家或地区货币政策的控制,当越来越多的人开始使用GEB Network,越来越多的流动性被注入市场。由于竞争更加激烈,在中国或者欧洲或者非洲,抵押贷款市场都具有相同的流动性,国家和地区之间的利率差异将会消失。 154 |      155 | ### 2.4. GEB协议的优势 156 | 157 | #### 2.4.1. 对协议参与者 158 | 159 | | 角色 | 优势 | 160 | | :----- | :------------------------------ | 161 | | OTC交易者 | 随时随地与任何交易对手进行方便,安全,快速,低费用的OTC交易 | 162 | | 借款人 | 通过抵押数字货币,获得低利率的法币贷款 | 163 | | 放贷人 | 获得安全且收益率高于银行利率的法币投资渠道 | 164 | | 交易商 | 维护一个订单簿,并通过促成交易收取手续费获利 | 165 | | 陪审员 | 通过仲裁智能合约无法判断的争议获取代币奖励 | 166 | 167 | #### 2.4.2. 竞争对手比较 168 | 169 | | | ***GEB Network*** | ETHlend | SALT | Everex | Libra | Coinloan | 170 | | :-------: | :-------------------: | :----------: | :------------: | :------------: | :------------: | :----------: | 171 | |   项目类型   |  ***协议型(P2P交易协议)***   | 平台型(P2P交易平台) | 平台型(P2P交易平台) | 应用型(去中心化抵押贷款机构) | 应用型(去中心化抵押贷款机构) | 平台型(P2P交易平台) | 172 | | 去中心化程度 | ***完全*** | 高 | 中等 | 低 | 低 | 中等 | 173 | | 安全性 | ***高(智能合约保证)*** | 高(智能合约保证) | 中等(需要信任平台) | 中等(需要信任机构) | 中等(需要信任机构) | 中等(需要信任平台) | 174 | | 生态扩张能力 | ***强(利润分配广泛)*** | 中等 | 中等 | 低 | 低 | 中等 | 175 | | OTC交易功能 | ***有*** | 无 | 无 | 无 | 无 | 无 | 176 | | 链下争议 解决方案 | ***分散的陪审员网络*** | 无 | 精简仲裁 | 无 | 无 | 无 | 177 | | 跨链技术方案 | ***双向挂钩,闪电原子交换*** | 无明确说明 | 无明确说明 | 无明确说明 | 无明确说明 | 无明确说明 | 178 | | 用户隐私保护 | ***去中心化身份认证*** | 无明确说明 | 授权获取用户数据,分布式存储 | 授权获取用户数据 | 无明确说明 | 无明确说明 | 179 | | Token升值逻辑 | ***抵押需求,保证金需求,代币回购*** | 抵押需求 | 抵押需求 | 抵押需求 | 抵押需求 | 抵押需求 | 180 | 181 |

182 | ## 3. GEB协议详述 183 | 184 | ### 3.1. 协议流程 185 | 186 | #### 3.1.1. OTC交易协议 187 | 1. Maker和Taker均需要通过Relayer进行KYC。
188 | 2. Maker批准DEX contract使用他的账户中的Token A。
189 | 3. Maker通过Relayer提供的DApp创建出售Token A获取法币B的订单,设置好交易数量X,交易价格,法币接收账户和订单过期时间,并用自己的私钥签名。
190 | 4. Maker把签名后的订单发送给Relayer。
191 | 5. Relayer接收订单并对订单进行校验。如果校验失败,此订单将被拒绝接收;如果校验成功,Relayer将此订单写入自己的订单簿。
192 | 6. Taker通过Relayer提供的DApp获取包含了Maker订单的新版本订单簿。
193 | 7. Taker填写购买Token A订单,设置买入数量Y(Y≦X),并向以太坊上DEX contract提交。
194 | 8. Maker订单中数量Y的代币被DEX contract锁定,等待Taker付款。
195 | 9. Taker在指定的时间范围内向Maker指定的法币接收账户转入法币B。
196 | 10. Maker收到法币后,向DEX contract提交交易确认。
197 | 11. DEX contract验证Maker签名,订单是否过期,是否已经成交,校验成功后将数量Y的Token A转入Taker账户。
198 | 199 | #### 3.1.2. 抵押借贷协议 200 | **借款:**
201 | 1. Maker和Taker均需要通过Relayer进行KYC。
202 | 2. Maker批准DEX contract使用其账户中的Token A作为抵押物。
203 | 3. Maker通过Relayer提供的DApp创建抵押Token A借入法币B的订单,设置好借款金额X,借款方式(目前仅支持到期还本付息),借款时间,年化利率,法币接收账户和订单过期时间,并用自己的私钥签名。
204 | 4. Maker把签名后的订单发送给Relayer。
205 | 5. Relayer接收订单并对订单进行校验。如果校验失败,此订单将被拒绝接收;如果校验成功,Relayer将此订单写入自己的订单簿。
206 | 6. Taker通过Relayer提供的DApp获取包含了Maker订单的新版本订单簿。
207 | 7. Taker填写借出法币B订单,设置借出金额Y(Y≦X),并向以太坊上DEX contract提交。
208 | 8. DEX contract向Oracle询问Token A对法币B的比价,并锁定等值于1.5倍借出金额Y的Token A。若Maker账户中的Token A数量不足,则借款失败,该订单被取消。
209 | 9. Taker在指定的时间范围内向Maker指定的法币接收账户转入金额Y的法币B。
210 | 10. Maker收到法币后,向DEX contract提交交易确认。
211 | 11. DEX contract验证Maker签名,订单是否过期,是否已经成交,校验成功后借贷合同生效。
212 | 213 | **还款:**
214 | 1. 抵押贷款到期后,DEX contract通知Maker还款。 215 | 2. Maker在指定的时间内向Taker的法币账户转入应还的本息总额。 216 | 3. Taker收到法币后,向DEX contract提交收款确认。 217 | 4. DEX contract验证Taker签名,订单是否存在,校验成功后将锁定的抵押代币转入Maker地址。 218 | 219 | ### 3.2. 交易订单格式 220 |   每个交易订单都是一个包含交易参数和相关签名的数据包。订单参数按key升序排列连接并通过Keccak SHA3函数散列为32个字节。交易订单发布者使用他们的私钥签署交易参数散列以产生ECDSA签名。
221 |   GEB交易所仅负责保存和传播一个订单簿来促进交易信息流动,并对交易收取少量手续费(全网统一,默认1%,交易双方各收取0.5%,费率可由GEB DAO投票表决修改)。和中心化的交易所不同,GEB交易所不托管用户的加密货币,也不代表交易双方执行交易,这意味着交易双方不需要信任GEB交易所的运营者。
222 |   交易所可以选择是否将交易订单放入共享流动性池中。如果交易订单被放入共享流动性池中并在其他交易所成交,那么手续费的70%将被分配给创建订单的交易所,30%被分配给成交订单的交易所。
223 | 224 | #### 3.2.1. OTC交易订单 225 | 226 |
227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 |
NameData TypeDescription
versionaddressAddress of the Exchange smart contract. This address will change each time the protocol is updated.
makeraddressAddress originating the order.
tokenAaddressAddress of an ERC20 Token contract.
valueAuint256Total units of tokenA offered by maker.
fiatBbytes3Type of fiat (eg. usd, cny).
priceuint64Price of tokenA in fiatB, in cents as unit.
realNamestringReal name of maker.
payChannelbytesFiat pay channel (eg. paypal, alipay).
payDetailstringDetails of payment.
accountbytesFiat account of maker.
expirationuint256Time at which the order expires (seconds since unix epoch).
feeRecipientAaddressAddress of RelayerA. Receives transaction fees.
feeRecipientBaddressAddress of RelayerB. Receives transaction fees.
vuint8ECDSA signature of the above arguments.
rbytes32
sbytes32
311 | 312 | feeRecipientA代表默认交易所的收费地址,feeRecipientB代表将订单从共享流动性池中取出的交易所的收费地址。 313 | 314 | #### 3.2.2. 抵押贷款交易订单 315 | 316 |
317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 |
NameData TypeDescription
versionaddressAddress of the Exchange smart contract. This address will change each time the protocol is updated.
makeraddressAddress originating the order.
tokenAaddressCollateral, address of an ERC20 Token contract.
fiatBbytes3Type of fiat (eg. usd, cny).
valueBuint64Total units of fiatB to borrow, in cents as unit.
perioduint8Loan period, in months as unit, between 1 and 24.
interestuint16Annualized interest rate, between 1(0.1%) and 1000(100%).
realNamestringReal name of maker.
payChannelbytesFiat pay channel (eg. paypal, alipay).
payDetailstringDetails of payment.
accountbytesFiat account of maker.
expirationuint256Time at which the order expires (seconds since unix epoch).
feeRecipientAaddressAddress of a RelayerA. Receives transaction fees.
feeRecipientBaddressAddress of a RelayerB. Receives transaction fees.
vuint8ECDSA signature of the above arguments.
rbytes32
sbytes32
406 | 407 | ### 3.3. 价格、利率、清算与保护机制 408 |   GEB交易所不能决定OTC交易价格,而只能向交易双方推荐一个当前市场的公允价格,具体成交价格由交易双方共同决定。为了促进流动性,GEB交易所内的OTC交易订单列表将按照价格由低到高的顺序排列。GEB交易所也不能决定抵押贷款利率,利率由借入方自行设定。如果出借方对于借入方给出的利率满意,那么双方将通过智能合约完成交易。为了控制抵押贷款风险,可抵押代币种类,抵押率,强制清算线均由GEB协议开发组统一设置。这些全局设置将保存在一个由GEB基金会部署的以太坊智能合约中,任何一个设置参数的修改均需要DAO投票通过。为了应对突发情况,GEB基金会可选出若干成员组成GEB DAO委员会,委员会中的多数成员确认即可执行某项修改操作。
409 |   在借款期内,使用ethereum-alarm-clock定时调用价格预言机合约,从可信预言机集合(trusted-oracles-set)获取抵押代币实时价格,并通知所有DEX Contract。DEX Contract收到价格通知以后,计算本合约内所有抵押贷款订单的抵押物价值是否低于清算线。如果发现抵押物价值低于清算线,则立即向借款方发送通知,要求其在指定时间内补充抵押物至安全水平。指定时间过后DEX Contract再次计算抵押物价值,如果仍低于清算线则立即自动执行强制清算。清算方法为:计算实时应还的本息总额,将价值等于本息总额105%(至多)的代币转入出借方地址,剩余代币转入借入方地址。
410 |   为了防止多种欺诈和攻击情况,我们使用(不限于)如下的保护机制:
411 | - 用户 - 必须通过KYC才能进行交易 412 | - 交易所 - 必须通过GEB基金会认证,必须抵押保证金 413 | - 陪审员 - 必须通过GEB基金会认证,必须抵押保证金,匿名并随机分配仲裁 414 | - 数字签名订单 - 交易细节不可伪造的证据 415 | - [PageSigner](https://tlsnotary.org/pagesigner.html)证据 - 法币转账不可伪造的证据 416 | - 交易金额限制 - 限制最大交易金额(50ETH)以减少欺诈的潜在收益 417 | - 时间锁定智能合约(Timelock Contract)- 解决交易对手恶意退出风险 418 | - 仅支持不可逆转的法币转账方式,以最大限度的降低退款风险(参见[https://en.bitcoin.it/wiki/Payment_methods](https://en.bitcoin.it/wiki/Payment_methods)) 419 | - 价格观察机制 - 通过ethereum-alarm-clock定时调用价格预言机合约,从可信预言机集合(trusted-oracles-set)获取抵押代币实时价格 420 | - 可信预言机集合 - DAO有权投票决定一组可信的预言机节点,突发情况下,DAO委员会中多数成员确认即可增加或删除若干预言机节点 421 | - 强制清算机制 - 解决抵押物价格下跌的风险 422 | - 不得在加密货币交易非法的司法管辖区使用GEB Network 423 | 424 | ### 3.4. 黑天鹅事件 425 |   黑天鹅事件是指非常难以预测,且不寻常的事件,通常会引起市场连锁负面反应甚至颠覆。加密货币市场具有很大的波动性,因此我们必须考虑一种极端情况:某种抵押代币的价格在短时间内快速下跌,DEX Contract还来不及执行强制清算,抵押物价格就已经跌破了债务金额。在这种情况下,为了防止风险敞口扩大,DEX Contract会立即自动执行强制清算,并请求GEB ERC20 Contract根据GEB Token的市场价格增发一定数量的GEB给出借方以补偿抵押物价值与债务金额之差。这种增发机制虽然会对GEB Token造成一定程度的价值稀释,但是与大规模债务违约对GEB Network造成的伤害相比较,这种价值稀释是温和并且可控的,也符合绝大多数GEB Token持有者的长期利益。
426 |   如果加密货币市场价格大幅波动,那么GEB DAO委员会有权决定将某些种类的加密货币移出可抵押代币范围,甚至暂时关闭全网抵押贷款业务。由于GEB Network的主要业务体系完全建立在以太坊和比特币(未来可能拓展到EOS)生态系统之上,因此GEB Network的安全性和实用性以及GEB Token的价格都会在很大程度上取决于以太坊和比特币生态系统的健康程度。从长远来看,GEB团队将持续密切关注区块链底层技术的发展方向,GEB Network也将因此受益于整个加密货币生态的繁荣而获得持续的健康发展。
427 | 428 | ### 3.5. 智能合约技术 429 |   GEB协议通过一组部署在以太坊上的智能合约(DEX Contract)完成了一个标准实现。该组合约代码是开源的(使用AGPL协议发布源代码)并可以免费使用(仅需要标准gas消耗)。它们是用Solidity语言编写的,包含了实现OTC交易和抵押借贷的全部功能。
430 | 431 | #### 3.5.1. 签名认证 432 |   DEX Contract能够使用ecrecover函数认证交易订单的Maker的签名,以防止Taker提交伪造的Maker订单进行欺诈。该函数将哈希和签名哈希作为参数,返回生成签名的公钥地址。如果ecrecover返回的公钥地址等于Maker的地址,则该签名是真实的。
433 | 434 | ```solidity 435 | address publicKeyAddr = ecrecover(hash, signature(hash)); 436 | if(publicKeyAddr != maker) throw; 437 | ``` 438 | 439 | #### 3.5.2. 时间锁定 440 | - 抵押贷款和OTC交易中,Taker提交订单后,必须在30分钟内完成法币转账并点击“已转账”按钮,否则视为放弃交易,DEX Contract将锁定的Token退还Maker地址。 441 | - 抵押贷款和OTC交易中,Taker点击“已转账”按钮后,Maker会立即收到通知。此后Maker必须在1小时内点击“确认收款”或者“申请仲裁”,否则视为恶意退出交易,DEX Contract将锁定的Token转入Taker地址。 442 | - 抵押贷款到期后,DEX Contract向Maker发出还款通知,Maker必须在24小时内完成法币还款并点击“已还款”按钮,否则视为还款逾期,DEX Contract将立即执行强制清算。 443 | - 抵押贷款到期后,Maker点击“已还款”后,Taker必须在24小时内点击“确认收款”或者“申请仲裁”,否则视为恶意退出交易,DEX Contract将锁定的Token退还Maker地址。 444 | - 任意一方申请仲裁后,交易双方必须在24小时内按照系统要求提交证据,此后进入陪审员仲裁阶段,未提交证据方将没有机会再次提交证据。 445 | 446 | #### 3.5.3. 填充和部分填充订单 447 |   DEX Contract存储了每个先前提交的订单。每个订单由一个结构体(struct)构成。订单列表被存储在一个mapping(一种类似于哈希表的solidity数据结构)中。这个mapping将32字节的数据块映射到订单结构体。将订单参数传递到Keccak SHA3函数中会生成一个唯一的32字节散列,用于唯一标识该订单(哈希碰撞的几率实际上为零)。在订单结构体中有一个成员ValueFill,用于表示该订单被填充的数量。每次订单被填充时,mapping都会更新订单填充数量的累计值。
448 | 449 | ```solidity 450 | struct Order { 451 | ... 452 | uint256 valueFill; 453 | } 454 | mapping(bytes32 => Order) internal OrderList 455 | ``` 456 | 457 |   在填充OTC交易订单和抵押贷款订单时,Taker可以通过指定附加参数valueFill来部分填充订单。只要部分填充的总和不超过订单总额,就可以对单个订单执行多次部分填充。
458 | 459 | | Name | Data Type | Description | 460 | | :-------- | :-------: | :--------------------------------------- | 461 | | valueFill | uint256 | Total units of token or fiat to be filled (valueFill ≤ valueA or valueB). | 462 | 463 |   在填充抵押贷款订单时,Taker需要指定附加参数takerRealName, paybackChannel, paybackDetail来指定法币还款方式。
464 | 465 | | Name | Data Type | Description | 466 | | :------------- | :-------: | :--------------------------------------- | 467 | | takerRealName | string | Real name of Taker | 468 | | paybackChannel | bytes | Fiat payback channel (eg. paypal, alipay) | 469 | | paybackDetail | string | Details of payment | 470 | 471 | #### 3.5.4. 过期时间 472 |   订单的过期时间由创造订单的Maker指定。过期时间是一个无符号整数值,表示一个UNIX时间戳。该值一旦被签名就无法更改。
473 |   以太坊虚拟机中的时间由每次挖出新区块时设置的块时间戳给出。因此,判断订单是否过期并不取决于Taker提交订单的时间,而是取决于矿工在EVM中执行填充功能的时间。矿工无法将当前区块的时间戳设置为早于前一个区块的时间戳。
474 | 475 | #### 3.5.5. 取消订单 476 |   在订单被提交给DEX Contract之前,Maker可以随时向Relayer请求取消订单。在订单被提交给DEX Contract后,Maker可以通过DEX Contract的取消功能取消未填充且未过期的订单部分。该功能将订单的valueFill更改到最大值以防止后续填充。通过DEX Contract取消订单会产生费用,因此该功能仅用作备用机制。通常情况下,Maker可以通过将订单过期时间设置为与他们打算更新订单的时间相匹配来避免链上取消订单交易。
477 |   这种方法存在的一个问题是它可能会造成一种情况:Maker在试图取消订单的同时,Taker试图填充同一订单。这会导致两笔交易中的一笔失败,并浪费gas。交易开采顺序的不确定性有时会导致非预期的结果,如果以太坊区块链上待处理的交易大量积压,这种不确定性可能会增加。
478 | 479 | #### 3.5.6. WETH合约 480 |   [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md)为以太坊令牌建立了一个标准接口,以允许以太坊智能合约与任何符合标准的令牌进行交互。ETH是以太坊的基础货币,不符合ERC20令牌标准。许多DApp开发者发现,通过将ETH抽象为兼容ERC20的令牌,智能合约可以通过去除用于处理ETH的业务逻辑代码来简化。
481 |   我们使用由[Makerdao](https://medium.com/@MakerDAO)团队部署的WETH合约来实现上述功能。
482 | **合约部署地址:**
483 | - Mainnet:[0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2](https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) 484 | - Kovan:[0xd0a1e359811322d97991e03f863a0c30c2cf029c](https://kovan.etherscan.io/address/0xd0a1e359811322d97991e03f863a0c30c2cf029c) 485 | - Ropsten:[0xc778417e063141139fce010982780140aa0cd5ab](https://ropsten.etherscan.io/address/0xc778417e063141139fce010982780140aa0cd5ab) 486 | - Rinkeby:[0xc778417e063141139fce010982780140aa0cd5ab](https://rinkeby.etherscan.io/address/0xc778417e063141139fce010982780140aa0cd5ab) 487 | 488 | ### 3.6. 非以太坊加密货币兼容 489 |   GEB协议在设计之初就考虑了对非以太坊数字货币的兼容。为了实现这一目标,我们需要依靠允许这些加密数字货币网络之间相互通信的技术和协议。我们很高兴地看到许多优秀的团队 — — 比如,Polkadot和Cosmos — — 正在着手解决这一问题。遗憾的是,这些项目现今仍处于紧张的开发阶段 — — 有的要么尚未公布具体的发布日期(例如Polkadot),要么仅仅适用于基于权益证明(PoS)机制的区块链(例如Cosmos)。因此,现有区块链间的跨链通信的实际解决方案依然有待探索。在综合比较了多种跨链技术方案以后,GEB团队选择了一条分两步实施的技术路线。
490 | 491 | #### 3.6.1. 双向挂钩(2-way peg)技术【当前方案】 492 |   以下是关于双向挂钩的一般性描述:我们把以太坊上的比特币代理币称为E-BTC。当一个用户“存放”BTC时,这些BTC在比特币区块链上被锁定。这些BTC的交易证明被发送到一个以太坊合约中,该合约被称为PegContract。PegContract验证这笔交易,并发行E-BTC到用户的以太坊地址。比特币系统中的1BTC等价于以太坊系统中的1E-BTC。之后,当用户想把E-BTC换回到BTC时,只要燃烧掉E-BTC,再提供一个烧毁证明给比特币区块链。比特币区块链验证这些E-BTC已经烧毁后,解锁原始的BTC。
493 |   这种PegContract现在就能在以太坊上实现,并且能够无需信任地完成所有工作:它能够验证BTC已经被发送到某个地址并且锁定了;它能够发行E-BTC;它能够燃烧E-BTC并提供烧毁证明。BTC-Relay就是这样一种合约,BTC-Relay实现了比特币简化支付证明(SPV),从而能够验证一笔交易是否已经在比特币区块链上被确认(需要向Relayer支付验证手续费以激励Relayer持续向BTC-Relay合约提交比特币区块头)。因此在比特币系统中的任何交易,从支付到BTC的锁定,都可以被以太坊合约验证。同理我们可以实现用以太坊合约验证比特币现金(BCH)区块链上的交易。
494 |   双向挂钩存在的问题是,我们无法在比特币区块链上部署ETH-Relay或者任何锁定合约。我们可以等到RootStock发布以后,在ETH和RootStock之间建立一个双向挂钩,以实现比特币和以太坊之间的交互。另一个实际的解决方案是,将用户的BTC锁定在多重签名地址中,其中每个签名者必须在以太坊PegContract中存入ETH。当BTC被锁定时,PegContract将照常发行E-BTC。当E-BTC被发回PegContract时,它们将被烧毁并由PegContract生成证明。同时PegContract开始倒计时,为签名者提供足够的时间来验证烧毁证明并解锁BTC。如果任何签名者不签署多重签名,他存放在PegContract中的ETH会被转入用户的以太坊地址。为了使赎回过程更加顺利,签名者可以从每次存入/赎回过程中获得手续费奖励。具体原理如下图所示:
495 | 496 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/cross-chain-vertical.jpg) 497 | 498 | #### 3.6.2. 闪电原子交换(Lighting atomic swap)技术【演进方案】 499 |   为了确保跨链交易的安全性,双向挂钩技术的交易速度必须满足以下不等式:
500 | 501 |                     ![](https://latex.codecogs.com/gif.latex?%5Cfrac%7B1%7D%7Bv%7D%5Cgeq%20%5Cfrac%7B1%7D%7Bv1%7D+%5Cfrac%7B1%7D%7Bv2%7D) 502 | 503 | v表示跨链安全交易速度;v1、v2分别表示两条区块链单独的安全交易速度。从上式可以看出,跨链安全交易的速度比任意一条区块链上的安全交易速度更慢。对于比特币区块链,安全的交易确认时间可能需要30分钟甚至更久。另一方面,由于需要在两条区块链上各上链一笔交易并且支付一笔SPV验证的gas费用和一笔Relayer手续费,所以使用双向挂钩技术实现跨链交易是比较昂贵的。
504 |   闪电原子交换是一种结合了闪电网络和原子交换两种技术的即时跨链交易技术。闪电网络是一种协议,它通过在不同的交易者之间创建链下支付通道来工作,只有在打开和关闭支付通道时才需要上链交易。这有三大好处:第一,加快交易速度;第二,降低交易费用;第三,提高交易容量。原子交换是另一种协议,它能够让交易双方无需信任地进行跨链交易。原子交换的执行只有两种结果,要么双方成功完成数字货币交换,要么什么都没有发生。最重要的是,因为交易无需信任任何第三方,也就避免了欺诈。
505 |   单独使用原子交换需要很长的等待时间来确保安全,并且需要上链至少四笔交易。而在两条区块链均存在支付通道的情况下,使用闪电原子交换可以大大缩短等待时间,并且不需要上链任何一笔交易。Lightning实验室已经于2017年11月16日确认完成了全球首次基于比特币-莱特币区块链的闪电原子交换。具体的技术原理如下图所示:
506 | 507 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/lightning-swap-vertical.jpg) 508 | 509 | 截至本文写作时,比特币闪电网络已经在比特币主网成功发布,以太坊上的闪电网络——雷电网络(Raiden Network)正在密集研发中。我们将持续关注相关项目的进展并在合适的时间(待相关技术的可靠性得到验证)将闪电原子交换技术引入GEB Network。
510 | 511 |

512 | ## 4. GEB协议代币 513 |   为了促进GEB Network的发展并让更多人能够参与GEB生态建设,分享GEB生态收益,在GEB Network上建立分散的协同决策机制。GEB团队将发行基于以太坊区块链的ERC20代币GEB Token。GEB Token将主要用于在GEB生态内部流通,并激励GEB用户建设、使用和维护GEB Network。GEB Token将成为GEB Network稳定运转的润滑剂。
514 | 515 | ### 4.1. GEB代币经济模型 516 |   协议代币的价值储存功能和流通功能是代币经济模型设计中的一对矛盾。如果代币经济模型设计偏向于价值储存功能,由于存在价格上涨预期,代币拥有者倾向于持有而非使用代币,这又进一步导致了流动性减弱。这种自我强化的正反馈导致新用户进入门槛过高,协议使用范围的扩大受到阻碍。这种情况已经在比特币系统中得到了验证。可以预见,当这种自我强化达到极限,市场上已经没有人再使用这种代币,也没有新用户进入,那么整个代币经济模型就接近了崩溃边缘。代币交易完全由投机需求驱动,代币价格随时可能在最高点突然崩盘。如果代币经济模型设计偏向于流通功能,那么用户就没有动力持有代币,而是选择尽快交易,尤其是当协议代币价格上升预期低于其他具有价值储存功能的代币的时候。这种情况下,用户持有协议代币的平均时间取决于对代币价格的预期,代币的使用价值和使用频率,代币与其他货币的交易成本。任何一个因素的下降都会导致用户倾向于交易而非持有代币,这又进一步导致了代币价格的下跌预期。这种逆向的正反馈会导致协议代币价格崩溃,甚至整个协议生态的死亡。
517 |   通过上面的分析我们得出结论,一种协议代币只有同时具备价值储存和流通功能并维持两者之间的平衡,才能保持相对稳定的价格。Vitalik Buterin在2017年的一篇博客中对这一问题进行了论述,并提出了一个评估代币价格的公式:
518 |

MC = TH

519 | 520 | - M表示代币供应总量 521 | - C表示代币价格 522 | - T表示代币交易量 523 | - H表示用户持有代币的平均时间 524 | 525 | 我们对GEB代币经济模型的设计目标是使代币价格C保持一个相对平稳的长期增长率,同时尽可能做大代币总市值MC/TH。这要求我们关注两个方面:第一,尽可能扩大代币交易量T并提高用户持有代币的平均时间H;第二,保持代币供应总量的增长率低于TH的增长率。在用户量快速增长阶段,代币交易量T同步增长,TH的增长主要由新增用户的T驱动;当用户量增长放缓甚至停滞,T和H开始呈现负相关关系,TH存在一个极大值。因此,在GEB Network的发展早期,做大GEB Token总市值最有效的方法是尽可能吸引更多新用户加入GEB Network,并鼓励用户持有更多GEB Token。只有当GEB Network发展到覆盖了大部分加密货币用户,并且整个加密货币生态的用户总数增长放缓,我们才需要考虑通过提高系统内部的流动性使TH向极大值靠拢。
526 |   在充分考虑了以上因素后,结合GEB Network的使用场景,我们为GEB协议设计了非常巧妙并且独一无二的代币经济模型。在GEB协议设计中,存在一种特殊类型的代币交易——代币抵押。在GEB代币抵押过程中,我们仍可以将这些代币视为处于用户持有状态,因为市场上的流动性并没有增加。通过鼓励用户抵押GEB代币,我们提升了用户对GEB代币的需求,同时延长了用户持有代币的时间。我们将这种模型称为“使用即持有”的代币经济模型。显而易见的是,这种模型将极大地刺激GEB代币价格上涨,因此,我们需要设计一种代币增发机制以将GEB代币的价格上涨速度控制在一个合理的范围内。幸运的是,在GEB协议生态内部有丰富的场景让我们可以通过增发GEB代币来激励用户共同建设和维护GEB Network。4.2、4.3两小节列举了一些GEB Token的具体用例和增发场景。
527 |   除此以外,我们还为GEB Token设计了一个额外的价格调节机制。通过成立GEB投资基金,我们将投资于GEB协议生态内的企业和DAO,并将投资收益的一部分用于回购市场上流通的GEB Token并销毁(详见4.6)。
528 | 529 | ### 4.2. GEB代币用例 530 | - 建立GEB认证交易所需要在GEB基金会抵押一定数量的GEB Token 531 | - 担任GEB认证陪审员需要在GEB基金会抵押一定数量的GEB Token 532 | - 用户使用GEB Token支付OTC交易手续费可以享受50%折扣优惠 533 | - 用户使用GEB Token作为抵押物借款可以享受50%的手续费优惠,并且获得更高的抵押率和更低的清算线 534 | - 使用GEB Token作为抵押物的借款订单将被高亮显示 535 | - GEB Token持有者可以参加GEB DAO投票,成为协议治理决策层的一员 536 | 537 | ### 4.3. GEB代币增发 538 |   GEB代币初始发行量为10亿枚,此后每年都会有一定数量的增发。GEB代币增发量与GEB Network的运行状况密切相关,目前已经确定以下的增发场景:
539 | - GEB交易所接受GEB Token作为手续费,给予用户优惠部分由增发补足 540 | - GEB陪审员做出恰当的仲裁将获得GEB Token奖励,奖励部分由增发产生 541 | - 用户邀请好友注册GEB交易所并完成KYC将获得GEB Token奖励,奖励部分由增发产生 542 | - 黑天鹅事件发生时,立即执行强制清算并增发GEB Token补偿出借方以避免债务违约 543 | 544 | 如果未来需要增加任何GEB Token增发场景,需要向GEB DAO提交提案并通过DAO投票表决。 545 | 546 | ### 4.4. Aragon DAO治理 547 |   Aragon于2017年发布,是一款去中心化自治组织的操作系统。在Aragon上可以方便地实现一套简单易用的去中心化自治组织的基本管理组件。这些组件包括:代币分配管理,组织成员管理,⻆⾊权限管理,投票管理,众筹管理以及财务管理等。Aragon组织的行为很容易通过更改章程来定制。此外,Aragon组织可通过与组织合约交互的第三方模块进行扩展。
548 | 549 | ![img](https://images-cdn.shimo.im/HzrAKHaKcJwws0mN/aragon.gif) 550 | 551 |   GEB Token持有者可以通过Aragon软件的投票模块对GEB协议的各方面提案进行投票表决,这些方面包括但不限于:
552 | - DAICO资金解锁提案 553 | - GEB协议升级提案 554 | - GEB Token增发提案 555 | - GEB DAO委员会选举 556 | - 可信预言机集合修改提案 557 | - GEB Network全局参数(可抵押代币范围,抵押率,强制清算线,手续费率,可用法币转账渠道等)修改提案 558 | - GEB Network临时关闭和开启提案 559 | 560 |   GEB Network最终能否被大众认可在很大程度上取决于能否在一个健全的去中心化生态系统中提高流动性。参与生态建设的角色不局限于GEB Token持有者,还可以是开发者,终端用户等。为了高效的广泛采纳建议,我们遵循分布式治理的理念建立一套标准决策流程托管至Aragon中,其中涉及到用[Aragon Group](https://wiki.aragon.one/dev/apps/group/)进行成员和权限管理,用[Aragon Finance](https://wiki.aragon.one/dev/apps/finance/)进行财务管理以及其他的管理模块。
561 |   随着AragonOS release 3.0的发布,投票管理成为了DAO治理更加灵活的入口,我们可以在ACL自定义参数化规则来处理不同的投票场景,也可以使用Forwarders将投票结果轻而易举地转发至不同的DAO管理应用程序。以下是一个自定义参数规则验证的程序示例:
562 | 563 | ```javascript 564 | function verifyCombinatedParams() { 565 | Param[] memory params = new Param[](7); 566 | params[0] = Param(LOGIC_OP_PARAM_ID, uint8(Op.IF_ELSE), encodeIfElse(1, 4, 6)); 567 | params[1] = Param(LOGIC_OP_PARAM_ID, uint8(Op.AND), encodeOperator(2, 3)); 568 | params[2] = Param(ORACLE_PARAM_ID, uint8(Op.EQ), uint240(new AcceptOracle())); 569 | params[3] = Param(BLOCK_NUMBER_PARAM_ID, uint8(Op.GT), uint240(block.number - 1)); 570 | params[4] = Param(LOGIC_OP_PARAM_ID, uint8(Op.OR), encodeOperator(5, 2)); 571 | params[5] = Param(0, uint8(Op.LT), uint240(10)); 572 | params[6] = Param(PARAM_VALUE_PRARM_ID, uint8(Op.RET),0); 573 | 574 | assertEval(params, arr(uint256(10)), true); 575 | } 576 | ``` 577 | 578 |   DAO的治理模型是多样化且动态调整的,AragonOS给我们提供了便利也给予了一定的安全保证。
579 | 580 | ### 4.5. 首次代币发行 581 | 582 | #### 4.5.1. 代币发行计划——IEO【备选1】 583 |   在结束GEB Network的私募活动之后,选择直接在首发交易所进行首次代币发行。
584 | 585 | #### 4.5.2. 代币发行计划——DAICO【备选2】 586 |   2018年1月,Vitalik Buterin提出了一个革命性的概念——结合ICO和DAO(分布式自治系统)的DAICO (https://ethresear.ch/t/explanation-of-daicos/465) 在DAICO中参与者可以投票赞成或者反对固定的预算增加,如果团队没有成功实施该项目,参与者可以投票退回。
587 | 588 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/daico.jpg) 589 | 590 |   GEB Network将使用DAICO进行资金的众筹和使用管理,将规则100%透明的嵌入在代码中,直接由参与者和智能合约控制,不再有第三方。
591 | 592 | #### 4.5.3. 代币分配计划 593 |   GEB Token发行总量为10亿,团队、顾问、私募、众筹销售、基金会和激励池等各部分的代币将由智能合约分配如下:
594 | 595 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/token-distributed.jpg) 596 | 597 | - 团队和顾问:该部分将有3%份额的GEB Token立即释放;剩余的12%份额将通过智能合约冻结1年,解冻之后的分配方式:1)顾问的剩余部分立即全部释放;2)团队的剩余部分按18个月分期释放。 598 | - 私募:私募销售的GEB Token将分为两部分:1)未参与锁定计划的部分将在私募结束后分发到参与者的钱包中;2)参与锁定计划的部分将在私募结束后被锁定在智能合约中,再根据既定规则分期解锁分发至参与者钱包中。 599 | - IEO/DAICO:该部分将在IEO/DAICO结束后即时分发到参与者的钱包中。 600 | - 基金会:该部分的GEB Token将由智能合约托管并在2年内分月解锁,解锁资金的使用需要经过GEB DAO同意并在使用过程中进行细节披露。 601 | - 激励池:每年将从激励池中固定拿出1%份额的GEB Token奖励团队和社区开发者,持续奖励10年;剩余的5%份额将用于重要资源引入,包括但不限于人才,战略合作伙伴等。 602 | 603 | #### 4.5.4. 资金取款 604 |   众筹销售结束之后Fund contract转为TeamWithdraw模式,允许该项目的团队定期提取筹集资金的有限数量。所筹集的资金通过Fund contract可以使用两种方式给开发团队支付:
605 | - 有限直接支付(第一次取款) 606 | 607 |   考虑到ETH价格的波动性较高,出于对项目的保护,团队有可能在众筹销售结束之后立即提取软顶的一半,并将其兑换成法定货币或者DAI。
608 | - 基于TAP模式支付 609 | 610 |   **Tap (wei/秒钟)**:这是项目团队每个月可以从Fund contract提取合理的最大金额。初始Tap由智能合约规定为77160493827160 (wei/秒钟) = 200 ETH/月份。Tap用来支持平台的长期发展。如果Tap没有支出,则不断积累。
611 |   **Tap的增加**:如果团队由于任何原因需要更多资金,可以发起增加Tap的投票。代币持有者可以根据他们在钱包上保持的代币数量(N, where N≠0)进行投票,表决是否批准向团队支出额外的资金。增加Tap的投票将于每个月1日进行。如果“同意”的投票数量超过“不同意”的话,投票就被视为成功完成。投票进行3天,发起之后立即开始。为了防止系统被破坏,Tap可以一次提升的百分数将限制在初始数量的50%。(附Tap的增加投票预防性(Proof-of-Stake算法)协议,该协议旨在防止巨额持有者恶意投票,如交易所等。每一个Ethereum钱包投票的比重被限制在一定的代币数量之内(投票权重<=0.5%所有代币数量)。被智能合约锁定的代币不具备投票资格,如基石投资、私募、团队、基金和激励池的锁定部分,因为该部分被智能合约控制,不以人的意志为转移。)
612 |   **退款投票**:如果代币持有者对项目的团队工作不满意(以及认为团队未能履约项目),他们就可以要求进行退款投票。退款活动将会在代币销售结束后的前两年持续可用,但如果在销售结束后的两年内,运营团队完成交易所上币工作,则退款活动将被关闭。退款投票每半年由团队发起一次,发起之后立即开始,投票延续一个星期。如果退款投票中“同意”的投票数量超过“不同意”的话,投票就被视为成功完成。投票进行一星期,发起之后立即开始,在投票期间可随时更改投票结果。投票关闭之后,不再接受投票,未参与投票的默认视为“不同意”。如果退款投票成功,代币持有者需要保留代币,并在下个月的第一天之前不发生将其转移到另一个ETH钱包的行为。 在这种情况下,投票将被视为已完成。 如果代币被转移,代币持有者当前的投票权重将减少。 例如,如果一个人投了1000个代币并将其中的500个移动到另一个钱包,那么他的投票权重将减少到500而不是1000。我们将根据退款投票成功后次月第一天的代币实际的转移情况计算最终的投票结果。如果第一次退款投票成功,团队的取款被锁定,并且第二次退款投票在一个月期间内要进行,与第一次投票相似,我们第二次的投票时间也为一个星期,期间可以随时更改投票的结果,结束后不再接受任何投票操作。如果第二次退款投票获得成功,代币持有者可以返回剩下的资金。在不成功的情况下,团队的取款被解锁。这种包括两阶段的投票系统是为了保护该项目免受由于加密货币市场急剧变化而引起的代币持有者的仓促决定。如果退款最终执行的话,在团队、激励池和基金的代币被销毁之后,以当前资金账户剩余的ETH除以代币总量算出当前GEB/ETH汇率,用以返回资金给代币持有者。(附退款投票预防性(Proof-of-Stake算法)协议,该协议旨在防止巨额持有者恶意投票,如交易所等。每一个Ethereum钱包投票的比重被限制在一定的代币数量之内(投票权重<=0.1%所有代币数量)。被智能合约锁定的代币不具备投票资格,如基石投资、私募、团队、基金和激励池的锁定部分,因为该部分被智能合约控制,不以人的意志为转移。)
613 |   我们相信采用DAICO的资金管理方案会提供给投资者前所未有的安全,透明性和控制性的水平,帮助项目良好、健康地发展。
614 | 615 | ### 4.6. GEB投资基金 616 |   GEB Network的募资工作完成后,GEB基金会将从募集到的资金和基金会中的3亿个GEB Token中各拿出30%成立GEB投资基金,专门用于投资孵化GEB协议生态内的企业和DAO。投资的方向主要包括区块链底层技术,区块链协议与应用,GEB协议扩展等。GEB投资基金由GEB DAO委员会直接管理并配置专业的投研团队和投后管理团队。基金收益的20%~50%将被用于回购市场上流通的GEB Token并销毁(视GEB Token价格决定回购规模),剩余收益将用于持续滚动投资。
617 | 618 |

619 | ## 5. GEB协议生态 620 | 621 | ### 5.1. GEB Network整体架构 622 | 623 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/network-structure.jpg) 624 | 625 | ### 5.2. 陪审员网络 626 |   智能合约可以通过控制链上交易来解决争端,但是无法控制链下交易。陪审员网络用于处理智能合约无法判断的情况,并将处理结果提交给智能合约。当用户在交易过程中申请仲裁时,陪审员网络将介入处理。陪审员网络的设计目标是通过经济激励建立一个分散的争议解决机制,这种机制避免了对单一仲裁机构的绝对信任,因此具有更高的安全性。整套仲裁软件运行在由以太坊和IPFS构建的基础设施之上。通过一个简单的用户界面,陪审员可以方便地接收争议双方提交的证据并做出仲裁。所有的仲裁记录都会被永久保存在以太坊区块链上,所有不可篡改的加密证据(由[PageSigner](https://tlsnotary.org/pagesigner.html)生成)都会被永久保存在IPFS上。
627 | 628 | #### 5.2.1. 陪审员申请 629 |   要加入GEB陪审员网络需要首先向GEB DAO提交申请并提供身份证明材料,审核通过后需要参加GEB陪审员在线培训和考核。考核通过后需要与GEB基金会在线签约并购买一定数量的GEB Token抵押给GEB基金会。签约期内陪审员不得动用抵押代币。签约期满后若不再续约,GEB基金会将把抵押代币退还陪审员。
630 | 631 | #### 5.2.2. 仲裁流程 632 | - **Phase1**:用户发起仲裁申请,仲裁软件会向争议双方发出通知,要求双方在24小时内按照规定格式各提交一份加密证据(使用[PageSigner](https://tlsnotary.org/pagesigner.html),一个允许用户生成不可篡改的网页证据的Firefox/Chrome插件)以及其他补充证据(文字,图片,语音,视频等)。所有证据文件会被打包并签名后上传至IPFS。与此同时,仲裁软件会从签约陪审员中随机选取三名陪审员并通知他们进入仲裁准备状态(通过KYC信息校验排除陪审员自己仲裁自己的可能性)。陪审员必须在8小时内应答,如果超时不应答会被罚款X(抵押代币),仲裁软件会重新选择陪审员。整个流程必须在24小时内完成。 633 | - **Phase2**:陪审员接受争议双方提交的证据文件,校验签名后进行审查。陪审员还可以请求审查争议双方的KYC资料。为了避免共谋欺诈,陪审员之间不能够互相沟通,也不能与争议双方直接沟通。陪审员必须在8小时内完成审查并独立作出裁决(裁决可以是支持争议的一方或者无法判定)。如果陪审员超时未做出裁决会被罚款。裁决完成后仲裁软件会按照如下方式评判仲裁结果: 634 | - 如果三名陪审员支持同一方,则该方胜诉,仲裁结束。仲裁软件通知DEX Contract仲裁结果。 635 | - 其他情况仲裁将进入Phase3阶段。 636 | - **Phase3**:如果仲裁在Phase2没有结束,那么争议双方提交的证据文件和三名陪审员的裁决结果将被提交给GEB DAO委员会进行最后裁决。GEB DAO委员会可能会要求争议双方提交补充证据,在必要时甚至可能要求与争议双方进行视频通话或者屏幕共享以确保裁决的正确性。所有的证据文件和视频材料都会被上传至IPFS。Phase3阶段没有固定时间限制,仲裁将持续至GEB DAO委员会做出最终裁决。 637 | 638 | #### 5.2.3. 经济激励与保证金 639 |   为了激励陪审员正确行使陪审权力,陪审员需要在GEB DAO抵押一定数量GEB Token作为保证金。每次仲裁结束后,仲裁系统会根据每名陪审员的裁决和**最终仲裁结果R**对三名陪审员(A、B、C)分别进行代币奖励或惩罚,具体规则如下(+X表示奖励X,-X表示罚款X,0表示无奖惩):
640 | 641 |
642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 |
裁决奖惩
ABCABC
RRR+X+X+X
RR¬R+X+X-X
RR无法判定+X+X0
RR超时+X+X-2X
R¬R¬R+X00
R¬R无法判定+X-X0
R¬R超时+X-X-2X
R无法判定无法判定+X00
R无法判定超时+X0-2X
R超时超时+X-2X-2X
¬R¬R无法判定00+X
¬R¬R超时00-2X
¬R无法判定无法判定-X+X/2+X/2
¬R无法判定超时-X+X/2-2X
¬R超时超时0-2X-2X
无法判定无法判定无法判定+X/2+X/2+X/2
无法判定无法判定超时+X/2+X/2-2X
无法判定超时超时0-2X-2X
超时超时超时-2X-2X-2X
807 | 808 | 因A、B、C顺序无关,以上表格已经包含了三名陪审员所有可能的裁决结果组合。陪审员超时未裁决的情况事实上较少发生,因为这会导致该陪审员遭受双倍的代币罚款。
809 | 810 | #### 5.2.4. 退出机制 811 |   陪审员在签约期内如果发生以下情况,将启动退出机制。
812 | - **陪审员主动申请退出**:陪审员不在任何仲裁期内,可向GEB DAO提出退出申请。GEB DAO委员会经过审查后,如果确认该陪审员无任何不当行为,则通过申请并退还剩余的抵押代币和奖励代币。 813 | - **签约期内被罚款超过5次**:将启动强制退出流程。经GEB DAO委员会审查后,如果确认该陪审员无其他不当行为,则强制该陪审员退网并退还剩余的抵押代币和奖励代币。 814 | - **GEB DAO委员会认定该陪审员有明显的不当行为(如共谋欺诈)**:扣除所有抵押代币和奖励代币并强制退网,GEB DAO保留对该陪审员进一步追究责任的权利。 815 | 816 | ### 5.3. 交易商网络 817 |   交易商网络的主要作用是促进GEB Network的流动性,并为用户提供全面的交易服务。交易服务商可以通过部署GEB开源软件或者自主开发(二次开发)GEB协议实现来建立GEB交易所并通过收取交易手续费获利。申请成为GEB认证交易服务商需要满足以下条件:
818 | - 认证交易服务商需要有经营所在地的小额借贷运营资质,有公司实体和固定办公场地,有小额借贷行业运营经验。GEB官方提供全套开源软件和二次开发技术支持(免费技术培训,工程师7\*24远程技术支持)。首次签约三年。 819 | - 认证交易服务商需要按照 1ETH = 10000GEB 的价格购买 1000000GEB(首批,未来会随GEB价格的变化调整购买价格和购买数量),并抵押在GEB基金会中。签约期内交易服务商不可动用该笔保证金,签约期满后若不再续约,GEB基金会将保证金退还交易服务商。 820 | - 认证交易服务商需遵守经营所在地的法律法规和政策。如交易服务商出现违法违规行为,GEB DAO委员会有权对交易服务商进行罚款直至取消认证交易服务商资格。 821 | - 认证交易服务商需要确保交易软件完整实现GEB协议的所有规定并严格执行。任何不遵守GEB协议的交易服务商将会被罚款直至取消认证交易服务商资格。 822 | - 签约期内认证交易服务商不得申请退出。 823 | 824 | ### 5.4. 去中心化身份认证 825 |   为了保证交易安全,用户使用GEB Network之前需要完成身份认证。传统的KYC/AML系统将用户身份数据保存在中心化的服务器上,这导致了严重的用户隐私泄露风险,并加剧了用户和服务商之间权利的不平等。我们希望将GEB Network用户数据的所有权归还给用户本人。为了达到这个目标,我们为GEB Network设计了一套去中心化的身份认证协议。用户可以在GEB Network上注册自己的身份,请求和发送证明凭证,安全地管理他们的密钥和隐私数据。
826 | 827 | #### 5.4.1. DID与DID文档 828 |   我们的身份认证协议设计参考了W3C Credentials Community Group关于Decentralized Identifiers和Identity Credentials的工作 (参见https://w3c-ccg.github.io/did-spec/, https://opencreds.org/specs/source/identity-credentials/) 。身份由分散标识符(DID)标识,并指向一个DID文档。DID及其关联的DID文档的组合形成分散标识符的根记录。
829 |   GEB Network目前支持的DID生成方法如下所示:
830 | 831 | ```gebdid 832 | geb-did = "did:geb:"geb-specific-idstring 833 | geb-specific-idstring = network":"address 834 | network = "mainnet"/"ropsten"/"rinkeby"/"kovan" 835 | address = 40*HEXDIG 836 | ``` 837 | 838 | - network目前仅支持以太坊的"mainnet", "ropsten", "rinkeby"和"kovan",但可以在未来扩展以支持任意以太坊实例(包括私有实例)。 839 | - address为HEX编码的以太坊地址(不带0x前缀)。 840 | 841 |   DID文档必须是单个JSON对象,此JSON对象的格式是在[JSON-LD](https://json-ld.org/)中指定的。[JSON-LD](https://json-ld.org/)是一种用于将JSON数据映射到[[JSON-LD](https://www.w3.org/TR/json-ld/)]定义的RDF语义图模型的格式。一个基本的DID文档示例如下所示:
842 | 843 | ```json 844 | { 845 | "@context": "https://github.com/gebnetwork/geb-connect/geb-did-v1.jsonld", 846 | "@id": "did:geb:mainnet:d278018404b0889326f1799beecf8724b61d691e", 847 | "@type": "Person", 848 | "name": "ZhuWei", 849 | "email": "geekchu@qq.com", 850 | "born": "1986-05-26", 851 | "credential": [{ 852 | "@graph": { 853 | "@context": "https://w3id.org/identity/v1", 854 | "@id": "http://example.gov/credentials/3732", 855 | "@type": ["Credential", "PassportCredential"], 856 | "name": "Passport", 857 | "issuer": "https://example.gov", 858 | "issued": "2010-01-01", 859 | "claim": { 860 | "@id": "did:ebfeb1f712ebc6f1c276e12ec21", 861 | "name": "Alice Bobman", 862 | "birthDate": "1985-12-14", 863 | "gender": "female", 864 | "nationality": { 865 | "name": "United States" 866 | }, 867 | "address": { 868 | "@type": "PostalAddress", 869 | "addressStreet": "372 Sumter Lane", 870 | "addressLocality": "Blackrock", 871 | "addressRegion": "Nevada", 872 | "postalCode": "237842", 873 | "addressCountry": "US" 874 | }, 875 | "passport": { 876 | "@type": "Passport", 877 | "name": "United States Passport", 878 | "documentId": "123-45-6789", 879 | "issuer": "https://example.gov", 880 | "issued": "2010-01-07T01:02:03Z", 881 | "expires": "2020-01-07T01:02:03Z" 882 | } 883 | }, 884 | "signature": { 885 | "@type": "LinkedDataSignature2015", 886 | "creator": "https://example.gov/keys/27", 887 | "signature": "3780eyfh3q0fhhfiq3q9f8ahsidfhf29rhaish" 888 | } 889 | } 890 | }], 891 | "signature": { 892 | "@type": "EcdsaKoblitzSignature2016", 893 | "created": "2016-10-23T05:50:16Z", 894 | "creator": "ecdsa-koblitz-pubkey:020d79074ef137d4f338c2e6bef2a49c618109eccf1cd01ccc3286634789baef4b", 895 | "signatureValue": "..." 896 | } 897 | } 898 | ``` 899 | 900 | - credential是由第三方发布的用于证明数字身份的数字证书集合。详见https://opencreds.org/specs/source/identity-credentials/。 901 | - DID文档可以附加关联数据签名(Linked Data Signatures)以保证文档的正确性和完整性。详见https://w3c-dvcg.github.io/ld-signatures。 902 | 903 |   DID文档使用SHA256哈希值作为文件名,公钥加密后存储在IPFS上。DID和DID文档的映射关系存储在由GEB认证的节点所维护的etcd集群中(将此映射关系存储在以太坊智能合约中会产生交易费用,考虑到初次创建身份的GEB用户大多并未持有以太币,这将显著提高用户使用GEB Network的门槛)。用户可以通过GEB DApp(WEB/Mobile)创建身份(DID文档)并与一个以太坊地址(DID)绑定。身份创建成功后,用户可以授权某个GEB交易所访问他们的身份数据以完成KYC。身份认证成功后,GEB交易所将会向用户颁发数字证书。用户将该数字证书存储在DID文档中,并可在未来用于身份证明。
904 | 905 | #### 5.4.2. GEB Connect 906 |   我们计划在未来(2019~2020)将GEB去中心化身份认证协议升级为GEB Connect,一个允许用户使用唯一的DID登录所有的以太坊DApp,注册自己的身份,请求和发送身份证明凭证,发送以太坊交易,与任何他们信任的人分享数据,安全地管理他们的密钥和隐私数据的以太坊身份管理基础设施。一些其他项目,比如uport和kyc.legal也在进行类似的尝试,然而我们认为缺乏使用场景和用户规模基础的去中心化身份认证项目很难获得成功。而GEB Connect的发展将依托于GEB Network项目庞大的生态网络和严格的KYC要求。随着GEB Network用户规模的扩大,GEB Connect必将在金融,保险,招聘,电商,征信等领域获得广泛的应用。
907 | 908 | ### 5.5. 共享流动性池 909 |   流动性(liquidity)是任何一个市场的“灵魂”,用户在有活力的市场中能够获得极佳的交易体验。因此,我们提供了一个共享流动性池来保持GEB Network中交易的流动性。共享流动性池主要有以下适用场景:
910 | - 如果一个交易所流动性不足,他可以把他自己交易所的挂单放到共享流动性池中,而其他交易所可以把共享流动性池中的订单挑选至自己的交易所进行展示。如果订单成交,则两家交易所将根据订单属性marginSplitPercentage的值按比例获取该笔交易的佣金。 911 | - 用户想在某交易所借贷非所在地流通的法币,该交易所可提供一种直接将订单转发至共享流动性池中的通道,促使该笔交易在其他符合条件的交易所快速成交以提升用户体验。交易佣金依然由两家交易所根据订单属性marginSplitPercentage的值按比例收取。 912 | 913 | #### 5.5.1. 共享订单 914 |   我们称交易所想要投放至共享流动性池中的订单为共享订单,其格式如下:
915 | 916 | ```protobuf 917 | message sharedOrder { 918 | string originExAddr/DID; 919 | bytes rawOrder; 920 | uint8 marginSplitPercentage; // [1-100]; we will set a default value:3; 921 | uint8 v; 922 | bytes r; 923 | bytes s; 924 | uint256 nonce; 925 | } 926 | ``` 927 | 928 | #### 5.5.2. 微服务与集群 929 |   在GEB Network中,共享流动性池以服务组织的形式存在。为了未来能够更好地拓展与升级服务,我们采用了微服务的架构设计。参与维护共享流动性池的节点需要抵押保证金并向GEB基金会提交服务器参数配置等相关材料,认证通过后方可加入服务集群。对于长期稳定提供服务的诚实节点,我们通过服务质量加权计费或按时计费等方式用GEB Token进行结算。
930 |   从简单和安全的角度出发,为支持RESTful API访问和可选的SSL客户端证书认证,我们以etcd作为共享流动性池的主要技术实现。etcd是一个高可用的KV存储系统,可用于共享配置和服务发现。在其持久化层,主要维护的是服务列表和订单列表,服务列表用于交易所消费数据时进行服务查找,如交易所主动选单,热点账户配置等;订单列表是交易所向共享流动性池投放的订单集合,为了保证订单来源,订单列表中的每一笔订单都是用源交易所的私钥对除字段 originExAddr 以外的参数哈希进行签名得到。因此,挑选该订单的交易所也需要对其进行验签,如果验签不通过则反馈订单无效,集群服务会在订单列表中进行状态更新。在服务层,一般情况下是使用Pub-Sub模式广播Topic全局版本号的变动。所谓Topic全局版本号更新就是Topic指向的任意服务列表或者Topic指向的订单列表发生了变动,这个Topic版本号都会递增。接收到所订阅Topic版本号变动的交易所可向目标服务器请求服务。
931 | 932 | ```javascript 933 | var pubsub = new PubSub(), 934 | grab = function(shareOrder) { 935 | // do something 936 | putToEx(sharedOrder) 937 | ... 938 | }; 939 | 940 | pubsub.on('orderList', grab); 941 | pubsub.emit('orderList', newOrders); 942 | ``` 943 | 944 | 当共享订单数过高时,由于服务集群会长期追踪各个交易所的数据并对日志数据进行分析,因此我们可根据结论在集群中设置高性能节点以主动推送订单给流动性高的交易所的方式来提升撮合效率。
945 | 946 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/sharded-pool.jpg) 947 | 948 | ### 5.6. 可信预言机集合 949 |   由于部署在区块链网络中的智能合约的主观性体现在对链内数据的访问,而对于链外数据只能被动接受。因此,我们需要一个可信任的实体——预言机(Oracle)来完成诚实数据的输入。预言机是区块链世界与现实世界沟通的桥梁,它提供了一个权威准确、不可篡改、稳定、并可接受审计的数据查询接口。在区块链系统中获取链外数据的一般性流程:智能合约会在预定的时间或通过事件触发让Oracle从链外的数据源获取数据并输入,然后智能合约按照获取的数据采取预设的行动。然而该过程的实现,我们要解决两个关键问题:1)共识;2)受信方。
950 |   GEB Network采用声誉系统和流动服务机制来解决以上问题。首先,我们选取N个预言机组成混合网络,并让网络中单一预言机与数据源之间建立1:M的关系。其次,在数据源和预言机上分别设有声誉系统,对可信输入形成双层保障机制。最后,根据数据源和预言机的多次工作流的信用积累实行流动服务,以此形成正向反馈来提高数据查询与数据写入的效率。
951 | 952 | ![img](https://raw.githubusercontent.com/gebnetwork/DAICO/master/whitepaper/images/data-feed.jpg) 953 | 954 |   预言机网络和数据源都是动态的,它是实现流动服务的基础。每一个Oracle合约实例都需要在GEB Network中进行注册,并填充目标数据关键字,费用,保证金阈值,参与门槛等内容。在需要获取链外数据时,GEB Network会根据合约实例内容撮合需求方和Oracle,匹配成功后Oracle抵押GEB Token正式组成预言机网络。在共识阶段,先检查达成共识的Oracle数是否符合Oracle合约实例中的预设值,若符合,则进行Data Feed及分发奖励金;若不符合,则阻塞Data Feed进程且所有Oracle重试不超过有限K次向数据源获取数据并进行共识的过程,在重试的过程中,Oracle有权更新数据源并应该自身维护一个对数据源信用积分更新的列表来提高查询效率。若有限K次重试后仍然无法达成共识,则分以下几种情况处理:
955 |   **前置条件,预言机网络节点数N,共识节点数预设值C,其中C满足:**
956 | 957 |                     ![](https://latex.codecogs.com/gif.latex?N*%5Cfrac%7B2%7D%7B3%7D+1%5Cleq%20C%5Cleq%20N) 958 | 959 | 1. 当实际共识节点数N/2 960 | 2. 当实际共识节点数N/3<=C'<=N/2时,所有预言机网络节点失去声誉点,并应主动更新自身所维护的数据源信用积分列表。
961 | 3. 当实际共识节点数C' 962 | 963 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/oracle.jpg) 964 | 965 |   以下我们描述了Oracle合约需具备但不限于所列出的属性:
966 | 967 | | Field | Type | Description | 968 | | ----------- | :----: | :--------------------------------------- | 969 | | charge | uint64 | Service charge, bounty. | 970 | | deposit | uint64 | Prevent Oracle Nodes from doing evil. | 971 | | reputation | uint32 | The credit threshold for participating in Oracles network. | 972 | | sourceType | string | Keywords for reducing search scope and improving query efficiency.eg:"chaindata,UML". | 973 | | oracleCount | uint8 | Expected number of Oracle. | 974 | | agreeCount | uint8 | The number of Oracle reaching a consensus. | 975 | | threshold | uint32 | Comprehensive assessment of Oracle and the list of data sources it maintains. | 976 | 977 | ### 5.7. GEB开源软件 978 |   GEB团队将在未来提供以下(不限于)的开源软件:
979 | - 交易市场节点软件 980 | - 交易市场DApp 981 | - H5交易市场插件 982 | - 陪审员仲裁软件 983 | 984 |

985 | ## 6. 协议安全分析 986 | 987 | ### 6.1. 法币转移风险 988 |   GEB Network中的OTC以及抵押借贷都实现了Token与法币之间的兑换。因此,在执行交易时,我们要考虑经常会出现的问题是区块链加密资产转移的不可回退性与许多法币支付方式可回退性之间的不匹配。常见的支付方式及其交易回退性如下:
989 | 990 | | Payment Method | Currencies | Reversibility of Transactions | 991 | | :------------------ | :-------------------- | :--------------------------------------- | 992 | | PayPal - regular | Most world currencies | Extremely easy to charge back. Also, since trading bitcoin is against their ToS, good luck disputing the chargeback. | 993 | | Paypal - personal | Most world currencies | If funded via bank, requires person to dispute the ACH, which may be more arduous. If funded via credit card, requires person to dispute the CC charge, which is pretty easy. Since there's no way to tell what the funding source was... it's a gamble. Also, if paypal account is reported stolen, paypal will probably attempt to claw back the money. | 994 | | AliPay / Wechat Pay | CNY | There are reports of reversed AliPay payments can be found on the Internet. | 995 | | Dwolla | USD | Since Dwolla amounts are funded via ACH, Dwolla will now reverse payments if the funds were the result of fraud. Additionally, Dwolla's Terms and Conditions now state that peyments received are subject to chargebacks as the result of their internal dispute resolution process. | 996 | | Credit / Debit card | Any currency | Extremely easy to charge back. | 997 | 998 |   针对这种不匹配性矛盾,GEB基金会将对认证的交易商所支持的法币支付方式做相关要求,必须选择符合地区法律监管,交易不可回退的支付方式(如Bank wire,MoneyPak,Webmoney,[LavaPay](https://en.bitcoin.it/wiki/LavaPay),OKPay等)以匹配区块链资产转移的特性,从而实现广义程度上的交易原子性,防范欺诈等风险。
999 | 1000 | ### 6.2. 预言机攻击 1001 |   GEB协议下的有效合约操作都映射到以太坊区块链全局状态的更改,即APPLY(S,TX) -> S'。而协议簇是由一组或多组有状态的合约构成,一个非正确性(虚假数据,乱序等)的输入就会使得非预期性结果永久被写入账本。有前后状态依赖的输入输出意味着具备有序性与逻辑性,这就对合约程序的鲁棒性和输入的正确性都提出了很高的要求。合约编写需要我们缜密的思考,良好的编码习惯及细致的审计工作。数据的输入需要保证数据源的可靠,在GEB Network中对于数据源的接入以及防止Oracle节点联合作恶,我们设置了应用层共识,声誉系统、抵押保证金、流动性服务等机制。在匹配需求是从外部行情市场进行喂价时,要考虑价格的波动和成交的及时性,Oracle之间未达成共识时的有限K次重试就可能会成为攻击点,我们会在保证系统安全的情况下根据流量监控等多重因素,设计出K值的动态调整策略以尽量减少K值并结合对数据进行剔除最值再取均值的处理方式来完成喂价。此外,针对特定的外部数据输入我们还设立了加解密预言机来保护数据和提升系统的安全性。 1002 | 1003 | ### 6.3. 中间人攻击 1004 |   中间人攻击主要发生在用户与服务器通信的过程中。在GEB Network中设有共享流动性池分布式集群服务和分散的陪审员网络。在共享流动性池集群中,交易所需要与服务节点直接通信,正常情况下两者在TLS连接下内容是加密的,第三方即使可以嗅探到所有的数据,也不能解密。但第三方即中间人可以与交易所建立连接,然后中间人再与服务节点建立连接,转发他们之间的内容,这时候中间人就能解密获取明文信息并进行修改。如果中间人截获交易所发出的共享订单,经篡改后转发至服务节点则导致大量垃圾交易被填充在共享流动性池中,进而使得其他交易所可能获取的是大量的无效共享订单。因此,GEB基金会将通过DAO给已认证的集群节点根据其DID颁发证书来防范此类攻击。在陪审员网络中,我们采用了内容推拉分离式设计使得用户与陪审员网络不直接交互,而是通过PageSigner等方式将证据的内容哈希上链存储,而陪审员主动提审证据,从而防范了中间人攻击。
1005 | 1006 | ### 6.4. 女巫攻击或拒绝服务攻击 1007 |   伪装成多个节点执行恶意行为称为Sybil攻击,它致使被攻击者承受多方伪装节点的虚假数据。而拒绝服务攻击即是攻击者想办法让目标机器停止提供服务。Sybil和DOS两种攻击模型经常能够组合出现,比如只需要20个女巫节点,DOS就能完全可以泛滥式攻击某P2P网络的数据库使其脱机,还能对网络上的所有流量进行归档。GEB Network 与以太坊区块链存在安全性的从属依赖关系,在以太坊中工作量证明的目的之一就是使区块的创建变得困难,从而阻止女巫攻击者恶意重新生成区块链。在GEB协议生态中,陪审员、交易商、共享流动性池集群节点都经过去中心化身份认证,不存在攻击者可以通过只部署一个实体,向网络中广播多个身份ID,来充当多个不同的节点。此外,有关对共享流动性池的DDOS攻击可选用如蜘蛛系统等解决方案进行防御。
1008 |   还有值得我们注意的是,在抵押借贷的背景下,由于抵押率的存在且是浮动的,女巫攻击者的角色有可能是由借贷者扮演。攻击者的意图是根据抵押率以及对市场行情的分析,在适时使用大量欺诈身份发起借贷订单,待成交之后全部违约或故意逾期来获利。然而,现阶段GEB协议被设计成有担保债务,即使攻击成功也收益甚微,况且我们的要求是所有的债务/债权人都需要进行去中心化身份认证,所以不具备条件来发起女巫攻击。 1009 | 1010 | ### 6.5. Penny-Spend 攻击 1011 |   Penny-Spend 攻击是指攻击者通过发送大量微小金额的交易来浪费节点的存储资源或作为套利手段骗取GEB Token。GEB协议设计成“链下订单中继链上结算”的模式,那么在交易结算之前的订单合并是防范由于零成本的订单委托容易成为攻击切入口的有效措施(实际上,此为传统中心化交易所常见的业务模式)。但是,交易所本身可能会想通过发送大量垃圾共享订单来污染共享流动性池,关于此种做法,我们能够根据共享订单中的DID/originExAddr来追踪共享订单来源,在集群服务中对恶意行为进行监控,如有发现作恶则提交至DAO来取消该交易所的认证资格和没收保证金。此外,关于交易所通过刷量交易获取GEB Token的情形,由于交易所收取交易佣金是在上链结算之后,交易的合法性也会经以太坊矿工验证,因此可以杜绝此类现象。
1012 | 1013 | ### 6.6. 信心攻击 1014 |   信心攻击是指攻击者利用典型的人类特征,如贪婪,不诚实,虚荣,机会主义,欲望,同情,轻信,不负责任,绝望和天真等对目标者实施诈骗。 然而,信心攻击在GEB Network中的体现主要在于攻击者已经获取对手方的相关信息,并且分析数据来了解其弱点先行进行信任骗取(攻击者为了实行攻击,通常建立了样本库并进行过聚类分析,获取信息后只需与数据库进行匹配就可快速采取相应的攻击手段),再通过引导的方式让双方的交易在脱离GEB协议的场景下完成。为防范此类攻击,我们要求交易商在所提供的交易工具上呈现醒目的类似“请勿将交易转移至GEB Network之外的环境执行”等风险提示。此外,就系统本身而言,我们设计了去中心化身份认证机制,具有高度的隐私保护性,攻击者想在GEB Network中获取目标隐私数据是困难的。同时,我们也倡议用户注意合理维护自身资金账户地址与社交属性App之间的弱相关性,提升自我隐私保护意识。
1015 | 1016 | ### 6.7. 智能合约代码审核 1017 |   回顾2016年6月17日The DAO事件,2017年11月6日Parity多重签名合约漏洞事件,以及最近的SMT、BEC合约的整数溢出漏洞事件等均造成了资金上的巨大损失。若不做好严格的代码审计和安全防护,生态建设就成为了一纸空文。因此,GEB Network 的所有合约代码均会经专业的智能合约安全审计机构进行审阅和充分测试,届时还会提交测试报告及相关材料。
1018 |   考虑到协议的升级,GEB Network 的部分组件有可能建立在Zeppelin_OS之上。Zeppelin_OS是用以安全地构建和管理EVM生态的智能合约应用的去中心化平台。它设有担保机制实现合约代码的管理与升级,同时还提供了一个用于攻击响应的工具箱来预防攻击,当遭遇黑客攻击时,Zeppelin_OS将被触发紧急暂停,恢复到之前未受影响的状态。
1019 |   我们相信,一系列严谨细致的研发工作将能为 GEB Network 的生态建设之路保驾护航。
1020 | 1021 |

1022 | ## 7. 市场分析 1023 | 1024 | ### 7.1. 加密货币市场现状 1025 |   根据CoinMarketCap的研究,在2017年9月,加密货币的平均日交易量已经超过了40亿美元,加密货币市场的总市值已经超过了130亿美元。然而,与全球法定货币的交易相比,加密货币市场仍然很小。例如,国际清算银行评估的全球外汇市场日交易量为5.1万亿美元,根据加密货币目前的增长率,很可能在未来3年内就能达到与外汇市场相似的交易量。因为我们很快就会生活在一个以数字货币为主导的现实中。
1026 |   从市场反应和数据上看,2017年加密货币市场已经达到了政府无法忽视的规模,因此,越来越多的国家将会认可加密货币,并对其进行相关规范和立法,可见加密货币未来巨大的发展潜力。
1027 | 1028 | ### 7.2. 世界各国对区块链的态度 1029 |   总的来说,大多数国家对于加密货币和区块链技术的都持欢迎的态度,并且已经开始尝试推动加密货币的应用落地以及在技术上进行探索与创新:
1030 | 1031 | - **中国**:虽然中国目前对加密货币的交易持保守态度,但是在政府层面上从未停止对区块链底层技术的研究。 1032 | 1033 | 2016年2月,中国的央行行长周小川表示数字货币必须由央行来发行,区块链成为研发数字货币可选的技术。
1034 | 2016年12月,国家将区块链列入了十三五国家信息化规划。
1035 | 2016年10月,工信部发布了2016中国区块链技术和应用发展白皮书。
1036 | 2017年9月,中国人民银行等七部委联合发文认定ICO是一种未经批准的非法公开融资的行为,涉嫌非法发售代币票券,非法发行证券,以及非法集资金融诈骗传销等违法行为。 1037 | 1038 | - **俄罗斯**:俄罗斯政府的态度比较复杂,俄罗斯之前禁止公民持有和交易比特币,但是对于区块链技术却非常欢迎。 1039 | 1040 | 2017年6月,俄罗斯总统普京接见了以太坊创始人Vitalik Buterin。
1041 | 2017年8月,俄罗斯国家开发银行与以太坊基金会达成了战略合作。
1042 | 1043 | - **韩国**:韩国对区块链目前持支持的态度,对比特币以太坊等数字资产在加强监管。 1044 | 1045 | 2016年2月,韩国央行在报告中提出鼓励探索区块链技术。
1046 | 2017年9月,韩国金融服务委员会FSC宣布将如何对数字货币,比如比特币,以太币进行监管。韩国加大监管力度,对于洗钱,非法融资和其他数字货币非法交易进行调查。
1047 | 1048 | - **印度**:印度作为人口大国以及软件开发强国,一直很重视区块链技术的应用。 1049 | 1050 | 2017年1月,印度的央行发布了一份全面的区块链白皮书,认为区块链对于印度发行数字货币的时机已经成熟。
1051 | 2017年6月,印度政府委员会宣布支持监管比特币成立专门的任务组,创建监管框架计划短期内全面完成比特币的合法化。
1052 | 1053 | - **澳大利亚**:澳大利亚比较注重区块链技术的应用和标准的制定。 1054 | 1055 | 2016年4月,澳大利亚标准局呼吁制定全球ISO区块链标准。
1056 | 2017年3月,澳大利亚国家标准局根据国际标准组织iSO分配的任务,发布了国际区观念标准开发路线图。
1057 | 2017年8月,澳大利亚政府宣布将数字货币,交易所纳入澳大利亚交易数据分析中心监管。澳大利亚证券交易所等均在使用区块链技术进行交易的测试。
1058 | 1059 | - **英国**:英国是欧洲地区最早对区块链进行研究验证的国家。 1060 | 1061 | 2016年1月19日,英国政府率先发布了长达88页的《分布式账本技术:超越区块链》的白皮书,同时积极评估区块链技术的潜力,考虑它将用于减少金融欺诈降低成本的领域。
1062 | 2016年3月,欧洲央行ECB在《欧元体系的愿景——欧洲金融市场基础设施的未来》这个咨询报告中公开宣布正在探索如何使用区块链技术为己所用。
1063 | 1064 | - **荷兰**:荷兰央行发布观点认为区块链技术可以改善其金融业务质量。 1065 | 1066 | 2016年9月,荷兰境内成立区块链园区,由银行和金融公司合作开发区块链技术在支付和泛金融领域的应用。
1067 | 1068 | - **德国**:德国在区块链新风口将抓住机遇与迎接挑战。 1069 | 1070 | 2016年11月,德意志联邦银行和法兰克福金融管理学院联合召开区块链技术机遇与挑战的大会,大会的主要目的都是对分布式账本的潜在运用展开研究,包括跨境支付跨行转账以及贸易数据的存储等等。
1071 | 1072 | - **美国**:美国通过立法来支持区块链的发展。 1073 | 1074 | 2014年6月,美国加利福尼亚州州长签署了一项编号为 AB129 的法律文件,保障加州比特币以及其他数字货币交易的合法化。
1075 | 2016年6月,美国国土安全部对六家致力于政府去管理应用的开发公司进行补贴。
1076 | 2017年2月,美国亚利桑那州通过区块链签名和智能合约合法性法案。同月,美国医疗保健部门 ONC 以举办医疗保健黑客应用开发马拉松,将区块链技术应用到医疗保健领域当中。美国国会宣布成立国会区块链决策委员会并承认了区块链的潜力,呼吁发展区块链技术在公共部门中的应用,而在比特币的态度上,美国也是鼓励投资并实施严格的监管。
1077 | 2017年7月,美国证券交易委员会 SEC 认定以太坊代币属于证券,发行方需要依法办理证券发行的登记。同月,美国商品期货交易委员会 CFTC 批准 LedgerX 与以加密币市场挂钩的期权和衍生品提供清算服务。
1078 | 1079 | - **日本**:日本的态度非常积极。日本的央行自己在尝试一些区块链项目,在立法监管上主要是针对如何推动比特币等数字资产的应用落地。 1080 | 1081 | 2016年3月,日本内阁通过投票将比特币和数字货币均视为数字等价货币。
1082 | 2017年4月1日,日本实施了《支付服务法案》,正式承认比特币是一种合法的支付方式,对于数字资产交易所提出了明确的监管要求。
1083 | 2017年7月,日本新版消费税正式生效,比特币交易将不再需要缴纳 8% 的消费税。
1084 | 1085 | - **新加坡**:新加坡的是一片区块链的沃土,该国总理李显龙公开督促新加坡金融部门跟上区块链技术的发展的步伐。因此,新加坡在对于区块链证券金融创新监管政策的开放程度远超亚洲其他国家。 1086 | 1087 | 2016年6月,新加坡金融管理局推出了沙盒机制 Sandbox,只要任何在法律规定的受保护中注册的金融科技公司,在事先报备的情况下,允许从事和目前法律法规有所冲突的业务,并且即使以后被官方终止相关业务,也不会追究其相关的法律责任。通过这种沙盒的机制,新加坡政府能够在可控范围内鼓励企业进行各种区块链的金融创新。
1088 |   综上分析可知,GEB团队在未来发行代币时将会严格遵守世界各国目前的相关政策法规,先从对数字货币政策相对开放的新加坡发行,逐步向其他国家发展。
1089 | 1090 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/world.jpg) 1091 | 1092 | ### 7.3. SWOT分析 1093 | 1094 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/swot.jpg) 1095 | 1096 |

1097 | ## 8. 路线图 1098 | 1099 | ![img](https://github.com/gebnetwork/DAICO/blob/master/whitepaper/images/roadmap-horizontal.jpg) 1100 | 1101 |
1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 |
哥德尔2018.Q2白皮书发布
GEB Network官网上线
启动全球社群运营,包括美国,中国,加拿大,澳大利亚,俄罗斯等国家
埃舍尔2018.Q3开放交易商申请
DAICO启动,分为Phase Ⅰ和Phase Ⅱ两个阶段
GEB代币上线交易所
智能合约开发
2018.Q4平台软件开发
发布GEB协议内测版
巴赫2019.Q1上线至少10家GEB认证交易所
发布GEB协议公测版,及平台开源
官方交易所试运行,模拟交易
2019.Q2GEB Network主网上线
GEB官方交易所正式运行
设立GEB Network北美、欧洲办公室,扩展全球业务
1157 | 1158 |

1159 | ## 9. 团队介绍 1160 | - CEO & 基金会主席: 朱崴 1161 | 1162 |   复旦大学微电子学学士,十余年互联网行业技术研发和技术管理经验。区块链,人工智能布道者。增长黑客,终身学习者。曾创办新普IT咨询,为国内最早的从事区块链技术咨询的企业。曾任奇虎360WiFi业务首席架构师,DeNA China技术总监,主持亿级用户产品的研发管理工作。技术创新先驱,主张从协议层对互联网基础设施进行重构。对区块链、分布式计算、事件溯源,图灵计算、深度学习等理论有深入研究和独到的见解。
1163 | 1164 | - COO: 陈旺勇 1165 | 南京理工大学科技信息管理学士,前华为欧洲市场部营销总监。目前专注与IPO资本市场投资和区块链数字货币领域产品运营和投资。 1166 | 1167 | - CFO: 江纯 1168 | 1169 |   本科毕业于复旦大学,硕士就读于杜克大学国际经贸专业。曾就职于摩根士丹利伦敦,任职金融分析师。曾供职于世界银行,从事全球价值链研究,分析中国经济金融政策对产业链升级和全球化的影响。
1170 | 1171 | - 海外市场运营: 周海琴 1172 | 1173 |   七年海外市场商务谈判与项目管理经验,曾在著名车联网企业迪纳科技全面负责海外市场业务,任职期间为公司引进千万级马来西亚运营商合作项目,首开国内车联网公司为海外运营商提供包括车联网大数据平台与硬件在内的一体化解决方案的合作案例先河。英语高级口译,曾在上海G20财政部长会议担任同声传译工作。目前专注于从事加密货币投资与区块链相关产业研究与市场运营,有丰富的海外商务与项目运营经验。
1174 | 1175 |

1176 | ## 10. 顾问 1177 | 1178 | - 吕彦鹏 1179 | 1180 |   借贷宝首席架构师。毕业于中国科学技术大学,在人工智能方向发表多篇论文,其论文引用数及影响力居高不下。曾经就职于360手机助手,负责手机助手推荐业务,为亿级用户提供App推荐服务,所研发的推荐算法精准匹配用户需求,用户下载率获得了20%的提升。在支付领域深耕已久,对于借贷业务有自己的独到见解,主持借贷金融方向核心系统研发,对存管政策变化合理架构进行了深度解析并完成了存管系统的升级。
1181 | 1182 |

1183 | ## 11. 参考文献 1184 | [1] W3C. JSON-LD 1.0, https://www.w3.org/TR/json-ld/, 2014.
1185 | [2] Jorge Izquierdo. The new operating system for protocols and DApps, https://blog.aragon.one/introducing-aragonos-3-0-alpha-the-new-operating-system-for-protocols-and-dapps-348f7ac92cff, 2018.
1186 | [3] BitcoinWiki. Payment methods, https://en.bitcoin.it/wiki/Payment_methods, 2016.
1187 | [4] Joseph Poon, Thaddeus Dryja. The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments, 2016.
1188 | [5] Vitalik Buterin. A Next-Generation Smart Contract and Decentralized Application Platform, https://github.com/ethereum/wiki/wiki/White-Paper, 2014.
1189 | [6] Vitalik Buterin. Explanation of DAICOs, https://ethresear.ch/t/explanation-of-daicos/465, 2018.
1190 | [7] Vitalik Buterin. On Medium-of-Exchange Token Valuations, https://vitalik.ca/general/2017/10/17/moe.html, 2017.
1191 | [8] Conner Fromknecht. Connecting Blockchains: Instant Cross-Chain Transactions On Lightning, https://blog.lightning.engineering/announcement/2017/11/16/ln-swap.html, 2017.
1192 | [9] Alex Evans. On Value, Velocity and Monetary Theory, https://medium.com/blockchannel/on-value-velocity-and-monetary-theory-a-new-approach-to-cryptoasset-valuations-32c9b22e3b6f, 2018.
1193 | [10] Matus Lestan, Joe Urgo, Alexander Khoriaty. district0x Network: A cooperative of decentralized marketplaces and communities, 2017.
1194 | [11] Shiliang Huang. Refusal of payment arbitrage attack -- An attack technique in OTC transactions and precautions for it, https://mp.weixin.qq.com/s?__biz=MzIxNTA0NDQzMA==&mid=2651798518&idx=1&sn=4e91bac98cea5bc600e8429f1af3a728, 2017.
1195 | [12] RSK Labs. Sidechains, Drivechains, and RSK 2-Way peg Design, https://www.rsk.co/blog/sidechains-drivechains-and-rsk-2-way-peg-design, 2017.
1196 | -------------------------------------------------------------------------------- /whitepaper/images/cross-chain-vertical.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/cross-chain-vertical.jpg -------------------------------------------------------------------------------- /whitepaper/images/daico.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/daico.jpg -------------------------------------------------------------------------------- /whitepaper/images/data-feed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/data-feed.jpg -------------------------------------------------------------------------------- /whitepaper/images/lightning-swap-vertical.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/lightning-swap-vertical.jpg -------------------------------------------------------------------------------- /whitepaper/images/network-structure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/network-structure.jpg -------------------------------------------------------------------------------- /whitepaper/images/oracle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/oracle.jpg -------------------------------------------------------------------------------- /whitepaper/images/roadmap-horizontal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/roadmap-horizontal.jpg -------------------------------------------------------------------------------- /whitepaper/images/sharded-pool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/sharded-pool.jpg -------------------------------------------------------------------------------- /whitepaper/images/swot-en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/swot-en.jpg -------------------------------------------------------------------------------- /whitepaper/images/swot-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/swot-small.jpg -------------------------------------------------------------------------------- /whitepaper/images/swot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/swot.jpg -------------------------------------------------------------------------------- /whitepaper/images/token-distributed-en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/token-distributed-en.jpg -------------------------------------------------------------------------------- /whitepaper/images/token-distributed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/token-distributed.jpg -------------------------------------------------------------------------------- /whitepaper/images/world.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gebnetwork/DAICO/fc484a283eac9dac5ae2e12c7d06e4689372675e/whitepaper/images/world.jpg --------------------------------------------------------------------------------