Skip to content

Instantly share code, notes, and snippets.

@korrio
Last active August 18, 2021 02:22
Show Gist options
  • Save korrio/30804e5b8375b5fc0012d4e37708ec4a to your computer and use it in GitHub Desktop.
Save korrio/30804e5b8375b5fc0012d4e37708ec4a to your computer and use it in GitHub Desktop.
redeem.sol
function redeem(uint256 amount) external nonReentrant {
uint256 busdTransferAmount = amount * (1000 - xvonPermille - treasuryPermille) / 1000;
uint256 busdTreasuryAmount = amount * treasuryPermille / 1000;
uint256 xvonTransferAmount = xvon.balanceOf(address(this)) * amount / vdp.totalSupply();
vdp.burn(msg.sender, amount);
busd.safeTransfer(treasury, busdTreasuryAmount);
busd.safeTransfer(msg.sender, busdTransferAmount);
xvon.safeTransferFrom(msg.sender, address(this), xvonTransferAmount);
emit Redeem(msg.sender, amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment