Skip to content

Commit

Permalink
Merge pull request #34 from Jeff-CCH/feat/mopho-flashloan
Browse files Browse the repository at this point in the history
Add Morphoblue flashloan
  • Loading branch information
Jeff-CCH authored Jan 5, 2024
2 parents 1789db9 + c97eb5c commit 95b8a2e
Show file tree
Hide file tree
Showing 21 changed files with 707 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-phones-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@protocolink/logics': patch
---

add Morphoblue flashloan
2 changes: 1 addition & 1 deletion .env.goerli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CHAIN_ID=5
HTTP_RPC_URL=https://rpc.ankr.com/eth_goerli
BLOCK_NUMBER=10310000
BLOCK_NUMBER=10320000
66 changes: 66 additions & 0 deletions src/logics/morphoblue/abis/MorphoFlashLoanCallback.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"inputs": [
{ "internalType": "address", "name": "router_", "type": "address" },
{ "internalType": "address", "name": "morpho_", "type": "address" },
{ "internalType": "uint256", "name": "feeRate_", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [{ "internalType": "address", "name": "token", "type": "address" }],
"name": "InvalidBalance",
"type": "error"
},
{ "inputs": [], "name": "InvalidCaller", "type": "error" },
{
"inputs": [],
"name": "feeRate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "token", "type": "address" },
{ "internalType": "uint256", "name": "assets", "type": "uint256" },
{ "internalType": "bytes", "name": "data", "type": "bytes" }
],
"name": "flashLoan",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "metadata",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "morpho",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "assets", "type": "uint256" },
{ "internalType": "bytes", "name": "data", "type": "bytes" }
],
"name": "onMorphoFlashLoan",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "router",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
}
]
3 changes: 2 additions & 1 deletion src/logics/morphoblue/configs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as common from '@protocolink/common';
import { goerliTokens } from './tokens';

type ContractNames = 'Morpho';
type ContractNames = 'Morpho' | 'MorphoFlashLoanCallback';

export interface MarketConfig {
id: string;
Expand All @@ -23,6 +23,7 @@ export const configs: Config[] = [
chainId: common.ChainId.goerli,
contract: {
Morpho: '0x64c7044050Ba0431252df24fEd4d9635a275CB41',
MorphoFlashLoanCallback: '0x24D5b6b712D1f0D0B628E21E39dBaDde3f28C56e',
},
markets: [
{
Expand Down
178 changes: 178 additions & 0 deletions src/logics/morphoblue/contracts/MorphoFlashLoanCallback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers';
import type { FunctionFragment, Result } from '@ethersproject/abi';
import type { Listener, Provider } from '@ethersproject/providers';
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common';

export interface MorphoFlashLoanCallbackInterface extends utils.Interface {
functions: {
'feeRate()': FunctionFragment;
'flashLoan(address,uint256,bytes)': FunctionFragment;
'metadata()': FunctionFragment;
'morpho()': FunctionFragment;
'onMorphoFlashLoan(uint256,bytes)': FunctionFragment;
'router()': FunctionFragment;
};

getFunction(
nameOrSignatureOrTopic: 'feeRate' | 'flashLoan' | 'metadata' | 'morpho' | 'onMorphoFlashLoan' | 'router'
): FunctionFragment;

encodeFunctionData(functionFragment: 'feeRate', values?: undefined): string;
encodeFunctionData(functionFragment: 'flashLoan', values: [string, BigNumberish, BytesLike]): string;
encodeFunctionData(functionFragment: 'metadata', values?: undefined): string;
encodeFunctionData(functionFragment: 'morpho', values?: undefined): string;
encodeFunctionData(functionFragment: 'onMorphoFlashLoan', values: [BigNumberish, BytesLike]): string;
encodeFunctionData(functionFragment: 'router', values?: undefined): string;

decodeFunctionResult(functionFragment: 'feeRate', data: BytesLike): Result;
decodeFunctionResult(functionFragment: 'flashLoan', data: BytesLike): Result;
decodeFunctionResult(functionFragment: 'metadata', data: BytesLike): Result;
decodeFunctionResult(functionFragment: 'morpho', data: BytesLike): Result;
decodeFunctionResult(functionFragment: 'onMorphoFlashLoan', data: BytesLike): Result;
decodeFunctionResult(functionFragment: 'router', data: BytesLike): Result;

events: {};
}

export interface MorphoFlashLoanCallback extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: MorphoFlashLoanCallbackInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;

listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;

functions: {
feeRate(overrides?: CallOverrides): Promise<[BigNumber]>;

flashLoan(
token: string,
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<ContractTransaction>;

metadata(overrides?: CallOverrides): Promise<[string]>;

morpho(overrides?: CallOverrides): Promise<[string]>;

onMorphoFlashLoan(
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<ContractTransaction>;

router(overrides?: CallOverrides): Promise<[string]>;
};

feeRate(overrides?: CallOverrides): Promise<BigNumber>;

flashLoan(
token: string,
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<ContractTransaction>;

metadata(overrides?: CallOverrides): Promise<string>;

morpho(overrides?: CallOverrides): Promise<string>;

onMorphoFlashLoan(
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<ContractTransaction>;

router(overrides?: CallOverrides): Promise<string>;

callStatic: {
feeRate(overrides?: CallOverrides): Promise<BigNumber>;

flashLoan(token: string, assets: BigNumberish, data: BytesLike, overrides?: CallOverrides): Promise<void>;

metadata(overrides?: CallOverrides): Promise<string>;

morpho(overrides?: CallOverrides): Promise<string>;

onMorphoFlashLoan(assets: BigNumberish, data: BytesLike, overrides?: CallOverrides): Promise<void>;

router(overrides?: CallOverrides): Promise<string>;
};

filters: {};

estimateGas: {
feeRate(overrides?: CallOverrides): Promise<BigNumber>;

flashLoan(
token: string,
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<BigNumber>;

metadata(overrides?: CallOverrides): Promise<BigNumber>;

morpho(overrides?: CallOverrides): Promise<BigNumber>;

onMorphoFlashLoan(
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<BigNumber>;

router(overrides?: CallOverrides): Promise<BigNumber>;
};

populateTransaction: {
feeRate(overrides?: CallOverrides): Promise<PopulatedTransaction>;

flashLoan(
token: string,
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<PopulatedTransaction>;

metadata(overrides?: CallOverrides): Promise<PopulatedTransaction>;

morpho(overrides?: CallOverrides): Promise<PopulatedTransaction>;

onMorphoFlashLoan(
assets: BigNumberish,
data: BytesLike,
overrides?: Overrides & { from?: string }
): Promise<PopulatedTransaction>;

router(overrides?: CallOverrides): Promise<PopulatedTransaction>;
};
}
Loading

0 comments on commit 95b8a2e

Please sign in to comment.