# Adonis DeFi ### Whitepaper v0.7 ###### Author: Jad A. Jabbour @ Cryptoware ME ##### A decentralized non-governmental solution for managing hyperinflation & Lira devaluation in Lebanon. As well as providing a non-custodial decentralized exchange for a FIAT-tethered cryptocurrency: ALEF, it also provides avenues of profit for ALEF token holders through automated arbitrage; Which in turn -in theory- should help in stabilizing the Lebanese Lira. <br /> ## Introduction September 2019 -after several regional changes in the political scene and years of mismanagement of economy & state- Lebanon sunk into a vortex of economic and political instability that expanded ten-fold after the August 4, 2020 Beirut explosion. Due to socio-political reasons that are beyond this paper's scope, the government and the Central Bank "BDL" are yet to implement a proper solution. This whitepaper outlines the creation of a token pegged to the 1000 LBP `ALEF`, A decentralized exchange with a DEX-native reward token `AdonisDEX` & `ADNX`, an Arbitrage pool for automatic arbitrage using staked `ALEF` funds and rewarding `ADNS` tokens redeemable for Etherum's `ETH`. In addition to that, a governance contract, `AdonisGovernance`, with a native token `ADNG` will be implemented to manage both `AdonisDEX` & `AdonisArbitrage`. The interweaving of the above mentioned tokens and contracts in the manner discussed in this paper could provide a solution for problems on multiple levels of the economic crisis, as well as -through automatic arbitrage and exploiting market inefficiencies- stabilize the value of the `Lebanese Lira` by slowly moving the peg away from the `US Dollar`. Furthermore, this might be an opportunity to create -eventually- a crypto-pegged FIAT currency which, even though seems like an alien concept, would behave as a regular sovereign currency but supported by the individuals holding `ALEF` and `ADN-` tokens on the network. Leveraging the boom in miners in Lebanon and making it more difficult for bad actors to manipulate the local currency in black markets while distributing profits to be gained from trading the currency to liquidity providers and `ADN-` token holders. This paper builds on established concepts in the crypto-space, DeFi and blockchain technology; Which is why it will not be very lengthy since other DeFi open-source projects will be used as a basis for the smart contracts mentioned. Mainly, the contracts mentioned above will adopt concepts and approaches implemented in `UniswapV1/V2` as well as pulling inspiration from other DeFi projects for the different aspects of this solution. ## Alef Token ###### by AlefTokenomics SAL The `AlefToken` is an `ERC20` token pegged to `1000 LBP`. The company `Alef Tokenomics SAL` will own the contract. It will be responsible for maintaining a reserve of `Libanese Lira` equivalent to the `AlefTokens` in circulation; keeping `30%` of funds in cash and `70%` in local bank accounts. The company therefore would be able to provide `LBP` cash up to a total of `30%` of the amount of tokens held by an individual and the rest in bank transfers when an individual decides to redeem their tokens for `LBP`. These tokens are then burned by the company. The burning and minting of new tokens will be publicly declared, per transaction via the company's chosen channels, or can be easily discoverable using any chain analysis tool. The company will also mint new tokens for users that deposit their `LBP` either in cash or via bank transfer, while maintaining the `30%/70%` ratio of cash-on-hand/bank account(s) total value. The company will also publish monthly reports on the reserves it has and the number of tokens in circulation guaranteeing to the individuals holding `ALEF` that the tokens in circulation represent actual liras. Ideally, after some time, the ownership of the contract governing the `AlefToken` would be revoked by the company as `AlefToken` becomes decentralized -a more detailed plan for that would be required at that stage- while maintaining a peg to the `LBP`. It would not be the first stablecoin to be completely decentralized and stabilized algorithmically but those have not been successful yet and we currently do not have the privilege to break new grounds. Later stages of adoption would see POS systems integrating a payment module to accommodate for direct wallet payments therefore allowing people to directly use their `ALEF` tokens. A deeper dive into faster transactions would come when such a solution is to be implemented given that a certain critical mass of adoption is required for this to become viable. The only reliably fast payment systems currently are highly centralized. With that being said, `Alef Tokenomics` will implement a decentralized version of deferred payments to facilitate the process. Of course, it might not need to implement this at all, once Ethereum moves to Proof of Stake; with a lot of local crypto-miners running Ethereum nodes, theoretically that would make transactions much faster. #### Alef PayNet But at the risk of being redundant, and not wanting to wait till Etherum2.0, `Alef Tokenomics` will implement an EIP712-based mechanism and smart contract to facilitate defered and signed transactions with minimal payer gas fees (if any!). This solution would also require the development of a MetaMask-like wallet that specifically caters to this service and other `Alef Tokenomics` products; the end-goal being to allow fluid transfers of `ALEF` tokens between holders, businesses and other `DAO`s. ## Adonis DEX ###### Decentralized Autonomous Organization (DAO) &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; منظمة مستقلة تلقائية لامركزية (م م ت ل) `AdonisDEX` is not trying to reinvent DEXs but it is trying to be a specialized DEX. `AdonisDEX` contract, unlike `AlefToken`, will not have an owner and will be completely decentralized -governed by `AdonisGovernance`, discussed later. Using the `UniswapV1/V2` protocol as inspiration, `AdonisDEX` will allow `ALEF` holders to provide `ETH/ALEF` liquidity to an automated liquidity pool using the `AMM` -automated market maker-approach. Utilizing the 'constant product' to insure liquidity is always balanced as such -where `K` is always constant: `ETH_provided * ALEF_provided = K` Adding liquidity requires depositing an equivalent value of `ETH` and `ALEF` tokens into the exchange contract. By doing so, liquidity providers receive `ADNX` tokens that represent their share in the liquidity pool. These tokens can then be redeemed for a percentage of the liquidity pool or used in voting for protocol change propositions on `AdonisGovernance` and earning `ADNG`. Initial supply of `ADNX` is calculated as such: `ADNX_initial = sqrt(K)` ### Liquidity Provision The first liquidity provider to join the pool sets the initial exchange rate by depositing what they believe to be an equivalent value of `ETH` and `ALEF` tokens. If this ratio is off, arbitrage traders will bring the prices to equilibrium at the expense of the initial liquidity provider. `AdonisArbitrage` -discussed later- would automate that process with staked funds therefore distributing the profits to be made from arbitrage to `ALEF` stakers. The pool has a `MINIMUM_LIQUIDITY` and a `MAXIMUM_LIQUIDITY` parameters, these are meant to stabilize the pool but are not set in stone. These parameters will be adjustable through governance propositions on `AdonisGovernance`. All future liquidity providers deposit `ETH` and `ALEF` using the exchange rate at the moment of their deposit. If the exchange rate is "bad" there is a profitable arbitrage opportunity that will correct the price. In this case the Arbitrage BOT is triggered, and using the funds in the `AdonisArbitrage` contract, it will initiate a trade for `ETH` at a favorable rate. Bringing the markets to balance and scoring profits for stakers. The number of `ADNX` tokens minted is determined by the amount of `ETH` deposited. It can be calculated using the equation: `ADNX_minted = ADNX_total * (ETH_deposited / ETH_pool)` Calculating the equivalent value in `ALEF` tokens to deposit is done using this equation: `ALEF_required = ALEF_pool * (ETH_deposited / ETH_pool)` If the liquidity provider at any point chooses to pull their liquidity, they would receive a proportion of the pair that is equal to the proportion of `ADNX` tokens they hold to the total supply of `ADNX`. This is calculated using the equations: `ETH_withdrawn = ETH_pool * (ADNX_burned / ADNX_total)` `ALEF_withdrawn = ALEF_pool * (ADNX_burned / ADNX_total)` With every swap, a fee of `0.4%` will be deducted and added back to the pool making the system profitable for liquidity providers. This parameter, like many others discussed later, can be adjusted via governance propositions on which `ADN-` holders will be able to vote. ### Swap Exchange The exchange rate between `ETH` and `ALEF` is based on the relative sizes of their liquidity pools within the contract. This is done by maintaining the relationship -where 'K' is invariant: `ETH_pool * ALFT_pool = K` This invariant is held constant during trades and only changes when liquidity is added or removed from the market. When a swap is initiated to purchase `ALEF`, the `ETH` coins sent to the exchange contract are added to the pool; To maintain the relationship mentioned above, `ALEF_pool` is decreased by a proportional amount. The amount by which `ALEF_pool` is decreased is the amount of tokens purchased at the end of the transaction. This change in reserve ratio shifts the `ETH` to `ALEF` exchange rate, incentivizing trades in the opposite direction. #### > Example Let's consider for example's sake that the initial liquidity provided in the pool is `10 ETH` and `1000 ALEF`. In that case the invariant `K` is directly calculated as `10,000`. Given that this is the initial liquidity provided the provider receives `sqrt(K)` as `ADNX` token, in this case the initial liquidity provider will receive `100 ADNX` tokens. This will also set the price of ALFT in that pool to `0.01 ETH` A trade of `0.2 ETH` against the pool to exchange for `ALEF` is mapped out as such: - Buyer sends: `0.2 ETH` - Fee: `0.2 ETH * (0.45 / 100) = 0.0009 ETH` - ETH_pool = `10 + (0.2 - 0.0009) = 10.1991 ETH` - ALEF_pool = `10000/10.1991 = 980.48 ALEF` - Buyer receives: `1000 - 980.48 = 19.52 ALEF` The fee is now added back into the liquidity pool, which acts as a payout to liquidity providers that is collected when liquidity is removed from the market. Since the fee is added after price calculation, the invariant `K` increases slightly with every trade, making the system profitable for liquidity providers. - ETH_pool: `10.1991 + 0.0009 = 10.2 ETH` - ALEF_pool = `980.48 ALEF` - New invariant K = `10.2 * 980.48 = 10,000.9` In this case the buyer received a rate of `97.6 ETH/ALEF` or `0.00976 ALEF/ETH`. However the price has shifted. If another buyer makes a trade in the same direction, they will get a slightly worse rate of `ETH/ALEF`. However, if a buyer makes a trade in the opposite direction they will get a slightly better `ETH/ALEF` rate. Opening the doors for arbitrage opportunities with the FIAT `LBP` market, inadvertently stabilizing the `LBP/USD` rate. Now what if the provider wishes to pull their liquidity from the pool? Using the equations mentioned in the Liquidity Provision section above, considering there are a total of `354 ADNX` tokens minted, and that the liquidity provider decides to redeem `57 ADNX` tokens: `ETH_withdrawn: 10.2 * (57 / 354) = 1.64 ETH` `ALFT_withdrawn: 980.48 * (57 / 354) = 157.87 ALFT` `ADNX_total: 354 - 57 = 297 ADNX` The liquidity provider therefore burns `57 ADNX` tokens and receives `1.64 ETH` & `157.87 ALFT` also reducing the total ADNX in circulation to `297 ADNX` ## Adonis Arbitrage ###### Decentralized Autonomous Organization (DAO) &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; منظمة مستقلة تلقائية لامركزية (م م ت ل) AdonisArbitrage is a special smart contract that acts as a decentralized fund for arbitrage trades governed by `AdonisGovernance` and an off-chain arbitrage bot. The bot, although initially is managed by `AlefTokenomics` can be changed if the community wishes so by creating an appropriate proposition on `AdonisGovernance` and voting for it. It will allow users to participate in the fund by sending their `ALEF` tokens to the contract and benefit automatically from arbitrage opportunities that arise from market imbalances. Stakers can send their `ALEF` tokens to `AdonisArbitrage` and receive the `ADNS` tokens in return. These tokens entitle the user to rewards in `ETH` after successful arbitrage trades and voting power on specific propositions. `AlefTokenomics'` off-chain arbitrage bot receives a daily rate for the `LBP` against the `USD` in the local market, it then calculates the rate for the `ALEF` against the `USD` via `ETH`. If a market imbalance exists where `(ALEF/USD)*1000` on `AdonisDEX` is lower than `LBP/USD` then an arbitrage opportunity exists and is triggered by the bot. `ADNS` tokens are minted for individuals that deposit their `ALEF` tokens in the arbitrage contract at a 1:1 ratio. When the bot trades, the purchased `ETH` will be deposited in the contract and locked in for some time -mainly, until the amount is proportionally relevant to the amount of eligible `ADNS` tokens. Once released, `ADNS` holder's eligible `ADNS` token can be burned and a transfer of `ETH` will initiated to their wallet. Instead of directly selling at market pool price, an individual may then deposit their `ALEF` for a future purchase of `ETH` at a slightly better price than the actual market, pocketing the profit to be made from arbitrage; As opposed to the traditional market where specific actors arbitrate securities and currencies while those holding these securities and currencies reap no benefit. In this model, without middlemen and monetary doctrine peddlers, the profit to be made from arbitrage is distributed to the people, creating an automatic hedge against currency inflation -in theory, when the network reaches critical mass. Another parameter that can be adjusted via propositions on `AdonisGovernance` here is the threshold at which the bot is triggered to perform a profitable arbitrage trade. #### > Example Let's consider for example's sake that an initial staker deposited `20,000 ALEF` tokens into the arbitrage contract. They would then receive `20,000 ADNS` tokens in return. These `ADNS` tokens are not yet eligible for rewards. Another staker comes along and deposits `60,000 ALEF` and receives the same amount deposited in `ADNS` tokens. This also brings the total of deposits to `80,000 ALEF`. Let's also consider that `1 ETH = 1000 USD` and that `10 ALEF = 1 USD`. Whenever a discrepancy in the market arises, which is measured by the difference in price of `ALEF` in `ETH` ie: `1 ETH = 9,254 ALEF` in the `AdonisDEX` pool and the price `1 USD = 10,000 LBP = 10 ALEF` in the offline market, the bot detects it and initiates a trade of `ALEF` to `ETH`. With enough liquidity, this contract can -with one trade- bring the market to efficiency while scoring profits for those holding `ADNS` tokens. Using the `AMM` approach as a blueprint, the bot executes the trade and flags tokens that have become eligible. Let's say the bot sold `46,750 ALFT` and received `5.05 ETH` at a very favorable rate. The distribution is calculated as follows: Staker A's eligible tokens: `46,750 * (20,000 / 80,000) = 11,687.5 ADNS` Staker A's non-eligible tokens: `20,000 - 11,687.5 = 8,312.5 ADNS` Staker B's eligible tokens: `46,750 * (60,000 / 80,000) = 35,062.5 ADNS` Staker B's non-eligible tokens: `60,000 - 35,062.5 = 24,937.5 ADNS` Total eligible tokens: `46,750 ADNS` Staker A's reward: `5.05 * (11,687.5 / 46,750) = 1.2625 ETH` Staker B's reward: `5.05 * (35,062.5 / 46,750) = 3.7875 ETH` Burned eligible tokens: `46,750 ADNS` Total eligible tokens: `0 ADNS` Total remaining `ADNS` tokens: `33,250 ADNS` ## Adonis Governance ###### Decentralized Autonomous Organization (DAO) &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; منظمة مستقلة تلقائية لامركزية (م م ت ل) `AdonisGovernance` is a governance smart contract that manages the `AdonisDEX`, `AdonisArbitrage` and their relative tokens `ADNX` & `ADNS`. Governance is an integral part of the Adonis-DeFi protocol, so much so that we've decided to delay the project for a few extra weeks and implement it before our alpha-testing phase. It will guarantee the decentralization of the entire protocol ecosystem with the exception of `AlefToken`. `ADNX` and `ADNS` holder will be able to vote on propositions initiated by other holders that meet the criteria. These propositions cover actions to change essential parameters in each aspect of the protocol. Voting on propositions will cost the account casting the vote a fee but will earn them 1`ADNG` token. `ADNG` tokens are later used to vote on higher-level propositions that have to do with governance itself. In addition, `ADNG` holders gain value from `ADNS` and `ADNX` tokens gathered by the governance contract through voting. With ability to burn `ADNX`, stake `ADNS` in `AdonisArbitrage` to earn `ETH` or inject `ETH` and `ALEF` into the `AdonisDEX` liquidity pool to earn `ADNG` holders a share of `ADNX` tokens -or a share in the liquidity pool. Initially, proposition and voting fees will be set to a higher range mainly to discourage individuals from early protocol manipulation. With critical mass and after several propositions, `ADNX` holders that meet specific criteria will be able to initiate the appropriate proposition to decrease the fees associated with voting on or proposing changes. In addition to higher initial voting fees, the criteria required to initiate propositions will be initially set to holders with `10%` or more of total supply of `ADNX`, to ensure that initial liqiudity providers aren't at risk of losses due to changes in the earlier days of the protocol. However, like with the fees, this can be later changed via a proposition that gathers the minimum required votes. Proposotions will be divided into three categories and are limited to: #### Proposition Types ##### AdonisDEX - Pause, Unpause or Snapshot - Change maximum allowed liquidity *[parameter: new maximum liquidity]* - Change minimum allowed liquidity *[parameter: new minimum liquidity]* - Change maximum daily allowed liquidity withdrawal *[parameter: percentage of daily allowed tokens for burning]* - Change liquidity provider fee *[parameter: number per-thousands]* ##### AdonisArbitrage - Pause, Unpause or Snapshot - Add/Remove address to BOT_ROLE *[parameter: BOT contract address]* - Arbitrage Trigger Threshhold *[parameter: number percent]* ##### AdonisGovernance - Pause, Unpause or Snapshot - Minimum liquidity required to propose *[parameter: new minimum liquidity]* - Burn `ADNX` held by governance contract (increases value of `ADNX`) *[parameter: amount to burn]* - Redeem eligible `ADNS` tokens helpd by governance contract *[parameter: amount to redeem]* - Mint new `ADNG` tokens that are distributed per-rata to all `ADNG` holders *[parameter: amount to mint]* - Provide liquidity in `AdonisDEX` from funds in the governance contract, earning `ADNG` holders a stake in the pool *[parameter: amount to mint]* - Change the cost of initiating specific propositions *[parameter: cost, proposition code]* - Change the cost of voting for specific propositions *[parameter: cost, proposition code]* - Change the minimum required votes to execute specific propositions *[parameter: minimum votes, proposition code]* - Change the deadline to execute specific propositions *[parameter: days to execute, proposition code]* ##### Proposition parameters and fees Each proposition has these meta-parameters: initiation cost, minimum votes required, voting cost and execution deadline. In addition, each of the propositions have special parameters related to the action taken once the minimum votes required has been gathered. Meta-parameters are changed via other propositions that require `ADNG` to initiate. ##### Voting restrictions Specific `ADN-` tokens allow individuals to vote on specific propositions. For example, `AdonisDEX` propositions can only be voted on with `ADNX` tokens, `AdonisArbitrage`-related propositions can be voted on by both `ADNS` & `ADNX` holders however the cost is always priced as `ADNX`. By calculating the value of the pool with the knowledge that `ADNS` is backed 1:1 with the `ALEF` token, the governance contract will be able to properly allow individuals to vote with `ADNS` tokens. ##### The governance fund The fees collected by voting are deposited in the `AdonisGovernance` fund which will hold: `ADNS`, `ADNX`, `ALEF` and `ETH` creating value for the `ADNG` token. The aim of this is alongside the propositions that burn `ADNX` from the fund or mint new `ADNG` that is distributed to all holders -among other actions- is to create an opportunity to relatively stabilizing the `ADNG` token value, maybe even decouple it from the crypto-market's volatility to some extent. All propositions related to the governance contract itself will have the fees set in `ADNG` tokens. ## Final Thoughts It seems that we live, unnecessarily, in a highly centralized world. There are numerous arguments as to why decentralization was only properly achieved with the evolution of information technology; But I could make an argument for decentralization that would even fit the Middle Ages, had it not been beyond the scope of this paper. Decentralization is a societal evolutionary step; Not just a redistribution of information but a redistribution of power and control. A democratization of literally every aspect of human society which will lead to a more robust and economically viable society. However, proper democratization cannot exist without decentralization. As Lebanese people, we have suffered a lot due to the inadequacies of those in control of the state. The state no longer, in any aspect, represents the people and their best interest. This is not about patriotism as much as it's about people taking control of their economy and their country. We have an opportunity to repel the claws of corruption by taking control of our own currency. Creating a cryptocurrency market for the Lebanese Lira would rescue it from the clutches of the black market vampires and give control of the currency back to the people. At a first stage, expats will realize that it's cheaper and more efficient to transfer money to their loved ones as `ALEF` and local `ETH` miners benefit from providing liquidity. At a later stage, exporters' adoption would mean other countries and companies abroad would require to also use `ALEF`, indirectly strengthening the `LBP`. Later stages would see more mainstream adoption where ecommerce websites start accepting it as payment as well as stores and supermarkets. All they would need is a MetaMask-like wallet app on mobile or desktop and maybe a 15 minute youtube video. Let's not forget that even grandmothers now have successful instagram blogs and beat leaderboards in Candy Crush. I'm sure they could manage a simple wallet app. Our **country**, our **currency**, our **responsibility**. ***Refuse, Resist, DeFi*** ***- Jad A. Jabbour*** --- ## References - UniswapV1 - https://hackmd.io/@HaydenAdams/HJ9jLsfTz - UniswapV2 - https://uniswap.org/whitepaper.pdf - Uniswap's Financial Alchemy - https://research.paradigm.xyz/uniswaps-alchemy - ExtropyIO DeFi Bot - https://github.com/ExtropyIO/defi-bot - Open Zeppelin Contracts - https://openzeppelin.com/contracts/ - EIP20 - https://eips.ethereum.org/EIPS/eip-20 - DAICheque [Gasless Signed Payments] - https://github.com/dapphub/ds-dach/blob/master/src/dach.sol - EIP712 - https://eips.ethereum.org/EIPS/eip-712 - Compound's Govenor Alpha - https://github.com/compound-finance/compound-protocol/tree/master/contracts/Governance <br/> ### Disclaimer *This paper is for general information purposes only. It does not constitute investment advice or a recommendation or solicitation to buy or sell any investment and should not be used in the evaluation of the merits of making any investment decision. It should not be relied upon for accounting, legal or tax advice or investment recommendations. This paper reflects current opinions of the author; the opinions reflected herein are subject to change without this document being updated.*