Skip to content

Commit

Permalink
feat(morpho-compound): fixing error in apy calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomrpl committed Jan 16, 2024
1 parent d205e87 commit 1a0bd68
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,7 @@ export abstract class MorphoBasePoolAdapter implements IMetadataBuilder {
protocolTokenAddress,
blockNumber,
})

const apy = aprToApy(apr * 86400, 365)

const apy = aprToApy(apr, 365)
return {
...(await this._fetchProtocolTokenMetadata(protocolTokenAddress)),
apyDecimal: apy * 100,
Expand Down
30 changes: 15 additions & 15 deletions src/adapters/morpho-compound-v2/tests/snapshots/ethereum.apy.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
"name": "Compound Dai",
"symbol": "cDAI",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 4.15195152770691
},
{
"address": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
"name": "Compound Collateral",
"symbol": "cCOMP",
"decimals": 8,
"apyDecimal": 3.592410643850331e+79
"apyDecimal": 0.2669651536329365
},
{
"address": "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
"name": "Compound Ether",
"symbol": "cETH",
"decimals": 8,
"apyDecimal": 489617249292756800
"apyDecimal": 0.04396289946195786
},
{
"address": "0x7713dd9ca933848f6819f38b8352d9a15ea73f67",
Expand All @@ -45,28 +45,28 @@
"name": "Compound Uniswap",
"symbol": "cUNI",
"decimals": 8,
"apyDecimal": 1.2470420805503048e+69
"apyDecimal": 0.2228585419931095
},
{
"address": "0x39aa39c021dfbae8fac545936693ac917d5e7563",
"name": "Compound USD Coin",
"symbol": "cUSDC",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 7.9227667823736025
},
{
"address": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
"name": "Compound USDT",
"symbol": "cUSDT",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 7.3123862508547965
},
{
"address": "0xccf4429db6322d5c611ee964527d42e5d685dd6a",
"name": "Compound Wrapped BTC",
"symbol": "cWBTC",
"decimals": 8,
"apyDecimal": 23457.527681591804
"apyDecimal": 0.006369534836347945
}
]
},
Expand All @@ -86,56 +86,56 @@
"name": "Compound Dai",
"symbol": "cDAI",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 6.108600469467196
},
{
"address": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
"name": "Compound Collateral",
"symbol": "cCOMP",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 5.5065423327720575
},
{
"address": "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
"name": "Compound Ether",
"symbol": "cETH",
"decimals": 8,
"apyDecimal": 3.0715944107697535e+307
"apyDecimal": 2.5106851228543503
},
{
"address": "0x7713dd9ca933848f6819f38b8352d9a15ea73f67",
"name": "Compound Fei USD",
"symbol": "cFEI",
"decimals": 8,
"apyDecimal": 7.218237310111175e+222
"apyDecimal": 1.287392196491166
},
{
"address": "0x35a18000230da775cac24873d00ff85bccded550",
"name": "Compound Uniswap",
"symbol": "cUNI",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 4.471866383292578
},
{
"address": "0x39aa39c021dfbae8fac545936693ac917d5e7563",
"name": "Compound USD Coin",
"symbol": "cUSDC",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 17.063130395873504
},
{
"address": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
"name": "Compound USDT",
"symbol": "cUSDT",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 8.477447344896394
},
{
"address": "0xccf4429db6322d5c611ee964527d42e5d685dd6a",
"name": "Compound Wrapped BTC",
"symbol": "cWBTC",
"decimals": 8,
"apyDecimal": null
"apyDecimal": 2.6009590718750975
}
]
}
Expand Down
32 changes: 16 additions & 16 deletions src/adapters/morpho-compound-v2/tests/snapshots/ethereum.tvl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"symbol": "cDAI",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "8052351927547491n",
"totalSupply": "80523519.27547491"
"totalSupplyRaw": "8052255267947755n",
"totalSupply": "80522552.67947755"
},
{
"address": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
Expand All @@ -36,8 +36,8 @@
"symbol": "cETH",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "168902893874n",
"totalSupply": "1689.02893874"
"totalSupplyRaw": "168902851072n",
"totalSupply": "1689.02851072"
},
{
"address": "0x7713dd9ca933848f6819f38b8352d9a15ea73f67",
Expand All @@ -63,17 +63,17 @@
"symbol": "cUSDC",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "1177307371464930n",
"totalSupply": "11773073.7146493"
"totalSupplyRaw": "1177277213480166n",
"totalSupply": "11772772.13480166"
},
{
"address": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
"name": "Compound USDT",
"symbol": "cUSDT",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "29710511814903157n",
"totalSupply": "297105118.14903157"
"totalSupplyRaw": "29710265186723695n",
"totalSupply": "297102651.86723695"
},
{
"address": "0xccf4429db6322d5c611ee964527d42e5d685dd6a",
Expand Down Expand Up @@ -103,8 +103,8 @@
"symbol": "cDAI",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "7201315785810239n",
"totalSupply": "72013157.85810239"
"totalSupplyRaw": "7201229341960331n",
"totalSupply": "72012293.41960331"
},
{
"address": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
Expand All @@ -121,8 +121,8 @@
"symbol": "cETH",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "117581797771n",
"totalSupply": "1175.81797771"
"totalSupplyRaw": "117581767975n",
"totalSupply": "1175.81767975"
},
{
"address": "0x7713dd9ca933848f6819f38b8352d9a15ea73f67",
Expand All @@ -148,17 +148,17 @@
"symbol": "cUSDC",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "23481197789717399n",
"totalSupply": "234811977.89717399"
"totalSupplyRaw": "23480596293776462n",
"totalSupply": "234805962.93776462"
},
{
"address": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
"name": "Compound USDT",
"symbol": "cUSDT",
"decimals": 8,
"type": "protocol",
"totalSupplyRaw": "3457279567400647n",
"totalSupply": "34572795.67400647"
"totalSupplyRaw": "3457250868380889n",
"totalSupply": "34572508.68380889"
},
{
"address": "0xccf4429db6322d5c611ee964527d42e5d685dd6a",
Expand Down
40 changes: 20 additions & 20 deletions src/core/metadata/AdapterMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import MendiFinanceBorrowLineaMendi from '../../adapters/mendi-finance/products/
import MendiFinanceSupplyLineaMendi from '../../adapters/mendi-finance/products/supply/metadata/linea.mendi.json'
import MorphoAaveV2OptimizerBorrowEthereumOptimizerBorrow from '../../adapters/morpho-aave-v2/products/optimizer-borrow/metadata/ethereum.optimizer-borrow.json'
import MorphoAaveV2OptimizerSupplyEthereumOptimizerSupply from '../../adapters/morpho-aave-v2/products/optimizer-supply/metadata/ethereum.optimizer-supply.json'
import MorphoAaveV3ETHOptimizerBorrowEthereumOptimizerBorrow from '../../adapters/morpho-aave-v3-eth/products/optimizer-borrow/metadata/ethereum.optimizer-borrow.json'
import MorphoAaveV3ETHOptimizerSupplyEthereumOptimizerSupply from '../../adapters/morpho-aave-v3-eth/products/optimizer-supply/metadata/ethereum.optimizer-supply.json'
import MorphoAaveV3ETHOptimizerOptimizerBorrowEthereumOptimizerBorrow from '../../adapters/morpho-aave-v3-eth/products/optimizer-borrow/metadata/ethereum.optimizer-borrow.json'
import MorphoAaveV3ETHOptimizerOptimizerSupplyEthereumOptimizerSupply from '../../adapters/morpho-aave-v3-eth/products/optimizer-supply/metadata/ethereum.optimizer-supply.json'
import MorphoCompoundV2OptimizerBorrowEthereumOptimizerBorrow from '../../adapters/morpho-compound-v2/products/optimizer-borrow/metadata/ethereum.optimizer-borrow.json'
import MorphoCompoundV2OptimizerSupplyEthereumOptimizerSupply from '../../adapters/morpho-compound-v2/products/optimizer-supply/metadata/ethereum.optimizer-supply.json'
import PricesUsdArbitrumProtocolToken from '../../adapters/prices/products/usd/metadata/arbitrum.protocol-token.json'
Expand Down Expand Up @@ -512,24 +512,6 @@ export const MetadataFiles = new Map<string, Json>([
}),
MorphoCompoundV2OptimizerSupplyEthereumOptimizerSupply,
],
[
metadataKey({
protocolId: Protocol.MorphoAaveV3ETHOptimizer,
productId: 'optimizer-borrow',
chainId: Chain.Ethereum,
fileKey: 'optimizer-borrow',
}),
MorphoAaveV3ETHOptimizerBorrowEthereumOptimizerBorrow,
],
[
metadataKey({
protocolId: Protocol.MorphoAaveV3ETHOptimizer,
productId: 'optimizer-supply',
chainId: Chain.Ethereum,
fileKey: 'optimizer-supply',
}),
MorphoAaveV3ETHOptimizerSupplyEthereumOptimizerSupply,
],
[
metadataKey({
protocolId: Protocol.Prices,
Expand Down Expand Up @@ -584,6 +566,24 @@ export const MetadataFiles = new Map<string, Json>([
}),
MendiFinanceBorrowLineaMendi,
],
[
metadataKey({
protocolId: Protocol.MorphoAaveV3ETHOptimizer,
productId: 'optimizer-supply',
chainId: Chain.Ethereum,
fileKey: 'optimizer-supply',
}),
MorphoAaveV3ETHOptimizerOptimizerSupplyEthereumOptimizerSupply,
],
[
metadataKey({
protocolId: Protocol.MorphoAaveV3ETHOptimizer,
productId: 'optimizer-borrow',
chainId: Chain.Ethereum,
fileKey: 'optimizer-borrow',
}),
MorphoAaveV3ETHOptimizerOptimizerBorrowEthereumOptimizerBorrow,
],
])

export function metadataKey({
Expand Down

0 comments on commit 1a0bd68

Please sign in to comment.