Smart Contract Design and Functionality
For a better understanding of PLIT protocol, we have used the Two-contract system in previous. PLIT protocol is capable of working only using a single contract and we will explain that here:
when a new project is listed on Plit Protocol, a new contract will be created specifically for that project. Let's use the example of Project ABC.
Contract 1: Project Contract/vault
This is a smart contract specific to each project that wants to participate in Plit Protocol. When the ABC project is listed on PLIT Protocol, it will deploy its own ABC project contract. The ABC project will send its own token to the ABC project contract. The purpose of this contract is to hold the tokens of the project that are used for liquidity provision. When users provide stablecoins to the ABC project contract, the contract will calculate the current price of the project's token (ABC) and determine the amount of ABC tokens needed to match the value of the stablecoins provided. For example, if a user provides 100 DAI and the price of ABC tokens is $2, the contract will calculate that 50 ABC tokens are needed to match the value of 100 DAI.
Once the required amount of ABC tokens is determined, the project contract will create a new contract and send the 50 ABC tokens and 100 DAI to the newly created contract(contract 2).
Contract 2: Liquidity Provision Contract
This contract is created by the project contract and is used for adding liquidity to a decentralized exchange like Uniswap. When users provide stablecoins to the ABC project contract, the ABC project contract will determine the amount of ABC tokens needed to match the value of the stablecoins provided. The project contract will then create a new contract and deposit the ABC project tokens and stablecoins into that contract.
The newly created contract will then use the 100 DAI and 50 ABC tokens to provide liquidity to a decentralized exchange such as Uniswap or SushiSwap, adding them to an existing liquidity pool for the ABC/DAI pair. The liquidity provider (LP) tokens obtained from the exchange will be stored in the newly created contract rather than the ABC project contract.
Each time a user deposits stable tokens, a new contract will be created, and the newly created contract will be linked to an NFT that specifies the amount of stable tokens and the contract's address. The price of the token at the time of deposit will also be saved in the newly created contract.
The LP tokens represent the user's share in the liquidity pool, and they can be redeemed for their proportional share of the underlying assets (dai and ABC) at any time. When the user wants to withdraw their dai, the project contract will redeem the LP tokens and use the dai and ABC tokens received to send the user their initial investment of 100 dai.
For example
The ABC project will have an ABC project contract that holds ABC tokens that will be used for liquidity provision. when user A deposits 100$ Dai to the ABC project contract, it will calculate the value of the ABC token. if ABC = 2$ then the Project contract will create a new contract and will Deposit 100Dai + 50ABC (as per calculation) to the new contract it created. This newly created contract will then mint an NFT representing the contract and the amount of dai it has. The newly created contract will then use the 100 DAI and 50 ABC tokens to provide liquidity to a decentralized exchange such as Uniswap or SushiSwap, adding them to an existing liquidity pool for the ABC/DAI pair.
The liquidity provider (LP) tokens obtained from the exchange will be stored in the newly created contract rather than the ABC project contract.
when a user wants to withdraw their stablecoins (DAI) from the ABC project vault, they will deposit their NFT (received when they provided DAI) back into the project vault contract. This will trigger the contract to redeem the corresponding LP tokens from the liquidity provision contract (Contract 2). The contract will then calculate the amount of stablecoins and project tokens (ABC) that can be obtained from the LP tokens, and send the stablecoins back to the user. The project vault contract will keep the project tokens obtained from the redemption and can use them to provide liquidity or for other purposes.

learn more about Liquidity Withdrawals and asjustments.
Handling Liquidity Withdrawals and AdjustmentsLast updated