From 2eb924daf810ba4025daff31e014e51aec9e5656 Mon Sep 17 00:00:00 2001 From: Bob Lu Date: Tue, 18 Jun 2024 15:53:57 +0800 Subject: [PATCH] fix: token configs of compound v3 and morphoblue --- .changeset/hungry-wombats-study.md | 5 + src/logics/compound-v3/configs.ts | 75 ++++------- src/logics/compound-v3/logic.borrow.test.ts | 2 +- src/logics/compound-v3/logic.borrow.ts | 2 +- src/logics/compound-v3/logic.claim.ts | 4 +- src/logics/compound-v3/logic.repay.test.ts | 2 +- src/logics/compound-v3/logic.repay.ts | 2 +- .../compound-v3/logic.supply-base.test.ts | 2 +- src/logics/compound-v3/logic.supply-base.ts | 2 +- .../logic.supply-collateral.test.ts | 2 +- .../compound-v3/logic.supply-collateral.ts | 2 +- .../compound-v3/logic.withdraw-base.test.ts | 2 +- src/logics/compound-v3/logic.withdraw-base.ts | 2 +- .../logic.withdraw-collateral.test.ts | 2 +- .../compound-v3/logic.withdraw-collateral.ts | 2 +- src/logics/compound-v3/service.ts | 26 ++-- .../compound-v3/tokens/data/arbitrum.json | 27 +++- src/logics/compound-v3/tokens/data/base.json | 65 ++++++++++ .../compound-v3/tokens/data/optimism.json | 51 ++++++++ .../compound-v3/tokens/data/polygon.json | 11 +- src/logics/compound-v3/tokens/index.ts | 15 +++ src/logics/morphoblue/configs.ts | 120 +++++++++--------- src/logics/morphoblue/logic.borrow.ts | 4 +- src/logics/morphoblue/logic.flash-loan.ts | 4 +- src/logics/morphoblue/logic.repay.ts | 4 +- .../morphoblue/logic.supply-collateral.ts | 4 +- src/logics/morphoblue/logic.supply.ts | 4 +- .../morphoblue/logic.withdraw-collateral.ts | 4 +- src/logics/morphoblue/logic.withdraw.ts | 4 +- src/logics/morphoblue/service.ts | 4 +- test/logics/compound-v3/helpers.ts | 6 +- test/logics/morphoblue/helpers.ts | 14 +- 32 files changed, 308 insertions(+), 167 deletions(-) create mode 100644 .changeset/hungry-wombats-study.md create mode 100644 src/logics/compound-v3/tokens/data/base.json create mode 100644 src/logics/compound-v3/tokens/data/optimism.json diff --git a/.changeset/hungry-wombats-study.md b/.changeset/hungry-wombats-study.md new file mode 100644 index 00000000..99b797ca --- /dev/null +++ b/.changeset/hungry-wombats-study.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': patch +--- + +fix token configs of compound v3 and morphoblue diff --git a/src/logics/compound-v3/configs.ts b/src/logics/compound-v3/configs.ts index d171f1de..95f47d95 100644 --- a/src/logics/compound-v3/configs.ts +++ b/src/logics/compound-v3/configs.ts @@ -1,3 +1,4 @@ +import { arbitrumTokens, baseTokens, mainnetTokens, optimismTokens, polygonTokens } from './tokens'; import * as common from '@protocolink/common'; type ContractNames = 'CometRewards'; @@ -11,8 +12,8 @@ export enum MarketId { export interface MarketConfig { id: string; - cometAddress: string; - baseTokenAddress: string; + comet: common.Token; + baseToken: common.Token; } export interface Config { @@ -31,22 +32,16 @@ export const configs: Config[] = [ markets: [ { id: MarketId.USDC, - cometAddress: '0xc3d688B66703497DAA19211EEdff47f25384cdc3', - baseTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + comet: mainnetTokens.cUSDCv3, + baseToken: mainnetTokens.USDC, }, { id: MarketId.ETH, - cometAddress: '0xA17581A9E3356d9A858b789D68B4d866e593aE94', - baseTokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + comet: mainnetTokens.cWETHv3, + baseToken: mainnetTokens.WETH, }, ], - COMP: new common.Token( - common.ChainId.mainnet, - '0xc00e94Cb662C3520282E6f5717214004A7f26888', - 18, - 'COMP', - 'Compound' - ), + COMP: mainnetTokens.COMP, }, { chainId: common.ChainId.optimism, @@ -56,17 +51,11 @@ export const configs: Config[] = [ markets: [ { id: MarketId.USDC, - cometAddress: '0x2e44e174f7D53F0212823acC11C01A11d58c5bCB', - baseTokenAddress: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', + comet: optimismTokens.cUSDCv3, + baseToken: optimismTokens.USDC, }, ], - COMP: new common.Token( - common.ChainId.optimism, - '0x7e7d4467112689329f7E06571eD0E8CbAd4910eE', - 18, - 'COMP', - 'Compound' - ), + COMP: optimismTokens.COMP, }, { chainId: common.ChainId.polygon, @@ -76,17 +65,11 @@ export const configs: Config[] = [ markets: [ { id: MarketId.USDCe, - cometAddress: '0xF25212E676D1F7F89Cd72fFEe66158f541246445', - baseTokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', + comet: polygonTokens.cUSDCv3, + baseToken: polygonTokens['USDC.e'], }, ], - COMP: new common.Token( - common.ChainId.polygon, - '0x8505b9d2254A7Ae468c0E9dd10Ccea3A837aef5c', - 18, - 'COMP', - '(PoS) Compound' - ), + COMP: polygonTokens.COMP, }, { chainId: common.ChainId.base, @@ -96,21 +79,21 @@ export const configs: Config[] = [ markets: [ { id: MarketId.USDC, - cometAddress: '0xb125E6687d4313864e53df431d5425969c15Eb2F', - baseTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', + comet: baseTokens.cUSDCv3, + baseToken: baseTokens.USDC, }, { id: MarketId.USDbC, - cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', - baseTokenAddress: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', + comet: baseTokens.cUSDbCv3, + baseToken: baseTokens.USDbC, }, { id: MarketId.ETH, - cometAddress: '0x46e6b214b524310239732D51387075E0e70970bf', - baseTokenAddress: '0x4200000000000000000000000000000000000006', + comet: baseTokens.cWETHv3, + baseToken: baseTokens.WETH, }, ], - COMP: new common.Token(common.ChainId.base, '0x9e1028F5F1D5eDE59748FFceE5532509976840E0', 18, 'COMP', 'Compound'), + COMP: baseTokens.COMP, }, { chainId: common.ChainId.arbitrum, @@ -120,22 +103,16 @@ export const configs: Config[] = [ markets: [ { id: MarketId.USDCe, - cometAddress: '0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA', - baseTokenAddress: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', + comet: arbitrumTokens.cUSDCev3, + baseToken: arbitrumTokens['USDC.e'], }, { id: MarketId.USDC, - cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', - baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + comet: arbitrumTokens.cUSDCv3, + baseToken: arbitrumTokens.USDC, }, ], - COMP: new common.Token( - common.ChainId.arbitrum, - '0x354A6dA3fcde098F8389cad84b0182725c6C91dE', - 18, - 'COMP', - 'Compound' - ), + COMP: arbitrumTokens.COMP, }, ]; diff --git a/src/logics/compound-v3/logic.borrow.test.ts b/src/logics/compound-v3/logic.borrow.test.ts index 12acd753..d48fc816 100644 --- a/src/logics/compound-v3/logic.borrow.test.ts +++ b/src/logics/compound-v3/logic.borrow.test.ts @@ -42,7 +42,7 @@ describe('CompoundV3 BorrowLogic', function () { const { marketId, output } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('withdrawFrom')); expect(routerLogic.inputs).to.deep.eq([]); diff --git a/src/logics/compound-v3/logic.borrow.ts b/src/logics/compound-v3/logic.borrow.ts index 0739062f..68430dfd 100644 --- a/src/logics/compound-v3/logic.borrow.ts +++ b/src/logics/compound-v3/logic.borrow.ts @@ -40,7 +40,7 @@ export class BorrowLogic extends core.Logic implements core.LogicTokenListInterf const tokenOut = output.token.wrapped; const agent = await this.calcAgent(account); - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('withdrawFrom', [ account, agent, diff --git a/src/logics/compound-v3/logic.claim.ts b/src/logics/compound-v3/logic.claim.ts index 417758c8..875ad9ab 100644 --- a/src/logics/compound-v3/logic.claim.ts +++ b/src/logics/compound-v3/logic.claim.ts @@ -45,13 +45,13 @@ export class ClaimLogic if (owner === account) { const agent = await this.calcAgent(account); data = CometRewards__factory.createInterface().encodeFunctionData('claimTo', [ - market.cometAddress, + market.comet.address, owner, agent, true, ]); } else { - data = CometRewards__factory.createInterface().encodeFunctionData('claim', [market.cometAddress, owner, true]); + data = CometRewards__factory.createInterface().encodeFunctionData('claim', [market.comet.address, owner, true]); } return core.newLogic({ to, data }); diff --git a/src/logics/compound-v3/logic.repay.test.ts b/src/logics/compound-v3/logic.repay.test.ts index a2af20f8..0807a939 100644 --- a/src/logics/compound-v3/logic.repay.test.ts +++ b/src/logics/compound-v3/logic.repay.test.ts @@ -67,7 +67,7 @@ describe('CompoundV3 RepayLogic', function () { const { marketId, input, balanceBps } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('supplyTo')); expect(routerLogic.inputs[0].token).to.eq(input.token.wrapped.address); diff --git a/src/logics/compound-v3/logic.repay.ts b/src/logics/compound-v3/logic.repay.ts index b893e6ca..ceaeeb43 100644 --- a/src/logics/compound-v3/logic.repay.ts +++ b/src/logics/compound-v3/logic.repay.ts @@ -54,7 +54,7 @@ export class RepayLogic extends core.Logic implements core.LogicTokenListInterfa const borrowBalance = await service.getBorrowBalance(marketId, borrower, tokenIn); const repayAll = input.gte(borrowBalance); - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('supplyTo', [ borrower, tokenIn.address, diff --git a/src/logics/compound-v3/logic.supply-base.test.ts b/src/logics/compound-v3/logic.supply-base.test.ts index 6963c2c4..6881c2a9 100644 --- a/src/logics/compound-v3/logic.supply-base.test.ts +++ b/src/logics/compound-v3/logic.supply-base.test.ts @@ -88,7 +88,7 @@ describe('CompoundV3 SupplyBaseLogic', function () { const { marketId, input, balanceBps } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('supply')); expect(routerLogic.inputs[0].token).to.eq(input.token.wrapped.address); diff --git a/src/logics/compound-v3/logic.supply-base.ts b/src/logics/compound-v3/logic.supply-base.ts index 17003252..61c7fb41 100644 --- a/src/logics/compound-v3/logic.supply-base.ts +++ b/src/logics/compound-v3/logic.supply-base.ts @@ -48,7 +48,7 @@ export class SupplyBaseLogic const market = getMarket(this.chainId, marketId); const tokenIn = input.token.wrapped; - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('supply', [tokenIn.address, input.amountWei]); const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; const inputs = [ diff --git a/src/logics/compound-v3/logic.supply-collateral.test.ts b/src/logics/compound-v3/logic.supply-collateral.test.ts index aec2ec9e..72cc4c98 100644 --- a/src/logics/compound-v3/logic.supply-collateral.test.ts +++ b/src/logics/compound-v3/logic.supply-collateral.test.ts @@ -70,7 +70,7 @@ describe('CompoundV3 SupplyCollateralLogic', function () { const { marketId, input, balanceBps } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('supplyTo')); expect(routerLogic.inputs[0].token).to.eq(input.token.wrapped.address); diff --git a/src/logics/compound-v3/logic.supply-collateral.ts b/src/logics/compound-v3/logic.supply-collateral.ts index 91f5fae7..e00411c3 100644 --- a/src/logics/compound-v3/logic.supply-collateral.ts +++ b/src/logics/compound-v3/logic.supply-collateral.ts @@ -38,7 +38,7 @@ export class SupplyCollateralLogic const market = getMarket(this.chainId, marketId); const tokenIn = input.token.wrapped; - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('supplyTo', [ account, tokenIn.address, diff --git a/src/logics/compound-v3/logic.withdraw-base.test.ts b/src/logics/compound-v3/logic.withdraw-base.test.ts index 09c06f51..92e7e520 100644 --- a/src/logics/compound-v3/logic.withdraw-base.test.ts +++ b/src/logics/compound-v3/logic.withdraw-base.test.ts @@ -87,7 +87,7 @@ describe('CompoundV3 WithdrawBaseLogic', function () { const { marketId, input, output, balanceBps } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('withdraw')); if (balanceBps) { diff --git a/src/logics/compound-v3/logic.withdraw-base.ts b/src/logics/compound-v3/logic.withdraw-base.ts index 02125969..d3e25646 100644 --- a/src/logics/compound-v3/logic.withdraw-base.ts +++ b/src/logics/compound-v3/logic.withdraw-base.ts @@ -50,7 +50,7 @@ export class WithdrawBaseLogic const market = getMarket(this.chainId, marketId); const tokenOut = output.token.wrapped; - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('withdraw', [tokenOut.address, input.amountWei]); const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; diff --git a/src/logics/compound-v3/logic.withdraw-collateral.test.ts b/src/logics/compound-v3/logic.withdraw-collateral.test.ts index 1efe9a6a..976a79fd 100644 --- a/src/logics/compound-v3/logic.withdraw-collateral.test.ts +++ b/src/logics/compound-v3/logic.withdraw-collateral.test.ts @@ -43,7 +43,7 @@ describe('CompoundV3 WithdrawCollateralLogic', function () { const { marketId, output } = fields; const market = getMarket(chainId, marketId); - expect(routerLogic.to).to.eq(market.cometAddress); + expect(routerLogic.to).to.eq(market.comet.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; expect(sig).to.eq(iface.getSighash('withdrawFrom')); expect(routerLogic.inputs).to.deep.eq([]); diff --git a/src/logics/compound-v3/logic.withdraw-collateral.ts b/src/logics/compound-v3/logic.withdraw-collateral.ts index ee4f353b..697f7d15 100644 --- a/src/logics/compound-v3/logic.withdraw-collateral.ts +++ b/src/logics/compound-v3/logic.withdraw-collateral.ts @@ -39,7 +39,7 @@ export class WithdrawCollateralLogic const tokenOut = output.token.wrapped; const agent = await this.calcAgent(account); - const to = market.cometAddress; + const to = market.comet.address; const data = Comet__factory.createInterface().encodeFunctionData('withdrawFrom', [ account, agent, diff --git a/src/logics/compound-v3/service.ts b/src/logics/compound-v3/service.ts index 23a66e48..6c7b2b2e 100644 --- a/src/logics/compound-v3/service.ts +++ b/src/logics/compound-v3/service.ts @@ -5,33 +5,33 @@ import * as common from '@protocolink/common'; export class Service extends common.Web3Toolkit { async getCToken(marketId: string) { const market = getMarket(this.chainId, marketId); - const cToken = await this.getToken(market.cometAddress); + const cToken = await this.getToken(market.comet.address); return cToken; } async getBaseToken(marketId: string) { const market = getMarket(this.chainId, marketId); - const baseToken = await this.getToken(market.baseTokenAddress); + const baseToken = await this.getToken(market.baseToken.address); return baseToken; } async getCometTokens(marketId: string) { const market = getMarket(this.chainId, marketId); - const tokens = await this.getTokens([market.cometAddress, market.baseTokenAddress]); + const tokens = await this.getTokens([market.comet.address, market.baseToken.address]); return { cToken: tokens[0], baseToken: tokens[1] }; } async getCollaterals(marketId: string) { const market = getMarket(this.chainId, marketId); - const numAssets = await Comet__factory.connect(market.cometAddress, this.provider).numAssets(); + const numAssets = await Comet__factory.connect(market.comet.address, this.provider).numAssets(); const iface = Comet__factory.createInterface(); const calls: common.Multicall3.CallStruct[] = []; for (let i = 0; i < numAssets; i++) { - calls.push({ target: market.cometAddress, callData: iface.encodeFunctionData('getAssetInfo', [i]) }); + calls.push({ target: market.comet.address, callData: iface.encodeFunctionData('getAssetInfo', [i]) }); } const { returnData } = await this.multicall3.callStatic.aggregate(calls); @@ -50,14 +50,14 @@ export class Service extends common.Web3Toolkit { async isAllowed(marketId: string, owner: string, manager: string) { const market = getMarket(this.chainId, marketId); - const isAllowed = await Comet__factory.connect(market.cometAddress, this.provider).isAllowed(owner, manager); + const isAllowed = await Comet__factory.connect(market.comet.address, this.provider).isAllowed(owner, manager); return isAllowed; } buildAllowTransactionRequest(marketId: string, manager: string, isAllowed: boolean): common.TransactionRequest { const market = getMarket(this.chainId, marketId); - const to = market.cometAddress; + const to = market.comet.address; const iface = Comet__factory.createInterface(); const data = iface.encodeFunctionData('allow', [manager, isAllowed]); @@ -66,7 +66,7 @@ export class Service extends common.Web3Toolkit { async getCollateralBalance(marketId: string, account: string, asset: common.Token) { const market = getMarket(this.chainId, marketId); - const collateralBalance = await Comet__factory.connect(market.cometAddress, this.provider).collateralBalanceOf( + const collateralBalance = await Comet__factory.connect(market.comet.address, this.provider).collateralBalanceOf( account, asset.wrapped.address ); @@ -79,7 +79,7 @@ export class Service extends common.Web3Toolkit { if (!baseToken) { baseToken = await this.getBaseToken(market.id); } - const borrowBalance = await Comet__factory.connect(market.cometAddress, this.provider).borrowBalanceOf(borrower); + const borrowBalance = await Comet__factory.connect(market.comet.address, this.provider).borrowBalanceOf(borrower); return new common.TokenAmount(baseToken).setWei(borrowBalance); } @@ -89,7 +89,7 @@ export class Service extends common.Web3Toolkit { if (!baseToken) { baseToken = await this.getBaseToken(market.id); } - const userBasic = await Comet__factory.connect(market.cometAddress, this.provider).userBasic(account); + const userBasic = await Comet__factory.connect(market.comet.address, this.provider).userBasic(account); return new common.TokenAmount(baseToken).setWei(userBasic.principal); } @@ -99,7 +99,7 @@ export class Service extends common.Web3Toolkit { const { owed } = await CometRewards__factory.connect( getContractAddress(this.chainId, 'CometRewards'), this.provider - ).callStatic.getRewardOwed(market.cometAddress, owner); + ).callStatic.getRewardOwed(market.comet.address, owner); return new common.TokenAmount(COMP(this.chainId)).setWei(owed); } @@ -111,11 +111,11 @@ export class Service extends common.Web3Toolkit { const iface = Comet__factory.createInterface(); const calls: common.Multicall3.CallStruct[] = [ { - target: market.cometAddress, + target: market.comet.address, callData: iface.encodeFunctionData('getAssetInfoByAddress', [asset]), }, { - target: market.cometAddress, + target: market.comet.address, callData: iface.encodeFunctionData('totalsCollateral', [asset]), }, ]; diff --git a/src/logics/compound-v3/tokens/data/arbitrum.json b/src/logics/compound-v3/tokens/data/arbitrum.json index df9226d2..fadf4147 100644 --- a/src/logics/compound-v3/tokens/data/arbitrum.json +++ b/src/logics/compound-v3/tokens/data/arbitrum.json @@ -1,17 +1,38 @@ { + "COMP": { + "chainId": 42161, + "address": "0x354A6dA3fcde098F8389cad84b0182725c6C91dE", + "decimals": 18, + "symbol": "COMP", + "name": "Compound" + }, "cUSDCv3": { "chainId": 42161, - "address": "0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA", + "address": "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf", "decimals": 6, "symbol": "cUSDCv3", "name": "Compound USDC" }, "USDC": { "chainId": 42161, - "address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", + "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "decimals": 6, "symbol": "USDC", - "name": "USD Coin (Arb1)" + "name": "USD Coin" + }, + "cUSDCev3": { + "chainId": 42161, + "address": "0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA", + "decimals": 6, + "symbol": "cUSDCev3", + "name": "Compound USDCe" + }, + "USDC.e": { + "chainId": 42161, + "address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", + "decimals": 6, + "symbol": "USDC.e", + "name": "Bridged USDC" }, "ARB": { "chainId": 42161, diff --git a/src/logics/compound-v3/tokens/data/base.json b/src/logics/compound-v3/tokens/data/base.json new file mode 100644 index 00000000..ca49da98 --- /dev/null +++ b/src/logics/compound-v3/tokens/data/base.json @@ -0,0 +1,65 @@ +{ + "COMP": { + "chainId": 8453, + "address": "0x9e1028F5F1D5eDE59748FFceE5532509976840E0", + "decimals": 18, + "symbol": "COMP", + "name": "Compound" + }, + "cUSDCv3": { + "chainId": 8453, + "address": "0xb125E6687d4313864e53df431d5425969c15Eb2F", + "decimals": 6, + "symbol": "cUSDCv3", + "name": "Compound USDC" + }, + "USDC": { + "chainId": 8453, + "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + "decimals": 6, + "symbol": "USDC", + "name": "USD Coin" + }, + "cbETH": { + "chainId": 8453, + "address": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", + "decimals": 18, + "symbol": "cbETH", + "name": "Coinbase Wrapped Staked ETH" + }, + "ETH": { + "chainId": 8453, + "address": "0x0000000000000000000000000000000000000000", + "decimals": 18, + "symbol": "ETH", + "name": "Ethereum" + }, + "WETH": { + "chainId": 8453, + "address": "0x4200000000000000000000000000000000000006", + "decimals": 18, + "symbol": "WETH", + "name": "Wrapped Ether" + }, + "cUSDbCv3": { + "chainId": 8453, + "address": "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf", + "decimals": 6, + "symbol": "cUSDbCv3", + "name": "Compound USDbC" + }, + "USDbC": { + "chainId": 8453, + "address": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", + "decimals": 6, + "symbol": "USDbC", + "name": "USD Base Coin" + }, + "cWETHv3": { + "chainId": 8453, + "address": "0x46e6b214b524310239732D51387075E0e70970bf", + "decimals": 18, + "symbol": "cWETHv3", + "name": "Compound WETH" + } +} diff --git a/src/logics/compound-v3/tokens/data/optimism.json b/src/logics/compound-v3/tokens/data/optimism.json new file mode 100644 index 00000000..0cdfd634 --- /dev/null +++ b/src/logics/compound-v3/tokens/data/optimism.json @@ -0,0 +1,51 @@ +{ + "COMP": { + "chainId": 10, + "address": "0x7e7d4467112689329f7E06571eD0E8CbAd4910eE", + "decimals": 18, + "symbol": "COMP", + "name": "Compound" + }, + "cUSDCv3": { + "chainId": 10, + "address": "0x2e44e174f7D53F0212823acC11C01A11d58c5bCB", + "decimals": 6, + "symbol": "cUSDCv3", + "name": "Compound USDC" + }, + "USDC": { + "chainId": 10, + "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", + "decimals": 6, + "symbol": "USDC", + "name": "USD Coin" + }, + "OP": { + "chainId": 10, + "address": "0x4200000000000000000000000000000000000042", + "decimals": 18, + "symbol": "OP", + "name": "Optimism" + }, + "ETH": { + "chainId": 10, + "address": "0x0000000000000000000000000000000000000000", + "decimals": 18, + "symbol": "ETH", + "name": "Ethereum" + }, + "WETH": { + "chainId": 10, + "address": "0x4200000000000000000000000000000000000006", + "decimals": 18, + "symbol": "WETH", + "name": "Wrapped Ether" + }, + "WBTC": { + "chainId": 10, + "address": "0x68f180fcCe6836688e9084f035309E29Bf0A2095", + "decimals": 8, + "symbol": "WBTC", + "name": "Wrapped BTC" + } +} diff --git a/src/logics/compound-v3/tokens/data/polygon.json b/src/logics/compound-v3/tokens/data/polygon.json index 911781f7..a3678619 100644 --- a/src/logics/compound-v3/tokens/data/polygon.json +++ b/src/logics/compound-v3/tokens/data/polygon.json @@ -1,4 +1,11 @@ { + "COMP": { + "chainId": 137, + "address": "0x8505b9d2254A7Ae468c0E9dd10Ccea3A837aef5c", + "decimals": 18, + "symbol": "COMP", + "name": "(PoS) Compound" + }, "cUSDCv3": { "chainId": 137, "address": "0xF25212E676D1F7F89Cd72fFEe66158f541246445", @@ -6,11 +13,11 @@ "symbol": "cUSDCv3", "name": "Compound USDC" }, - "USDC": { + "USDC.e": { "chainId": 137, "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", "decimals": 6, - "symbol": "USDC", + "symbol": "USDC.e", "name": "USD Coin (PoS)" }, "WETH": { diff --git a/src/logics/compound-v3/tokens/index.ts b/src/logics/compound-v3/tokens/index.ts index cdd49c98..80deb1f8 100644 --- a/src/logics/compound-v3/tokens/index.ts +++ b/src/logics/compound-v3/tokens/index.ts @@ -1,11 +1,26 @@ +import arbitrumTokensJSON from './data/arbitrum.json'; +import baseTokensJSON from './data/base.json'; import * as common from '@protocolink/common'; import mainnetTokensJSON from './data/mainnet.json'; +import optimismTokensJSON from './data/optimism.json'; import polygonTokensJSON from './data/polygon.json'; type MainnetTokenSymbols = keyof typeof mainnetTokensJSON; export const mainnetTokens = common.toTokenMap(mainnetTokensJSON); +type OptimismTokenSymbols = keyof typeof optimismTokensJSON; + +export const optimismTokens = common.toTokenMap(optimismTokensJSON); + type PolygonTokenSymbols = keyof typeof polygonTokensJSON; export const polygonTokens = common.toTokenMap(polygonTokensJSON); + +type BaseTokenSymbols = keyof typeof baseTokensJSON; + +export const baseTokens = common.toTokenMap(baseTokensJSON); + +type ArbitrumTokenSymbols = keyof typeof arbitrumTokensJSON; + +export const arbitrumTokens = common.toTokenMap(arbitrumTokensJSON); diff --git a/src/logics/morphoblue/configs.ts b/src/logics/morphoblue/configs.ts index 49040931..b6a8f28c 100644 --- a/src/logics/morphoblue/configs.ts +++ b/src/logics/morphoblue/configs.ts @@ -5,8 +5,8 @@ type ContractNames = 'Morpho' | 'MorphoFlashLoanCallback'; export interface MarketConfig { id: string; - loanTokenAddress: string; - collateralTokenAddress: string; + loanToken: common.Token; + collateralToken: common.Token; oracle: string; irm: string; lltv: string; @@ -31,232 +31,232 @@ export const configs: Config[] = [ markets: [ { id: '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.wstETH, oracle: '0x2a01EB9496094dA03c4E364Def50f5aD1280AD72', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '945000000000000000', }, { id: '0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc', - loanTokenAddress: mainnetTokens.USDC.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.USDC, + collateralToken: mainnetTokens.wstETH, oracle: '0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0xa921ef34e2fc7a27ccc50ae7e4b154e16c9799d3387076c421423ef52ac4df99', - loanTokenAddress: mainnetTokens.USDT.address, - collateralTokenAddress: mainnetTokens.WBTC.address, + loanToken: mainnetTokens.USDT, + collateralToken: mainnetTokens.WBTC, oracle: '0x008bF4B1cDA0cc9f0e882E0697f036667652E1ef', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x698fe98247a40c5771537b5786b2f3f9d78eb487b4ce4d75533cd0e94d88a115', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.weETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.weETH, oracle: '0x3fa58b74e9a8eA8768eb33c8453e9C2Ed089A40a', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x3a85e619751152991742810df6ec69ce473daef99e28a64ab2340d7b7ccfee49', - loanTokenAddress: mainnetTokens.USDC.address, - collateralTokenAddress: mainnetTokens.WBTC.address, + loanToken: mainnetTokens.USDC, + collateralToken: mainnetTokens.WBTC, oracle: '0xDddd770BADd886dF3864029e4B377B5F6a2B6b83', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0xd5211d0e3f4a30d5c98653d988585792bb7812221f04801be73a44ceecb11e89', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.osETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.osETH, oracle: '0x224F2F1333b45E34fFCfC3bD01cE43C73A914498', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0xe7e9694b754c4d4f7e21faf7223f6fa71abaeb10296a4c43a54a7977149687d2', - loanTokenAddress: mainnetTokens.USDT.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.USDT, + collateralToken: mainnetTokens.wstETH, oracle: '0x95DB30fAb9A3754e42423000DF27732CB2396992', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x124ddf1fa02a94085d1fcc35c46c7e180ddb8a0d3ec1181cf67a75341501c9e6', - loanTokenAddress: mainnetTokens.PYUSD.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.PYUSD, + collateralToken: mainnetTokens.wstETH, oracle: '0x27679a17b7419fB10Bd9D143f21407760fdA5C53', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x49bb2d114be9041a787432952927f6f144f05ad3e83196a7d062f374ee11d0ee', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.ezETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.ezETH, oracle: '0x61025e2B0122ac8bE4e37365A4003d87ad888Cc3', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x1929f8139224cb7d5db8c270addc9ce366d37ad279e1135f73c0adce74b0f936', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.sDAI.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.sDAI, oracle: '0x0f9bb760D76af1B5Ca89102084E1963F6698AFda', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x1247f1c237eceae0602eab1470a5061a6dd8f734ba88c7cdc5d6109fb0026b28', - loanTokenAddress: mainnetTokens.DAI.address, - collateralTokenAddress: mainnetTokens.sUSDe.address, + loanToken: mainnetTokens.DAI, + collateralToken: mainnetTokens.sUSDe, oracle: '0x5D916980D5Ae1737a8330Bf24dF812b2911Aae25', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0x8bbd1763671eb82a75d5f7ca33a0023ffabdd9d1a3d4316f34753685ae988e80', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.apxETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.apxETH, oracle: '0x037D67A5E6F19d0Fb26A6603d2D4fE9d70eC3258', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x8e6aeb10c401de3279ac79b4b2ea15fc94b7d9cfc098d6c2a1ff7b2b26d9d02c', - loanTokenAddress: mainnetTokens.DAI.address, - collateralTokenAddress: mainnetTokens.USDe.address, + loanToken: mainnetTokens.DAI, + collateralToken: mainnetTokens.USDe, oracle: '0xaE4750d0813B5E37A51f7629beedd72AF1f9cA35', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0x97bb820669a19ba5fa6de964a466292edd67957849f9631eb8b830c382f58b7f', - loanTokenAddress: mainnetTokens.USDC.address, - collateralTokenAddress: mainnetTokens.MKR.address, + loanToken: mainnetTokens.USDC, + collateralToken: mainnetTokens.MKR, oracle: '0x6686788B4315A4F93d822c1Bf73910556FCe2d5a', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '770000000000000000', }, { id: '0xdc5333039bcf15f1237133f74d5806675d83d9cf19cfd4cfdd9be674842651bf', - loanTokenAddress: mainnetTokens.USDT.address, - collateralTokenAddress: mainnetTokens.sUSDe.address, + loanToken: mainnetTokens.USDT, + collateralToken: mainnetTokens.sUSDe, oracle: '0xE47E36457D0cF83A74AE1e45382B7A044f7abd99', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0xb8fc70e82bc5bb53e773626fcc6a23f7eefa036918d7ef216ecfb1950a94a85e', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.wstETH, oracle: '0xbD60A6770b27E084E8617335ddE769241B0e71D8', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '965000000000000000', }, { id: '0x423cb007534ac88febb8ce39f544ab303e8b757f8415ed891fc76550f8f4c965', - loanTokenAddress: mainnetTokens.USDA.address, - collateralTokenAddress: mainnetTokens.wstETH.address, + loanToken: mainnetTokens.USDA, + collateralToken: mainnetTokens.wstETH, oracle: '0xBC693693fDBB177Ad05ff38633110016BC043AC5', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0xea023e57814fb9a814a5a9ee9f3e7ece5b771dd8cc703e50b911e9cde064a12d', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.WOETH.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.WOETH, oracle: '0xb7948b5bEEe825E609990484A99340D8767B420e', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0xbd33e0ae076c82cfd0fa8d759ea83a296190f9f98d9f79b74a0eb4a294d8bf42', - loanTokenAddress: mainnetTokens.USDC.address, - collateralTokenAddress: mainnetTokens.weETH.address, + loanToken: mainnetTokens.USDC, + collateralToken: mainnetTokens.weETH, oracle: '0x90CFE73B913ee1B93EA75Aa47134b7330289a458', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '770000000000000000', }, { id: '0x9337a95dcb09d10abb33fdb955dd27b46e345f5510d54d9403f570f8f37b5983', - loanTokenAddress: mainnetTokens.PYUSD.address, - collateralTokenAddress: mainnetTokens.WBTC.address, + loanToken: mainnetTokens.PYUSD, + collateralToken: mainnetTokens.WBTC, oracle: '0xc53c90d6E9A5B69E4ABf3d5Ae4c79225C7FeF3d2', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '860000000000000000', }, { id: '0x138eec0e4a1937eb92ebc70043ed539661dd7ed5a89fb92a720b341650288a40', - loanTokenAddress: mainnetTokens.WETH.address, - collateralTokenAddress: mainnetTokens.WBTC.address, + loanToken: mainnetTokens.WETH, + collateralToken: mainnetTokens.WBTC, oracle: '0xc29B3Bc033640baE31ca53F8a0Eb892AdF68e663', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0xdb760246f6859780f6c1b272d47a8f64710777121118e56e0cdb4b8b744a3094', - loanTokenAddress: mainnetTokens.DAI.address, - collateralTokenAddress: mainnetTokens.USDe.address, + loanToken: mainnetTokens.DAI, + collateralToken: mainnetTokens.USDe, oracle: '0xaE4750d0813B5E37A51f7629beedd72AF1f9cA35', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '945000000000000000', }, { id: '0xcec858380cba2d9ca710fce3ce864d74c3f620d53826f69d08508902e09be86f', - loanTokenAddress: mainnetTokens.USDT.address, - collateralTokenAddress: mainnetTokens.USDe.address, + loanToken: mainnetTokens.USDT, + collateralToken: mainnetTokens.USDe, oracle: '0xAf5060C11D3E8325a8ECF84c07fAB7Ac2297A72d', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0xe475337d11be1db07f7c5a156e511f05d1844308e66e17d2ba5da0839d3b34d9', - loanTokenAddress: mainnetTokens.DAI.address, - collateralTokenAddress: mainnetTokens.sUSDe.address, + loanToken: mainnetTokens.DAI, + collateralToken: mainnetTokens.sUSDe, oracle: '0x5D916980D5Ae1737a8330Bf24dF812b2911Aae25', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '945000000000000000', }, { id: '0xb1eac1c0f3ad13fb45b01beac8458c055c903b1bff8cb882346635996a774f77', - loanTokenAddress: mainnetTokens.DAI.address, - collateralTokenAddress: mainnetTokens.sDAI.address, + loanToken: mainnetTokens.DAI, + collateralToken: mainnetTokens.sDAI, oracle: '0x9d4eb56E054e4bFE961F861E351F606987784B65', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '980000000000000000', }, { id: '0xa72f4af2570dca1b356aa6c1e6a804d0d3df5b23bb092189776d0dc652feabb4', - loanTokenAddress: mainnetTokens.USDA.address, - collateralTokenAddress: mainnetTokens.rsETH.address, + loanToken: mainnetTokens.USDA, + collateralToken: mainnetTokens.rsETH, oracle: '0x599AD2053bFE462AB535f6370B9aBBa137CDeb83', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '770000000000000000', }, { id: '0x5d09770b08517329e25b7dff8f32ad7098c8b6fd075660cdabec3e717ca8068f', - loanTokenAddress: mainnetTokens.USDA.address, - collateralTokenAddress: mainnetTokens.Re7USDT.address, + loanToken: mainnetTokens.USDA, + collateralToken: mainnetTokens.Re7USDT, oracle: '0x1f083a4c51E6cAa627A8Cbe7452bF3D6eb815F57', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '915000000000000000', }, { id: '0x459687783a68f4cf4e230618f88ce135d1cd459a850f6496751c2a9c1c6e852e', - loanTokenAddress: mainnetTokens.USDA.address, - collateralTokenAddress: mainnetTokens.ezETH.address, + loanToken: mainnetTokens.USDA, + collateralToken: mainnetTokens.ezETH, oracle: '0xd5116061F4a1FFac23E9c6c9f6B4AF28b9AF7676', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '770000000000000000', }, { id: '0xbe4c211adca4400078db69af91ea0df98401adb5959510ae99edd06fee5146f7', - loanTokenAddress: mainnetTokens.USDC.address, - collateralTokenAddress: mainnetTokens.mTBILL.address, + loanToken: mainnetTokens.USDC, + collateralToken: mainnetTokens.mTBILL, oracle: '0x6E8F5b2DF218443E87fe8aA9811E6956716dde88', irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC', lltv: '980000000000000000', diff --git a/src/logics/morphoblue/logic.borrow.ts b/src/logics/morphoblue/logic.borrow.ts index 75e68ee8..1620d86c 100644 --- a/src/logics/morphoblue/logic.borrow.ts +++ b/src/logics/morphoblue/logic.borrow.ts @@ -34,14 +34,14 @@ export class BorrowLogic extends core.Logic implements core.LogicTokenListInterf const { marketId, output } = fields; const { account } = options; - const { collateralTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { collateralToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const loanToken = output.token.wrapped; const agent = await this.calcAgent(account); const service = new Service(this.chainId, this.provider); const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('borrow', [ - { loanToken: loanToken.address, collateralToken: collateralTokenAddress, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, output.amountWei, // assets 0, // shares account, // onBehalf diff --git a/src/logics/morphoblue/logic.flash-loan.ts b/src/logics/morphoblue/logic.flash-loan.ts index 20d338ad..121e689b 100644 --- a/src/logics/morphoblue/logic.flash-loan.ts +++ b/src/logics/morphoblue/logic.flash-loan.ts @@ -36,8 +36,8 @@ export class FlashLoanLogic extends core.Logic implements core.LogicTokenListInt const markets = getMarkets(this.chainId); for (const market of markets) { - tokenAddressSet.add(market.loanTokenAddress); - tokenAddressSet.add(market.collateralTokenAddress); + tokenAddressSet.add(market.loanToken.address); + tokenAddressSet.add(market.collateralToken.address); } const tokenList: FlashLoanLogicTokenList = await service.getTokens([...tokenAddressSet]); diff --git a/src/logics/morphoblue/logic.repay.ts b/src/logics/morphoblue/logic.repay.ts index d02d74e0..e2c9d9c7 100644 --- a/src/logics/morphoblue/logic.repay.ts +++ b/src/logics/morphoblue/logic.repay.ts @@ -43,7 +43,7 @@ export class RepayLogic extends core.Logic implements core.LogicTokenListInterfa async build(fields: RepayLogicFields) { const { marketId, borrower, input, balanceBps } = fields; - const { collateralTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { collateralToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const loanToken = input.token.wrapped; const service = new Service(this.chainId, this.provider); @@ -55,7 +55,7 @@ export class RepayLogic extends core.Logic implements core.LogicTokenListInterfa const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('repay', [ - { loanToken: loanToken.address, collateralToken: collateralTokenAddress, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, assets, // assets shares, // shares borrower, // onBehalf diff --git a/src/logics/morphoblue/logic.supply-collateral.ts b/src/logics/morphoblue/logic.supply-collateral.ts index dea7915e..11ba1cbe 100644 --- a/src/logics/morphoblue/logic.supply-collateral.ts +++ b/src/logics/morphoblue/logic.supply-collateral.ts @@ -37,13 +37,13 @@ export class SupplyCollateralLogic const { marketId, input, balanceBps } = fields; const { account } = options; - const { loanTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { loanToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const collateralToken = input.token.wrapped; const service = new Service(this.chainId, this.provider); const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('supplyCollateral', [ - { loanToken: loanTokenAddress, collateralToken: collateralToken.address, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, input.amountWei, // assets account, // onBehalf '0x', // data diff --git a/src/logics/morphoblue/logic.supply.ts b/src/logics/morphoblue/logic.supply.ts index c3329d12..e11fec36 100644 --- a/src/logics/morphoblue/logic.supply.ts +++ b/src/logics/morphoblue/logic.supply.ts @@ -34,13 +34,13 @@ export class SupplyLogic extends core.Logic implements core.LogicTokenListInterf const { marketId, input, balanceBps } = fields; const { account } = options; - const { collateralTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { collateralToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const loanToken = input.token.wrapped; const service = new Service(this.chainId, this.provider); const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('supply', [ - { loanToken: loanToken.address, collateralToken: collateralTokenAddress, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, input.amountWei, // assets 0, // shares account, // onBehalf diff --git a/src/logics/morphoblue/logic.withdraw-collateral.ts b/src/logics/morphoblue/logic.withdraw-collateral.ts index 4597c994..a966e0ec 100644 --- a/src/logics/morphoblue/logic.withdraw-collateral.ts +++ b/src/logics/morphoblue/logic.withdraw-collateral.ts @@ -37,14 +37,14 @@ export class WithdrawCollateralLogic const { marketId, output } = fields; const { account } = options; - const { loanTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { loanToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const collateralToken = output.token.wrapped; const agent = await this.calcAgent(account); const service = new Service(this.chainId, this.provider); const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('withdrawCollateral', [ - { loanToken: loanTokenAddress, collateralToken: collateralToken.address, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, output.amountWei, // assets account, // onBehalf agent, // receiver diff --git a/src/logics/morphoblue/logic.withdraw.ts b/src/logics/morphoblue/logic.withdraw.ts index a7177d7c..19b274d2 100644 --- a/src/logics/morphoblue/logic.withdraw.ts +++ b/src/logics/morphoblue/logic.withdraw.ts @@ -34,14 +34,14 @@ export class WithdrawLogic extends core.Logic implements core.LogicTokenListInte const { marketId, output } = fields; const { account } = options; - const { collateralTokenAddress, oracle, irm, lltv } = getMarket(this.chainId, marketId); + const { collateralToken, oracle, irm, lltv } = getMarket(this.chainId, marketId); const loanToken = output.token.wrapped; const agent = await this.calcAgent(account); const service = new Service(this.chainId, this.provider); const to = service.morpho.address; const data = service.morphoIface.encodeFunctionData('withdraw', [ - { loanToken: loanToken.address, collateralToken: collateralTokenAddress, oracle, irm, lltv }, + { loanToken: loanToken.address, collateralToken: collateralToken.address, oracle, irm, lltv }, output.amountWei, // assets 0, // shares account, // onBehalf diff --git a/src/logics/morphoblue/service.ts b/src/logics/morphoblue/service.ts index a20a881d..867cbd10 100644 --- a/src/logics/morphoblue/service.ts +++ b/src/logics/morphoblue/service.ts @@ -26,13 +26,13 @@ export class Service extends common.Web3Toolkit { async getLoanToken(marketId: string) { const market = getMarket(this.chainId, marketId); - const loanToken = await this.getToken(market.loanTokenAddress); + const loanToken = await this.getToken(market.loanToken.address); return loanToken; } async getCollateralToken(marketId: string) { const market = getMarket(this.chainId, marketId); - const collateralToken = await this.getToken(market.collateralTokenAddress); + const collateralToken = await this.getToken(market.collateralToken.address); return collateralToken; } diff --git a/test/logics/compound-v3/helpers.ts b/test/logics/compound-v3/helpers.ts index 89e2c422..c83bb415 100644 --- a/test/logics/compound-v3/helpers.ts +++ b/test/logics/compound-v3/helpers.ts @@ -20,15 +20,15 @@ export async function allow(chainId: number, user: SignerWithAddress, marketId: export async function supply(chainId: number, user: SignerWithAddress, marketId: string, supply: common.TokenAmount) { const market = compoundv3.getMarket(chainId, marketId); - await approve(user, market.cometAddress, supply); + await approve(user, market.comet.address, supply); await expect( - compoundv3.Comet__factory.connect(market.cometAddress, user).supply(supply.token.address, supply.amountWei) + compoundv3.Comet__factory.connect(market.comet.address, user).supply(supply.token.address, supply.amountWei) ).to.not.be.reverted; } export async function borrow(chainId: number, user: SignerWithAddress, marketId: string, borrow: common.TokenAmount) { const market = compoundv3.getMarket(chainId, marketId); await expect( - compoundv3.Comet__factory.connect(market.cometAddress, user).withdraw(borrow.token.address, borrow.amountWei) + compoundv3.Comet__factory.connect(market.comet.address, user).withdraw(borrow.token.address, borrow.amountWei) ).to.not.be.reverted; } diff --git a/test/logics/morphoblue/helpers.ts b/test/logics/morphoblue/helpers.ts index 170d4adf..455cdc8d 100644 --- a/test/logics/morphoblue/helpers.ts +++ b/test/logics/morphoblue/helpers.ts @@ -13,7 +13,7 @@ export async function authorize(chainId: number, user: SignerWithAddress) { const service = new morphoblue.Service(chainId, hre.ethers.provider); const isAuthorized = await service.isAuthorized(user.address, agent); if (!isAuthorized) { - const tx = await service.buildAuthorizeTransactionRequest(agent, true); + const tx = service.buildAuthorizeTransactionRequest(agent, true); await expect(user.sendTransaction(tx)).to.not.be.reverted; } } @@ -25,8 +25,8 @@ export async function supply(chainId: number, user: SignerWithAddress, marketId: await expect( morphoblue.Morpho__factory.connect(morphoAddress, user).supply( { - loanToken: market.loanTokenAddress, - collateralToken: market.collateralTokenAddress, + loanToken: market.loanToken.address, + collateralToken: market.collateralToken.address, oracle: market.oracle, irm: market.irm, lltv: market.lltv, @@ -52,8 +52,8 @@ export async function supplyCollateral( await expect( morphoblue.Morpho__factory.connect(morphoAddress, user).supplyCollateral( { - loanToken: market.loanTokenAddress, - collateralToken: market.collateralTokenAddress, + loanToken: market.loanToken.address, + collateralToken: market.collateralToken.address, oracle: market.oracle, irm: market.irm, lltv: market.lltv, @@ -74,8 +74,8 @@ export async function borrow(chainId: number, user: SignerWithAddress, marketId: await expect( morphoblue.Morpho__factory.connect(morphoAddress, user).borrow( { - loanToken: market.loanTokenAddress, - collateralToken: market.collateralTokenAddress, + loanToken: market.loanToken.address, + collateralToken: market.collateralToken.address, oracle: market.oracle, irm: market.irm, lltv: market.lltv,