Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3ccbe6a
removed lending integration and added require
ororopickpocket May 20, 2021
0665b23
updates wrapper proxy migration script
ororopickpocket May 27, 2021
8576095
Merge pull request #29 from DistributedCollective/liquidity-mining
ororopickpocket Aug 23, 2021
a0d2904
prepared addConverter script to also deploy oracle.
ororopickpocket Aug 27, 2021
4c7e6ac
prepared mainnet fish config
ororopickpocket Aug 27, 2021
b5ecddd
merged development
ororopickpocket Aug 27, 2021
4768f0a
upd/.gitignore *.code-workspace
tjcloa Aug 27, 2021
ceb95b0
fix/addConverter.js & upd addFish configs
tjcloa Aug 27, 2021
0dcf1fb
Merge branch 'fish-token' of https://github.com/DistributedCollective…
ororopickpocket Aug 27, 2021
ef19d51
changed add converter script to work with truffle build files
ororopickpocket Aug 27, 2021
04475a9
mend
ororopickpocket Aug 27, 2021
a79851b
upd/added multisig wallet to data files
tjcloa Aug 30, 2021
4418613
upd/replaced mainnet to mainnet2 URL for RPC calls
tjcloa Aug 30, 2021
a5637b2
fix/hh config formatting
tjcloa Aug 30, 2021
f48fedf
fix/multisig wallet, TODOs added to process Oracle
tjcloa Aug 30, 2021
afacba7
upd/fish token cionfigs updates by deployment
tjcloa Aug 30, 2021
6c92f18
enh/added TODO to transfer ownership to multisig
tjcloa Aug 30, 2021
fedb46a
added a newline as separator
tjcloa Nov 25, 2021
efe5afc
add BZX testnet config
tjcloa Nov 25, 2021
392c3f3
removed legacy interim non-working addConverter
tjcloa Nov 25, 2021
52f48f8
add deployment script for non-wRBTC based converters
tjcloa Nov 25, 2021
7326baa
fixed token symbol
tjcloa Nov 25, 2021
1aa1fd1
fixed BRZ decimals
tjcloa Nov 25, 2021
43c713a
added funding amounts for the testnet
tjcloa Nov 29, 2021
42c2da8
added XUSD/BRZ converter & manual updated
tjcloa Nov 30, 2021
929fca7
fix wss://testnet.sovryn.app/ws URI
tjcloa May 13, 2022
695f173
update XUSD address in XUSD/BRZ converter config
tjcloa May 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ solidity/build/Test*
/rbtcwrapperproxy/private-key
/rbtcwrapperproxy/build

workspace.code-workspace
*.code-workspace
.env
yarn.lock

Expand Down
37 changes: 30 additions & 7 deletions ADD-POOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,47 @@ The configuration file is updated during the process, in order to allow resuming

### Adding LM pools to the testnet and mainnet (only needed if contracts' abi were changed)

1. Before adding pools we need to make sure having updated comipled contracts in [./solidity/build](./solidity/build)
- Change contract folder in script Compile contracts `../../scripts/compile.sh`
- Run from root dir `./scripts/compile.sh`
2. Top up RBTC and WRBTC account with some RBTC to pay for tx and **WRBTC** amount for initial deposit (0.01 usually)
1. Use ```yarn install``` or ```npm install``` from the root to install node modules
2. Before adding pools we need to make sure having updated compiled contracts in [./solidity/build/contracts](./solidity/build/contracts)
- Run from root dir ```truffle compile```
3. Top up deploying account with RBTC to pay tx fees and pair tokens for initial deposit if it is not zero - at least `balance` amounts in config file, e.g. 18 XUSD and 100 BRZ:
```js
"reserves": [
{
"symbol": "XUSD",
"weight": "50%",
"balance": "18"
},
{
"symbol": "BRZ",
"weight": "50%",
"balance": "100"
}
],
"k": 6779,
"btcAddress": "0x69FE5cEC81D5eF92600c1A0dB1F11986AB3758Ab",
```
* For WRBTC-paired tokens **WRBTC** amount for initial deposit is usually 0.01

