mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	new fixes
This commit is contained in:
		
							parent
							
								
									79d88be34e
								
							
						
					
					
						commit
						34a4ad41bd
					
				| 
						 | 
				
			
			@ -52,8 +52,8 @@ contract Events {
 | 
			
		|||
	);
 | 
			
		||||
 | 
			
		||||
	event LogETransfer(
 | 
			
		||||
		uint256 subAccount1,
 | 
			
		||||
		uint256 subAccount2,
 | 
			
		||||
		uint256 subAccountFrom,
 | 
			
		||||
		uint256 subAccountTo,
 | 
			
		||||
		address token,
 | 
			
		||||
		uint256 amount,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
| 
						 | 
				
			
			@ -61,31 +61,20 @@ contract Events {
 | 
			
		|||
	);
 | 
			
		||||
 | 
			
		||||
	event LogDTransfer(
 | 
			
		||||
		uint256 subAccount1,
 | 
			
		||||
		uint256 subAccount2,
 | 
			
		||||
		address token,
 | 
			
		||||
		uint256 amount,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
		uint256 setId
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	event LogApproveDebt(
 | 
			
		||||
		uint256 subAccountId,
 | 
			
		||||
		address debtReceiver,
 | 
			
		||||
		address token,
 | 
			
		||||
		uint256 amount,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
		uint256 setId
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	event LogSwap(
 | 
			
		||||
		uint256 subAccountFrom,
 | 
			
		||||
		uint256 subAccountTo,
 | 
			
		||||
		address buyAddr,
 | 
			
		||||
		address sellAddr,
 | 
			
		||||
		uint256 sellAmt,
 | 
			
		||||
		uint256 unitAmt,
 | 
			
		||||
		bytes callData
 | 
			
		||||
		address token,
 | 
			
		||||
		uint256 amount,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
		uint256 setId
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	event LogApproveSpenderDebt(
 | 
			
		||||
		uint256 subAccountId,
 | 
			
		||||
		address debtSender,
 | 
			
		||||
		address token,
 | 
			
		||||
		uint256 amount,
 | 
			
		||||
		uint256 setId
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	event LogEnterMarket(uint256 subAccountId, address[] newMarkets);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,7 +95,9 @@ abstract contract Euler is Helpers {
 | 
			
		|||
 | 
			
		||||
		TokenInterface tokenContract = TokenInterface(_token);
 | 
			
		||||
		IEulerEToken eToken = IEulerEToken(markets.underlyingToEToken(_token));
 | 
			
		||||
		_amt = _amt == uint256(-1) ?  eToken.balanceOfUnderlying(address(this)) : _amt;
 | 
			
		||||
 | 
			
		||||
		address _subAccount = getSubAccount(address(this), subAccount);
 | 
			
		||||
		_amt = _amt == uint256(-1) ?  eToken.balanceOfUnderlying(_subAccount) : _amt;
 | 
			
		||||
		uint256 initialBal = tokenContract.balanceOf(address(this));
 | 
			
		||||
 | 
			
		||||
		eToken.withdraw(subAccount, _amt);
 | 
			
		||||
| 
						 | 
				
			
			@ -178,7 +180,8 @@ abstract contract Euler is Helpers {
 | 
			
		|||
			markets.underlyingToDToken(_token)
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		_amt = _amt == uint256(-1) ? borrowedDToken.balanceOf(address(this)) : _amt;
 | 
			
		||||
		address _subAccount = getSubAccount(address(this), subAccount);
 | 
			
		||||
		_amt = _amt == uint256(-1) ? borrowedDToken.balanceOf(_subAccount) : _amt;
 | 
			
		||||
		if (isEth) {
 | 
			
		||||
			convertEthToWeth(isEth, TokenInterface(_token), _amt);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -299,15 +302,15 @@ abstract contract Euler is Helpers {
 | 
			
		|||
 | 
			
		||||
		IEulerEToken eToken = IEulerEToken(markets.underlyingToEToken(_token));
 | 
			
		||||
 | 
			
		||||
		address _subAccountFromAddr = getSubAccount(address(this), subAccountFrom);
 | 
			
		||||
		address _subAccountToAddr = getSubAccount(address(this), subAccountTo);
 | 
			
		||||
 | 
			
		||||
		_amt = _amt == uint256(-1)
 | 
			
		||||
			? eToken.balanceOf(address(this))
 | 
			
		||||
			? eToken.balanceOf(_subAccountFromAddr)
 | 
			
		||||
			: _amt;
 | 
			
		||||
 | 
			
		||||
		if (isEth) convertEthToWeth(isEth, TokenInterface(_token), _amt);
 | 
			
		||||
 | 
			
		||||
		address _subAccountFromAddr = getSubAccount(address(this), subAccountFrom);
 | 
			
		||||
		address _subAccountToAddr = getSubAccount(address(this), subAccountTo);
 | 
			
		||||
 | 
			
		||||
		eToken.transferFrom(_subAccountFromAddr, _subAccountToAddr, _amt);
 | 
			
		||||
 | 
			
		||||
		setUint(setId, _amt);
 | 
			
		||||
| 
						 | 
				
			
			@ -352,14 +355,15 @@ abstract contract Euler is Helpers {
 | 
			
		|||
 | 
			
		||||
		IEulerDToken dToken = IEulerDToken(markets.underlyingToDToken(_token));
 | 
			
		||||
 | 
			
		||||
		address _subAccountFromAddr = getSubAccount(address(this), subAccountFrom);
 | 
			
		||||
		address _subAccountToAddr = getSubAccount(address(this), subAccountTo);
 | 
			
		||||
 | 
			
		||||
		_amt = _amt == uint256(-1)
 | 
			
		||||
			? dToken.balanceOf(address(this))
 | 
			
		||||
			? dToken.balanceOf(_subAccountFromAddr)
 | 
			
		||||
			: _amt;
 | 
			
		||||
 | 
			
		||||
		if (isEth) convertEthToWeth(isEth, TokenInterface(_token), _amt);
 | 
			
		||||
 | 
			
		||||
		address _subAccountFromAddr = getSubAccount(address(this), subAccountFrom);
 | 
			
		||||
		address _subAccountToAddr = getSubAccount(address(this), subAccountTo);
 | 
			
		||||
		dToken.transferFrom(_subAccountFromAddr, _subAccountToAddr, _amt);
 | 
			
		||||
 | 
			
		||||
		setUint(setId, _amt);
 | 
			
		||||
| 
						 | 
				
			
			@ -405,8 +409,8 @@ abstract contract Euler is Helpers {
 | 
			
		|||
 | 
			
		||||
		setUint(setId, amt);
 | 
			
		||||
 | 
			
		||||
		_eventName = "LogApproveDebt(uint256,address,address,uint256)";
 | 
			
		||||
		_eventParam = abi.encode(subAccountId, debtSender, token, amt);
 | 
			
		||||
		_eventName = "LogApproveSpenderDebt(uint256,address,address,uint256,uint256)";
 | 
			
		||||
		_eventParam = abi.encode(subAccountId, debtSender, token, amt, setId);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -412,7 +412,7 @@ describe("Euler", function () {
 | 
			
		|||
      const spell = [
 | 
			
		||||
        {
 | 
			
		||||
          connector: connectorName,
 | 
			
		||||
          method: "approveDebt",
 | 
			
		||||
          method: "approveSpenderDebt",
 | 
			
		||||
          args: ["0", "0x85c2ac24a8BD9Ff6E2Ef6cf76C198E36550f41D7", tokens.dai.address, "10000000", "0"],
 | 
			
		||||
        },
 | 
			
		||||
      ];
 | 
			
		||||
| 
						 | 
				
			
			@ -502,5 +502,37 @@ describe("Euler", function () {
 | 
			
		|||
 | 
			
		||||
      await txn.wait();
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it("Should deposit in sub account 4", async function () {
 | 
			
		||||
 | 
			
		||||
      const spells = [
 | 
			
		||||
        {
 | 
			
		||||
          connector: connectorName,
 | 
			
		||||
          method: "deposit",
 | 
			
		||||
          args: ["4", tokens.weth.address, "1000000000000000000", "true", "0", "0"],
 | 
			
		||||
        },
 | 
			
		||||
      ];
 | 
			
		||||
 | 
			
		||||
      const tx = await dsaWallet0
 | 
			
		||||
          .connect(wallet0)
 | 
			
		||||
          .cast(...encodeSpells(spells), wallet1.getAddress());
 | 
			
		||||
 | 
			
		||||
      await tx.wait();
 | 
			
		||||
    })
 | 
			
		||||
    it("Should withdraw from sub account 4", async function () {
 | 
			
		||||
      const spell = [
 | 
			
		||||
        {
 | 
			
		||||
          connector: connectorName,
 | 
			
		||||
          method: "withdraw",
 | 
			
		||||
          args: ["4", tokens.weth.address, "115792089237316195423570985008687907853269984665640564039457584007913129639935", "0", "0"],
 | 
			
		||||
        },
 | 
			
		||||
      ];
 | 
			
		||||
 | 
			
		||||
      const txn = await dsaWallet0
 | 
			
		||||
          .connect(wallet0)
 | 
			
		||||
          .cast(...encodeSpells(spell), wallet1.getAddress());
 | 
			
		||||
 | 
			
		||||
      await txn.wait();
 | 
			
		||||
    })
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user