Skip to content

Commit 851f948

Browse files
authored
Fix of toncoin losses for gas on each tx in send_usd.fc (#56)
get_compute_fee calc amount of gas used till this opcode -> all tvm instruction gas cost after this function will be paid by contract itself -> loss of ton
1 parent 1e75b51 commit 851f948

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

price_feeds/ton/send_usd/contracts/send_usd.fc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,11 @@ const ERROR_UNAUTHORIZED = 401;
5454
.store_uint(usd_amount, 16)
5555
.end_cell();
5656

57-
58-
int compute_fee = get_compute_fee(WORKCHAIN, gas_consumed());
59-
int forward_amount = msg_value - compute_fee;
60-
6157
;; Create message to Pyth contract according to schema
6258
cell msg = begin_cell()
6359
.store_uint(0x18, 6) ;; nobounce
6460
.store_slice(ctx_pyth_address) ;; pyth contract address
65-
.store_coins(forward_amount) ;; forward amount minus fees
61+
.store_coins(0) ;; forward amount can be 0 with tx mode == 64 (carry all remainings)
6662
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) ;; default message headers
6763
.store_uint(PYTH_OP_PARSE_PRICE_FEED_UPDATES, 32) ;; pyth opcode
6864
.store_ref(price_update_data) ;; update data
@@ -73,7 +69,7 @@ const ERROR_UNAUTHORIZED = 401;
7369
.store_ref(custom_payload) ;; custom payload with recipient and amount
7470
.end_cell();
7571

76-
send_raw_message(msg, 0);
72+
send_raw_message(msg, 64);
7773
}
7874

7975
;; Main message handler
@@ -151,4 +147,4 @@ const ERROR_UNAUTHORIZED = 401;
151147
slice get_pyth_address() method_id {
152148
load_data();
153149
return ctx_pyth_address;
154-
}
150+
}

0 commit comments

Comments
 (0)