{ "cells": [ { "cell_type": "markdown", "id": "5408864a-0c65-44fa-a86c-02a9bb83c772", "metadata": { "tags": [] }, "source": [ "![PepeTeam](https://pepe.team/favicon.ico)\n", "\n", "# **bridge** litepaper [DRAFT]\n", "\n", "###### powered by PepeTeam (@stupid_boar,@pepenger)\n" ] }, { "cell_type": "markdown", "id": "6940cccf", "metadata": {}, "source": [ "## 1 Introduction\n", "\n", "###### Disclaimer\n", "\n", "> This paper is for general information purposes only. It does not constitute investment advice, recommendation or solicitation to buy or sell any investment products and should not be used in the evaluation of the merits of making any investment decisions. It should not be relied upon for accounting, legal or tax advice or investment recommendations.\n", "\n", "The growing popularity of blockchain technologies has led to the creation of DeFi(decentralized finance) [1] applications that are based on the principles of traditional financial tools. DeFi applications are represented by program code written in the language of smart contracts. The recognized leader in the field of decentralized financial instruments is not only Ethereum and its analogues (BSC, Polygon PoS, Avalanche etc), but also second-layer derivative platforms (L2) [2] that were designed to improve network TPS(transactions per second) bandwidth.\n", "\n", "Investors' attention to the decentralized economy attracted professionals who implemented the functionalities of AMM(automated market maker) pools, loans, liquidity farms, exchanges and gaming platforms (Maker, Curve Finance, AAVE, Compound, UniSwap, yFinance, Balancer, dYdX, Decentraland).\n", "\n", "The development of blockchain platforms led to a wide variety of technological solutions, driven by the desire to solve the main problems of decentralized systems: scalability, decentralization and security. Differences in consensus algorithms [5] (PoW, PoS, dPoS, PoH, PoA, GRANDPA, Hashgraph etc), cryptography [6] (ECDH, ECDSA, secp256k1, curve25519, ed25519, nistk571, nistb571, SNARK, STARK, groth16 etc.), the availability and capabilities of smart contracts (Bitcoin script, EVM, eWASM, LLVM etc) do not allow for designing a single interface for cross-platform interaction. The isolation of blockchain systems requires taking into account the internal structure and scheme for storing data and transactions. So, for example, a sent transaction on the Ethereum network cannot be validated on the Bitcoin network due to the difference in cryptographic primitives and incompatible ownership models (UTXO and Ethereum accounting model [7]).\n", "\n", "Considering emerging trends in the development of blockchain technologies and specifically in DeFi, we can confidently predict a further increase in capitalization and interest from institutional investors. However, the improvement of financial models will create high demand for mechanisms providing cheap and safe movement of liquidity not only between DeFi protocols, but also between blockchain platforms, as the degree of isolation between platforms leads to liquidity fragmentation.\n", "\n", "The crypto community is actively researching and developing new cryptographic algorithms that enable reducing transaction fees and raising the level of anonymity. A promising area of cryptography is Zero Knowledge algorithms [8]. Tornado Cash, Monero, ZCash use ZK-SNARKs/Bulletproof to create anonymous transactions. Zk-Rollups [9] use ZK-SNARK to solve the Ethereum network scalability problem. The most advanced algorithm is ZK-STARK [10] (StarkEx, StarkNet, dYdX), which solves the problem of post-quantum security.\n", "\n", "The use of ZK imposes a number of restrictions on the implementation of the interaction protocol: the presence of smart contracts, the software set of commands must offer an ability to implement the zero-knowledge proof verification algorithm, the interacting platforms must support equivalent proof verification algorithms. The above restrictions, for example, make building a protocol of interaction between BTC and EVM, impossible.\n", "\n", "The high cost of proof verification (see Table 1) is also unacceptable for most users (comparable to 10 ERC20 token transfers). A solution for reducing the cost is possible, but it requires an increase in the time of the transaction on the target blockchain (compression of transfer events).\n", "\n", "##### Table 1\n", "\n", "| | SNARKs | STARKs | Bulletproofs |\n", "| -------------------------- | ---------------------- | -------------------------- | ------------- |\n", "| Prover | O(N × log(N)) | O(N × polylog(N)) | O(N × log(N)) |\n", "| Verifier | ~O(1) | O(polylog(N)) | O(N) |\n", "| Communication (proof size) | ~O(1) | O(polylog(N)) | O(log(N)) |\n", "| Proof size (1 tx) | 200 bytes (key 50 MB) | 45 kB | 1.5 kb |\n", "| Proof size (10000 tx) | 200 bytes (key 500 GB) | 135 kB | 2.5 kb |\n", "| EVM verification gas cost | ~600k (Groth16) | ~2.5M (estimate, no impl.) | n/a |\n", "| Trusted setup required | + | - | - |\n", "| Post-quantum secure | - | + | - |\n", "\n", "An important solution is the creation of a transparent protocol for the interaction of blockchain platforms. Such a protocol should solve not only the problem of information exchange in a general way, but also the problem of liquidity fragmentation through cost-effective rebalancing.\n", "\n", "PepeTeam is highly qualified in the field of blockchain technology and consists of developers involved in building popular DeFi projects based on EVM (solidity/vyper) [11] and Ride [12]. The team decided to be anonymous and decentralized, focusing its efforts on implementing projects that serve the interests of the crypto community.\n" ] }, { "cell_type": "markdown", "id": "3b5cb73e", "metadata": {}, "source": [ "## 2 Principles of work\n", "\n", "The task of transferring liquidity between different blockchains is currently solved with the help of centralized bridges, which are managed by private crypto asset exchange platforms (for example, Binance, Huobi etc) or individual organizations that have implemented their bridges as a way to earn money on transfer fees (multichain.xyz etc) [13]. Such solutions are trusted by users because they offer low fees, have been stably functioning for a long time and rely on the reputation and brand of a specific vendor. However, such products contradict the blockchain philosophy as a decentralized system without a single control center. Such an approach leads to the emergence of possible risks of the service failure, asset freeze for an indefinite time before the user completes identification procedures (AML, KYC), possible software errors and infrastructure breakdowns. It is extremely difficult to assess the degree of risk in this case due to the lack of open-source code, third-party security audits and an insufficiently formed regulatory framework for regulating crypto assets around the world.\n", "\n", "Currently, a significant number of teams and crypto enthusiasts are in the process of solving the above problems by developing decentralized systems for the transfer of liquidity (or control actions and events) between blockchains. These systems are subject to the following requirements:\n", "\n", "- open-source contracts and applications;\n", "- high level of security and reliability of the employed cryptographic tools;\n", "- low fees for the user;\n", "- transparency of the protocol and the ability to audit the correct execution of user transactions;\n", "- decentralized protocol management by the community through a DAO;\n", "- the use of smart contracts to manage business logic and guarantee its immutability (a change is possible only after community approval);\n", "- scalability of the system and the possibility of increasing the degree of decentralization;\n", "- the ability to manage system components for new users;\n", "- protocol integration with other projects (AMM, Lending, DEX etc);\n", "- extending functionality through DAO.\n", "\n", "The planned solution must meet all the above requirements. Among the most obvious approaches for implementing the protocol are the following:\n", "\n", "1. systems with mutual proofs (connext [14]);\n", "1. p2p threshold signature networks;\n", "1. an intermediate transport blockchain that regulates the consensus between the participants (witnesses, signers etc.).\n", "\n", "Protocols based on mutual proofs have a critical flaw. Since the operation is based on the generation and validation of cryptographic signatures, there is a need to support common cryptographic primitives. Due to this restriction, there is no possibility for the interaction of cryptographically incompatible networks. The second important limitation is the requirement for the same type of organization of evidentiary mechanisms of the storage structure (hash tree). Such an approach is convenient for organizing the interaction of compatible networks (sidechains, parachains), but it creates significant restrictions when integrating non-joint blockchains (BTC, FreeTON, Solana etc.), which limits the list of the supported crypto assets.\n", "\n", "Projects implemented under schemes with a P2P threshold signature network are mostly closed (allbridge, debridge [15]) and difficult to validate by third-party auditors. Proving correct operation of a P2P network is a difficult task, even with the presence of a slashing mechanism there is no guarantee that the actual executable code corresponds to the declared code, and that it does not contain errors, backdoors and potential vulnerabilities. In terms of implementation, this approach is close to centralized platforms for the exchange of crypto assets, which contradicts the earlier provided requirements.\n", "\n", "Thus, the most appropriate solution is the use of a transport blockchain. This approach enables flexible and transparent management of the protocol without compromising decentralization, simplifies the procedures for controlling cross-chain interaction processes and facilitates a transparent security audit.\n", "\n", "The implementation of a new blockchain for solving transport problems seems to be laborious and time consuming. In addition, there is a possibility of errors in program code and potential attacks on the network. In this regard, we decided to use a time-tested technology suitable for the transport needs of the protocol.\n", "\n", "After analyzing the market to find the available solutions (blockchains) that are technically suitable for the functioning of the system and satisfy the above requirements, the choice was made in favor of the Waves blockchain [16] due to the following considerations:\n", "\n", "1. a fixed fee for calling a smart contract [0.005 WAVES] allows for calculating in advance the fee burden on users of the protocol, compensating possible bursts of network activity (an increase in gas price in Ethereum-like networks leads to an increase in the cost of invoke by several times);\n", "2. the advanced smart contract language Ride (functional scala-like, supporting a large set of functions, including the ability to multiple call smart contracts);\n", "3. free cancellation of transactions, subject to the restrictions on the complexity of the called function, simplifies the interaction of witness and signer with the protocol contracts;\n", "4. PoS consensus, the speed of creating new blocks is 1 minute (microblocks 3-5 seconds), which is a compromise solution between high throughput (as Polygon) and stability (as BTC);\n", "5. the blockchain has been successfully functioning for more than 6 years;\n", "6. a high degree of network decentralization (compared to BSC);\n", "7. stable network operation, no long downtime and protocol failures (compared to Solana);\n", "8. no successful hacker attacks leading to a public fork of the network;\n", "9. the availability of an advanced development infrastructure (blockchain explorer, public node pool, online IDE, WavesKeeper browser extension, open-source code):\n", "10. a rapidly developing ecosystem (analogues of Curve, Uniswap, AAVE etc. are implemented entirely on smart contracts).\n", "\n", "The predicted cost of generating evidence in the transport network is 0.04-0.05 WAVES, which at a rate of 5 USD, is 0.2-0.25 USD.\n", "In the future, DAO participants will be able to vote for the possibility of replacing the transport blockchain (for example, for economic reasons or in order to improve the security of the protocol).\n", "\n", "DAO participants can also decide to make cross-chain transactions on the network more anonymous. This is possible in the Waves blockchain due to the implementation of zkSNARK cryptography (groth16 [17]).\n" ] }, { "cell_type": "markdown", "id": "2a315ce4", "metadata": {}, "source": [ "### 2.1 Protocol\n", "\n", "![protocol](protocol.png)\n", "\n", "The proposed cross-chain interaction protocol is a set of smart contracts (the transport layer is built in the Ride language, peripheral contracts are implemented on smart contracts or target platform scripts) and software modules that are necessary for organizing cross-platform interaction (witness, signer etc.).\n", "\n", "Peripheral smart contracts or scripts are necessary to implement the mechanism for locking transferred tokens and to correctly confirm the execution of transactions. The initiator of this process is the user who independently pays for the transfer and locking transactions. Within this call, the user selects the target blockchain and the appropriate group of signers for the given token in it. When working with wrapped tokens, peripheral smart contracts issue (mint) new wrapped tokens when the collateral is deposited in another blockchain and burn them during the reverse operation.\n", "\n", "`Witness Smart Contract` is a smart contract that stores information about confirmed transactions that initiate a cross-chain transfer, collects and validates evidence from witness instances and monitors their correct fulfillment of obligations. This smart contract defines the order of selection, appointment and punishment for the witnesses. It determines their minimum and maximum number, as well as the amount of necessary security deposit for participation in elections for the role of witness. The main task of this contract is to obtain consensus on the fact that the user's original transaction exists in the blockchain.\n", "\n", "`Witness` is a component responsible for confirming the existence of the original transaction in the sender's blockchain. It consists of a client subsystem for the target and transport blockchain. The main task of this component is to perform verification for the transactions specified in the Witness Smart Contract and give an answer about the presence/absence of a transaction in the source blockchain for a reward.\n", "\n", "`Signature Generator Smart Contract` is a smart contract for monitoring the signing process of Signers and their re-election. It regulates the procedures for managing a group of signers. The main task of this component is to accumulate parts of signatures to allow the execution of user operations in the target blockchain.\n", "\n", "`Signer` – a component (software module) that is responsible for generating part of the signature to confirm the cross-chain transfer. The main task is to generate a signature for a peripheral smart contract in the target blockchain for a reward if there is a successfully passed check in the Witness Smart Contract. It is allowed to use different signature algorithms, provided that the final signature can be composed of partial signatures of each signer (TSS algorithm). The functionality allows generating a signature without revealing the secret parts of the key, which can be changed without compromising the security of the protocol. It is assumed that there will be different groups of signers for each target blockchain.\n", "\n", "`Tax Provider Smart Contract` is a smart contract that provides calculation of protocol fees. This component is responsible for managing the protocol fee.\n", "\n", "`Vault` - is a peripheral smart contract in the Waves network. This component is responsible for storing and managing protocol provisioning (for example, Waves staking.Unlike other peripheral contracts, it explicitly interacts with the protocol transport system.\n", "\n", "`Witness Proxy` is a component that initiates the transaction confirmation procedure by a group of the witnesses. It allows for informing the protocol about the event of the formation of a transaction, if there is no native token to pay the fee for calling a smart contract in the Waves network.\n", "\n", "The main goal is to simplify the user scenario and eliminate the need to have a WAVES or PBT (Pepe Bridge Token) for a cross-chain transfer.\n", "\n", "`Relayer` is component intended to simplify the custom scenario of delivering a token to a target user. If the user does not have a native token to pay a fee for calling a peripheral smart contract (to send transferred tokens to their address), then when initializing the transfer, the user can specify that Relayer will transfer the tokens in the target blockchain to the final address, for which they will be able to take additional fee. The users have the right to choose a Relayer with a suitable fee, or at any time to withdraw their assets on their own.\n", "\n", "In the future, the designed architecture could not only enable solving issues with new types of cross-chain interactions (NFT, price oracles etc.), but could also allow for upgrading parts of the protocol independently. This approach facilitates, for example, changing cryptographic primitives or protocol logic." ] }, { "cell_type": "markdown", "id": "4188f19b", "metadata": {}, "source": [ "#### 2.1.1 Cross-chain transfer\n", "\n", "![crosschain transfer](crosschain.png)\n", "\n", "Let’s review an example of a cross-chain transfer of an ERC-20 standard token between EVM platforms, such as Ethereum and BSC. When transferring between blockchains other than EVM, changes in the order of operations will affect only the level of peripheral smart contracts or scripts; the main algorithm of the transport layer of the protocol remains unchanged.\n", "\n", "A generalized sequence of actions for EVM cross-chain transfer includes the following steps:\n", "1. the user calls the deposit function of the peripheral contract in the Ethereum network, which takes the user's assets (transferFrom ERC-20 function) and locks these assets in the contract;\n", " - first of all, the user of the protocol performs the Approve operation of the transferred ERC-20 token for the required amount (or infinity approve) in favor of the address of the peripheral contract in the Ethereum network;\n", " - if the transferred amount of the asset is less than the minimum or the token/network is not supported, the contract prohibits the transaction;\n", "2. when a transaction is detected, the witness proxy calls the witness smart contract to create a request to confirm the existence of the transaction, attaching the service information (transaction ID, height, recipient, transfer amount, blockchain ID etc);\n", " - if the provision of the witness proxy is less than necessary or the given transaction has already been added to the verification queue, the contract prohibits the execution of the transaction;\n", " - if the transferred amount of the asset is less than the minimum or the token/network is not supported, the contract prohibits the transaction;\n", "3. the witness smart contract makes a call to the tax provider to record the request fee calculation;\n", "4. by tracking a new request to confirm the transaction, each witness checks the existence of the transaction and reports the result of the check to the witness smart contract;\n", "5. after the majority of the witnesses have verified that the transaction exists in the source blockchain, consensus on this issue has been collected, the witness smart contract calls the signature generator smart contract to subsequently generate a signature for the target blockchain;\n", " - if the majority of the witnesses report the fact that there is no transaction in the blockchain or that the read height is exceeded, then the transaction is considered invalid, the witness proxy is penalized, and no further actions are taken;\n", " - if a witness does not form a quorum for the transaction for a long time (set by the number of confirmation blocks at the time the confirmation request was created), the witness is penalized, and the request can be reused;\n", "6. in the signature generator smart contract, a signature data block is formed, which will be signed by each signer;\n", "7. signers analyze the presence of new blocks of data for signature, perform the signature with their private key and publish the signed message in the signature generator smart contract;\n", "8. the signature generator smart contract validates the signer and the signature from the given signer, after reaching the specified set of signatures, it is possible to combine the parts into the final signature (TSS algorithm);\n", " - if it is possible to validate the signature when it is published in the signature generator smart contract, then upon successful completion of the verification, the signer that published this signature is rewarded with PBT;\n", " - if the signature validation cannot be carried out when it is published in the signature generator smart contract (an unsupported cryptographic primitive), then the user can initiate the signature process again, while the set of signers is different from the original one. In this case, the signers are rewarded (for signing) only in the WAVES token;\n", "9. the user makes a call to a peripheral smart contract to receive tokens in the target blockchain; if the user does not have a native token, then they can use a relayer to call the smart contract, which will make the call for the user, while retaining a fee.\n", "\n", "The user of the protocol can return the assets sent to another blockchain if the transaction did not have time to confirm the quorum of witnesses. To do this, the user must call the cancellation function in the witness smart contract. If the confirmation was not sent to the signature generator smart contract of the target blockchain, then after calling the cancellation, the confirmation of the user's transaction will be sent to the signature generator smart contract for the source blockchain for a refund in the source blockchain. In this case, the return fee will be deducted from the user. After the signature is generated, the user will be able to return funds from the smart contract in the source blockchain.\n", "\n" ] }, { "cell_type": "markdown", "id": "75861f12", "metadata": {}, "source": [ "#### 2.1.2 Cross-chain transfer for Waves\n", "\n", "When transferring tokens between Waves and another blockchain, the difference from the above scheme (2.1.1) is that the peripheral contracts in Waves can be directly integrated with the main transport contracts of the protocol.\n", "\n", "When transferring from the Waves network, the original transaction exists on the Waves blockchain, the peripheral contract can notify the witness smart contract about this directly. Its task is to make sure that there is a necessary delay (since block rollbacks are possible in any network), then call the signature generator smart contract for the target network and start the signature generation process.\n", "\n", "When transferred to the Waves network, after the signature is generated in the signature generator smart contract, the call can be immediately executed directly to the peripheral Vault smart contract for instant fulfillment of the obligations in the target Waves blockchain.\n", "\n", "The above changes help reduce user costs for cross-chain transactions and speed up the process of interaction." ] }, { "cell_type": "markdown", "id": "6b54a38a", "metadata": {}, "source": [ "### 2.2 Witness Proxy\n", "\n", "Witness proxy allows initiating a procedure for confirming a transaction by a group of witnesses, provided that the user does not have WAVES token to pay the fee for calling a smart contract in the transport network. According to the type of interaction with the blockchain, witness proxies are divided into active and passive.\n", "\n", "The passive witness proxy model responds to user events (REST API method call, websocket event). This model is of an auxiliary nature and is designed to solve the problem of delivering events to a witness smart contract at the first stages of protocol development. In the future, this model will be a spare (used in case of failures or lack of active witness proxies).\n", "\n", "The active witness proxy model implies a more advanced response model based on interaction with the blockchain platform. Depending on the interfaces used (REST API, WS etc.), witness proxy independently monitors transactions of peripheral contracts. So, for example, for EVM-compatible blockchains, it is possible to use the contract event subscription mechanism, which simplifies the work of the platform developers and reduces the computational costs of maintaining an active witness proxy.\n", "\n", "A necessary and sufficient condition for the functioning of a witness proxy is the locking of the minimum collateral on the witness smart contract. To calculate the minimum collateral amount, you can use the following formula:\n", "\n", "$$ b_{min} = 0.005 \\cdot N \\cdot 1000 $$\n", "\n", "where $b_{min}$ – is the minimum security amount in WAVES, $N$ – is the number of witnesses in the source blockchain.\n", "\n", "For example, if the number of witnesses is 3, then 15 WAVES are required to fulfill the obligations of a witness proxy (75 USD at a rate of 1 WAVES = 5 USD). This requirement is necessary for the formation of the system of punishment for providing invalid information about the existence of a transaction in the blockchain. Each call to witness smart contract to verify a new transaction requires a one-time locking of penalty amount in order to protect against witness DDoS attacks. If the witness proxy does not have enough assets, then further calls to verify a new transaction are rejected by the smart contract. The penalty for providing a non- existent transaction (not confirmed by the witness consensus) in such a case is 10 times the witness fee costs:\n", "\n", "$$ p =0.005 \\cdot N \\cdot 10 $$\n", "\n", "where $p$ – is the penalty for false information in WAVES, $N$ – is the number of witnesses in the source blockchain.\n", "\n", "To encourage the correct fulfillment of obligations, the witness is awarded with PBT only after successful confirmation by witness consensus. Witness smart contract encourages the proxy with the same amount of PBT as witness (covered in paragraph 3).\n", "\n", "Relatively low-requirement and high-performance rewards can create lively competition among witness proxies, resulting in a balance in event delivery rates. The high speed of the block monitoring and network reorganization can lead to unwanted witness proxy penalties, which react too quickly to events and create a dangerous protocol load. Slow witness proxies will not be able to receive a reward, but due to the peculiarities of the Waves network, they will not incur financial costs [18]. The resulting architecture allows creating a compromise solution that allows checking only secured claims.\n", "\n", "The user can do without the use of witness proxy services. To do this, the user must independently call the smart contract method to add a request to confirm the transaction in the desired network and provide the required security.\n", "\n", "The community can implement their own version of the witness proxy or use the public open-source version made by PepeTeam." ] }, { "cell_type": "markdown", "id": "9350fbd2", "metadata": {}, "source": [ "### 2.3 Witness\n", "\n", "For the protocol's efficient and secure operation, it is necessary to implement a system for confirming transactions in various blockchains. This task is solved with the help of witnesses, which directly perform necessary checks. A given level of security is ensured with the help of economic instruments, namely:\n", "\n", "1. in order to launch a new witness, you need to add its public address to the witness smart contract to participate in elections and lock a certain amount of WAVES token as collateral;\n", "2. to perform the operation of confirming the presence of a transaction, the witness smart contract allocates 720 blocks (the block number is recorded during the first call to the witness proxy). The penalty for non-compliance is\n", " \n", " $$p = 0.005 \\cdot N \\cdot 10$$\n", " \n", " where $p$ is the penalty for false information in WAVES, $N$ is the number of witnesses in the source blockchain;\n", "3. if their obligations are correctly fulfilled, each witness is rewarded with a project token in order to recoup the costs of calling the smart contract function and get additional profit;\n", "4. adding a new witness requires a security lock, calculated by the formula:\n", " \n", " $$ V = \\frac {S_w} {N \\cdot l}$$\n", " \n", " where $V$ is the minimum required security amount, $S_w$ is the total amount of operating assets in the system (expressed in USD); $N$ is the number of witnesses; $l$ is the confidence factor that is regulated by DAO (by default is 1).\n", "5. adding a new witness requires initialization and voting by current witnesses, deleting the current witness and unlocking its assets also requires initialization and voting by active witnesses.\n", "\n", "At the project's launch, witnesses will belong to the team, subsequently the list of active witnesses will be built up by large capital holders (defi projects, exchanges, products that use this protocol and are interested in correct operation).\n", "\n", "After the voting stage, new witnesses become active and receive a reward in PBT for confirming transactions. The amount of the received rewards depends on the cost of WAVES, PBT and protocol settings, and can be adjusted by the decision of the DAO (see 2.4).\n", "\n", "For the protocol to make a final decision on the fact of the presence (absence) of a transaction in the source network, the following conditions must be met:\n", "1. the number of witnesses who reported their decisions on this transaction must be higher than half of the total number of active witnesses in the current round;\n", "2. the sum of the locked balances of the witnesses who reported their decision must exceed 50% of the sum of the balances of all active witnesses in the current round;\n", " - if there is a witness whose locked balance is higher than the sum of the remaining active witnesses, then their virtual balance is normalized by the average value of the balance of the rest;\n", "3. if the decision on this transaction is not unanimous (a part of the witnesses confirmed the transaction, another part denied it), then the decision made by the group with the largest amount of locked balances is considered true.\n", "\n", "To minimize the possibility of incorrect operation of one or more witnesses, a collective responsibility mechanism is provided, in which the punishment for incorrect behavior affects all witnesses. The procedure is carried out in two stages:\n", "1. a smart contract can suspend the work of a witness smart contract by a DAO decision until the reason for the incorrect operation of witness is eliminated or the incorrect witness is excluded from the list of active ones;\n", "2. if it is impossible to eliminate the cause of incorrect operation or non-compliance with the requirements of the DAO, all the collateral will be transferred to the insurance fund, after which a new selection of active witnesses will be made.\n", "\n", "If, at the time of the epoch update, the locked balance of the witness is lower than the required locked collateral V, then the witness becomes inactive. If the number of those who fulfilled the requirements of witness is less than 3, the active participants are elected with the largest locked balance.\n", "\n", "As the protocol develops, it is assumed that to reduce the costs associated with the need for each witness to complete a transaction and spend WAVES at the same time, it will be possible to organize witnesses into a private P2P network for exchanging signed messages. This method will reduce the number of smart contract calls and reduce the cost of each witness in proportion to their total number. At the same time, signing witnesses receive the same reward, while the broadcasting (calling smart contract) witness receives an increased reward:\n", "\n", "$$ r = r_b + N \\cdot K \\cdot r_b $$\n", "\n", "where $r$ – is the reward for the broadcasting witness, $r_b$ – is the reward for the confirming witness, $N$ is the number of confirming witnesses, $K$ is the encouragement rate for aggregation while broadcasting (by default 0.5).\n" ] }, { "cell_type": "markdown", "id": "03428be4", "metadata": {}, "source": [ "### 2.4 Tax provider\n", "\n", "The initial implementation of the tax provider is a smart contract with fixed protocol fees. As liquidity pools are formed (PBT/WAVES and synthetic pools of transferable tokens to stablecoins, such as ETH/USDT), the business logic of the contract will replace the static variables with a market formula (see calculation example in p.3). The selected pricing mechanism for the PBT will allow avoiding speculation in the cost of the token by the participants of the protocol, since the actual cost of operations is tied to the transport costs of the protocol, and accordingly depends on the cost of the WAVES token. In the future, it will be possible to implement sponsorship [18] for the PBT, which will simplify operations for users of the system." ] }, { "cell_type": "markdown", "id": "29978ea7", "metadata": {}, "source": [ "### 2.5 Signer\n", "\n", "The central functionality of the protocol is signature generation for the target blockchain. To ensure the required level of security, the following conditions must be met:\n", "\n", "1. not a single subject of the protocol (human, software module, singer, external participant in the system) should be able to compromise the protocol by generating a fake signature;\n", "2. there should be no centralized repository of complete key information;\n", "3. full key information should never be owned by a single server, device or user.\n", "\n", "The only way to support the above conditions is to split one main signing key into several parts. Each part must be kept separately by different subjects of the protocol. When performing operations, participants must interact without disclosing their secret keys.\n", "\n", "This idea is implemented by TSS algorithms (Threshold Signature Scheme), which determine the total and minimum required number of signers, while no key information is disclosed. Such solutions have been used in practice for a long time and have proven to be one of the most reliable (Binance Smart Chain TSS). To achieve a high degree of decentralization, it is necessary to be able to add new participants in the formation of a signature, while following certain conditions:\n", "\n", "1. in order to launch a new signer, you need to add its public address to the signature generator smart contract to participate in elections and lock a certain amount of tokens as collateral;\n", "2. to carry out the operation of signing the signature generator smart contract allocates 120 blocks (the block number is recorded during the first time when the smart contract is accessed). The penalty for non-compliance is\n", " \n", " $$ p = 0.005 \\cdot N \\cdot 10 $$\n", " \n", " where $p$ – is the penalty for late fulfillment of obligations (distributed signature) in WAVES, $N$ – is the number of signers;\n", "3. if the obligations are correctly fulfilled, each signer is rewarded with a project token in order to recoup the costs of calling the smart contract function and get additional profit;\n", "4. adding a new signer requires locking the collateral determined by the formula:\n", " \n", " $$ V = \\frac {S_w} {N \\cdot l}$$\n", " \n", " where $V$ is the minimum required collateral to be locked, $S_w$ is the total amount of operating assets in the system (expressed in USD); $N$ is the number of signers; $l$ is the confidence factor that is regulated by DAO (by default is 1);\n", "5. adding a new signer requires initialization and voting by current signers, deleting the current signer and unlocking its funds also requires initialization and voting by active signers;\n", "6. signer addition and deletion occur with a delay of one epoch.\n", "\n", "An active signer cannot refund locked funds if the number of active members is less than the minimum (default minimum number of signers is 3, but can be increased by the community). The mechanism ensures the security of the protocol in a historical perspective.\n", "\n", "To reduce transport costs of the signer, the exchange mechanism can be improved by creating a private p2p network (similar to the witness p2p network in paragraph 2.3, with appropriate reward models).\n", "\n", "After the voting stage, new signers become active and receive a reward in PBT for confirming transactions. The amount of the received rewards depends on the cost of WAVES, PBT and protocol settings, and can be adjusted by the decision of the DAO (see 2.4).\n", "The minimum time that indicates the duration of an epoch is determined by the DAO and cannot be less than 1440 blocks. When the protocol starts, the epoch length will be 10080 blocks. Changing the epoch (regenerating signers keys, adding or deleting signer) occurs only after a preliminary request.\n", "\n", "Normally, the regeneration of signers keys occurs with the fact that the final public signing key remains unchanged, only the number and parts of the key change. However, signers may decide by majority vote that the signature public key should be regenerated to improve security and mitigate the risk of having “old parts of the key” (toxic waste) for previously active signers. Such a replacement consists of generating and signing a message that instructs all peripheral smart contracts to verify signatures against a newly generated public key. To change the public key in the peripheral smart contract, it is necessary to sign a new public key using the current private key (verification with the current public key must be successful)." ] }, { "cell_type": "markdown", "id": "a9e95aa1", "metadata": {}, "source": [ "#### 2.5.1 Threshold signature scheme for EdDSA cryptography with Curve25519\n", "\n", "All scalar values ​below are assumed to be in a subset of the final field. Any t of n signers can generate a signature. Let's suppose that a signature is generated by the participants $P_i$, $i=1..t$\n", "\n", "1. Participant $P_i$ generates an integer $ r_i = SHA_{512}(prefix || s_i || M || rand(64)) \\quad mod \\quad q$\n", "2. Participant $P_i$ calculates and publishes a point to others $R_i = r_i \\cdot B$\n", "3. After every $P_i$ publishes $R_i$, the point is calculated $ R = \\sum_{i=1}^{t} R_i$\n", "4. Calculate $k = SHA_{512}(R || A || M ) \\quad mod \\quad q$.\n", "5. The polynomial Lagrange coefficients at zero are calculated:\n", "\n", "$$ l_i = \\prod_{j=1, j \\neq i}^{t} \\frac{j}{j-i}$$\n", "\n", "6. Participant $P_i$ calculates and publishes $S_i = r_i + k \\cdot l_i \\cdot s_i$\n", "7. Final $S = \\sum_{i=1}^{t} S_i$ value is calculated.\n", "8. Addition (concatenation) of values (R, S) is the resulting signature.\n", "\n", "Signature verification is performed by checking:\n", "\n", "$$ 8 \\cdot S \\cdot B = 8 \\cdot R + 8 \\cdot k \\cdot A$$" ] }, { "cell_type": "markdown", "id": "9520b527", "metadata": {}, "source": [ "### 2.6 Relayer\n", "\n", "In typical scenarios for the execution of cross-chain transfers, gasless operations (operations that do not require a native token to pay the fee when receiving user assets at the moment when the transfer scenario is completed, see 2.1.1) play an important role. Gasless operations simplify the initial login procedure, since in general, when transferring assets to a network where the user account does not have native tokens, it is not possible to complete a transaction to receive tokens (claim operation).\n", "\n", "When depositing assets, the user can analyze the relayer fees (fees are fixed in the blockchain or provided by the REST API) and select the appropriate one by specifying the maximum amount of the fee when depositing assets to a peripheral smart contract in the transferred token.\n", "\n", "The main task of the relayer is to monitor cross-chain transfers, which contain a fee for the relayer. In the case when the fee costs are as expected, the relayer can perform the claim operation instead of the user. In this case, the fee is transferred to the relayer, and the remaining assets are transferred to the user's account.\n", "\n", "The user can perform the operation by themselves instead of the relayer. This feature allows the user to safely (there is always the opportunity to receive assets on their own) carry out gasless interaction, forming a competitive market for various relayers.\n", "\n", "The implemented mechanism will make the relayer find a balance between maximum economic efficiency (combining calls into a sequence reduces the fee in the case of EVM, using rollup etc.) and high speed (the faster and more expensive the claim is executed, the higher is the probability of receiving a reward).\n" ] }, { "cell_type": "markdown", "id": "0b7343b6", "metadata": {}, "source": [ "### 2.7 Wrapped tokens\n", "\n", "![wrapped tokens](wrapped.png)\n", "\n", "In an economically simplified expression, wrapped tokens represent a time-limited obligation to return assets. The functionality includes the following interaction options:\n", "1. deposit is the operation of locking tokens by the user in the source blockchain and minting wrapped tokens in the target blockchain;\n", "2. withdraw is the operation is the reverse of the deposit, namely the burning of wrapped tokens and unlocking the user's assets.\n", "\n", "Wrapped tokens allow the protocol to keep user assets transparent and secure. In addition to a clear audit model (the balance of blocked assets should always be equal to the balance of the issued wrapped tokens, except for ongoing transfers), the mechanism separates the liquidity of directions and does not need to be secured. To avoid liquidity fragmentation, wrapped tokens are combined with platform-native tokens into liquidity pools.\n" ] }, { "cell_type": "markdown", "id": "e77ec3d2", "metadata": {}, "source": [ "### 2.8 Liquidity providers\n", "\n", "An effective way to deal with liquidity fragmentation is to form cross liquidity AMM pools. Such pools combine the native liquidity of the platform with wrapped tokens, forming a single protocol.\n", "\n", "![lp](lp.png)\n", "\n", "The mechanism allows the project's users to conveniently and safely exchange required liquidity between different networks with an acceptable fee (it is planned to use stable swap pools, for example, curve.fi). At the same time, the high interest of liquidity providers is due not only to income from exchange fees (for more details, see CPMM [20], StableSwap [21]), but also due to additional motivation in the form of a reward for providing liquidity to the pools (decided by a DAO). As an example, consider the process of transferring a cross-liquid token from the ETH network to BSC:\n", "1. the user exchanges USDC token in the ETH network to pUSD, a cross-liquid protocol token using a stable swap pool;\n", "2. then, using the cross-chain protocol they transfer the pUSD token to the BSC network;\n", "3. then they perform the exchange of the pUSD token to the required token (USDT, USDC, DAI etc).\n", "\n", "From the point of view of the previously presented protocol, such a mechanism does not differ from a typical transfer of a token between networks and is an add-on implemented by a set of smart contracts of synthetic pool tokens. The implementation of an auxiliary protocol that solves the problem of liquidity balancing (by means of the arbitrage policy of the liquidity pools and the economic interest of providers) can be carried out by the active community of the project.\n" ] }, { "cell_type": "markdown", "id": "34f0288c", "metadata": {}, "source": [ "## 3 Tokenomics\n", "\n", "Most DeFi projects – either at launch or at a later stage - issue their own token, which is designed to stimulate market participants to use the project more actively. A project's token can be used to reward liquidity providers, yield farmers, DAO participants, protocol users, (early) investors, the team etc. As a rule, the token's total emission and final distribution among the participants are predetermined. The project team's task is to increase the value of the token, which allows token holders to earn on the difference in rates (for example, curve.fi tokenomics [22]). Such an approach leads to a risk that the project will be abandoned by the developers, and investors who bought tokens earlier will lose their investments. Often, such risks are mitigated by a delayed unlocking of tokens allocated to the team or early investors (vesting). However, it should be understood that an unbalanced emission management policy and a significant number of issued tokens can create conditions for the collapse of the token's value and loss of funds by investors who supported the project at a later stage of its development. This scenario would lead to a negative attitude towards the project and, in the worst case, to the termination of its work.\n", "\n", "Our protocol stipulates the creation of PBT (Pepe Bridge Token). The purpose of the project development is not related to the profit of early investors and the team due to the influx of new investments (speculation on exchange rate differences). The task of the token is to simplify the functioning of the protocol's economic aspect by tokenizing the participants' obligations.\n", "\n", "The main purpose of PBT is to pack the costs of witnesses and signers (can be thought of as a bond or a deferred obligation). During the operation of the protocol, witnesses and signers will receive rewards in PBT. A portion of fees for the transfer of user assets will be used to buy back PBT and subsequently burn them. A balance between the number of the issued and redeemed tokens is regulated and can be changed by the community.\n", "\n", "There is no initial emission. The token will be issued gradually after the project's launch and only to the protocol's participants (witnesses, signers). Decisions on additional issuance of tokens for the needs of investors or marketing will be made through the DAO.\n", "\n", "The maximum emission of the token is not fixed and is regulated by community decisions aimed at controlling the intensity of token production (rewards for the fulfillments of witnesses and signers obligations) and the intensity of token burning (the size of the pledged fee of the transport level, the frequency of clearing etc.).\n", "\n", "The protocol's initial settings will be aimed at increasing the intensity of burning tokens, which will decrease the total emission of the token, however, the opposite situation is also possible, in which the rate of production of new tokens will exceed the burning rate. Such a situation can be useful for increasing liquidity in order to attract new users, accumulating liquidity for placement on other trading spots and marketing activities. Such decisions will be made by community members interested in improving the operation of the protocol.\n", "\n", "During the protocol operation, the system participants (witnesses and signers) call smart contracts and make entries, while spending WAVES. The amount of spent WAVES is expressed by the formula:\n", "\n", "$$ f = f_i \\cdot (N+K+1) $$\n", "\n", "where $f$ is the protocol fees in WAVES, $f_i = 0.005$ – smart contract function call constant in the Waves network, $N$ – is the number of witnesses in the source blockchain, $K$ – is the number of signers in the target blockchain.\n", "\n", "The amount of issued PBT for one transfer is divided between the participants of the protocol and the participants of the DAO:\n", "\n", "$$ q_{pbt} = k_{tx} \\cdot f \\cdot p_{pbtwaves}$$\n", "\n", "where $q_{pbt}$ is the total amount of issued PBT for 1 transfer, $k_{tx}$ is the cost compensation ratio (at the start of the project $k_{tx}=2$), $f$ is the price of PBT in WAVES.\n", "\n", "$$ q_{pbtgov} = g_{gov} \\cdot q_{pbtsys} $$\n", "\n", "$$ q_{pbtsys} = (1 - k_{gov}) \\cdot q_{pbt} $$\n", "\n", "where $q_{pbtgov}$ is the amount of PBT for DAO participants, $q_{pbtsys}$ is the amount of PBT for the system participants (witnesses and signers), $q_{gov} \\in [0;1]$ – is the distribution ratio of PBT among the project participants.\n", "\n", "The transport fee withheld from the user is expressed by the following formula:\n", "\n", "$$ f_u = q_{pbt} \\cdot p_{pbt} + a \\cdot k_p $$\n", "\n", "where $f_u$ is the transport fee withheld for transfer, $a$ is the transferred amount of the user’s assets, $k_p$ is the protocol fee rate (determined by voting with the help of DAO at the start of the project $k_p$ = 0.0001), $p_{pbt}$ is the price of the transferred token in PBT.\n", "\n", "An example of calculating the fee for a user is shown below. It is assumed that the user transfers 100,000 USDT from the ETH network to the Waves network, the number of witnesses for the ETH network is 3, the number of signers for the Waves network is 3. For this example, we will take the following constant values: $N=3,K=3,k_{tx}=2,p_{wavesusdt}=10,p_{wavespbt}=4,p_{pbtusdt}=2.5$\n", "\n", "$$ f_{tx} = 0.005 \\cdot (3+3+1) = 0.035 $$\n", "\n", "$$ q_{pbt} = 2 \\cdot 0.035 \\cdot 4 = 0.28 $$\n", "\n", "$$ q_{pbtgov} = 0.28 \\cdot 0.3 = 0.084 $$\n", "\n", "$$ q_{pbtsys} = (1-0.3) \\cdot 0.28 = 0.196 $$\n", "\n", "$$ f_u = 0.28 \\cdot 2.5 + 100000 \\cdot 0.0001 = 10.7 $$\n", "\n", "The fee for the user is 10.7 USDT (0.0106% of the transferred amount), the transport fee is 0.7 USDT, the protocol fee is 10 USDT. Under these market conditions, the minimum amount of USDT transferred must exceed 0.7 USDT." ] }, { "cell_type": "markdown", "id": "e19168fb", "metadata": {}, "source": [ "## 4 Governance\n", "\n", "![Governance](governance.png)\n", "\n", "When building DeFi applications, special attention should be paid to their management. A complex decentralized system, as a rule, incorporates many adjustable parameters (for example, the amount of fees, constants in mathematical formulas for calculating system parameters, allowed lists of addresses etc). This requires the presence of some “administrator” who reserves the right to change these values. In addition, there is also a number of business processes that should be launched only if certain conditions are met (including after appropriate off-chain checks).\n", "\n", "To perform the above functions without compromising decentralization, collective governance is applied based on DAO, which is a set of smart contracts designed for voting for changes in the system parameters. The advantages of this approach are transparency (each vote is a record in a blockchain or other distributed ledger, which makes it possible to exclude shadow manipulations with votes), a high degree of decentralization (anyone can become a participant in the voting process and governance in general), autonomy (the DAO mechanism is able to function independently on-chain according to the logic embedded in the smart contract). Currently many large DeFi projects are integrating DAO (curve.fi, uniswap, sushiswap, 1inch, AragonOS etc.).\n", "\n", "\n", "The project involves the use of DAO mechanisms implemented on the Waves blockchain as a set of smart contracts. At the time of the launch of the product, it is assumed that in order to safely develop the protocol, the management will be delegated to our team, however, the laid down mechanisms will significantly increase the degree of decentralization in the future by attracting new participants to the ready-made infrastructure designed for community decision-making on the further development of the project.\n", "\n", "DAO community will be able to make decisions on the following issues:\n", "1. support of new blockchains and networks (requires preliminary infrastructure preparation, launch of new witness instances, witness helper, deploy smart contracts etc.);\n", "2. support of new tokens (including Wrapped tokens) in blockchains that support multiple tokens;\n", "3. regulation of transport fees for performing interaction (liquidity transfer in particular) between blockchains;\n", "4. regulation of fees during interaction of liquidity providers, managing witness instances, DAO participants;\n", "5. managing the intensity of issuance and burning PBT covered by the accumulated protocol fees.\n", "\n", "To participate in the DAO, the user needs to lock any amount of PBT on the smart contract. The value of their vote directly depends on the locking time and the amount of the locked PBT.\n", "\n", "$$ V = b \\cdot (\\frac{t_{max}}{k \\cdot (t_{max} - t) + t} + \\frac{t-t_{max}}{k \\cdot t_{max}}) $$\n", "\n", "when $ (t-t_0) \\leq t_{max} $\n", "\n", "$$ V = b $$\n", "\n", "when $ (t-t_0) > t_{max} $\n", "\n", "where $V$ is the user’s vote value, $b$ is the amount of locked PBT, $k=6$ is the descent rate, $t_{max}$ is the max PBT locking duration, $t$ is the PBT locking duration.\n", "\n", "The $V$ amount decreases linearly over time and tends to zero upon reaching the time of unlocking PBT by the following formula:\n", "\n", "$$V(t) = V(t_0) - \\frac{t-t_0}{2} \\cdot V(t_0)$$\n", "\n", "where $V(t)$ is the users’ vote value at the moment of time $t$, $V(t_0)$ is the user’s vote value at start of the locking period $t$\n", "\n", "The locking time can be extended, the number of locked tokens can also be subsequently increased.\n", "\n", "40% of the issued PBT will be used to reward DAO participants, which will be distributed in proportion to the number of vPBTs. The remaining 60% will be used to reward the work of witnesses and signers.\n", "\n", "The distribution of rewards to DAO participants will be made according to the following formula:\n", "\n", "$$ K_u = \\frac{K_{t} \\cdot V}{S_{vpbt}} $$\n", "\n", "where $K_u$ is the user’s reward, $K_t$ is the total reward amount for DAO participants, $V$ is the amount of user’s votes, $S_{vpbt}$ is the total amount of the votes.\n", "\n", "Thus, every decision about the project must be made through governance with the help of DAO. Each transaction that changes the parameters of the system can be initiated by any participant, but it must be approved by voting in order to apply it. When the vote on the network has passed, anyone can apply the transaction, as a result the accepted changes will take effect immediately.\n" ] }, { "cell_type": "markdown", "id": "2cbbdf81", "metadata": {}, "source": [ "## 5 References\n", "\n", "1. [Decentralized finance (DeFi)](https://ethereum.org/en/defi)\n", "2. [Ethereum. Scaling](https://ethereum.org/en/developers/docs/scaling)\n", "3. [Defipulse](https://www.defipulse.com)\n", "4. [DeFi Token Watchlist](https://cryptorank.io/category/defi)\n", "5. [Binance academy. What Is a Blockchain Consensus Algorithm](https://academy.binance.com/en/articles/what-is-a-blockchain-consensus-algorithm)\n", "6. [Cryptographic primitives in blockchains](https://www.researchgate.net/publication/329122257_Cryptographic_primitives_in_blockchains)\n", "7. [Horizen academy. UTXO vs account model](https://academy.horizen.io/technology/expert/utxo-vs-account-model)\n", "8. [Zero-knowledge proof](https://en.wikipedia.org/wiki/Zero-knowledge_proof)\n", "9. [Ethereum. ZK-Rollups](https://ethereum.org/en/developers/docs/scaling/zk-rollups/)\n", "10. [Binance academy. zk-SNARKs and zk-STARKs Explained](https://academy.binance.com/en/articles/zk-snarks-and-zk-starks-explained)\n", "11. [Ethereum virtual machine (EVM)](https://ethereum.org/en/developers/docs/evm)\n", "12. [Waves. About Ride](https://docs.waves.tech/en/ride)\n", "13. [Multichain documentation](https://docs.multichain.org)\n", "14. [Connext documentation](https://docs.connext.network)\n", "15. [Allbridge documentation](https://docs.allbridge.io)\n", "16. [Waves documentation](https://docs.waves.tech/en)\n", "17. [On the Size of Pairing-based Non-interactive Arguments](https://eprint.iacr.org/2016/260.pdf)\n", "18. [Waves documentation. Transactions](https://docs.waves.tech/en/blockchain/transaction)\n", "19. [Secure Distributed Key Generation for Discrete-Log Based Cryptosystems](https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_21.pdf)\n", "20. [The homogeneous properties of automated market makers](https://arxiv.org/pdf/2105.02782.pdf)\n", "21. [Curve finance. StableSwap - efficient mechanism for Stablecoin liquidity](https://curve.fi/files/stableswap-paper.pdf)\n", "22. [Curve finance. Understanding Tokenomics](https://resources.curve.fi/base-features/understanding-tokenomics)\n" ] }, { "cell_type": "markdown", "id": "0ade462f", "metadata": {}, "source": [ "## 6 Contacts\n", "\n", "- [Telegram](https://t.me/pepe_team)\n", "- [Twitter](https://twitter.com/cryptopepeteam)\n", "- [Medium](https://crypto-pepe-team.medium.com/)\n", "- [YouTube](https://www.youtube.com/@pepe-team)\n", "- [GitHub](https://github.com/crypto-pepe)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.13 64-bit", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" }, "vscode": { "interpreter": { "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" } } }, "nbformat": 4, "nbformat_minor": 5 }