Skip to content

Commit

Permalink
Merge pull request #93 from starknet-id/feat/add_new_quizzes
Browse files Browse the repository at this point in the history
feat: add more quizzes & read some twitter tasks
  • Loading branch information
Th0rgal authored Oct 13, 2023
2 parents 00bd9a6 + 90e22dc commit 77dbbbe
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 15 deletions.
178 changes: 177 additions & 1 deletion config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,180 @@ options = [
"A browser extension for secure internet browsing.",
"An online shopping platform for buying digital goods."
]
correct_answers = [*]
correct_answers = [*]

[quizzes.avnu]
name = "AVNU NoFluff Quiz"
desc = "Take part in our AVNU NoFluff Quiz to test your knowledge about Starknet’s Aggerator, and you'll have a chance to win an exclusive AVNU NoFluff Quiz as your reward."
intro = "Starknet Quest Quiz Rounds, a quiz series designed to make Starknet ecosystem knowledge accessible and enjoyable for all. Test your understanding of the workings of AVNU, enjoy the experience, and earn an exclusive NFT reward by testing your knowledge about Starknet Ecosystem projects!"

[[quizzes.avnu.questions]]
kind = "text_choice"
layout = "default"
question = "What is AVNU's mission? "
options = [
"To build Liquidity Infrastructure for traders and dApps",
"To offer the highest yields on investments",
"To create a social media platform",
"To provide health services "
]
correct_answers = [*]

[[quizzes.avnu.questions]]
kind = "text_choice"
layout = "default"
question = "What problem does AVNU aim to address in the DeFi space?"
options = [
"Inefficiencies in transportation systems",
"Poor weather forecasting",
"Capital inefficiency and poor price discovery in AMMs",
"Lack of social media engagement "
]
correct_answers = [*]

[[quizzes.avnu.questions]]
kind = "text_choice"
layout = "default"
question = "How does AVNU's RFQ system work to improve the trading experience?"
options = [
"By offering the highest possible yields to users",
"By preventing impermanent loss",
"By aggregating liquidity from various AMMs",
"By leveraging professional market makers and off-chain pricing algorithms to optimize pricing and minimize hidden costs"
]
correct_answers = [*]

[[quizzes.avnu.questions]]
kind = "text_choice"
layout = "default"
question = "What is MEV protection, and how does AVNU's RFQ system provide it?"
options = [
"MEV protection is Maximum Earnings Volatility, and AVNU ensures it through trading volume.",
"MEV protection is Market Efficiency Verification, and AVNU uses it to verify liquidity sources.",
"MEV protection is Miner Extractable Value, and AVNU uses cryptographic signatures to prevent front-running and maintain a secure trading environment.",
"MEV protection is Monetary Exchange Value, and AVNU guarantees it through blockchain technology. "
]
correct_answers = [*]

[quizzes.zklend]
name = "ZkLend Zenders Quiz"
desc = "Take part in our ZkLend Zenders Quiz to test your DeFi knowledge, and you'll have a chance to win an exclusive ZkLend Zenders NFT as your reward."
intro = "Starknet Quest Quiz Rounds, a quiz series designed to make Starknet ecosystem knowledge accessible and enjoyable for all. Test your understanding of the intricate workings of ZkLend, enjoy the experience and earn exclusive NFT rewards by testing your Starknet-related topics."

[[quizzes.zklend.questions]]
kind = "text_choice"
layout = "default"
question = "What is ZkLend?"
options = [
"ZkLend is a traditional banking system.",
"ZkLend is a cryptocurrency used for online payments.",
"ZkLend is a permissionless lending market for retail users, offering depositing, borrowing, and earning yields on digital assets.",
"ZkLend is a physical lending institution with branches worldwide."
]
correct_answers = [*]

[[quizzes.zklend.questions]]
kind = "text_choice"
layout = "default"
question = "What does borrowing and lending mean in the context of ZkLend?"
options = [
"Borrowing allows users to deposit assets to earn interest, while lending involves borrowing assets using collateral.",
"Lending allows users to deposit assets to earn interest, while borrowing involves borrowing assets using collateral.",
"Borrowing and lending both refer to depositing assets to earn interest without any collateral involved.",
"Borrowing and lending are unrelated to ZKLend; it's a decentralized platform for gaming. "
]
correct_answers = [*]

[[quizzes.zklend.questions]]
kind = "text_choice"
layout = "default"
question = "What is the Health Factor in ZkLend?"
options = [
"A numerical representation of the leverage ratio",
"A metric showing a user's borrowing capacity",
"The sum of outstanding borrowings and accrued interest",
"The safety of deposited assets in relation to borrowed assets"
]
correct_answers = [*]

