How to DeFi on Partisia Blockchain

How to DeFi on Partisia Blockchain

This is a demonstration of how to get started with DeFi on Partisia Blockchain focusing on interacting with smart contracts directly via blockchain explorer on TestNet and building DEXes based on the Scalable AMM framework developed by co-founder, Kurt Nielsen. There’s currently teams building out DeFi on Partisia Blockchain for MainNet – one example is zkCross Network.

This new AMM DEX design is intended for builders to reinvent traditional finance with a more fair and compliant DEX that ensures scalability, price guarantee, and frontrun protection – all features you will not find in a regular DEX model out-of-the-box. Note that this guide is a walkthrough of a low-level interface to learn the mechanics, and we are encouraging teams to take this and build a user-friendly DeFi app on top of these contracts. Is your team ready to build the next frontier of finance? Read more about our Grants Program.

First things first, let’s meet the testnet tokens and smart contract that we will be using in this guide.

MPC20 tokens

DEX contracts

Get tokens

Now, go to Partisia Blockchain’s Discord server and open a #support-ticket. Choose Developer Support option, and indicate you need test gas and IWH tokens. If you don’t have a wallet already, you can use Parti Wallet. Note: to show your MPC20 tokens in Parti Wallet, go to the “MPC20” tab and then “Manage Tokens”.

Swap via router

Here we use the DEX router for swapping across multiple pairs and liquidity pools to demonstrate the lock-swap price guarantee concept that can be used for building scalable DeFi that operates cross-chain and on multiple shards. In this case we will swap IWH to PPE.

1. Go IvanWifHat (IWH) token contract and sign in with your wallet.

2. Select “Approve” under the “INTERACT” dropdown.

3. Insert the smart contract address of DEX router in “Spender”, select the amount you want to swap (e.g. 50000), and hit “APPROVE” to sign the transaction via your wallet.

Remember IWH has 4 decimals e.g. if you want to approve 5 IWH, insert 50000 in “Amount”. In this guide we use 50000 in “Amount”.

Approval is needed before the DEX router can manage your tokens for the swap.

4. Now go to DEX router and select “Route swap” from the “INTERACT” dropdown.

5. Insert the smart contract address from IvanWifHat (IWH) in the “Token in” field and the smart contract address of PeterPepe (PPE) in “Token out”. Insert the amount you want to swap in “Amount in” e.g. 50000, and the minimum amount you are willing to receive from the swap in “Amount out minimum” e.g. 40000. Click “ADD ADDRESS” twice under “Swap route” and insert the smart contract addresses of QTK/IWH liquidity pool and PPE/QTK liquidity pool in respective order. This will define the route of your swap through liquidity pools. Adjust the gas fee to 500000 and hit “ROUTE SWAP”.

When you set the “Amount out minimum”, take into consideration that each liquidity pool takes a 3% swap fee, gas fees and slippage. In this example we use 50000 “Amount in” and 40000 “Amount out minimum”.

 

6. Examine the transaction hash to explore routing and the lock-swap price guarantee concept, and check the assets in your wallet.

Supply liquidity

Now, if you hold two tokens that correspond to a pair in a liquidity pool, you can become a liquidity provider (LP) to earn revenue from the fees paid by other users that swap.

First, make sure you have swapped your way to hold either QTK and IWH or PPE and QTK. In the below example we use QTK/IWH. See above section “Swap via router” for instructions.

1. Go to IvanWifHat (IWH) and approve the smart contract address of QTK/IWH liquidity pool to spend the amount of that token you want to supply as liquidity. Do the same for QuantumKurt (QTK).

Again, remember that IWH, QTK and PPE has 4 decimals.

2. Then go to QTK/IWH liquidity pool and select “Deposit” under “INTERACT”. Now insert the smart contract address of IvanWifHat (IWH), specify the amount, and hit “DEPOSIT”. Do the same for QuantumKurt (QTK).

 