To add converters to an existing swap network, use ```addConverter.js```.
To add converters to an existing swap network, use ```addConverter.js``` or ```addConverterNoOracle.js```.

Example creation v1 pool WRBTC/ETH

Note: `data_testnet.json` and `data_mainnet.json` store contracts addresses participating in converter creation.

testnet:

```node addConverter.js ETH addETHs_testnet.json data_testnet.json https://public-node.testnet.rsk.co <private key>```
```node addConverter.js ETH addETHs_testnet.json data_testnet.json https://public-node.testnet.rsk.co <private key>```

for pairs with no WRBTC (with no internal oracle):

```node addConverterNoOracle.js BRZ addBRZ_testnet.json data_testnet.json https://public-node.testnet.rsk.co <private key>```

mainnet:

```node addConverter.js ETH addETHs_mainnet.json data_mainnet.json https://mainnet.sovryn.app/rpc <private key>```
```node addConverter.js ETH addETHs_mainnet.json data_mainnet.json https://mainnet2.sovryn.app/rpc <private key>```
or respectively
```node addConverterNoOracle.js BRZ addBRZ_testnet.json data_testnet.json https://public-node.testnet.rsk.co <private key>```

```TODO: check if the following is for v2 pools only```

Expand Down
128 changes: 64 additions & 64 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ require("@nomiclabs/hardhat-web3");
require("hardhat-contract-sizer"); //yarn run hardhat size-contracts
require("solidity-coverage"); // $ npx hardhat coverage
require("hardhat-log-remover");
require('hardhat-docgen');
require("hardhat-docgen");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
/// this is for use with ethers.js
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
const accounts = await ethers.getSigners();

for (const account of accounts.address) {
const wallet = ethers.Wallet.fromMnemonic("test test test test test test test test test test test junk", "m/44'/60'/0'/0");
for (const account of accounts.address) {
const wallet = ethers.Wallet.fromMnemonic("test test test test test test test test test test test junk", "m/44'/60'/0'/0");

console.log(account);
}
console.log(account);
}
});

/*task("accounts", "Prints accounts", async (_, { web3 }) => {
Expand All @@ -36,61 +36,61 @@ task("accounts", "Prints the list of accounts", async () => {
/**/

module.exports = {
solidity: {
version: "0.4.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
contractSizer: {
alphaSort: false,
runOnCompile: false,
disambiguatePaths: false,
},
networks: {
hardhat: {},
rskPublicTestnet: {
url: "https://public-node.testnet.rsk.co/",
accounts: { mnemonic: "brownie", count: 10 },
network_id: 31,
confirmations: 4,
gasMultiplier: 1.25,
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskPublicMainnet: {
url: "https://public-node.rsk.co/",
network_id: 30,
//timeout: 20000, // increase if needed; 20000 is the default value
},
rskSovrynTestnet: {
url: "https://testnet.sovryn.app/rpc",
accounts: { mnemonic: "brownie", count: 10 },
network_id: 31,
confirmations: 4,
gasMultiplier: 1.25,
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskSovrynMainnet: {
url: "https://mainnet.sovryn.app/rpc",
network_id: 30,
//timeout: 20000, // increase if needed; 20000 is the default value
},
},
paths: {
sources: "./solidity/contracts",
tests: "./solidity/test/",
},
mocha: {
timeout: 800000,
grep: "^(?!.*; using Ganache).*",
},
docgen: {
path: './docs',
clear: true
}
};
solidity: {
version: "0.4.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
contractSizer: {
alphaSort: false,
runOnCompile: false,
disambiguatePaths: false,
},
networks: {
hardhat: {},
rskPublicTestnet: {
url: "https://public-node.testnet.rsk.co/",
accounts: { mnemonic: "brownie", count: 10 },
network_id: 31,
confirmations: 4,
gasMultiplier: 1.25,
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskPublicMainnet: {
url: "https://public-node.rsk.co/",
network_id: 30,
//timeout: 20000, // increase if needed; 20000 is the default value
},
rskSovrynTestnet: {
url: "https://testnet.sovryn.app/rpc",
accounts: { mnemonic: "brownie", count: 10 },
network_id: 31,
confirmations: 4,
gasMultiplier: 1.25,
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskSovrynMainnet: {
url: "https://mainnet2.sovryn.app/rpc",
network_id: 30,
//timeout: 20000, // increase if needed; 20000 is the default value
},
},
paths: {
sources: "./solidity/contracts",
tests: "./solidity/test/",
},
mocha: {
timeout: 800000,
grep: "^(?!.*; using Ganache).*",
},
docgen: {
path: "./docs",
clear: true,
},
};
45 changes: 1 addition & 44 deletions rbtcwrapperproxy/contracts/RBTCWrapperProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import "./interfaces/ISovrynSwapFormula.sol";
import "./interfaces/IContractRegistry.sol";
import "./ContractRegistryClient.sol";
import "./mockups/LiquidityMining.sol";
import "./interfaces/ILoanToken.sol";

contract RBTCWrapperProxy is ContractRegistryClient {

Expand Down Expand Up @@ -181,7 +180,7 @@ contract RBTCWrapperProxy is ContractRegistryClient {
IWrbtcERC20(wrbtcTokenAddress).deposit.value(_amount)();
}
else{
reserveToken.transferFrom(msg.sender, address(this), _amount);
require(reserveToken.transferFrom(msg.sender, address(this), _amount));
}

require(reserveToken.approve(_liquidityPoolConverterAddress, _amount), "token approval failed");
Expand Down Expand Up @@ -455,46 +454,4 @@ contract RBTCWrapperProxy is ContractRegistryClient {
}
}

/**
* @notice provides funds to a lending pool and deposits the pool tokens into the liquidity mining contract.
* @param loanTokenAddress the address of the loan token (aka lending pool)
* @param depositAmount he amount of underlying tokens to deposit
*/
function addToLendingPool(address loanTokenAddress, uint256 depositAmount) public{
LoanToken loanToken = LoanToken(loanTokenAddress);
IERC20Token underlyingAsset = IERC20Token(loanToken.loanTokenAddress());

//retrieve the underlying asset from the user
require(underlyingAsset.transferFrom(msg.sender, address(this), depositAmount), "Failed to transfer tokens to the wrapper proxy");

//add the tokens to the lending pool
underlyingAsset.approve(loanTokenAddress, depositAmount);
uint256 minted = loanToken.mint(address(this), depositAmount);

//deposit the pool tokens in the liquidity mining contract on the sender's behalf
loanToken.approve(address(liquidityMiningContract), minted);
liquidityMiningContract.deposit(loanTokenAddress, minted, msg.sender);

emit LoanTokensMinted(msg.sender, minted, depositAmount);
}

/**
* @notice removes funds from the liquidity mining contract, burns them on the lending pool and
* provides the underlying asset to the user
* @param loanTokenAddress the address of the loan token (aka lending pool)
* @param burnAmount the amount of pool tokens to withdraw from the lending pool and burn
*/
function removeFromLendingPool(address loanTokenAddress, uint256 burnAmount) public{
LoanToken loanToken = LoanToken(loanTokenAddress);

//withdraw always transfers the pool tokens to the caller and the reward tokens to the passed address
liquidityMiningContract.withdraw(loanTokenAddress, burnAmount, msg.sender);

//burn pool token and directly send underlying tokens to the receiver
loanToken.approve(address(liquidityMiningContract), burnAmount);
uint256 redeemed = loanToken.burn(msg.sender, burnAmount);

emit LoanTokensBurnt(msg.sender, burnAmount, redeemed);
}

}
28 changes: 0 additions & 28 deletions rbtcwrapperproxy/contracts/interfaces/ILoanToken.sol

This file was deleted.

Loading