---
# System prepended metadata

title: PEPA IDO Launchpad
tags: [Sway Language, IDO Launchpad, Fuel Network]

---

---
title: PEPA IDO Launchpad
---

###### tags: `IDO Launchpad` `Fuel Network` `Sway Language`

<font size="8"> PEPA IDO Launchpad </font>
Design & Spec
===
> Copyright © 2023 by PEPA Market. All rights reserved.
> Feb 23, 2023
> by **PEPA Market**

<!-- <span style="position:fixed;
 top:200px;
 right:400px;
 opacity:0.5;
 font-size: 20px;
 z-index:99;">watermark</span> -->

<!-- inser new picture here -->
![PEPA-Market-Cover](https://imgur.com/2aX6mtS.png)

This report presents our PEPA dev team's engineering design & spec for the PEPA IDO Launchpad. 

---

## Table of Content

[TOC]

---

## Project Summary

PEPA IDO Launchpad is a platform that enables new Fuel projects to raise capital by releasing an Initial DEX Offering (IDO). An IDO is a decentralized fundraising technique that enables investors to purchase new tokens directly from a project's smart contract, as opposed to a centralized exchange.

PEPA IDO Launchpad provides a variety of services, including marketing and community building, technical support, and token distribution, to assist Fuel Ecosystem projects in preparing for and executing their IDO. In addition to enabling investors to discover and engage in new projects, PEPA IDO provides tools for analyzing and monitoring the performance of various tokens.


---

## Protocol Overview

### Business Logic

PEPA IDO Launchpad is a platform that helps web3 startups and projects on Fuel raise capital by launching their tokens through an Initial DEX Offering on a decentralized exchange. 

Here is a list of services that PEPA IDO offers:

+ **Token creation and distribution**: PEPA IDO Launchpad allows web3 startups and projects on Fuel create their own tokens and distribute them to investors during the IDO event. PEPA IDO also helps ensure that tokens are distributed fairly according to predetermined rules.

![](https://i.imgur.com/CFdTj7l.png)

+ **Liquidity freeze**: To facilitate a seamless trading experience for investors, PEPA IDO provides liquidity by locking up unused tokens in PEPA DEX pools. This helps prevent large price fluctuations and encourage trading activity.

+ **Marketing and promotion**: To attract investors, PEPA IDO Launchpad provides marketing and promotional services to the Fuel-based projects. This includes social media promition, creating press releases, and engaging with potential investors.








### Core Elements
PEPA IDO Launchpad is a Fuel-based contract suite enabling on-chain creation and IDO of tokens on Fuel with security guarantee. The functionality of PEPA IDO is achieved collectively by a collection of core contracts.

#### IDO Contract

IDO contract wraps up logic of creating a single IDO. It stores quote token and handles token bidding, liquidity pool setup, and token vesting.

#### Factory Contract

Factory contract serves as singleton service and information center for all services that PEPA IDO provides. It handles exchange IDO registration and information request, as well as verifying existing IDO contract. 

---

## PEPA IDO Launchpad Architecture 
<!-- todo: add an system level overview / graph to explain each component -->
![IDO Architecture and user action](https://i.imgur.com/nXuNm5W.png)

### Factory Contract
Factory Contract has been designed to record the list of the pool contract, where there are 3 important functions that users/admin can interact with:
- initialize
- add_ido
- get_ido_user

#### initialize - storage(read,write)

Initialize a factory contract.


|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | template_ido_id | b256 | `ContractId` of IDO contract template |

#### add_ido - storage(read,write)

Register an IDO project and pass in necessary parameters. We plan to include contract creation feature in the upcoming updates.

|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | base_token | b256 | `ContractId` of base token |
| Input - 2 | quote_token | b256 | `ContractId` of quote token |
| Input - 3 | id_address | b256 | `ContractId` of IDO contract to add |
| Input - 4 | owner | b256 | Owner of the IDO |

#### get_ido_by_token - storage(read)

Search an IDO contract address by base and quote token.

|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | base_token | b256 | `ContractId` of base token |
| Input - 2 | quote_token | b256 | `ContractId` of quote token |
| Output - 1 | ido_address | b256 | `ContractId` of IDO contract |

#### get_ido_by_admin - storage(read)

Search an IDO contract address by its admin.

|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | owner | b256 | Owner of the IDO |
| Output - 1 | ido_address | b256 | `ContractId` of IDO contract |

#### update_admin - storage(read)

Update admin of an IDO project.

|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | owner | b256 | Owner of the IDO |
| Output - 1 | ido_address | b256 | `ContractId` of IDO contract |


#### remove_ido - storage(read)

remove an IDO project and its public pool (if exist).

|           |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | owner | b256 | Owner of the IDO |
| Input - 2 | base_token | b256 | `ContractId` of base token |
| Input - 3 | quote_token | b256 | `ContractId` of quote token |
| Input - 4 | pool | b256 | `ContractId` of the pool initialized. |



### IDO Contract
<!-- todo: IDO Contract Functional Level Explaination -->

#### initialize - storage(read,write)

Initialize an IDO contract and provides necessary parameters and options.


|     <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | address_list | Vec<b256> | An ordered list of address in following order: owner, maintainer, base token, quote token, fee model, pool factory address|
| Input - 2 | timeline | Vec<u64> | contains ordered list of timestamp representing following timestamps: Start, Bid, Freeze, Vesting, Claim |
| Input - 3 | value_list | Vec<u64> | containing list of IDO parameters providing advanced setting |
| Input - 4 | switches | Vec<bool> | containing on and off status for list of options for setup IDO contract |
    
    
    
#### get_info - storage(read)

Get detailed user status in current IDO.


|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | user_address | b256 |  User address to look up |
| Input - 2 | timeline | Vec<u64> | contains ordered list of timestamp representing following timestamps: Start, Bid, Freeze, Vesting, Claim |
| Input - 3 | value_list | Vec<u64> | containing list of IDO parameters providing advanced setting |
| Input - 4 | switches | Vec<bool> | containing on and off status for list of options for setup IDO contract |
    
    
#### claim_bid - storage(read,write)
Claim base token and quote token after IDO settlement.

|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | to | b256 |  Address to send claimed token to |

#### get_claimable_token - storage(read)
Return the amount of base and quote token claimable at address provided.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | user_address | b256 |  Address to lookup for claimable token |
| Output - 1 | base | u64 |  Amount of base token claimable |
| Output - 2 | quote | u64 |  Amount of quote token claimable |
    
#### claim_lp_token - storage(read,write)
Claim LP token.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
    
#### get_lp_token_claimable - storage(read)
Return the amount of LP token claimable.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | user_address | b256 |  Address to lookup for claimable LP token |
| Output - 1 | lp_token_amount | u64 |  Amount of LP token claimable |
    
    
#### bid - storage(read,write)
Place bid on the current IDO.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | to | b256 |  Address to place bid for |
    
#### cancel - storage(read,write)
Remove bid from the current IDO.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Input - 1 | to | b256 |  Address to cancel bid for |
| Input - 2 | amount | u64 |  Amount of token to remove from bid |
    
#### settle - storage(read,write)
Settle IDO and allocate shares.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Output - 1 | settled | bool |  Set to true if settle processed successfully and revert otherwise. |
    
#### get_settle_result - storage(read)
Get IDO settlement result.
    
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Output - 1 | base_pool | u64 |  Unsold base token |
| Output - 2 | quote_pool | u64 | Unsold quote token |
| Output - 3 | pool_price | u64 |  Price of the quote token, determined by the amount of token sold and base token supply. |
| Output - 4 | base_unused | u64 |  Amount of base token unused. |
| Output - 5 | quote_unused | u64 |  Amount of quote token unused. |

#### get_expected_price - storage(read)
Get expected average price for the current unsettled IDO.
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Output - 1 | price | u64 |  Estimated IDO token price |
    
#### get_shares - storage(read)
Get user shares for the current IDO.
|   <font color='white'>test</font>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;        |   Veriable Name  | Type |     Description       |
| --------- | ---------------- | -----|       --------        |
| Output - 1 | total_shares | u64 |  Total shares allocated |
| Output - 2 | share_amount | u64 |  Share amount allocated to user |
    
---

## License | Safety Notice | Disclaimer
<!-- todo: Express current engineering and testing is still undergoing and contract has not been security review yet -->
    
**DISCLAIMER:** This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose. The author(s) will not be held liable for any damages arising from the use of this software. This code is provided for educational and informational purposes only. It should not be used for any purpose that may be deemed commercial, without prior written consent from the author(s). The author(s) make no representations or warranties with respect to the accuracy or completeness of the contents of this code and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. The user assumes all responsibility and risk for the use of this code. Feel free to modify and customize the disclaimer as needed, depending on the specific details of your code and the intended use of the software.



