Inspiration

Wanted to make a completely decentralized insurance platform and a trading platform. Fantom is a great choice due to it's higher throughput, faster transaction and cheaper gas fees.

What it does

A decentralised p2p insurance and a trading platform.

All the funds in the insurance pool can be used to provide liquidity to the exchange. And if opted to use pool funds in liquidity, rate of native token to liquidity token will be considered as rate at the time of removing liquidity from the exchange. So the exchange will act as a price oracle. Liquidity will be removed after judging period is over. And Liquidity will be keep on adding as members joins.

Any user can become liquidity provider in general and can use Exchange to swap tokens.

Exchange fees is 1% which will be divided among liquidity providers.

Every user can create an insurance contract, which will have following informations:

  1. Title
  2. Description
  3. Minimum members
  4. Time after which no new user can enter and insurance will start
  5. validity, that is for how long insurance will remains
  6. claim time: that is for how long after insurance ended, can a user make an insurance claim for their loss.
  7. Percentage divided among judges
  8. judging time: how much time will judge get to judge all the claims.

After an insurance contract is created, anyone who wants join a particular contract is supposed to send a request for membership. If every member of that contract accept the request then the user can add himself to the contract.

Judges are selected using chainlink oracles, one for getting random numbers to select judges randomly and other to perform function after certain period which is also done using oracles. So custom logic based automation + random number is used from chainlink oracles.

If no judges had fullfilled their jobs then everyone except those judges will get their fund inside the pool back. If no claim have majority votes then judges who didn't fullfilled won't get their funds back and everyone else will get their funds back. If claim request is fullfilled then remaining amount is distributed among all the members. Also first judges get their percentage from total pool amount as a prize for fullfilling their job.

Fullfillment logic in smart contract

All contracts are deployed on fantom testnet. smart contract address

Smart Contracts

Insurance Factory

Exchange Factory

Test Token

How we built it

All the smart contracts are deployed on Fantom testnet. There are 2 Factory contract. One is Insurance Factory to create, deploy and manage Insurance contracts and other is Exchange Factory to create, deploy and manage token pairs for liquidity pool. Hardhat was used to deploy smart contracts written in Solidity. Nextjs was used to create decentralized web application to interact with smart contracts.

Challenges we ran into

P2P insurance in itself is a challenging task but to use all the funds in the insurance contract as liquidity pool makes it a lot complicated as after removing liquidity at the end of insurance validity, amount of funds will be changed and properly distributing the funds by calculating and managing details by applying a lot of mathematical concepts made it very difficult.

Accomplishments that we're proud of

Have finally made a platform where any user can swap tokens, become liquidity provider, participate in p2p insurance contract and insurance contract can opt to put all the funds as liquidity and get rewards at the end of the insurance.

What we learned

Learnt about automatic market maker and a lot other DeFi concepts.

What's next for Insurely

Want to do proper auditing and then deploy it to Fantom mainnet.

Built With

Share this project:

Updates