[[quizzes.zklend.questions]]
kind = "text_choice"
layout = "default"
question = "What does liquidation mean in ZkLend?"
options = [
"Liquidation is a process initiated by borrowers to lower their debt.",
"Liquidation is the process of selling off collateral to repay a portion of a borrower's debt when their Health Factor falls below 1.",
"Liquidation is a bonus given to borrowers who maintain a high Health Factor.",
"Liquidation is a penalty imposed on external parties for monitoring zkLend's loan portfolios."
]
correct_answers = [*]

[quizzes.starknetid]
name = "Starknet ID Tribe Quiz"
desc = "Take part in our Starknet ID Tribe Quiz to test your knowledge, and you'll have a chance to win an exclusive Starknet ID Tribe NFT as your reward."
intro = "Starknet Quest Quiz Rounds, a quiz series designed to make Starknet ecosystem knowledge accessible and enjoyable for all. Test your understanding of the Basics of how Starknet ID functions, enjoy and earn an exclusive NFT reward by testing your knowledge about Starknet Ecosystem projects!"

[[quizzes.starknetid.questions]]
kind = "text_choice"
layout = "default"
question = "What is the primary purpose of Starknet.id?"
options = [
"A social media platform",
"An online marketplace",
"An identity and naming protocol for Starknet",
"A gaming platform"
]
correct_answers = [*]

[[quizzes.starknetid.questions]]
kind = "text_choice"
layout = "default"
question = "What extension do the domain names use on Starknet.id?"
options = [
".com",
".stark",
".crypto",
".eth"
]
correct_answers = [*]

[[quizzes.starknetid.questions]]
kind = "text_choice"
layout = "default"
question = "What is the purpose of the 'Proof of Personhood' (POP) verification in Starknet.id?"
options = [
"To verify financial transactions",
"To prove ownership of digital assets",
"To verify that a user is a real human and a single person",
"To confirm the user's location"
]
correct_answers = [*]

[quizzes.sithswap]
name = "SithSwap The Dark Side Quiz"
desc = "Take part in our SithSwap The Dark Side Quiz to test your knowledge, and you'll have a chance to win an exclusive The Dark Side NFT as your reward."
intro = "Starknet Quest Quiz Rounds, a quiz series designed to make Starknet ecosystem knowledge accessible and enjoyable for all. Put your knowledge of the fundamental workings of SithSwap to the test, enjoy and earn an exclusive NFT reward by testing your knowledge about Starknet Ecosystem projects!"

[[quizzes.sithswap.questions]]
kind = "text_choice"
layout = "default"
question = "What are volatile pairs in dual-liquidity pools?"
options = [
"Volatile pairs are designed for assets with little-to-no volatility in trading correlation.",
"Volatile pairs rely on a constant-product formula.",
"Volatile pairs are optimized for assets with medium-to-high price volatility and use a generic constant-product formula.",
"Volatile pairs have extremely low slippage on large trading volumes."
]
correct_answers = [*]

