You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

765 lines
37 KiB

#pragma version =0.4.1;
#pragma allow-post-modification;
#pragma compute-asm-ltr;
forall X -> X __tact_not_null(X x) inline { throw_if(128, null?(x)); return x; }
(cell, int) __tact_dict_delete(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";
(slice, int) __tact_dict_get(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";
global (int, slice, int, slice) __tact_context;
global cell __tact_context_sys;
(int, slice, int, slice) __tact_context_get() inline { return __tact_context; }
() __tact_verify_address(slice address) inline {
throw_unless(136, address.slice_bits() != 267);
}
builder __tact_store_bool(builder b, int v) inline {
b = b.store_int(v, 1);
return b;
}
(slice, slice) __tact_load_address(slice cs) inline {
slice raw = cs~load_msg_addr();
__tact_verify_address(raw);
return (cs, raw);
}
(slice, slice) __tact_load_address_opt(slice cs) inline {
slice raw = cs~load_msg_addr();
if (raw.preload_uint(2) != 0) {
__tact_verify_address(raw);
return (cs, raw);
} else {
return (cs, null());
}
}
builder __tact_store_address(builder b, slice address) inline {
__tact_verify_address(address);
b = b.store_slice(address);
return b;
}
builder __tact_store_address_opt(builder b, slice address) inline {
if (null?(address)) {
b = b.store_uint(0, 2);
return b;
} else {
return __tact_store_address(b, address);
}
}
(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl) inline {
if (null?(v)) {
var (r, ok) = idict_delete?(d, kl, k);
return (r, ());
} else {
return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ());
}
}
int __tact_dict_get_int_int(cell d, int kl, int k, int vl) inline {
var (r, ok) = idict_get?(d, kl, k);
if (ok) {
return r~load_int(vl);
} else {
return null();
}
}
(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v) inline {
if (null?(v)) {
var (r, ok) = idict_delete?(d, kl, k);
return (r, ());
} else {
return (idict_set_ref(d, kl, k, v), ());
}
}
cell __tact_dict_get_int_cell(cell d, int kl, int k) {
var (r, ok) = idict_get_ref?(d, kl, k);
if (ok) {
return r;
} else {
return null();
}
}
slice __tact_dict_get_int_slice(cell d, int kl, int k) inline {
var (r, ok) = idict_get?(d, kl, k);
if (ok) {
return r;
} else {
return null();
}
}
(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl) {
if (null?(v)) {
var (r, ok) = __tact_dict_delete(d, kl, k);
return (r, ());
} else {
return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ());
}
}
int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl) inline {
var (r, ok) = __tact_dict_get(d, kl, k);
if (ok) {
return r~load_int(vl);
} else {
return null();
}
}
int __tact_address_eq(slice a, slice b) inline {
return equal_slice_bits(a, b);
}
forall X0, X1, X2, X3, X4 -> tuple __tact_tuple_create_5((X0, X1, X2, X3, X4) v) asm "5 TUPLE";
forall X0, X1, X2, X3, X4 -> (X0, X1, X2, X3, X4) __tact_tuple_destroy_5(tuple v) asm "5 UNTUPLE";
forall X0, X1, X2, X3, X4, X5 -> tuple __tact_tuple_create_6((X0, X1, X2, X3, X4, X5) v) asm "6 TUPLE";
forall X0, X1, X2, X3, X4, X5 -> (X0, X1, X2, X3, X4, X5) __tact_tuple_destroy_6(tuple v) asm "6 UNTUPLE";
builder __gen_write_BlacklistWallet(builder build_0, (slice) v) inline {
var (v'wallet) = v;
build_0 = store_uint(build_0, 43811734, 32);
build_0 = __tact_store_address(build_0, v'wallet);
return build_0;
}
cell __gen_writecell_BlacklistWallet((slice) v) inline_ref {
return __gen_write_BlacklistWallet(begin_cell(), v).end_cell();
}
(slice, ((int, slice, int, int))) __gen_read_InitiateBlacklistVote(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 3909090059);
var v'adminIndex = sc_0~load_int(257);
var v'wallet = sc_0~__tact_load_address();
var v'quorum_percent = sc_0~load_int(257);
slice sc_1 = sc_0~load_ref().begin_parse();
var v'vote_time = sc_1~load_int(257);
return (sc_0, (v'adminIndex, v'wallet, v'quorum_percent, v'vote_time));
}
(slice, ((int, int, int))) __gen_read_InitiateLiquidationVote(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 301696559);
var v'adminIndex = sc_0~load_int(257);
var v'quorum_percent = sc_0~load_int(257);
var v'vote_time = sc_0~load_int(257);
return (sc_0, (v'adminIndex, v'quorum_percent, v'vote_time));
}
(slice, ((int))) __gen_read_FinishVote(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 710362179);
var v'voteId = sc_0~load_int(257);
return (sc_0, (v'voteId));
}
(slice, ((int, int, int))) __gen_read_VoteMsg(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 1493035179);
var v'voteId = sc_0~load_int(257);
var v'adminIndex = sc_0~load_int(257);
var v'vote = sc_0~load_int(257);
return (sc_0, (v'voteId, v'adminIndex, v'vote));
}
builder __gen_write_AddressList(builder build_0, (cell, int) v) inline {
var (v'addresses, v'length) = v;
build_0 = build_0.store_dict(v'addresses);
build_0 = build_0.store_int(v'length, 257);
return build_0;
}
(slice, ((cell, int))) __gen_read_AddressList(slice sc_0) inline {
var v'addresses = sc_0~load_dict();
var v'length = sc_0~load_int(257);
return (sc_0, (v'addresses, v'length));
}
builder __gen_write_Distribution(builder build_0, ((cell, int), cell) v) inline {
var ((v'addresses'addresses, v'addresses'length), v'percents) = v;
build_0 = __gen_write_AddressList(build_0, (v'addresses'addresses, v'addresses'length));
build_0 = build_0.store_dict(v'percents);
return build_0;
}
(slice, (((cell, int), cell))) __gen_read_Distribution(slice sc_0) inline {
var v'addresses = sc_0~__gen_read_AddressList();
var v'percents = sc_0~load_dict();
return (sc_0, (v'addresses, v'percents));
}
(slice, ((int, int, int, ((cell, int), cell)))) __gen_read_InitiateDistributionVote(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 2512227654);
var v'adminIndex = sc_0~load_int(257);
var v'quorum_percent = sc_0~load_int(257);
var v'vote_time = sc_0~load_int(257);
slice sc_1 = sc_0~load_ref().begin_parse();
var v'distribution = sc_1~__gen_read_Distribution();
return (sc_0, (v'adminIndex, v'quorum_percent, v'vote_time, v'distribution));
}
builder __gen_write_Unstake(builder build_0, (int) v) inline {
var (v'amount) = v;
build_0 = store_uint(build_0, 3125946401, 32);
build_0 = build_0.store_int(v'amount, 257);
return build_0;
}
cell __gen_writecell_Unstake((int) v) inline_ref {
return __gen_write_Unstake(begin_cell(), v).end_cell();
}
(slice, ((int))) __gen_read_Unstake(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 3125946401);
var v'amount = sc_0~load_int(257);
return (sc_0, (v'amount));
}
(slice, ((int))) __gen_read_RequestUnstake(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 3922648959);
var v'founderIndex = sc_0~load_int(257);
return (sc_0, (v'founderIndex));
}
(slice, ((int))) __gen_read_CollectProfit(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 1368467253);
var v'adminIndex = sc_0~load_int(257);
return (sc_0, (v'adminIndex));
}
builder __gen_write_Proposal(builder build_0, (int, slice, cell, int, cell) v) inline {
var (v'type, v'blacklistAddress, v'distribution_addresses, v'distribution_addresses_length, v'distribution_percents) = v;
build_0 = build_0.store_int(v'type, 257);
build_0 = __tact_store_address_opt(build_0, v'blacklistAddress);
build_0 = build_0.store_dict(v'distribution_addresses);
build_0 = ~ null?(v'distribution_addresses_length) ? build_0.store_int(true, 1).store_int(v'distribution_addresses_length, 257) : build_0.store_int(false, 1);
build_0 = build_0.store_dict(v'distribution_percents);
return build_0;
}
cell __gen_writecell_Proposal((int, slice, cell, int, cell) v) inline_ref {
return __gen_write_Proposal(begin_cell(), v).end_cell();
}
(slice, ((int, slice, cell, int, cell))) __gen_read_Proposal(slice sc_0) inline {
var v'type = sc_0~load_int(257);
var v'blacklistAddress = sc_0~__tact_load_address_opt();
var v'distribution_addresses = sc_0~load_dict();
var v'distribution_addresses_length = sc_0~load_int(1) ? sc_0~load_int(257) : null();
var v'distribution_percents = sc_0~load_dict();
return (sc_0, (v'type, v'blacklistAddress, v'distribution_addresses, v'distribution_addresses_length, v'distribution_percents));
}
tuple __gen_Proposal_as_optional(((int, slice, cell, int, cell)) v) inline {
var (v'type, v'blacklistAddress, v'distribution_addresses, v'distribution_addresses_length, v'distribution_percents) = v;
return __tact_tuple_create_5(v'type, v'blacklistAddress, v'distribution_addresses, v'distribution_addresses_length, v'distribution_percents);
}
tuple __gen_readopt_Proposal(cell cl) inline_ref {
if (null?(cl)) {
return null();
}
var sc = cl.begin_parse();
return __gen_Proposal_as_optional(sc~__gen_read_Proposal());
}
builder __gen_write_Vote(builder build_0, (int, cell, int, int, int, int) v) inline_ref {
var (v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result) = v;
build_0 = build_0.store_int(v'id, 257);
build_0 = build_0.store_dict(v'votes);
build_0 = build_0.store_int(v'vote_end, 257);
build_0 = build_0.store_int(v'quorum_percent, 257);
build_0 = build_0.store_int(v'ended, 1);
build_0 = ~ null?(v'result) ? build_0.store_int(true, 1).store_int(v'result, 1) : build_0.store_int(false, 1);
return build_0;
}
cell __gen_writecell_Vote((int, cell, int, int, int, int) v) inline_ref {
return __gen_write_Vote(begin_cell(), v).end_cell();
}
(slice, ((int, cell, int, int, int, int))) __gen_read_Vote(slice sc_0) inline_ref {
var v'id = sc_0~load_int(257);
var v'votes = sc_0~load_dict();
var v'vote_end = sc_0~load_int(257);
var v'quorum_percent = sc_0~load_int(257);
var v'ended = sc_0~load_int(1);
var v'result = sc_0~load_int(1) ? sc_0~load_int(1) : null();
return (sc_0, (v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result));
}
tuple __gen_Vote_as_optional(((int, cell, int, int, int, int)) v) inline {
var (v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result) = v;
return __tact_tuple_create_6(v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result);
}
tuple __gen_readopt_Vote(cell cl) inline_ref {
if (null?(cl)) {
return null();
}
var sc = cl.begin_parse();
return __gen_Vote_as_optional(sc~__gen_read_Vote());
}
builder __gen_write_Foundation(builder build_0, ((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) v) inline {
var ((v'founders'addresses, v'founders'length), ((v'admins'addresses'addresses, v'admins'addresses'length), v'admins'percents), v'tonb, v'votes, v'profits, v'proposals, v'n_votes) = v;
build_0 = __gen_write_AddressList(build_0, (v'founders'addresses, v'founders'length));
var build_1 = begin_cell();
build_1 = __gen_write_Distribution(build_1, ((v'admins'addresses'addresses, v'admins'addresses'length), v'admins'percents));
build_1 = __tact_store_address(build_1, v'tonb);
build_1 = build_1.store_dict(v'votes);
var build_2 = begin_cell();
build_2 = build_2.store_dict(v'profits);
build_2 = build_2.store_dict(v'proposals);
build_2 = build_2.store_int(v'n_votes, 257);
build_1 = store_ref(build_1, build_2.end_cell());
build_0 = store_ref(build_0, build_1.end_cell());
return build_0;
}
(slice, (((cell, int), ((cell, int), cell), slice, cell, cell, cell, int))) __gen_read_Foundation(slice sc_0) inline {
var v'founders = sc_0~__gen_read_AddressList();
slice sc_1 = sc_0~load_ref().begin_parse();
var v'admins = sc_1~__gen_read_Distribution();
var v'tonb = sc_1~__tact_load_address();
var v'votes = sc_1~load_dict();
slice sc_2 = sc_1~load_ref().begin_parse();
var v'profits = sc_2~load_dict();
var v'proposals = sc_2~load_dict();
var v'n_votes = sc_2~load_int(257);
return (sc_0, (v'founders, v'admins, v'tonb, v'votes, v'profits, v'proposals, v'n_votes));
}
(cell, int) __gen_AddressList_to_external(((cell, int)) v) inline {
var (v'addresses, v'length) = v;
return (v'addresses, v'length);
}
((int, slice, cell, int, cell)) __gen_Proposal_not_null(tuple v) inline {
throw_if(128, null?(v));
var (int vvv'type, slice vvv'blacklistAddress, cell vvv'distribution_addresses, int vvv'distribution_addresses_length, cell vvv'distribution_percents) = __tact_tuple_destroy_5(v);
return (vvv'type, vvv'blacklistAddress, vvv'distribution_addresses, vvv'distribution_addresses_length, vvv'distribution_percents);
}
((int, cell, int, int, int, int)) __gen_Vote_not_null(tuple v) inline {
throw_if(128, null?(v));
var (int vvv'id, cell vvv'votes, int vvv'vote_end, int vvv'quorum_percent, int vvv'ended, int vvv'result) = __tact_tuple_destroy_6(v);
return (vvv'id, vvv'votes, vvv'vote_end, vvv'quorum_percent, vvv'ended, vvv'result);
}
tuple __gen_Vote_to_tuple(((int, cell, int, int, int, int)) v) inline {
var (v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result) = v;
return __tact_tuple_create_6(v'id, v'votes, v'vote_end, v'quorum_percent, v'ended, v'result);
}
tuple __gen_Vote_opt_to_tuple(tuple v) inline {
if (null?(v)) { return null(); }
return __gen_Vote_to_tuple(__gen_Vote_not_null(v));
}
tuple __gen_Vote_opt_to_external(tuple v) inline {
var loaded = __gen_Vote_opt_to_tuple(v);
if (null?(loaded)) {
return null();
} else {
return (loaded);
}
}
((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) __gen_load_Foundation() inline {
slice sc = get_data().begin_parse();
__tact_context_sys = sc~load_ref();
return sc~__gen_read_Foundation();
}
() __gen_store_Foundation(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) v) impure inline {
builder b = begin_cell();
b = b.store_ref(__tact_context_sys);
b = __gen_write_Foundation(b, v);
set_data(b.end_cell());
}
() $send((int, slice, int, int, cell, cell, cell) $params) impure inline_ref {
var (($params'bounce, $params'to, $params'value, $params'mode, $params'body, $params'code, $params'data)) = $params;
builder $b = begin_cell();
$b = store_int($b, 1, 2);
$b = __tact_store_bool($b, $params'bounce);
$b = store_int($b, 0, 3);
$b = __tact_store_address($b, $params'to);
$b = store_coins($b, $params'value);
$b = store_int($b, 0, ((((1 + 4) + 4) + 64) + 32));
if (((~ null?($params'code)) | (~ null?($params'data)))) {
$b = __tact_store_bool($b, true);
builder $bc = begin_cell();
$bc = __tact_store_bool($bc, false);
$bc = __tact_store_bool($bc, false);
if ((~ null?($params'code))) {
$bc = __tact_store_bool($bc, true);
$bc = store_ref($bc, __tact_not_null($params'code));
} else {
$bc = __tact_store_bool($bc, false);
}
if ((~ null?($params'data))) {
$bc = __tact_store_bool($bc, true);
$bc = store_ref($bc, __tact_not_null($params'data));
} else {
$bc = __tact_store_bool($bc, false);
}
$bc = __tact_store_bool($bc, false);
$b = __tact_store_bool($b, true);
$b = store_ref($b, end_cell($bc));
} else {
$b = __tact_store_bool($b, false);
}
cell $body = $params'body;
if ((~ null?($body))) {
$b = __tact_store_bool($b, true);
$b = store_ref($b, __tact_not_null($body));
} else {
$b = __tact_store_bool($b, false);
}
cell $c = end_cell($b);
send_raw_message($c, $params'mode);
}
int $__gen_Foundation_numVotes(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self) impure inline_ref {
var ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes)) = $self;
return $self'n_votes;
}
_ $__gen_get_numVotes() method_id(70748) {
var self = __gen_load_Foundation();
var res = $__gen_Foundation_numVotes(self);
return res;
}
tuple $__gen_Foundation_nthVote(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, int $n) impure inline_ref {
var ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes)) = $self;
return __gen_readopt_Vote(__tact_dict_get_int_cell($self'votes, 257, $n));
}
_ $__gen_get_nthVote(int $$n) method_id(115768) {
int $n = $$n;
var self = __gen_load_Foundation();
var res = $__gen_Foundation_nthVote(self, $n);
return __gen_Vote_opt_to_external(res);
}
(cell, int) $__gen_Foundation_AdminList(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self) impure inline_ref {
var ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes)) = $self;
return ($self'admins'addresses'addresses, $self'admins'addresses'length);
}
_ $__gen_get_AdminList() method_id(125436) {
var self = __gen_load_Foundation();
var res = $__gen_Foundation_AdminList(self);
return __gen_AddressList_to_external(res);
}
cell $__gen_Foundation_AdminPercents(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self) impure inline_ref {
var ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes)) = $self;
return $self'admins'percents;
}
_ $__gen_get_AdminPercents() method_id(87676) {
var self = __gen_load_Foundation();
var res = $__gen_Foundation_AdminPercents(self);
return res;
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_FinishVote(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'voteId) = $msg;
throw_unless(46931, ($msg'voteId < $self'n_votes));
var ($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result) = __gen_Vote_not_null(__gen_readopt_Vote(__tact_dict_get_int_cell($self'votes, 257, $msg'voteId)));
throw_unless(30386, ($vote'ended == false));
throw_unless(34326, ($vote'vote_end >= now()));
int $n_yes = 0;
int $n_no = 0;
int $n_abstain = 0;
int $i = 0;
while (($i < $self'admins'addresses'length)) {
int $vote_i = __tact_not_null(__tact_dict_get_int_int($vote'votes, 257, $i, 257));
if (($vote_i == 1)) {
$n_yes = ($n_yes + __tact_not_null(__tact_dict_get_int_int($self'admins'percents, 257, $i, 257)));
} elseif (($vote_i == 2)) {
$n_no = ($n_no + __tact_not_null(__tact_dict_get_int_int($self'admins'percents, 257, $i, 257)));
} elseif (($vote_i == 0)) {
$n_abstain = ($n_abstain + __tact_not_null(__tact_dict_get_int_int($self'admins'percents, 257, $i, 257)));
}
$i = ($i + 1);
}
int $n_total = (($n_yes + $n_no) + $n_abstain);
int $present = $n_total;
if (($present < $vote'quorum_percent)) {
$vote'result = false;
} elseif (($n_yes > $n_no)) {
$vote'result = true;
} else {
$vote'result = false;
}
$vote'ended = true;
$self'votes~__tact_dict_set_int_cell(257, $msg'voteId, __gen_writecell_Vote(($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result)));
if (($vote'result == true)) {
var ($prop'type, $prop'blacklistAddress, $prop'distribution_addresses, $prop'distribution_addresses_length, $prop'distribution_percents) = __gen_Proposal_not_null(__gen_readopt_Proposal(__tact_dict_get_int_cell($self'proposals, 257, $msg'voteId)));
if (($prop'type == 0)) {
$send((true, $self'tonb, 0, 64, __gen_writecell_BlacklistWallet((__tact_not_null($prop'blacklistAddress))), null(), null()));
}
if (($prop'type == 1)) {
}
if (($prop'type == 2)) {
(($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents) = (($prop'distribution_addresses, __tact_not_null($prop'distribution_addresses_length)), $prop'distribution_percents);
}
}
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_VoteMsg(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int, int, int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'voteId, $msg'adminIndex, $msg'vote) = $msg;
throw_unless(49606, ($msg'adminIndex < $self'admins'addresses'length));
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(56549, __tact_address_eq($ctx'sender, __tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $msg'adminIndex)));
throw_unless(46931, ($msg'voteId < $self'n_votes));
var ($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result) = __gen_Vote_not_null(__gen_readopt_Vote(__tact_dict_get_int_cell($self'votes, 257, $msg'voteId)));
throw_unless(30386, ($vote'ended == false));
throw_unless(29720, (($msg'vote >= 0) & ($msg'vote <= 2)));
$vote'votes~__tact_dict_set_int_int(257, $msg'adminIndex, $msg'vote, 257);
$self'votes~__tact_dict_set_int_cell(257, $msg'voteId, __gen_writecell_Vote(($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result)));
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_InitiateBlacklistVote(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int, slice, int, int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'adminIndex, $msg'wallet, $msg'quorum_percent, $msg'vote_time) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(6873, __tact_address_eq($ctx'sender, __tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $msg'adminIndex)));
throw_unless(29821, ($ctx'value >= 1000000000));
throw_unless(19362, (($msg'quorum_percent > 20) & ($msg'quorum_percent <= 100)));
throw_unless(61070, (($msg'vote_time >= 0) & ($msg'vote_time < ((3 * 24) * 3600))));
var ($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents) = (0, $msg'wallet, null(), null(), null());
var ($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result) = ($self'n_votes, null(), (now() + $msg'vote_time), $msg'quorum_percent, false, null());
int $i = 0;
while (($i < $self'admins'addresses'length)) {
$vote'votes~__tact_dict_set_int_int(257, $i, (- 1), 257);
$i = ($i + 1);
}
$self'votes~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Vote(($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result)));
$self'proposals~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Proposal(($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents)));
$self'n_votes = ($self'n_votes + 1);
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_InitiateDistributionVote(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int, int, int, ((cell, int), cell)) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'adminIndex, $msg'quorum_percent, $msg'vote_time, (($msg'distribution'addresses'addresses, $msg'distribution'addresses'length), $msg'distribution'percents)) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(6873, __tact_address_eq($ctx'sender, __tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $msg'adminIndex)));
throw_unless(29821, ($ctx'value >= 1000000000));
throw_unless(19362, (($msg'quorum_percent > 20) & ($msg'quorum_percent <= 100)));
throw_unless(61070, (($msg'vote_time >= 0) & ($msg'vote_time < ((3 * 24) * 3600))));
var ($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents) = (2, null(), $msg'distribution'addresses'addresses, $msg'distribution'addresses'length, $msg'distribution'percents);
var ($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result) = ($self'n_votes, null(), (now() + $msg'vote_time), $msg'quorum_percent, false, null());
int $i = 0;
while (($i < $self'admins'addresses'length)) {
$vote'votes~__tact_dict_set_int_int(257, $i, (- 1), 257);
$i = ($i + 1);
}
$self'votes~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Vote(($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result)));
$self'proposals~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Proposal(($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents)));
$self'n_votes = ($self'n_votes + 1);
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_InitiateLiquidationVote(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int, int, int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'adminIndex, $msg'quorum_percent, $msg'vote_time) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(6873, __tact_address_eq($ctx'sender, __tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $msg'adminIndex)));
throw_unless(29821, ($ctx'value >= 1000000000));
throw_unless(19362, (($msg'quorum_percent > 85) & ($msg'quorum_percent <= 100)));
throw_unless(61070, (($msg'vote_time > 0) & ($msg'vote_time < ((3 * 24) * 3600))));
var ($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result) = ($self'n_votes, null(), (now() + $msg'vote_time), $msg'quorum_percent, false, null());
int $i = 0;
while (($i < $self'admins'addresses'length)) {
$vote'votes~__tact_dict_set_int_int(257, $i, (- 1), 257);
$i = ($i + 1);
}
var ($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents) = (1, null(), null(), null(), null());
$self'votes~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Vote(($vote'id, $vote'votes, $vote'vote_end, $vote'quorum_percent, $vote'ended, $vote'result)));
$self'proposals~__tact_dict_set_int_cell(257, $self'n_votes, __gen_writecell_Proposal(($proposal'type, $proposal'blacklistAddress, $proposal'distribution_addresses, $proposal'distribution_addresses_length, $proposal'distribution_percents)));
$self'n_votes = ($self'n_votes + 1);
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_Unstake(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'amount) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
if (__tact_address_eq($ctx'sender, $self'tonb)) {
int $value = $ctx'value;
int $i = 0;
while (($i < $self'admins'addresses'length)) {
slice $addr = __tact_not_null(__tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $i));
int $percent = __tact_not_null(__tact_dict_get_int_int($self'admins'percents, 257, $i, 257));
int $amount = (($value * $percent) / 100);
int $current_profit = 0;
int $profit_record = __tact_dict_get_slice_int($self'profits, 267, $addr, 257);
if ((~ null?($profit_record))) {
$current_profit = __tact_not_null($profit_record);
}
$self'profits~__tact_dict_set_slice_int(267, $addr, ($current_profit + $amount), 257);
$i = ($i + 1);
}
}
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_RequestUnstake(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'founderIndex) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(37444, __tact_address_eq(__tact_dict_get_int_slice($self'founders'addresses, 257, $msg'founderIndex), $ctx'sender));
$send((true, $self'tonb, 0, 64, __gen_writecell_Unstake((0)), null(), null()));
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive_CollectProfit(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self, (int) $msg) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
var ($msg'adminIndex) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(53981, __tact_address_eq(__tact_dict_get_int_slice($self'admins'addresses'addresses, 257, $msg'adminIndex), $ctx'sender));
int $profit = __tact_dict_get_slice_int($self'profits, 267, $ctx'sender, 257);
throw_unless(42983, (~ null?($profit)));
int $amount = __tact_not_null($profit);
$self'profits~__tact_dict_set_slice_int(267, $ctx'sender, 0, 257);
$send((true, $ctx'sender, ($amount - 150000000), 64, null(), null(), null()));
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
((((cell, int), ((cell, int), cell), slice, cell, cell, cell, int)), ()) $__gen_Foundation_receive(((cell, int), ((cell, int), cell), slice, cell, cell, cell, int) $self) impure inline {
var (($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes) = $self;
return ((($self'founders'addresses, $self'founders'length), (($self'admins'addresses'addresses, $self'admins'addresses'length), $self'admins'percents), $self'tonb, $self'votes, $self'profits, $self'proposals, $self'n_votes), ());
}
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
;; Parse incoming message
int op = 0;
if (slice_bits(in_msg) >= 32) {
op = in_msg.preload_uint(32);
}
var cs = in_msg_cell.begin_parse();
var msg_flags = cs~load_uint(4);
var msg_bounced = ((msg_flags & 1) == 1 ? true : false);
slice msg_sender_addr = cs~load_msg_addr();
__tact_context = (msg_bounced, msg_sender_addr, msg_value, cs);
;; Handle bounced messages
if (msg_bounced) {
return ();
}
;; Receive FinishVote message
if (op == 710362179) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_FinishVote();
self~$__gen_Foundation_receive_FinishVote(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive VoteMsg message
if (op == 1493035179) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_VoteMsg();
self~$__gen_Foundation_receive_VoteMsg(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive InitiateBlacklistVote message
if (op == 3909090059) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_InitiateBlacklistVote();
self~$__gen_Foundation_receive_InitiateBlacklistVote(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive InitiateDistributionVote message
if (op == 2512227654) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_InitiateDistributionVote();
self~$__gen_Foundation_receive_InitiateDistributionVote(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive InitiateLiquidationVote message
if (op == 301696559) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_InitiateLiquidationVote();
self~$__gen_Foundation_receive_InitiateLiquidationVote(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive Unstake message
if (op == 3125946401) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_Unstake();
self~$__gen_Foundation_receive_Unstake(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive RequestUnstake message
if (op == 3922648959) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_RequestUnstake();
self~$__gen_Foundation_receive_RequestUnstake(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive CollectProfit message
if (op == 1368467253) {
var self = __gen_load_Foundation();
var msg = in_msg~__gen_read_CollectProfit();
self~$__gen_Foundation_receive_CollectProfit(msg);
__gen_store_Foundation(self);
return ();
}
;; Receive empty message
if ((op == 0) & (slice_bits(in_msg) <= 32)) {
var self = __gen_load_Foundation();
self~$__gen_Foundation_receive();
__gen_store_Foundation(self);
return ();
}
throw(130);
}
_ supported_interfaces() method_id {
return (
"org.ton.introspection.v0"H >> 128,
"org.ton.abi.ipfs.v0"H >> 128
);
}
_ get_abi_ipfs() {
return "ipfs://QmTpahMZ5QmQr9Tr28bzZjVXyrZDoiJu5wUsDtQignQvds";
}