Skip to content

Commit

Permalink
fix(metamorpho): explicit cast
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-devatom committed Jan 27, 2024
1 parent 61d6e28 commit 017e7cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/meta-morpho.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function handleAccrueInterest(event: AccrueInterestEvent): void {
mm.totalShares,
// This is taking the last total assets, not the current one
mm.lastTotalAssets,
token.getDecimals()
token.getDecimals() as u8
);
mm.feeAccruedAssets = mm.feeAccruedAssets.plus(feeAssets);
mm.save();
Expand Down Expand Up @@ -654,7 +654,7 @@ export function handleTransfer(event: TransferEvent): void {
fromPosition.shares,
mm.totalShares,
mm.lastTotalAssets,
token.getDecimals()
token.getDecimals() as u8
);
fromPosition.lastAssetsBalance = fromAssets;
fromPosition.lastAssetsBalanceUSD = token.getAmountUSD(fromAssets);
Expand Down Expand Up @@ -723,7 +723,7 @@ export function handleWithdraw(event: WithdrawEvent): void {
position.shares,
mm.totalShares,
mm.lastTotalAssets,
asset.getDecimals()
asset.getDecimals() as u8
);
position.lastAssetsBalance = totalAssets;
position.lastAssetsBalanceUSD = asset.getAmountUSD(totalAssets);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/metaMorphoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export function toMetaMorphoAssetsUp(
shares: BigInt,
totalShares: BigInt,
totalAssets: BigInt,
underlyingDecimals: i32
underlyingDecimals: u8
): BigInt {
const sharesOffset = underlyingDecimals > 18 ? 0 : 18 - underlyingDecimals;
return shares
.times(totalAssets.plus(BigInt.fromString("1")))
.div(totalShares.plus(BigInt.fromString("10").pow(sharesOffset)));
.div(totalShares.plus(BigInt.fromString("10").pow(sharesOffset as u8)));
}

0 comments on commit 017e7cf

Please sign in to comment.