VKINHA Contract Documentation

ERC-20 VKINHA contract with buying, staking, and administration functionalities.

Overview

The VKINHA contract is an ERC-20 token deployed on the BNB Chain Mainnet, designed to provide buying, transferring, staking, and administrative functionalities, with anti-bot mechanisms and fees to encourage legitimate use and deter abuse. The token, symbolized as VKINHA, has a maximum total supply of 15 million and integrates with decentralized exchanges (DEXs) such as PancakeSwap, Biswap, ApeSwap, and SushiSwap, supporting purchases with BNB, BUSD, and USDT via Chainlink oracles.

Main Features

Contract Structure

Inheritances

Constants

The constants defined in the contract determine its behavior and operational limits. The table below lists the main constants:

Name Value Description
MAX_SUPPLY15_000_000 * 10^18Maximum supply of VKINHA (15M).
LOCKED_SUPPLY2_000_000 * 10^18Initial locked amount, unlockable after 365 days.
ADMIN_SUPPLY1_500_000 * 10^18Initial amount minted for admin1.
INITIAL_TOKEN_WALLET_SUPPLY11_500_000 * 10^18Initial amount minted for tokenWallet.
BURN_AMOUNT100_000 * 10^18Amount of tokens burned per interval.
BURN_SUPPLY_TARGET10_000_000 * 10^18Target supply after burns.
BURN_INTERVAL30 daysInterval between burns.
UNLOCK_DELAY365 daysLock period for LOCKED_SUPPLY.
STAKING_THRESHOLD10^16 (0.01 VKINHA)Minimum staking threshold.
MAX_STAKED_TOKENS1_000_000 * 10^18Maximum staked tokens allowed.
BASE_BUY_FEE_PERCENTAGE25 (0.25%)Base fee for purchases in buyTokens.
EXTRA_FEE_INCREMENT100 (1%)Fee increment per extra purchase within 30 minutes.
MAX_EXTRA_FEE_PERCENTAGE2000 (20%)Maximum additional fee for repetitive purchases.
TRANSFER_FEE_PERCENTAGE300 (3%)Fixed fee for normal transfers.
SELL_FEE_PERCENTAGE50 (0.5%)Additional fee for sales on DEX.
BASE_REWARD_RATE2 (0.002% per day)Base reward rate for staking.
EXTRA_REWARD_RATE1 (0.001% per 1000 tokens)Extra reward rate for tokens above 0.01 VKINHA.
MAX_REWARD_RATE100 (0.1% per day)Maximum reward rate for staking.
FEE_POOL_REWARD_RATE2 (0.002% per day)Reward rate on the fee pool.
MIN_TRANSACTION_AMOUNT1e11 (0.0000001 VKINHA)Minimum amount for purchases and transfers.
COOLDOWN_WINDOW30 minutesWindow for applying progressive fees.
RESET_WINDOW1 hourPeriod to reset extra fee after inactivity.

Configurable Addresses (Mainnet)

Configurable addresses used in the contract for administrators, wallets, and DEX integration:

Name Mainnet Address Description
admin10x5B419e1A55e24e91D7016D4313BC5b284382Faf6Primary administrator.
admin20xe93bc1259C7F53aBf2073b0528e6007275D0E507Secondary administrator.
tokenWallet0xB9A2eF80914Cb1bDBE93F04C86CBC9a54Eb0d7D2Token storage wallet.
dexRouter0x10ED43C718714eb63d5aA57B78B54704E256024EPancakeSwap V2 Router (configurable).
WBNB0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095cWrapped BNB on Mainnet.
BUSD0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56BUSD on Mainnet.
USDT0x55d398326f99059fF775485246999027B3197955USDT on Mainnet.

Chainlink Oracles (Mainnet)

Oracles used to fetch real-time prices for BNB, BUSD, and USDT:

Name Mainnet Address Description
bnbPriceFeed0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeEBNB/USD price.
busdPriceFeed0xcBb98864Ef56E9042e7d2efef76141f15731B82fBUSD/USD price.
usdtPriceFeed0xB97Ad0E74fa7d920791E90258A6E2085088b4320USDT/USD price.

Fee Logic

Fees on Purchase (buyTokensFunction to buy VKINHA tokens using BNB, BUSD, or USDT. Example: You send 0.1 BNB to receive VKINHA, paying an initial 0.25% fee that increases with frequent purchases.)

Base Fee: 0.25% (BASE_BUY_FEE_PERCENTAGE).

Progressive Fee:

Note: The progressive fee is designed to discourage automated trading bots and high-frequency trades, which can manipulate the price. This ensures a more stable and fair trading environment.

Calculation:

uint256 extraFee = purchaseCountInWindow[msg.sender] > 1 ? (purchaseCountInWindow[msg.sender] - 1) * EXTRA_FEE_INCREMENT : 0;
uint256 totalFeePercentage = BASE_BUY_FEE_PERCENTAGE + (extraFee > MAX_EXTRA_FEE_PERCENTAGE ? MAX_EXTRA_FEE_PERCENTAGE : extraFee);
uint256 buyFee = (amount * totalFeePercentage) / 10000;
uint256 amountAfterFee = amount - buyFee;

