fixed some bugs and update test script

This commit is contained in:
q1q0 2023-06-25 03:46:38 -04:00
parent c50e7e2ec1
commit b7002335b7
3 changed files with 1210 additions and 336 deletions

View File

@ -4,6 +4,8 @@ pragma experimental ABIEncoderV2;
import "./helpers.sol";
import "./events.sol";
import "hardhat/console.sol";
abstract contract MorphoAaveV3 is Helpers, Events {
/**
* @dev Deposit ETH/ERC20_Token.
@ -270,16 +272,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isETH = _tokenAddress == ethAddr;
address _token = _isETH ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), address(this), max_iteration);
uint256 _borrowed = MORPHO_AAVE_V3.borrow(_token, _amt, address(this), address(this), max_iteration);
convertWethToEth(_isETH, TokenInterface(_token), _amt);
convertWethToEth(_isETH, TokenInterface(_token), _borrowed);
setUint(_setId, _amt);
setUint(_setId, _borrowed);
_eventName = "LogBorrow(address,uint256,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_borrowed,
_getId,
_setId
);
@ -312,16 +314,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isETH = _tokenAddress == ethAddr;
address _token = _isETH ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, max_iteration);
uint256 _borrowed = MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, max_iteration);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _borrowed);
setUint(_setId, _amt);
setUint(_setId, _borrowed);
_eventName = "LogBorrowOnBehalf(address,uint256,addresss,address,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_borrowed,
_onBehalf,
_receiver,
_getId,
@ -356,16 +358,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isETH = _tokenAddress == ethAddr;
address _token = _isETH ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, _maxIteration);
uint256 _borrowed = MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, _maxIteration);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _borrowed);
setUint(_setId, _amt);
setUint(_setId, _borrowed);
_eventName = "LogBorrowWithMaxIterations(address,uint256,addresss,uint256,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_borrowed,
_receiver,
_maxIteration,
_getId,
@ -402,16 +404,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isETH = _tokenAddress == ethAddr;
address _token = _isETH ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, _maxIteration);
uint256 _borrowed = MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, _maxIteration);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isETH, TokenInterface(_token), _borrowed);
setUint(_setId, _amt);
setUint(_setId, _borrowed);
_eventName = "LogBorrowOnBehalfWithMaxIterations(address,uint256,addresss,address,uint256,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_borrowed,
_onBehalf,
_receiver,
_maxIteration,
@ -443,16 +445,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
address _token = _isEth? wethAddr : _tokenAddress;
// Morpho will internally handle max amount conversion by taking the minimum of amount or supplied collateral.
MORPHO_AAVE_V3.withdraw(_token, _amt, address(this), address(this), max_iteration);
uint256 _withdrawn = MORPHO_AAVE_V3.withdraw(_token, _amt, address(this), address(this), max_iteration);
convertWethToEth(_isEth, TokenInterface(_token), _amt);
convertWethToEth(_isEth, TokenInterface(_token), _withdrawn);
setUint(_setId, _amt);
setUint(_setId, _withdrawn);
_eventName = "LogWithdraw(address,uint256,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_withdrawn,
_getId,
_setId
);
@ -486,16 +488,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
address _token = _isEth ? wethAddr : _tokenAddress;
// Morpho will internally handle max amount conversion by taking the minimum of amount or supplied collateral.
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, max_iteration);
uint256 _withdrawn = MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, max_iteration);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _withdrawn);
setUint(_setId, _amt);
setUint(_setId, _withdrawn);
_eventName = "LogWithdrawOnBehalf(address,uint256,address,address,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_withdrawn,
_onBehalf,
_receiver,
_getId,
@ -533,16 +535,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
address _token = _isEth ? wethAddr : _tokenAddress;
// Morpho will internally handle max amount conversion by taking the minimum of amount or supplied collateral.
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, _maxIteration);
uint256 _withdrawn = MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, _maxIteration);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _withdrawn);
setUint(_setId, _amt);
setUint(_setId, _withdrawn);
_eventName = "LogWithdrawOnBehalfWithMaxIterations(address,uint256,address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_withdrawn,
_onBehalf,
_receiver,
_maxIteration,
@ -576,16 +578,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isEth = _tokenAddress == ethAddr;
address _token = _isEth ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, address(this), _receiver);
uint256 _withdrawn = MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, address(this), _receiver);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _withdrawn);
setUint(_setId, _amt);
setUint(_setId, _withdrawn);
_eventName = "LogWithdrawCollateral(address,uint256,address,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_withdrawn,
_receiver,
_getId,
_setId
@ -619,16 +621,16 @@ abstract contract MorphoAaveV3 is Helpers, Events {
bool _isEth = _tokenAddress == ethAddr;
address _token = _isEth ? wethAddr : _tokenAddress;
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, _onBehalf, _receiver);
uint256 _withdrawn = MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, _onBehalf, _receiver);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _amt);
if(_receiver == address(this)) convertWethToEth(_isEth, TokenInterface(_token), _withdrawn);
setUint(_setId, _amt);
setUint(_setId, _withdrawn);
_eventName = "LogWithdrawCollateralOnBehalf(address,uint256,address,address,uint256,uint256)";
_eventParam = abi.encode(
_tokenAddress,
_amt,
_withdrawn,
_onBehalf,
_receiver,
_getId,

View File

@ -9,44 +9,34 @@ import { ConnectV2MorphoAaveV3__factory, IERC20Minimal__factory } from "../../..
import { parseEther, parseUnits } from "@ethersproject/units";
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { dsaMaxValue, tokens } from "../../../scripts/tests/mainnet/tokens";
import morpho_ABI from './morpho-abi.json'
const { ethers } = hre;
import type { Signer, Contract } from "ethers";
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
const ACC_USDC = '0xe78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0'
const Usdc = parseUnits('5000', 6)
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const ACC_USDC = "0xe78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0";
const Usdc = parseUnits("5000", 6);
const DAI = '0x6b175474e89094c44da98b954eedeac495271d0f'
const ACC_DAI = '0xcd6Eb888e76450eF584E8B51bB73c76ffBa21FF2'
const Dai = parseUnits('1', 18)
const DAI = "0x6b175474e89094c44da98b954eedeac495271d0f";
const ACC_DAI = "0xcd6Eb888e76450eF584E8B51bB73c76ffBa21FF2";
const Dai = parseUnits("1", 18);
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
const user = "0x41bc7d0687e6cea57fa26da78379dfdc5627c56d"
const user = "0x41bc7d0687e6cea57fa26da78379dfdc5627c56d";
const token_usdc = new ethers.Contract(
USDC,
IERC20Minimal__factory.abi,
ethers.provider,
)
const token_usdc = new ethers.Contract(USDC, IERC20Minimal__factory.abi, ethers.provider);
const token_dai = new ethers.Contract(
DAI,
IERC20Minimal__factory.abi,
ethers.provider,
)
const token_dai = new ethers.Contract(DAI, IERC20Minimal__factory.abi, ethers.provider);
const token_weth = new ethers.Contract(
WETH,
IERC20Minimal__factory.abi,
ethers.provider,
)
const token_weth = new ethers.Contract(WETH, IERC20Minimal__factory.abi, ethers.provider);
describe("Morpho-Aave-v3", function () {
const connectorName = "MORPHO-AAVE-V3-TEST-A";
let connector: any;
let wallet0: Signer, wallet1:Signer;
let wallet0: Signer, wallet1: Signer;
let dsaWallet0: any;
let instaConnectorsV2: Contract;
let masterSigner: Signer;
@ -59,22 +49,19 @@ describe("Morpho-Aave-v3", function () {
forking: {
// @ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
blockNumber: 17544460,
},
},
],
blockNumber: 17544460
}
}
]
});
[wallet0, wallet1] = await ethers.getSigners();
masterSigner = await getMasterSigner();
instaConnectorsV2 = await ethers.getContractAt(
abis.core.connectorsV2,
addresses.core.connectorsV2
);
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
connector = await deployAndEnableConnector({
connectorName,
contractArtifact: ConnectV2MorphoAaveV3__factory,
signer: masterSigner,
connectors: instaConnectorsV2,
connectors: instaConnectorsV2
});
console.log("Connector address", connector.address);
});
@ -94,33 +81,28 @@ describe("Morpho-Aave-v3", function () {
it("Deposit 1000 ETH into DSA wallet", async function () {
await wallet0.sendTransaction({
to: dsaWallet0.address,
value: parseEther("1000"),
value: parseEther("1000")
});
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
parseEther("1000")
);
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(parseEther("1000"));
});
it("Deposit 5000 USDC into DSA wallet", async function () {
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [ACC_USDC]
});
const signer_usdc = await ethers.getSigner(ACC_USDC);
await token_usdc.connect(signer_usdc).transfer(wallet0.getAddress(), Usdc);
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ACC_USDC],
})
const signer_usdc = await ethers.getSigner(ACC_USDC)
await token_usdc.connect(signer_usdc).transfer(wallet0.getAddress(), Usdc)
await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount',
params: [ACC_USDC],
})
method: "hardhat_stopImpersonatingAccount",
params: [ACC_USDC]
});
await token_usdc.connect(wallet0).transfer(dsaWallet0.address, Usdc);
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('5000', 6)
);
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(parseUnits("5000", 6));
});
// it("Deposit 1 DAI into DSA wallet", async function () {
@ -147,304 +129,323 @@ describe("Morpho-Aave-v3", function () {
});
describe("Main", function () {
// it("Should deposit 10 ETH", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "deposit",
// args: [tokens.eth.address, "10000000000000000000", "0", "0"], // 10 ETH
// },
// ];
it("Should deposit 10 ETH", async function () {
const spells = [
{
connector: connectorName,
method: "deposit",
args: [tokens.eth.address, "10000000000000000000", "0", "0"], // 10 ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
// parseUnits('990', 18))
// );
// })
await tx.wait();
expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
parseUnits('990', 18))
);
})
// it("Should deposit 1 ETH with MaxIteration", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "depositWithMaxIterations",
// args: [tokens.eth.address, "1000000000000000000", 5, "0", "0"], // 1 ETH
// },
// ];
it("Should deposit 1 ETH with MaxIteration", async function () {
const spells = [
{
connector: connectorName,
method: "depositWithMaxIterations",
args: [tokens.eth.address, "1000000000000000000", 5, "0", "0"], // 1 ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
// parseUnits('989', 18))
// );
// })
await tx.wait();
expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
parseUnits('989', 18))
);
})
// it("Should deposit 10 ETH on behalf", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "depositOnBehalf",
// args: [tokens.eth.address, "10000000000000000000", user, "0", "0"], // 1 ETH
// },
// ];
it("Should deposit 10 ETH on behalf", async function () {
const spells = [
{
connector: connectorName,
method: "depositOnBehalf",
args: [tokens.eth.address, "10000000000000000000", user, "0", "0"], // 1 ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
// parseUnits('979', 18))
// );
// })
await tx.wait();
expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
parseUnits('979', 18))
);
})
// it("Should deposit 1 ETH on behalf with MaxIteration", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "depositOnBehalfWithMaxIterations",
// args: [tokens.eth.address, "1000000000000000000", user, 5, "0", "0"], // 1 ETH
// },
// ];
it("Should deposit 1 ETH on behalf with MaxIteration", async function () {
const spells = [
{
connector: connectorName,
method: "depositOnBehalfWithMaxIterations",
args: [tokens.eth.address, "1000000000000000000", user, 5, "0", "0"], // 1 ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
// parseUnits('978', 18))
// );
// })
await tx.wait();
expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
parseUnits('978', 18))
);
})
// it("Should deposit collateral 2000 USDC", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "depositCollateral",
// args: [tokens.usdc.address, "2000000000", "0", "0"], // 50 USDC
// },
// ];
it("Should deposit collateral 2000 USDC", async function () {
const spells = [
{
connector: connectorName,
method: "depositCollateral",
args: [tokens.usdc.address, "2000000000", "0", "0"], // 50 USDC
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.lte(
// parseUnits('3000', 6)
// );
// })
await tx.wait();
expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.lte(
parseUnits('3000', 6)
);
})
// it("Should deposit collateral 2000 USDC on behalf with maxValue", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "depositCollateralOnBehalf",
// args: [tokens.usdc.address, dsaMaxValue, user, "0", "0"], // ~3000 USDC
// },
// ];
it("Should deposit collateral 2000 USDC on behalf with maxValue", async function () {
const spells = [
{
connector: connectorName,
method: "depositCollateralOnBehalf",
args: [tokens.usdc.address, dsaMaxValue, user, "0", "0"], // ~3000 USDC
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.lte(
// parseUnits('1', 6)
// );
// })
await tx.wait();
expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.lte(
parseUnits('1', 6)
);
})
// it("Should withdraw 10 ETH", async function () {
// const spells = [
// {
// connector: connectorName,
// method: "withdraw",
// args: [tokens.eth.address, "10000000000000000000", "0", "0"], // 10 ETH
// },
// ];
it("Should withdraw 10 ETH", async function () {
const spells = [
{
connector: connectorName,
method: "withdraw",
args: [tokens.eth.address, "10000000000000000000", "0", "0"], // 10 ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// await tx.wait();
// expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
// parseUnits('978', 18))
// );
// })
await tx.wait();
expect(expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
parseUnits('978', 18))
);
})
// it("Should withdraw on behalf of user with maxValue", async function () {
// let ethBala = await ethers.provider.getBalance(user)
// let wethBala = await token_weth.balanceOf(user)
it("Should withdraw on behalf of user with maxValue", async function () {
let ethBala = await ethers.provider.getBalance(user)
let wethBala = await token_weth.balanceOf(user)
// const spells = [
// {
// connector: connectorName,
// method: "withdrawOnBehalf",
// args: [tokens.eth.address, dsaMaxValue, dsaWallet0.address, user, "0", "0"], // Max ETH
// },
// ];
const spells = [
{
connector: connectorName,
method: "withdrawOnBehalf",
args: [tokens.eth.address, dsaMaxValue, dsaWallet0.address, user, "0", "0"], // Max ETH
},
];
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
ethBala = await ethers.provider.getBalance(user)
wethBala = await token_weth.balanceOf(user)
// await tx.wait();
// ethBala = await ethers.provider.getBalance(user)
// wethBala = await token_weth.balanceOf(user)
})
// })
it("Should borrow WETH into DSA", async function () {
const balance = await token_weth.balanceOf(dsaWallet0.address);
const spells = [
{
connector: connectorName,
method: "borrow",
args: [tokens.weth.address, "500000000000000000", "0", "0"], // 0.5 WETH
},
];
// it("Should borrow WETH into DSA", async function () {
// const balance = await token_weth.balanceOf(dsaWallet0.address);
// const spells = [
// {
// connector: connectorName,
// method: "borrow",
// args: [tokens.weth.address, "500000000000000000", "0", "0"], // 0.5 WETH
// },
// ];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
.to.be.eq(parseUnits('5', 17));
})
// await tx.wait();
// expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
// .to.be.eq(parseUnits('5', 17));
// })
it("Should borrow WETH into user", async function () {
const balance = await token_weth.balanceOf(user);
const spells = [
{
connector: connectorName,
method: "borrowOnBehalf",
args: [tokens.weth.address, "200000000000000000", dsaWallet0.address, user, "0", "0"], // 0.7 WETH
},
];
// it("Should borrow WETH into user", async function () {
// const balance = await token_weth.balanceOf(user);
// const spells = [
// {
// connector: connectorName,
// method: "borrowOnBehalf",
// args: [tokens.weth.address, "200000000000000000", dsaWallet0.address, user, "0", "0"], // 0.7 WETH
// },
// ];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect((await token_weth.balanceOf(user)).sub(balance))
.to.be.eq(parseUnits('2', 17));
})
// await tx.wait();
// expect((await token_weth.balanceOf(user)).sub(balance))
// .to.be.eq(parseUnits('2', 17));
// })
it("Should borrow WETH into wallet1 using iteration", async function () {
const balance = await token_weth.balanceOf(dsaWallet0.address);
const spells = [
{
connector: connectorName,
method: "borrowWithMaxIterations",
args: [tokens.weth.address, "20000000000000000", dsaWallet0.address, 10, "0", "0"], // 0.02 WETH
},
];
// it("Should borrow WETH into wallet1 using iteration", async function () {
// const balance = await token_weth.balanceOf(dsaWallet0.address);
// const spells = [
// {
// connector: connectorName,
// method: "borrowWithMaxIterations",
// args: [tokens.weth.address, "20000000000000000", dsaWallet0.address, 10, "0", "0"], // 0.02 WETH
// },
// ];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
.to.be.eq(parseUnits('2', 16));
})
// await tx.wait();
// expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
// .to.be.eq(parseUnits('2', 16));
// })
it("Test withdrawCollateral ", async function () {
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ACC_USDC],
})
// it("Test withdrawCollateral ", async function () {
// await hre.network.provider.request({
// method: 'hardhat_impersonateAccount',
// params: [ACC_USDC],
// })
const signer_usdc = await ethers.getSigner(ACC_USDC)
await token_usdc.connect(signer_usdc).transfer(dsaWallet0.address, parseUnits('500', 6))
// const signer_usdc = await ethers.getSigner(ACC_USDC)
// await token_usdc.connect(signer_usdc).transfer(dsaWallet0.address, parseUnits('500', 6))
await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount',
params: [ACC_USDC],
})
// await hre.network.provider.request({
// method: 'hardhat_stopImpersonatingAccount',
// params: [ACC_USDC],
// })
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('500', 6)
);
// expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
// parseUnits('500', 6)
// );
const balance = await token_usdc.balanceOf(dsaWallet0.address);
console.log('balance: ', balance.toString());
// const balance = await token_usdc.balanceOf(dsaWallet0.address);
// console.log('balance: ', balance.toString());
const spells = [
{
connector: connectorName,
method: "depositCollateral",
args: [tokens.usdc.address, "20000000", "0", "0"], // 20 USDC
},
{
connector: connectorName,
method: "withdrawCollateral",
args: [tokens.usdc.address, "19000000", dsaWallet0.address, "0", "0"], // 19 USDC
},
];
// const spells = [
// {
// connector: connectorName,
// method: "depositCollateral",
// args: [tokens.usdc.address, "20000000", "0", "0"], // 20 USDC
// },
// {
// connector: connectorName,
// method: "withdrawCollateral",
// args: [tokens.usdc.address, "19000000", dsaWallet0.address, "0", "0"], // 19 USDC
// },
// ];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
// await tx.wait();
})
// })
it("Test withdrawCollateralOnBehalf with maxValue", async function () {
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ACC_USDC],
})
method: "hardhat_impersonateAccount",
params: [ACC_USDC]
});
const signer_usdc = await ethers.getSigner(ACC_USDC)
await token_usdc.connect(signer_usdc).transfer(dsaWallet0.address, parseUnits('500', 6))
const signer_usdc = await ethers.getSigner(ACC_USDC);
await token_usdc.connect(signer_usdc).transfer(dsaWallet0.address, parseUnits("500", 6));
await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount',
params: [ACC_USDC],
})
method: "hardhat_stopImpersonatingAccount",
params: [ACC_USDC]
});
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('500', 6)
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [user]
});
const signer_user = await ethers.getSigner(user);
const mophor = new ethers.Contract(
"0x33333aea097c193e66081E930c33020272b33333",
morpho_ABI,
ethers.provider
);
await mophor.connect(signer_user).approveManager(dsaWallet0.address, true)
await hre.network.provider.request({
method: "hardhat_stopImpersonatingAccount",
params: [user]
});
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(parseUnits("500", 6));
const balance = await token_usdc.balanceOf(dsaWallet0.address);
const spells = [
{
connector: connectorName,
method: "depositCollateralOnBehalf",
args: [tokens.usdc.address, "20000000", user, "0", "0"], // 20 USDC
args: [tokens.usdc.address, "20000000", user, "0", "0"] // 20 USDC
},
// {
// connector: connectorName,
// method: "approveManager",
// args: [user, true] // 20 USDC
// },
{
connector: connectorName,
method: "withdrawCollateralOnBehalf",
args: [tokens.usdc.address, dsaMaxValue, dsaWallet0.address, user, "0", "0"], // 20 USDC
},
args: [tokens.usdc.address, dsaMaxValue, user, user, "0", "0"] // 20 USDC
}
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('499', 6)
);
})
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(parseUnits("499", 6));
});
it("Test payback with maxValue", async function () {
await hre.network.provider.request({
@ -452,11 +453,6 @@ describe("Morpho-Aave-v3", function () {
params: [ACC_USDC],
})
await hre.network.provider.request({
method: 'hardhat_setBalance',
params: [dsaWallet0.address, "1000000000000000000"],
})
const signer_usdc = await ethers.getSigner(ACC_USDC)
await token_usdc.connect(signer_usdc).transfer(dsaWallet0.address, parseUnits('500', 6))
@ -500,19 +496,19 @@ describe("Morpho-Aave-v3", function () {
);
})
it("approve manger", async () => {
const spells = [
{
connector: connectorName,
method: "approveManager",
args: [user, true],
},
]
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
// it("approve manger", async () => {
// const spells = [
// {
// connector: connectorName,
// method: "approveManager",
// args: [user, true],
// },
// ]
// const tx = await dsaWallet0
// .connect(wallet0)
// .cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
})
// await tx.wait();
// })
});
});

View File

@ -0,0 +1,876 @@
[
{ "inputs": [], "name": "AddressIsZero", "type": "error" },
{ "inputs": [], "name": "AmountIsZero", "type": "error" },
{ "inputs": [], "name": "AssetIsCollateralOnMorpho", "type": "error" },
{ "inputs": [], "name": "AssetNotCollateralOnPool", "type": "error" },
{ "inputs": [], "name": "BorrowNotPaused", "type": "error" },
{ "inputs": [], "name": "ClaimRewardsPaused", "type": "error" },
{ "inputs": [], "name": "ExceedsMaxBasisPoints", "type": "error" },
{ "inputs": [], "name": "InvalidNonce", "type": "error" },
{ "inputs": [], "name": "InvalidSignatory", "type": "error" },
{ "inputs": [], "name": "InvalidValueS", "type": "error" },
{ "inputs": [], "name": "InvalidValueV", "type": "error" },
{ "inputs": [], "name": "MarketAlreadyCreated", "type": "error" },
{ "inputs": [], "name": "MarketIsDeprecated", "type": "error" },
{ "inputs": [], "name": "MarketIsNotListedOnAave", "type": "error" },
{ "inputs": [], "name": "MarketLtTooLow", "type": "error" },
{ "inputs": [], "name": "MarketNotCreated", "type": "error" },
{ "inputs": [], "name": "SetAsCollateralOnPoolButMarketNotCreated", "type": "error" },
{ "inputs": [], "name": "SignatureExpired", "type": "error" },
{ "inputs": [], "name": "SiloedBorrowMarket", "type": "error" },
{ "inputs": [], "name": "UnsafeCast", "type": "error" },
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferStarted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [],
"name": "addressesProvider",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "manager", "type": "address" },
{ "internalType": "bool", "name": "isAllowed", "type": "bool" }
],
"name": "approveManager",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "delegator", "type": "address" },
{ "internalType": "address", "name": "manager", "type": "address" },
{ "internalType": "bool", "name": "isAllowed", "type": "bool" },
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{
"components": [
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"internalType": "struct Types.Signature",
"name": "signature",
"type": "tuple"
}
],
"name": "approveManagerWithSig",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "uint256", "name": "maxIterations", "type": "uint256" }
],
"name": "borrow",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "borrowBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "address", "name": "onBehalf", "type": "address" }
],
"name": "claimRewards",
"outputs": [
{ "internalType": "address[]", "name": "rewardTokens", "type": "address[]" },
{ "internalType": "uint256[]", "name": "claimedAmounts", "type": "uint256[]" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "underlyings", "type": "address[]" },
{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }
],
"name": "claimToTreasury",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "collateralBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint16", "name": "reserveFactor", "type": "uint16" },
{ "internalType": "uint16", "name": "p2pIndexCursor", "type": "uint16" }
],
"name": "createMarket",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "defaultIterations",
"outputs": [
{
"components": [
{ "internalType": "uint128", "name": "repay", "type": "uint128" },
{ "internalType": "uint128", "name": "withdraw", "type": "uint128" }
],
"internalType": "struct Types.Iterations",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eModeCategoryId",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "enum Types.Position", "name": "position", "type": "uint8" }
],
"name": "getBucketsMask",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "enum Types.Position", "name": "position", "type": "uint8" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "getNext",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "increaseP2PDeltas",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "addressesProvider", "type": "address" },
{ "internalType": "uint8", "name": "eModeCategoryId", "type": "uint8" },
{ "internalType": "address", "name": "positionsManager", "type": "address" },
{
"components": [
{ "internalType": "uint128", "name": "repay", "type": "uint128" },
{ "internalType": "uint128", "name": "withdraw", "type": "uint128" }
],
"internalType": "struct Types.Iterations",
"name": "defaultIterations",
"type": "tuple"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "isClaimRewardsPaused",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "delegator", "type": "address" },
{ "internalType": "address", "name": "manager", "type": "address" }
],
"name": "isManagedBy",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlyingBorrowed", "type": "address" },
{ "internalType": "address", "name": "underlyingCollateral", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "liquidate",
"outputs": [
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "uint256", "name": "", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "liquidityData",
"outputs": [
{
"components": [
{ "internalType": "uint256", "name": "borrowable", "type": "uint256" },
{ "internalType": "uint256", "name": "maxDebt", "type": "uint256" },
{ "internalType": "uint256", "name": "debt", "type": "uint256" }
],
"internalType": "struct Types.LiquidityData",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "underlying", "type": "address" }],
"name": "market",
"outputs": [
{
"components": [
{
"components": [
{
"components": [
{ "internalType": "uint128", "name": "poolIndex", "type": "uint128" },
{ "internalType": "uint128", "name": "p2pIndex", "type": "uint128" }
],
"internalType": "struct Types.MarketSideIndexes",
"name": "supply",
"type": "tuple"
},
{
"components": [
{ "internalType": "uint128", "name": "poolIndex", "type": "uint128" },
{ "internalType": "uint128", "name": "p2pIndex", "type": "uint128" }
],
"internalType": "struct Types.MarketSideIndexes",
"name": "borrow",
"type": "tuple"
}
],
"internalType": "struct Types.Indexes",
"name": "indexes",
"type": "tuple"
},
{
"components": [
{
"components": [
{ "internalType": "uint256", "name": "scaledDelta", "type": "uint256" },
{ "internalType": "uint256", "name": "scaledP2PTotal", "type": "uint256" }
],
"internalType": "struct Types.MarketSideDelta",
"name": "supply",
"type": "tuple"
},
{
"components": [
{ "internalType": "uint256", "name": "scaledDelta", "type": "uint256" },
{ "internalType": "uint256", "name": "scaledP2PTotal", "type": "uint256" }
],
"internalType": "struct Types.MarketSideDelta",
"name": "borrow",
"type": "tuple"
}
],
"internalType": "struct Types.Deltas",
"name": "deltas",
"type": "tuple"
},
{ "internalType": "address", "name": "underlying", "type": "address" },
{
"components": [
{ "internalType": "bool", "name": "isP2PDisabled", "type": "bool" },
{ "internalType": "bool", "name": "isSupplyPaused", "type": "bool" },
{ "internalType": "bool", "name": "isSupplyCollateralPaused", "type": "bool" },
{ "internalType": "bool", "name": "isBorrowPaused", "type": "bool" },
{ "internalType": "bool", "name": "isWithdrawPaused", "type": "bool" },
{ "internalType": "bool", "name": "isWithdrawCollateralPaused", "type": "bool" },
{ "internalType": "bool", "name": "isRepayPaused", "type": "bool" },
{ "internalType": "bool", "name": "isLiquidateCollateralPaused", "type": "bool" },
{ "internalType": "bool", "name": "isLiquidateBorrowPaused", "type": "bool" },
{ "internalType": "bool", "name": "isDeprecated", "type": "bool" }
],
"internalType": "struct Types.PauseStatuses",
"name": "pauseStatuses",
"type": "tuple"
},
{ "internalType": "bool", "name": "isCollateral", "type": "bool" },
{ "internalType": "address", "name": "variableDebtToken", "type": "address" },
{ "internalType": "uint32", "name": "lastUpdateTimestamp", "type": "uint32" },
{ "internalType": "uint16", "name": "reserveFactor", "type": "uint16" },
{ "internalType": "uint16", "name": "p2pIndexCursor", "type": "uint16" },
{ "internalType": "address", "name": "aToken", "type": "address" },
{ "internalType": "address", "name": "stableDebtToken", "type": "address" },
{ "internalType": "uint256", "name": "idleSupply", "type": "uint256" }
],
"internalType": "struct Types.Market",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "marketsCreated",
"outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pendingOwner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pool",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "positionsManager",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" }
],
"name": "repay",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{
"components": [
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"internalType": "struct Types.Signature",
"name": "signature",
"type": "tuple"
}
],
"name": "repayWithPermit",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "rewardsManager",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "scaledCollateralBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "scaledP2PBorrowBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "scaledP2PSupplyBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "scaledPoolBorrowBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "scaledPoolSupplyBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isCollateral", "type": "bool" }
],
"name": "setAssetIsCollateral",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isCollateral", "type": "bool" }
],
"name": "setAssetIsCollateralOnPool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"components": [
{ "internalType": "uint128", "name": "repay", "type": "uint128" },
{ "internalType": "uint128", "name": "withdraw", "type": "uint128" }
],
"internalType": "struct Types.Iterations",
"name": "defaultIterations",
"type": "tuple"
}
],
"name": "setDefaultIterations",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsBorrowPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bool", "name": "isPaused", "type": "bool" }],
"name": "setIsClaimRewardsPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isDeprecated", "type": "bool" }
],
"name": "setIsDeprecated",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsLiquidateBorrowPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsLiquidateCollateralPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isP2PDisabled", "type": "bool" }
],
"name": "setIsP2PDisabled",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bool", "name": "isPaused", "type": "bool" }],
"name": "setIsPausedForAllMarkets",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsRepayPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsSupplyCollateralPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsSupplyPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsWithdrawCollateralPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "bool", "name": "isPaused", "type": "bool" }
],
"name": "setIsWithdrawPaused",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint16", "name": "p2pIndexCursor", "type": "uint16" }
],
"name": "setP2PIndexCursor",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "positionsManager", "type": "address" }],
"name": "setPositionsManager",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint16", "name": "newReserveFactor", "type": "uint16" }
],
"name": "setReserveFactor",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "rewardsManager", "type": "address" }],
"name": "setRewardsManager",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "treasuryVault", "type": "address" }],
"name": "setTreasuryVault",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "uint256", "name": "maxIterations", "type": "uint256" }
],
"name": "supply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "supplyBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" }
],
"name": "supplyCollateral",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{
"components": [
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"internalType": "struct Types.Signature",
"name": "signature",
"type": "tuple"
}
],
"name": "supplyCollateralWithPermit",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "uint256", "name": "maxIterations", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{
"components": [
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"internalType": "struct Types.Signature",
"name": "signature",
"type": "tuple"
}
],
"name": "supplyWithPermit",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "treasuryVault",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "underlying", "type": "address" }],
"name": "updatedIndexes",
"outputs": [
{
"components": [
{
"components": [
{ "internalType": "uint256", "name": "poolIndex", "type": "uint256" },
{ "internalType": "uint256", "name": "p2pIndex", "type": "uint256" }
],
"internalType": "struct Types.MarketSideIndexes256",
"name": "supply",
"type": "tuple"
},
{
"components": [
{ "internalType": "uint256", "name": "poolIndex", "type": "uint256" },
{ "internalType": "uint256", "name": "p2pIndex", "type": "uint256" }
],
"internalType": "struct Types.MarketSideIndexes256",
"name": "borrow",
"type": "tuple"
}
],
"internalType": "struct Types.Indexes256",
"name": "indexes",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "userBorrows",
"outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "userCollaterals",
"outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "userNonce",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "uint256", "name": "maxIterations", "type": "uint256" }
],
"name": "withdraw",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "underlying", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "onBehalf", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" }
],
"name": "withdrawCollateral",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
}
]