Skip to content

Commit 8ab18af

Browse files
committed
address comments
1 parent b55632b commit 8ab18af

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

price_feeds/ton/send_usd/contracts/send_usd.fc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ const ERROR_UNAUTHORIZED = 401;
104104

105105
if (op == PYTH_OP_PARSE_PRICE_FEED_UPDATES) {
106106
;; Check if sender is the official Pyth contract
107-
slice pyth_contract = "EQB4ZnrI5qsP_IUJgVJNwEGKLzZWsQOFhiaqDbD7pTt_f9oU"a;
108-
throw_unless(ERROR_UNAUTHORIZED, equal_slices_bits(sender_address, pyth_contract));
107+
throw_unless(ERROR_UNAUTHORIZED, equal_slices_bits(sender_address, ctx_pyth_address));
109108

110109
int num_price_feeds = in_msg_body~load_uint(8);
111110

@@ -139,7 +138,7 @@ const ERROR_UNAUTHORIZED = 401;
139138
;; Calculate: (1e9 * decimals * usd_amount) / price
140139
int ton_amount = ((1000000000 * decimals * usd_amount) / price);
141140

142-
;; Send TON to recipient
141+
;; Send TON to recipient, please note that extra transferred TON will be stored in this contract
143142
send_ton(recipient, ton_amount);
144143

145144
return ();

price_feeds/ton/send_usd/scripts/sendUsdPayment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export async function run(provider: NetworkProvider, args: string[]) {
3030

3131
// Calculate TON needed for USD amount
3232
// If TON price is $5.70, then 1 USD = 1/5.70 TON ≈ 0.1754385965 TON
33-
const priceDecimals = Math.abs(expo);
33+
const priceDecimals = -expo;
3434
const priceInUsd = Number(price) / 10 ** priceDecimals; // Convert price to actual USD value
3535
const tonAmount = (usdAmountNum / priceInUsd) * 1e9; // Convert to nanoTON
3636
const tonNeeded = BigInt(Math.floor(tonAmount));
3737

3838
// Add base fee (0.2 TON)
39-
const totalValue = toNano('0.2') + tonNeeded;
39+
const totalValue = toNano('0.4') + tonNeeded;
4040

4141
const updateData = Buffer.from(latestPriceUpdates.binary.data[0], 'hex');
4242
console.log('Update data:', updateData.toString('hex'));

0 commit comments

Comments
 (0)