Skip to content

Commit

Permalink
add potlock contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiuosvat committed Aug 22, 2024
1 parent 9db2f10 commit 0771634
Show file tree
Hide file tree
Showing 30 changed files with 4,176 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ members = [
"contracts/lottery-esdt",
"contracts/lottery-esdt/meta",
"contracts/lottery-esdt/interactor",
"contracts/potlock",
"contracts/potlock/meta",
"contracts/potlock/interact-rs",
]
25 changes: 25 additions & 0 deletions contracts/lottery-esdt/scenarios/wrong-start-params.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,31 @@
"status": "4",
"message": "str:The contract can't burn the selected token!"
}
},
{
"step": "scCall",
"id": "",
"tx": {
"from": "address:OWNER_ADDRESS",
"to": "sc:lottery-esdt",
"function": "start",
"arguments": [
"0x74657374",
"0x544553542d313233343536",
"0x01",
"0x0100000002",
"0x010000000000000014",
"0x0100000001",
"0x01000000024b19",
"0x010000000246495253545f414444524553535f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5345434f4e445f414444524553535f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"0x65"
],
"gasLimit": "5,000,000"
},
"expect": {
"status": "4",
"message": "str:Invalid burn percentage!"
}
}
]
}
22 changes: 22 additions & 0 deletions contracts/potlock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "potlock"
version = "0.0.0"
authors = ["you"]
edition = "2021"
publish = false
readme = "README.md"

[lib]
path = "src/potlock.rs"

[dependencies.multiversx-sc]
version = "0.52.3"

[dependencies.multiversx-sc-modules]
version = "=0.52.3"

[dev-dependencies]
num-bigint = "0.4.2"

[dev-dependencies.multiversx-sc-scenario]
version = "0.52.3"
27 changes: 27 additions & 0 deletions contracts/potlock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Potlock SC

## Overview
Potlock is a smart contract designed to enhance and accelerate Public Goods Funding (PGF) by leveraging the power of blockchain technology. Inspired by the collaboration between Potlock and the NEAR Foundation, this contract aims to provide an efficient and transparent mechanism for funding public goods, encouraging community participation, and maximizing the impact of pooled resources.

## Features
* **Public Goods Funding (PGF)**: Facilitates the pooling of resources for funding projects that benefit the public.
* **Transparent Allocation**: Ensures that funds are distributed transparently according to predefined rules.
* **Decentralized Governance:** Empowers the community to participate in decision-making processes related to fund allocation.
* **Efficient Fund Management**: Optimizes the management and distribution of funds to maximize impact.



## How It Works

2. **Activation**:
* A POT is defined, where backers and the foundation contribute tokens.
* Anyone can suggest a new POT by paying a fee, but the proposal must be accepted by the admin for it to be activated.
2. **Application and Review**:
* Projects submit their applications to the POT, aiming to secure funding.
* An authority reviews these submissions, evaluating their eligibility and potential impact.
3. **Donation and Matching**:
* Approved projects receive direct contributions from verified donors.
* These donations are further amplified by the POT's value through the Quadratic Funding (QF) model, maximizing the impact of smaller contributions.
4. **Payout**:
* Funds are distributed to the projects based on the matching model.
* After a cooldown period, the process can start again from step 1, with a new or existing POT.
2 changes: 2 additions & 0 deletions contracts/potlock/interact-rs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Pem files are used for interactions, but shouldn't be committed
*.pem
30 changes: 30 additions & 0 deletions contracts/potlock/interact-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[[bin]]
name = "rust-interact"
path = "src/potlock_interactor_main.rs"

[package]
name = "rust-interact"
version = "0.0.0"
authors = ["you"]
edition = "2021"
publish = false

[dependencies]
toml = "0.8.6"

[dependencies.potlock]
path = ".."

[dependencies.multiversx-sc-snippets]
version = "0.52.3"

[dependencies.multiversx-sc]
version = "0.52.3"

[dependencies.clap]
version = "4.4.7"
features = ["derive"]

[dependencies.serde]
version = "1.0"
features = ["derive"]
6 changes: 6 additions & 0 deletions contracts/potlock/interact-rs/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gateway = 'https://devnet-gateway.multiversx.com'
admin = "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
pot_proposer = "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"
project_proposer = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8"
pot_donor = "erd1kyaqzaprcdnv4luvanah0gfxzzsnpaygsy6pytrexll2urtd05ts9vegu7"
project_donor = "erd18tudnj2z8vjh0339yu3vrkgzz2jpz8mjq0uhgnmklnap6z33qqeszq2yn4"
32 changes: 32 additions & 0 deletions contracts/potlock/interact-rs/src/potlock_interactor_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use multiversx_sc_snippets::imports::Bech32Address;
use serde::Deserialize;
use std::io::Read;

/// Config file
const CONFIG_FILE: &str = "config.toml";

/// Multisig Interact configuration
#[derive(Debug, Deserialize)]
pub struct Config {
gateway: String,
pub admin: Bech32Address,
pub pot_proposer: Bech32Address,
pub project_proposer: Bech32Address,
pub pot_donor: Bech32Address,
pub project_donor: Bech32Address,
}

impl Config {
// Deserializes config from file
pub fn load_config() -> Self {
let mut file = std::fs::File::open(CONFIG_FILE).unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
toml::from_str(&content).unwrap()
}

// Returns the gateway
pub fn gateway(&self) -> &str {
&self.gateway
}
}
Loading

0 comments on commit 0771634

Please sign in to comment.