The stabilizer bot is designed to maintain the price stability of a token by pegging it to a stable coin. The bot uses a mint/burn algorithm to maintain the price stability. In this testing report, we will test the functionality of the bot and ensure that it is working as expected.
Test Case 2: Mint 2 token to stimulate Low Demand Bot should Burn Tokens until price is at threshold
· Input: Price of the token = 1 USDT, Threshold = 0.01, Current token supply = 102 tokens
· Output: Burn 2 tokens and price of stablecoin is 0.998USDT and will transfer required USDT to make it 1USDT again from reserve wallet to contract
· RESULT : PASS
Test Case 3: Transfer 1 USDT to contract to stimulate High Demand Bot should Burn tokens to stabilize exceeding price
· Input: Price of the token = 1 USDT, Current token supply = 100 tokens 101 USDT in reserves
· Output: Burn 1 tokens and transfer required USDT from the contract to reserved wallet RESULT : PASS
Test Case 4: Price depreciates due to increase in USDT reserves in smart contract BOT should mint tokens adjustments to stabilize the price by equalizing supply and reserves
· RESULT :PASS
Test Case 5: Do not mint/burn tokens when the price is within the threshold
· Input: Price of the token = 0.99 USDT, Threshold price = 1 USDT, Current token supply = 99 tokens USDT reserves 99 USDT
· Output: Do not mint or burn tokens
· RESULT : PASS
Conclusion
The stabilizer bot was successfully tested and all test cases passed. The bot was able to maintain the price stability of the token by pegging it to a stable coin. The mint/burn algorithm was effective in controlling the token supply and maintaining the price stability.
To test the efficiency of the stabilizer with stressed the bot, th how you can test Gusd :
// Scripts:To Run Tests:npx harhat nodenpx hardhat test test/TestBot.js --network localhostconst { expect } =require("chai");const { ethers } =require("hardhat");constWeb3=require('web3');conststabilizer=require('./testingBot')describe("StabilizerBot",function () {let owner;let add;let stablecoinContract;let usdtContract;before(async () => { [owner, add] =awaitethers.getSigners();constUSDT=awaitethers.getContractFactory("MockUSDT"); usdtContract =awaitUSDT.deploy();awaitusdtContract.deployed();constContract=awaitethers.getContractFactory("Stablecoin"); stablecoinContract =awaitContract.deploy(100,usdtContract.address);awaitstablecoinContract.deployed();awaitusdtContract.transfer(stablecoinContract.address,100);awaitusdtContract.approve(stablecoinContract.address,ethers.constants.MaxUint256 ); });it("should check the price",asyncfunction () {constgetUSDTBalance=awaitstablecoinContract.balanceOfUSDT()constgettotalSupply=awaitstablecoinContract.totalSupply()// const price = await stablecoinContractconsole.log(getUSDTBalance.toNumber());console.log(parseInt(gettotalSupply.toString())/10**18);console.log("add________",add.address);console.log("usdtContract.address",usdtContract.address);console.log("stablecoinContract.address",stablecoinContract.address);try{let check=awaitstabilizer.stabilize(usdtContract.address,stablecoinContract.address)console.log(check);expect(check).to.equal(1);}catch(e){console.log(e); } });it("should not Mint or Burn if price is 1",asyncfunction () {constTargetPrice=1;try{let check=awaitstabilizer.stabilize(usdtContract.address,stablecoinContract.address)console.log(check);expect(check).to.equal(TargetPrice); }catch(e){console.log(e); } });it("should adjust the supply by minting stablecoin",asyncfunction () {// ustabilize stablecoin by increasing price by transfering usdtawaitusdtContract.transfer(stablecoinContract.address,100);try{let check=awaitstabilizer.stabilize(usdtContract.address,stablecoinContract.address)console.log(check);expect(check).to.equal(1); }catch(e){console.log(e); } });it("should adjust the supply by burning stablecoin",asyncfunction () {constMint=awaitstablecoinContract.mintAdjust("10000000000000000000")try{let check=awaitstabilizer.stabilize(usdtContract.address,stablecoinContract.address)console.log(check);expect(check).to.equal(1); }catch(e){console.log(e); } });});