UNPKG

rubic-sdk

Version:
32 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StonfiApiService = void 0; const injector_1 = require("../../../../../../../core/injector/injector"); const addresses_1 = require("../constants/addresses"); class StonfiApiService { static async makeQuoteRequest(from, to, slippage) { try { const srcTokenAddress = from.isNative ? addresses_1.BOUNCEABLE_TON_NATIVE_ADDRESS : from.address; const dstTokenAddress = to.isNative ? addresses_1.BOUNCEABLE_TON_NATIVE_ADDRESS : to.address; // @TODO Add dex_v2=true after stonfi-sdk update const queryParams = `offer_address=${srcTokenAddress} &ask_address=${dstTokenAddress} &units=${from.stringWeiAmount} &slippage_tolerance=${slippage} &referral_fee_bps=100 &referral_address=${addresses_1.STONFI_REFERRAL_ADDRESS}`; const res = await injector_1.Injector.httpClient.post(`${this.apiUrl}/swap/simulate?${queryParams}`); return { minAmountOutWei: res.min_ask_units, amountOutWei: res.ask_units, stonfiFee: res.fee_units }; } catch (err) { throw err; } } } exports.StonfiApiService = StonfiApiService; StonfiApiService.apiUrl = 'https://api.ston.fi/v1'; //# sourceMappingURL=stonfi-api-service.js.map