Skip to content

Commit

Permalink
fix: readme updates (#59)
Browse files Browse the repository at this point in the history
Update fee distributor README in response to questions raised in the oak-glow-v2 audit.

* fix: update fee distributor README
  • Loading branch information
Ruborcalor authored Apr 26, 2022
1 parent 4952ae2 commit 63344ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contracts/fee-distributor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The fee distributor contract supports `Claim`, `DistributeGlow`, and `Sweep` fun

### DistributeGlow

Distribute glow can be called to distribute all available glow in the gov contract to veGlow holders. Available glow means the Glow balance of the gov contract minus the amount reserved for polls and reserved for past glow distributions.
Distribute glow can be called to distribute all available glow in the fee distributor contract to veGlow holders. Available glow means the Glow balance of the fee distributor contract minus the amount reserved for past glow distributions.

Glow distribution works by making use of the `WEEKLY_TOKEN_DISTRIBUTION` map.

Expand Down
18 changes: 7 additions & 11 deletions contracts/fee-distributor/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub const DEFAULT_CLAIM_LIMIT: u32 = 20;
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
_env: Env,
info: MessageInfo,
_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
Expand All @@ -44,7 +44,6 @@ pub fn instantiate(
};

let state = State {
contract_addr: env.contract.address,
total_distributed_unclaimed_fees: Uint128::zero(),
};

Expand Down Expand Up @@ -102,12 +101,9 @@ pub fn distribute_glow(deps: DepsMut, env: Env) -> Result<Response, ContractErro

// Get the amount to distribute which includes the GLOW that has just been sent to the contractx
// but subtracts the amount reserved for previous unclaimed fee distribution.
let amount_to_distribute = query_token_balance(
&deps.querier,
config.glow_token,
state.contract_addr.clone(),
)?
.checked_sub(state.total_distributed_unclaimed_fees)?;
let amount_to_distribute =
query_token_balance(&deps.querier, config.glow_token, env.contract.address)?
.checked_sub(state.total_distributed_unclaimed_fees)?;

// Verify that the amount to distribute is non zero.
if amount_to_distribute == Uint128::zero() {
Expand Down Expand Up @@ -307,7 +303,7 @@ pub fn update_config(
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
match msg {
QueryMsg::Config {} => Ok(to_binary(&query_config(deps)?)?),
QueryMsg::State {} => Ok(to_binary(&query_state(deps)?)?),
QueryMsg::State {} => Ok(to_binary(&query_state(deps, env)?)?),
QueryMsg::Staker {
address,
fee_limit,
Expand All @@ -332,10 +328,10 @@ fn query_config(deps: Deps) -> Result<ConfigResponse, ContractError> {
})
}

fn query_state(deps: Deps) -> Result<StateResponse, ContractError> {
fn query_state(deps: Deps, env: Env) -> Result<StateResponse, ContractError> {
let state = STATE.load(deps.storage)?;
Ok(StateResponse {
contract_addr: state.contract_addr.to_string(),
contract_addr: env.contract.address.to_string(),
total_distributed_unclaimed_fees: state.total_distributed_unclaimed_fees,
})
}
Expand Down
1 change: 0 additions & 1 deletion contracts/fee-distributor/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ pub struct Config {

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
pub contract_addr: Addr,
pub total_distributed_unclaimed_fees: Uint128,
}
1 change: 0 additions & 1 deletion contracts/fee-distributor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ fn proper_initialization() {
assert_eq!(
state,
State {
contract_addr: deps.api.addr_validate(MOCK_CONTRACT_ADDR).unwrap(),
total_distributed_unclaimed_fees: Uint128::zero(),
}
);
Expand Down

0 comments on commit 63344ff

Please sign in to comment.