Skip to content

Commit

Permalink
Merge pull request #147 from starknet-id/ayush/nimbora-quest
Browse files Browse the repository at this point in the history
feat: add nimbora quest
  • Loading branch information
Th0rgal authored May 10, 2024
2 parents 6e2e36f + f739977 commit d2b4f35
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 23 deletions.
34 changes: 15 additions & 19 deletions config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,47 +1013,43 @@ options = [
correct_answers = [*]

[quizzes.nimbora]
name = "Nimbora Quiz"
desc = "Test your Nimbora knowledge in our quiz for a chance to win an exclusive NFT as your reward."
intro = "Welcome to the Nimbora quiz! Are you familiar with DeFi on Nimbora? Let's explore it together. Good luck!"
name = "Defi Pot quiz"
desc = "Bridging Ethereum's Layer 1 and Layer 2 seamlessly for cost-efficient DeFi interactions with improved user experience and uncompromised pooling."
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 Nostra, enjoy the experience, and earn an exclusive NFT reward by testing your knowledge about Starknet Ecosystem projects!"

[[quizzes.nimbora.questions]]
kind = "text_choice"
layout = "default"
question = "What is Nimbora?"
options = [
"Liquidity mining",
"A traditional Layer 2 solution",
"Defi pooling solution bridging Ethereum's L1 and L2 for cost-efficient DeFi interactions",
"An L1 DeFi protocol without composability"
"Liquidity mining",
"L1 DeFi protocol",
"Starknet-based cross-chain yield strategy platform that enables users to engage with Layer 1 protocols at a fraction of the cost",
]
correct_answers = [*]

[[quizzes.nimbora.questions]]
kind = "text_choice"
layout = "default"
question = "What is the benefit of Nimbora’s automatic withdrawal service?"
question = "What can you do on Nimbora?"
options = [
"Manual claiming of tokens",
"Increased transaction fees",
"Hassle-free experience and minimized fees",
"Limited token selection"
"Earn and borrow crypto assets",
"Bridge",
"Swap",
]
correct_answers = [*]

[[quizzes.nimbora.questions]]
kind = "text_choice"
layout = "default"
question = "What is the current maximum borrowing limit with Liquity?"
question = "Nimbora offers yield that is:"
options = [
"LUSD 1000",
"LUSD 500",
"LUSD 750",
"LUSD 100"
"Nothing special",
"Ok, has fixed APR",
"Nimbora has the highest APR on Starknet",
]
correct_answers = [*]


[quizzes.nostra2]
name = "Nostra Quiz"
desc = "Take part in our Quiz to test your knowledge about Nostra, and you'll have a chance to win 250 STRK."
Expand Down Expand Up @@ -1130,4 +1126,4 @@ options = [
"No, the strategy does this automatically",
"Yes",
]
correct_answers = [*]
correct_answers = [*]
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ pub_struct!(Clone, Deserialize; Quests {
nostra: Nostra,
carbonable: Contract,
hashstack: TokenAndContract,
haiko: PublicApi
haiko: PublicApi,
nimbora: Contract
});

pub_struct!(Clone, Deserialize; Twitter {
Expand Down
59 changes: 59 additions & 0 deletions src/endpoints/quests/nimbora/check_balance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use std::sync::Arc;

use crate::{
models::{AppState, VerifyQuery},
utils::{get_error, CompletedTasksTrait},
};
use axum::{
extract::{Query, State},
http::StatusCode,
response::IntoResponse,
Json,
};
use axum_auto_routes::route;
use serde_json::json;
use starknet::{
core::types::{BlockId, BlockTag, FieldElement, FunctionCall},
macros::selector,
providers::Provider,
};

#[route(
get,
"/quests/nimbora/check_balance",
crate::endpoints::quests::nimbora::check_balance
)]
pub async fn handler(
State(state): State<Arc<AppState>>,
Query(query): Query<VerifyQuery>,
) -> impl IntoResponse {
let task_id = 144;
let addr = &query.addr;
let calldata = vec![*addr];
let call_result = state
.provider
.call(
FunctionCall {
contract_address: state.conf.quests.nimbora.contract,
entry_point_selector: selector!("balance_of"),
calldata,
},
BlockId::Tag(BlockTag::Latest),
)
.await;


match call_result {
Ok(result) => {
if result[0] < FieldElement::from_dec_str("4000000000000000").unwrap() {
get_error("You didn't invest on nimbora.".to_string())
} else {
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)),
}
}
}
Err(e) => get_error(format!("{}", e)),
}
}
4 changes: 2 additions & 2 deletions src/endpoints/quests/nimbora/claimable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use starknet::{
use std::sync::Arc;

const QUEST_ID: u32 = 22;
const TASK_IDS: &[u32] = &[89, 90, 91];
const LAST_TASK: u32 = TASK_IDS[2];
const TASK_IDS: &[u32] = &[89, 90, 91,144];
const LAST_TASK: u32 = TASK_IDS[3];
const NFT_LEVEL: u32 = 35;

#[derive(Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/endpoints/quests/nimbora/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod verify_twitter_rt;
pub mod discord_fw_callback;
pub mod claimable;
pub mod claimable;
pub mod check_balance;

0 comments on commit d2b4f35

Please sign in to comment.