Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

view - get balance of underlying for unactivated market #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions contracts/views/EulerGeneralView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}


Expand Down
5 changes: 5 additions & 0 deletions test/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down