diff --git a/contracts/views/EulerGeneralView.sol b/contracts/views/EulerGeneralView.sol index 1cf4d1fd..610c026b 100644 --- a/contracts/views/EulerGeneralView.sol +++ b/contracts/views/EulerGeneralView.sol @@ -142,6 +142,11 @@ contract EulerGeneralView is Constants { m.decimals = IERC20(m.underlying).decimals(); + if (q.account != address(0)) { + m.underlyingBalance = IERC20(m.underlying).balanceOf(q.account); + m.eulerAllowance = IERC20(m.underlying).allowance(q.account, q.eulerContract); + } + m.eTokenAddr = marketsProxy.underlyingToEToken(m.underlying); if (m.eTokenAddr == address(0)) return; // not activated @@ -170,11 +175,9 @@ contract EulerGeneralView is Constants { if (q.account == address(0)) return; - m.underlyingBalance = IERC20(m.underlying).balanceOf(q.account); m.eTokenBalance = IERC20(m.eTokenAddr).balanceOf(q.account); m.eTokenBalanceUnderlying = EToken(m.eTokenAddr).balanceOfUnderlying(q.account); m.dTokenBalance = IERC20(m.dTokenAddr).balanceOf(q.account); - m.eulerAllowance = IERC20(m.underlying).allowance(q.account, q.eulerContract); } diff --git a/test/view.js b/test/view.js index 032ba01f..bfe52b2e 100644 --- a/test/view.js +++ b/test/view.js @@ -85,9 +85,14 @@ et.testSet({ .test({ desc: "inactive market", actions: ctx => [ + { send: 'tokens.TST4.mint', args: [ctx.wallet.address, et.eth(1)], }, + { send: 'tokens.TST4.approve', args: [ctx.contracts.euler.address, et.eth(2)], }, { call: 'eulerGeneralView.doQuery', args: [{ eulerContract: ctx.contracts.euler.address, account: ctx.wallet.address, markets: [ctx.contracts.tokens.TST4.address], }], assertResult: r => { let tst4 = r.markets[2]; et.expect(tst4.symbol).to.equal('TST4'); + et.equals(tst4.underlyingBalance, et.eth(1)); + et.equals(tst4.eulerAllowance, et.eth(2)); + et.expect(tst4.eTokenAddr).to.equal(et.AddressZero) et.equals(tst4.borrowAPY, 0); et.equals(tst4.supplyAPY, 0);