3. Next, go to the QTK/IWH liquidity pool and select “Provide liquidity” under “INTERACT”. Then insert the smart contract address of IvanWifHat (IWH), specify the amount, and hit “PROVIDE LIQUIDITY”. Do the same for QuantumKurt (QTK).

 

4. Go QTK/IWH liquidity pool and examine the smart contract state to see your LP.

5. If you want to reclaim your liquidity and transfer the tokens back to your account, then use the “Reclaim liquidity” and “Withdraw” function.

Create new DEX and markets

You can find all DeFi smart contract templates here if you are interested in deploying your own DEX and explore all functionalities as operator. For more information on how to compile, deploy and interact with smart contracts, please visit the smart contract documentation. Connect with us on Discord for our tech Q&A and apply for our Grants Program if you are interested in building DeFi on mainnet.

Stay updated: WebsiteXDiscord •  TelegramLinkedInFacebookInstagramGitLabMediumYouTube

BYOC framework intro and high level instructions

BYOC framework intro and high level instructions

As explained in our BYOC documentation, Partisia Blockchain (PBC) has a multi-chain solution where gas for transaction in PBC is paid using external coins. To help developers add additional tokens into the chain, we have a framework that allows anyone who meets the requirements to add other tokens as a bridgeable asset and include them into the payment system. This document’s aim is to provide instructions on how you can add other tokens into the Partisia Blockchain ecosystem.

Currently the framework supports any tokens that run under Ethereum, Polygon or BNB chain. As other L1 chains get added, other tokens will become available under the BYOC Framework.

Requirements:

  • The proposer must hold 10,000 MPC tokens
  • 2/3rd vote from PBC block producing node operators
  • Contract in either Eth, Polygon or BNB chain
  • Contract in PBC network

Risks:

  • Remember that node operators will get compensated for the token being onboarded and used.
  • If the contract is not verified properly and confirmed that it conforms to the template, it can potentially do malicious activities such as draining the new tokens from oracle nodes, etc.

High level instructions:

  1. The requester must hold at least 10,000 MPC tokens staked to their wallet. It will not be used but rather shows that you are a PBC contributor.
  2. You need to get 2/3rd approval from the Node Operator. Partisia Blockchain Foundation’s Developer Relations team will assist in making the announcement and help drive the vote. Send your request to “build@partisiablockchain.com”.
  3. Once node operator consensus is achieved, you need to deploy the contract in the asset chain and also in PBC. You can find the template code here — https://gitlab.com/partisiablockchain/governance/byoc-contract-eth.
  4. Once contracts are deployed, Node Operators have seven days to vote for your contract. If the vote passes, the contract will be live.
  5. PBC will then assist in adding the new token into the bridge UI.

In the coming weeks we will provide additional guides and videos to walk you through the process, for both the node operators and the proposer. We hope this article will help you begin to consider what tokens you would like to onboard as payment.

Introducing BYOC framework

Introducing BYOC framework

We are proud to introduce to the community one of our major roadmap items, the BYOC framework.

Interoperability and decentralization is one of our core values of our blockchain and one of our goals is to enable anyone to harness the capabilities of MPC. This is why our BYOC architecture was created in the first place, allowing the onboarding of any liquid assets to be usable as transaction fees (gas) on our blockchain.

Until now the foundation has proposed and enabled the onboarding of ETH, Polygon USDC and BNB as forms of payment. But our long term goal always was to allow for the community to make decisions on what tokens should be enabled on our chain.

The BYOC framework will now allow for the community to propose any tokens running on the Ethereum, BNB or Polygon chains to be usable as gas payment. The proposal then will go to our validators who will then make the final vote on whether or not to onboard the token as form of payment on Partisia Blockchain.

In the coming days we will share additional details and instructions on how the community can create a proposal for a token to be enabled on Partisia Blockchain. The foundation will initially start by submitting proposals to enable both USDT and MATIC tokens, and create detailed instruction guides using these two tokens as templates to help guide the community to onboard other tokens of their choice.

We are very excited to introduce this new feature and looking forward to seeing other great tokens being introduced by the community into our bridge.