Skip to content

Commit

Permalink
change allowed strategist rewards claimer from range admin to treasur…
Browse files Browse the repository at this point in the history
…y address (#577)

## 1. Overview

Instead of allowing the range admin to claim the strategist rewards,
this is moved to the treasury address.

## 2. Implementation details

This is changed by fetching the allowed address from the `RANGE_ADMIN`
to the `VAULT_CONFIG`

## 3. How to test/use

The unit tests are adapted for the updated claiming

## 4. Checklist

<!-- Checklist for PR author(s). -->

- [x] Does the Readme need to be updated?
Not as of now

## 5. Limitations (optional)

<!-- Describe any limitation of the capabilities listed in the Overview
section. -->

## 6. Future Work (optional)

This design allows for future processing of strategists fees through
middleware
  • Loading branch information
0xLaurenzo authored Mar 5, 2024
1 parent 8a8f655 commit 756c7a1
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions smart-contracts/contracts/cl-vault/src/vault/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub fn execute_claim_strategist_rewards(
deps: DepsMut,
info: MessageInfo,
) -> ContractResult<Response> {
let range_admin = RANGE_ADMIN.load(deps.storage)?;
if info.sender != range_admin {
let allowed_claimer = VAULT_CONFIG.load(deps.storage)?.treasury;
if info.sender != allowed_claimer {
return Err(ContractError::Unauthorized {});
}

Expand All @@ -51,7 +51,7 @@ pub fn execute_claim_strategist_rewards(
Ok(Response::new()
.add_attribute("rewards", format!("{:?}", rewards.coins()))
.add_message(BankMsg::Send {
to_address: range_admin.to_string(),
to_address: allowed_claimer.to_string(),
amount: sort_tokens(rewards.coins()),
}))
}
Expand Down Expand Up @@ -171,7 +171,7 @@ mod tests {

#[test]
fn test_execute_claim_strategist_rewards_success() {
let range_admin = Addr::unchecked("bob");
let treasury = Addr::unchecked("bob");
let mut deps = mock_dependencies();
let rewards = vec![coin(12304151, "uosmo"), coin(5415123, "uatom")];
STRATEGIST_REWARDS
Expand All @@ -181,16 +181,23 @@ mod tests {
)
.unwrap();

RANGE_ADMIN
.save(deps.as_mut().storage, &range_admin)
VAULT_CONFIG
.save(
deps.as_mut().storage,
&VaultConfig {
performance_fee: Decimal::percent(20),
treasury: treasury.clone(),
swap_max_slippage: Decimal::percent(10),
},
)
.unwrap();

let response =
execute_claim_strategist_rewards(deps.as_mut(), mock_info(range_admin.as_str(), &[]))
execute_claim_strategist_rewards(deps.as_mut(), mock_info(treasury.as_str(), &[]))
.unwrap();
assert_eq!(
CosmosMsg::Bank(BankMsg::Send {
to_address: range_admin.to_string(),
to_address: treasury.to_string(),
amount: sort_tokens(rewards)
}),
response.messages[0].msg
Expand All @@ -199,15 +206,22 @@ mod tests {

#[test]
fn test_execute_claim_strategist_rewards_not_admin() {
let range_admin = Addr::unchecked("bob");
let treasury = Addr::unchecked("bob");
let mut deps = mock_dependencies();
let rewards = vec![coin(12304151, "uosmo"), coin(5415123, "uatom")];
STRATEGIST_REWARDS
.save(deps.as_mut().storage, &CoinList::from_coins(rewards))
.unwrap();

RANGE_ADMIN
.save(deps.as_mut().storage, &range_admin)
VAULT_CONFIG
.save(
deps.as_mut().storage,
&VaultConfig {
performance_fee: Decimal::percent(20),
treasury,
swap_max_slippage: Decimal::percent(10),
},
)
.unwrap();

let err =
Expand Down

0 comments on commit 756c7a1

Please sign in to comment.