Skip to content

Commit

Permalink
Remove vote_investor as it's Carmine only
Browse files Browse the repository at this point in the history
  • Loading branch information
tensojka committed Nov 17, 2023
1 parent 14dad37 commit b1a1e44
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions src/proposals.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -355,51 +355,4 @@ mod Proposals {
return constants::MINUS_ONE; // yay_tally < nay_tally
}
}


fn vote_investor(prop_id: felt252, opinion: felt252) {
// Checks
assert(
(opinion == constants::MINUS_ONE) | (opinion == 1), 'opinion must be either 1 or -1'
);

let mut state = Governance::unsafe_new_contract_state();

let caller_addr = get_caller_address();
let investor_voting_power: u128 = state.investor_voting_power.read(prop_id);
assert(investor_voting_power != 0, 'caller not whitelisted investor');

let curr_vote_status: felt252 = read.@state.proposal_voted_by;
assert(curr_vote_status == 0, 'already voted');

assert_voting_in_progress(prop_id);

// Calculate real voting power
let gov_token_addr = state.governance_token_address.read();
let total_supply_u256: u256 = IERC20Dispatcher {
contract_address: gov_token_addr
}.totalSupply();
assert(total_supply_u256.high == 0, 'totalSupply weirdly high');
let total_supply: u128 = total_supply_u256.low;
let real_investor_voting_power: u128 = total_supply - constants::TEAM_TOKEN_BALANCE;
assert(total_supply >= constants::TEAM_TOKEN_BALANCE, 'total_supply<team token bal?');
let total_distributed_power: u128 = state.total_investor_distributed_power.read();
let vote_power = (real_investor_voting_power * investor_voting_power)
/ total_distributed_power;
assert(vote_power != 0, 'vote_power is zero');

// Cast vote
state.proposal_voted_by.write((prop_id, caller_addr), opinion);
if opinion == constants::MINUS_ONE {
let curr_votes: u128 = read.@state.proposal_total_nay;
let new_votes: u128 = curr_votes + vote_power;
assert(new_votes >= 0, 'new_votes negative');
state.proposal_total_nay.write(prop_id, new_votes.into());
} else {
let curr_votes: u128 = state.proposal_total_yay.read(prop_id);
let new_votes: u128 = curr_votes + vote_power;
assert(new_votes >= 0, 'new_votes negative');
state.proposal_total_yay.write(prop_id, new_votes.into());
}
}
}

0 comments on commit b1a1e44

Please sign in to comment.