diff --git a/brownie-config.yaml b/brownie-config.yaml index 6efba1693..4abd5ef36 100644 --- a/brownie-config.yaml +++ b/brownie-config.yaml @@ -29,7 +29,7 @@ networks: cmd_settings: port: 443 gas_limit: 6800000 - gas_price: 65000010 # 8000000000 + gas_price: 20000000000 # 20 GWei reverting_tx_gas_limit: false default_contract_owner: false diff --git a/interfaces/IPancakeRouter01.sol b/interfaces/IPancakeRouter01.sol new file mode 100644 index 000000000..eba5a85bf --- /dev/null +++ b/interfaces/IPancakeRouter01.sol @@ -0,0 +1,96 @@ +/// @dev https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/IPancakeRouter01.sol (pragma changed) +pragma solidity ^0.5.17; + +interface IPancakeRouter01 { + function factory() external pure returns (address); + function WETH() external pure returns (address); + + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB, uint liquidity); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external payable returns (uint amountToken, uint amountETH, uint liquidity); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns (uint amountA, uint amountB); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountToken, uint amountETH); + function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountA, uint amountB); + function removeLiquidityETHWithPermit( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountToken, uint amountETH); + function swapExactTokensForTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapTokensForExactTokens( + uint amountOut, + uint amountInMax, + address[] calldata path, + address to, + uint deadline + ) external returns (uint[] memory amounts); + function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + external + returns (uint[] memory amounts); + function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) + external + payable + returns (uint[] memory amounts); + + function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); + function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); + function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); + function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); + function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); +} diff --git a/interfaces/IPancakeRouter02.sol b/interfaces/IPancakeRouter02.sol new file mode 100644 index 000000000..1aa919f9a --- /dev/null +++ b/interfaces/IPancakeRouter02.sol @@ -0,0 +1,45 @@ +/// @dev https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/IPancakeRouter02.sol (with minor changes) +pragma solidity ^0.5.17; + +import './IPancakeRouter01.sol'; + +contract IPancakeRouter02 is IPancakeRouter01 { + function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns (uint amountETH); + function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline, + bool approveMax, uint8 v, bytes32 r, bytes32 s + ) external returns (uint amountETH); + + function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; + function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external payable; + function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint amountIn, + uint amountOutMin, + address[] calldata path, + address to, + uint deadline + ) external; +} diff --git a/scripts/pancakeswap/README.md b/scripts/pancakeswap/README.md new file mode 100644 index 000000000..035f6ef19 --- /dev/null +++ b/scripts/pancakeswap/README.md @@ -0,0 +1,123 @@ +# PancakeSwap Pool Creation + +## Files: + +### deploy_test_bSOV + +Creates a sample SOV token in the network you choose with 100 Million tokens. + +### deploy_multisig + +Creates a sample multisig using [`MultisigWallet.sol`](../../contracts/multisig/MultiSigWallet.sol) + +The multisig owners are taken from either [`bsc_testnet_contracts.json`](./bsc_testnet_contracts.json) or [`bsc_mainnet_contracts.json`](./bsc_mainnet_contracts.json) depending on the network. + +In testnet, required confirmations from admins are 1 while in mainnet, it is 2. + +### deploy_pool_user + +Creates a pool from an EOA (Externally Owned Account) in PancakeSwap. + +It assumes that you have enough BNB & token balance for the liquidity in the wallet calling this function. + +It checks if the token is approved to be spent by the PancakeSwap, if not, it will do that. + +It then creates the pool in PancakeSwap. + +### deploy_pool + +Creates a pool from a multisig in PancakeSwap. + +It assumes either multisig or the user (EOA) calling it has enough BNB and Token in balance. + +It checks if the multisig has enough BNB balance, if not it takes the required BNB from EOA. + +It then checks if the multisig has enough Token balance, if not, it takes the required Token from EOA. + +It then checks if the token is approved to be spent by the PancakeSwap, if not, it will do that. + +It then creates a pool from multisig. (A transaction in multisig is created.) + +If checking on testnet, these steps will create the pool. If on mainnet, another user has to call the confirm transaction. + +## Steps to Create Pool: + +NOTE: Dev experience advised to run the script and to make some edits suggested. + + +### Brownie Configuration for Binance Network + +Add new BSC networks to brownie: + +``` +brownie networks add "BSC" "binance-mainnet" host="https://bsc​-dataseed1.defibit.io/" chainid=56 +``` + +``` +brownie networks add "BSC" "binance-testnet" host="https://data-seed-prebsc-1-s1.binance.org:8545/" chainid=97 +``` + +### Mainnet + +1. Go to [`bsc_mainnet_contracts.json`](./bsc_mainnet_contracts.json) and add the values for Multisig Admins. (NOTE: PancakeRouter02 is taken from [OpenZeppeling Forum](https://forum.openzeppelin.com/t/psa-regarding-safemoon-forks-on-pancakeswap-transfers-not-working-read-this/7692) and bSOV is taken from [Sovryn Wiki](https://wiki.sovryn.app/en/technical-documents/mainnet-contract-addresses). Please don't change it unless you know what you are doing.) + +2. Go to [`brownie-config.yaml`](../../brownie-config.yaml) and edit the `gas_price` under `networks > live` to the current average or fast gas price for BSC network. Binance average is somewhere near [`20 Gwei`](https://bscscan.com/chart/gasprice). + +3. (Optional) Deploying MultiSig: If you don't have a multisig yet, please use the [`deploy_multisig.py`](./deploy_multisig.py) to create a multisig with the parameters taken from [`bsc_mainnet_contracts.json`](./bsc_mainnet_contracts.json). To create, please run the following command: + +``` +brownie run scripts/pancakeswap/deploy_multisig.py --network binance-mainnet +``` + +4. Once multisig is deployed or known, please update [`bsc_mainnet_contracts.json`](./bsc_mainnet_contracts.json) to add the new multisig address. + +5. Deploying Pool: Create a new pool using [`deploy_pool.py`](./deploy_pool.py). To create, please run the following command: + +``` +brownie run scripts/pancakeswap/deploy_pool.py --network binance-mainnet +``` + +### Testnet + +1. Go to [`bsc_testnet_contracts.json`](./bsc_testnet_contracts.json) and add the values for Multisig Admins. (NOTE: PancakeRouter02 is taken from [PancakeSwap's Twitter Feed](https://twitter.com/pancakeswap/status/1369547285160370182?lang=en). Please don't change it unless you know what you are doing.) + +2. Go to [`brownie-config.yaml`](../../brownie-config.yaml) and edit the `gas_price` under `networks > live` to the current average or fast gas price for BSC network. + +3. (Optional) Deploying bSOV: If you don't have a bSOV Token yet, please use the [`deploy_test_bSOV.py`](./deploy_test_bSOV.py) to create a bSOV Token with 100 Million as Token Initial Supply. To create, please run the following command: + +``` +brownie run scripts/pancakeswap/deploy_test_bSOV.py --network binance-testnet +``` + +4. Once bSOV is deployed or known, please update [`bsc_testnet_contracts.json`](./bsc_testnet_contracts.json) to add the new bSOV Token address. + +5. (Optional) Deploying MultiSig: If you don't have a multisig yet, please use the [`deploy_multisig.py`](./deploy_multisig.py) to create a multisig with the parameters taken from [`bsc_testnet_contracts.json`](./bsc_testnet_contracts.json). To create, please run the following command: + +``` +brownie run scripts/pancakeswap/deploy_multisig.py --network binance-testnet +``` + +6. Once multisig is deployed or known, please update [`bsc_testnet_contracts.json`](./bsc_testnet_contracts.json) to add the new multisig address. + +7. Deploying Pool: Create a new pool using [`deploy_pool.py`](./deploy_pool.py). To create, please run the following command: + +``` +brownie run scripts/pancakeswap/deploy_pool.py --network binance-testnet +``` + +NOTE: If you want to create a pool with EOA, use [`deploy_pool_user.py`](./deploy_pool_user.py). This does not require multisig deployment. + +## Possible Errors: + +1. Please don't forget to set end points (RPC) for brownie networks (`binance-mainnet` and `binance-testnet`). Use your own full node, or any provider like [BSC RPC Endpoints](https://docs.binance.org/smart-chain/developer/rpc.html). + +2. If the multisig does not have enough tokens or BNB to provide liquidity, it is taken from the account which is running it. Please make sure you have enough liquidity present in either your account or multisig. + +The deploy script w/ no multisig (`deploy_pool_user.py`) and also the multisign script (`deploy_pool.py`) on line 12 has a default configuration values for the amount of BNB and bSOV to spend when deploying the pool: + +``` + # deployPool(10e18, 500e18) ## previous settings probably right for mainet, but too high for a regular faucet interaction on testnet. + deployPool(.1e18, 5e18) +``` + +So, be sure to set these values properly on mainnet before running the scripts. diff --git a/scripts/pancakeswap/bsc_mainnet_contracts.json b/scripts/pancakeswap/bsc_mainnet_contracts.json new file mode 100644 index 000000000..2e68a9044 --- /dev/null +++ b/scripts/pancakeswap/bsc_mainnet_contracts.json @@ -0,0 +1,6 @@ +{ + "multisigOwners": ["0x4C3d3505d34213751c4b4d621cB6bDe7E664E222", "0x9E0816a71B53ca67201a5088df960fE90910DE55", "0x27D55f5668eF4438635bdCE0aDCA083507E77752", "0x3Fa303A564645a36a8a92BBB5B7eAF1a899213F4", "0xDBE9fDECb4510ab20BB5A6D32C720f1048704A44"], + "bscMultisig": "", + "PancakeRouter02": "0x10ED43C718714eb63d5aA57B78B54704E256024E", + "bSOV": "0x8753ede1b3a36358e4d7780f384f3f7a2d9e4359" +} \ No newline at end of file diff --git a/scripts/pancakeswap/bsc_testnet_contracts.json b/scripts/pancakeswap/bsc_testnet_contracts.json new file mode 100644 index 000000000..a2de66246 --- /dev/null +++ b/scripts/pancakeswap/bsc_testnet_contracts.json @@ -0,0 +1,6 @@ +{ + "multisigOwners": ["0x4C3d3505d34213751c4b4d621cB6bDe7E664E222", "0x9E0816a71B53ca67201a5088df960fE90910DE55", "0x27D55f5668eF4438635bdCE0aDCA083507E77752", "0x3Fa303A564645a36a8a92BBB5B7eAF1a899213F4", "0xDBE9fDECb4510ab20BB5A6D32C720f1048704A44"], + "bscMultisig": "", + "PancakeRouter02": "0xD99D1c33F9fC3444f8101754aBC46c52416550D1", + "bSOV": "" +} diff --git a/scripts/pancakeswap/deploy_multisig.py b/scripts/pancakeswap/deploy_multisig.py new file mode 100644 index 000000000..4d2cbcb62 --- /dev/null +++ b/scripts/pancakeswap/deploy_multisig.py @@ -0,0 +1,54 @@ +from brownie import * + +import json + +def main(): + loadConfig() + + balanceBefore = acct.balance() + # Function Call + deployMultisig() + balanceAfter = acct.balance() + + print("=============================================================") + print("BNB Before Balance: ", balanceBefore) + print("BNB After Balance: ", balanceAfter) + print("Gas Used: ", balanceBefore - balanceAfter) + print("=============================================================") + +def loadConfig(): + global contracts, acct + thisNetwork = network.show_active() + + # == Load config ======================================================================================================================= + if thisNetwork == "binance-testnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_testnet_contracts.json') + elif thisNetwork == "binance-mainnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_mainnet_contracts.json') + else: + raise Exception("Network not supported.") + + # Load deployed contracts addresses + contracts = json.load(configFile) + +# == Multisig Deployment ====================================== +def deployMultisig(): + owners = contracts["multisigOwners"] + requiredConf = 1 + if network.show_active() == "mainnet": + requiredConf = int(len(owners)/2 + 1) + print("=============================================================") + print("Deployment Parameters") + print("=============================================================") + print("Multisig Owners: ", owners) + print("Required Confirmations: ", requiredConf) + print("=============================================================") + + multisig = acct.deploy(MultiSigWallet, owners, requiredConf) + print("=============================================================") + print("Deployed Details") + print("=============================================================") + print("Multisig Address: ", multisig) + print("=============================================================") \ No newline at end of file diff --git a/scripts/pancakeswap/deploy_pool.py b/scripts/pancakeswap/deploy_pool.py new file mode 100644 index 000000000..00044ab06 --- /dev/null +++ b/scripts/pancakeswap/deploy_pool.py @@ -0,0 +1,162 @@ +from brownie import * +from brownie.network.contract import InterfaceContainer +import time +import json +import sys + +def main(): + loadConfig() + + balanceBefore = acct.balance() + # Function Call + # tokenTransfer(contracts['multisig'], bSOVAmount) # Change bSOVAmount with the amount of bSOV to be transferred. + deployPoolFromMultisig(10e18, 500e18) + # deployPoolFromMultisig(.1e10, 5e10) # testnet settings (mainet settings are too high for a regular faucet interaction). + # confirmTransaction() # Need to add a transaction ID as parameter. + # executeOnMultisig() # Need to add a transaction ID as parameter. + balanceAfter = acct.balance() + + print("=============================================================") + print("BNB Before Balance: ", balanceBefore) + print("BNB After Balance: ", balanceAfter) + print("Gas Used: ", balanceBefore - balanceAfter) + print("=============================================================") + +def loadConfig(): + global contracts, acct + thisNetwork = network.show_active() + + ### IMPORTANT! rskdeployer account should be the same as multisig's owner1 + + # == Load config ======================================================================================================================= + if thisNetwork == "binance-testnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_testnet_contracts.json') + elif thisNetwork == "binance-mainnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_mainnet_contracts.json') + else: + raise Exception("Network not supported.") + + # Load deployed contracts addresses + contracts = json.load(configFile) + +# == PancakeSwap Pool Deployment ================================== +def deployPoolFromMultisig(bnbAmount, bSOVAmount): + bSOV = Contract.from_abi("SOV", address = contracts['bSOV'], abi = SOV.abi, owner = acct) + bscMultisig = Contract.from_abi("MultiSig", address=contracts['bscMultisig'], abi=MultiSigWallet.abi, owner=acct) + pancakeRouter02 = Contract.from_abi("IPancakeRouter02", address=contracts['PancakeRouter02'], abi=interface.IPancakeRouter02.abi, owner=acct) + + # Checks if multisig has enough BNB balance. If not enough, will transfer in case of test network. + checkBnbBalanceAndTransfer(bscMultisig, bnbAmount) + + # Checks if multisig has enough token balance. If not enough, will transfer in case of test network. + checkTokenBalanceAndTransfer(bSOV, bscMultisig.address, bSOVAmount) + + # Checks if multisig has approved PancakeSwap for transfer. If not, will do the transfer. + checkTokenApprovalInMultisig(bSOV, bscMultisig.address, pancakeRouter02.address, bSOVAmount) + + # Creating PancakeSwap Pool + thirtyMinutes = 30 * 60 + currentTimestamp = int(time.time()) + deadline = currentTimestamp + thirtyMinutes + data = pancakeRouter02.addLiquidityETH.encode_input(bSOV.address, bSOVAmount, bSOVAmount, bnbAmount, bscMultisig.address, deadline) + # https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L61 + print("=============================================================") + print("Interaction Parameters (Pool Creation)") + print("=============================================================") + print("bSOV Token: ", bSOV.address) + print("amountTokenDesired: ", bSOVAmount) + print("amountTokenMin: ", bSOVAmount) + print("amountBNBMin: ", bnbAmount) + print("to: ", bscMultisig.address) + print("deadline: ", deadline) + print("Encoded Data: ", data) + print("=============================================================") + print("Current Timestamp: ", currentTimestamp) + print("=============================================================") + submitTransaction(pancakeRouter02.address, bnbAmount, data) + +# Checks if enough balance is there in a receiver, if not, will transfer the difference. +def checkBnbBalanceAndTransfer(receiver, bnbAmount): + bal = receiver.balance() + if(bal < bnbAmount): + if network.show_active() == "binance-testnet": + acct.transfer(receiver.address, bnbAmount - bal) + else: + print("Not enough BNB balance in address.") + sys.exit() + +# Just a function to take out BNB from multisig. +def bnbTransferOutFromMultisig(receiver, bnbAmount): + submitTransaction(receiver, bnbAmount, '0x') + +# Checks user token balance, and if not enough balance, will either quit the program (mainnet) or replenish (testnet) +def checkTokenBalanceAndTransfer(token, addr, amount): + addrBalance = token.balanceOf(addr) + if(addrBalance < amount): + if network.show_active() == "binance-testnet": + tokenTransfer(addr, amount) + else: + print("Not enough token balance in address.") + sys.exit() + +# Makes the token transfer to `receiver` for the amount of `bSOVAmount`. +def tokenTransfer(receiver, bSOVAmount): + bSOV = Contract.from_abi("SOV", address = contracts['bSOV'], abi = SOV.abi, owner = acct) + print("=============================================================") + print("Interaction Parameters (Token Transfer)") + print("=============================================================") + print("Receiver: ", receiver) + print("bSOV Amount: ", bSOVAmount) + print("=============================================================") + tx = bSOV.transfer(receiver, bSOVAmount) + tx.info() + +# Checks if enough token approval is there in spender from owner. If not, it will make the allowance. This one is made for multisig. +def checkTokenApprovalInMultisig(token, owner, spender, amount): + if(token.allowance(owner, spender) < amount): + # Approving token transfer. + data = token.approve.encode_input(spender, amount) + print("=============================================================") + print("Interaction Parameters (Token Transfer Approval)") + print("=============================================================") + print("Spender Address: ", spender) + print("Amount approved: ", amount) + print("Encoded Data: ", data) + print("=============================================================") + submitTransaction(token.address, 0, data) + +# Submits the transaction in multisig. +def submitTransaction(target, value, data): + bscMultisig = Contract.from_abi("MultiSig", address=contracts['bscMultisig'], abi=MultiSigWallet.abi, owner=acct) + tx = bscMultisig.submitTransaction(target, value, data) + txId = tx.events["Submission"]["transactionId"] + print("=============================================================") + print("Return Parameters (Multisig Submission)") + print("=============================================================") + print("Transaction ID: ", txId) + print("=============================================================") + tx.info() + +# Confirm the transaction in multisig. +def confirmTransaction(transactionId): + bscMultisig = Contract.from_abi("MultiSig", address=contracts['bscMultisig'], abi=MultiSigWallet.abi, owner=acct) + print("=============================================================") + print("Interaction Parameters (Multisig Confirmation)") + print("=============================================================") + print("Transaction ID: ", transactionId) + print("=============================================================") + tx = bscMultisig.confirmTransaction(transactionId) + tx.info() + +# Execute the transaction in multisig. +def executeOnMultisig(transactionId): + multisig = Contract.from_abi("MultiSig", address=contracts['bscMultisig'], abi=MultiSigWallet.abi, owner=acct) + print("=============================================================") + print("Interaction Parameters (Multisig Execution)") + print("=============================================================") + print("Transaction ID: ", transactionId) + print("=============================================================") + tx = multisig.executeTransaction(transactionId) + tx.info() diff --git a/scripts/pancakeswap/deploy_pool_user.py b/scripts/pancakeswap/deploy_pool_user.py new file mode 100644 index 000000000..60e08f36d --- /dev/null +++ b/scripts/pancakeswap/deploy_pool_user.py @@ -0,0 +1,77 @@ +from brownie import * +from brownie.network.contract import InterfaceContainer +import time +import json +import sys + +def main(): + loadConfig() + + balanceBefore = acct.balance() + # Function Call + deployPool(10e18, 500e18) + # deployPool(.1e18, 5e18) # testnet settings (mainet settings are too high for a regular faucet interaction). + balanceAfter = acct.balance() + + print("=============================================================") + print("BNB Before Balance: ", balanceBefore) + print("BNB After Balance: ", balanceAfter) + print("Gas Used: ", balanceBefore - balanceAfter) + print("=============================================================") + +def loadConfig(): + global contracts, acct + thisNetwork = network.show_active() + + # == Load config ======================================================================================================================= + if thisNetwork == "binance-testnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_testnet_contracts.json') + elif thisNetwork == "binance-mainnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_mainnet_contracts.json') + else: + raise Exception("Network not supported.") + + # Load deployed contracts addresses + contracts = json.load(configFile) + +# == PancakeSwap Pool Deployment ================================== +def deployPool(bnbAmount, bSOVAmount): + bSOV = Contract.from_abi("SOV", address = contracts['bSOV'], abi = SOV.abi, owner = acct) + pancakeRouter02 = Contract.from_abi("IPancakeRouter02", address=contracts['PancakeRouter02'], abi=interface.IPancakeRouter02.abi, owner=acct) + + # Checks if user has approved PancakeSwap for transfer. If not, will do the transfer. + checkTokenApproval(bSOV, acct, pancakeRouter02.address, bSOVAmount) + + # Creating PancakeSwap Pool + thirtyMinutes = 30 * 60 + currentTimestamp = int(time.time()) + deadline = currentTimestamp + thirtyMinutes + # https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L61 + print("=============================================================") + print("Interaction Parameters (Pool Creation)") + print("=============================================================") + print("bSOV Token: ", bSOV.address) + print("amountTokenDesired: ", bSOVAmount) + print("amountTokenMin: ", bSOVAmount) + print("amountBNBMin: ", bnbAmount) + print("to: ", acct) + print("deadline: ", deadline) + print("=============================================================") + print("Current Timestamp: ", currentTimestamp) + print("=============================================================") + tx = pancakeRouter02.addLiquidityETH(bSOV.address, bSOVAmount, bSOVAmount, bnbAmount, acct, deadline, { 'value': bnbAmount }) + tx.info() + +def checkTokenApproval(token, owner, spender, amount): + if(token.allowance(owner, spender) < amount): + # Approving token transfer. + print("=============================================================") + print("Interaction Parameters (Token Transfer Approval)") + print("=============================================================") + print("Spender Address: ", spender) + print("Amount approved: ", amount) + print("=============================================================") + tx = token.approve(spender, amount) + tx.info() diff --git a/scripts/pancakeswap/deploy_test_bSOV.py b/scripts/pancakeswap/deploy_test_bSOV.py new file mode 100644 index 000000000..b5a3a287a --- /dev/null +++ b/scripts/pancakeswap/deploy_test_bSOV.py @@ -0,0 +1,52 @@ +from brownie import * + +import json + +def main(): + loadConfig() + + balanceBefore = acct.balance() + # Function Call + deploy_bSOV() + balanceAfter = acct.balance() + + print("=============================================================") + print("BNB Before Balance: ", balanceBefore) + print("BNB After Balance: ", balanceAfter) + print("Gas Used: ", balanceBefore - balanceAfter) + print("=============================================================") + +def loadConfig(): + global contracts, acct + thisNetwork = network.show_active() + + # == Load config ============================================== + if thisNetwork == "binance-testnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_testnet_contracts.json') + elif thisNetwork == "binance-mainnet": + acct = accounts.load("rskdeployer") + configFile = open('./scripts/pancakeswap/bsc_mainnet_contracts.json') + else: + raise Exception("Network not supported.") + + # Load deployed contracts addresses + contracts = json.load(configFile) + +# == bSOV Deployment ========================================== +def deploy_bSOV(): + tokenAmount = 10**26 # 100 Million Equivalent + print("=============================================================") + print("Deployment Parameters") + print("=============================================================") + print("Token Balance: ", tokenAmount) + print("=============================================================") + + bSOVtoken = acct.deploy(SOV, tokenAmount) + tokenAmount = bSOVtoken.balanceOf(acct) + print("=============================================================") + print("Deployed Details") + print("=============================================================") + print("bSOV Address: ", bSOVtoken) + print("Token Balance: ", tokenAmount) + print("=============================================================") \ No newline at end of file