Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Morphoblue flashloan #34

Merged
merged 5 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading