Skip to content

Commit

Permalink
updated pooltogether and curve compound
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolev-igor committed Mar 4, 2020
1 parent dc0d52d commit be2887c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/adapters/CurveCompoundAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface stableswap {
*/
contract CurveCompoundAdapter is Adapter {

address constant internal SS = 0x2e60CF74d81ac34eB21eEff58Db4D385920ef419;
address constant internal SS = 0xA2B47E3D5c44877cca798226B7B8118F9BFb7A56;

/**
* @return Name of the protocol.
Expand Down
6 changes: 5 additions & 1 deletion contracts/adapters/PoolTogetherAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ contract PoolTogetherAdapter is Adapter {

address internal constant SAI = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address internal constant POOL_SAI = 0xb7896fce748396EcFC240F5a0d3Cc92ca42D7d84;
address internal constant POOL_DAI = 0x29fe7D60DdF151E5b52e5FAB4f1325da6b2bD958;
address internal constant POOL_USDC = 0x0034Ea9808E620A0EF79261c51AF20614B742B24;

/**
* @return Name of the protocol.
Expand All @@ -37,14 +39,16 @@ contract PoolTogetherAdapter is Adapter {
}

/**
* @return Amount of DAI/SAI locked on the protocol by the given user.
* @return Amount of DAI/SAI/USDC locked on the protocol by the given user.
* @dev Implementation of Adapter function.
*/
function getAssetAmount(address asset, address user) external view override returns (int256) {
if (asset == DAI) {
return int256(BasePool(POOL_DAI).totalBalanceOf(user));
} else if (asset == SAI) {
return int256(BasePool(POOL_SAI).totalBalanceOf(user));
} else if (asset == USDC) {
return int256(BasePool(POOL_USDC).totalBalanceOf(user));
} else {
return int256(0);
}
Expand Down
2 changes: 1 addition & 1 deletion test/CurveCompoundAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const AdapterRegistry = artifacts.require('./AdapterRegistry');
const CurveAdapter = artifacts.require('./CurveCompoundAdapter');

contract('CurveCompoundAdapter', () => {
const ssTokenAddress = '0x3740fb63ab7a09891d7c0d4299442A551D06F5fD';
const ssTokenAddress = '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2';
const DAIAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const USDCAddress = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
const testAddress = '0x42b9dF65B219B3dD36FF330A4dD8f327A6Ada990';
Expand Down
16 changes: 14 additions & 2 deletions test/PoolTogetherAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const PoolTogetherAdapter = artifacts.require('./PoolTogetherAdapter');
contract('PoolTogetherAdapter', () => {
const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const saiAddress = '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359';
const testAddress = '0x7e5ce10826ee167de897d262fcc9976f609ecd2b';
const usdcAddress = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';

const testAddress = '0x42b9dF65B219B3dD36FF330A4dD8f327A6Ada990';
const incorrectAsset = '0x1C83501478f1320977047008496DACBD60Bb15ef';

let accounts;
Expand All @@ -20,7 +22,7 @@ contract('PoolTogetherAdapter', () => {
});
await AdapterRegistry.new(
[poolAdapter.options.address],
[[daiAddress, saiAddress]],
[[daiAddress, saiAddress, usdcAddress]],
{ from: accounts[0] },
)
.then((result) => {
Expand All @@ -37,16 +39,26 @@ contract('PoolTogetherAdapter', () => {
// eslint-disable-next-line no-console
console.log(`Deposited DAI amount: ${daiAmount}`);
assert.equal(result[0].name, 'PoolTogether');
const usdcBase = new BN(10).pow(new BN(4));
const usdcAmount = new BN(result[0].balances[2].amount).div(usdcBase) / 100;
// eslint-disable-next-line no-console
console.log(`Deposited USDC amount: ${usdcAmount}`);
assert.equal(result[0].name, 'PoolTogether');
assert.equal(result[0].balances[0].decimals, 18);
assert.equal(result[0].balances[0].asset, daiAddress);
assert.equal(result[0].balances[1].decimals, 18);
assert.equal(result[0].balances[1].asset, saiAddress);
assert.equal(result[0].balances[2].decimals, 6);
assert.equal(result[0].balances[2].asset, usdcAddress);
assert.equal(result[0].rates[0].asset, daiAddress);
assert.equal(result[0].rates[0].components[0].underlying, daiAddress);
assert.equal(result[0].rates[0].components[0].rate, 1e18);
assert.equal(result[0].rates[1].asset, saiAddress);
assert.equal(result[0].rates[1].components[0].underlying, saiAddress);
assert.equal(result[0].rates[1].components[0].rate, 1e18);
assert.equal(result[0].rates[2].asset, usdcAddress);
assert.equal(result[0].rates[2].components[0].underlying, usdcAddress);
assert.equal(result[0].rates[2].components[0].rate, 1e18);
});
});

Expand Down

0 comments on commit be2887c

Please sign in to comment.