Ton

Форк
0
125 строк · 3.2 Кб
1
;;
2
;; Related contracts
3
;;
4

5
_ get_proxy() method_id {
6
    load_base_data();
7
    return ctx_proxy;
8
}
9

10
_ get_owner() method_id {
11
    load_base_data();
12
    return ctx_owner;
13
}
14

15
_ get_controller() method_id {
16
    load_base_data();
17
    return ctx_controller;
18
}
19

20
;;
21
;; Balances for controller
22
;;
23

24
_ get_unowned() method_id {
25
    load_base_data();
26
    var [balance, extra] = get_balance();
27
    return max(balance - owned_balance(), 0);
28
}
29

30
_ get_available() method_id {
31
    load_base_data();
32
    return ctx_balance - ctx_balance_sent;
33
}
34

35
;;
36
;; Pool and staking status
37
;;
38

39
_ get_staking_status() method_id {
40
    load_base_data();
41
    load_validator_data();
42

43
    var querySent = proxy_stored_query_id != 0;
44
    var unlocked = (proxy_stake_until == 0) | (proxy_stake_until < now());
45
    var until_val = proxy_stake_until;
46
    if ((proxy_stake_at != 0) & (proxy_stake_until != 0)) {
47
        until_val = lockup_lift_time(proxy_stake_at, proxy_stake_until);
48
        unlocked = unlocked & (until_val < now());
49
    }
50
    return (proxy_stake_at, until_val, proxy_stake_sent, querySent, unlocked, ctx_locked);
51
}
52

53
_ get_pool_status() method_id {
54
    load_base_data();
55
    load_member(owner_id());
56
    return (ctx_balance, ctx_balance_sent, ctx_balance_pending_deposits, ctx_balance_pending_withdraw, ctx_balance_withdraw);
57
}
58

59
;;
60
;; Params
61
;;
62
_ get_params() method_id {
63
    load_base_data();
64
    var (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price) = ctx_extras;
65
    return (enabled, udpates_enabled, min_stake, deposit_fee, withdraw_fee, pool_fee, receipt_price);
66
}
67

68
;;
69
;; Members
70
;;
71

72
_ get_member_balance(slice address) method_id {
73
    load_base_data();
74
    load_member(parse_work_addr(address));
75
    
76
    member_update_balance();
77
    return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
78
}
79

80
_ get_members_raw() method_id {
81
    load_base_data();
82
    return ctx_nominators;
83
}
84

85
_ get_members() method_id {
86
    load_base_data();
87

88
    ;; Init with owner
89
    load_member(owner_id());
90
    member_update_balance();
91
    var list = nil;
92
    list = cons([ctx_owner, ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
93

94
    ;; Iterate all members
95
    var id = -1;
96
    do {
97
        (id, var cs, var f) = ctx_nominators.udict_get_next?(256, id);
98

99
        ;; NOTE: One line condition doesn't work
100
        if (f) {
101
            if (id != owner_id()) {
102
                ;; For some reason loading member from slice doesn't work
103
                load_member(id);
104
                member_update_balance();
105
                list = cons([serialize_work_addr(id), ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw], list);
106
            }
107
        }
108
    } until (~ f);
109

110
    return list;
111
}
112

113
_ get_member(slice address) method_id {
114
    load_base_data();
115
    load_member(parse_work_addr(address));
116
    member_update_balance();
117
    return (ctx_member_balance, ctx_member_pending_deposit, ctx_member_pending_withdraw, ctx_member_withdraw);
118
}
119

120
_ supported_interfaces() method_id {
121
    return (
122
        123515602279859691144772641439386770278, ;; org.ton.introspection.v0
123
        256184278959413194623484780286929323492 ;; com.tonwhales.nominators:v0
124
    );
125
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.