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

feat: add morpho reallocate to #716

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"dev": "lerna run --scope @oasisdex/dma-contracts dev",
"deploy:dev": "lerna run deploy:dev",
"test": "lerna run pretest && lerna run test --stream",
"test": "lerna run test --stream",
"test:e2e": "lerna run test:e2e --stream",
"test:unit": "lerna run test:unit --stream",
"clean": "rm -rf .parcel-cache && lerna run clean --stream",
Expand All @@ -24,7 +24,7 @@
"build": "yarn clean && yarn fetch-compilers && yarn compile && lerna run build --stream",
"format": "lerna run format --stream",
"format:check": "lerna run format:check --stream",
"lint": "lerna run prelint --stream && lerna run lint --stream && yarn clean",
"lint": "lerna run prelint --stream && lerna run lint --stream",
"publish:all": "npx lerna publish --no-private",
"postinstall": "patch-package"
},
Expand All @@ -36,6 +36,7 @@
"@ethereumjs/tx": "3.5.0",
"@ethersproject/contracts": "^5.7.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.2",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@nomiclabs/hardhat-waffle": "^2.0.5",
Expand Down Expand Up @@ -135,4 +136,4 @@
"hardhat/**/@ethereumjs/tx": "3.5.0",
"ethers": "^5.7.2"
}
}
}
5 changes: 3 additions & 2 deletions packages/addresses/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oasisdex/addresses",
"version": "0.1.91",
"version": "0.1.92-0.1.92-dev-testnet-only.0",
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
"main": "lib/index.js",
Expand All @@ -23,5 +23,6 @@
"implicitDependencies": [
"@oasisdex/deploy-configurations"
]
}
},
"gitHead": "34e72e10dd17a1108334675b9b68afeb341c8fa0"
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/arbitrum.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,5 +1086,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
12 changes: 12 additions & 0 deletions packages/deploy-configurations/configs/base.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ export const config: SystemConfig = {
history: [],
constructorArgs: [],
},
MorphoBlueReallocateTo: {
name: 'MorphoBlueReallocateTo',
deploy: true,
address: '',
serviceRegistryName: SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO,
history: [],
constructorArgs: ['address:ServiceRegistry'],
},
},
},
common: {
Expand Down Expand Up @@ -1607,5 +1615,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x23055618898e202386e6c13955a58D3C68200BFB',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/goerli.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,5 +1263,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/hardhat.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,5 +1471,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/local.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1424,5 +1424,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
13 changes: 13 additions & 0 deletions packages/deploy-configurations/configs/mainnet.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ export const config: SystemConfig = {
history: [],
constructorArgs: [],
},
MorphoBlueReallocateTo: {
name: 'MorphoBlueReallocateTo',
deploy: true,
address: '0xd9261350974569527be51d1e39e72828b7dc514a',
serviceRegistryName: SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO,
history: [],
constructorArgs: ['address:ServiceRegistry'],
},
},
},
common: {
Expand Down Expand Up @@ -1879,5 +1887,10 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: '0x9D03bb2092270648d7480049d0E58d2FcF0E5123',
},
Bundler: {
name: 'Bundler',
address: '0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077',
serviceRegistryName: SERVICE_REGISTRY_NAMES.morphoblue.BUNDLER,
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/optimism.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1309,5 +1309,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/sepolia.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,5 +1267,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/tenderly.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1473,5 +1473,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/test.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1530,5 +1530,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/test/arbitrum.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,5 +938,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/test/mainnet.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1338,5 +1338,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
4 changes: 4 additions & 0 deletions packages/deploy-configurations/configs/test/optimism.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,5 +1233,9 @@ export const config: SystemConfig = {
name: 'Wrapper',
address: ADDRESS_ZERO,
},
Bundler: {
name: 'Bundler',
address: '0x0000000000000000000000000000000000000000',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ export const SERVICE_REGISTRY_NAMES = {
},
morphoblue: {
MORPHO_BLUE: 'MorphoBlue',
BUNDLER: 'MorphoBlueBundler',
DEPOSIT: 'MorphoBlueDeposit',
WITHDRAW: 'MorphoBlueWithdraw',
BORROW: 'MorphoBlueBorrow',
PAYBACK: 'MorphoBluePayback',
CLAIM_REWARDS: 'MorphoBlueClaimRewards',
REALLOCATE_TO: 'MorphoBlueReallocate',
},
test: {
DUMMY_ACTION: 'DummyAction',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ export const SERVICE_REGISTRY_NAMES = {
},
morphoblue: {
MORPHO_BLUE: 'MorphoBlue',
BUNDLER: 'MorphoBlueBundler',
DEPOSIT: 'MorphoBlueDeposit',
WITHDRAW: 'MorphoBlueWithdraw',
BORROW: 'MorphoBlueBorrow',
PAYBACK: 'MorphoBluePayback_2',
CLAIM_REWARDS: 'MorphoBlueClaimRewards',
REALLOCATE_TO: 'MorphoBlueReallocate',
},
test: {
DUMMY_ACTION: 'DummyAction',
Expand Down
10 changes: 5 additions & 5 deletions packages/deploy-configurations/constants/operation-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ export const OPERATION_NAMES = {
CLOSE_POSITION_TO_COLLATERAL: 'AjnaCloseToCollateralPosition_5',
},
morphoblue: {
OPEN_POSITION: 'MorphoBlueOpenPosition',
OPEN_POSITION: 'MorphoBlueOpenPosition_2',
CLOSE_POSITION: 'MorphoBlueClosePosition_2',
ADJUST_RISK_UP: 'MorphoBlueAdjustRiskUp',
ADJUST_RISK_UP: 'MorphoBlueAdjustRiskUp_2',
ADJUST_RISK_DOWN: 'MorphoBlueAdjustRiskDown_2',
DEPOSIT_BORROW: 'MorphoBlueDepositBorrow',
OPEN_DEPOSIT_BORROW: 'MorphoBlueOpenDepositBorrow',
DEPOSIT_BORROW: 'MorphoBlueDepositBorrow_2',
OPEN_DEPOSIT_BORROW: 'MorphoBlueOpenDepositBorrow_3', // Change back after testing
DEPOSIT: 'MorphoBlueDeposit',
BORROW: 'MorphoBlueBorrow',
BORROW: 'MorphoBlueBorrow_2',
PAYBACK_WITHDRAW: 'MorphoBluePaybackWithdraw_2',
CLAIM_REWARDS: 'MorphoBlueClaimRewards',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export function getMorphoBlueBorrowOperationDefinition(network: Network) {
return {
name: OPERATION_NAMES.morphoblue.BORROW,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.BORROW),
optional: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function getMorphoBlueDepositBorrowOperationDefinition(network: Network)
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.DEPOSIT),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.BORROW),
optional: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function getMorphoBlueOpenDepositBorrowOperationDefinition(network: Netwo
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.DEPOSIT),
optional: false,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.BORROW),
optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export function getMorphoBlueAdjustUpOperationDefinition(network: Network) {
return {
name: OPERATION_NAMES.morphoblue.ADJUST_RISK_UP,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN),
optional: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export function getMorphoBlueOpenOperationDefinition(network: Network) {
return {
name: OPERATION_NAMES.morphoblue.OPEN_POSITION,
actions: [
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.morphoblue.REALLOCATE_TO),
optional: true,
},
{
hash: getActionHash(SERVICE_REGISTRY_NAMES.common.TAKE_A_FLASHLOAN),
optional: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type MorphoBlueActions =
| `MorphoBlueWithdraw`
| `MorphoBluePayback`
| 'MorphoBlueClaimRewards'
| 'MorphoBlueReallocateTo'

export type Actions = CommonActions | AaveV3Actions | AjnaActions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConfigEntry } from './config-entries'

export type MorphoBlueProtocol = 'MorphoBlue' | 'AdaptiveCurveIrm' | 'Wrapper'
export type MorphoBlueProtocol = 'MorphoBlue' | 'AdaptiveCurveIrm' | 'Wrapper' | 'Bundler'

export type MorphoBlueProtocolContracts = Record<MorphoBlueProtocol, ConfigEntry>
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ export class ServiceRegistry {
async addEntry(label: ContractNames, address: string, debug = false): Promise<string> {
const entryHash = utils.keccak256(utils.toUtf8Bytes(label))
const registry = await this._getRegistry()
await registry.addNamedService(entryHash, address)

if (debug) {
console.log(`DEBUG: Service '${label}' has been added with hash: ${entryHash}`)
console.log(
`DEBUG: Service '${label}' is about to be added with hash: ${entryHash} and address: ${address}`,
)
}
try {
await registry.addNamedService(entryHash, address)
} catch (error) {
console.error(`Error adding service '${label}' to registry: ${error}`)
return ''
}

return entryHash
Expand Down
Loading
Loading