mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
update logic
This commit is contained in:
parent
8cd4a08f0f
commit
bb8914afde
|
@ -25,4 +25,6 @@ interface IMorphoCore {
|
||||||
function withdrawCollateral(address underlying, uint256 amount, address onBehalf, address receiver)
|
function withdrawCollateral(address underlying, uint256 amount, address onBehalf, address receiver)
|
||||||
external
|
external
|
||||||
returns (uint256 withdrawn);
|
returns (uint256 withdrawn);
|
||||||
|
|
||||||
|
function approveManager(address manager, bool isAllowed) external;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, max_iteration);
|
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, max_iteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -310,7 +314,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, max_iteration);
|
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, max_iteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -349,7 +357,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, _maxIteration);
|
MORPHO_AAVE_V3.borrow(_token, _amt, address(this), _receiver, _maxIteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -389,7 +401,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, _maxIteration);
|
MORPHO_AAVE_V3.borrow(_token, _amt, _onBehalf, _receiver, _maxIteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -428,7 +444,12 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.withdraw(_token, _amt, address(this), _receiver, max_iteration);
|
MORPHO_AAVE_V3.withdraw(_token, _amt, address(this), _receiver, max_iteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
_eventName = "LogWithdraw(address,uint256,address,uint256,uint256)";
|
_eventName = "LogWithdraw(address,uint256,address,uint256,uint256)";
|
||||||
|
@ -464,7 +485,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
uint256 _amt = getUint(_getId, _amount);
|
uint256 _amt = getUint(_getId, _amount);
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, max_iteration);
|
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, max_iteration);
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -504,7 +529,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, _maxIteration);
|
MORPHO_AAVE_V3.withdraw(_token, _amt, _onBehalf, _receiver, _maxIteration);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -534,7 +563,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, address(this), _receiver);
|
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, address(this), _receiver);
|
||||||
|
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -563,7 +596,11 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
uint256 _amt = getUint(_getId, _amount);
|
uint256 _amt = getUint(_getId, _amount);
|
||||||
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
address _token = _tokenAddress == ethAddr ? wethAddr : _tokenAddress;
|
||||||
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, _onBehalf, _receiver);
|
MORPHO_AAVE_V3.withdrawCollateral(_token, _amt, _onBehalf, _receiver);
|
||||||
// convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
if(_tokenAddress == ethAddr) {
|
||||||
|
if(_receiver == address(this))
|
||||||
|
convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt);
|
||||||
|
else revert("cannot convert");
|
||||||
|
}
|
||||||
|
|
||||||
setUint(_setId, _amt);
|
setUint(_setId, _amt);
|
||||||
|
|
||||||
|
@ -676,6 +713,13 @@ abstract contract MorphoAaveV3 is Helpers, Events {
|
||||||
_setId
|
_setId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice Approves a `manager` to borrow/withdraw on behalf of the sender.
|
||||||
|
/// @param _manager The address of the manager.
|
||||||
|
/// @param _isAllowed Whether `manager` is allowed to manage `msg.sender`'s position or not.
|
||||||
|
function approveManager(address _manager, bool _isAllowed) external {
|
||||||
|
MORPHO_AAVE_V3.approveManager(_manager, _isAllowed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV3MorphoAaveV3 is MorphoAaveV3 {
|
contract ConnectV3MorphoAaveV3 is MorphoAaveV3 {
|
||||||
|
|
|
@ -123,27 +123,27 @@ describe("Morpho-Aave-v3", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it("Deposit 1 DAI into DSA wallet", async function () {
|
it("Deposit 1 DAI into DSA wallet", async function () {
|
||||||
|
|
||||||
// await hre.network.provider.request({
|
await hre.network.provider.request({
|
||||||
// method: 'hardhat_impersonateAccount',
|
method: 'hardhat_impersonateAccount',
|
||||||
// params: [ACC_DAI],
|
params: [ACC_DAI],
|
||||||
// })
|
})
|
||||||
|
|
||||||
// const signer_dai = await ethers.getSigner(ACC_DAI)
|
const signer_dai = await ethers.getSigner(ACC_DAI)
|
||||||
// await token_dai.connect(signer_dai).transfer(wallet0.getAddress(), Dai)
|
await token_dai.connect(signer_dai).transfer(wallet0.getAddress(), Dai)
|
||||||
|
|
||||||
// await hre.network.provider.request({
|
await hre.network.provider.request({
|
||||||
// method: 'hardhat_stopImpersonatingAccount',
|
method: 'hardhat_stopImpersonatingAccount',
|
||||||
// params: [ACC_DAI],
|
params: [ACC_DAI],
|
||||||
// })
|
})
|
||||||
|
|
||||||
// await token_dai.connect(wallet0).transfer(dsaWallet0.address, Dai);
|
await token_dai.connect(wallet0).transfer(dsaWallet0.address, Dai);
|
||||||
|
|
||||||
// expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
|
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
// parseUnits('1', 18)
|
parseUnits('1', 18)
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Main", function () {
|
describe("Main", function () {
|
||||||
|
@ -281,7 +281,7 @@ describe("Morpho-Aave-v3", function () {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should withdraw ETH max on behalf", async function () {
|
it("Should revert because behalf is different with dsa address", async function () {
|
||||||
const spells = [
|
const spells = [
|
||||||
{
|
{
|
||||||
connector: connectorName,
|
connector: connectorName,
|
||||||
|
@ -290,13 +290,10 @@ describe("Morpho-Aave-v3", function () {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const tx = await dsaWallet0
|
await expect(dsaWallet0
|
||||||
.connect(wallet0)
|
.connect(wallet0)
|
||||||
.cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress())).to.be.revertedWith("cannot convert");
|
||||||
|
|
||||||
await tx.wait();
|
|
||||||
console.log("------------user balance----------",(await token_weth.balanceOf(user)).toString())
|
|
||||||
expect(await token_weth.balanceOf(user)).to.be.gte(parseUnits('1', 18))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should borrow WETH into DSA", async function () {
|
it("Should borrow WETH into DSA", async function () {
|
||||||
|
@ -314,7 +311,6 @@ describe("Morpho-Aave-v3", function () {
|
||||||
.cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
await tx.wait();
|
await tx.wait();
|
||||||
console.log("====================", balance.toString(), (await token_weth.balanceOf(dsaWallet0.address)).toString())
|
|
||||||
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
|
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
|
||||||
.to.be.eq(parseUnits('5', 17));
|
.to.be.eq(parseUnits('5', 17));
|
||||||
})
|
})
|
||||||
|
@ -334,7 +330,6 @@ describe("Morpho-Aave-v3", function () {
|
||||||
.cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
await tx.wait();
|
await tx.wait();
|
||||||
console.log("====================", balance.toString(), (await token_weth.balanceOf(user)).toString())
|
|
||||||
expect((await token_weth.balanceOf(user)).sub(balance))
|
expect((await token_weth.balanceOf(user)).sub(balance))
|
||||||
.to.be.eq(parseUnits('2', 17));
|
.to.be.eq(parseUnits('2', 17));
|
||||||
})
|
})
|
||||||
|
@ -345,7 +340,7 @@ describe("Morpho-Aave-v3", function () {
|
||||||
{
|
{
|
||||||
connector: connectorName,
|
connector: connectorName,
|
||||||
method: "borrowWithMaxIterations",
|
method: "borrowWithMaxIterations",
|
||||||
args: [tokens.weth.address, "200000000000000000", dsaWallet0.address, 10, "0", "0"], // 0.7 WETH
|
args: [tokens.weth.address, "20000000000000000", dsaWallet0.address, 10, "0", "0"], // 0.7 WETH
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -356,199 +351,199 @@ describe("Morpho-Aave-v3", function () {
|
||||||
await tx.wait();
|
await tx.wait();
|
||||||
console.log("====================", balance.toString(), (await token_weth.balanceOf(dsaWallet0.address)).toString())
|
console.log("====================", balance.toString(), (await token_weth.balanceOf(dsaWallet0.address)).toString())
|
||||||
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
|
expect((await token_weth.balanceOf(dsaWallet0.address)).sub(balance))
|
||||||
.to.be.eq(parseUnits('2', 17));
|
.to.be.eq(parseUnits('2', 16));
|
||||||
})
|
})
|
||||||
|
|
||||||
// it("Should borrow DAI into DSA on behalf", async function () {
|
it("Should borrow DAI into DSA on behalf", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "borrowOnBehalf",
|
method: "borrowOnBehalf",
|
||||||
// args: [tokens.dai.address, "10000000000000000000", user, dsaWallet0.address, "0", "0"], // 10 DAI
|
args: [tokens.dai.address, "10000000000000000000", user, dsaWallet0.address, "0", "0"], // 10 DAI
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
||||||
// .to.be.gte(parseUnits('21', 18));
|
.to.be.gte(parseUnits('21', 18));
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should borrow DAI into DSA with MaxIteration", async function () {
|
it("Should borrow DAI into DSA with MaxIteration", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "borrowWithMaxIterations",
|
method: "borrowWithMaxIterations",
|
||||||
// args: [tokens.dai.address, "10000000000000000000", dsaWallet0.address, 5, "0", "0"], // 10 DAI
|
args: [tokens.dai.address, "10000000000000000000", dsaWallet0.address, 5, "0", "0"], // 10 DAI
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
||||||
// .to.be.gte(parseUnits('31', 18));
|
.to.be.gte(parseUnits('31', 18));
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should borrow DAI into DSA on behalf with MaxIteration", async function () {
|
it("Should borrow DAI into DSA on behalf with MaxIteration", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "borrowOnBehalfWithMaxIterations",
|
method: "borrowOnBehalfWithMaxIterations",
|
||||||
// args: [tokens.dai.address, "10000000000000000000", user, dsaWallet0.address, 5, "0", "0"], // 10 DAI
|
args: [tokens.dai.address, "10000000000000000000", user, dsaWallet0.address, 5, "0", "0"], // 10 DAI
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address))
|
||||||
// .to.be.gte(parseUnits('41', 18));
|
.to.be.gte(parseUnits('41', 18));
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should payback DAI MAX", async function () {
|
it("Should payback DAI MAX", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "payback",
|
method: "payback",
|
||||||
// args: [tokens.dai.address, dsaMaxValue, "0", "0"], // Max DAI
|
args: [tokens.dai.address, dsaMaxValue, "0", "0"], // Max DAI
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.lte(
|
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.lte(
|
||||||
// parseUnits('1', 18)
|
parseUnits('1', 18)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Should payback ETH on behalf", async function () {
|
||||||
|
const spells = [
|
||||||
|
{
|
||||||
|
connector: connectorName,
|
||||||
|
method: "paybackOnBehalf",
|
||||||
|
args: [tokens.eth.address, user, dsaMaxValue, "0", "0"], // Max ETH
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const tx = await dsaWallet0
|
||||||
|
.connect(wallet0)
|
||||||
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
|
await tx.wait();
|
||||||
|
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||||
|
parseUnits('125', 18)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Should withdraw 8 USDC on behalf", async function () {
|
||||||
|
const spells = [
|
||||||
|
{
|
||||||
|
connector: connectorName,
|
||||||
|
method: "withdrawOnBehalf",
|
||||||
|
args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, "0", "0"], // 8 USDC
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const tx = await dsaWallet0
|
||||||
|
.connect(wallet0)
|
||||||
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
|
await tx.wait();
|
||||||
|
console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
||||||
|
// expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
|
// parseUnits('398', 6))
|
||||||
// );
|
// );
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should payback ETH on behalf", async function () {
|
it("Should withdraw 8 USDC on behalf", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "paybackOnBehalf",
|
method: "withdrawOnBehalf",
|
||||||
// args: [tokens.eth.address, user, dsaMaxValue, "0", "0"], // Max ETH
|
args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, "0", "0"], // 8 USDC
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
||||||
// parseUnits('125', 18)
|
// expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
|
// parseUnits('398', 6))
|
||||||
// );
|
// );
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should withdraw 8 USDC on behalf", async function () {
|
it("Should withdraw 8 USDC on behalf with MaxIteration", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "withdrawOnBehalf",
|
method: "withdrawWithMaxIterations",
|
||||||
// args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, "0", "0"], // 8 USDC
|
args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
||||||
// // expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
// expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
// // parseUnits('398', 6))
|
// parseUnits('398', 6))
|
||||||
// // );
|
// );
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should withdraw 8 USDC on behalf", async function () {
|
it("Should withdraw 8 USDC as collateral", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "withdrawOnBehalf",
|
method: "withdrawCollateral",
|
||||||
// args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, "0", "0"], // 8 USDC
|
args: [tokens.usdc.address, "8000000", dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
||||||
// // expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
// expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
// // parseUnits('398', 6))
|
// parseUnits('398', 6))
|
||||||
// // );
|
// );
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should withdraw 8 USDC on behalf with MaxIteration", async function () {
|
it("Should withdraw 8 USDC as collateral on behalf", async function () {
|
||||||
// const spells = [
|
const spells = [
|
||||||
// {
|
{
|
||||||
// connector: connectorName,
|
connector: connectorName,
|
||||||
// method: "withdrawWithMaxIterations",
|
method: "withdrawCollateralOnBehalf",
|
||||||
// args: [tokens.usdc.address, "8000000", user, dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
args: [tokens.usdc.address, "8000000",user, dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
const tx = await dsaWallet0
|
||||||
// .connect(wallet0)
|
.connect(wallet0)
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
.cast(...encodeSpells(spells), wallet1.getAddress());
|
||||||
|
|
||||||
// await tx.wait();
|
await tx.wait();
|
||||||
// console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
||||||
// // expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
// expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||||
// // parseUnits('398', 6))
|
// parseUnits('398', 6))
|
||||||
// // );
|
// );
|
||||||
// })
|
})
|
||||||
|
|
||||||
// it("Should withdraw 8 USDC as collateral", async function () {
|
|
||||||
// const spells = [
|
|
||||||
// {
|
|
||||||
// connector: connectorName,
|
|
||||||
// method: "withdrawCollateral",
|
|
||||||
// args: [tokens.usdc.address, "8000000", dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
|
||||||
// .connect(wallet0)
|
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
|
||||||
|
|
||||||
// await tx.wait();
|
|
||||||
// console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
|
||||||
// // expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
|
||||||
// // parseUnits('398', 6))
|
|
||||||
// // );
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it("Should withdraw 8 USDC as collateral on behalf", async function () {
|
|
||||||
// const spells = [
|
|
||||||
// {
|
|
||||||
// connector: connectorName,
|
|
||||||
// method: "withdrawCollateralOnBehalf",
|
|
||||||
// args: [tokens.usdc.address, "8000000",user, dsaWallet0.address, 5, "0", "0"], // 8 USDC
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// const tx = await dsaWallet0
|
|
||||||
// .connect(wallet0)
|
|
||||||
// .cast(...encodeSpells(spells), wallet1.getAddress());
|
|
||||||
|
|
||||||
// await tx.wait();
|
|
||||||
// console.log("----balance of USDC----", (await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).toString())
|
|
||||||
// // expect(expect(await token_usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
|
||||||
// // parseUnits('398', 6))
|
|
||||||
// // );
|
|
||||||
// })
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user