Point program

Discover how many points you have on this page: https://0liqlend.com/points

Getters

// Displayed as "your points" in https://0liqlend.com/points
fn frontend_get_user_points(self: @ContractState, user: ContractAddress) -> u256 {
    self.user_points.read(user)
}
// Displayed as "total points" in https://0liqlend.com/points
fn frontend_get_total_points(self: @ContractState) -> u256 {
    self.total_points.read()
}
// Right now 100, will only get lower
fn set_points_multiplier(ref self: ContractState, multiplier: u256) {
    assert_is_admin();
    self.points_multiplier.write(multiplier);
}

Setters - when a loan is repaid

// Fee is 1% APR - so a loan of 1000$ over a year earns 10*multiplier points
let multiplier = self.points_multiplier.read();
// 1strk = .5USDC, hence the following line
if (category_id_from_address(lend_token) == STRK_CATEGORY) { multiplier = multiplier / 2; }
self.total_points.write(self.total_points.read() + 2 * fee * multiplier);
self.user_points.entry(lender).write(self.user_points.entry(lender).read() + fee * multiplier);
self.user_points.entry(borrower).write(self.user_points.entry(borrower).read() + fee * multiplier);

Last updated