Destination: buyFee is transferred to tokenWallet and added to accumulatedFeePool.

Fees on Transfer (transferFunction to send VKINHA to another address. Example: You send 10 VKINHA to a friend and pay a 3% fee (0.3 VKINHA). If it's a sale on DEX, you pay an additional 0.5%.)

Transfer Fee: 3% (TRANSFER_FEE_PERCENTAGE) on all transfers.

Sale Fee: 0.5% (SELL_FEE_PERCENTAGE) additional only when the recipient is dexRouter (sale on DEX).

Calculation:

uint256 transferFee = (amount * TRANSFER_FEE_PERCENTAGE) / 10000;
uint256 sellFee = (to == dexRouter) ? (amount * SELL_FEE_PERCENTAGE) / 10000 : 0;
uint256 totalFee = transferFee + sellFee;
uint256 amountAfterFee = amount - totalFee;

Destination: totalFee is transferred to tokenWallet and added to accumulatedFeePool.

Reward Logic

Staking (stakeTokensFunction to stake your VKINHA and earn rewards. Example: You stake 100 VKINHA for 30 days and receive a portion of the collected fees as a reward.)

Operation: Users stake VKINHA to earn rewards based on accumulated fees.

Rewards: Calculated in calculateRewards based on:

Calculation:

uint256 baseReward = (staker.amount * BASE_REWARD_RATE * timeElapsed) / (10000 * 1 days);
uint256 extraReward = (extraTokens / (1000 * 1e18)) * EXTRA_REWARD_RATE * timeElapsed / (10000 * 1 days);
uint256 fixedReward = baseReward + extraReward > maxReward ? maxReward : baseReward + extraReward;
uint256 feePoolReward = (feePoolDelta * FEE_POOL_REWARD_RATE * timeElapsed) / (10000 * 1 days);
uint256 proportionalReward = totalStaked > 0 ? (staker.amount * feePoolReward) / totalStaked : 0;
return staker.accumulatedRewards + fixedReward + proportionalReward;

Payment: Rewards are transferred from tokenWallet when calling claimRewardsFunction to claim your staking rewards. Example: After staking 100 VKINHA, you claim 0.5 VKINHA in rewards..

Fees and Holder Benefits

The VKINHA contract implements a fee structure where a portion of the fees collected from purchases and transfers is allocated to a dedicated fee pool. This pool serves as the foundation for distributing rewards to token holders who participate in staking. Specifically, a segment of the accumulated fees is systematically redistributed to stakers, proportional to their staked amount, thereby providing a direct financial benefit to committed holders. This mechanism not only incentivizes long-term holding and active participation in the ecosystem but also contributes to the token's overall health and stability by aligning the interests of holders with the sustainability of the network. By rewarding those who stake their VKINHA tokens, the system fosters a robust and resilient token economy.

Administrative Functions

Administrators

admin1: Initial owner with permission for all administrative functions.

admin2: Secondary administrator with permission for specific functions (e.g., replaceTokenWallet).

Main Functions

Interaction Examples

Using Remix

Buying VKINHA with BNB:

Transferring VKINHA:

Using Web3.js

const Web3 = require('web3');
const web3 = new Web3('https://bsc-dataseed.binance.org/');
const contractABI = [/* Contract ABI */];
const contractAddress = '0xContract';
const contract = new web3.eth.Contract(contractABI, contractAddress);

async function buyTokens(account, amount) {
    const tx = await contract.methods.buyTokens(amount, "0x0000000000000000000000000000000000000000")
        .send({ from: account, value: web3.utils.toWei('0.001', 'ether') });
    console.log('Purchase completed:', tx.transactionHash);
}

buyTokens('0xYourAddress', '1000000000000000');

Security Considerations

Attack Vectors and Mitigations

Recommendations

Testing

Test Strategy

Recommended Tools

Hardhat:

Setup:

const { ethers } = require("hardhat");

async function main() {
    const VKINHA = await ethers.getContractFactory("VKINHA");
    const vkinha = await VKINHA.deploy();
    await vkinha.deployed();
    console.log("Contract deployed to:", vkinha.address);
}

Tests:

it("should apply progressive buy fee", async function () {
    const [owner] = await ethers.getSigners();
    await vkinha.buyTokens(ethers.utils.parseEther("0.001"), "0x0", { value: ethers.utils.parseEther("0.001") });
    await vkinha.buyTokens(ethers.utils.parseEther("0.001"), "0x0", { value: ethers.utils.parseEther("0.001") });
    // Verify fee > 0.25%
});

Foundry:

Setup: Use forge init and add the contract.

Test: Write in Solidity to simulate interactions.

Steps

Gas Optimization

Current Optimizations

Possible Improvements

Impact

Estimated reduction: 5-10% in gas cost per transaction.