Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Prepating to fix new release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alepacheco committed Jul 2, 2018
1 parent c755216 commit 0a0f964
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Resources exchange for EOS blockchain

## Work in progress, not ready for new eosio code release

### The aim of this contract is to create a self regulated market for CPU and Bandwidth on the eos blockchain

> This contract is under development
Expand Down
17 changes: 12 additions & 5 deletions resource_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ void resource_exchange::sellstake(account_name user, asset net, asset cpu) {
}
}

auto state = contract_state.get();
// TODO mark as liquid on the next cycle when refunded (not refunding here)
/* auto state = contract_state.get();
contract_state.set(
state_t{state.liquid_funds + (net + cpu),
state.total_stacked - (net + cpu), state.timestamp},
_self);
_self); */
}

/**
Expand All @@ -270,10 +271,13 @@ void resource_exchange::reset_delayed_tx(pendingtx tx) {
state.timestamp},
_self);
}

/**
* Cycle is run every 3.5 days, that way
**/
void resource_exchange::cycle() {
print("Run cycle\n");
auto secs_to_next = time_point_sec(60); // Run every minute
// * TODO tune
auto secs_to_next = time_point_sec(60*60*24*3.5); // TODO, every 3.5 days
auto secs_flexibility = time_point_sec(5);
auto state = contract_state.get();
time_point_sec this_time = time_point_sec(now());
Expand Down Expand Up @@ -395,6 +399,9 @@ void resource_exchange::matchbandwidth(account_name owner) {
}
if ((net_to_undelegate + cpu_to_undelegate) > asset(0)) {
undelegatebw(user->owner, net_to_undelegate, cpu_to_undelegate);
// TODO add to refunding
// * Remove from price and available calculation
// * Set as liquid on next cycle
}
}

Expand Down Expand Up @@ -468,7 +475,7 @@ double resource_exchange::calcosttoken() {
double cost_per_token = ((total * total / liquid) /
(total * PRICE_TUNE)); // TODO find optimal function

print("price token: ", asset(cost_per_token * 10000), "\n");
print("price token: ", asset(cost_per_token * 10000), "::", cost_per_token, "\n");
return cost_per_token;
}
} // namespace eosio
Expand Down

0 comments on commit 0a0f964

Please sign in to comment.