|
| 1 | +const { BN } = web3.utils; |
| 2 | +const AdapterRegistry = artifacts.require('./AdapterRegistry'); |
| 3 | +const IearnAdapter = artifacts.require('./IearnAdapter'); |
| 4 | + |
| 5 | +contract('IearnAdapter', () => { |
| 6 | + const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; |
| 7 | + const yDAIAddress = '0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01'; |
| 8 | + const yUSDCAddress = '0xd6aD7a6750A7593E092a9B218d66C0A814a3436e'; |
| 9 | + const yUSDTAddress = '0x83f798e925BcD4017Eb265844FDDAbb448f1707D'; |
| 10 | + const ySUSDAddress = '0xF61718057901F84C4eEC4339EF8f0D86D2B45600'; |
| 11 | + const yTUSDAddress = '0x73a052500105205d34Daf004eAb301916DA8190f'; |
| 12 | + const yWBTCAddress = '0x04Aa51bbcB46541455cCF1B8bef2ebc5d3787EC9'; |
| 13 | + const testAddress = '0x42b9dF65B219B3dD36FF330A4dD8f327A6Ada990'; |
| 14 | + |
| 15 | + let accounts; |
| 16 | + let adapterRegistry; |
| 17 | + let iearnAdapter; |
| 18 | + |
| 19 | + beforeEach(async () => { |
| 20 | + accounts = await web3.eth.getAccounts(); |
| 21 | + await IearnAdapter.new({ from: accounts[0] }) |
| 22 | + .then((result) => { |
| 23 | + iearnAdapter = result.contract; |
| 24 | + }); |
| 25 | + await AdapterRegistry.new( |
| 26 | + [iearnAdapter.options.address], |
| 27 | + [[yDAIAddress, |
| 28 | + yUSDCAddress, |
| 29 | + yUSDTAddress, |
| 30 | + ySUSDAddress, |
| 31 | + yTUSDAddress, |
| 32 | + yWBTCAddress, |
| 33 | + ]], |
| 34 | + { from: accounts[0] }, |
| 35 | + ) |
| 36 | + .then((result) => { |
| 37 | + adapterRegistry = result.contract; |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should be correct balances and rates', async () => { |
| 42 | + await adapterRegistry.methods['getBalancesAndRates(address)'](testAddress) |
| 43 | + .call() |
| 44 | + .then((result) => { |
| 45 | + const base = new BN(10).pow(new BN(34)); |
| 46 | + const yDAIAmount = new BN(result[0].balances[0].amount); |
| 47 | + const yDAIRate = new BN(result[0].rates[0].components[0].rate); |
| 48 | + const daiAmount = yDAIRate.mul(yDAIAmount).div(base).toNumber() / 100; |
| 49 | + // eslint-disable-next-line no-console |
| 50 | + console.log(`Deposited yDAI amount: ${yDAIAmount.toString()}`); |
| 51 | + // eslint-disable-next-line no-console |
| 52 | + console.log(`yDAI rate: ${yDAIRate.toString()}`); |
| 53 | + // eslint-disable-next-line no-console |
| 54 | + console.log(`Means its: ${daiAmount} DAI locked`); |
| 55 | + // eslint-disable-next-line no-console |
| 56 | + console.log(`Deposited yUSDC amount: ${result[0].balances[1].amount.toString()}`); |
| 57 | + // eslint-disable-next-line no-console |
| 58 | + console.log(`Deposited yUSDT amount: ${result[0].balances[2].amount.toString()}`); |
| 59 | + |
| 60 | + assert.equal(result[0].balances[0].decimals, 18); |
| 61 | + assert.equal(result[0].balances[0].asset, yDAIAddress); |
| 62 | + assert.equal(result[0].rates[0].asset, yDAIAddress); |
| 63 | + assert.equal(result[0].rates[0].components[0].underlying, daiAddress); |
| 64 | + assert.equal(result[0].name, 'iearn.finance'); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
0 commit comments