Skip to content

Fix of toncoin losses for gas on each tx in send_usd.fc #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions price_feeds/ton/send_usd/contracts/send_usd.fc
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,11 @@ const ERROR_UNAUTHORIZED = 401;
.store_uint(usd_amount, 16)
.end_cell();


int compute_fee = get_compute_fee(WORKCHAIN, gas_consumed());
int forward_amount = msg_value - compute_fee;

;; Create message to Pyth contract according to schema
cell msg = begin_cell()
.store_uint(0x18, 6) ;; nobounce
.store_slice(ctx_pyth_address) ;; pyth contract address
.store_coins(forward_amount) ;; forward amount minus fees
.store_coins(0) ;; forward amount can be 0 with tx mode == 64 (carry all remainings)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) ;; default message headers
.store_uint(PYTH_OP_PARSE_PRICE_FEED_UPDATES, 32) ;; pyth opcode
.store_ref(price_update_data) ;; update data
Expand All @@ -73,7 +69,7 @@ const ERROR_UNAUTHORIZED = 401;
.store_ref(custom_payload) ;; custom payload with recipient and amount
.end_cell();

send_raw_message(msg, 0);
send_raw_message(msg, 64);
}

;; Main message handler
Expand Down Expand Up @@ -151,4 +147,4 @@ const ERROR_UNAUTHORIZED = 401;
slice get_pyth_address() method_id {
load_data();
return ctx_pyth_address;
}
}