import { Address, toNano } from '@ton/core'; import { MainBalance } from '../wrappers/MainBalance'; import { compile, NetworkProvider } from '@ton/blueprint'; import contractConfig from '../config/contract.config'; import { calcPercent, getMainBalanceContract } from './utils'; export async function run(provider: NetworkProvider) { const ui = provider.ui(); const mainBalance = await getMainBalanceContract(provider); const depositAddress = contractConfig.script.depositAddress; const depositAmount = contractConfig.script.depositAmount; const withdrawAmount = depositAmount - calcPercent(depositAmount, contractConfig.totalFee); ui.write(`Current contract balance: ${await mainBalance.getBalance()}`); await mainBalance.sendWithdraw(provider.sender(), Address.parse(depositAddress), toNano(withdrawAmount)) ui.write(`${depositAmount} - ${contractConfig.totalFee}% = ${withdrawAmount} TON was withdrawn to user address: ${depositAddress}`); }