teleton 0.1.9 → 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-7AUS3OYB.js → chunk-4UDOZME7.js} +2088 -128
- package/dist/cli/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
|
@@ -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,10 +12016,1971 @@ 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
|
-
|
|
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
|
+
};
|
|
12023
13984
|
|
|
12024
13985
|
// node_modules/@ston-fi/api/dist/esm/index.js
|
|
12025
13986
|
import { ofetch } from "ofetch";
|
|
@@ -12747,27 +14708,27 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12747
14708
|
}
|
|
12748
14709
|
const isTonInput = from_asset.toLowerCase() === "ton";
|
|
12749
14710
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS : from_asset;
|
|
12750
|
-
const
|
|
14711
|
+
const toAddress2 = to_asset;
|
|
12751
14712
|
if (!isTonInput && !fromAddress.match(/^[EUe][Qq][A-Za-z0-9_-]{46}$/)) {
|
|
12752
14713
|
return {
|
|
12753
14714
|
success: false,
|
|
12754
14715
|
error: `Invalid from_asset address: ${from_asset}`
|
|
12755
14716
|
};
|
|
12756
14717
|
}
|
|
12757
|
-
if (!
|
|
14718
|
+
if (!toAddress2.match(/^[EUe][Qq][A-Za-z0-9_-]{46}$/)) {
|
|
12758
14719
|
return {
|
|
12759
14720
|
success: false,
|
|
12760
|
-
error: `Invalid to_asset address: ${
|
|
14721
|
+
error: `Invalid to_asset address: ${toAddress2}`
|
|
12761
14722
|
};
|
|
12762
14723
|
}
|
|
12763
14724
|
const endpoint = await getHttpEndpoint9({ network: "mainnet" });
|
|
12764
14725
|
const tonClient = new TonClient9({ endpoint });
|
|
12765
14726
|
const stonApiClient = new StonApiClient();
|
|
12766
|
-
console.log(`Simulating swap: ${amount} ${fromAddress} \u2192 ${
|
|
14727
|
+
console.log(`Simulating swap: ${amount} ${fromAddress} \u2192 ${toAddress2}`);
|
|
12767
14728
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
12768
14729
|
offerAddress: fromAddress,
|
|
12769
|
-
askAddress:
|
|
12770
|
-
offerUnits:
|
|
14730
|
+
askAddress: toAddress2,
|
|
14731
|
+
offerUnits: toNano18(amount).toString(),
|
|
12771
14732
|
slippageTolerance: slippage.toString()
|
|
12772
14733
|
});
|
|
12773
14734
|
if (!simulationResult || !simulationResult.router) {
|
|
@@ -12777,7 +14738,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12777
14738
|
};
|
|
12778
14739
|
}
|
|
12779
14740
|
const { router: routerInfo } = simulationResult;
|
|
12780
|
-
const router = tonClient.open(new
|
|
14741
|
+
const router = tonClient.open(new DEX4.v1.Router(routerInfo.address));
|
|
12781
14742
|
const keyPair = await mnemonicToPrivateKey7(walletData.mnemonic);
|
|
12782
14743
|
const wallet = WalletContractV5R17.create({
|
|
12783
14744
|
workchain: 0,
|
|
@@ -12791,7 +14752,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12791
14752
|
txParams = await router.getSwapTonToJettonTxParams({
|
|
12792
14753
|
userWalletAddress: walletData.address,
|
|
12793
14754
|
proxyTon,
|
|
12794
|
-
askJettonAddress:
|
|
14755
|
+
askJettonAddress: toAddress2,
|
|
12795
14756
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
12796
14757
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
12797
14758
|
});
|
|
@@ -12799,7 +14760,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12799
14760
|
txParams = await router.getSwapJettonToJettonTxParams({
|
|
12800
14761
|
userWalletAddress: walletData.address,
|
|
12801
14762
|
offerJettonAddress: fromAddress,
|
|
12802
|
-
askJettonAddress:
|
|
14763
|
+
askJettonAddress: toAddress2,
|
|
12803
14764
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
12804
14765
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
12805
14766
|
});
|
|
@@ -12822,7 +14783,7 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12822
14783
|
success: true,
|
|
12823
14784
|
data: {
|
|
12824
14785
|
from: fromAddress,
|
|
12825
|
-
to:
|
|
14786
|
+
to: toAddress2,
|
|
12826
14787
|
amountIn: amount.toString(),
|
|
12827
14788
|
expectedOutput: expectedOutput.toFixed(6),
|
|
12828
14789
|
minOutput: (Number(simulationResult.minAskUnits) / 10 ** 9).toFixed(6),
|
|
@@ -12847,8 +14808,8 @@ var jettonSwapExecutor = async (params, context) => {
|
|
|
12847
14808
|
// src/agent/tools/jetton/send.ts
|
|
12848
14809
|
import { Type as Type82 } from "@sinclair/typebox";
|
|
12849
14810
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey8 } from "@ton/crypto";
|
|
12850
|
-
import { WalletContractV5R1 as WalletContractV5R18, TonClient as TonClient10, toNano as
|
|
12851
|
-
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";
|
|
12852
14813
|
import { getHttpEndpoint as getHttpEndpoint10 } from "@orbs-network/ton-access";
|
|
12853
14814
|
var JETTON_TRANSFER_OP = 260734629;
|
|
12854
14815
|
var jettonSendTool = {
|
|
@@ -12883,7 +14844,7 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12883
14844
|
};
|
|
12884
14845
|
}
|
|
12885
14846
|
try {
|
|
12886
|
-
|
|
14847
|
+
Address11.parse(to);
|
|
12887
14848
|
} catch {
|
|
12888
14849
|
return {
|
|
12889
14850
|
success: false,
|
|
@@ -12904,7 +14865,7 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12904
14865
|
}
|
|
12905
14866
|
const jettonsData = await jettonsResponse.json();
|
|
12906
14867
|
const jettonBalance = jettonsData.balances?.find(
|
|
12907
|
-
(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()
|
|
12908
14869
|
);
|
|
12909
14870
|
if (!jettonBalance) {
|
|
12910
14871
|
return {
|
|
@@ -12924,11 +14885,11 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12924
14885
|
error: `Insufficient ${symbol} balance. You have ${balanceHuman.toFixed(4)} but trying to send ${amount}`
|
|
12925
14886
|
};
|
|
12926
14887
|
}
|
|
12927
|
-
let forwardPayload =
|
|
14888
|
+
let forwardPayload = beginCell15().endCell();
|
|
12928
14889
|
if (comment) {
|
|
12929
|
-
forwardPayload =
|
|
14890
|
+
forwardPayload = beginCell15().storeUint(0, 32).storeStringTail(comment).endCell();
|
|
12930
14891
|
}
|
|
12931
|
-
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();
|
|
12932
14893
|
const keyPair = await mnemonicToPrivateKey8(walletData.mnemonic);
|
|
12933
14894
|
const wallet = WalletContractV5R18.create({
|
|
12934
14895
|
workchain: 0,
|
|
@@ -12944,8 +14905,8 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
12944
14905
|
sendMode: SendMode7.PAY_GAS_SEPARATELY + SendMode7.IGNORE_ERRORS,
|
|
12945
14906
|
messages: [
|
|
12946
14907
|
internal7({
|
|
12947
|
-
to:
|
|
12948
|
-
value:
|
|
14908
|
+
to: Address11.parse(senderJettonWallet),
|
|
14909
|
+
value: toNano19("0.05"),
|
|
12949
14910
|
// Gas for jetton transfer
|
|
12950
14911
|
body: messageBody,
|
|
12951
14912
|
bounce: true
|
|
@@ -13297,7 +15258,7 @@ var jettonSearchExecutor = async (params, context) => {
|
|
|
13297
15258
|
|
|
13298
15259
|
// src/agent/tools/jetton/quote.ts
|
|
13299
15260
|
import { Type as Type86 } from "@sinclair/typebox";
|
|
13300
|
-
import { toNano as
|
|
15261
|
+
import { toNano as toNano20 } from "@ton/ton";
|
|
13301
15262
|
var NATIVE_TON_ADDRESS2 = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
13302
15263
|
var jettonQuoteTool = {
|
|
13303
15264
|
name: "jetton_quote",
|
|
@@ -13327,12 +15288,12 @@ var jettonQuoteExecutor = async (params, context) => {
|
|
|
13327
15288
|
const { from_asset, to_asset, amount, slippage = 0.01 } = params;
|
|
13328
15289
|
const isTonInput = from_asset.toLowerCase() === "ton";
|
|
13329
15290
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS2 : from_asset;
|
|
13330
|
-
const
|
|
15291
|
+
const toAddress2 = to_asset;
|
|
13331
15292
|
const stonApiClient = new StonApiClient();
|
|
13332
15293
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
13333
15294
|
offerAddress: fromAddress,
|
|
13334
|
-
askAddress:
|
|
13335
|
-
offerUnits:
|
|
15295
|
+
askAddress: toAddress2,
|
|
15296
|
+
offerUnits: toNano20(amount).toString(),
|
|
13336
15297
|
slippageTolerance: slippage.toString()
|
|
13337
15298
|
});
|
|
13338
15299
|
if (!simulationResult) {
|
|
@@ -13356,7 +15317,7 @@ var jettonQuoteExecutor = async (params, context) => {
|
|
|
13356
15317
|
const quote = {
|
|
13357
15318
|
from: fromAddress,
|
|
13358
15319
|
fromSymbol,
|
|
13359
|
-
to:
|
|
15320
|
+
to: toAddress2,
|
|
13360
15321
|
toSymbol,
|
|
13361
15322
|
amountIn: amount.toString(),
|
|
13362
15323
|
expectedOutput: expectedOutput.toFixed(6),
|
|
@@ -13813,8 +15774,8 @@ var jettonPoolsExecutor = async (params, context) => {
|
|
|
13813
15774
|
|
|
13814
15775
|
// src/agent/tools/dedust/quote.ts
|
|
13815
15776
|
import { Type as Type91 } from "@sinclair/typebox";
|
|
13816
|
-
import { TonClient as TonClient11, toNano as
|
|
13817
|
-
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";
|
|
13818
15779
|
import { getHttpEndpoint as getHttpEndpoint11 } from "@orbs-network/ton-access";
|
|
13819
15780
|
import { Factory, Asset, PoolType, ReadinessStatus } from "@dedust/sdk";
|
|
13820
15781
|
|
|
@@ -13871,7 +15832,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13871
15832
|
let toAssetAddr = to_asset;
|
|
13872
15833
|
if (!isTonInput) {
|
|
13873
15834
|
try {
|
|
13874
|
-
fromAssetAddr =
|
|
15835
|
+
fromAssetAddr = Address12.parse(from_asset).toString();
|
|
13875
15836
|
} catch (error) {
|
|
13876
15837
|
return {
|
|
13877
15838
|
success: false,
|
|
@@ -13881,7 +15842,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13881
15842
|
}
|
|
13882
15843
|
if (!isTonOutput) {
|
|
13883
15844
|
try {
|
|
13884
|
-
toAssetAddr =
|
|
15845
|
+
toAssetAddr = Address12.parse(to_asset).toString();
|
|
13885
15846
|
} catch (error) {
|
|
13886
15847
|
return {
|
|
13887
15848
|
success: false,
|
|
@@ -13892,10 +15853,10 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13892
15853
|
const endpoint = await getHttpEndpoint11({ network: "mainnet" });
|
|
13893
15854
|
const tonClient = new TonClient11({ endpoint });
|
|
13894
15855
|
const factory = tonClient.open(
|
|
13895
|
-
Factory.createFromAddress(
|
|
15856
|
+
Factory.createFromAddress(Address12.parse(DEDUST_FACTORY_MAINNET))
|
|
13896
15857
|
);
|
|
13897
|
-
const fromAsset = isTonInput ? Asset.native() : Asset.jetton(
|
|
13898
|
-
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));
|
|
13899
15860
|
const poolTypeEnum = pool_type === "stable" ? PoolType.STABLE : PoolType.VOLATILE;
|
|
13900
15861
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAsset, toAsset]));
|
|
13901
15862
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -13906,7 +15867,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13906
15867
|
};
|
|
13907
15868
|
}
|
|
13908
15869
|
const reserves = await pool.getReserves();
|
|
13909
|
-
const amountIn =
|
|
15870
|
+
const amountIn = toNano21(amount);
|
|
13910
15871
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
13911
15872
|
assetIn: fromAsset,
|
|
13912
15873
|
amountIn
|
|
@@ -13971,8 +15932,8 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
13971
15932
|
// src/agent/tools/dedust/swap.ts
|
|
13972
15933
|
import { Type as Type92 } from "@sinclair/typebox";
|
|
13973
15934
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey9 } from "@ton/crypto";
|
|
13974
|
-
import { WalletContractV5R1 as WalletContractV5R19, TonClient as TonClient12, toNano as
|
|
13975
|
-
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";
|
|
13976
15937
|
import { getHttpEndpoint as getHttpEndpoint12 } from "@orbs-network/ton-access";
|
|
13977
15938
|
import { Factory as Factory2, Asset as Asset2, PoolType as PoolType2, ReadinessStatus as ReadinessStatus2, JettonRoot, VaultJetton } from "@dedust/sdk";
|
|
13978
15939
|
var dedustSwapTool = {
|
|
@@ -14019,7 +15980,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14019
15980
|
let toAssetAddr = to_asset;
|
|
14020
15981
|
if (!isTonInput) {
|
|
14021
15982
|
try {
|
|
14022
|
-
fromAssetAddr =
|
|
15983
|
+
fromAssetAddr = Address13.parse(from_asset).toString();
|
|
14023
15984
|
} catch (error) {
|
|
14024
15985
|
return {
|
|
14025
15986
|
success: false,
|
|
@@ -14029,7 +15990,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14029
15990
|
}
|
|
14030
15991
|
if (!isTonOutput) {
|
|
14031
15992
|
try {
|
|
14032
|
-
toAssetAddr =
|
|
15993
|
+
toAssetAddr = Address13.parse(to_asset).toString();
|
|
14033
15994
|
} catch (error) {
|
|
14034
15995
|
return {
|
|
14035
15996
|
success: false,
|
|
@@ -14040,10 +16001,10 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14040
16001
|
const endpoint = await getHttpEndpoint12({ network: "mainnet" });
|
|
14041
16002
|
const tonClient = new TonClient12({ endpoint });
|
|
14042
16003
|
const factory = tonClient.open(
|
|
14043
|
-
Factory2.createFromAddress(
|
|
16004
|
+
Factory2.createFromAddress(Address13.parse(DEDUST_FACTORY_MAINNET))
|
|
14044
16005
|
);
|
|
14045
|
-
const fromAssetObj = isTonInput ? Asset2.native() : Asset2.jetton(
|
|
14046
|
-
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));
|
|
14047
16008
|
const poolTypeEnum = pool_type === "stable" ? PoolType2.STABLE : PoolType2.VOLATILE;
|
|
14048
16009
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAssetObj, toAssetObj]));
|
|
14049
16010
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -14053,7 +16014,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14053
16014
|
error: `Pool not ready. Status: ${readinessStatus}. Try the other pool type (${pool_type === "volatile" ? "stable" : "volatile"}) or check if the pool exists.`
|
|
14054
16015
|
};
|
|
14055
16016
|
}
|
|
14056
|
-
const amountIn =
|
|
16017
|
+
const amountIn = toNano22(amount);
|
|
14057
16018
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
14058
16019
|
assetIn: fromAssetObj,
|
|
14059
16020
|
amountIn
|
|
@@ -14079,10 +16040,10 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14079
16040
|
poolAddress: pool.address,
|
|
14080
16041
|
amount: amountIn,
|
|
14081
16042
|
limit: minAmountOut,
|
|
14082
|
-
gasAmount:
|
|
16043
|
+
gasAmount: toNano22(DEDUST_GAS.SWAP_TON_TO_JETTON)
|
|
14083
16044
|
});
|
|
14084
16045
|
} else {
|
|
14085
|
-
const jettonAddress =
|
|
16046
|
+
const jettonAddress = Address13.parse(fromAssetAddr);
|
|
14086
16047
|
const jettonVault = tonClient.open(await factory.getJettonVault(jettonAddress));
|
|
14087
16048
|
const vaultStatus = await jettonVault.getReadinessStatus();
|
|
14088
16049
|
if (vaultStatus !== ReadinessStatus2.READY) {
|
|
@@ -14093,17 +16054,17 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
14093
16054
|
}
|
|
14094
16055
|
const jettonRoot = tonClient.open(JettonRoot.createFromAddress(jettonAddress));
|
|
14095
16056
|
const jettonWallet = tonClient.open(
|
|
14096
|
-
await jettonRoot.getWallet(
|
|
16057
|
+
await jettonRoot.getWallet(Address13.parse(walletData.address))
|
|
14097
16058
|
);
|
|
14098
16059
|
const swapPayload = VaultJetton.createSwapPayload({
|
|
14099
16060
|
poolAddress: pool.address,
|
|
14100
16061
|
limit: minAmountOut
|
|
14101
16062
|
});
|
|
14102
|
-
await jettonWallet.sendTransfer(sender,
|
|
16063
|
+
await jettonWallet.sendTransfer(sender, toNano22(DEDUST_GAS.SWAP_JETTON_TO_ANY), {
|
|
14103
16064
|
destination: jettonVault.address,
|
|
14104
16065
|
amount: amountIn,
|
|
14105
|
-
responseAddress:
|
|
14106
|
-
forwardAmount:
|
|
16066
|
+
responseAddress: Address13.parse(walletData.address),
|
|
16067
|
+
forwardAmount: toNano22(DEDUST_GAS.FORWARD_GAS),
|
|
14107
16068
|
forwardPayload: swapPayload
|
|
14108
16069
|
});
|
|
14109
16070
|
}
|
|
@@ -14267,8 +16228,8 @@ var dedustPoolsExecutor = async (params, context) => {
|
|
|
14267
16228
|
|
|
14268
16229
|
// src/agent/tools/dex/smart-quote.ts
|
|
14269
16230
|
import { Type as Type94 } from "@sinclair/typebox";
|
|
14270
|
-
import { TonClient as TonClient13, toNano as
|
|
14271
|
-
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";
|
|
14272
16233
|
import { getHttpEndpoint as getHttpEndpoint13 } from "@orbs-network/ton-access";
|
|
14273
16234
|
import { Factory as Factory3, Asset as Asset3, PoolType as PoolType3, ReadinessStatus as ReadinessStatus3 } from "@dedust/sdk";
|
|
14274
16235
|
var dexQuoteTool = {
|
|
@@ -14299,12 +16260,12 @@ async function getStonfiQuote(fromAsset, toAsset, amount, slippage) {
|
|
|
14299
16260
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
14300
16261
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
14301
16262
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS3 : fromAsset;
|
|
14302
|
-
const
|
|
16263
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
14303
16264
|
const stonApiClient = new StonApiClient();
|
|
14304
16265
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
14305
16266
|
offerAddress: fromAddress,
|
|
14306
|
-
askAddress:
|
|
14307
|
-
offerUnits:
|
|
16267
|
+
askAddress: toAddress2,
|
|
16268
|
+
offerUnits: toNano23(amount).toString(),
|
|
14308
16269
|
slippageTolerance: slippage.toString()
|
|
14309
16270
|
});
|
|
14310
16271
|
if (!simulationResult) {
|
|
@@ -14349,10 +16310,10 @@ async function getDedustQuote(fromAsset, toAsset, amount, slippage, tonClient) {
|
|
|
14349
16310
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
14350
16311
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
14351
16312
|
const factory = tonClient.open(
|
|
14352
|
-
Factory3.createFromAddress(
|
|
16313
|
+
Factory3.createFromAddress(Address14.parse(DEDUST_FACTORY_MAINNET))
|
|
14353
16314
|
);
|
|
14354
|
-
const fromAssetObj = isTonInput ? Asset3.native() : Asset3.jetton(
|
|
14355
|
-
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));
|
|
14356
16317
|
let pool;
|
|
14357
16318
|
let poolType = "volatile";
|
|
14358
16319
|
try {
|
|
@@ -14383,7 +16344,7 @@ async function getDedustQuote(fromAsset, toAsset, amount, slippage, tonClient) {
|
|
|
14383
16344
|
error: "Pool lookup failed"
|
|
14384
16345
|
};
|
|
14385
16346
|
}
|
|
14386
|
-
const amountIn =
|
|
16347
|
+
const amountIn = toNano23(amount);
|
|
14387
16348
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
14388
16349
|
assetIn: fromAssetObj,
|
|
14389
16350
|
amountIn
|
|
@@ -14526,10 +16487,9 @@ Use dex_swap to execute on the best DEX, or jetton_swap/dedust_swap for specific
|
|
|
14526
16487
|
// src/agent/tools/dex/smart-swap.ts
|
|
14527
16488
|
import { Type as Type95 } from "@sinclair/typebox";
|
|
14528
16489
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey10 } from "@ton/crypto";
|
|
14529
|
-
import { WalletContractV5R1 as WalletContractV5R110, TonClient as TonClient14, toNano as
|
|
14530
|
-
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";
|
|
14531
16492
|
import { getHttpEndpoint as getHttpEndpoint14 } from "@orbs-network/ton-access";
|
|
14532
|
-
import { DEX as DEX2, pTON as pTON2 } from "@ston-fi/sdk";
|
|
14533
16493
|
import { Factory as Factory4, Asset as Asset4, PoolType as PoolType4, ReadinessStatus as ReadinessStatus4, JettonRoot as JettonRoot2, VaultJetton as VaultJetton2 } from "@dedust/sdk";
|
|
14534
16494
|
var dexSwapTool = {
|
|
14535
16495
|
name: "dex_swap",
|
|
@@ -14564,12 +16524,12 @@ async function getStonfiQuote2(fromAsset, toAsset, amount, slippage) {
|
|
|
14564
16524
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
14565
16525
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
14566
16526
|
const fromAddress = isTonInput ? NATIVE_TON_ADDRESS3 : fromAsset;
|
|
14567
|
-
const
|
|
16527
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
14568
16528
|
const stonApiClient = new StonApiClient();
|
|
14569
16529
|
const simulationResult = await stonApiClient.simulateSwap({
|
|
14570
16530
|
offerAddress: fromAddress,
|
|
14571
|
-
askAddress:
|
|
14572
|
-
offerUnits:
|
|
16531
|
+
askAddress: toAddress2,
|
|
16532
|
+
offerUnits: toNano24(amount).toString(),
|
|
14573
16533
|
slippageTolerance: slippage.toString()
|
|
14574
16534
|
});
|
|
14575
16535
|
if (!simulationResult) {
|
|
@@ -14596,10 +16556,10 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
14596
16556
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
14597
16557
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
14598
16558
|
const factory = tonClient.open(
|
|
14599
|
-
Factory4.createFromAddress(
|
|
16559
|
+
Factory4.createFromAddress(Address15.parse(DEDUST_FACTORY_MAINNET))
|
|
14600
16560
|
);
|
|
14601
|
-
const fromAssetObj = isTonInput ? Asset4.native() : Asset4.jetton(
|
|
14602
|
-
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));
|
|
14603
16563
|
let pool;
|
|
14604
16564
|
let poolType = "volatile";
|
|
14605
16565
|
try {
|
|
@@ -14616,7 +16576,7 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
14616
16576
|
} catch {
|
|
14617
16577
|
return { dex: "DeDust", expectedOutput: 0, available: false, error: "Pool lookup failed" };
|
|
14618
16578
|
}
|
|
14619
|
-
const amountIn =
|
|
16579
|
+
const amountIn = toNano24(amount);
|
|
14620
16580
|
const { amountOut, tradeFee } = await pool.getEstimatedSwapOut({
|
|
14621
16581
|
assetIn: fromAssetObj,
|
|
14622
16582
|
amountIn
|
|
@@ -14645,7 +16605,7 @@ async function getDedustQuote2(fromAsset, toAsset, amount, slippage, tonClient)
|
|
|
14645
16605
|
async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulationResult, walletData, tonClient) {
|
|
14646
16606
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
14647
16607
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
14648
|
-
const
|
|
16608
|
+
const toAddress2 = isTonOutput ? NATIVE_TON_ADDRESS3 : toAsset;
|
|
14649
16609
|
const keyPair = await mnemonicToPrivateKey10(walletData.mnemonic);
|
|
14650
16610
|
const wallet = WalletContractV5R110.create({
|
|
14651
16611
|
workchain: 0,
|
|
@@ -14654,14 +16614,14 @@ async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulatio
|
|
|
14654
16614
|
const walletContract = tonClient.open(wallet);
|
|
14655
16615
|
const seqno = await walletContract.getSeqno();
|
|
14656
16616
|
const { router: routerInfo } = simulationResult;
|
|
14657
|
-
const router = tonClient.open(new
|
|
16617
|
+
const router = tonClient.open(new DEX4.v1.Router(routerInfo.address));
|
|
14658
16618
|
let txParams;
|
|
14659
16619
|
if (isTonInput) {
|
|
14660
|
-
const proxyTon = new
|
|
16620
|
+
const proxyTon = new pTON.v1(routerInfo.ptonMasterAddress);
|
|
14661
16621
|
txParams = await router.getSwapTonToJettonTxParams({
|
|
14662
16622
|
userWalletAddress: walletData.address,
|
|
14663
16623
|
proxyTon,
|
|
14664
|
-
askJettonAddress:
|
|
16624
|
+
askJettonAddress: toAddress2,
|
|
14665
16625
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
14666
16626
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
14667
16627
|
});
|
|
@@ -14669,7 +16629,7 @@ async function executeStonfiSwap(fromAsset, toAsset, amount, slippage, simulatio
|
|
|
14669
16629
|
txParams = await router.getSwapJettonToJettonTxParams({
|
|
14670
16630
|
userWalletAddress: walletData.address,
|
|
14671
16631
|
offerJettonAddress: fromAsset,
|
|
14672
|
-
askJettonAddress:
|
|
16632
|
+
askJettonAddress: toAddress2,
|
|
14673
16633
|
offerAmount: BigInt(simulationResult.offerUnits),
|
|
14674
16634
|
minAskAmount: BigInt(simulationResult.minAskUnits)
|
|
14675
16635
|
});
|
|
@@ -14700,32 +16660,32 @@ async function executeDedustSwap(fromAsset, toAsset, amount, pool, minAmountOut,
|
|
|
14700
16660
|
});
|
|
14701
16661
|
const walletContract = tonClient.open(wallet);
|
|
14702
16662
|
const sender = walletContract.sender(keyPair.secretKey);
|
|
14703
|
-
const factory = tonClient.open(Factory4.createFromAddress(
|
|
14704
|
-
const amountIn =
|
|
16663
|
+
const factory = tonClient.open(Factory4.createFromAddress(Address15.parse(DEDUST_FACTORY_MAINNET)));
|
|
16664
|
+
const amountIn = toNano24(amount);
|
|
14705
16665
|
if (isTonInput) {
|
|
14706
16666
|
const tonVault = tonClient.open(await factory.getNativeVault());
|
|
14707
16667
|
await tonVault.sendSwap(sender, {
|
|
14708
16668
|
poolAddress: pool.address,
|
|
14709
16669
|
amount: amountIn,
|
|
14710
16670
|
limit: minAmountOut,
|
|
14711
|
-
gasAmount:
|
|
16671
|
+
gasAmount: toNano24(DEDUST_GAS.SWAP_TON_TO_JETTON)
|
|
14712
16672
|
});
|
|
14713
16673
|
} else {
|
|
14714
|
-
const jettonAddress =
|
|
16674
|
+
const jettonAddress = Address15.parse(fromAsset);
|
|
14715
16675
|
const jettonVault = tonClient.open(await factory.getJettonVault(jettonAddress));
|
|
14716
16676
|
const jettonRoot = tonClient.open(JettonRoot2.createFromAddress(jettonAddress));
|
|
14717
16677
|
const jettonWallet = tonClient.open(
|
|
14718
|
-
await jettonRoot.getWallet(
|
|
16678
|
+
await jettonRoot.getWallet(Address15.parse(walletData.address))
|
|
14719
16679
|
);
|
|
14720
16680
|
const swapPayload = VaultJetton2.createSwapPayload({
|
|
14721
16681
|
poolAddress: pool.address,
|
|
14722
16682
|
limit: minAmountOut
|
|
14723
16683
|
});
|
|
14724
|
-
await jettonWallet.sendTransfer(sender,
|
|
16684
|
+
await jettonWallet.sendTransfer(sender, toNano24(DEDUST_GAS.SWAP_JETTON_TO_ANY), {
|
|
14725
16685
|
destination: jettonVault.address,
|
|
14726
16686
|
amount: amountIn,
|
|
14727
|
-
responseAddress:
|
|
14728
|
-
forwardAmount:
|
|
16687
|
+
responseAddress: Address15.parse(walletData.address),
|
|
16688
|
+
forwardAmount: toNano24(DEDUST_GAS.FORWARD_GAS),
|
|
14729
16689
|
forwardPayload: swapPayload
|
|
14730
16690
|
});
|
|
14731
16691
|
}
|
|
@@ -16130,14 +18090,14 @@ Example: "Send 2 TON to EQxxx with memo: john_doe"`,
|
|
|
16130
18090
|
};
|
|
16131
18091
|
var casinoBalanceExecutor = async (params, context) => {
|
|
16132
18092
|
try {
|
|
16133
|
-
const
|
|
16134
|
-
if (!
|
|
18093
|
+
const address4 = getWalletAddress();
|
|
18094
|
+
if (!address4) {
|
|
16135
18095
|
return {
|
|
16136
18096
|
success: false,
|
|
16137
18097
|
error: "Casino wallet not initialized. Contact admin."
|
|
16138
18098
|
};
|
|
16139
18099
|
}
|
|
16140
|
-
const balanceInfo = await getWalletBalance(
|
|
18100
|
+
const balanceInfo = await getWalletBalance(address4);
|
|
16141
18101
|
if (!balanceInfo) {
|
|
16142
18102
|
return {
|
|
16143
18103
|
success: false,
|
|
@@ -16168,7 +18128,7 @@ var casinoBalanceExecutor = async (params, context) => {
|
|
|
16168
18128
|
return {
|
|
16169
18129
|
success: true,
|
|
16170
18130
|
data: {
|
|
16171
|
-
address,
|
|
18131
|
+
address: address4,
|
|
16172
18132
|
balance: balance.toFixed(2),
|
|
16173
18133
|
balanceNano: balanceInfo.balanceNano,
|
|
16174
18134
|
status,
|
|
@@ -16199,7 +18159,7 @@ import { Api as Api53 } from "telegram";
|
|
|
16199
18159
|
|
|
16200
18160
|
// src/casino/payment-verifier.ts
|
|
16201
18161
|
import { TonClient as TonClient15, fromNano as fromNano8 } from "@ton/ton";
|
|
16202
|
-
import { Address as
|
|
18162
|
+
import { Address as Address16 } from "@ton/core";
|
|
16203
18163
|
import { getHttpEndpoint as getHttpEndpoint15 } from "@orbs-network/ton-access";
|
|
16204
18164
|
|
|
16205
18165
|
// src/casino/retry.ts
|
|
@@ -16276,7 +18236,7 @@ async function verifyPayment(db, params) {
|
|
|
16276
18236
|
const { botWalletAddress, betAmount, requestTime, gameType, userId } = params;
|
|
16277
18237
|
const endpoint = await getHttpEndpoint15({ network: "mainnet" });
|
|
16278
18238
|
const client = new TonClient15({ endpoint });
|
|
16279
|
-
const botAddress =
|
|
18239
|
+
const botAddress = Address16.parse(botWalletAddress);
|
|
16280
18240
|
const transactions = await withBlockchainRetry(
|
|
16281
18241
|
() => client.getTransactions(botAddress, { limit: 20 }),
|
|
16282
18242
|
"getTransactions"
|
|
@@ -16433,13 +18393,13 @@ function shouldAwardDailyJackpot(db) {
|
|
|
16433
18393
|
|
|
16434
18394
|
// src/casino/payout-sender.ts
|
|
16435
18395
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey11 } from "@ton/crypto";
|
|
16436
|
-
import { WalletContractV5R1 as WalletContractV5R111, TonClient as TonClient16, toNano as
|
|
16437
|
-
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";
|
|
16438
18398
|
import { getHttpEndpoint as getHttpEndpoint16 } from "@orbs-network/ton-access";
|
|
16439
18399
|
async function sendPayout(playerAddress, amount, message) {
|
|
16440
18400
|
try {
|
|
16441
18401
|
try {
|
|
16442
|
-
|
|
18402
|
+
Address17.parse(playerAddress);
|
|
16443
18403
|
} catch (e) {
|
|
16444
18404
|
return {
|
|
16445
18405
|
success: false,
|
|
@@ -16469,8 +18429,8 @@ async function sendPayout(playerAddress, amount, message) {
|
|
|
16469
18429
|
sendMode: SendMode9.PAY_GAS_SEPARATELY,
|
|
16470
18430
|
messages: [
|
|
16471
18431
|
internal9({
|
|
16472
|
-
to:
|
|
16473
|
-
value:
|
|
18432
|
+
to: Address17.parse(playerAddress),
|
|
18433
|
+
value: toNano25(amount),
|
|
16474
18434
|
body: message,
|
|
16475
18435
|
bounce: false
|
|
16476
18436
|
})
|
|
@@ -16865,8 +18825,8 @@ var casinoDiceExecutor = async (params, context) => {
|
|
|
16865
18825
|
// src/agent/tools/casino/payout.ts
|
|
16866
18826
|
import { Type as Type108 } from "@sinclair/typebox";
|
|
16867
18827
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey12 } from "@ton/crypto";
|
|
16868
|
-
import { WalletContractV5R1 as WalletContractV5R112, TonClient as TonClient17, toNano as
|
|
16869
|
-
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";
|
|
16870
18830
|
import { getHttpEndpoint as getHttpEndpoint17 } from "@orbs-network/ton-access";
|
|
16871
18831
|
var casinoPayoutTool = {
|
|
16872
18832
|
name: "casino_payout",
|
|
@@ -16963,7 +18923,7 @@ var casinoPayoutExecutor = async (params, context) => {
|
|
|
16963
18923
|
}
|
|
16964
18924
|
const payout = bet_amount * multiplier;
|
|
16965
18925
|
try {
|
|
16966
|
-
|
|
18926
|
+
Address18.parse(player_address);
|
|
16967
18927
|
} catch (e) {
|
|
16968
18928
|
return {
|
|
16969
18929
|
success: false,
|
|
@@ -16993,8 +18953,8 @@ var casinoPayoutExecutor = async (params, context) => {
|
|
|
16993
18953
|
sendMode: SendMode10.PAY_GAS_SEPARATELY + SendMode10.IGNORE_ERRORS,
|
|
16994
18954
|
messages: [
|
|
16995
18955
|
internal10({
|
|
16996
|
-
to:
|
|
16997
|
-
value:
|
|
18956
|
+
to: Address18.parse(player_address),
|
|
18957
|
+
value: toNano26(payout),
|
|
16998
18958
|
body: `${winType} You won ${payout} TON (${multiplier}x)`,
|
|
16999
18959
|
bounce: false
|
|
17000
18960
|
})
|
|
@@ -17795,17 +19755,17 @@ var GiftDetector = class {
|
|
|
17795
19755
|
|
|
17796
19756
|
// src/ton/transfer.ts
|
|
17797
19757
|
import { mnemonicToPrivateKey as mnemonicToPrivateKey13 } from "@ton/crypto";
|
|
17798
|
-
import { WalletContractV5R1 as WalletContractV5R113, TonClient as TonClient18, toNano as
|
|
17799
|
-
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";
|
|
17800
19760
|
import { getHttpEndpoint as getHttpEndpoint18 } from "@orbs-network/ton-access";
|
|
17801
19761
|
async function sendTon(params) {
|
|
17802
19762
|
try {
|
|
17803
|
-
const { toAddress, amount, comment = "", bounce = false } = params;
|
|
19763
|
+
const { toAddress: toAddress2, amount, comment = "", bounce = false } = params;
|
|
17804
19764
|
let recipientAddress;
|
|
17805
19765
|
try {
|
|
17806
|
-
recipientAddress =
|
|
19766
|
+
recipientAddress = Address19.parse(toAddress2);
|
|
17807
19767
|
} catch (e) {
|
|
17808
|
-
console.error(`Invalid recipient address: ${
|
|
19768
|
+
console.error(`Invalid recipient address: ${toAddress2}`, e);
|
|
17809
19769
|
return null;
|
|
17810
19770
|
}
|
|
17811
19771
|
const walletData = loadWallet();
|
|
@@ -17829,14 +19789,14 @@ async function sendTon(params) {
|
|
|
17829
19789
|
messages: [
|
|
17830
19790
|
internal11({
|
|
17831
19791
|
to: recipientAddress,
|
|
17832
|
-
value:
|
|
19792
|
+
value: toNano27(amount),
|
|
17833
19793
|
body: comment,
|
|
17834
19794
|
bounce
|
|
17835
19795
|
})
|
|
17836
19796
|
]
|
|
17837
19797
|
});
|
|
17838
19798
|
const pseudoHash = `${seqno}_${Date.now()}_${amount.toFixed(2)}`;
|
|
17839
|
-
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}`);
|
|
17840
19800
|
return pseudoHash;
|
|
17841
19801
|
} catch (error) {
|
|
17842
19802
|
console.error("Error sending TON:", error);
|