teleton 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TQBJNXWV.js → chunk-4UDOZME7.js} +2782 -135
- package/dist/cli/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -3548,10 +3548,10 @@ async function generateWallet() {
|
|
|
3548
3548
|
workchain: 0,
|
|
3549
3549
|
publicKey: keyPair.publicKey
|
|
3550
3550
|
});
|
|
3551
|
-
const
|
|
3551
|
+
const address4 = wallet.address.toString({ bounceable: true, testOnly: false });
|
|
3552
3552
|
return {
|
|
3553
3553
|
version: "w5r1",
|
|
3554
|
-
address,
|
|
3554
|
+
address: address4,
|
|
3555
3555
|
publicKey: keyPair.publicKey.toString("hex"),
|
|
3556
3556
|
mnemonic,
|
|
3557
3557
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3590,10 +3590,10 @@ async function importWallet(mnemonic) {
|
|
|
3590
3590
|
workchain: 0,
|
|
3591
3591
|
publicKey: keyPair.publicKey
|
|
3592
3592
|
});
|
|
3593
|
-
const
|
|
3593
|
+
const address4 = wallet.address.toString({ bounceable: true, testOnly: false });
|
|
3594
3594
|
return {
|
|
3595
3595
|
version: "w5r1",
|
|
3596
|
-
address,
|
|
3596
|
+
address: address4,
|
|
3597
3597
|
publicKey: keyPair.publicKey.toString("hex"),
|
|
3598
3598
|
mnemonic,
|
|
3599
3599
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3603,12 +3603,12 @@ function getWalletAddress() {
|
|
|
3603
3603
|
const wallet = loadWallet();
|
|
3604
3604
|
return wallet?.address || null;
|
|
3605
3605
|
}
|
|
3606
|
-
async function getWalletBalance(
|
|
3606
|
+
async function getWalletBalance(address4) {
|
|
3607
3607
|
try {
|
|
3608
3608
|
const endpoint = await getHttpEndpoint({ network: "mainnet" });
|
|
3609
3609
|
const client = new TonClient({ endpoint });
|
|
3610
|
-
const { Address:
|
|
3611
|
-
const addressObj =
|
|
3610
|
+
const { Address: Address20 } = await import("@ton/core");
|
|
3611
|
+
const addressObj = Address20.parse(address4);
|
|
3612
3612
|
const balance = await client.getBalance(addressObj);
|
|
3613
3613
|
const balanceFormatted = fromNano(balance);
|
|
3614
3614
|
return {
|
|
@@ -3953,12 +3953,12 @@ Usage:
|
|
|
3953
3953
|
* /wallet - Check TON wallet balance
|
|
3954
3954
|
*/
|
|
3955
3955
|
async handleWalletCommand() {
|
|
3956
|
-
const
|
|
3957
|
-
if (!
|
|
3958
|
-
const result = await getWalletBalance(
|
|
3956
|
+
const address4 = getWalletAddress();
|
|
3957
|
+
if (!address4) return "\u274C No wallet configured.";
|
|
3958
|
+
const result = await getWalletBalance(address4);
|
|
3959
3959
|
if (!result) return "\u274C Failed to fetch balance.";
|
|
3960
3960
|
return `\u{1F48E} **${result.balance} TON**
|
|
3961
|
-
\u{1F4CD} \`${
|
|
3961
|
+
\u{1F4CD} \`${address4}\``;
|
|
3962
3962
|
}
|
|
3963
3963
|
/**
|
|
3964
3964
|
* /help - Show available commands
|
|
@@ -4183,8 +4183,8 @@ var MarketScraperService = class {
|
|
|
4183
4183
|
* Currently not implemented
|
|
4184
4184
|
* Would require modifications to support single-collection mode
|
|
4185
4185
|
*/
|
|
4186
|
-
async scrapeSingleCollection(
|
|
4187
|
-
console.log(`\u{1F504} Single collection scrape not yet implemented for ${
|
|
4186
|
+
async scrapeSingleCollection(address4) {
|
|
4187
|
+
console.log(`\u{1F504} Single collection scrape not yet implemented for ${address4}`);
|
|
4188
4188
|
return {
|
|
4189
4189
|
success: false,
|
|
4190
4190
|
error: "Single collection scrape not yet implemented"
|
|
@@ -10571,8 +10571,8 @@ var tonGetAddressTool = {
|
|
|
10571
10571
|
};
|
|
10572
10572
|
var tonGetAddressExecutor = async (params, context) => {
|
|
10573
10573
|
try {
|
|
10574
|
-
const
|
|
10575
|
-
if (!
|
|
10574
|
+
const address4 = getWalletAddress();
|
|
10575
|
+
if (!address4) {
|
|
10576
10576
|
return {
|
|
10577
10577
|
success: false,
|
|
10578
10578
|
error: "Wallet not initialized. Contact admin to generate wallet."
|
|
@@ -10581,8 +10581,8 @@ var tonGetAddressExecutor = async (params, context) => {
|
|
|
10581
10581
|
return {
|
|
10582
10582
|
success: true,
|
|
10583
10583
|
data: {
|
|
10584
|
-
address,
|
|
10585
|
-
message: `Your TON wallet address: ${
|
|
10584
|
+
address: address4,
|
|
10585
|
+
message: `Your TON wallet address: ${address4}`
|
|
10586
10586
|
}
|
|
10587
10587
|
};
|
|
10588
10588
|
} catch (error) {
|
|
@@ -10604,14 +10604,14 @@ var tonGetBalanceTool = {
|
|
|
10604
10604
|
};
|
|
10605
10605
|
var tonGetBalanceExecutor = async (params, context) => {
|
|
10606
10606
|
try {
|
|
10607
|
-
const
|
|
10608
|
-
if (!
|
|
10607
|
+
const address4 = getWalletAddress();
|
|
10608
|
+
if (!address4) {
|
|
10609
10609
|
return {
|
|
10610
10610
|
success: false,
|
|
10611
10611
|
error: "Wallet not initialized. Contact admin to generate wallet."
|
|
10612
10612
|
};
|
|
10613
10613
|
}
|
|
10614
|
-
const balance = await getWalletBalance(
|
|
10614
|
+
const balance = await getWalletBalance(address4);
|
|
10615
10615
|
if (!balance) {
|
|
10616
10616
|
return {
|
|
10617
10617
|
success: false,
|
|
@@ -10621,7 +10621,7 @@ var tonGetBalanceExecutor = async (params, context) => {
|
|
|
10621
10621
|
return {
|
|
10622
10622
|
success: true,
|
|
10623
10623
|
data: {
|
|
10624
|
-
address,
|
|
10624
|
+
address: address4,
|
|
10625
10625
|
balance: balance.balance,
|
|
10626
10626
|
balanceNano: balance.balanceNano,
|
|
10627
10627
|
message: `Your wallet balance: ${balance.balance} TON`,
|
|
@@ -10825,14 +10825,14 @@ function parseMessageBody(body) {
|
|
|
10825
10825
|
}
|
|
10826
10826
|
var tonGetTransactionsExecutor = async (params, context) => {
|
|
10827
10827
|
try {
|
|
10828
|
-
const { address, limit = 10 } = params;
|
|
10828
|
+
const { address: address4, limit = 10 } = params;
|
|
10829
10829
|
let addressObj;
|
|
10830
10830
|
try {
|
|
10831
|
-
addressObj = Address2.parse(
|
|
10831
|
+
addressObj = Address2.parse(address4);
|
|
10832
10832
|
} catch (e) {
|
|
10833
10833
|
return {
|
|
10834
10834
|
success: false,
|
|
10835
|
-
error: `Invalid address: ${
|
|
10835
|
+
error: `Invalid address: ${address4}`
|
|
10836
10836
|
};
|
|
10837
10837
|
}
|
|
10838
10838
|
const endpoint = await getHttpEndpoint3({ network: "mainnet" });
|
|
@@ -10962,7 +10962,7 @@ var tonGetTransactionsExecutor = async (params, context) => {
|
|
|
10962
10962
|
return {
|
|
10963
10963
|
success: true,
|
|
10964
10964
|
data: {
|
|
10965
|
-
address,
|
|
10965
|
+
address: address4,
|
|
10966
10966
|
transactions: formatted
|
|
10967
10967
|
}
|
|
10968
10968
|
};
|
|
@@ -12016,11 +12016,2662 @@ var jettonBalancesExecutor = async (params, context) => {
|
|
|
12016
12016
|
// src/agent/tools/jetton/swap.ts
|
|
12017
12017
|
import { Type as Type81 } from "@sinclair/typebox";
|
|
12018
12018
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey7 } from "@ton/crypto";
|
|
12019
|
-
import { WalletContractV5R1 as WalletContractV5R17, TonClient as TonClient9, toNano as
|
|
12019
|
+
import { WalletContractV5R1 as WalletContractV5R17, TonClient as TonClient9, toNano as toNano18, internal as internal6 } from "@ton/ton";
|
|
12020
12020
|
import { SendMode as SendMode6 } from "@ton/core";
|
|
12021
12021
|
import { getHttpEndpoint as getHttpEndpoint9 } from "@orbs-network/ton-access";
|
|
12022
|
-
|
|
12023
|
-
|
|
12022
|
+
|
|
12023
|
+
// node_modules/@ston-fi/sdk/dist/chunk-HNMPFVZW.js
|
|
12024
|
+
import { Address as Address8, address } from "@ton/ton";
|
|
12025
|
+
function toAddress(addressValue) {
|
|
12026
|
+
if (addressValue instanceof Address8) {
|
|
12027
|
+
return addressValue;
|
|
12028
|
+
}
|
|
12029
|
+
return address(addressValue.toString());
|
|
12030
|
+
}
|
|
12031
|
+
|
|
12032
|
+
// node_modules/@ston-fi/sdk/dist/chunk-3QLJQGLC.js
|
|
12033
|
+
var Contract = class {
|
|
12034
|
+
address;
|
|
12035
|
+
constructor(address4, options) {
|
|
12036
|
+
this.address = toAddress(address4);
|
|
12037
|
+
}
|
|
12038
|
+
static create(address4) {
|
|
12039
|
+
return new this(address4);
|
|
12040
|
+
}
|
|
12041
|
+
};
|
|
12042
|
+
|
|
12043
|
+
// node_modules/@ston-fi/sdk/dist/chunk-ZZPZXK37.js
|
|
12044
|
+
import { beginCell as beginCell4 } from "@ton/ton";
|
|
12045
|
+
var JettonMinter = class extends Contract {
|
|
12046
|
+
async getWalletAddress(provider, ownerAddress) {
|
|
12047
|
+
const result = await provider.get("get_wallet_address", [
|
|
12048
|
+
{
|
|
12049
|
+
type: "slice",
|
|
12050
|
+
cell: beginCell4().storeAddress(toAddress(ownerAddress)).endCell()
|
|
12051
|
+
}
|
|
12052
|
+
]);
|
|
12053
|
+
return result.stack.readAddress();
|
|
12054
|
+
}
|
|
12055
|
+
async getJettonData(provider) {
|
|
12056
|
+
const result = await provider.get("get_jetton_data", []);
|
|
12057
|
+
const jettonData = {
|
|
12058
|
+
totalSupply: result.stack.readBigNumber(),
|
|
12059
|
+
canIncSupply: Boolean(result.stack.readNumber()),
|
|
12060
|
+
adminAddress: result.stack.readAddressOpt(),
|
|
12061
|
+
contentRaw: result.stack.readCell(),
|
|
12062
|
+
jettonWalletCode: result.stack.readCell()
|
|
12063
|
+
};
|
|
12064
|
+
return jettonData;
|
|
12065
|
+
}
|
|
12066
|
+
};
|
|
12067
|
+
|
|
12068
|
+
// node_modules/@ston-fi/sdk/dist/chunk-6OHMCTKH.js
|
|
12069
|
+
var JettonWallet = class extends Contract {
|
|
12070
|
+
async getBalance(provider) {
|
|
12071
|
+
const state = await provider.getState();
|
|
12072
|
+
if (state.state.type !== "active") {
|
|
12073
|
+
return BigInt(0);
|
|
12074
|
+
}
|
|
12075
|
+
const { balance } = await this.getWalletData(provider);
|
|
12076
|
+
return balance;
|
|
12077
|
+
}
|
|
12078
|
+
async getWalletData(provider) {
|
|
12079
|
+
const result = await provider.get("get_wallet_data", []);
|
|
12080
|
+
return {
|
|
12081
|
+
balance: result.stack.readBigNumber(),
|
|
12082
|
+
ownerAddress: result.stack.readAddress(),
|
|
12083
|
+
jettonMasterAddress: result.stack.readAddress(),
|
|
12084
|
+
jettonWalletCode: result.stack.readCell()
|
|
12085
|
+
};
|
|
12086
|
+
}
|
|
12087
|
+
};
|
|
12088
|
+
|
|
12089
|
+
// node_modules/@ston-fi/sdk/dist/chunk-7OWKQS2D.js
|
|
12090
|
+
import { beginCell as beginCell5 } from "@ton/ton";
|
|
12091
|
+
function createJettonTransferMessage(params) {
|
|
12092
|
+
const builder = beginCell5();
|
|
12093
|
+
builder.storeUint(260734629, 32);
|
|
12094
|
+
builder.storeUint(params.queryId, 64);
|
|
12095
|
+
builder.storeCoins(BigInt(params.amount));
|
|
12096
|
+
builder.storeAddress(toAddress(params.destination));
|
|
12097
|
+
builder.storeAddress(
|
|
12098
|
+
params.responseDestination ? toAddress(params.responseDestination) : void 0
|
|
12099
|
+
);
|
|
12100
|
+
if (params.customPayload) {
|
|
12101
|
+
builder.storeBit(true);
|
|
12102
|
+
builder.storeRef(params.customPayload);
|
|
12103
|
+
} else {
|
|
12104
|
+
builder.storeBit(false);
|
|
12105
|
+
}
|
|
12106
|
+
builder.storeCoins(BigInt(params.forwardTonAmount));
|
|
12107
|
+
if (params.forwardPayload) {
|
|
12108
|
+
builder.storeBit(true);
|
|
12109
|
+
builder.storeRef(params.forwardPayload);
|
|
12110
|
+
} else {
|
|
12111
|
+
builder.storeBit(false);
|
|
12112
|
+
}
|
|
12113
|
+
return builder.endCell();
|
|
12114
|
+
}
|
|
12115
|
+
|
|
12116
|
+
// node_modules/@ston-fi/sdk/dist/chunk-MEGJZKYP.js
|
|
12117
|
+
var pTON_VERSION = {
|
|
12118
|
+
v1: "v1",
|
|
12119
|
+
v2_1: "v2_1"
|
|
12120
|
+
};
|
|
12121
|
+
|
|
12122
|
+
// node_modules/@ston-fi/sdk/dist/chunk-G6J4NHH6.js
|
|
12123
|
+
var DEX_OP_CODES = {
|
|
12124
|
+
SWAP: 630424929,
|
|
12125
|
+
PROVIDE_LP: 4244235663,
|
|
12126
|
+
DIRECT_ADD_LIQUIDITY: 1291331587,
|
|
12127
|
+
REFUND_ME: 200537159,
|
|
12128
|
+
RESET_GAS: 1117846339,
|
|
12129
|
+
COLLECT_FEES: 533429565,
|
|
12130
|
+
BURN: 1499400124
|
|
12131
|
+
};
|
|
12132
|
+
var ROUTER_ADDRESS = "EQB3ncyBUTjZUA5EnFKR5_EnOMI9V1tTEAAPaiU71gc4TiUt";
|
|
12133
|
+
|
|
12134
|
+
// node_modules/@ston-fi/sdk/dist/chunk-4KVHWM75.js
|
|
12135
|
+
var DEX_VERSION = {
|
|
12136
|
+
v1: "v1",
|
|
12137
|
+
/**
|
|
12138
|
+
* We recommend using `v2_1` contracts
|
|
12139
|
+
* only for withdrawal functionality on already deployed contracts.
|
|
12140
|
+
* @see https://t.me/stonfidex/712
|
|
12141
|
+
*/
|
|
12142
|
+
v2_1: "v2_1",
|
|
12143
|
+
v2_2: "v2_2"
|
|
12144
|
+
};
|
|
12145
|
+
var DEX_TYPE = {
|
|
12146
|
+
CPI: "constant_product",
|
|
12147
|
+
Stable: "stableswap",
|
|
12148
|
+
WCPI: "weighted_const_product",
|
|
12149
|
+
WStable: "weighted_stableswap"
|
|
12150
|
+
};
|
|
12151
|
+
|
|
12152
|
+
// node_modules/@ston-fi/sdk/dist/chunk-ZPXELCC2.js
|
|
12153
|
+
import {
|
|
12154
|
+
beginCell as beginCell6,
|
|
12155
|
+
toNano as toNano6
|
|
12156
|
+
} from "@ton/ton";
|
|
12157
|
+
var LpAccountV1 = class _LpAccountV1 extends Contract {
|
|
12158
|
+
static version = DEX_VERSION.v1;
|
|
12159
|
+
static gasConstants = {
|
|
12160
|
+
refund: toNano6("0.3"),
|
|
12161
|
+
directAddLp: toNano6("0.3"),
|
|
12162
|
+
resetGas: toNano6("0.3")
|
|
12163
|
+
};
|
|
12164
|
+
gasConstants;
|
|
12165
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
12166
|
+
super(address4, options);
|
|
12167
|
+
this.gasConstants = {
|
|
12168
|
+
..._LpAccountV1.gasConstants,
|
|
12169
|
+
...gasConstants
|
|
12170
|
+
};
|
|
12171
|
+
}
|
|
12172
|
+
async createRefundBody(params) {
|
|
12173
|
+
return beginCell6().storeUint(DEX_OP_CODES.REFUND_ME, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
12174
|
+
}
|
|
12175
|
+
/**
|
|
12176
|
+
* Build all data required to execute a `refund_me` transaction.
|
|
12177
|
+
*
|
|
12178
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12179
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12180
|
+
*
|
|
12181
|
+
* @returns {SenderArguments} all data required to execute a `refund_me` transaction.
|
|
12182
|
+
*/
|
|
12183
|
+
async getRefundTxParams(provider, params) {
|
|
12184
|
+
const to = this.address;
|
|
12185
|
+
const body = await this.createRefundBody({
|
|
12186
|
+
queryId: params?.queryId
|
|
12187
|
+
});
|
|
12188
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.refund);
|
|
12189
|
+
return { to, value, body };
|
|
12190
|
+
}
|
|
12191
|
+
async sendRefund(provider, via, params) {
|
|
12192
|
+
const txParams = await this.getRefundTxParams(provider, params);
|
|
12193
|
+
return via.send(txParams);
|
|
12194
|
+
}
|
|
12195
|
+
async createDirectAddLiquidityBody(params) {
|
|
12196
|
+
return beginCell6().storeUint(DEX_OP_CODES.DIRECT_ADD_LIQUIDITY, 32).storeUint(params?.queryId ?? 0, 64).storeCoins(BigInt(params.amount0)).storeCoins(BigInt(params.amount1)).storeCoins(BigInt(params.minimumLpToMint ?? 1)).endCell();
|
|
12197
|
+
}
|
|
12198
|
+
/**
|
|
12199
|
+
* Build all data required to execute a `direct_add_liquidity` transaction.
|
|
12200
|
+
*
|
|
12201
|
+
* @param {bigint | number} params.amount0 - Amount of the first Jetton tokens (in basic token units)
|
|
12202
|
+
* @param {bigint | number} params.amount1 - Amount of the second Jetton tokens (in basic token units)
|
|
12203
|
+
* @param {bigint | number | undefined} params.minimumLpToMint - Optional; minimum amount of received liquidity tokens (in basic token units)
|
|
12204
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12205
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12206
|
+
*
|
|
12207
|
+
* @returns {SenderArguments} all data required to execute a `direct_add_liquidity` transaction.
|
|
12208
|
+
*/
|
|
12209
|
+
async getDirectAddLiquidityTxParams(provider, params) {
|
|
12210
|
+
const to = this.address;
|
|
12211
|
+
const body = await this.createDirectAddLiquidityBody({
|
|
12212
|
+
amount0: params.amount0,
|
|
12213
|
+
amount1: params.amount1,
|
|
12214
|
+
minimumLpToMint: params.minimumLpToMint,
|
|
12215
|
+
queryId: params.queryId
|
|
12216
|
+
});
|
|
12217
|
+
const value = BigInt(params.gasAmount ?? this.gasConstants.directAddLp);
|
|
12218
|
+
return { to, value, body };
|
|
12219
|
+
}
|
|
12220
|
+
async sendDirectAddLiquidity(provider, via, params) {
|
|
12221
|
+
const txParams = await this.getDirectAddLiquidityTxParams(provider, params);
|
|
12222
|
+
return via.send(txParams);
|
|
12223
|
+
}
|
|
12224
|
+
async createResetGasBody(params) {
|
|
12225
|
+
return beginCell6().storeUint(DEX_OP_CODES.RESET_GAS, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
12226
|
+
}
|
|
12227
|
+
/**
|
|
12228
|
+
* Build all data required to execute a `reset_gas` transaction.
|
|
12229
|
+
*
|
|
12230
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12231
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12232
|
+
*
|
|
12233
|
+
* @returns {SenderArguments} all data required to execute a `reset_gas` transaction.
|
|
12234
|
+
*/
|
|
12235
|
+
async getResetGasTxParams(provider, params) {
|
|
12236
|
+
const to = this.address;
|
|
12237
|
+
const body = await this.createResetGasBody({
|
|
12238
|
+
queryId: params?.queryId
|
|
12239
|
+
});
|
|
12240
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.resetGas);
|
|
12241
|
+
return { to, value, body };
|
|
12242
|
+
}
|
|
12243
|
+
async sendResetGas(provider, via, params) {
|
|
12244
|
+
const txParams = await this.getResetGasTxParams(provider, params);
|
|
12245
|
+
return via.send(txParams);
|
|
12246
|
+
}
|
|
12247
|
+
/**
|
|
12248
|
+
* @returns structure containing current state of the lp account.
|
|
12249
|
+
*/
|
|
12250
|
+
async getLpAccountData(provider) {
|
|
12251
|
+
const result = await provider.get("get_lp_account_data", []);
|
|
12252
|
+
return {
|
|
12253
|
+
userAddress: result.stack.readAddress(),
|
|
12254
|
+
poolAddress: result.stack.readAddress(),
|
|
12255
|
+
amount0: result.stack.readBigNumber(),
|
|
12256
|
+
amount1: result.stack.readBigNumber()
|
|
12257
|
+
};
|
|
12258
|
+
}
|
|
12259
|
+
};
|
|
12260
|
+
|
|
12261
|
+
// node_modules/@ston-fi/sdk/dist/chunk-OREDCISV.js
|
|
12262
|
+
import {
|
|
12263
|
+
beginCell as beginCell7,
|
|
12264
|
+
toNano as toNano7
|
|
12265
|
+
} from "@ton/ton";
|
|
12266
|
+
var PoolV1 = class _PoolV1 extends JettonMinter {
|
|
12267
|
+
static version = DEX_VERSION.v1;
|
|
12268
|
+
static gasConstants = {
|
|
12269
|
+
collectFees: toNano7("1.1"),
|
|
12270
|
+
burn: toNano7("0.5")
|
|
12271
|
+
};
|
|
12272
|
+
gasConstants;
|
|
12273
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
12274
|
+
super(address4, options);
|
|
12275
|
+
this.gasConstants = {
|
|
12276
|
+
..._PoolV1.gasConstants,
|
|
12277
|
+
...gasConstants
|
|
12278
|
+
};
|
|
12279
|
+
}
|
|
12280
|
+
async createCollectFeesBody(params) {
|
|
12281
|
+
return beginCell7().storeUint(DEX_OP_CODES.COLLECT_FEES, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
12282
|
+
}
|
|
12283
|
+
/**
|
|
12284
|
+
* Build all data required to execute a `collect_fees` transaction.
|
|
12285
|
+
*
|
|
12286
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12287
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12288
|
+
*
|
|
12289
|
+
* @returns {SenderArguments} all data required to execute a `collect_fees` transaction.
|
|
12290
|
+
*/
|
|
12291
|
+
async getCollectFeeTxParams(provider, params) {
|
|
12292
|
+
const to = this.address;
|
|
12293
|
+
const body = await this.createCollectFeesBody({
|
|
12294
|
+
queryId: params?.queryId
|
|
12295
|
+
});
|
|
12296
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.collectFees);
|
|
12297
|
+
return { to, value, body };
|
|
12298
|
+
}
|
|
12299
|
+
async sendCollectFees(provider, via, params) {
|
|
12300
|
+
const txParams = await this.getCollectFeeTxParams(provider, params);
|
|
12301
|
+
return via.send(txParams);
|
|
12302
|
+
}
|
|
12303
|
+
async createBurnBody(params) {
|
|
12304
|
+
return beginCell7().storeUint(DEX_OP_CODES.BURN, 32).storeUint(params?.queryId ?? 0, 64).storeCoins(BigInt(params.amount)).storeAddress(toAddress(params.responseAddress)).storeMaybeRef().endCell();
|
|
12305
|
+
}
|
|
12306
|
+
/**
|
|
12307
|
+
* Build all data required to execute a `burn` transaction.
|
|
12308
|
+
*
|
|
12309
|
+
* @param {bigint | number} params.amount - Amount of lp tokens to burn (in basic token units)
|
|
12310
|
+
* @param {Address | string} params.responseAddress - Address of a user
|
|
12311
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12312
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12313
|
+
*
|
|
12314
|
+
* @returns {SenderArguments} all data required to execute a `burn` transaction.
|
|
12315
|
+
*/
|
|
12316
|
+
async getBurnTxParams(provider, params) {
|
|
12317
|
+
const [to, body] = await Promise.all([
|
|
12318
|
+
this.getWalletAddress(provider, params.responseAddress),
|
|
12319
|
+
this.createBurnBody({
|
|
12320
|
+
amount: params.amount,
|
|
12321
|
+
responseAddress: params.responseAddress,
|
|
12322
|
+
queryId: params.queryId
|
|
12323
|
+
})
|
|
12324
|
+
]);
|
|
12325
|
+
const value = BigInt(params.gasAmount ?? this.gasConstants.burn);
|
|
12326
|
+
return { to, value, body };
|
|
12327
|
+
}
|
|
12328
|
+
async sendBurn(provider, via, params) {
|
|
12329
|
+
const txParams = await this.getBurnTxParams(provider, params);
|
|
12330
|
+
return via.send(txParams);
|
|
12331
|
+
}
|
|
12332
|
+
/**
|
|
12333
|
+
* Estimate the expected result of the amount of jettonWallet tokens swapped to the other token of the pool
|
|
12334
|
+
*
|
|
12335
|
+
* @param {bigint | number} params.amount - Amount of tokens to swap (in basic token units)
|
|
12336
|
+
* @param {Address | string} params.jettonWallet - jetton wallet address (owned by the router)
|
|
12337
|
+
*
|
|
12338
|
+
* @returns structure with the expected result of a token swap
|
|
12339
|
+
*/
|
|
12340
|
+
async getExpectedOutputs(provider, params) {
|
|
12341
|
+
const result = await provider.get("get_expected_outputs", [
|
|
12342
|
+
{ type: "int", value: BigInt(params.amount) },
|
|
12343
|
+
{
|
|
12344
|
+
type: "slice",
|
|
12345
|
+
cell: beginCell7().storeAddress(toAddress(params.jettonWallet)).endCell()
|
|
12346
|
+
}
|
|
12347
|
+
]);
|
|
12348
|
+
return {
|
|
12349
|
+
jettonToReceive: result.stack.readBigNumber(),
|
|
12350
|
+
protocolFeePaid: result.stack.readBigNumber(),
|
|
12351
|
+
refFeePaid: result.stack.readBigNumber()
|
|
12352
|
+
};
|
|
12353
|
+
}
|
|
12354
|
+
/**
|
|
12355
|
+
* Estimate an expected amount of lp tokens minted when providing liquidity.
|
|
12356
|
+
*
|
|
12357
|
+
* @param {bigint | number} params.amount0 - Amount of tokens for the first Jetton (in basic token units)
|
|
12358
|
+
* @param {bigint | number} params.amount1 - Amount of tokens for the second Jetton (in basic token units)
|
|
12359
|
+
*
|
|
12360
|
+
* @returns {bigint} an estimated amount of liquidity tokens to be minted
|
|
12361
|
+
*/
|
|
12362
|
+
async getExpectedTokens(provider, params) {
|
|
12363
|
+
const result = await provider.get("get_expected_tokens", [
|
|
12364
|
+
{ type: "int", value: BigInt(params.amount0) },
|
|
12365
|
+
{ type: "int", value: BigInt(params.amount1) }
|
|
12366
|
+
]);
|
|
12367
|
+
return result.stack.readBigNumber();
|
|
12368
|
+
}
|
|
12369
|
+
/**
|
|
12370
|
+
* Estimate expected liquidity freed upon burning liquidity tokens.
|
|
12371
|
+
*
|
|
12372
|
+
* @param {bigint | number} params.jettonAmount - Amount of liquidity tokens (in basic token units)
|
|
12373
|
+
*
|
|
12374
|
+
* @returns structure with expected freed liquidity
|
|
12375
|
+
*/
|
|
12376
|
+
async getExpectedLiquidity(provider, params) {
|
|
12377
|
+
const result = await provider.get("get_expected_liquidity", [
|
|
12378
|
+
{ type: "int", value: BigInt(params.jettonAmount) }
|
|
12379
|
+
]);
|
|
12380
|
+
return {
|
|
12381
|
+
amount0: result.stack.readBigNumber(),
|
|
12382
|
+
amount1: result.stack.readBigNumber()
|
|
12383
|
+
};
|
|
12384
|
+
}
|
|
12385
|
+
/**
|
|
12386
|
+
* @param {Address | string} params.ownerAddress - Address of a user
|
|
12387
|
+
*
|
|
12388
|
+
* @returns {Address} the lp account address of a user
|
|
12389
|
+
*/
|
|
12390
|
+
async getLpAccountAddress(provider, params) {
|
|
12391
|
+
const result = await provider.get("get_lp_account_address", [
|
|
12392
|
+
{
|
|
12393
|
+
type: "slice",
|
|
12394
|
+
cell: beginCell7().storeAddress(toAddress(params.ownerAddress)).endCell()
|
|
12395
|
+
}
|
|
12396
|
+
]);
|
|
12397
|
+
return result.stack.readAddress();
|
|
12398
|
+
}
|
|
12399
|
+
/**
|
|
12400
|
+
* @param {Address | string} params.ownerAddress - Address of a user
|
|
12401
|
+
*
|
|
12402
|
+
* @returns {JettonWallet} a JettonWallet instance with address returned by getJettonWalletAddress
|
|
12403
|
+
*/
|
|
12404
|
+
async getJettonWallet(provider, params) {
|
|
12405
|
+
const jettonWalletAddress = await this.getWalletAddress(
|
|
12406
|
+
provider,
|
|
12407
|
+
params.ownerAddress
|
|
12408
|
+
);
|
|
12409
|
+
return JettonWallet.create(jettonWalletAddress);
|
|
12410
|
+
}
|
|
12411
|
+
/**
|
|
12412
|
+
* @returns structure containing current state of the pool.
|
|
12413
|
+
*/
|
|
12414
|
+
async getPoolData(provider) {
|
|
12415
|
+
const result = await provider.get("get_pool_data", []);
|
|
12416
|
+
return {
|
|
12417
|
+
reserve0: result.stack.readBigNumber(),
|
|
12418
|
+
reserve1: result.stack.readBigNumber(),
|
|
12419
|
+
token0WalletAddress: result.stack.readAddress(),
|
|
12420
|
+
token1WalletAddress: result.stack.readAddress(),
|
|
12421
|
+
lpFee: result.stack.readBigNumber(),
|
|
12422
|
+
protocolFee: result.stack.readBigNumber(),
|
|
12423
|
+
refFee: result.stack.readBigNumber(),
|
|
12424
|
+
protocolFeeAddress: result.stack.readAddress(),
|
|
12425
|
+
collectedToken0ProtocolFee: result.stack.readBigNumber(),
|
|
12426
|
+
collectedToken1ProtocolFee: result.stack.readBigNumber()
|
|
12427
|
+
};
|
|
12428
|
+
}
|
|
12429
|
+
/**
|
|
12430
|
+
* @param {Address | string} params.ownerAddress - Address of a user
|
|
12431
|
+
*
|
|
12432
|
+
* @returns {LpAccount} object for address returned by getLpAccountAddress
|
|
12433
|
+
*/
|
|
12434
|
+
async getLpAccount(provider, params) {
|
|
12435
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
12436
|
+
return LpAccountV1.create(lpAccountAddress);
|
|
12437
|
+
}
|
|
12438
|
+
};
|
|
12439
|
+
|
|
12440
|
+
// node_modules/@ston-fi/sdk/dist/chunk-BZOLUFTK.js
|
|
12441
|
+
import { Address as Address9 } from "@ton/ton";
|
|
12442
|
+
var HOLE_ADDRESS = Address9.parse(
|
|
12443
|
+
"0:0000000000000000000000000000000000000000000000000000000000000000"
|
|
12444
|
+
);
|
|
12445
|
+
|
|
12446
|
+
// node_modules/@ston-fi/sdk/dist/chunk-VGVCKGFT.js
|
|
12447
|
+
var UnmatchedPtonVersion = class extends Error {
|
|
12448
|
+
constructor({
|
|
12449
|
+
expected,
|
|
12450
|
+
received
|
|
12451
|
+
}) {
|
|
12452
|
+
super(
|
|
12453
|
+
`The version of the provided pTON (${received}) does not match the expected version (${expected})`
|
|
12454
|
+
);
|
|
12455
|
+
}
|
|
12456
|
+
};
|
|
12457
|
+
|
|
12458
|
+
// node_modules/@ston-fi/sdk/dist/chunk-QLGZ6VJX.js
|
|
12459
|
+
import {
|
|
12460
|
+
address as address2,
|
|
12461
|
+
beginCell as beginCell8,
|
|
12462
|
+
toNano as toNano8
|
|
12463
|
+
} from "@ton/ton";
|
|
12464
|
+
var RouterV1 = class _RouterV1 extends Contract {
|
|
12465
|
+
static version = DEX_VERSION.v1;
|
|
12466
|
+
static address = address2(ROUTER_ADDRESS);
|
|
12467
|
+
static gasConstants = {
|
|
12468
|
+
swapJettonToJetton: {
|
|
12469
|
+
gasAmount: toNano8("0.22"),
|
|
12470
|
+
forwardGasAmount: toNano8("0.175")
|
|
12471
|
+
},
|
|
12472
|
+
swapJettonToTon: {
|
|
12473
|
+
gasAmount: toNano8("0.17"),
|
|
12474
|
+
forwardGasAmount: toNano8("0.125")
|
|
12475
|
+
},
|
|
12476
|
+
swapTonToJetton: {
|
|
12477
|
+
forwardGasAmount: toNano8("0.185")
|
|
12478
|
+
},
|
|
12479
|
+
provideLpJetton: {
|
|
12480
|
+
gasAmount: toNano8("0.3"),
|
|
12481
|
+
forwardGasAmount: toNano8("0.24")
|
|
12482
|
+
},
|
|
12483
|
+
provideLpTon: {
|
|
12484
|
+
forwardGasAmount: toNano8("0.26")
|
|
12485
|
+
}
|
|
12486
|
+
};
|
|
12487
|
+
gasConstants;
|
|
12488
|
+
constructor(address22 = _RouterV1.address, { gasConstants, ...options } = {}) {
|
|
12489
|
+
super(address22, options);
|
|
12490
|
+
this.gasConstants = {
|
|
12491
|
+
..._RouterV1.gasConstants,
|
|
12492
|
+
...gasConstants
|
|
12493
|
+
};
|
|
12494
|
+
}
|
|
12495
|
+
async createSwapBody(params) {
|
|
12496
|
+
const builder = beginCell8();
|
|
12497
|
+
builder.storeUint(DEX_OP_CODES.SWAP, 32);
|
|
12498
|
+
builder.storeAddress(toAddress(params.askJettonWalletAddress));
|
|
12499
|
+
builder.storeCoins(BigInt(params.minAskAmount));
|
|
12500
|
+
builder.storeAddress(toAddress(params.userWalletAddress));
|
|
12501
|
+
const referralAddress = this.maybeReferralAddress(params.referralAddress);
|
|
12502
|
+
if (referralAddress) {
|
|
12503
|
+
builder.storeUint(1, 1);
|
|
12504
|
+
builder.storeAddress(referralAddress);
|
|
12505
|
+
} else {
|
|
12506
|
+
builder.storeUint(0, 1);
|
|
12507
|
+
}
|
|
12508
|
+
return builder.endCell();
|
|
12509
|
+
}
|
|
12510
|
+
/**
|
|
12511
|
+
* Build all data required to execute a jetton to jetton `swap` transaction
|
|
12512
|
+
*
|
|
12513
|
+
* @param {Address | string} params.userWalletAddress - User's address
|
|
12514
|
+
* @param {Address | string} params.offerJettonAddress - Jetton address of a token to be swapped
|
|
12515
|
+
* @param {Address | string} params.askJettonAddress - Jetton address of a token to be received
|
|
12516
|
+
* @param {bigint | number} params.offerAmount - Amount of tokens to be swapped (in basic token units)
|
|
12517
|
+
* @param {bigint | number} params.minAskAmount - Minimum amount of tokens received (in basic token units)
|
|
12518
|
+
* @param {Address | string | undefined} params.referralAddress - Optional; referral address
|
|
12519
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12520
|
+
* @param {bigint | number | string | undefined} params.forwardGasAmount - Optional; Custom transaction forward gas amount (in nanoTons)
|
|
12521
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12522
|
+
* @param {Cell | undefined} params.jettonCustomPayload - Optional; custom payload for the jetton transfer message
|
|
12523
|
+
* @param {Address | string | undefined} params.transferExcessAddress - Optional; address to transfer excess tokens
|
|
12524
|
+
*
|
|
12525
|
+
* @returns {SenderArguments} data required to execute a jetton `swap` transaction
|
|
12526
|
+
*/
|
|
12527
|
+
async getSwapJettonToJettonTxParams(provider, params) {
|
|
12528
|
+
const [offerJettonWalletAddress, askJettonWalletAddress] = await Promise.all([
|
|
12529
|
+
params.offerJettonWalletAddress ? toAddress(params.offerJettonWalletAddress) : provider.open(JettonMinter.create(params.offerJettonAddress)).getWalletAddress(params.userWalletAddress),
|
|
12530
|
+
params.askJettonWalletAddress ? params.askJettonWalletAddress : provider.open(JettonMinter.create(params.askJettonAddress)).getWalletAddress(this.address)
|
|
12531
|
+
]);
|
|
12532
|
+
const forwardPayload = await this.createSwapBody({
|
|
12533
|
+
userWalletAddress: params.userWalletAddress,
|
|
12534
|
+
minAskAmount: params.minAskAmount,
|
|
12535
|
+
askJettonWalletAddress,
|
|
12536
|
+
referralAddress: params.referralAddress
|
|
12537
|
+
});
|
|
12538
|
+
const forwardTonAmount = BigInt(
|
|
12539
|
+
params.forwardGasAmount ?? this.gasConstants.swapJettonToJetton.forwardGasAmount
|
|
12540
|
+
);
|
|
12541
|
+
const body = createJettonTransferMessage({
|
|
12542
|
+
queryId: params.queryId ?? 0,
|
|
12543
|
+
amount: params.offerAmount,
|
|
12544
|
+
destination: this.address,
|
|
12545
|
+
responseDestination: params.transferExcessAddress ?? params.userWalletAddress,
|
|
12546
|
+
customPayload: params.jettonCustomPayload,
|
|
12547
|
+
forwardTonAmount,
|
|
12548
|
+
forwardPayload
|
|
12549
|
+
});
|
|
12550
|
+
const value = BigInt(
|
|
12551
|
+
params.gasAmount ?? this.gasConstants.swapJettonToJetton.gasAmount
|
|
12552
|
+
);
|
|
12553
|
+
return {
|
|
12554
|
+
to: offerJettonWalletAddress,
|
|
12555
|
+
value,
|
|
12556
|
+
body
|
|
12557
|
+
};
|
|
12558
|
+
}
|
|
12559
|
+
async sendSwapJettonToJetton(provider, via, params) {
|
|
12560
|
+
const txParams = await this.getSwapJettonToJettonTxParams(provider, params);
|
|
12561
|
+
return via.send(txParams);
|
|
12562
|
+
}
|
|
12563
|
+
/**
|
|
12564
|
+
* Build all data required to execute a jetton to ton `swap` transaction
|
|
12565
|
+
*
|
|
12566
|
+
* @param {Address | string} params.userWalletAddress - User's address
|
|
12567
|
+
* @param {Address | string} params.offerJettonAddress - Jetton address of a token to be swapped
|
|
12568
|
+
* @param {PtonV1} params.proxyTon - Proxy ton contract
|
|
12569
|
+
* @param {bigint | number} params.offerAmount - Amount of tokens to be swapped (in basic token units)
|
|
12570
|
+
* @param {bigint | number} params.minAskAmount - Minimum amount of tokens received (in basic token units)
|
|
12571
|
+
* @param {Address | string | undefined} params.referralAddress - Optional; referral address
|
|
12572
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12573
|
+
* @param {bigint | number | string | undefined} params.forwardGasAmount - Optional; Custom transaction forward gas amount (in nanoTons)
|
|
12574
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12575
|
+
* @param {Cell | undefined} params.jettonCustomPayload - Optional; custom payload for the jetton transfer message
|
|
12576
|
+
* @param {Address | string | undefined} params.transferExcessAddress - Optional; address to transfer excess tokens
|
|
12577
|
+
*
|
|
12578
|
+
* @returns {SenderArguments} data required to execute a jetton `swap` transaction
|
|
12579
|
+
*/
|
|
12580
|
+
async getSwapJettonToTonTxParams(provider, params) {
|
|
12581
|
+
this.assertProxyTon(params.proxyTon);
|
|
12582
|
+
return await this.getSwapJettonToJettonTxParams(provider, {
|
|
12583
|
+
...params,
|
|
12584
|
+
askJettonAddress: params.askJettonWalletAddress ?? params.proxyTon.address,
|
|
12585
|
+
gasAmount: params.gasAmount ?? this.gasConstants.swapJettonToTon.gasAmount,
|
|
12586
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.swapJettonToTon.forwardGasAmount
|
|
12587
|
+
});
|
|
12588
|
+
}
|
|
12589
|
+
async sendSwapJettonToTon(provider, via, params) {
|
|
12590
|
+
const txParams = await this.getSwapJettonToTonTxParams(provider, params);
|
|
12591
|
+
return via.send(txParams);
|
|
12592
|
+
}
|
|
12593
|
+
/**
|
|
12594
|
+
* Build all data required to execute a ton to jetton `swap` transaction
|
|
12595
|
+
*
|
|
12596
|
+
* @param {Address | string} params.userWalletAddress - User's address
|
|
12597
|
+
* @param {PtonV1} params.proxyTon - Proxy ton contract
|
|
12598
|
+
* @param {Address | string} params.askJettonAddress - Jetton address of a token to be received
|
|
12599
|
+
* @param {bigint | number} params.offerAmount - Amount of ton to be swapped (in nanoTons)
|
|
12600
|
+
* @param {bigint | number} params.minAskAmount - Minimum amount of tokens received (in basic token units)
|
|
12601
|
+
* @param {Address | string | undefined} params.referralAddress - Optional; Referral address
|
|
12602
|
+
* @param {bigint | number | string | undefined} params.forwardGasAmount - Optional; Custom transaction forward gas amount (in nanoTons)
|
|
12603
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12604
|
+
*
|
|
12605
|
+
* @returns {SenderArguments} data required to execute a ton to jetton `swap` transaction
|
|
12606
|
+
*/
|
|
12607
|
+
async getSwapTonToJettonTxParams(provider, params) {
|
|
12608
|
+
this.assertProxyTon(params.proxyTon);
|
|
12609
|
+
const askJettonWalletAddress = params.askJettonWalletAddress ?? await provider.open(JettonMinter.create(params.askJettonAddress)).getWalletAddress(this.address);
|
|
12610
|
+
const forwardPayload = await this.createSwapBody({
|
|
12611
|
+
userWalletAddress: params.userWalletAddress,
|
|
12612
|
+
minAskAmount: params.minAskAmount,
|
|
12613
|
+
askJettonWalletAddress,
|
|
12614
|
+
referralAddress: params.referralAddress
|
|
12615
|
+
});
|
|
12616
|
+
const forwardTonAmount = BigInt(
|
|
12617
|
+
params.forwardGasAmount ?? this.gasConstants.swapTonToJetton.forwardGasAmount
|
|
12618
|
+
);
|
|
12619
|
+
return await provider.open(params.proxyTon).getTonTransferTxParams({
|
|
12620
|
+
queryId: params.queryId ?? 0,
|
|
12621
|
+
tonAmount: params.offerAmount,
|
|
12622
|
+
destinationAddress: this.address,
|
|
12623
|
+
destinationWalletAddress: params.offerJettonWalletAddress,
|
|
12624
|
+
refundAddress: params.userWalletAddress,
|
|
12625
|
+
forwardPayload,
|
|
12626
|
+
forwardTonAmount
|
|
12627
|
+
});
|
|
12628
|
+
}
|
|
12629
|
+
async sendSwapTonToJetton(provider, via, params) {
|
|
12630
|
+
const txParams = await this.getSwapTonToJettonTxParams(provider, params);
|
|
12631
|
+
return via.send(txParams);
|
|
12632
|
+
}
|
|
12633
|
+
async createProvideLiquidityBody(params) {
|
|
12634
|
+
return beginCell8().storeUint(DEX_OP_CODES.PROVIDE_LP, 32).storeAddress(toAddress(params.routerWalletAddress)).storeCoins(BigInt(params.minLpOut)).endCell();
|
|
12635
|
+
}
|
|
12636
|
+
/**
|
|
12637
|
+
* Collect all data required to execute a jetton `provide_lp` transaction
|
|
12638
|
+
*
|
|
12639
|
+
* @param {Address | string} params.userWalletAddress - User's address
|
|
12640
|
+
* @param {Address | string} params.sendTokenAddress - Address of the provided Jetton token
|
|
12641
|
+
* @param {Address | string} params.otherTokenAddress - Address of the other Jetton token in pair
|
|
12642
|
+
* @param {bigint | number} params.sendAmount - Amount of the first token deposited as liquidity (in basic token units)
|
|
12643
|
+
* @param {bigint | number} params.minLpOut - Minimum amount of created liquidity tokens (in basic token units)
|
|
12644
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12645
|
+
* @param {bigint | number | string | undefined} params.forwardGasAmount - Optional; Custom transaction forward gas amount (in nanoTons)
|
|
12646
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12647
|
+
* @param {Cell | undefined} params.jettonCustomPayload - Optional; custom payload for the jetton transfer message
|
|
12648
|
+
*
|
|
12649
|
+
* @returns {SenderArguments} data required to execute a jetton `provide_lp` transaction
|
|
12650
|
+
*/
|
|
12651
|
+
async getProvideLiquidityJettonTxParams(provider, params) {
|
|
12652
|
+
const [jettonWalletAddress, routerWalletAddress] = await Promise.all([
|
|
12653
|
+
provider.open(JettonMinter.create(params.sendTokenAddress)).getWalletAddress(params.userWalletAddress),
|
|
12654
|
+
provider.open(JettonMinter.create(params.otherTokenAddress)).getWalletAddress(this.address)
|
|
12655
|
+
]);
|
|
12656
|
+
const forwardPayload = await this.createProvideLiquidityBody({
|
|
12657
|
+
routerWalletAddress,
|
|
12658
|
+
minLpOut: params.minLpOut
|
|
12659
|
+
});
|
|
12660
|
+
const forwardTonAmount = BigInt(
|
|
12661
|
+
params.forwardGasAmount ?? this.gasConstants.provideLpJetton.forwardGasAmount
|
|
12662
|
+
);
|
|
12663
|
+
const body = createJettonTransferMessage({
|
|
12664
|
+
queryId: params.queryId ?? 0,
|
|
12665
|
+
amount: params.sendAmount,
|
|
12666
|
+
destination: this.address,
|
|
12667
|
+
responseDestination: params.transferExcessAddress ?? params.userWalletAddress,
|
|
12668
|
+
customPayload: params.jettonCustomPayload,
|
|
12669
|
+
forwardTonAmount,
|
|
12670
|
+
forwardPayload
|
|
12671
|
+
});
|
|
12672
|
+
const value = BigInt(
|
|
12673
|
+
params.gasAmount ?? this.gasConstants.provideLpJetton.gasAmount
|
|
12674
|
+
);
|
|
12675
|
+
return {
|
|
12676
|
+
to: jettonWalletAddress,
|
|
12677
|
+
value,
|
|
12678
|
+
body
|
|
12679
|
+
};
|
|
12680
|
+
}
|
|
12681
|
+
async sendProvideLiquidityJetton(provider, via, params) {
|
|
12682
|
+
const txParams = await this.getProvideLiquidityJettonTxParams(
|
|
12683
|
+
provider,
|
|
12684
|
+
params
|
|
12685
|
+
);
|
|
12686
|
+
return via.send(txParams);
|
|
12687
|
+
}
|
|
12688
|
+
/**
|
|
12689
|
+
* Collect all data required to execute a proxy ton `provide_lp` transaction
|
|
12690
|
+
*
|
|
12691
|
+
* @param {Address | string} params.userWalletAddress - User's address
|
|
12692
|
+
* @param {PtonV1} params.proxyTon - proxy ton contract
|
|
12693
|
+
* @param {Address | string} params.otherTokenAddress - Address of the other Jetton token in pair
|
|
12694
|
+
* @param {bigint | number} params.sendAmount - Amount of ton deposited as liquidity (in nanoTons)
|
|
12695
|
+
* @param {bigint | number} params.minLpOut - Minimum amount of created liquidity tokens (in basic token units)
|
|
12696
|
+
* @param {bigint | number | string | undefined} params.forwardGasAmount - Optional; Custom transaction forward gas amount (in nanoTons)
|
|
12697
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12698
|
+
*
|
|
12699
|
+
* @returns {SenderArguments} data required to execute a proxy ton `provide_lp` transaction
|
|
12700
|
+
*/
|
|
12701
|
+
async getProvideLiquidityTonTxParams(provider, params) {
|
|
12702
|
+
this.assertProxyTon(params.proxyTon);
|
|
12703
|
+
const routerWalletAddress = await provider.open(JettonMinter.create(params.otherTokenAddress)).getWalletAddress(this.address);
|
|
12704
|
+
const forwardPayload = await this.createProvideLiquidityBody({
|
|
12705
|
+
routerWalletAddress,
|
|
12706
|
+
minLpOut: params.minLpOut
|
|
12707
|
+
});
|
|
12708
|
+
const forwardTonAmount = BigInt(
|
|
12709
|
+
params.forwardGasAmount ?? this.gasConstants.provideLpTon.forwardGasAmount
|
|
12710
|
+
);
|
|
12711
|
+
return await provider.open(params.proxyTon).getTonTransferTxParams({
|
|
12712
|
+
queryId: params.queryId ?? 0,
|
|
12713
|
+
tonAmount: params.sendAmount,
|
|
12714
|
+
destinationAddress: this.address,
|
|
12715
|
+
refundAddress: params.userWalletAddress,
|
|
12716
|
+
forwardPayload,
|
|
12717
|
+
forwardTonAmount
|
|
12718
|
+
});
|
|
12719
|
+
}
|
|
12720
|
+
async sendProvideLiquidityTon(provider, via, params) {
|
|
12721
|
+
const txParams = await this.getProvideLiquidityTonTxParams(
|
|
12722
|
+
provider,
|
|
12723
|
+
params
|
|
12724
|
+
);
|
|
12725
|
+
return via.send(txParams);
|
|
12726
|
+
}
|
|
12727
|
+
assertProxyTon(proxyTon) {
|
|
12728
|
+
if (proxyTon.version !== pTON_VERSION.v1) {
|
|
12729
|
+
throw new UnmatchedPtonVersion({
|
|
12730
|
+
expected: pTON_VERSION.v1,
|
|
12731
|
+
received: proxyTon.version
|
|
12732
|
+
});
|
|
12733
|
+
}
|
|
12734
|
+
}
|
|
12735
|
+
/**
|
|
12736
|
+
* **Note:** It's necessary to specify addresses of Jetton wallets of the router as the arguments of this method.
|
|
12737
|
+
* These addresses can be retrieved with getJettonWalletAddress of the Jetton minter.
|
|
12738
|
+
*
|
|
12739
|
+
* @param {Address | string} params.token0 - The address of the router's wallet of first Jetton
|
|
12740
|
+
* @param {Address | string} params.token1 - The address of the router's wallet of second Jetton
|
|
12741
|
+
*
|
|
12742
|
+
* @returns {Address} an address of a pool for a specified pair of assets.
|
|
12743
|
+
*/
|
|
12744
|
+
async getPoolAddress(provider, params) {
|
|
12745
|
+
const result = await provider.get("get_pool_address", [
|
|
12746
|
+
{
|
|
12747
|
+
type: "slice",
|
|
12748
|
+
cell: beginCell8().storeAddress(toAddress(params.token0)).endCell()
|
|
12749
|
+
},
|
|
12750
|
+
{
|
|
12751
|
+
type: "slice",
|
|
12752
|
+
cell: beginCell8().storeAddress(toAddress(params.token1)).endCell()
|
|
12753
|
+
}
|
|
12754
|
+
]);
|
|
12755
|
+
return result.stack.readAddress();
|
|
12756
|
+
}
|
|
12757
|
+
/**
|
|
12758
|
+
* @param {Address | string} params.token0 - The address of the first Jetton minter
|
|
12759
|
+
* @param {Address | string} params.token1 - The address of the second Jetton minter
|
|
12760
|
+
*
|
|
12761
|
+
* @returns {Address} an address of a pool for a specified pair of assets.
|
|
12762
|
+
*/
|
|
12763
|
+
async getPoolAddressByJettonMinters(provider, params) {
|
|
12764
|
+
const [jetton0WalletAddress, jetton1WalletAddress] = await Promise.all([
|
|
12765
|
+
provider.open(JettonMinter.create(params.token0)).getWalletAddress(this.address),
|
|
12766
|
+
provider.open(JettonMinter.create(params.token1)).getWalletAddress(this.address)
|
|
12767
|
+
]);
|
|
12768
|
+
const poolAddress = await this.getPoolAddress(provider, {
|
|
12769
|
+
token0: jetton0WalletAddress,
|
|
12770
|
+
token1: jetton1WalletAddress
|
|
12771
|
+
});
|
|
12772
|
+
return poolAddress;
|
|
12773
|
+
}
|
|
12774
|
+
/**
|
|
12775
|
+
* @param {Address | string} params.token0 - The address of the first Jetton minter
|
|
12776
|
+
* @param {Address | string} params.token1 - The address of the second Jetton minter
|
|
12777
|
+
*
|
|
12778
|
+
* @returns {PoolV1} object for a pool with specified Jetton token addresses.
|
|
12779
|
+
*/
|
|
12780
|
+
async getPool(provider, params) {
|
|
12781
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(provider, {
|
|
12782
|
+
token0: params.token0,
|
|
12783
|
+
token1: params.token1
|
|
12784
|
+
});
|
|
12785
|
+
return PoolV1.create(poolAddress);
|
|
12786
|
+
}
|
|
12787
|
+
/**
|
|
12788
|
+
* @returns current state of the router.
|
|
12789
|
+
*/
|
|
12790
|
+
async getRouterData(provider) {
|
|
12791
|
+
const result = await provider.get("get_router_data", []);
|
|
12792
|
+
return {
|
|
12793
|
+
isLocked: result.stack.readBoolean(),
|
|
12794
|
+
adminAddress: result.stack.readAddress(),
|
|
12795
|
+
tempUpgrade: result.stack.readCell(),
|
|
12796
|
+
poolCode: result.stack.readCell(),
|
|
12797
|
+
jettonLpWalletCode: result.stack.readCell(),
|
|
12798
|
+
lpAccountCode: result.stack.readCell()
|
|
12799
|
+
};
|
|
12800
|
+
}
|
|
12801
|
+
maybeReferralAddress(referralAddress) {
|
|
12802
|
+
if (!referralAddress) return null;
|
|
12803
|
+
const referralAddressParsed = toAddress(referralAddress);
|
|
12804
|
+
if (referralAddressParsed.equals(HOLE_ADDRESS)) return null;
|
|
12805
|
+
return referralAddressParsed;
|
|
12806
|
+
}
|
|
12807
|
+
};
|
|
12808
|
+
|
|
12809
|
+
// node_modules/@ston-fi/sdk/dist/chunk-WC6BMQXZ.js
|
|
12810
|
+
var pTON_OP_CODES = {
|
|
12811
|
+
DEPLOY_WALLET: 1824798067
|
|
12812
|
+
};
|
|
12813
|
+
|
|
12814
|
+
// node_modules/@ston-fi/sdk/dist/chunk-PFUMIEMI.js
|
|
12815
|
+
import {
|
|
12816
|
+
address as address3,
|
|
12817
|
+
beginCell as beginCell9,
|
|
12818
|
+
toNano as toNano9
|
|
12819
|
+
} from "@ton/ton";
|
|
12820
|
+
var PtonV1 = class _PtonV1 extends JettonMinter {
|
|
12821
|
+
static version = pTON_VERSION.v1;
|
|
12822
|
+
static address = address3(
|
|
12823
|
+
"EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez"
|
|
12824
|
+
);
|
|
12825
|
+
static gasConstants = {
|
|
12826
|
+
deployWallet: toNano9("1.05")
|
|
12827
|
+
};
|
|
12828
|
+
version = _PtonV1.version;
|
|
12829
|
+
gasConstants;
|
|
12830
|
+
constructor(address22 = _PtonV1.address, { gasConstants, ...options } = {}) {
|
|
12831
|
+
super(address22, options);
|
|
12832
|
+
this.gasConstants = {
|
|
12833
|
+
..._PtonV1.gasConstants,
|
|
12834
|
+
...gasConstants
|
|
12835
|
+
};
|
|
12836
|
+
}
|
|
12837
|
+
async getTonTransferTxParams(provider, params) {
|
|
12838
|
+
const to = params.destinationWalletAddress ? toAddress(params.destinationWalletAddress) : await this.getWalletAddress(provider, params.destinationAddress);
|
|
12839
|
+
const body = createJettonTransferMessage({
|
|
12840
|
+
queryId: params.queryId ?? 0,
|
|
12841
|
+
amount: params.tonAmount,
|
|
12842
|
+
destination: params.destinationAddress,
|
|
12843
|
+
forwardTonAmount: BigInt(params.forwardTonAmount ?? 0),
|
|
12844
|
+
forwardPayload: params.forwardPayload
|
|
12845
|
+
});
|
|
12846
|
+
const value = BigInt(params.tonAmount) + BigInt(params.forwardTonAmount ?? 0);
|
|
12847
|
+
return { to, value, body };
|
|
12848
|
+
}
|
|
12849
|
+
async sendTonTransfer(provider, via, params) {
|
|
12850
|
+
const txParams = await this.getTonTransferTxParams(provider, params);
|
|
12851
|
+
return via.send(txParams);
|
|
12852
|
+
}
|
|
12853
|
+
async createDeployWalletBody(params) {
|
|
12854
|
+
return beginCell9().storeUint(pTON_OP_CODES.DEPLOY_WALLET, 32).storeUint(params.queryId ?? 0, 64).storeAddress(toAddress(params.ownerAddress)).endCell();
|
|
12855
|
+
}
|
|
12856
|
+
async getDeployWalletTxParams(provider, params) {
|
|
12857
|
+
const to = this.address;
|
|
12858
|
+
const body = await this.createDeployWalletBody({
|
|
12859
|
+
ownerAddress: params.ownerAddress,
|
|
12860
|
+
queryId: params?.queryId
|
|
12861
|
+
});
|
|
12862
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.deployWallet);
|
|
12863
|
+
return { to, value, body };
|
|
12864
|
+
}
|
|
12865
|
+
async sendDeployWallet(provider, via, params) {
|
|
12866
|
+
const txParams = await this.getDeployWalletTxParams(provider, params);
|
|
12867
|
+
return via.send(txParams);
|
|
12868
|
+
}
|
|
12869
|
+
};
|
|
12870
|
+
|
|
12871
|
+
// node_modules/@ston-fi/sdk/dist/chunk-TO5IKSJT.js
|
|
12872
|
+
var DEX = {
|
|
12873
|
+
Router: RouterV1,
|
|
12874
|
+
Pool: PoolV1,
|
|
12875
|
+
LpAccount: LpAccountV1,
|
|
12876
|
+
pTON: PtonV1
|
|
12877
|
+
};
|
|
12878
|
+
|
|
12879
|
+
// node_modules/@ston-fi/sdk/dist/chunk-CWGXHOMU.js
|
|
12880
|
+
var DEX_OP_CODES2 = {
|
|
12881
|
+
SWAP: 1717886506,
|
|
12882
|
+
CROSS_SWAP: 1775180379,
|
|
12883
|
+
PROVIDE_LP: 935368415,
|
|
12884
|
+
DIRECT_ADD_LIQUIDITY: 267960262,
|
|
12885
|
+
REFUND_ME: 321624620,
|
|
12886
|
+
RESET_GAS: 701638965,
|
|
12887
|
+
COLLECT_FEES: 518295838,
|
|
12888
|
+
BURN: 1499400124,
|
|
12889
|
+
WITHDRAW_FEE: 894160372
|
|
12890
|
+
};
|
|
12891
|
+
var TX_DEADLINE = 15 * 60;
|
|
12892
|
+
|
|
12893
|
+
// node_modules/@ston-fi/sdk/dist/chunk-ZREZXXSX.js
|
|
12894
|
+
import {
|
|
12895
|
+
beginCell as beginCell10,
|
|
12896
|
+
toNano as toNano10
|
|
12897
|
+
} from "@ton/ton";
|
|
12898
|
+
var VaultV2_1 = class _VaultV2_1 extends Contract {
|
|
12899
|
+
static version = DEX_VERSION.v2_1;
|
|
12900
|
+
static gasConstants = {
|
|
12901
|
+
withdrawFee: toNano10("0.3")
|
|
12902
|
+
};
|
|
12903
|
+
gasConstants;
|
|
12904
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
12905
|
+
super(address4, options);
|
|
12906
|
+
this.gasConstants = {
|
|
12907
|
+
..._VaultV2_1.gasConstants,
|
|
12908
|
+
...gasConstants
|
|
12909
|
+
};
|
|
12910
|
+
}
|
|
12911
|
+
async createWithdrawFeeBody(params) {
|
|
12912
|
+
return beginCell10().storeUint(DEX_OP_CODES2.WITHDRAW_FEE, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
12913
|
+
}
|
|
12914
|
+
/**
|
|
12915
|
+
* Build all data required to execute a `withdraw_fee` transaction.
|
|
12916
|
+
*
|
|
12917
|
+
* @param {ContractProvider} provider - {@link ContractProvider} instance
|
|
12918
|
+
*
|
|
12919
|
+
* @param {object | undefined} params - Optional tx params
|
|
12920
|
+
* @param {bigint | number | string | undefined} params.gasAmount - Optional; Custom transaction gas amount (in nanoTons)
|
|
12921
|
+
* @param {bigint | number | undefined} params.queryId - Optional; query id
|
|
12922
|
+
*
|
|
12923
|
+
*
|
|
12924
|
+
* @returns {SenderArguments} all data required to execute a `withdraw_fee` transaction.
|
|
12925
|
+
*/
|
|
12926
|
+
async getWithdrawFeeTxParams(provider, params) {
|
|
12927
|
+
const to = this.address;
|
|
12928
|
+
const body = await this.createWithdrawFeeBody({
|
|
12929
|
+
queryId: params?.queryId
|
|
12930
|
+
});
|
|
12931
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.withdrawFee);
|
|
12932
|
+
return { to, body, value };
|
|
12933
|
+
}
|
|
12934
|
+
async sendWithdrawFee(provider, via, params) {
|
|
12935
|
+
const txParams = await this.getWithdrawFeeTxParams(provider, params);
|
|
12936
|
+
return via.send(txParams);
|
|
12937
|
+
}
|
|
12938
|
+
/**
|
|
12939
|
+
* Get the current state of the vault contract.
|
|
12940
|
+
*
|
|
12941
|
+
* @param {ContractProvider} provider - {@link ContractProvider} instance
|
|
12942
|
+
*
|
|
12943
|
+
*
|
|
12944
|
+
* @returns {Promise<object>} structure containing the current state of the vault contract.
|
|
12945
|
+
*/
|
|
12946
|
+
async getVaultData(provider) {
|
|
12947
|
+
const result = await provider.get("get_vault_data", []);
|
|
12948
|
+
return {
|
|
12949
|
+
ownerAddress: result.stack.readAddress(),
|
|
12950
|
+
tokenAddress: result.stack.readAddress(),
|
|
12951
|
+
routerAddress: result.stack.readAddress(),
|
|
12952
|
+
depositedAmount: result.stack.readBigNumber()
|
|
12953
|
+
};
|
|
12954
|
+
}
|
|
12955
|
+
};
|
|
12956
|
+
|
|
12957
|
+
// node_modules/@ston-fi/sdk/dist/chunk-NYDP354Z.js
|
|
12958
|
+
import {
|
|
12959
|
+
beginCell as beginCell11,
|
|
12960
|
+
toNano as toNano11
|
|
12961
|
+
} from "@ton/ton";
|
|
12962
|
+
var LpAccountV2_1 = class _LpAccountV2_1 extends Contract {
|
|
12963
|
+
static version = DEX_VERSION.v2_1;
|
|
12964
|
+
static gasConstants = {
|
|
12965
|
+
refund: toNano11("0.8"),
|
|
12966
|
+
directAddLp: toNano11("0.3"),
|
|
12967
|
+
resetGas: toNano11("0.02")
|
|
12968
|
+
};
|
|
12969
|
+
gasConstants;
|
|
12970
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
12971
|
+
super(address4, options);
|
|
12972
|
+
this.gasConstants = {
|
|
12973
|
+
..._LpAccountV2_1.gasConstants,
|
|
12974
|
+
...gasConstants
|
|
12975
|
+
};
|
|
12976
|
+
}
|
|
12977
|
+
async createRefundBody(params) {
|
|
12978
|
+
return beginCell11().storeUint(DEX_OP_CODES2.REFUND_ME, 32).storeUint(params?.queryId ?? 0, 64).storeMaybeRef(params?.leftMaybePayload).storeMaybeRef(params?.rightMaybePayload).endCell();
|
|
12979
|
+
}
|
|
12980
|
+
async getRefundTxParams(provider, params) {
|
|
12981
|
+
const to = this.address;
|
|
12982
|
+
const body = await this.createRefundBody({
|
|
12983
|
+
leftMaybePayload: params?.leftMaybePayload,
|
|
12984
|
+
rightMaybePayload: params?.rightMaybePayload,
|
|
12985
|
+
queryId: params?.queryId
|
|
12986
|
+
});
|
|
12987
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.refund);
|
|
12988
|
+
return { to, value, body };
|
|
12989
|
+
}
|
|
12990
|
+
async sendRefund(provider, via, params) {
|
|
12991
|
+
const txParams = await this.getRefundTxParams(provider, params);
|
|
12992
|
+
return via.send(txParams);
|
|
12993
|
+
}
|
|
12994
|
+
async createDirectAddLiquidityBody(params) {
|
|
12995
|
+
return beginCell11().storeUint(DEX_OP_CODES2.DIRECT_ADD_LIQUIDITY, 32).storeUint(params?.queryId ?? 0, 64).storeCoins(BigInt(params.amount0)).storeCoins(BigInt(params.amount1)).storeCoins(BigInt(params.minimumLpToMint ?? 1)).storeCoins(BigInt(params.dexCustomPayloadForwardGasAmount ?? 0)).storeAddress(toAddress(params.userWalletAddress)).storeMaybeRef(params.dexCustomPayload).storeRef(
|
|
12996
|
+
beginCell11().storeAddress(
|
|
12997
|
+
toAddress(params.refundAddress ?? params.userWalletAddress)
|
|
12998
|
+
).storeAddress(
|
|
12999
|
+
toAddress(
|
|
13000
|
+
params.excessesAddress ?? params.refundAddress ?? params.userWalletAddress
|
|
13001
|
+
)
|
|
13002
|
+
).endCell()
|
|
13003
|
+
).endCell();
|
|
13004
|
+
}
|
|
13005
|
+
async getDirectAddLiquidityTxParams(provider, params) {
|
|
13006
|
+
const to = this.address;
|
|
13007
|
+
const body = await this.createDirectAddLiquidityBody({
|
|
13008
|
+
amount0: params.amount0,
|
|
13009
|
+
amount1: params.amount1,
|
|
13010
|
+
minimumLpToMint: params.minimumLpToMint,
|
|
13011
|
+
userWalletAddress: params.userWalletAddress,
|
|
13012
|
+
refundAddress: params.refundAddress,
|
|
13013
|
+
excessesAddress: params.excessesAddress,
|
|
13014
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13015
|
+
dexCustomPayloadForwardGasAmount: params.dexCustomPayloadForwardGasAmount,
|
|
13016
|
+
queryId: params.queryId
|
|
13017
|
+
});
|
|
13018
|
+
const value = BigInt(params.gasAmount ?? this.gasConstants.directAddLp);
|
|
13019
|
+
return { to, value, body };
|
|
13020
|
+
}
|
|
13021
|
+
async sendDirectAddLiquidity(provider, via, params) {
|
|
13022
|
+
const txParams = await this.getDirectAddLiquidityTxParams(provider, params);
|
|
13023
|
+
return via.send(txParams);
|
|
13024
|
+
}
|
|
13025
|
+
async createResetGasBody(params) {
|
|
13026
|
+
return beginCell11().storeUint(DEX_OP_CODES2.RESET_GAS, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
13027
|
+
}
|
|
13028
|
+
async getResetGasTxParams(provider, params) {
|
|
13029
|
+
const to = this.address;
|
|
13030
|
+
const body = await this.createResetGasBody({
|
|
13031
|
+
queryId: params?.queryId
|
|
13032
|
+
});
|
|
13033
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.resetGas);
|
|
13034
|
+
return { to, value, body };
|
|
13035
|
+
}
|
|
13036
|
+
async sendResetGas(provider, via, params) {
|
|
13037
|
+
const txParams = await this.getResetGasTxParams(provider, params);
|
|
13038
|
+
return via.send(txParams);
|
|
13039
|
+
}
|
|
13040
|
+
async getLpAccountData(provider) {
|
|
13041
|
+
const result = await provider.get("get_lp_account_data", []);
|
|
13042
|
+
return {
|
|
13043
|
+
userAddress: result.stack.readAddress(),
|
|
13044
|
+
poolAddress: result.stack.readAddress(),
|
|
13045
|
+
amount0: result.stack.readBigNumber(),
|
|
13046
|
+
amount1: result.stack.readBigNumber()
|
|
13047
|
+
};
|
|
13048
|
+
}
|
|
13049
|
+
};
|
|
13050
|
+
|
|
13051
|
+
// node_modules/@ston-fi/sdk/dist/chunk-DFPKM3LH.js
|
|
13052
|
+
import {
|
|
13053
|
+
beginCell as beginCell12,
|
|
13054
|
+
toNano as toNano12
|
|
13055
|
+
} from "@ton/ton";
|
|
13056
|
+
var BasePoolV2_1 = class _BasePoolV2_1 extends JettonMinter {
|
|
13057
|
+
static version = DEX_VERSION.v2_1;
|
|
13058
|
+
static gasConstants = {
|
|
13059
|
+
collectFees: toNano12("0.4"),
|
|
13060
|
+
burn: toNano12("0.8")
|
|
13061
|
+
};
|
|
13062
|
+
gasConstants;
|
|
13063
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
13064
|
+
super(address4, options);
|
|
13065
|
+
this.gasConstants = {
|
|
13066
|
+
..._BasePoolV2_1.gasConstants,
|
|
13067
|
+
...gasConstants
|
|
13068
|
+
};
|
|
13069
|
+
}
|
|
13070
|
+
async createCollectFeesBody(params) {
|
|
13071
|
+
return beginCell12().storeUint(DEX_OP_CODES2.COLLECT_FEES, 32).storeUint(params?.queryId ?? 0, 64).endCell();
|
|
13072
|
+
}
|
|
13073
|
+
async getCollectFeeTxParams(provider, params) {
|
|
13074
|
+
const to = this.address;
|
|
13075
|
+
const body = await this.createCollectFeesBody({
|
|
13076
|
+
queryId: params?.queryId
|
|
13077
|
+
});
|
|
13078
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.collectFees);
|
|
13079
|
+
return { to, value, body };
|
|
13080
|
+
}
|
|
13081
|
+
async sendCollectFees(provider, via, params) {
|
|
13082
|
+
const txParams = await this.getCollectFeeTxParams(provider, params);
|
|
13083
|
+
return via.send(txParams);
|
|
13084
|
+
}
|
|
13085
|
+
async createBurnBody(params) {
|
|
13086
|
+
return beginCell12().storeUint(DEX_OP_CODES2.BURN, 32).storeUint(params?.queryId ?? 0, 64).storeCoins(BigInt(params.amount)).storeAddress(null).storeMaybeRef(params.dexCustomPayload).endCell();
|
|
13087
|
+
}
|
|
13088
|
+
async getBurnTxParams(provider, params) {
|
|
13089
|
+
const [to, body] = await Promise.all([
|
|
13090
|
+
this.getWalletAddress(provider, params.userWalletAddress),
|
|
13091
|
+
this.createBurnBody({
|
|
13092
|
+
amount: params.amount,
|
|
13093
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13094
|
+
queryId: params.queryId
|
|
13095
|
+
})
|
|
13096
|
+
]);
|
|
13097
|
+
const value = BigInt(params.gasAmount ?? this.gasConstants.burn);
|
|
13098
|
+
return { to, value, body };
|
|
13099
|
+
}
|
|
13100
|
+
async sendBurn(provider, via, params) {
|
|
13101
|
+
const txParams = await this.getBurnTxParams(provider, params);
|
|
13102
|
+
return via.send(txParams);
|
|
13103
|
+
}
|
|
13104
|
+
async getPoolType(provider) {
|
|
13105
|
+
const result = await provider.get("get_pool_type", []);
|
|
13106
|
+
return result.stack.readString();
|
|
13107
|
+
}
|
|
13108
|
+
async getLpAccountAddress(provider, params) {
|
|
13109
|
+
const result = await provider.get("get_lp_account_address", [
|
|
13110
|
+
{
|
|
13111
|
+
type: "slice",
|
|
13112
|
+
cell: beginCell12().storeAddress(toAddress(params.ownerAddress)).endCell()
|
|
13113
|
+
}
|
|
13114
|
+
]);
|
|
13115
|
+
return result.stack.readAddress();
|
|
13116
|
+
}
|
|
13117
|
+
async getLpAccount(provider, params) {
|
|
13118
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13119
|
+
return LpAccountV2_1.create(lpAccountAddress);
|
|
13120
|
+
}
|
|
13121
|
+
async getJettonWallet(provider, params) {
|
|
13122
|
+
const jettonWalletAddress = await this.getWalletAddress(
|
|
13123
|
+
provider,
|
|
13124
|
+
params.ownerAddress
|
|
13125
|
+
);
|
|
13126
|
+
return JettonWallet.create(jettonWalletAddress);
|
|
13127
|
+
}
|
|
13128
|
+
async getPoolData(provider) {
|
|
13129
|
+
const data = await this.implGetPoolData(provider);
|
|
13130
|
+
return data.commonPoolData;
|
|
13131
|
+
}
|
|
13132
|
+
async implGetPoolData(provider) {
|
|
13133
|
+
const result = await provider.get("get_pool_data", []);
|
|
13134
|
+
return {
|
|
13135
|
+
commonPoolData: {
|
|
13136
|
+
isLocked: result.stack.readBoolean(),
|
|
13137
|
+
routerAddress: result.stack.readAddress(),
|
|
13138
|
+
totalSupplyLP: result.stack.readBigNumber(),
|
|
13139
|
+
reserve0: result.stack.readBigNumber(),
|
|
13140
|
+
reserve1: result.stack.readBigNumber(),
|
|
13141
|
+
token0WalletAddress: result.stack.readAddress(),
|
|
13142
|
+
token1WalletAddress: result.stack.readAddress(),
|
|
13143
|
+
lpFee: result.stack.readBigNumber(),
|
|
13144
|
+
protocolFee: result.stack.readBigNumber(),
|
|
13145
|
+
protocolFeeAddress: result.stack.readAddressOpt(),
|
|
13146
|
+
collectedToken0ProtocolFee: result.stack.readBigNumber(),
|
|
13147
|
+
collectedToken1ProtocolFee: result.stack.readBigNumber()
|
|
13148
|
+
},
|
|
13149
|
+
stack: result.stack
|
|
13150
|
+
};
|
|
13151
|
+
}
|
|
13152
|
+
};
|
|
13153
|
+
|
|
13154
|
+
// node_modules/@ston-fi/sdk/dist/chunk-YSYMABVC.js
|
|
13155
|
+
import {
|
|
13156
|
+
Address as Address10,
|
|
13157
|
+
beginCell as beginCell13,
|
|
13158
|
+
toNano as toNano13
|
|
13159
|
+
} from "@ton/ton";
|
|
13160
|
+
var BaseRouterV2_1 = class _BaseRouterV2_1 extends Contract {
|
|
13161
|
+
static version = DEX_VERSION.v2_1;
|
|
13162
|
+
static gasConstants = {
|
|
13163
|
+
swapJettonToJetton: {
|
|
13164
|
+
gasAmount: toNano13("0.3"),
|
|
13165
|
+
forwardGasAmount: toNano13("0.24")
|
|
13166
|
+
},
|
|
13167
|
+
swapJettonToTon: {
|
|
13168
|
+
gasAmount: toNano13("0.3"),
|
|
13169
|
+
forwardGasAmount: toNano13("0.24")
|
|
13170
|
+
},
|
|
13171
|
+
swapTonToJetton: {
|
|
13172
|
+
forwardGasAmount: toNano13("0.3")
|
|
13173
|
+
},
|
|
13174
|
+
provideLpJetton: {
|
|
13175
|
+
gasAmount: toNano13("0.3"),
|
|
13176
|
+
forwardGasAmount: toNano13("0.235")
|
|
13177
|
+
},
|
|
13178
|
+
provideLpTon: {
|
|
13179
|
+
forwardGasAmount: toNano13("0.3")
|
|
13180
|
+
},
|
|
13181
|
+
singleSideProvideLpJetton: {
|
|
13182
|
+
gasAmount: toNano13("1"),
|
|
13183
|
+
forwardGasAmount: toNano13("0.8")
|
|
13184
|
+
},
|
|
13185
|
+
singleSideProvideLpTon: {
|
|
13186
|
+
forwardGasAmount: toNano13("0.8")
|
|
13187
|
+
}
|
|
13188
|
+
};
|
|
13189
|
+
gasConstants;
|
|
13190
|
+
txDeadline;
|
|
13191
|
+
constructor(address4, { gasConstants, txDeadline, ...options } = {}) {
|
|
13192
|
+
super(address4, options);
|
|
13193
|
+
if (this.address.equals(Address10.parse(ROUTER_ADDRESS))) {
|
|
13194
|
+
throw Error(
|
|
13195
|
+
[
|
|
13196
|
+
"You are trying to create an instance v2.1 Router with a v1 address",
|
|
13197
|
+
"Please use the appropriate class for the v1 Router. Otherwise, all the funds will be permanently lost."
|
|
13198
|
+
].join("\n")
|
|
13199
|
+
);
|
|
13200
|
+
}
|
|
13201
|
+
this.gasConstants = {
|
|
13202
|
+
..._BaseRouterV2_1.gasConstants,
|
|
13203
|
+
...gasConstants
|
|
13204
|
+
};
|
|
13205
|
+
this.txDeadline = txDeadline ?? TX_DEADLINE;
|
|
13206
|
+
}
|
|
13207
|
+
async createSwapBody(params) {
|
|
13208
|
+
if (params.referralValue && (BigInt(params.referralValue) < 0 || BigInt(params.referralValue) > 100)) {
|
|
13209
|
+
throw Error(`'referralValue' should be in range [0, 100] BPS`);
|
|
13210
|
+
}
|
|
13211
|
+
return beginCell13().storeUint(DEX_OP_CODES2.SWAP, 32).storeAddress(toAddress(params.askJettonWalletAddress)).storeAddress(toAddress(params.refundAddress)).storeAddress(toAddress(params.excessesAddress ?? params.refundAddress)).storeUint(params.deadline ?? this.defaultDeadline, 64).storeRef(
|
|
13212
|
+
beginCell13().storeCoins(BigInt(params.minAskAmount)).storeAddress(toAddress(params.receiverAddress)).storeCoins(BigInt(params.dexCustomPayloadForwardGasAmount ?? 0)).storeMaybeRef(params.dexCustomPayload).storeCoins(BigInt(params.refundForwardGasAmount ?? 0)).storeMaybeRef(params.refundPayload).storeUint(BigInt(params.referralValue ?? 10), 16).storeAddress(this.maybeReferralAddress(params.referralAddress)).endCell()
|
|
13213
|
+
).endCell();
|
|
13214
|
+
}
|
|
13215
|
+
async createCrossSwapBody(params) {
|
|
13216
|
+
if (params.referralValue && (BigInt(params.referralValue) < 0 || BigInt(params.referralValue) > 100)) {
|
|
13217
|
+
throw Error(`'referralValue' should be in range [0, 100] BPS`);
|
|
13218
|
+
}
|
|
13219
|
+
return beginCell13().storeUint(DEX_OP_CODES2.CROSS_SWAP, 32).storeAddress(toAddress(params.askJettonWalletAddress)).storeAddress(toAddress(params.refundAddress)).storeAddress(toAddress(params.excessesAddress ?? params.refundAddress)).storeUint(params.deadline ?? this.defaultDeadline, 64).storeRef(
|
|
13220
|
+
beginCell13().storeCoins(BigInt(params.minAskAmount)).storeAddress(toAddress(params.receiverAddress)).storeCoins(BigInt(params.dexCustomPayloadForwardGasAmount ?? 0)).storeMaybeRef(params.dexCustomPayload).storeCoins(BigInt(params.refundForwardGasAmount ?? 0)).storeMaybeRef(params.refundPayload).storeUint(BigInt(params.referralValue ?? 10), 16).storeAddress(this.maybeReferralAddress(params.referralAddress)).endCell()
|
|
13221
|
+
).endCell();
|
|
13222
|
+
}
|
|
13223
|
+
async getSwapJettonToJettonTxParams(provider, params) {
|
|
13224
|
+
const contractAddress = this.address;
|
|
13225
|
+
const [offerJettonWalletAddress, askJettonWalletAddress] = await Promise.all([
|
|
13226
|
+
params.offerJettonWalletAddress ? toAddress(params.offerJettonWalletAddress) : provider.open(JettonMinter.create(params.offerJettonAddress)).getWalletAddress(params.userWalletAddress),
|
|
13227
|
+
params.askJettonWalletAddress ? params.askJettonWalletAddress : provider.open(JettonMinter.create(params.askJettonAddress)).getWalletAddress(this.address)
|
|
13228
|
+
]);
|
|
13229
|
+
const forwardTonAmount = BigInt(
|
|
13230
|
+
params.forwardGasAmount ?? this.gasConstants.swapJettonToJetton.forwardGasAmount
|
|
13231
|
+
);
|
|
13232
|
+
const forwardPayload = await this.createSwapBody({
|
|
13233
|
+
askJettonWalletAddress,
|
|
13234
|
+
receiverAddress: params.receiverAddress ?? params.userWalletAddress,
|
|
13235
|
+
minAskAmount: params.minAskAmount,
|
|
13236
|
+
refundAddress: params.refundAddress ?? params.userWalletAddress,
|
|
13237
|
+
excessesAddress: params.excessesAddress,
|
|
13238
|
+
referralAddress: params.referralAddress,
|
|
13239
|
+
referralValue: params.referralValue,
|
|
13240
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13241
|
+
dexCustomPayloadForwardGasAmount: params.dexCustomPayloadForwardGasAmount,
|
|
13242
|
+
refundPayload: params.refundPayload,
|
|
13243
|
+
refundForwardGasAmount: params.refundForwardGasAmount,
|
|
13244
|
+
deadline: params.deadline
|
|
13245
|
+
});
|
|
13246
|
+
const body = createJettonTransferMessage({
|
|
13247
|
+
queryId: params.queryId ?? 0,
|
|
13248
|
+
amount: params.offerAmount,
|
|
13249
|
+
destination: contractAddress,
|
|
13250
|
+
responseDestination: params.transferExcessAddress ?? params.userWalletAddress,
|
|
13251
|
+
customPayload: params.jettonCustomPayload,
|
|
13252
|
+
forwardTonAmount,
|
|
13253
|
+
forwardPayload
|
|
13254
|
+
});
|
|
13255
|
+
const value = BigInt(
|
|
13256
|
+
params.gasAmount ?? this.gasConstants.swapJettonToJetton.gasAmount
|
|
13257
|
+
);
|
|
13258
|
+
return {
|
|
13259
|
+
to: offerJettonWalletAddress,
|
|
13260
|
+
value,
|
|
13261
|
+
body
|
|
13262
|
+
};
|
|
13263
|
+
}
|
|
13264
|
+
async sendSwapJettonToJetton(provider, via, params) {
|
|
13265
|
+
const txParams = await this.getSwapJettonToJettonTxParams(provider, params);
|
|
13266
|
+
return via.send(txParams);
|
|
13267
|
+
}
|
|
13268
|
+
async getSwapJettonToTonTxParams(provider, params) {
|
|
13269
|
+
this.assertProxyTon(params.proxyTon);
|
|
13270
|
+
return await this.getSwapJettonToJettonTxParams(provider, {
|
|
13271
|
+
...params,
|
|
13272
|
+
askJettonAddress: params.proxyTon.address,
|
|
13273
|
+
askJettonWalletAddress: params.askJettonWalletAddress,
|
|
13274
|
+
gasAmount: params.gasAmount ?? this.gasConstants.swapJettonToTon.gasAmount,
|
|
13275
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.swapJettonToTon.forwardGasAmount
|
|
13276
|
+
});
|
|
13277
|
+
}
|
|
13278
|
+
async sendSwapJettonToTon(provider, via, params) {
|
|
13279
|
+
const txParams = await this.getSwapJettonToTonTxParams(provider, params);
|
|
13280
|
+
return via.send(txParams);
|
|
13281
|
+
}
|
|
13282
|
+
async getSwapTonToJettonTxParams(provider, params) {
|
|
13283
|
+
this.assertProxyTon(params.proxyTon);
|
|
13284
|
+
const contractAddress = this.address;
|
|
13285
|
+
const askJettonWalletAddress = params.askJettonWalletAddress ?? await provider.open(JettonMinter.create(params.askJettonAddress)).getWalletAddress(contractAddress);
|
|
13286
|
+
const forwardPayload = await this.createSwapBody({
|
|
13287
|
+
askJettonWalletAddress,
|
|
13288
|
+
receiverAddress: params.receiverAddress ?? params.userWalletAddress,
|
|
13289
|
+
minAskAmount: params.minAskAmount,
|
|
13290
|
+
refundAddress: params.refundAddress ?? params.userWalletAddress,
|
|
13291
|
+
excessesAddress: params.excessesAddress,
|
|
13292
|
+
referralAddress: params.referralAddress,
|
|
13293
|
+
referralValue: params.referralValue,
|
|
13294
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13295
|
+
dexCustomPayloadForwardGasAmount: params.dexCustomPayloadForwardGasAmount,
|
|
13296
|
+
refundPayload: params.refundPayload,
|
|
13297
|
+
refundForwardGasAmount: params.refundForwardGasAmount,
|
|
13298
|
+
deadline: params.deadline
|
|
13299
|
+
});
|
|
13300
|
+
const forwardTonAmount = BigInt(
|
|
13301
|
+
params.forwardGasAmount ?? this.gasConstants.swapTonToJetton.forwardGasAmount
|
|
13302
|
+
);
|
|
13303
|
+
return await provider.open(params.proxyTon).getTonTransferTxParams({
|
|
13304
|
+
queryId: params.queryId ?? 0,
|
|
13305
|
+
tonAmount: params.offerAmount,
|
|
13306
|
+
destinationAddress: contractAddress,
|
|
13307
|
+
destinationWalletAddress: params.offerJettonWalletAddress,
|
|
13308
|
+
refundAddress: params.userWalletAddress,
|
|
13309
|
+
forwardPayload,
|
|
13310
|
+
forwardTonAmount
|
|
13311
|
+
});
|
|
13312
|
+
}
|
|
13313
|
+
async sendSwapTonToJetton(provider, via, params) {
|
|
13314
|
+
const txParams = await this.getSwapTonToJettonTxParams(provider, params);
|
|
13315
|
+
return via.send(txParams);
|
|
13316
|
+
}
|
|
13317
|
+
async createProvideLiquidityBody(params) {
|
|
13318
|
+
return beginCell13().storeUint(DEX_OP_CODES2.PROVIDE_LP, 32).storeAddress(toAddress(params.routerWalletAddress)).storeAddress(toAddress(params.refundAddress)).storeAddress(toAddress(params.excessesAddress ?? params.refundAddress)).storeUint(params.deadline ?? this.defaultDeadline, 64).storeRef(
|
|
13319
|
+
beginCell13().storeCoins(BigInt(params.minLpOut)).storeAddress(toAddress(params.receiverAddress)).storeUint(params.bothPositive ? 1 : 0, 1).storeCoins(BigInt(params.dexCustomPayloadForwardGasAmount ?? 0)).storeMaybeRef(params.dexCustomPayload).endCell()
|
|
13320
|
+
).endCell();
|
|
13321
|
+
}
|
|
13322
|
+
async getProvideLiquidityJettonTxParams(provider, params) {
|
|
13323
|
+
return this.implGetProvideLiquidityJettonTxParams(provider, {
|
|
13324
|
+
...params,
|
|
13325
|
+
gasAmount: params.gasAmount ?? this.gasConstants.provideLpJetton.gasAmount,
|
|
13326
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.provideLpJetton.forwardGasAmount,
|
|
13327
|
+
bothPositive: true
|
|
13328
|
+
});
|
|
13329
|
+
}
|
|
13330
|
+
async sendProvideLiquidityJetton(provider, via, params) {
|
|
13331
|
+
const txParams = await this.getProvideLiquidityJettonTxParams(
|
|
13332
|
+
provider,
|
|
13333
|
+
params
|
|
13334
|
+
);
|
|
13335
|
+
return via.send(txParams);
|
|
13336
|
+
}
|
|
13337
|
+
async getSingleSideProvideLiquidityJettonTxParams(provider, params) {
|
|
13338
|
+
return this.implGetProvideLiquidityJettonTxParams(provider, {
|
|
13339
|
+
...params,
|
|
13340
|
+
gasAmount: params.gasAmount ?? this.gasConstants.singleSideProvideLpJetton.gasAmount,
|
|
13341
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.singleSideProvideLpJetton.forwardGasAmount,
|
|
13342
|
+
bothPositive: false
|
|
13343
|
+
});
|
|
13344
|
+
}
|
|
13345
|
+
async sendSingleSideProvideLiquidityJetton(provider, via, params) {
|
|
13346
|
+
const txParams = await this.getSingleSideProvideLiquidityJettonTxParams(
|
|
13347
|
+
provider,
|
|
13348
|
+
params
|
|
13349
|
+
);
|
|
13350
|
+
return via.send(txParams);
|
|
13351
|
+
}
|
|
13352
|
+
async implGetProvideLiquidityJettonTxParams(provider, params) {
|
|
13353
|
+
const contractAddress = this.address;
|
|
13354
|
+
const [jettonWalletAddress, routerWalletAddress] = await Promise.all([
|
|
13355
|
+
provider.open(JettonMinter.create(params.sendTokenAddress)).getWalletAddress(params.userWalletAddress),
|
|
13356
|
+
provider.open(JettonMinter.create(params.otherTokenAddress)).getWalletAddress(contractAddress)
|
|
13357
|
+
]);
|
|
13358
|
+
const forwardPayload = await this.createProvideLiquidityBody({
|
|
13359
|
+
routerWalletAddress,
|
|
13360
|
+
receiverAddress: params.receiverAddress ?? params.userWalletAddress,
|
|
13361
|
+
minLpOut: params.minLpOut,
|
|
13362
|
+
refundAddress: params.refundAddress ?? params.userWalletAddress,
|
|
13363
|
+
excessesAddress: params.excessesAddress,
|
|
13364
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13365
|
+
dexCustomPayloadForwardGasAmount: params.dexCustomPayloadForwardGasAmount,
|
|
13366
|
+
bothPositive: params.bothPositive,
|
|
13367
|
+
deadline: params.deadline
|
|
13368
|
+
});
|
|
13369
|
+
const forwardTonAmount = BigInt(params.forwardGasAmount);
|
|
13370
|
+
const body = createJettonTransferMessage({
|
|
13371
|
+
queryId: params.queryId ?? 0,
|
|
13372
|
+
amount: params.sendAmount,
|
|
13373
|
+
destination: contractAddress,
|
|
13374
|
+
responseDestination: params.transferExcessAddress ?? params.userWalletAddress,
|
|
13375
|
+
customPayload: params.jettonCustomPayload,
|
|
13376
|
+
forwardTonAmount,
|
|
13377
|
+
forwardPayload
|
|
13378
|
+
});
|
|
13379
|
+
const value = BigInt(params.gasAmount);
|
|
13380
|
+
return {
|
|
13381
|
+
to: jettonWalletAddress,
|
|
13382
|
+
value,
|
|
13383
|
+
body
|
|
13384
|
+
};
|
|
13385
|
+
}
|
|
13386
|
+
async getProvideLiquidityTonTxParams(provider, params) {
|
|
13387
|
+
return this.implGetProvideLiquidityTonTxParams(provider, {
|
|
13388
|
+
...params,
|
|
13389
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.provideLpTon.forwardGasAmount,
|
|
13390
|
+
bothPositive: true
|
|
13391
|
+
});
|
|
13392
|
+
}
|
|
13393
|
+
async sendProvideLiquidityTon(provider, via, params) {
|
|
13394
|
+
const txParams = await this.getProvideLiquidityTonTxParams(
|
|
13395
|
+
provider,
|
|
13396
|
+
params
|
|
13397
|
+
);
|
|
13398
|
+
return via.send(txParams);
|
|
13399
|
+
}
|
|
13400
|
+
async getSingleSideProvideLiquidityTonTxParams(provider, params) {
|
|
13401
|
+
return this.implGetProvideLiquidityTonTxParams(provider, {
|
|
13402
|
+
...params,
|
|
13403
|
+
forwardGasAmount: params.forwardGasAmount ?? this.gasConstants.singleSideProvideLpTon.forwardGasAmount,
|
|
13404
|
+
bothPositive: false
|
|
13405
|
+
});
|
|
13406
|
+
}
|
|
13407
|
+
async sendSingleSideProvideLiquidityTon(provider, via, params) {
|
|
13408
|
+
const txParams = await this.getSingleSideProvideLiquidityTonTxParams(
|
|
13409
|
+
provider,
|
|
13410
|
+
params
|
|
13411
|
+
);
|
|
13412
|
+
return via.send(txParams);
|
|
13413
|
+
}
|
|
13414
|
+
async implGetProvideLiquidityTonTxParams(provider, params) {
|
|
13415
|
+
this.assertProxyTon(params.proxyTon);
|
|
13416
|
+
const contractAddress = this.address;
|
|
13417
|
+
const routerWalletAddress = await provider.open(JettonMinter.create(params.otherTokenAddress)).getWalletAddress(contractAddress);
|
|
13418
|
+
const forwardPayload = await this.createProvideLiquidityBody({
|
|
13419
|
+
routerWalletAddress,
|
|
13420
|
+
receiverAddress: params.receiverAddress ?? params.userWalletAddress,
|
|
13421
|
+
minLpOut: params.minLpOut,
|
|
13422
|
+
refundAddress: params.refundAddress ?? params.userWalletAddress,
|
|
13423
|
+
excessesAddress: params.excessesAddress,
|
|
13424
|
+
dexCustomPayload: params.dexCustomPayload,
|
|
13425
|
+
dexCustomPayloadForwardGasAmount: params.dexCustomPayloadForwardGasAmount,
|
|
13426
|
+
bothPositive: params.bothPositive,
|
|
13427
|
+
deadline: params.deadline
|
|
13428
|
+
});
|
|
13429
|
+
const forwardTonAmount = BigInt(params.forwardGasAmount);
|
|
13430
|
+
return await provider.open(params.proxyTon).getTonTransferTxParams({
|
|
13431
|
+
queryId: params.queryId ?? 0,
|
|
13432
|
+
tonAmount: params.sendAmount,
|
|
13433
|
+
destinationAddress: contractAddress,
|
|
13434
|
+
refundAddress: params.userWalletAddress,
|
|
13435
|
+
forwardPayload,
|
|
13436
|
+
forwardTonAmount
|
|
13437
|
+
});
|
|
13438
|
+
}
|
|
13439
|
+
maybeReferralAddress(referralAddress) {
|
|
13440
|
+
if (!referralAddress) return null;
|
|
13441
|
+
const referralAddressParsed = toAddress(referralAddress);
|
|
13442
|
+
if (referralAddressParsed.equals(HOLE_ADDRESS)) return null;
|
|
13443
|
+
return referralAddressParsed;
|
|
13444
|
+
}
|
|
13445
|
+
get defaultDeadline() {
|
|
13446
|
+
return Math.floor(Date.now() / 1e3) + this.txDeadline;
|
|
13447
|
+
}
|
|
13448
|
+
assertProxyTon(proxyTon) {
|
|
13449
|
+
if (proxyTon.version !== pTON_VERSION.v2_1) {
|
|
13450
|
+
throw new UnmatchedPtonVersion({
|
|
13451
|
+
expected: pTON_VERSION.v2_1,
|
|
13452
|
+
received: proxyTon.version
|
|
13453
|
+
});
|
|
13454
|
+
}
|
|
13455
|
+
}
|
|
13456
|
+
async getPoolAddress(provider, params) {
|
|
13457
|
+
const result = await provider.get("get_pool_address", [
|
|
13458
|
+
{
|
|
13459
|
+
type: "slice",
|
|
13460
|
+
cell: beginCell13().storeAddress(toAddress(params.token0)).endCell()
|
|
13461
|
+
},
|
|
13462
|
+
{
|
|
13463
|
+
type: "slice",
|
|
13464
|
+
cell: beginCell13().storeAddress(toAddress(params.token1)).endCell()
|
|
13465
|
+
}
|
|
13466
|
+
]);
|
|
13467
|
+
return result.stack.readAddress();
|
|
13468
|
+
}
|
|
13469
|
+
async getPoolAddressByJettonMinters(provider, params) {
|
|
13470
|
+
const [jetton0WalletAddress, jetton1WalletAddress] = await Promise.all([
|
|
13471
|
+
provider.open(JettonMinter.create(params.token0)).getWalletAddress(this.address),
|
|
13472
|
+
provider.open(JettonMinter.create(params.token1)).getWalletAddress(this.address)
|
|
13473
|
+
]);
|
|
13474
|
+
const poolAddress = await this.getPoolAddress(provider, {
|
|
13475
|
+
token0: jetton0WalletAddress,
|
|
13476
|
+
token1: jetton1WalletAddress
|
|
13477
|
+
});
|
|
13478
|
+
return poolAddress;
|
|
13479
|
+
}
|
|
13480
|
+
async getPool(provider, params) {
|
|
13481
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13482
|
+
provider,
|
|
13483
|
+
params
|
|
13484
|
+
);
|
|
13485
|
+
return BasePoolV2_1.create(poolAddress);
|
|
13486
|
+
}
|
|
13487
|
+
async getVaultAddress(provider, params) {
|
|
13488
|
+
const result = await provider.get("get_vault_address", [
|
|
13489
|
+
{
|
|
13490
|
+
type: "slice",
|
|
13491
|
+
cell: beginCell13().storeAddress(toAddress(params.user)).endCell()
|
|
13492
|
+
},
|
|
13493
|
+
{
|
|
13494
|
+
type: "slice",
|
|
13495
|
+
cell: beginCell13().storeAddress(toAddress(params.tokenWallet)).endCell()
|
|
13496
|
+
}
|
|
13497
|
+
]);
|
|
13498
|
+
return result.stack.readAddress();
|
|
13499
|
+
}
|
|
13500
|
+
async getVault(provider, params) {
|
|
13501
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13502
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13503
|
+
user: params.user,
|
|
13504
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13505
|
+
});
|
|
13506
|
+
return VaultV2_1.create(vaultAddress);
|
|
13507
|
+
}
|
|
13508
|
+
async getRouterVersion(provider) {
|
|
13509
|
+
const result = await provider.get("get_router_version", []);
|
|
13510
|
+
return {
|
|
13511
|
+
major: result.stack.readNumber(),
|
|
13512
|
+
minor: result.stack.readNumber(),
|
|
13513
|
+
development: result.stack.readString()
|
|
13514
|
+
};
|
|
13515
|
+
}
|
|
13516
|
+
async getRouterData(provider) {
|
|
13517
|
+
const result = await provider.get("get_router_data", []);
|
|
13518
|
+
return {
|
|
13519
|
+
routerId: result.stack.readNumber(),
|
|
13520
|
+
dexType: result.stack.readString(),
|
|
13521
|
+
isLocked: result.stack.readBoolean(),
|
|
13522
|
+
adminAddress: result.stack.readAddress(),
|
|
13523
|
+
tempUpgrade: result.stack.readCell(),
|
|
13524
|
+
poolCode: result.stack.readCell(),
|
|
13525
|
+
jettonLpWalletCode: result.stack.readCell(),
|
|
13526
|
+
lpAccountCode: result.stack.readCell(),
|
|
13527
|
+
vaultCode: result.stack.readCell()
|
|
13528
|
+
};
|
|
13529
|
+
}
|
|
13530
|
+
};
|
|
13531
|
+
|
|
13532
|
+
// node_modules/@ston-fi/sdk/dist/chunk-PFDB63A3.js
|
|
13533
|
+
var CPIPoolV2_1 = class extends BasePoolV2_1 {
|
|
13534
|
+
static dexType = DEX_TYPE.CPI;
|
|
13535
|
+
async getPoolData(provider) {
|
|
13536
|
+
const data = await this.implGetPoolData(provider);
|
|
13537
|
+
return {
|
|
13538
|
+
...data.commonPoolData
|
|
13539
|
+
};
|
|
13540
|
+
}
|
|
13541
|
+
};
|
|
13542
|
+
|
|
13543
|
+
// node_modules/@ston-fi/sdk/dist/chunk-IFMGU6GB.js
|
|
13544
|
+
var CPIRouterV2_1 = class extends BaseRouterV2_1 {
|
|
13545
|
+
static dexType = DEX_TYPE.CPI;
|
|
13546
|
+
async getPool(provider, params) {
|
|
13547
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13548
|
+
provider,
|
|
13549
|
+
params
|
|
13550
|
+
);
|
|
13551
|
+
return CPIPoolV2_1.create(poolAddress);
|
|
13552
|
+
}
|
|
13553
|
+
};
|
|
13554
|
+
|
|
13555
|
+
// node_modules/@ston-fi/sdk/dist/chunk-KXPOQKNK.js
|
|
13556
|
+
var StablePoolV2_1 = class extends BasePoolV2_1 {
|
|
13557
|
+
static dexType = DEX_TYPE.Stable;
|
|
13558
|
+
async getPoolData(provider) {
|
|
13559
|
+
const data = await this.implGetPoolData(provider);
|
|
13560
|
+
return {
|
|
13561
|
+
...data.commonPoolData,
|
|
13562
|
+
amp: data.stack.readBigNumber()
|
|
13563
|
+
};
|
|
13564
|
+
}
|
|
13565
|
+
};
|
|
13566
|
+
|
|
13567
|
+
// node_modules/@ston-fi/sdk/dist/chunk-VFE4LTGM.js
|
|
13568
|
+
import { toNano as toNano14 } from "@ton/ton";
|
|
13569
|
+
var StableRouterV2_1 = class _StableRouterV2_1 extends BaseRouterV2_1 {
|
|
13570
|
+
static dexType = DEX_TYPE.Stable;
|
|
13571
|
+
static gasConstants = {
|
|
13572
|
+
...BaseRouterV2_1.gasConstants,
|
|
13573
|
+
swapJettonToJetton: {
|
|
13574
|
+
gasAmount: toNano14("0.329"),
|
|
13575
|
+
forwardGasAmount: toNano14("0.269")
|
|
13576
|
+
},
|
|
13577
|
+
swapJettonToTon: {
|
|
13578
|
+
gasAmount: toNano14("0.329"),
|
|
13579
|
+
forwardGasAmount: toNano14("0.269")
|
|
13580
|
+
},
|
|
13581
|
+
swapTonToJetton: {
|
|
13582
|
+
forwardGasAmount: toNano14("0.329")
|
|
13583
|
+
}
|
|
13584
|
+
};
|
|
13585
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
13586
|
+
super(address4, {
|
|
13587
|
+
...options,
|
|
13588
|
+
gasConstants: {
|
|
13589
|
+
..._StableRouterV2_1.gasConstants,
|
|
13590
|
+
...gasConstants
|
|
13591
|
+
}
|
|
13592
|
+
});
|
|
13593
|
+
}
|
|
13594
|
+
async getPool(provider, params) {
|
|
13595
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13596
|
+
provider,
|
|
13597
|
+
params
|
|
13598
|
+
);
|
|
13599
|
+
return StablePoolV2_1.create(poolAddress);
|
|
13600
|
+
}
|
|
13601
|
+
};
|
|
13602
|
+
|
|
13603
|
+
// node_modules/@ston-fi/sdk/dist/chunk-XEXEDC3T.js
|
|
13604
|
+
var WCPIPoolV2_1 = class extends BasePoolV2_1 {
|
|
13605
|
+
static dexType = DEX_TYPE.WCPI;
|
|
13606
|
+
async getPoolData(provider) {
|
|
13607
|
+
const data = await this.implGetPoolData(provider);
|
|
13608
|
+
return {
|
|
13609
|
+
...data.commonPoolData
|
|
13610
|
+
};
|
|
13611
|
+
}
|
|
13612
|
+
};
|
|
13613
|
+
|
|
13614
|
+
// node_modules/@ston-fi/sdk/dist/chunk-FU2GQY36.js
|
|
13615
|
+
import { toNano as toNano15 } from "@ton/ton";
|
|
13616
|
+
var WCPIRouterV2_1 = class _WCPIRouterV2_1 extends BaseRouterV2_1 {
|
|
13617
|
+
static dexType = DEX_TYPE.WCPI;
|
|
13618
|
+
static gasConstants = {
|
|
13619
|
+
...BaseRouterV2_1.gasConstants,
|
|
13620
|
+
swapJettonToJetton: {
|
|
13621
|
+
gasAmount: toNano15("0.319"),
|
|
13622
|
+
forwardGasAmount: toNano15("0.259")
|
|
13623
|
+
},
|
|
13624
|
+
swapJettonToTon: {
|
|
13625
|
+
gasAmount: toNano15("0.319"),
|
|
13626
|
+
forwardGasAmount: toNano15("0.259")
|
|
13627
|
+
},
|
|
13628
|
+
swapTonToJetton: {
|
|
13629
|
+
forwardGasAmount: toNano15("0.319")
|
|
13630
|
+
}
|
|
13631
|
+
};
|
|
13632
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
13633
|
+
super(address4, {
|
|
13634
|
+
...options,
|
|
13635
|
+
gasConstants: {
|
|
13636
|
+
..._WCPIRouterV2_1.gasConstants,
|
|
13637
|
+
...gasConstants
|
|
13638
|
+
}
|
|
13639
|
+
});
|
|
13640
|
+
}
|
|
13641
|
+
async getPool(provider, params) {
|
|
13642
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13643
|
+
provider,
|
|
13644
|
+
params
|
|
13645
|
+
);
|
|
13646
|
+
return WCPIPoolV2_1.create(poolAddress);
|
|
13647
|
+
}
|
|
13648
|
+
};
|
|
13649
|
+
|
|
13650
|
+
// node_modules/@ston-fi/sdk/dist/chunk-D5R4VQ3E.js
|
|
13651
|
+
var WStablePoolV2_1 = class extends BasePoolV2_1 {
|
|
13652
|
+
static dexType = DEX_TYPE.WStable;
|
|
13653
|
+
async getPoolData(provider) {
|
|
13654
|
+
const data = await this.implGetPoolData(provider);
|
|
13655
|
+
return {
|
|
13656
|
+
...data.commonPoolData,
|
|
13657
|
+
amp: data.stack.readBigNumber(),
|
|
13658
|
+
rate: data.stack.readBigNumber(),
|
|
13659
|
+
w0: data.stack.readBigNumber(),
|
|
13660
|
+
rateSetterAddress: data.stack.readAddressOpt()
|
|
13661
|
+
};
|
|
13662
|
+
}
|
|
13663
|
+
};
|
|
13664
|
+
|
|
13665
|
+
// node_modules/@ston-fi/sdk/dist/chunk-KTS34XTO.js
|
|
13666
|
+
import { toNano as toNano16 } from "@ton/ton";
|
|
13667
|
+
var WStableRouterV2_1 = class _WStableRouterV2_1 extends BaseRouterV2_1 {
|
|
13668
|
+
static dexType = DEX_TYPE.WStable;
|
|
13669
|
+
static gasConstants = {
|
|
13670
|
+
...BaseRouterV2_1.gasConstants,
|
|
13671
|
+
swapJettonToJetton: {
|
|
13672
|
+
gasAmount: toNano16("0.479"),
|
|
13673
|
+
forwardGasAmount: toNano16("0.419")
|
|
13674
|
+
},
|
|
13675
|
+
swapJettonToTon: {
|
|
13676
|
+
gasAmount: toNano16("0.479"),
|
|
13677
|
+
forwardGasAmount: toNano16("0.419")
|
|
13678
|
+
},
|
|
13679
|
+
swapTonToJetton: {
|
|
13680
|
+
forwardGasAmount: toNano16("0.479")
|
|
13681
|
+
}
|
|
13682
|
+
};
|
|
13683
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
13684
|
+
super(address4, {
|
|
13685
|
+
...options,
|
|
13686
|
+
gasConstants: {
|
|
13687
|
+
..._WStableRouterV2_1.gasConstants,
|
|
13688
|
+
...gasConstants
|
|
13689
|
+
}
|
|
13690
|
+
});
|
|
13691
|
+
}
|
|
13692
|
+
async getPool(provider, params) {
|
|
13693
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13694
|
+
provider,
|
|
13695
|
+
params
|
|
13696
|
+
);
|
|
13697
|
+
return WStablePoolV2_1.create(poolAddress);
|
|
13698
|
+
}
|
|
13699
|
+
};
|
|
13700
|
+
|
|
13701
|
+
// node_modules/@ston-fi/sdk/dist/chunk-ZSA5H7PV.js
|
|
13702
|
+
var pTON_OP_CODES2 = {
|
|
13703
|
+
TON_TRANSFER: 32736093,
|
|
13704
|
+
DEPLOY_WALLET: 1331643155
|
|
13705
|
+
};
|
|
13706
|
+
|
|
13707
|
+
// node_modules/@ston-fi/sdk/dist/chunk-4OOOZ56G.js
|
|
13708
|
+
import {
|
|
13709
|
+
beginCell as beginCell14,
|
|
13710
|
+
toNano as toNano17
|
|
13711
|
+
} from "@ton/ton";
|
|
13712
|
+
var PtonV2_1 = class _PtonV2_1 extends PtonV1 {
|
|
13713
|
+
static version = pTON_VERSION.v2_1;
|
|
13714
|
+
static gasConstants = {
|
|
13715
|
+
tonTransfer: toNano17("0.01"),
|
|
13716
|
+
deployWallet: toNano17("0.1")
|
|
13717
|
+
};
|
|
13718
|
+
version = _PtonV2_1.version;
|
|
13719
|
+
gasConstants;
|
|
13720
|
+
constructor(address4, { gasConstants, ...options } = {}) {
|
|
13721
|
+
super(address4, options);
|
|
13722
|
+
this.gasConstants = {
|
|
13723
|
+
..._PtonV2_1.gasConstants,
|
|
13724
|
+
...gasConstants
|
|
13725
|
+
};
|
|
13726
|
+
}
|
|
13727
|
+
async createTonTransferBody(params) {
|
|
13728
|
+
const builder = beginCell14();
|
|
13729
|
+
builder.storeUint(pTON_OP_CODES2.TON_TRANSFER, 32);
|
|
13730
|
+
builder.storeUint(params.queryId ?? 0, 64);
|
|
13731
|
+
builder.storeCoins(BigInt(params.tonAmount));
|
|
13732
|
+
builder.storeAddress(toAddress(params.refundAddress));
|
|
13733
|
+
if (params.forwardPayload) {
|
|
13734
|
+
builder.storeBit(true);
|
|
13735
|
+
builder.storeRef(params.forwardPayload);
|
|
13736
|
+
} else {
|
|
13737
|
+
builder.storeBit(false);
|
|
13738
|
+
}
|
|
13739
|
+
return builder.endCell();
|
|
13740
|
+
}
|
|
13741
|
+
async getTonTransferTxParams(provider, params) {
|
|
13742
|
+
const to = params.destinationWalletAddress ? toAddress(params.destinationWalletAddress) : await this.getWalletAddress(provider, params.destinationAddress);
|
|
13743
|
+
const body = await this.createTonTransferBody({
|
|
13744
|
+
tonAmount: params.tonAmount,
|
|
13745
|
+
refundAddress: params.refundAddress,
|
|
13746
|
+
forwardPayload: params.forwardPayload,
|
|
13747
|
+
queryId: params.queryId
|
|
13748
|
+
});
|
|
13749
|
+
const value = BigInt(params.tonAmount) + BigInt(params.forwardTonAmount ?? 0) + BigInt(this.gasConstants.tonTransfer);
|
|
13750
|
+
return { to, value, body };
|
|
13751
|
+
}
|
|
13752
|
+
async sendTonTransfer(provider, via, params) {
|
|
13753
|
+
const txParams = await this.getTonTransferTxParams(provider, params);
|
|
13754
|
+
return via.send(txParams);
|
|
13755
|
+
}
|
|
13756
|
+
async createDeployWalletBody(params) {
|
|
13757
|
+
return beginCell14().storeUint(pTON_OP_CODES2.DEPLOY_WALLET, 32).storeUint(params.queryId ?? 0, 64).storeAddress(toAddress(params.ownerAddress)).storeAddress(toAddress(params.excessAddress)).endCell();
|
|
13758
|
+
}
|
|
13759
|
+
async getDeployWalletTxParams(provider, params) {
|
|
13760
|
+
const to = this.address;
|
|
13761
|
+
const body = await this.createDeployWalletBody({
|
|
13762
|
+
ownerAddress: params.ownerAddress,
|
|
13763
|
+
excessAddress: params.excessAddress,
|
|
13764
|
+
queryId: params?.queryId
|
|
13765
|
+
});
|
|
13766
|
+
const value = BigInt(params?.gasAmount ?? this.gasConstants.deployWallet);
|
|
13767
|
+
return { to, value, body };
|
|
13768
|
+
}
|
|
13769
|
+
async sendDeployWallet(provider, via, params) {
|
|
13770
|
+
const txParams = await this.getDeployWalletTxParams(provider, params);
|
|
13771
|
+
return via.send(txParams);
|
|
13772
|
+
}
|
|
13773
|
+
};
|
|
13774
|
+
|
|
13775
|
+
// node_modules/@ston-fi/sdk/dist/chunk-5LPE44J5.js
|
|
13776
|
+
var RouterV2_1 = class extends BaseRouterV2_1 {
|
|
13777
|
+
static CPI = CPIRouterV2_1;
|
|
13778
|
+
static Stable = StableRouterV2_1;
|
|
13779
|
+
static WCPI = WCPIRouterV2_1;
|
|
13780
|
+
static WStable = WStableRouterV2_1;
|
|
13781
|
+
};
|
|
13782
|
+
var PoolV2_1 = class extends BasePoolV2_1 {
|
|
13783
|
+
static CPI = CPIPoolV2_1;
|
|
13784
|
+
static Stable = StablePoolV2_1;
|
|
13785
|
+
static WCPI = WCPIPoolV2_1;
|
|
13786
|
+
static WStable = WStablePoolV2_1;
|
|
13787
|
+
};
|
|
13788
|
+
var DEX2 = {
|
|
13789
|
+
Router: RouterV2_1,
|
|
13790
|
+
Pool: PoolV2_1,
|
|
13791
|
+
LpAccount: LpAccountV2_1,
|
|
13792
|
+
Vault: VaultV2_1,
|
|
13793
|
+
pTON: PtonV2_1
|
|
13794
|
+
};
|
|
13795
|
+
|
|
13796
|
+
// node_modules/@ston-fi/sdk/dist/chunk-R6GQHPPW.js
|
|
13797
|
+
var VaultV2_2 = class extends VaultV2_1 {
|
|
13798
|
+
static version = DEX_VERSION.v2_2;
|
|
13799
|
+
};
|
|
13800
|
+
|
|
13801
|
+
// node_modules/@ston-fi/sdk/dist/chunk-XBZ6KIKA.js
|
|
13802
|
+
var LpAccountV2_2 = class extends LpAccountV2_1 {
|
|
13803
|
+
static version = DEX_VERSION.v2_2;
|
|
13804
|
+
};
|
|
13805
|
+
|
|
13806
|
+
// node_modules/@ston-fi/sdk/dist/chunk-UHNXDBA4.js
|
|
13807
|
+
var BasePoolV2_2 = class extends BasePoolV2_1 {
|
|
13808
|
+
static version = DEX_VERSION.v2_2;
|
|
13809
|
+
async getLpAccount(provider, params) {
|
|
13810
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13811
|
+
return LpAccountV2_2.create(lpAccountAddress);
|
|
13812
|
+
}
|
|
13813
|
+
};
|
|
13814
|
+
|
|
13815
|
+
// node_modules/@ston-fi/sdk/dist/chunk-W5BTFHCU.js
|
|
13816
|
+
var BaseRouterV2_2 = class extends BaseRouterV2_1 {
|
|
13817
|
+
static version = DEX_VERSION.v2_2;
|
|
13818
|
+
async getPool(provider, params) {
|
|
13819
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13820
|
+
provider,
|
|
13821
|
+
params
|
|
13822
|
+
);
|
|
13823
|
+
return BasePoolV2_2.create(poolAddress);
|
|
13824
|
+
}
|
|
13825
|
+
async getVault(provider, params) {
|
|
13826
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13827
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13828
|
+
user: params.user,
|
|
13829
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13830
|
+
});
|
|
13831
|
+
return VaultV2_2.create(vaultAddress);
|
|
13832
|
+
}
|
|
13833
|
+
};
|
|
13834
|
+
|
|
13835
|
+
// node_modules/@ston-fi/sdk/dist/chunk-MVLUFHSB.js
|
|
13836
|
+
var CPIPoolV2_2 = class extends CPIPoolV2_1 {
|
|
13837
|
+
static version = DEX_VERSION.v2_2;
|
|
13838
|
+
async getLpAccount(provider, params) {
|
|
13839
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13840
|
+
return LpAccountV2_2.create(lpAccountAddress);
|
|
13841
|
+
}
|
|
13842
|
+
};
|
|
13843
|
+
|
|
13844
|
+
// node_modules/@ston-fi/sdk/dist/chunk-PGCWH6QI.js
|
|
13845
|
+
var CPIRouterV2_2 = class extends CPIRouterV2_1 {
|
|
13846
|
+
static version = DEX_VERSION.v2_2;
|
|
13847
|
+
async getPool(provider, params) {
|
|
13848
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13849
|
+
provider,
|
|
13850
|
+
params
|
|
13851
|
+
);
|
|
13852
|
+
return CPIPoolV2_2.create(poolAddress);
|
|
13853
|
+
}
|
|
13854
|
+
async getVault(provider, params) {
|
|
13855
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13856
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13857
|
+
user: params.user,
|
|
13858
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13859
|
+
});
|
|
13860
|
+
return VaultV2_2.create(vaultAddress);
|
|
13861
|
+
}
|
|
13862
|
+
};
|
|
13863
|
+
|
|
13864
|
+
// node_modules/@ston-fi/sdk/dist/chunk-X3PT4LB6.js
|
|
13865
|
+
var StablePoolV2_2 = class extends StablePoolV2_1 {
|
|
13866
|
+
static version = DEX_VERSION.v2_2;
|
|
13867
|
+
async getLpAccount(provider, params) {
|
|
13868
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13869
|
+
return LpAccountV2_2.create(lpAccountAddress);
|
|
13870
|
+
}
|
|
13871
|
+
};
|
|
13872
|
+
|
|
13873
|
+
// node_modules/@ston-fi/sdk/dist/chunk-GHJFY7T3.js
|
|
13874
|
+
var StableRouterV2_2 = class extends StableRouterV2_1 {
|
|
13875
|
+
static version = DEX_VERSION.v2_2;
|
|
13876
|
+
async getPool(provider, params) {
|
|
13877
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13878
|
+
provider,
|
|
13879
|
+
params
|
|
13880
|
+
);
|
|
13881
|
+
return StablePoolV2_2.create(poolAddress);
|
|
13882
|
+
}
|
|
13883
|
+
async getVault(provider, params) {
|
|
13884
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13885
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13886
|
+
user: params.user,
|
|
13887
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13888
|
+
});
|
|
13889
|
+
return VaultV2_2.create(vaultAddress);
|
|
13890
|
+
}
|
|
13891
|
+
};
|
|
13892
|
+
|
|
13893
|
+
// node_modules/@ston-fi/sdk/dist/chunk-UBOSEJWA.js
|
|
13894
|
+
var WCPIPoolV2_2 = class extends WCPIPoolV2_1 {
|
|
13895
|
+
static version = DEX_VERSION.v2_2;
|
|
13896
|
+
async getLpAccount(provider, params) {
|
|
13897
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13898
|
+
return LpAccountV2_2.create(lpAccountAddress);
|
|
13899
|
+
}
|
|
13900
|
+
};
|
|
13901
|
+
|
|
13902
|
+
// node_modules/@ston-fi/sdk/dist/chunk-OW5D6WMM.js
|
|
13903
|
+
var WCPIRouterV2_2 = class extends WCPIRouterV2_1 {
|
|
13904
|
+
static version = DEX_VERSION.v2_2;
|
|
13905
|
+
async getPool(provider, params) {
|
|
13906
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13907
|
+
provider,
|
|
13908
|
+
params
|
|
13909
|
+
);
|
|
13910
|
+
return WCPIPoolV2_2.create(poolAddress);
|
|
13911
|
+
}
|
|
13912
|
+
async getVault(provider, params) {
|
|
13913
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13914
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13915
|
+
user: params.user,
|
|
13916
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13917
|
+
});
|
|
13918
|
+
return VaultV2_2.create(vaultAddress);
|
|
13919
|
+
}
|
|
13920
|
+
};
|
|
13921
|
+
|
|
13922
|
+
// node_modules/@ston-fi/sdk/dist/chunk-DCJ3CQ52.js
|
|
13923
|
+
var WStablePoolV2_2 = class extends WStablePoolV2_1 {
|
|
13924
|
+
static version = DEX_VERSION.v2_2;
|
|
13925
|
+
async getLpAccount(provider, params) {
|
|
13926
|
+
const lpAccountAddress = await this.getLpAccountAddress(provider, params);
|
|
13927
|
+
return LpAccountV2_2.create(lpAccountAddress);
|
|
13928
|
+
}
|
|
13929
|
+
};
|
|
13930
|
+
|
|
13931
|
+
// node_modules/@ston-fi/sdk/dist/chunk-5L3VBOB3.js
|
|
13932
|
+
var WStableRouterV2_2 = class extends WStableRouterV2_1 {
|
|
13933
|
+
static version = DEX_VERSION.v2_2;
|
|
13934
|
+
async getPool(provider, params) {
|
|
13935
|
+
const poolAddress = await this.getPoolAddressByJettonMinters(
|
|
13936
|
+
provider,
|
|
13937
|
+
params
|
|
13938
|
+
);
|
|
13939
|
+
return WStablePoolV2_2.create(poolAddress);
|
|
13940
|
+
}
|
|
13941
|
+
async getVault(provider, params) {
|
|
13942
|
+
const tokenMinter = provider.open(JettonMinter.create(params.tokenMinter));
|
|
13943
|
+
const vaultAddress = await this.getVaultAddress(provider, {
|
|
13944
|
+
user: params.user,
|
|
13945
|
+
tokenWallet: await tokenMinter.getWalletAddress(this.address)
|
|
13946
|
+
});
|
|
13947
|
+
return VaultV2_2.create(vaultAddress);
|
|
13948
|
+
}
|
|
13949
|
+
};
|
|
13950
|
+
|
|
13951
|
+
// node_modules/@ston-fi/sdk/dist/chunk-UFVKG5I6.js
|
|
13952
|
+
var RouterV2_2 = class extends BaseRouterV2_2 {
|
|
13953
|
+
static CPI = CPIRouterV2_2;
|
|
13954
|
+
static Stable = StableRouterV2_2;
|
|
13955
|
+
static WCPI = WCPIRouterV2_2;
|
|
13956
|
+
static WStable = WStableRouterV2_2;
|
|
13957
|
+
};
|
|
13958
|
+
var PoolV2_2 = class extends BasePoolV2_2 {
|
|
13959
|
+
static CPI = CPIPoolV2_2;
|
|
13960
|
+
static Stable = StablePoolV2_2;
|
|
13961
|
+
static WCPI = WCPIPoolV2_2;
|
|
13962
|
+
static WStable = WStablePoolV2_2;
|
|
13963
|
+
};
|
|
13964
|
+
var DEX3 = {
|
|
13965
|
+
Router: RouterV2_2,
|
|
13966
|
+
Pool: PoolV2_2,
|
|
13967
|
+
LpAccount: LpAccountV2_2,
|
|
13968
|
+
Vault: VaultV2_2,
|
|
13969
|
+
pTON: PtonV2_1
|
|
13970
|
+
};
|
|
13971
|
+
|
|
13972
|
+
// node_modules/@ston-fi/sdk/dist/chunk-TGJ3Z7X3.js
|
|
13973
|
+
var DEX4 = {
|
|
13974
|
+
[DEX_VERSION.v1]: DEX,
|
|
13975
|
+
[DEX_VERSION.v2_1]: DEX2,
|
|
13976
|
+
[DEX_VERSION.v2_2]: DEX3
|
|
13977
|
+
};
|
|
13978
|
+
|
|
13979
|
+
// node_modules/@ston-fi/sdk/dist/chunk-6QVKWEJ2.js
|
|
13980
|
+
var pTON = {
|
|
13981
|
+
[pTON_VERSION.v1]: PtonV1,
|
|
13982
|
+
[pTON_VERSION.v2_1]: PtonV2_1
|
|
13983
|
+
};
|
|
13984
|
+
|
|
13985
|
+
// node_modules/@ston-fi/api/dist/esm/index.js
|
|
13986
|
+
import { ofetch } from "ofetch";
|
|
13987
|
+
var __create = Object.create;
|
|
13988
|
+
var __defProp = Object.defineProperty;
|
|
13989
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13990
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13991
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13992
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13993
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
13994
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13995
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13996
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13997
|
+
key = keys[i];
|
|
13998
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13999
|
+
__defProp(to, key, {
|
|
14000
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14001
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14002
|
+
});
|
|
14003
|
+
}
|
|
14004
|
+
}
|
|
14005
|
+
}
|
|
14006
|
+
return to;
|
|
14007
|
+
};
|
|
14008
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
14009
|
+
value: mod,
|
|
14010
|
+
enumerable: true
|
|
14011
|
+
}) : target, mod));
|
|
14012
|
+
var normalizeDate = (date) => {
|
|
14013
|
+
return date.toISOString().split(".")[0];
|
|
14014
|
+
};
|
|
14015
|
+
var require_map_obj = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
14016
|
+
const isObject2 = (value) => typeof value === "object" && value !== null;
|
|
14017
|
+
const mapObjectSkip2 = /* @__PURE__ */ Symbol("skip");
|
|
14018
|
+
const isObjectCustom2 = (value) => isObject2(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
|
|
14019
|
+
const mapObject2 = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
|
|
14020
|
+
options = {
|
|
14021
|
+
deep: false,
|
|
14022
|
+
target: {},
|
|
14023
|
+
...options
|
|
14024
|
+
};
|
|
14025
|
+
if (isSeen.has(object)) return isSeen.get(object);
|
|
14026
|
+
isSeen.set(object, options.target);
|
|
14027
|
+
const { target } = options;
|
|
14028
|
+
delete options.target;
|
|
14029
|
+
const mapArray = (array) => array.map((element) => isObjectCustom2(element) ? mapObject2(element, mapper, options, isSeen) : element);
|
|
14030
|
+
if (Array.isArray(object)) return mapArray(object);
|
|
14031
|
+
for (const [key, value] of Object.entries(object)) {
|
|
14032
|
+
const mapResult = mapper(key, value, object);
|
|
14033
|
+
if (mapResult === mapObjectSkip2) continue;
|
|
14034
|
+
let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
|
|
14035
|
+
if (newKey === "__proto__") continue;
|
|
14036
|
+
if (options.deep && shouldRecurse && isObjectCustom2(newValue)) newValue = Array.isArray(newValue) ? mapArray(newValue) : mapObject2(newValue, mapper, options, isSeen);
|
|
14037
|
+
target[newKey] = newValue;
|
|
14038
|
+
}
|
|
14039
|
+
return target;
|
|
14040
|
+
};
|
|
14041
|
+
module.exports = (object, mapper, options) => {
|
|
14042
|
+
if (!isObject2(object)) throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
|
|
14043
|
+
return mapObject2(object, mapper, options);
|
|
14044
|
+
};
|
|
14045
|
+
module.exports.mapObjectSkip = mapObjectSkip2;
|
|
14046
|
+
}));
|
|
14047
|
+
var import_map_obj = /* @__PURE__ */ __toESM(require_map_obj(), 1);
|
|
14048
|
+
var QuickLRU = class extends Map {
|
|
14049
|
+
constructor(options = {}) {
|
|
14050
|
+
super();
|
|
14051
|
+
if (!(options.maxSize && options.maxSize > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
|
|
14052
|
+
if (typeof options.maxAge === "number" && options.maxAge === 0) throw new TypeError("`maxAge` must be a number greater than 0");
|
|
14053
|
+
this.maxSize = options.maxSize;
|
|
14054
|
+
this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
|
|
14055
|
+
this.onEviction = options.onEviction;
|
|
14056
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
14057
|
+
this.oldCache = /* @__PURE__ */ new Map();
|
|
14058
|
+
this._size = 0;
|
|
14059
|
+
}
|
|
14060
|
+
_emitEvictions(cache$2) {
|
|
14061
|
+
if (typeof this.onEviction !== "function") return;
|
|
14062
|
+
for (const [key, item] of cache$2) this.onEviction(key, item.value);
|
|
14063
|
+
}
|
|
14064
|
+
_deleteIfExpired(key, item) {
|
|
14065
|
+
if (typeof item.expiry === "number" && item.expiry <= Date.now()) {
|
|
14066
|
+
if (typeof this.onEviction === "function") this.onEviction(key, item.value);
|
|
14067
|
+
return this.delete(key);
|
|
14068
|
+
}
|
|
14069
|
+
return false;
|
|
14070
|
+
}
|
|
14071
|
+
_getOrDeleteIfExpired(key, item) {
|
|
14072
|
+
if (this._deleteIfExpired(key, item) === false) return item.value;
|
|
14073
|
+
}
|
|
14074
|
+
_getItemValue(key, item) {
|
|
14075
|
+
return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
|
|
14076
|
+
}
|
|
14077
|
+
_peek(key, cache$2) {
|
|
14078
|
+
const item = cache$2.get(key);
|
|
14079
|
+
return this._getItemValue(key, item);
|
|
14080
|
+
}
|
|
14081
|
+
_set(key, value) {
|
|
14082
|
+
this.cache.set(key, value);
|
|
14083
|
+
this._size++;
|
|
14084
|
+
if (this._size >= this.maxSize) {
|
|
14085
|
+
this._size = 0;
|
|
14086
|
+
this._emitEvictions(this.oldCache);
|
|
14087
|
+
this.oldCache = this.cache;
|
|
14088
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
14089
|
+
}
|
|
14090
|
+
}
|
|
14091
|
+
_moveToRecent(key, item) {
|
|
14092
|
+
this.oldCache.delete(key);
|
|
14093
|
+
this._set(key, item);
|
|
14094
|
+
}
|
|
14095
|
+
*_entriesAscending() {
|
|
14096
|
+
for (const item of this.oldCache) {
|
|
14097
|
+
const [key, value] = item;
|
|
14098
|
+
if (!this.cache.has(key)) {
|
|
14099
|
+
if (this._deleteIfExpired(key, value) === false) yield item;
|
|
14100
|
+
}
|
|
14101
|
+
}
|
|
14102
|
+
for (const item of this.cache) {
|
|
14103
|
+
const [key, value] = item;
|
|
14104
|
+
if (this._deleteIfExpired(key, value) === false) yield item;
|
|
14105
|
+
}
|
|
14106
|
+
}
|
|
14107
|
+
get(key) {
|
|
14108
|
+
if (this.cache.has(key)) {
|
|
14109
|
+
const item = this.cache.get(key);
|
|
14110
|
+
return this._getItemValue(key, item);
|
|
14111
|
+
}
|
|
14112
|
+
if (this.oldCache.has(key)) {
|
|
14113
|
+
const item = this.oldCache.get(key);
|
|
14114
|
+
if (this._deleteIfExpired(key, item) === false) {
|
|
14115
|
+
this._moveToRecent(key, item);
|
|
14116
|
+
return item.value;
|
|
14117
|
+
}
|
|
14118
|
+
}
|
|
14119
|
+
}
|
|
14120
|
+
set(key, value, { maxAge = this.maxAge } = {}) {
|
|
14121
|
+
const expiry = typeof maxAge === "number" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : void 0;
|
|
14122
|
+
if (this.cache.has(key)) this.cache.set(key, {
|
|
14123
|
+
value,
|
|
14124
|
+
expiry
|
|
14125
|
+
});
|
|
14126
|
+
else this._set(key, {
|
|
14127
|
+
value,
|
|
14128
|
+
expiry
|
|
14129
|
+
});
|
|
14130
|
+
return this;
|
|
14131
|
+
}
|
|
14132
|
+
has(key) {
|
|
14133
|
+
if (this.cache.has(key)) return !this._deleteIfExpired(key, this.cache.get(key));
|
|
14134
|
+
if (this.oldCache.has(key)) return !this._deleteIfExpired(key, this.oldCache.get(key));
|
|
14135
|
+
return false;
|
|
14136
|
+
}
|
|
14137
|
+
peek(key) {
|
|
14138
|
+
if (this.cache.has(key)) return this._peek(key, this.cache);
|
|
14139
|
+
if (this.oldCache.has(key)) return this._peek(key, this.oldCache);
|
|
14140
|
+
}
|
|
14141
|
+
delete(key) {
|
|
14142
|
+
const deleted = this.cache.delete(key);
|
|
14143
|
+
if (deleted) this._size--;
|
|
14144
|
+
return this.oldCache.delete(key) || deleted;
|
|
14145
|
+
}
|
|
14146
|
+
clear() {
|
|
14147
|
+
this.cache.clear();
|
|
14148
|
+
this.oldCache.clear();
|
|
14149
|
+
this._size = 0;
|
|
14150
|
+
}
|
|
14151
|
+
resize(newSize) {
|
|
14152
|
+
if (!(newSize && newSize > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
|
|
14153
|
+
const items = [...this._entriesAscending()];
|
|
14154
|
+
const removeCount = items.length - newSize;
|
|
14155
|
+
if (removeCount < 0) {
|
|
14156
|
+
this.cache = new Map(items);
|
|
14157
|
+
this.oldCache = /* @__PURE__ */ new Map();
|
|
14158
|
+
this._size = items.length;
|
|
14159
|
+
} else {
|
|
14160
|
+
if (removeCount > 0) this._emitEvictions(items.slice(0, removeCount));
|
|
14161
|
+
this.oldCache = new Map(items.slice(removeCount));
|
|
14162
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
14163
|
+
this._size = 0;
|
|
14164
|
+
}
|
|
14165
|
+
this.maxSize = newSize;
|
|
14166
|
+
}
|
|
14167
|
+
*keys() {
|
|
14168
|
+
for (const [key] of this) yield key;
|
|
14169
|
+
}
|
|
14170
|
+
*values() {
|
|
14171
|
+
for (const [, value] of this) yield value;
|
|
14172
|
+
}
|
|
14173
|
+
*[Symbol.iterator]() {
|
|
14174
|
+
for (const item of this.cache) {
|
|
14175
|
+
const [key, value] = item;
|
|
14176
|
+
if (this._deleteIfExpired(key, value) === false) yield [key, value.value];
|
|
14177
|
+
}
|
|
14178
|
+
for (const item of this.oldCache) {
|
|
14179
|
+
const [key, value] = item;
|
|
14180
|
+
if (!this.cache.has(key)) {
|
|
14181
|
+
if (this._deleteIfExpired(key, value) === false) yield [key, value.value];
|
|
14182
|
+
}
|
|
14183
|
+
}
|
|
14184
|
+
}
|
|
14185
|
+
*entriesDescending() {
|
|
14186
|
+
let items = [...this.cache];
|
|
14187
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
14188
|
+
const [key, value] = items[i];
|
|
14189
|
+
if (this._deleteIfExpired(key, value) === false) yield [key, value.value];
|
|
14190
|
+
}
|
|
14191
|
+
items = [...this.oldCache];
|
|
14192
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
14193
|
+
const [key, value] = items[i];
|
|
14194
|
+
if (!this.cache.has(key)) {
|
|
14195
|
+
if (this._deleteIfExpired(key, value) === false) yield [key, value.value];
|
|
14196
|
+
}
|
|
14197
|
+
}
|
|
14198
|
+
}
|
|
14199
|
+
*entriesAscending() {
|
|
14200
|
+
for (const [key, value] of this._entriesAscending()) yield [key, value.value];
|
|
14201
|
+
}
|
|
14202
|
+
get size() {
|
|
14203
|
+
if (!this._size) return this.oldCache.size;
|
|
14204
|
+
let oldCacheSize = 0;
|
|
14205
|
+
for (const key of this.oldCache.keys()) if (!this.cache.has(key)) oldCacheSize++;
|
|
14206
|
+
return Math.min(this._size + oldCacheSize, this.maxSize);
|
|
14207
|
+
}
|
|
14208
|
+
entries() {
|
|
14209
|
+
return this.entriesAscending();
|
|
14210
|
+
}
|
|
14211
|
+
forEach(callbackFunction, thisArgument = this) {
|
|
14212
|
+
for (const [key, value] of this.entriesAscending()) callbackFunction.call(thisArgument, value, key, this);
|
|
14213
|
+
}
|
|
14214
|
+
get [Symbol.toStringTag]() {
|
|
14215
|
+
return JSON.stringify([...this.entriesAscending()]);
|
|
14216
|
+
}
|
|
14217
|
+
};
|
|
14218
|
+
var handlePreserveConsecutiveUppercase = (decamelized, separator) => {
|
|
14219
|
+
decamelized = decamelized.replace(/((?<![\p{Uppercase_Letter}\d])[\p{Uppercase_Letter}\d](?![\p{Uppercase_Letter}\d]))/gu, ($0) => $0.toLowerCase());
|
|
14220
|
+
return decamelized.replace(new RegExp("(?<!\\p{Uppercase_Letter})(\\p{Uppercase_Letter}+)(\\p{Uppercase_Letter}\\p{Lowercase_Letter}+)", "gu"), (_, $1, $2) => $1 + separator + $2.toLowerCase());
|
|
14221
|
+
};
|
|
14222
|
+
function decamelize(text, { separator = "_", preserveConsecutiveUppercase: preserveConsecutiveUppercase$1 = false } = {}) {
|
|
14223
|
+
if (!(typeof text === "string" && typeof separator === "string")) throw new TypeError("The `text` and `separator` arguments should be of type `string`");
|
|
14224
|
+
if (text.length < 2) return preserveConsecutiveUppercase$1 ? text : text.toLowerCase();
|
|
14225
|
+
const replacement = `$1${separator}$2`;
|
|
14226
|
+
const decamelized = text.replace(new RegExp("([\\p{Lowercase_Letter}\\d])(\\p{Uppercase_Letter})", "gu"), replacement);
|
|
14227
|
+
if (preserveConsecutiveUppercase$1) return handlePreserveConsecutiveUppercase(decamelized, separator);
|
|
14228
|
+
return decamelized.replace(new RegExp("(\\p{Uppercase_Letter})(\\p{Uppercase_Letter}\\p{Lowercase_Letter}+)", "gu"), replacement).toLowerCase();
|
|
14229
|
+
}
|
|
14230
|
+
var has$1 = (array, key) => array.some((element) => {
|
|
14231
|
+
if (typeof element === "string") return element === key;
|
|
14232
|
+
element.lastIndex = 0;
|
|
14233
|
+
return element.test(key);
|
|
14234
|
+
});
|
|
14235
|
+
var cache$1 = new QuickLRU({ maxSize: 1e5 });
|
|
14236
|
+
var isObject$2 = (value) => typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
|
|
14237
|
+
var transform$1 = (input, options = {}) => {
|
|
14238
|
+
if (!isObject$2(input)) return input;
|
|
14239
|
+
const { separator = "_", exclude, deep = false } = options;
|
|
14240
|
+
const makeMapper = (parentPath) => (key, value) => {
|
|
14241
|
+
if (deep && isObject$2(value)) {
|
|
14242
|
+
const path = parentPath === void 0 ? key : `${parentPath}.${key}`;
|
|
14243
|
+
value = (0, import_map_obj.default)(value, makeMapper(path));
|
|
14244
|
+
}
|
|
14245
|
+
if (!(exclude && has$1(exclude, key))) {
|
|
14246
|
+
const cacheKey = `${separator}${key}`;
|
|
14247
|
+
if (cache$1.has(cacheKey)) key = cache$1.get(cacheKey);
|
|
14248
|
+
else {
|
|
14249
|
+
const returnValue = decamelize(key, { separator });
|
|
14250
|
+
if (key.length < 100) cache$1.set(cacheKey, returnValue);
|
|
14251
|
+
key = returnValue;
|
|
14252
|
+
}
|
|
14253
|
+
}
|
|
14254
|
+
return [key, value];
|
|
14255
|
+
};
|
|
14256
|
+
return (0, import_map_obj.default)(input, makeMapper(void 0));
|
|
14257
|
+
};
|
|
14258
|
+
function decamelizeKeys$1(input, options) {
|
|
14259
|
+
if (Array.isArray(input)) return Object.keys(input).map((key) => transform$1(input[key], options));
|
|
14260
|
+
return transform$1(input, options);
|
|
14261
|
+
}
|
|
14262
|
+
function decamelizeKeys(val) {
|
|
14263
|
+
return decamelizeKeys$1(val, { deep: true });
|
|
14264
|
+
}
|
|
14265
|
+
function toUrlSafe(str) {
|
|
14266
|
+
let safeStr = str;
|
|
14267
|
+
while (safeStr.indexOf("/") >= 0) safeStr = safeStr.replace("/", "_");
|
|
14268
|
+
while (safeStr.indexOf("+") >= 0) safeStr = safeStr.replace("+", "-");
|
|
14269
|
+
while (safeStr.indexOf("=") >= 0) safeStr = safeStr.replace("=", "");
|
|
14270
|
+
return safeStr;
|
|
14271
|
+
}
|
|
14272
|
+
function normalizeRequest(path, options) {
|
|
14273
|
+
const pathWithParams = path.replace(/{([a-zA-Z0-9_]+)}/g, (_, key) => {
|
|
14274
|
+
const value = options?.query?.[key];
|
|
14275
|
+
if (!value) throw new Error(`Missing value for path parameter "${key}"`);
|
|
14276
|
+
delete options?.query?.[key];
|
|
14277
|
+
return toUrlSafe(value);
|
|
14278
|
+
});
|
|
14279
|
+
if (options?.query) {
|
|
14280
|
+
for (const key in options.query) {
|
|
14281
|
+
const value = options.query[key];
|
|
14282
|
+
if (typeof value === "string") options.query[key] = toUrlSafe(value);
|
|
14283
|
+
}
|
|
14284
|
+
options.query = decamelizeKeys(options.query);
|
|
14285
|
+
}
|
|
14286
|
+
if (options?.body && typeof options.body === "object") options.body = decamelizeKeys(options.body);
|
|
14287
|
+
return [pathWithParams, options];
|
|
14288
|
+
}
|
|
14289
|
+
var isObject$1 = (value) => typeof value === "object" && value !== null;
|
|
14290
|
+
var isObjectCustom = (value) => isObject$1(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
|
|
14291
|
+
var mapObjectSkip = /* @__PURE__ */ Symbol("mapObjectSkip");
|
|
14292
|
+
var _mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
|
|
14293
|
+
options = {
|
|
14294
|
+
deep: false,
|
|
14295
|
+
target: {},
|
|
14296
|
+
...options
|
|
14297
|
+
};
|
|
14298
|
+
if (isSeen.has(object)) return isSeen.get(object);
|
|
14299
|
+
isSeen.set(object, options.target);
|
|
14300
|
+
const { target } = options;
|
|
14301
|
+
delete options.target;
|
|
14302
|
+
const mapArray = (array) => array.map((element) => isObjectCustom(element) ? _mapObject(element, mapper, options, isSeen) : element);
|
|
14303
|
+
if (Array.isArray(object)) return mapArray(object);
|
|
14304
|
+
for (const [key, value] of Object.entries(object)) {
|
|
14305
|
+
const mapResult = mapper(key, value, object);
|
|
14306
|
+
if (mapResult === mapObjectSkip) continue;
|
|
14307
|
+
let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
|
|
14308
|
+
if (newKey === "__proto__") continue;
|
|
14309
|
+
if (options.deep && shouldRecurse && isObjectCustom(newValue)) newValue = Array.isArray(newValue) ? mapArray(newValue) : _mapObject(newValue, mapper, options, isSeen);
|
|
14310
|
+
target[newKey] = newValue;
|
|
14311
|
+
}
|
|
14312
|
+
return target;
|
|
14313
|
+
};
|
|
14314
|
+
function mapObject(object, mapper, options) {
|
|
14315
|
+
if (!isObject$1(object)) throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
|
|
14316
|
+
return _mapObject(object, mapper, options);
|
|
14317
|
+
}
|
|
14318
|
+
var UPPERCASE = /[\p{Lu}]/u;
|
|
14319
|
+
var LOWERCASE = /[\p{Ll}]/u;
|
|
14320
|
+
var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
|
|
14321
|
+
var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
|
14322
|
+
var SEPARATORS = /[_.\- ]+/;
|
|
14323
|
+
var LEADING_SEPARATORS = /* @__PURE__ */ new RegExp("^" + SEPARATORS.source);
|
|
14324
|
+
var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
|
|
14325
|
+
var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
|
|
14326
|
+
var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase$1) => {
|
|
14327
|
+
let isLastCharLower = false;
|
|
14328
|
+
let isLastCharUpper = false;
|
|
14329
|
+
let isLastLastCharUpper = false;
|
|
14330
|
+
let isLastLastCharPreserved = false;
|
|
14331
|
+
for (let index = 0; index < string.length; index++) {
|
|
14332
|
+
const character = string[index];
|
|
14333
|
+
isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
|
|
14334
|
+
if (isLastCharLower && UPPERCASE.test(character)) {
|
|
14335
|
+
string = string.slice(0, index) + "-" + string.slice(index);
|
|
14336
|
+
isLastCharLower = false;
|
|
14337
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
14338
|
+
isLastCharUpper = true;
|
|
14339
|
+
index++;
|
|
14340
|
+
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase$1)) {
|
|
14341
|
+
string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
|
|
14342
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
14343
|
+
isLastCharUpper = false;
|
|
14344
|
+
isLastCharLower = true;
|
|
14345
|
+
} else {
|
|
14346
|
+
isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
|
|
14347
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
14348
|
+
isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
|
|
14349
|
+
}
|
|
14350
|
+
}
|
|
14351
|
+
return string;
|
|
14352
|
+
};
|
|
14353
|
+
var preserveConsecutiveUppercase = (input, toLowerCase) => {
|
|
14354
|
+
LEADING_CAPITAL.lastIndex = 0;
|
|
14355
|
+
return input.replaceAll(LEADING_CAPITAL, (match) => toLowerCase(match));
|
|
14356
|
+
};
|
|
14357
|
+
var postProcess = (input, toUpperCase) => {
|
|
14358
|
+
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
14359
|
+
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
14360
|
+
return input.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)).replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));
|
|
14361
|
+
};
|
|
14362
|
+
function camelCase(input, options) {
|
|
14363
|
+
if (!(typeof input === "string" || Array.isArray(input))) throw new TypeError("Expected the input to be `string | string[]`");
|
|
14364
|
+
options = {
|
|
14365
|
+
pascalCase: false,
|
|
14366
|
+
preserveConsecutiveUppercase: false,
|
|
14367
|
+
...options
|
|
14368
|
+
};
|
|
14369
|
+
if (Array.isArray(input)) input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
14370
|
+
else input = input.trim();
|
|
14371
|
+
if (input.length === 0) return "";
|
|
14372
|
+
const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
|
|
14373
|
+
const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
|
|
14374
|
+
if (input.length === 1) {
|
|
14375
|
+
if (SEPARATORS.test(input)) return "";
|
|
14376
|
+
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
|
14377
|
+
}
|
|
14378
|
+
if (input !== toLowerCase(input)) input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
|
|
14379
|
+
input = input.replace(LEADING_SEPARATORS, "");
|
|
14380
|
+
input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
|
|
14381
|
+
if (options.pascalCase) input = toUpperCase(input.charAt(0)) + input.slice(1);
|
|
14382
|
+
return postProcess(input, toUpperCase);
|
|
14383
|
+
}
|
|
14384
|
+
var has = (array, key) => array.some((element) => {
|
|
14385
|
+
if (typeof element === "string") return element === key;
|
|
14386
|
+
element.lastIndex = 0;
|
|
14387
|
+
return element.test(key);
|
|
14388
|
+
});
|
|
14389
|
+
var cache = new QuickLRU({ maxSize: 1e5 });
|
|
14390
|
+
var isObject = (value) => typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
|
|
14391
|
+
var transform = (input, options = {}) => {
|
|
14392
|
+
if (!isObject(input)) return input;
|
|
14393
|
+
const { exclude, pascalCase = false, stopPaths, deep = false, preserveConsecutiveUppercase: preserveConsecutiveUppercase$1 = false } = options;
|
|
14394
|
+
const stopPathsSet = new Set(stopPaths);
|
|
14395
|
+
const makeMapper = (parentPath) => (key, value) => {
|
|
14396
|
+
if (deep && isObject(value)) {
|
|
14397
|
+
const path = parentPath === void 0 ? key : `${parentPath}.${key}`;
|
|
14398
|
+
if (!stopPathsSet.has(path)) value = mapObject(value, makeMapper(path));
|
|
14399
|
+
}
|
|
14400
|
+
if (!(exclude && has(exclude, key))) {
|
|
14401
|
+
const cacheKey = pascalCase ? `${key}_` : key;
|
|
14402
|
+
if (cache.has(cacheKey)) key = cache.get(cacheKey);
|
|
14403
|
+
else {
|
|
14404
|
+
const returnValue = camelCase(key, {
|
|
14405
|
+
pascalCase,
|
|
14406
|
+
locale: false,
|
|
14407
|
+
preserveConsecutiveUppercase: preserveConsecutiveUppercase$1
|
|
14408
|
+
});
|
|
14409
|
+
if (key.length < 100) cache.set(cacheKey, returnValue);
|
|
14410
|
+
key = returnValue;
|
|
14411
|
+
}
|
|
14412
|
+
}
|
|
14413
|
+
return [key, value];
|
|
14414
|
+
};
|
|
14415
|
+
return mapObject(input, makeMapper(void 0));
|
|
14416
|
+
};
|
|
14417
|
+
function camelcaseKeys$1(input, options) {
|
|
14418
|
+
if (Array.isArray(input)) return Object.keys(input).map((key) => transform(input[key], options));
|
|
14419
|
+
return transform(input, options);
|
|
14420
|
+
}
|
|
14421
|
+
function camelcaseKeys(val) {
|
|
14422
|
+
return camelcaseKeys$1(val, { deep: true });
|
|
14423
|
+
}
|
|
14424
|
+
function denullifyValues(obj) {
|
|
14425
|
+
const newObj = {};
|
|
14426
|
+
for (const k in obj) {
|
|
14427
|
+
const v = obj[k];
|
|
14428
|
+
newObj[k] = v === null ? void 0 : v && typeof v === "object" && v.__proto__.constructor === Object ? denullifyValues(v) : v;
|
|
14429
|
+
}
|
|
14430
|
+
return newObj;
|
|
14431
|
+
}
|
|
14432
|
+
function normalizeResponse(response) {
|
|
14433
|
+
return denullifyValues(camelcaseKeys(response));
|
|
14434
|
+
}
|
|
14435
|
+
var StonApiClient = class {
|
|
14436
|
+
constructor(options) {
|
|
14437
|
+
this.apiFetch = ofetch.create({ baseURL: options?.baseURL ?? options?.baseUrl ?? "https://api.ston.fi" });
|
|
14438
|
+
}
|
|
14439
|
+
async getAsset(assetAddress) {
|
|
14440
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/assets/{assetAddress}", {
|
|
14441
|
+
method: "GET",
|
|
14442
|
+
query: { assetAddress }
|
|
14443
|
+
}))).asset;
|
|
14444
|
+
}
|
|
14445
|
+
async getAssets() {
|
|
14446
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/assets", { method: "GET" }))).assetList;
|
|
14447
|
+
}
|
|
14448
|
+
async queryAssets(body) {
|
|
14449
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/assets/query", {
|
|
14450
|
+
method: "POST",
|
|
14451
|
+
body
|
|
14452
|
+
}))).assetList;
|
|
14453
|
+
}
|
|
14454
|
+
/**
|
|
14455
|
+
* @deprecated use `queryAssets` method with `searchTerms` parameter instead
|
|
14456
|
+
*/
|
|
14457
|
+
async searchAssets(query) {
|
|
14458
|
+
return this.queryAssets({
|
|
14459
|
+
...query,
|
|
14460
|
+
searchTerms: [query.searchString]
|
|
14461
|
+
});
|
|
14462
|
+
}
|
|
14463
|
+
async getFarm(farmAddress) {
|
|
14464
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/farms/{farmAddress}", {
|
|
14465
|
+
method: "GET",
|
|
14466
|
+
query: { farmAddress }
|
|
14467
|
+
}))).farm;
|
|
14468
|
+
}
|
|
14469
|
+
async getFarms(query) {
|
|
14470
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/farms", {
|
|
14471
|
+
method: "GET",
|
|
14472
|
+
query
|
|
14473
|
+
}))).farmList;
|
|
14474
|
+
}
|
|
14475
|
+
async getFarmsByPool(poolAddress) {
|
|
14476
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/farms_by_pool/{poolAddress}", {
|
|
14477
|
+
method: "GET",
|
|
14478
|
+
query: { poolAddress }
|
|
14479
|
+
}))).farmList;
|
|
14480
|
+
}
|
|
14481
|
+
async getSwapPairs(query) {
|
|
14482
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/markets", {
|
|
14483
|
+
method: "GET",
|
|
14484
|
+
query
|
|
14485
|
+
}))).pairs;
|
|
14486
|
+
}
|
|
14487
|
+
async getSwapStatus(query) {
|
|
14488
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/swap/status", {
|
|
14489
|
+
method: "GET",
|
|
14490
|
+
query
|
|
14491
|
+
})));
|
|
14492
|
+
}
|
|
14493
|
+
async getPool(data) {
|
|
14494
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/pools/{poolAddress}", {
|
|
14495
|
+
method: "GET",
|
|
14496
|
+
query: typeof data === "string" ? { poolAddress: data } : data
|
|
14497
|
+
}))).pool;
|
|
14498
|
+
}
|
|
14499
|
+
async getPools(query) {
|
|
14500
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/pools", {
|
|
14501
|
+
method: "GET",
|
|
14502
|
+
query
|
|
14503
|
+
}))).poolList;
|
|
14504
|
+
}
|
|
14505
|
+
async getPoolsByAssetPair(query) {
|
|
14506
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/pools/by_market/{asset0Address}/{asset1Address}", {
|
|
14507
|
+
method: "GET",
|
|
14508
|
+
query
|
|
14509
|
+
}))).poolList;
|
|
14510
|
+
}
|
|
14511
|
+
async queryPools({ searchTerms: searchTerm, unconditionalAssets: unconditionalAsset, ...query }) {
|
|
14512
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/pools/query", {
|
|
14513
|
+
method: "POST",
|
|
14514
|
+
query: {
|
|
14515
|
+
...query,
|
|
14516
|
+
searchTerm,
|
|
14517
|
+
unconditionalAsset
|
|
14518
|
+
}
|
|
14519
|
+
}))).poolList;
|
|
14520
|
+
}
|
|
14521
|
+
async queryTransactions(query) {
|
|
14522
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/transactions/query", {
|
|
14523
|
+
method: "GET",
|
|
14524
|
+
query: {
|
|
14525
|
+
...query,
|
|
14526
|
+
minTxTimestamp: query.minTxTimestamp ? normalizeDate(query.minTxTimestamp) : void 0
|
|
14527
|
+
}
|
|
14528
|
+
})));
|
|
14529
|
+
}
|
|
14530
|
+
async simulateSwap({ offerUnits: units, ...query }) {
|
|
14531
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/swap/simulate", {
|
|
14532
|
+
method: "POST",
|
|
14533
|
+
query: {
|
|
14534
|
+
...query,
|
|
14535
|
+
units
|
|
14536
|
+
}
|
|
14537
|
+
})));
|
|
14538
|
+
}
|
|
14539
|
+
async simulateReverseSwap({ askUnits: units, ...query }) {
|
|
14540
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/reverse_swap/simulate", {
|
|
14541
|
+
method: "POST",
|
|
14542
|
+
query: {
|
|
14543
|
+
...query,
|
|
14544
|
+
units
|
|
14545
|
+
}
|
|
14546
|
+
})));
|
|
14547
|
+
}
|
|
14548
|
+
async simulateLiquidityProvision(query) {
|
|
14549
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/liquidity_provision/simulate", {
|
|
14550
|
+
method: "POST",
|
|
14551
|
+
query
|
|
14552
|
+
})));
|
|
14553
|
+
}
|
|
14554
|
+
async getJettonWalletAddress(query) {
|
|
14555
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/jetton/{jettonAddress}/address", {
|
|
14556
|
+
method: "GET",
|
|
14557
|
+
query
|
|
14558
|
+
}))).address;
|
|
14559
|
+
}
|
|
14560
|
+
async getWalletAsset(query) {
|
|
14561
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/assets/{assetAddress}", {
|
|
14562
|
+
method: "GET",
|
|
14563
|
+
query
|
|
14564
|
+
}))).asset;
|
|
14565
|
+
}
|
|
14566
|
+
async getWalletAssets(walletAddress) {
|
|
14567
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/assets", {
|
|
14568
|
+
method: "GET",
|
|
14569
|
+
query: { walletAddress }
|
|
14570
|
+
}))).assetList;
|
|
14571
|
+
}
|
|
14572
|
+
async getWalletFarm(query) {
|
|
14573
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/farms/{farmAddress}", {
|
|
14574
|
+
method: "GET",
|
|
14575
|
+
query
|
|
14576
|
+
}))).farm;
|
|
14577
|
+
}
|
|
14578
|
+
async getWalletFarms(data) {
|
|
14579
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/farms", {
|
|
14580
|
+
method: "GET",
|
|
14581
|
+
query: typeof data === "string" ? { walletAddress: data } : data
|
|
14582
|
+
}))).farmList;
|
|
14583
|
+
}
|
|
14584
|
+
async getWalletPool(query) {
|
|
14585
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/pools/{poolAddress}", {
|
|
14586
|
+
method: "GET",
|
|
14587
|
+
query
|
|
14588
|
+
}))).pool;
|
|
14589
|
+
}
|
|
14590
|
+
async getWalletPools(data) {
|
|
14591
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/pools", {
|
|
14592
|
+
method: "GET",
|
|
14593
|
+
query: typeof data === "string" ? { walletAddress: data } : data
|
|
14594
|
+
}))).poolList;
|
|
14595
|
+
}
|
|
14596
|
+
async getWalletStakes(query) {
|
|
14597
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/stakes", {
|
|
14598
|
+
method: "GET",
|
|
14599
|
+
query
|
|
14600
|
+
})));
|
|
14601
|
+
}
|
|
14602
|
+
async getWalletVaultsFee(query) {
|
|
14603
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/fee_vaults", {
|
|
14604
|
+
method: "GET",
|
|
14605
|
+
query
|
|
14606
|
+
}))).vaultList;
|
|
14607
|
+
}
|
|
14608
|
+
async getWalletOperations({ since, until, ...query }) {
|
|
14609
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/wallets/{walletAddress}/operations", {
|
|
14610
|
+
method: "GET",
|
|
14611
|
+
query: {
|
|
14612
|
+
...query,
|
|
14613
|
+
since: normalizeDate(since),
|
|
14614
|
+
until: normalizeDate(until)
|
|
14615
|
+
}
|
|
14616
|
+
}))).operations;
|
|
14617
|
+
}
|
|
14618
|
+
async getOperations({ since, until }) {
|
|
14619
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/stats/operations", {
|
|
14620
|
+
method: "GET",
|
|
14621
|
+
query: {
|
|
14622
|
+
since: normalizeDate(since),
|
|
14623
|
+
until: normalizeDate(until)
|
|
14624
|
+
}
|
|
14625
|
+
}))).operations;
|
|
14626
|
+
}
|
|
14627
|
+
async getAssetsFeeStats({ since, until, referrerAddress }) {
|
|
14628
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/stats/fees", {
|
|
14629
|
+
method: "GET",
|
|
14630
|
+
query: {
|
|
14631
|
+
since: normalizeDate(since),
|
|
14632
|
+
until: normalizeDate(until),
|
|
14633
|
+
referrerAddress
|
|
14634
|
+
}
|
|
14635
|
+
})));
|
|
14636
|
+
}
|
|
14637
|
+
async getWithdrawalsFeeStats({ since, until, referrerAddress }) {
|
|
14638
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/stats/fee_withdrawals", {
|
|
14639
|
+
method: "GET",
|
|
14640
|
+
query: {
|
|
14641
|
+
since: normalizeDate(since),
|
|
14642
|
+
until: normalizeDate(until),
|
|
14643
|
+
referrerAddress
|
|
14644
|
+
}
|
|
14645
|
+
}))).withdrawals;
|
|
14646
|
+
}
|
|
14647
|
+
async getAccrualsFeeStats({ since, until, referrerAddress }) {
|
|
14648
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/stats/fee_accruals", {
|
|
14649
|
+
method: "GET",
|
|
14650
|
+
query: {
|
|
14651
|
+
since: normalizeDate(since),
|
|
14652
|
+
until: normalizeDate(until),
|
|
14653
|
+
referrerAddress
|
|
14654
|
+
}
|
|
14655
|
+
}))).operations;
|
|
14656
|
+
}
|
|
14657
|
+
async getStakingStats() {
|
|
14658
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/stats/staking", { method: "GET" })));
|
|
14659
|
+
}
|
|
14660
|
+
async getRouters(query) {
|
|
14661
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/routers", {
|
|
14662
|
+
method: "GET",
|
|
14663
|
+
query
|
|
14664
|
+
}))).routerList;
|
|
14665
|
+
}
|
|
14666
|
+
async getRouter(routerAddress) {
|
|
14667
|
+
return normalizeResponse(await this.apiFetch(...normalizeRequest("/v1/routers/{routerAddress}", {
|
|
14668
|
+
method: "GET",
|
|
14669
|
+
query: { routerAddress }
|
|
14670
|
+
}))).router;
|
|
14671
|
+
}
|
|
14672
|
+
};
|
|
14673
|
+
|
|
14674
|
+
// src/agent/tools/jetton/swap.ts
|
|
12024
14675
|
var NATIVE_TON_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
12025
14676
|
var jettonSwapTool = {
|
|
12026
14677
|
name: "jetton_swap",
|
|
@@ -12057,27 +14708,27 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12057
14708
|
}
|
|
12058
14709
|
const isTonInput = from_asset.toLowerCase() === "ton";
|
|
12059
14710
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS : from_asset;
|
|
12060
|
-
const
|
|
14711
|
+
const toAddress2 = to_asset;
|
|
12061
14712
|
if (!isTonInput && !fromAddress.match(/^[EUe][Qq][A-Za-z0-9_-]{46}$/)) {
|
|
12062
14713
|
return {
|
|
12063
14714
|
success: false,
|
|
12064
14715
|
error: `Invalid from_asset address: ${from_asset}`
|
|
12065
14716
|
};
|
|
12066
14717
|
}
|
|
12067
|
-
if (!
|
|
14718
|
+
if (!toAddress2.match(/^[EUe][Qq][A-Za-z0-9_-]{46}$/)) {
|
|
12068
14719
|
return {
|
|
12069
14720
|
success: false,
|
|
12070
|
-
error: `Invalid to_asset address: ${
|
|
14721
|
+
error: `Invalid to_asset address: ${toAddress2}`
|
|
12071
14722
|
};
|
|
12072
14723
|
}
|
|
12073
14724
|
const endpoint = await getHttpEndpoint9({ network: "mainnet" });
|
|
12074
14725
|
const tonClient = new TonClient9({ endpoint });
|
|
12075
14726
|
const stonApiClient = new StonApiClient();
|
|
12076
|
-
console.log(`Simulating swap: ${amount} ${fromAddress} \u2192 ${
|
|
14727
|
+
console.log(`Simulating swap: ${amount} ${fromAddress} \u2192 ${toAddress2}`);
|
|
12077
14728
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
12078
14729
|
offerAddress: fromAddress,
|
|
12079
|
-
askAddress:
|
|
12080
|
-
offerUnits:
|
|
14730
|
+
askAddress: toAddress2,
|
|
14731
|
+
offerUnits: toNano18(amount).toString(),
|
|
12081
14732
|
slippageTolerance: slippage.toString()
|
|
12082
14733
|
});
|
|
12083
14734
|
if (!simulationResult || !simulationResult.router) {
|
|
@@ -12087,7 +14738,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12087
14738
|
};
|
|
12088
14739
|
}
|
|
12089
14740
|
const { router: routerInfo } = simulationResult;
|
|
12090
|
-
const router = tonClient.open(new
|
|
14741
|
+
const router = tonClient.open(new DEX4.v1.Router(routerInfo.address));
|
|
12091
14742
|
const keyPair = await mnemonicToPrivateKey7(walletData.mnemonic);
|
|
12092
14743
|
const wallet = WalletContractV5R17.create({
|
|
12093
14744
|
workchain: 0,
|
|
@@ -12101,7 +14752,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12101
14752
|
txParams = await router.getSwapTonToJettonTxParams({
|
|
12102
14753
|
userWalletAddress: walletData.address,
|
|
12103
14754
|
proxyTon,
|
|
12104
|
-
askJettonAddress:
|
|
14755
|
+
askJettonAddress: toAddress2,
|
|
12105
14756
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
12106
14757
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
12107
14758
|
});
|
|
@@ -12109,7 +14760,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12109
14760
|
txParams = await router.getSwapJettonToJettonTxParams({
|
|
12110
14761
|
userWalletAddress: walletData.address,
|
|
12111
14762
|
offerJettonAddress: fromAddress,
|
|
12112
|
-
askJettonAddress:
|
|
14763
|
+
askJettonAddress: toAddress2,
|
|
12113
14764
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
12114
14765
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
12115
14766
|
});
|
|
@@ -12132,7 +14783,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12132
14783
|
success: true,
|
|
12133
14784
|
data: {
|
|
12134
14785
|
from: fromAddress,
|
|
12135
|
-
to:
|
|
14786
|
+
to: toAddress2,
|
|
12136
14787
|
amountIn: amount.toString(),
|
|
12137
14788
|
expectedOutput: expectedOutput.toFixed(6),
|
|
12138
14789
|
minOutput: (Number(simulationResult.minAskUnits) / 10 ** 9).toFixed(6),
|
|
@@ -12157,8 +14808,8 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12157
14808
|
// src/agent/tools/jetton/send.ts
|
|
12158
14809
|
import { Type as Type82 } from "@sinclair/typebox";
|
|
12159
14810
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey8 } from "@ton/crypto";
|
|
12160
|
-
import { WalletContractV5R1 as WalletContractV5R18, TonClient as TonClient10, toNano as
|
|
12161
|
-
import { Address as
|
|
14811
|
+
import { WalletContractV5R1 as WalletContractV5R18, TonClient as TonClient10, toNano as toNano19, internal as internal7 } from "@ton/ton";
|
|
14812
|
+
import { Address as Address11, SendMode as SendMode7, beginCell as beginCell15 } from "@ton/core";
|
|
12162
14813
|
import { getHttpEndpoint as getHttpEndpoint10 } from "@orbs-network/ton-access";
|
|
12163
14814
|
var JETTON_TRANSFER_OP = 260734629;
|
|
12164
14815
|
var jettonSendTool = {
|
|
@@ -12193,7 +14844,7 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12193
14844
|
};
|
|
12194
14845
|
}
|
|
12195
14846
|
try {
|
|
12196
|
-
|
|
14847
|
+
Address11.parse(to);
|
|
12197
14848
|
} catch {
|
|
12198
14849
|
return {
|
|
12199
14850
|
success: false,
|
|
@@ -12214,7 +14865,7 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12214
14865
|
}
|
|
12215
14866
|
const jettonsData = await jettonsResponse.json();
|
|
12216
14867
|
const jettonBalance = jettonsData.balances?.find(
|
|
12217
|
-
(b) => b.jetton.address.toLowerCase() === jetton_address.toLowerCase() ||
|
|
14868
|
+
(b) => b.jetton.address.toLowerCase() === jetton_address.toLowerCase() || Address11.parse(b.jetton.address).toString() === Address11.parse(jetton_address).toString()
|
|
12218
14869
|
);
|
|
12219
14870
|
if (!jettonBalance) {
|
|
12220
14871
|
return {
|
|
@@ -12234,11 +14885,11 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12234
14885
|
error: `Insufficient ${symbol} balance. You have ${balanceHuman.toFixed(4)} but trying to send ${amount}`
|
|
12235
14886
|
};
|
|
12236
14887
|
}
|
|
12237
|
-
let forwardPayload =
|
|
14888
|
+
let forwardPayload = beginCell15().endCell();
|
|
12238
14889
|
if (comment) {
|
|
12239
|
-
forwardPayload =
|
|
14890
|
+
forwardPayload = beginCell15().storeUint(0, 32).storeStringTail(comment).endCell();
|
|
12240
14891
|
}
|
|
12241
|
-
const messageBody =
|
|
14892
|
+
const messageBody = beginCell15().storeUint(JETTON_TRANSFER_OP, 32).storeUint(0, 64).storeCoins(amountInUnits).storeAddress(Address11.parse(to)).storeAddress(Address11.parse(walletData.address)).storeBit(false).storeCoins(comment ? toNano19("0.01") : BigInt(1)).storeBit(comment ? true : false).storeMaybeRef(comment ? forwardPayload : null).endCell();
|
|
12242
14893
|
const keyPair = await mnemonicToPrivateKey8(walletData.mnemonic);
|
|
12243
14894
|
const wallet = WalletContractV5R18.create({
|
|
12244
14895
|
workchain: 0,
|
|
@@ -12254,8 +14905,8 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12254
14905
|
sendMode: SendMode7.PAY_GAS_SEPARATELY + SendMode7.IGNORE_ERRORS,
|
|
12255
14906
|
messages: [
|
|
12256
14907
|
internal7({
|
|
12257
|
-
to:
|
|
12258
|
-
value:
|
|
14908
|
+
to: Address11.parse(senderJettonWallet),
|
|
14909
|
+
value: toNano19("0.05"),
|
|
12259
14910
|
// Gas for jetton transfer
|
|
12260
14911
|
body: messageBody,
|
|
12261
14912
|
bounce: true
|
|
@@ -12607,8 +15258,7 @@ var jettonSearchExecutor = async (params, context) => {
|
|
|
12607
15258
|
|
|
12608
15259
|
// src/agent/tools/jetton/quote.ts
|
|
12609
15260
|
import { Type as Type86 } from "@sinclair/typebox";
|
|
12610
|
-
import { toNano as
|
|
12611
|
-
import { StonApiClient as StonApiClient2 } from "@ston-fi/api";
|
|
15261
|
+
import { toNano as toNano20 } from "@ton/ton";
|
|
12612
15262
|
var NATIVE_TON_ADDRESS2 = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
12613
15263
|
var jettonQuoteTool = {
|
|
12614
15264
|
name: "jetton_quote",
|
|
@@ -12638,12 +15288,12 @@ var jettonQuoteExecutor = async (params, context) => {
|
|
|
12638
15288
|
const { from_asset, to_asset, amount, slippage = 0.01 } = params;
|
|
12639
15289
|
const isTonInput = from_asset.toLowerCase() === "ton";
|
|
12640
15290
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS2 : from_asset;
|
|
12641
|
-
const
|
|
12642
|
-
const stonApiClient = new
|
|
15291
|
+
const toAddress2 = to_asset;
|
|
15292
|
+
const stonApiClient = new StonApiClient();
|
|
12643
15293
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
12644
15294
|
offerAddress: fromAddress,
|
|
12645
|
-
askAddress:
|
|
12646
|
-
offerUnits:
|
|
15295
|
+
askAddress: toAddress2,
|
|
15296
|
+
offerUnits: toNano20(amount).toString(),
|
|
12647
15297
|
slippageTolerance: slippage.toString()
|
|
12648
15298
|
});
|
|
12649
15299
|
if (!simulationResult) {
|
|
@@ -12667,7 +15317,7 @@ var jettonQuoteExecutor = async (params, context) => {
|
|
|
12667
15317
|
const quote = {
|
|
12668
15318
|
from: fromAddress,
|
|
12669
15319
|
fromSymbol,
|
|
12670
|
-
to:
|
|
15320
|
+
to: toAddress2,
|
|
12671
15321
|
toSymbol,
|
|
12672
15322
|
amountIn: amount.toString(),
|
|
12673
15323
|
expectedOutput: expectedOutput.toFixed(6),
|
|
@@ -13124,8 +15774,8 @@ var jettonPoolsExecutor = async (params, context) => {
|
|
|
13124
15774
|
|
|
13125
15775
|
// src/agent/tools/dedust/quote.ts
|
|
13126
15776
|
import { Type as Type91 } from "@sinclair/typebox";
|
|
13127
|
-
import { TonClient as TonClient11, toNano as
|
|
13128
|
-
import { Address as
|
|
15777
|
+
import { TonClient as TonClient11, toNano as toNano21, fromNano as fromNano4 } from "@ton/ton";
|
|
15778
|
+
import { Address as Address12 } from "@ton/core";
|
|
13129
15779
|
import { getHttpEndpoint as getHttpEndpoint11 } from "@orbs-network/ton-access";
|
|
13130
15780
|
import { Factory, Asset, PoolType, ReadinessStatus } from "@dedust/sdk";
|
|
13131
15781
|
|
|
@@ -13182,7 +15832,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13182
15832
|
let toAssetAddr = to_asset;
|
|
13183
15833
|
if (!isTonInput) {
|
|
13184
15834
|
try {
|
|
13185
|
-
fromAssetAddr =
|
|
15835
|
+
fromAssetAddr = Address12.parse(from_asset).toString();
|
|
13186
15836
|
} catch (error) {
|
|
13187
15837
|
return {
|
|
13188
15838
|
success: false,
|
|
@@ -13192,7 +15842,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13192
15842
|
}
|
|
13193
15843
|
if (!isTonOutput) {
|
|
13194
15844
|
try {
|
|
13195
|
-
toAssetAddr =
|
|
15845
|
+
toAssetAddr = Address12.parse(to_asset).toString();
|
|
13196
15846
|
} catch (error) {
|
|
13197
15847
|
return {
|
|
13198
15848
|
success: false,
|
|
@@ -13203,10 +15853,10 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13203
15853
|
const endpoint = await getHttpEndpoint11({ network: "mainnet" });
|
|
13204
15854
|
const tonClient = new TonClient11({ endpoint });
|
|
13205
15855
|
const factory = tonClient.open(
|
|
13206
|
-
Factory.createFromAddress(
|
|
15856
|
+
Factory.createFromAddress(Address12.parse(DEDUST_FACTORY_MAINNET))
|
|
13207
15857
|
);
|
|
13208
|
-
const fromAsset = isTonInput ? Asset.native() : Asset.jetton(
|
|
13209
|
-
const toAsset = isTonOutput ? Asset.native() : Asset.jetton(
|
|
15858
|
+
const fromAsset = isTonInput ? Asset.native() : Asset.jetton(Address12.parse(fromAssetAddr));
|
|
15859
|
+
const toAsset = isTonOutput ? Asset.native() : Asset.jetton(Address12.parse(toAssetAddr));
|
|
13210
15860
|
const poolTypeEnum = pool_type === "stable" ? PoolType.STABLE : PoolType.VOLATILE;
|
|
13211
15861
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAsset, toAsset]));
|
|
13212
15862
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -13217,7 +15867,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13217
15867
|
};
|
|
13218
15868
|
}
|
|
13219
15869
|
const reserves = await pool.getReserves();
|
|
13220
|
-
const amountIn =
|
|
15870
|
+
const amountIn = toNano21(amount);
|
|
13221
15871
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
13222
15872
|
assetIn: fromAsset,
|
|
13223
15873
|
amountIn
|
|
@@ -13282,8 +15932,8 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13282
15932
|
// src/agent/tools/dedust/swap.ts
|
|
13283
15933
|
import { Type as Type92 } from "@sinclair/typebox";
|
|
13284
15934
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey9 } from "@ton/crypto";
|
|
13285
|
-
import { WalletContractV5R1 as WalletContractV5R19, TonClient as TonClient12, toNano as
|
|
13286
|
-
import { Address as
|
|
15935
|
+
import { WalletContractV5R1 as WalletContractV5R19, TonClient as TonClient12, toNano as toNano22, fromNano as fromNano5 } from "@ton/ton";
|
|
15936
|
+
import { Address as Address13 } from "@ton/core";
|
|
13287
15937
|
import { getHttpEndpoint as getHttpEndpoint12 } from "@orbs-network/ton-access";
|
|
13288
15938
|
import { Factory as Factory2, Asset as Asset2, PoolType as PoolType2, ReadinessStatus as ReadinessStatus2, JettonRoot, VaultJetton } from "@dedust/sdk";
|
|
13289
15939
|
var dedustSwapTool = {
|
|
@@ -13330,7 +15980,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13330
15980
|
let toAssetAddr = to_asset;
|
|
13331
15981
|
if (!isTonInput) {
|
|
13332
15982
|
try {
|
|
13333
|
-
fromAssetAddr =
|
|
15983
|
+
fromAssetAddr = Address13.parse(from_asset).toString();
|
|
13334
15984
|
} catch (error) {
|
|
13335
15985
|
return {
|
|
13336
15986
|
success: false,
|
|
@@ -13340,7 +15990,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13340
15990
|
}
|
|
13341
15991
|
if (!isTonOutput) {
|
|
13342
15992
|
try {
|
|
13343
|
-
toAssetAddr =
|
|
15993
|
+
toAssetAddr = Address13.parse(to_asset).toString();
|
|
13344
15994
|
} catch (error) {
|
|
13345
15995
|
return {
|
|
13346
15996
|
success: false,
|
|
@@ -13351,10 +16001,10 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13351
16001
|
const endpoint = await getHttpEndpoint12({ network: "mainnet" });
|
|
13352
16002
|
const tonClient = new TonClient12({ endpoint });
|
|
13353
16003
|
const factory = tonClient.open(
|
|
13354
|
-
Factory2.createFromAddress(
|
|
16004
|
+
Factory2.createFromAddress(Address13.parse(DEDUST_FACTORY_MAINNET))
|
|
13355
16005
|
);
|
|
13356
|
-
const fromAssetObj = isTonInput ? Asset2.native() : Asset2.jetton(
|
|
13357
|
-
const toAssetObj = isTonOutput ? Asset2.native() : Asset2.jetton(
|
|
16006
|
+
const fromAssetObj = isTonInput ? Asset2.native() : Asset2.jetton(Address13.parse(fromAssetAddr));
|
|
16007
|
+
const toAssetObj = isTonOutput ? Asset2.native() : Asset2.jetton(Address13.parse(toAssetAddr));
|
|
13358
16008
|
const poolTypeEnum = pool_type === "stable" ? PoolType2.STABLE : PoolType2.VOLATILE;
|
|
13359
16009
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAssetObj, toAssetObj]));
|
|
13360
16010
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -13364,7 +16014,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13364
16014
|
error: `Pool not ready. Status: ${readinessStatus}. Try the other pool type (${pool_type === "volatile" ? "stable" : "volatile"}) or check if the pool exists.`
|
|
13365
16015
|
};
|
|
13366
16016
|
}
|
|
13367
|
-
const amountIn =
|
|
16017
|
+
const amountIn = toNano22(amount);
|
|
13368
16018
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
13369
16019
|
assetIn: fromAssetObj,
|
|
13370
16020
|
amountIn
|
|
@@ -13390,10 +16040,10 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13390
16040
|
poolAddress: pool.address,
|
|
13391
16041
|
amount: amountIn,
|
|
13392
16042
|
limit: minAmountOut,
|
|
13393
|
-
gasAmount:
|
|
16043
|
+
gasAmount: toNano22(DEDUST_GAS.SWAP_TON_TO_JETTON)
|
|
13394
16044
|
});
|
|
13395
16045
|
} else {
|
|
13396
|
-
const jettonAddress =
|
|
16046
|
+
const jettonAddress = Address13.parse(fromAssetAddr);
|
|
13397
16047
|
const jettonVault = tonClient.open(await factory.getJettonVault(jettonAddress));
|
|
13398
16048
|
const vaultStatus = await jettonVault.getReadinessStatus();
|
|
13399
16049
|
if (vaultStatus !== ReadinessStatus2.READY) {
|
|
@@ -13404,17 +16054,17 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
13404
16054
|
}
|
|
13405
16055
|
const jettonRoot = tonClient.open(JettonRoot.createFromAddress(jettonAddress));
|
|
13406
16056
|
const jettonWallet = tonClient.open(
|
|
13407
|
-
await jettonRoot.getWallet(
|
|
16057
|
+
await jettonRoot.getWallet(Address13.parse(walletData.address))
|
|
13408
16058
|
);
|
|
13409
16059
|
const swapPayload = VaultJetton.createSwapPayload({
|
|
13410
16060
|
poolAddress: pool.address,
|
|
13411
16061
|
limit: minAmountOut
|
|
13412
16062
|
});
|
|
13413
|
-
await jettonWallet.sendTransfer(sender,
|
|
16063
|
+
await jettonWallet.sendTransfer(sender, toNano22(DEDUST_GAS.SWAP_JETTON_TO_ANY), {
|
|
13414
16064
|
destination: jettonVault.address,
|
|
13415
16065
|
amount: amountIn,
|
|
13416
|
-
responseAddress:
|
|
13417
|
-
forwardAmount:
|
|
16066
|
+
responseAddress: Address13.parse(walletData.address),
|
|
16067
|
+
forwardAmount: toNano22(DEDUST_GAS.FORWARD_GAS),
|
|
13418
16068
|
forwardPayload: swapPayload
|
|
13419
16069
|
});
|
|
13420
16070
|
}
|
|
@@ -13578,10 +16228,9 @@ var dedustPoolsExecutor = async (params, context) => {
|
|
|
13578
16228
|
|
|
13579
16229
|
// src/agent/tools/dex/smart-quote.ts
|
|
13580
16230
|
import { Type as Type94 } from "@sinclair/typebox";
|
|
13581
|
-
import { TonClient as TonClient13, toNano as
|
|
13582
|
-
import { Address as
|
|
16231
|
+
import { TonClient as TonClient13, toNano as toNano23, fromNano as fromNano6 } from "@ton/ton";
|
|
16232
|
+
import { Address as Address14 } from "@ton/core";
|
|
13583
16233
|
import { getHttpEndpoint as getHttpEndpoint13 } from "@orbs-network/ton-access";
|
|
13584
|
-
import { StonApiClient as StonApiClient3 } from "@ston-fi/api";
|
|
13585
16234
|
import { Factory as Factory3, Asset as Asset3, PoolType as PoolType3, ReadinessStatus as ReadinessStatus3 } from "@dedust/sdk";
|
|
13586
16235
|
var dexQuoteTool = {
|
|
13587
16236
|
name: "dex_quote",
|
|
@@ -13611,12 +16260,12 @@ async function getStonfiQuote(fromAsset, toAsset, amount, slippage) {
|
|
|
13611
16260
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
13612
16261
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
13613
16262
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS3 : fromAsset;
|
|
13614
|
-
const
|
|
13615
|
-
const stonApiClient = new
|
|
16263
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
16264
|
+
const stonApiClient = new StonApiClient();
|
|
13616
16265
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
13617
16266
|
offerAddress: fromAddress,
|
|
13618
|
-
askAddress:
|
|
13619
|
-
offerUnits:
|
|
16267
|
+
askAddress: toAddress2,
|
|
16268
|
+
offerUnits: toNano23(amount).toString(),
|
|
13620
16269
|
slippageTolerance: slippage.toString()
|
|
13621
16270
|
});
|
|
13622
16271
|
if (!simulationResult) {
|
|
@@ -13661,10 +16310,10 @@ async function getDedustQuote(fromAsset, toAsset, amount, slippage, tonClient) {
|
|
|
13661
16310
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
13662
16311
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
13663
16312
|
const factory = tonClient.open(
|
|
13664
|
-
Factory3.createFromAddress(
|
|
16313
|
+
Factory3.createFromAddress(Address14.parse(DEDUST_FACTORY_MAINNET))
|
|
13665
16314
|
);
|
|
13666
|
-
const fromAssetObj = isTonInput ? Asset3.native() : Asset3.jetton(
|
|
13667
|
-
const toAssetObj = isTonOutput ? Asset3.native() : Asset3.jetton(
|
|
16315
|
+
const fromAssetObj = isTonInput ? Asset3.native() : Asset3.jetton(Address14.parse(fromAsset));
|
|
16316
|
+
const toAssetObj = isTonOutput ? Asset3.native() : Asset3.jetton(Address14.parse(toAsset));
|
|
13668
16317
|
let pool;
|
|
13669
16318
|
let poolType = "volatile";
|
|
13670
16319
|
try {
|
|
@@ -13695,7 +16344,7 @@ async function getDedustQuote(fromAsset, toAsset, amount, slippage, tonClient) {
|
|
|
13695
16344
|
error: "Pool lookup failed"
|
|
13696
16345
|
};
|
|
13697
16346
|
}
|
|
13698
|
-
const amountIn =
|
|
16347
|
+
const amountIn = toNano23(amount);
|
|
13699
16348
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
13700
16349
|
assetIn: fromAssetObj,
|
|
13701
16350
|
amountIn
|
|
@@ -13838,11 +16487,9 @@ Use dex_swap to execute on the best DEX, or jetton_swap/dedust_swap for specific
|
|
|
13838
16487
|
// src/agent/tools/dex/smart-swap.ts
|
|
13839
16488
|
import { Type as Type95 } from "@sinclair/typebox";
|
|
13840
16489
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey10 } from "@ton/crypto";
|
|
13841
|
-
import { WalletContractV5R1 as WalletContractV5R110, TonClient as TonClient14, toNano as
|
|
13842
|
-
import { Address as
|
|
16490
|
+
import { WalletContractV5R1 as WalletContractV5R110, TonClient as TonClient14, toNano as toNano24, fromNano as fromNano7 } from "@ton/ton";
|
|
16491
|
+
import { Address as Address15, SendMode as SendMode8, internal as internal8 } from "@ton/core";
|
|
13843
16492
|
import { getHttpEndpoint as getHttpEndpoint14 } from "@orbs-network/ton-access";
|
|
13844
|
-
import { StonApiClient as StonApiClient4 } from "@ston-fi/api";
|
|
13845
|
-
import { DEX as DEX2, pTON as pTON2 } from "@ston-fi/sdk";
|
|
13846
16493
|
import { Factory as Factory4, Asset as Asset4, PoolType as PoolType4, ReadinessStatus as ReadinessStatus4, JettonRoot as JettonRoot2, VaultJetton as VaultJetton2 } from "@dedust/sdk";
|
|
13847
16494
|
var dexSwapTool = {
|
|
13848
16495
|
name: "dex_swap",
|
|
@@ -13877,12 +16524,12 @@ async function getStonfiQuote2(fromAsset, toAsset, amount, slippage) {
|
|
|
13877
16524
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
13878
16525
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
13879
16526
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS3 : fromAsset;
|
|
13880
|
-
const
|
|
13881
|
-
const stonApiClient = new
|
|
16527
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
16528
|
+
const stonApiClient = new StonApiClient();
|
|
13882
16529
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
13883
16530
|
offerAddress: fromAddress,
|
|
13884
|
-
askAddress:
|
|
13885
|
-
offerUnits:
|
|
16531
|
+
askAddress: toAddress2,
|
|
16532
|
+
offerUnits: toNano24(amount).toString(),
|
|
13886
16533
|
slippageTolerance: slippage.toString()
|
|
13887
16534
|
});
|
|
13888
16535
|
if (!simulationResult) {
|
|
@@ -13909,10 +16556,10 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
13909
16556
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
13910
16557
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
13911
16558
|
const factory = tonClient.open(
|
|
13912
|
-
Factory4.createFromAddress(
|
|
16559
|
+
Factory4.createFromAddress(Address15.parse(DEDUST_FACTORY_MAINNET))
|
|
13913
16560
|
);
|
|
13914
|
-
const fromAssetObj = isTonInput ? Asset4.native() : Asset4.jetton(
|
|
13915
|
-
const toAssetObj = isTonOutput ? Asset4.native() : Asset4.jetton(
|
|
16561
|
+
const fromAssetObj = isTonInput ? Asset4.native() : Asset4.jetton(Address15.parse(fromAsset));
|
|
16562
|
+
const toAssetObj = isTonOutput ? Asset4.native() : Asset4.jetton(Address15.parse(toAsset));
|
|
13916
16563
|
let pool;
|
|
13917
16564
|
let poolType = "volatile";
|
|
13918
16565
|
try {
|
|
@@ -13929,7 +16576,7 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
13929
16576
|
} catch {
|
|
13930
16577
|
return { dex: "DeDust", expectedOutput: 0, available: false, error: "Pool lookup failed" };
|
|
13931
16578
|
}
|
|
13932
|
-
const amountIn =
|
|
16579
|
+
const amountIn = toNano24(amount);
|
|
13933
16580
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
13934
16581
|
assetIn: fromAssetObj,
|
|
13935
16582
|
amountIn
|
|
@@ -13958,7 +16605,7 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
13958
16605
|
async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulationResult, walletData, tonClient) {
|
|
13959
16606
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
13960
16607
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
13961
|
-
const
|
|
16608
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
13962
16609
|
const keyPair = await mnemonicToPrivateKey10(walletData.mnemonic);
|
|
13963
16610
|
const wallet = WalletContractV5R110.create({
|
|
13964
16611
|
workchain: 0,
|
|
@@ -13967,14 +16614,14 @@ async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulatio
|
|
|
13967
16614
|
const walletContract = tonClient.open(wallet);
|
|
13968
16615
|
const seqno = await walletContract.getSeqno();
|
|
13969
16616
|
const { router: routerInfo } = simulationResult;
|
|
13970
|
-
const router = tonClient.open(new
|
|
16617
|
+
const router = tonClient.open(new DEX4.v1.Router(routerInfo.address));
|
|
13971
16618
|
let txParams;
|
|
13972
16619
|
if (isTonInput) {
|
|
13973
|
-
const proxyTon = new
|
|
16620
|
+
const proxyTon = new pTON.v1(routerInfo.ptonMasterAddress);
|
|
13974
16621
|
txParams = await router.getSwapTonToJettonTxParams({
|
|
13975
16622
|
userWalletAddress: walletData.address,
|
|
13976
16623
|
proxyTon,
|
|
13977
|
-
askJettonAddress:
|
|
16624
|
+
askJettonAddress: toAddress2,
|
|
13978
16625
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
13979
16626
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
13980
16627
|
});
|
|
@@ -13982,7 +16629,7 @@ async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulatio
|
|
|
13982
16629
|
txParams = await router.getSwapJettonToJettonTxParams({
|
|
13983
16630
|
userWalletAddress: walletData.address,
|
|
13984
16631
|
offerJettonAddress: fromAsset,
|
|
13985
|
-
askJettonAddress:
|
|
16632
|
+
askJettonAddress: toAddress2,
|
|
13986
16633
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
13987
16634
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
13988
16635
|
});
|
|
@@ -14013,32 +16660,32 @@ async function executeDedustSwap(fromAsset, toAsset, amount, pool, minAmountOut,
|
|
|
14013
16660
|
});
|
|
14014
16661
|
const walletContract = tonClient.open(wallet);
|
|
14015
16662
|
const sender = walletContract.sender(keyPair.secretKey);
|
|
14016
|
-
const factory = tonClient.open(Factory4.createFromAddress(
|
|
14017
|
-
const amountIn =
|
|
16663
|
+
const factory = tonClient.open(Factory4.createFromAddress(Address15.parse(DEDUST_FACTORY_MAINNET)));
|
|
16664
|
+
const amountIn = toNano24(amount);
|
|
14018
16665
|
if (isTonInput) {
|
|
14019
16666
|
const tonVault = tonClient.open(await factory.getNativeVault());
|
|
14020
16667
|
await tonVault.sendSwap(sender, {
|
|
14021
16668
|
poolAddress: pool.address,
|
|
14022
16669
|
amount: amountIn,
|
|
14023
16670
|
limit: minAmountOut,
|
|
14024
|
-
gasAmount:
|
|
16671
|
+
gasAmount: toNano24(DEDUST_GAS.SWAP_TON_TO_JETTON)
|
|
14025
16672
|
});
|
|
14026
16673
|
} else {
|
|
14027
|
-
const jettonAddress =
|
|
16674
|
+
const jettonAddress = Address15.parse(fromAsset);
|
|
14028
16675
|
const jettonVault = tonClient.open(await factory.getJettonVault(jettonAddress));
|
|
14029
16676
|
const jettonRoot = tonClient.open(JettonRoot2.createFromAddress(jettonAddress));
|
|
14030
16677
|
const jettonWallet = tonClient.open(
|
|
14031
|
-
await jettonRoot.getWallet(
|
|
16678
|
+
await jettonRoot.getWallet(Address15.parse(walletData.address))
|
|
14032
16679
|
);
|
|
14033
16680
|
const swapPayload = VaultJetton2.createSwapPayload({
|
|
14034
16681
|
poolAddress: pool.address,
|
|
14035
16682
|
limit: minAmountOut
|
|
14036
16683
|
});
|
|
14037
|
-
await jettonWallet.sendTransfer(sender,
|
|
16684
|
+
await jettonWallet.sendTransfer(sender, toNano24(DEDUST_GAS.SWAP_JETTON_TO_ANY), {
|
|
14038
16685
|
destination: jettonVault.address,
|
|
14039
16686
|
amount: amountIn,
|
|
14040
|
-
responseAddress:
|
|
14041
|
-
forwardAmount:
|
|
16687
|
+
responseAddress: Address15.parse(walletData.address),
|
|
16688
|
+
forwardAmount: toNano24(DEDUST_GAS.FORWARD_GAS),
|
|
14042
16689
|
forwardPayload: swapPayload
|
|
14043
16690
|
});
|
|
14044
16691
|
}
|
|
@@ -15443,14 +18090,14 @@ Example: "Send 2 TON to EQxxx with memo: john_doe"`,
|
|
|
15443
18090
|
};
|
|
15444
18091
|
var casinoBalanceExecutor = async (params, context) => {
|
|
15445
18092
|
try {
|
|
15446
|
-
const
|
|
15447
|
-
if (!
|
|
18093
|
+
const address4 = getWalletAddress();
|
|
18094
|
+
if (!address4) {
|
|
15448
18095
|
return {
|
|
15449
18096
|
success: false,
|
|
15450
18097
|
error: "Casino wallet not initialized. Contact admin."
|
|
15451
18098
|
};
|
|
15452
18099
|
}
|
|
15453
|
-
const balanceInfo = await getWalletBalance(
|
|
18100
|
+
const balanceInfo = await getWalletBalance(address4);
|
|
15454
18101
|
if (!balanceInfo) {
|
|
15455
18102
|
return {
|
|
15456
18103
|
success: false,
|
|
@@ -15481,7 +18128,7 @@ var casinoBalanceExecutor = async (params, context) => {
|
|
|
15481
18128
|
return {
|
|
15482
18129
|
success: true,
|
|
15483
18130
|
data: {
|
|
15484
|
-
address,
|
|
18131
|
+
address: address4,
|
|
15485
18132
|
balance: balance.toFixed(2),
|
|
15486
18133
|
balanceNano: balanceInfo.balanceNano,
|
|
15487
18134
|
status,
|
|
@@ -15512,7 +18159,7 @@ import { Api as Api53 } from "telegram";
|
|
|
15512
18159
|
|
|
15513
18160
|
// src/casino/payment-verifier.ts
|
|
15514
18161
|
import { TonClient as TonClient15, fromNano as fromNano8 } from "@ton/ton";
|
|
15515
|
-
import { Address as
|
|
18162
|
+
import { Address as Address16 } from "@ton/core";
|
|
15516
18163
|
import { getHttpEndpoint as getHttpEndpoint15 } from "@orbs-network/ton-access";
|
|
15517
18164
|
|
|
15518
18165
|
// src/casino/retry.ts
|
|
@@ -15589,7 +18236,7 @@ async function verifyPayment(db, params) {
|
|
|
15589
18236
|
const { botWalletAddress, betAmount, requestTime, gameType, userId } = params;
|
|
15590
18237
|
const endpoint = await getHttpEndpoint15({ network: "mainnet" });
|
|
15591
18238
|
const client = new TonClient15({ endpoint });
|
|
15592
|
-
const botAddress =
|
|
18239
|
+
const botAddress = Address16.parse(botWalletAddress);
|
|
15593
18240
|
const transactions = await withBlockchainRetry(
|
|
15594
18241
|
() => client.getTransactions(botAddress, { limit: 20 }),
|
|
15595
18242
|
"getTransactions"
|
|
@@ -15746,13 +18393,13 @@ function shouldAwardDailyJackpot(db) {
|
|
|
15746
18393
|
|
|
15747
18394
|
// src/casino/payout-sender.ts
|
|
15748
18395
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey11 } from "@ton/crypto";
|
|
15749
|
-
import { WalletContractV5R1 as WalletContractV5R111, TonClient as TonClient16, toNano as
|
|
15750
|
-
import { Address as
|
|
18396
|
+
import { WalletContractV5R1 as WalletContractV5R111, TonClient as TonClient16, toNano as toNano25, internal as internal9 } from "@ton/ton";
|
|
18397
|
+
import { Address as Address17, SendMode as SendMode9 } from "@ton/core";
|
|
15751
18398
|
import { getHttpEndpoint as getHttpEndpoint16 } from "@orbs-network/ton-access";
|
|
15752
18399
|
async function sendPayout(playerAddress, amount, message) {
|
|
15753
18400
|
try {
|
|
15754
18401
|
try {
|
|
15755
|
-
|
|
18402
|
+
Address17.parse(playerAddress);
|
|
15756
18403
|
} catch (e) {
|
|
15757
18404
|
return {
|
|
15758
18405
|
success: false,
|
|
@@ -15782,8 +18429,8 @@ async function sendPayout(playerAddress, amount, message) {
|
|
|
15782
18429
|
sendMode: SendMode9.PAY_GAS_SEPARATELY,
|
|
15783
18430
|
messages: [
|
|
15784
18431
|
internal9({
|
|
15785
|
-
to:
|
|
15786
|
-
value:
|
|
18432
|
+
to: Address17.parse(playerAddress),
|
|
18433
|
+
value: toNano25(amount),
|
|
15787
18434
|
body: message,
|
|
15788
18435
|
bounce: false
|
|
15789
18436
|
})
|
|
@@ -16178,8 +18825,8 @@ var casinoDiceExecutor = async (params, context) => {
|
|
|
16178
18825
|
// src/agent/tools/casino/payout.ts
|
|
16179
18826
|
import { Type as Type108 } from "@sinclair/typebox";
|
|
16180
18827
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey12 } from "@ton/crypto";
|
|
16181
|
-
import { WalletContractV5R1 as WalletContractV5R112, TonClient as TonClient17, toNano as
|
|
16182
|
-
import { Address as
|
|
18828
|
+
import { WalletContractV5R1 as WalletContractV5R112, TonClient as TonClient17, toNano as toNano26, internal as internal10 } from "@ton/ton";
|
|
18829
|
+
import { Address as Address18, SendMode as SendMode10 } from "@ton/core";
|
|
16183
18830
|
import { getHttpEndpoint as getHttpEndpoint17 } from "@orbs-network/ton-access";
|
|
16184
18831
|
var casinoPayoutTool = {
|
|
16185
18832
|
name: "casino_payout",
|
|
@@ -16276,7 +18923,7 @@ var casinoPayoutExecutor = async (params, context) => {
|
|
|
16276
18923
|
}
|
|
16277
18924
|
const payout = bet_amount * multiplier;
|
|
16278
18925
|
try {
|
|
16279
|
-
|
|
18926
|
+
Address18.parse(player_address);
|
|
16280
18927
|
} catch (e) {
|
|
16281
18928
|
return {
|
|
16282
18929
|
success: false,
|
|
@@ -16306,8 +18953,8 @@ var casinoPayoutExecutor = async (params, context) => {
|
|
|
16306
18953
|
sendMode: SendMode10.PAY_GAS_SEPARATELY + SendMode10.IGNORE_ERRORS,
|
|
16307
18954
|
messages: [
|
|
16308
18955
|
internal10({
|
|
16309
|
-
to:
|
|
16310
|
-
value:
|
|
18956
|
+
to: Address18.parse(player_address),
|
|
18957
|
+
value: toNano26(payout),
|
|
16311
18958
|
body: `${winType} You won ${payout} TON (${multiplier}x)`,
|
|
16312
18959
|
bounce: false
|
|
16313
18960
|
})
|
|
@@ -17108,17 +19755,17 @@ var GiftDetector = class {
|
|
|
17108
19755
|
|
|
17109
19756
|
// src/ton/transfer.ts
|
|
17110
19757
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey13 } from "@ton/crypto";
|
|
17111
|
-
import { WalletContractV5R1 as WalletContractV5R113, TonClient as TonClient18, toNano as
|
|
17112
|
-
import { Address as
|
|
19758
|
+
import { WalletContractV5R1 as WalletContractV5R113, TonClient as TonClient18, toNano as toNano27, internal as internal11 } from "@ton/ton";
|
|
19759
|
+
import { Address as Address19, SendMode as SendMode11 } from "@ton/core";
|
|
17113
19760
|
import { getHttpEndpoint as getHttpEndpoint18 } from "@orbs-network/ton-access";
|
|
17114
19761
|
async function sendTon(params) {
|
|
17115
19762
|
try {
|
|
17116
|
-
const { toAddress, amount, comment = "", bounce = false } = params;
|
|
19763
|
+
const { toAddress: toAddress2, amount, comment = "", bounce = false } = params;
|
|
17117
19764
|
let recipientAddress;
|
|
17118
19765
|
try {
|
|
17119
|
-
recipientAddress =
|
|
19766
|
+
recipientAddress = Address19.parse(toAddress2);
|
|
17120
19767
|
} catch (e) {
|
|
17121
|
-
console.error(`Invalid recipient address: ${
|
|
19768
|
+
console.error(`Invalid recipient address: ${toAddress2}`, e);
|
|
17122
19769
|
return null;
|
|
17123
19770
|
}
|
|
17124
19771
|
const walletData = loadWallet();
|
|
@@ -17142,14 +19789,14 @@ async function sendTon(params) {
|
|
|
17142
19789
|
messages: [
|
|
17143
19790
|
internal11({
|
|
17144
19791
|
to: recipientAddress,
|
|
17145
|
-
value:
|
|
19792
|
+
value: toNano27(amount),
|
|
17146
19793
|
body: comment,
|
|
17147
19794
|
bounce
|
|
17148
19795
|
})
|
|
17149
19796
|
]
|
|
17150
19797
|
});
|
|
17151
19798
|
const pseudoHash = `${seqno}_${Date.now()}_${amount.toFixed(2)}`;
|
|
17152
|
-
console.log(`\u{1F4B8} [TON] Sent ${amount} TON to ${
|
|
19799
|
+
console.log(`\u{1F4B8} [TON] Sent ${amount} TON to ${toAddress2.slice(0, 8)}... - seqno: ${seqno}`);
|
|
17153
19800
|
return pseudoHash;
|
|
17154
19801
|
} catch (error) {
|
|
17155
19802
|
console.error("Error sending TON:", error);
|