Skip to content

Commit

Permalink
bugfix: handle unkn0wn assets in protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
brucedonovan committed Mar 31, 2022
1 parent ec0747f commit 8baf214
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app-v2",
"version": "2.1.11",
"version": "2.1.12",
"private": true,
"dependencies": {
"@multiavatar/multiavatar": "^1.0.6",
Expand Down
30 changes: 29 additions & 1 deletion src/config/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ASSET_INFO.set(UNKNOWN, {
name: 'UNKNOWN',
decimals: 18,
symbol: 'UNKNOWN',
showToken: true,
showToken: false,
isWrappedToken: false,
color: '#FFFFFFFF',
digitFormat: 2,
Expand Down Expand Up @@ -257,3 +257,31 @@ ASSET_INFO.set(FUSDC2206, {
tokenIdentifier: 844848939859969,
limitToSeries: ['0x303230360000']
});

// ASSET_INFO.set(FDAI2209, {
// version: '1',
// name: 'FDAI2209',
// decimals: 8,
// symbol: 'FDAI2209',
// showToken: false,
// isWrappedToken: false,
// color: '#FF007A',
// digitFormat: 6,
// tokenType: TokenType.ERC1155_,
// tokenIdentifier: 563373963149313,
// limitToSeries: ['0x303130360000']
// });

// ASSET_INFO.set(FUSDC2209, {
// version: '1',
// name: 'FUSDC2206',
// decimals: 8,
// symbol: 'FUSDC2206',
// showToken: false,
// isWrappedToken: false,
// color: '#FF007A',
// digitFormat: 6,
// tokenType: TokenType.ERC1155_,
// tokenIdentifier: 844848939859969,
// limitToSeries: ['0x303230360000']
// });
11 changes: 6 additions & 5 deletions src/contexts/ChainContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useConnection } from '../hooks/useConnection';
import yieldEnv from './yieldEnv.json';
import * as contracts from '../contracts';
import { IAssetInfo, IAssetRoot, IChainContextState, ISeriesRoot, IStrategyRoot, TokenType } from '../types';
import { ASSET_INFO, ETH_BASED_ASSETS, yvUSDC } from '../config/assets';
import { ASSET_INFO, ETH_BASED_ASSETS, UNKNOWN, yvUSDC } from '../config/assets';
import { nameFromMaturity, getSeason, SeasonType, clearCachedItems } from '../utils/appUtils';

import DaiMark from '../components/logos/DaiMark';
Expand Down Expand Up @@ -271,7 +271,7 @@ const ChainProvider = ({ children }: any) => {
setAllowance = async (spender: string) => {
console.log(spender);
console.log(asset.address);
assetContract.setApprovalForAll(spender, true );
assetContract.setApprovalForAll(spender, true);
};
break;

Expand Down Expand Up @@ -323,7 +323,9 @@ const ChainProvider = ({ children }: any) => {
const { assetId: id, asset: address } = x;

/* Get the basic hardcoded token info */
const assetInfo = ASSET_INFO.get(id) as IAssetInfo;
const assetInfo = ASSET_INFO.has(id)
? (ASSET_INFO.get(id) as IAssetInfo)
: (ASSET_INFO.get(UNKNOWN) as IAssetInfo);
let { name, symbol, decimals, version } = assetInfo;

/* On first load Checks/Corrects the ERC20 name/symbol/decimals (if possible ) */
Expand Down Expand Up @@ -356,8 +358,7 @@ const ChainProvider = ({ children }: any) => {
}
}


const idToUse = assetInfo?.wrappedTokenId || id; // here we are using the unwrapped id
const idToUse = assetInfo?.wrappedTokenId || id; // here we are using the unwrapped id

const newAsset = {
...assetInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const UserProvider = ({ children }: any) => {
try {
_accountData = await Promise.all(
_publicData.map(async (asset: IAssetRoot): Promise<IAsset> => {
const balance = asset.name !== 'UNKOWN' ? await asset.getBalance(account) : ZERO_BN;
const balance = asset.name !== 'UNKNOWN' ? await asset.getBalance(account) : ZERO_BN;
return {
...asset,
balance: balance || ethers.constants.Zero,
Expand Down

0 comments on commit 8baf214

Please sign in to comment.