[[quizzes.sithswap.questions]]
kind = "text_choice"
layout = "default"
question = "Why are stable pairs attractive for traders?"
options = [
"Because they offer high returns on investment",
"Because they involve tokens with unpredictable price fluctuations",
"Because they allow for extremely low slippage, even on large trading volumes",
"Because they have high liquidity and are easy to trade"
]
correct_answers = [*]
4 changes: 2 additions & 2 deletions src/endpoints/quests/avnu/claimable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use starknet::{
use std::sync::Arc;

const QUEST_ID: u32 = 3;
const TASK_IDS: &[u32] = &[12, 13];
const LAST_TASK: u32 = TASK_IDS[1];
const TASK_IDS: &[u32] = &[12, 13, 54];
const LAST_TASK: u32 = TASK_IDS[2];
const NFT_LEVEL: u32 = 6;

#[derive(Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/endpoints/quests/avnu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod claimable;
pub mod discord_fw_callback;
pub mod verify_quiz;
pub mod verify_swap;
42 changes: 42 additions & 0 deletions src/endpoints/quests/avnu/verify_quiz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::sync::Arc;

use crate::{
common::verify_quiz::verify_quiz,
models::{AppState, VerifyQuizQuery},
utils::{get_error, CompletedTasksTrait},
};
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
use starknet::core::types::FieldElement;

pub async fn handler(
State(state): State<Arc<AppState>>,
body: Json<VerifyQuizQuery>,
) -> impl IntoResponse {
let task_id = 54;
if body.addr == FieldElement::ZERO {
return get_error("Please connect your wallet first".to_string());
}

let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body
.user_answers_list
.iter()
.map(|inner_list| {
inner_list
.iter()
.map(|s| s.parse::<usize>())
.collect::<Result<Vec<_>, _>>()
})
.collect();

match user_answers_numbers {
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) {
true => match state.upsert_completed_task(body.addr, task_id).await {
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(),
Err(e) => get_error(format!("{}", e)),
},
false => get_error("Incorrect answers".to_string()),
},
Err(e) => get_error(format!("{}", e)),
}
}
4 changes: 2 additions & 2 deletions src/endpoints/quests/sithswap/claimable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use starknet::{
use std::sync::Arc;

const QUEST_ID: u32 = 5;
const TASK_IDS: &[u32] = &[20];
const LAST_TASK: u32 = TASK_IDS[0];
const TASK_IDS: &[u32] = &[20, 21, 55];
const LAST_TASK: u32 = TASK_IDS[2];
const NFT_LEVEL: u32 = 7;

#[derive(Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions src/endpoints/quests/sithswap/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pub mod claimable;
pub mod verify_added_liquidity;
pub mod verify_quiz;
pub mod verify_twitter_fw;
42 changes: 42 additions & 0 deletions src/endpoints/quests/sithswap/verify_quiz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::sync::Arc;

use crate::{
common::verify_quiz::verify_quiz,
models::{AppState, VerifyQuizQuery},
utils::{get_error, CompletedTasksTrait},
};
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
use starknet::core::types::FieldElement;

pub async fn handler(
State(state): State<Arc<AppState>>,
body: Json<VerifyQuizQuery>,
) -> impl IntoResponse {
let task_id = 55;
if body.addr == FieldElement::ZERO {
return get_error("Please connect your wallet first".to_string());
}

let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body
.user_answers_list
.iter()
.map(|inner_list| {
inner_list
.iter()
.map(|s| s.parse::<usize>())
.collect::<Result<Vec<_>, _>>()
})
.collect();

match user_answers_numbers {
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) {
true => match state.upsert_completed_task(body.addr, task_id).await {
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(),
Err(e) => get_error(format!("{}", e)),
},
false => get_error("Incorrect answers".to_string()),
},
Err(e) => get_error(format!("{}", e)),
}
}
28 changes: 28 additions & 0 deletions src/endpoints/quests/sithswap/verify_twitter_fw.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::sync::Arc;

use crate::{
models::{AppState, VerifyQuery},
utils::{get_error, CompletedTasksTrait},
};
use axum::{
extract::{Query, State},
http::StatusCode,
response::IntoResponse,
Json,
};
use serde_json::json;
use starknet::core::types::FieldElement;

pub async fn handler(
State(state): State<Arc<AppState>>,
Query(query): Query<VerifyQuery>,
) -> impl IntoResponse {
let task_id = 21;
if query.addr == FieldElement::ZERO {
return get_error("Please connect your wallet first".to_string());
}
match state.upsert_completed_task(query.addr, task_id).await {
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(),
Err(e) => get_error(format!("{}", e)),
}
}
4 changes: 2 additions & 2 deletions src/endpoints/quests/starknetid/claimable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use starknet::{
use std::sync::Arc;

const QUEST_ID: u32 = 1;
const TASK_IDS: &[u32] = &[5, 6, 7];
const LAST_TASK: u32 = TASK_IDS[2];
const TASK_IDS: &[u32] = &[5, 6, 7, 56];
const LAST_TASK: u32 = TASK_IDS[3];
const NFT_LEVEL: u32 = 4;

#[derive(Deserialize)]
Expand Down
5 changes: 3 additions & 2 deletions src/endpoints/quests/starknetid/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod verify_twitter_fw;
pub mod claimable;
pub mod verify_has_domain;
pub mod verify_has_root_domain;
pub mod verify_quiz;
pub mod verify_socials;
pub mod claimable;
pub mod verify_twitter_fw;
42 changes: 42 additions & 0 deletions src/endpoints/quests/starknetid/verify_quiz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::sync::Arc;

use crate::{
common::verify_quiz::verify_quiz,
models::{AppState, VerifyQuizQuery},
utils::{get_error, CompletedTasksTrait},
};
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
use starknet::core::types::FieldElement;

pub async fn handler(
State(state): State<Arc<AppState>>,
body: Json<VerifyQuizQuery>,
) -> impl IntoResponse {
let task_id = 56;
if body.addr == FieldElement::ZERO {
return get_error("Please connect your wallet first".to_string());
}

let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body
.user_answers_list
.iter()
.map(|inner_list| {
inner_list
.iter()
.map(|s| s.parse::<usize>())
.collect::<Result<Vec<_>, _>>()
})
.collect();

match user_answers_numbers {
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) {
true => match state.upsert_completed_task(body.addr, task_id).await {
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(),
Err(e) => get_error(format!("{}", e)),
},
false => get_error("Incorrect answers".to_string()),
},
Err(e) => get_error(format!("{}", e)),
}
}
Loading

0 comments on commit 77dbbbe

Please sign in to comment.