Skip to content

Commit

Permalink
feat: update verify_added_liquidity endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Sep 18, 2023
1 parent 321551d commit 420096f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pairs = ["0xXXXXXXXXXXXX"]
[quests.zklend]
contract = "0xXXXXXXXXXXXX"
[quests.ekubo]
utils_contract = "0xXXXXXXXXXXXX"
pairs = ["0xXXXXXXXXXXXX"]
contract = "0xXXXXXXXXXXXX"

[twitter]
oauth2_clientid = "xxxxxx"
Expand Down
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ pub_struct!(Clone, Deserialize; Jediswap {
});

pub_struct!(Clone, Deserialize; Ekubo {
utils_contract: FieldElement,
pairs : Vec<FieldElement>,
contract: FieldElement,
});

pub_struct!(Clone, Deserialize; Quests {
Expand Down
12 changes: 5 additions & 7 deletions src/endpoints/quests/ekubo/verify_added_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ pub async fn handler(
) -> impl IntoResponse {
let task_id = 38;
let addr = &query.addr;
let mut calldata = vec![addr.clone(), state.conf.quests.sithswap.pairs.len().into()];
calldata.append(&mut state.conf.quests.ekubo.pairs.clone());

// get starkname from address
// check if user has provider liquidity
let call_result = state
.provider
.call_contract(
CallFunction {
contract_address: state.conf.quests.ekubo.utils_contract,
entry_point_selector: selector!("sum_balances"),
calldata,
contract_address: state.conf.quests.ekubo.contract,
entry_point_selector: selector!("balanceOf"),
calldata: vec![*addr],
},
BlockId::Latest,
)
Expand All @@ -42,7 +40,7 @@ pub async fn handler(
match call_result {
Ok(result) => {
if result.result[0] == FieldElement::ZERO {
get_error("You didn't deposit liquidity.".to_string())
get_error("You didn't provided any liquidity on Ekubo.".to_string())
} else {
match state.upsert_completed_task(query.addr, task_id).await {
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(),
Expand Down

0 comments on commit 420096f

Please sign in to comment.