1.10 - Smart Contract Functionality

Please keep in mind that this smart contract functionality is no longer current, as node creations and their effective use as a liquidity mining program have been capped (stopped). It is no longer possible to create new nodes.

Nodes can be only bought, sold and traded on the tofuNFT marketplace.

--

There are 2 main Samurai owned addresses to consider: FutureUsePool and DistributionPool.

This is how the Node Creation algorithm works, line by line.

The contract effectively conducts the following:

  1. Check the input parameters to ensure that the wallet buying a node is not blacklisted, is not a zero address, is not a FutureUsePool or DistributionPool, and that the wallet has enough balance to buy the node at the stated price. Furthermore, the node name is validated and checked for node name length.

  2. Check whether the contract contains enough of KTNA tokens to engage in a DEX swapping operation, and if swapping is enabled. It also ensures that the transaction sender is not an owner, and that the address invoking the creation operation is not an AMM pair contract. If all these conditions pass, the contract will engage in a swapping operation and then follows step 3, or else the contract will skip the swapping operation and just passes through to step 3.

  3. Lastly, after the initial 2 steps, the contract will transfer an amount of KTNA tokens equivalent to the Node Price out of the wallet, which has called the transaction, and the said tokens will arrive to the contract address. After this step, the node is finally created for the respective wallet.

The Swapping Operation

The following fee structure is used to determine the amount that will be swapped:

FutureFee: 2%

LiquidityPoolFee: 10%

RewardsFee: 60%

RwSwap: 30%

These keywords will be reused to describe how the swapping operation works.

We are also assuming that the swapping threshold for the contract to engage in the operation is 100 KTNA and “swapLiquify” is enabled. That is, if the contract Samurai contains 100 KTNA tokens at the moment, and wallet A invokes a “createNodeWithTokens” function, the contract will engage in the swapping operation as part of the function processing.

This is the algorithm procedure given 100 initial KTNA tokens:

  1. Set “swapping” state to true (to lock the process and prevent re-entrancy)

  2. Swap 2 KTNA tokens and send them to FutureUsePool. This is using FutureFee rate of 2%.

  3. Calculate rewards tokens to swap, by firstly calculating the rewards pool tokens amount. This is 60 KTNA (rewardsPoolTokens) and 18 KTNA (rewardsTokensToSwap). It is 18 KTNA, because we are taking 30% out of the 60 KTNA tokens.

  4. Swap 18 KTNA tokens and send them to DistributionPool. This is using the RewardsFee rate of 60% and RwSwap fee rate of 30% in conjunction to calculate this fee of 18%.

  5. Transfer 42 KTNA tokens (60 minus 18) from the contract address to the DistributionPool. Note, these tokens are NOT being swapped, just transferred to refill the distribution pool.

  6. Swap 10 KTNA tokens and refill the liquidity pool on SpookySwap. These tokens are therefore given back to the DEX. This is using the LiquidityPool fee rate of 10%.

  7. Swap the remaining 28 KTNA tokens into FTM and leave them on the contract address.

  8. Set the swapping state to false and conclude the swapping operation.

The payees/shareholders (the core team) can then withdraw the amount of FTM, which has been swapped from the final 28 KTNA tokens, from the contract address into the designated wallets. All the fees collected by the aforementioned pools and the funds that are directed to the payee wallet addresses represent the allocation of the core team (as outlined in the tokenomics section - 1.3).

The total amount of percentage of inital KTNA tokens, that is swapped to FTM and then kept within the wallets is therefore:

2 (FutureFee) + 18 (RewardsFee * RwSwap) + 28 (Remaining amount of final tokens) = 48%

10% is used to automatically refill the DEX pool, and 42% of KTNA is used to refill the distribution pool to redistribute KTNA further.

Last updated