mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge branch 'feat/deploy-from-cmd' of https://github.com/Instadapp/dsa-connectors into feat/deploy-from-cmd
This commit is contained in:
commit
a55585136e
11
.github/workflows/status.yml
vendored
11
.github/workflows/status.yml
vendored
|
@ -29,7 +29,8 @@ jobs:
|
|||
- name: Run status checks
|
||||
id: status_check
|
||||
run: |
|
||||
output=$(node ./status-checks)
|
||||
# Run status checks, Remove ANSI colors from the text
|
||||
output=$(node ./status-checks | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g')
|
||||
# Escape newlines so _all_ the output is included in the set-output
|
||||
output="${output//'%'/'%25'}"
|
||||
output="${output//$'\n'/'%0A'}"
|
||||
|
@ -42,7 +43,7 @@ jobs:
|
|||
uses: bubkoo/auto-comment@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
pullRequestSynchronize: "${{ steps.status_check.outputs.status_check_output }}"
|
||||
pullRequestAssigned: "${{ steps.status_check.outputs.status_check_output }}"
|
||||
pullRequestOpened: "${{ steps.status_check.outputs.status_check_output }}"
|
||||
pullRequestReopened: "${{ steps.status_check.outputs.status_check_output }}"
|
||||
pullRequestSynchronize: "```${{ steps.status_check.outputs.status_check_output }}```"
|
||||
pullRequestAssigned: "```${{ steps.status_check.outputs.status_check_output }}```"
|
||||
pullRequestOpened: "```${{ steps.status_check.outputs.status_check_output }}```"
|
||||
pullRequestReopened: "```${{ steps.status_check.outputs.status_check_output }}```"
|
||||
|
|
|
@ -53,4 +53,3 @@ Few things to consider while writing the connector:
|
|||
### Support
|
||||
|
||||
If you can't find something you're looking for or have any questions, ask them at our developers community on [Discord](https://discord.gg/83vvrnY) or simply send an [Email](mailto:info@instadapp.io).
|
||||
|
||||
|
|
20
contracts/mainnet/connectors/basic-ERC1155/events.sol
Normal file
20
contracts/mainnet/connectors/basic-ERC1155/events.sol
Normal file
|
@ -0,0 +1,20 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogDepositERC1155(
|
||||
address indexed erc1155,
|
||||
address from,
|
||||
uint256 tokenId,
|
||||
uint256 amount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
event LogWithdrawERC1155(
|
||||
address indexed erc1155,
|
||||
uint256 tokenId,
|
||||
address indexed to,
|
||||
uint256 amount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
}
|
93
contracts/mainnet/connectors/basic-ERC1155/main.sol
Normal file
93
contracts/mainnet/connectors/basic-ERC1155/main.sol
Normal file
|
@ -0,0 +1,93 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Basic.
|
||||
* @dev Deposit & Withdraw from ERC1155 DSA.
|
||||
*/
|
||||
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
|
||||
|
||||
import {DSMath} from "../../common/math.sol";
|
||||
import {Basic} from "../../common/basic.sol";
|
||||
import {Events} from "./events.sol";
|
||||
|
||||
abstract contract BasicResolver is Events, DSMath, Basic {
|
||||
/**
|
||||
* @dev Deposit Assets To Smart Account.
|
||||
* @notice Deposit a ERC1155 token to DSA
|
||||
* @param token Address of token.
|
||||
* @param tokenId ID of token.
|
||||
* @param amount Amount to deposit.
|
||||
* @param getId ID to retrieve amount.
|
||||
* @param setId ID stores the amount.
|
||||
*/
|
||||
function depositERC1155(
|
||||
address token,
|
||||
uint256 tokenId,
|
||||
uint256 amount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amount = getUint(getId, amount);
|
||||
|
||||
IERC1155 tokenContract = IERC1155(token);
|
||||
tokenContract.safeTransferFrom(
|
||||
msg.sender,
|
||||
address(this),
|
||||
tokenId,
|
||||
_amount,
|
||||
""
|
||||
);
|
||||
|
||||
setUint(setId, _amount);
|
||||
|
||||
_eventName = "LogDepositERC1155(address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(
|
||||
token,
|
||||
msg.sender,
|
||||
tokenId,
|
||||
_amount,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw Assets To Smart Account.
|
||||
* @notice Withdraw a ERC1155 token from DSA
|
||||
* @param token Address of the token.
|
||||
* @param tokenId ID of token.
|
||||
* @param to The address to receive the token upon withdrawal
|
||||
* @param amount Amount to withdraw.
|
||||
* @param getId ID to retrieve amount.
|
||||
* @param setId ID stores the amount.
|
||||
*/
|
||||
function withdrawERC1155(
|
||||
address token,
|
||||
uint256 tokenId,
|
||||
address payable to,
|
||||
uint256 amount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amount = getUint(getId, amount);
|
||||
IERC1155 tokenContract = IERC1155(token);
|
||||
tokenContract.safeTransferFrom(address(this), to, tokenId, _amount, "");
|
||||
|
||||
setUint(setId, _amount);
|
||||
|
||||
_eventName = "LogWithdrawERC1155(address,uint256,address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, tokenId, to, _amount, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2BasicERC1155 is BasicResolver {
|
||||
string public constant name = "BASIC-ERC1155-v1.0";
|
||||
}
|
18
contracts/mainnet/connectors/basic-ERC721/events.sol
Normal file
18
contracts/mainnet/connectors/basic-ERC721/events.sol
Normal file
|
@ -0,0 +1,18 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogDepositERC721(
|
||||
address indexed erc721,
|
||||
address from,
|
||||
uint256 tokenId,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
event LogWithdrawERC721(
|
||||
address indexed erc721,
|
||||
uint256 tokenId,
|
||||
address indexed to,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
}
|
76
contracts/mainnet/connectors/basic-ERC721/main.sol
Normal file
76
contracts/mainnet/connectors/basic-ERC721/main.sol
Normal file
|
@ -0,0 +1,76 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Basic.
|
||||
* @dev Deposit & Withdraw ERC721 from DSA.
|
||||
*/
|
||||
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
|
||||
import {DSMath} from "../../common/math.sol";
|
||||
import {Basic} from "../../common/basic.sol";
|
||||
import {Events} from "./events.sol";
|
||||
|
||||
abstract contract BasicResolver is Events, DSMath, Basic {
|
||||
/**
|
||||
* @dev Deposit Assets To Smart Account.
|
||||
* @notice Deposit a ERC721 token to DSA
|
||||
* @param token Address of token.
|
||||
* @param tokenId ID of token.
|
||||
* @param getId ID to retrieve tokenId.
|
||||
* @param setId ID stores the tokenId.
|
||||
*/
|
||||
function depositERC721(
|
||||
address token,
|
||||
uint256 tokenId,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _tokenId = getUint(getId, tokenId);
|
||||
|
||||
IERC721 tokenContract = IERC721(token);
|
||||
tokenContract.safeTransferFrom(msg.sender, address(this), _tokenId);
|
||||
|
||||
setUint(setId, _tokenId);
|
||||
|
||||
_eventName = "LogDepositERC721(address,address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, msg.sender, _tokenId, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw Assets To Smart Account.
|
||||
* @notice Withdraw a ERC721 token from DSA
|
||||
* @param token Address of the token.
|
||||
* @param tokenId ID of token.
|
||||
* @param to The address to receive the token upon withdrawal
|
||||
* @param getId ID to retrieve tokenId.
|
||||
* @param setId ID stores the tokenId.
|
||||
*/
|
||||
function withdrawERC721(
|
||||
address token,
|
||||
uint256 tokenId,
|
||||
address payable to,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _tokenId = getUint(getId, tokenId);
|
||||
IERC721 tokenContract = IERC721(token);
|
||||
tokenContract.safeTransferFrom(address(this), to, _tokenId);
|
||||
|
||||
setUint(setId, _tokenId);
|
||||
|
||||
_eventName = "LogWithdrawERC721(address,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _tokenId, to, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2BasicERC721 is BasicResolver {
|
||||
string public constant name = "BASIC-ERC721-v1.0";
|
||||
}
|
|
@ -3,14 +3,14 @@ pragma solidity ^0.7.0;
|
|||
contract Events {
|
||||
|
||||
event LogDeposit(
|
||||
address indexed stakingToken,
|
||||
address indexed stakingPool,
|
||||
uint256 amount,
|
||||
uint getId,
|
||||
uint setId
|
||||
);
|
||||
|
||||
event LogWithdrawAndClaimedReward(
|
||||
address indexed stakingToken,
|
||||
address indexed stakingPool,
|
||||
uint256 amount,
|
||||
uint256 rewardAmt,
|
||||
uint getId,
|
||||
|
@ -19,6 +19,7 @@ contract Events {
|
|||
);
|
||||
|
||||
event LogClaimedReward(
|
||||
address indexed stakingPool,
|
||||
address indexed rewardToken,
|
||||
uint256 rewardAmt,
|
||||
uint setId
|
||||
|
|
|
@ -8,17 +8,5 @@ import { TokenInterface } from "../../common/interfaces.sol";
|
|||
import { IStakingRewards, IStakingRewardsFactory, IGUniPoolResolver } from "./interface.sol";
|
||||
|
||||
abstract contract Helpers is DSMath, Basic {
|
||||
|
||||
IGUniPoolResolver constant internal guniResolver =
|
||||
IGUniPoolResolver(0x729BF02a9A786529Fc80498f8fd0051116061B13);
|
||||
|
||||
TokenInterface constant internal rewardToken = TokenInterface(0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb);
|
||||
|
||||
function getStakingContract(address stakingToken) internal view returns (address) {
|
||||
IStakingRewardsFactory.StakingRewardsInfo memory stakingRewardsInfo =
|
||||
guniResolver.getStakingFactory().stakingRewardsInfoByStakingToken(stakingToken);
|
||||
|
||||
return stakingRewardsInfo.stakingRewards;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,12 +17,14 @@ contract Main is Helpers, Events {
|
|||
/**
|
||||
* @dev Deposit ERC20.
|
||||
* @notice Deposit Tokens to staking pool.
|
||||
* @param stakingPool staking pool address.
|
||||
* @param stakingToken staking token address.
|
||||
* @param amt staking token amount.
|
||||
* @param getId ID to retrieve amount.
|
||||
* @param setId ID stores the amount of staked tokens.
|
||||
*/
|
||||
function deposit(
|
||||
address stakingPool,
|
||||
address stakingToken,
|
||||
uint amt,
|
||||
uint getId,
|
||||
|
@ -30,7 +32,7 @@ contract Main is Helpers, Events {
|
|||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
|
||||
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
|
||||
IStakingRewards stakingContract = IStakingRewards(stakingPool);
|
||||
TokenInterface stakingTokenContract = TokenInterface(stakingToken);
|
||||
|
||||
_amt = _amt == uint(-1) ? stakingTokenContract.balanceOf(address(this)) : _amt;
|
||||
|
@ -40,12 +42,13 @@ contract Main is Helpers, Events {
|
|||
|
||||
setUint(setId, _amt);
|
||||
_eventName = "LogDeposit(address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(address(stakingToken), _amt, getId, setId);
|
||||
_eventParam = abi.encode(address(stakingPool), _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw ERC20.
|
||||
* @notice Withdraw Tokens from the staking pool.
|
||||
* @param stakingPool staking pool address.
|
||||
* @param stakingToken staking token address.
|
||||
* @param amt staking token amount.
|
||||
* @param getId ID to retrieve amount.
|
||||
|
@ -53,6 +56,7 @@ contract Main is Helpers, Events {
|
|||
* @param setIdReward ID stores the amount of reward tokens claimed.
|
||||
*/
|
||||
function withdraw(
|
||||
address stakingPool,
|
||||
address stakingToken,
|
||||
uint amt,
|
||||
uint getId,
|
||||
|
@ -61,7 +65,7 @@ contract Main is Helpers, Events {
|
|||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
|
||||
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
|
||||
IStakingRewards stakingContract = IStakingRewards(stakingPool);
|
||||
|
||||
_amt = _amt == uint(-1) ? stakingContract.balanceOf(address(this)) : _amt;
|
||||
uint intialBal = rewardToken.balanceOf(address(this));
|
||||
|
@ -74,21 +78,21 @@ contract Main is Helpers, Events {
|
|||
setUint(setIdReward, rewardAmt);
|
||||
{
|
||||
_eventName = "LogWithdrawAndClaimedReward(address,uint256,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(address(stakingToken), _amt, rewardAmt, getId, setIdAmount, setIdReward);
|
||||
_eventParam = abi.encode(address(stakingPool), _amt, rewardAmt, getId, setIdAmount, setIdReward);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Claim Reward.
|
||||
* @notice Claim Pending Rewards of tokens staked.
|
||||
* @param stakingToken staking token address.
|
||||
* @param stakingPool staking pool address.
|
||||
* @param setId ID stores the amount of reward tokens claimed.
|
||||
*/
|
||||
function claimReward(
|
||||
address stakingToken,
|
||||
address stakingPool,
|
||||
uint setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
IStakingRewards stakingContract = IStakingRewards(getStakingContract(stakingToken));
|
||||
IStakingRewards stakingContract = IStakingRewards(stakingPool);
|
||||
|
||||
uint intialBal = rewardToken.balanceOf(address(this));
|
||||
stakingContract.getReward();
|
||||
|
@ -97,12 +101,12 @@ contract Main is Helpers, Events {
|
|||
uint rewardAmt = sub(finalBal, intialBal);
|
||||
|
||||
setUint(setId, rewardAmt);
|
||||
_eventName = "LogClaimedReward(address,uint256,uint256)";
|
||||
_eventParam = abi.encode(address(rewardToken), rewardAmt, setId);
|
||||
_eventName = "LogClaimedReward(address,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(address(stakingPool), address(rewardToken), rewardAmt, setId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
contract connectV2StakeGUNI is Main {
|
||||
string public constant name = "Stake-G-UNI-v1.0";
|
||||
string public constant name = "Stake-G-UNI-v1.1";
|
||||
}
|
6
contracts/mainnet/connectors/yearn_v2/events.sol
Normal file
6
contracts/mainnet/connectors/yearn_v2/events.sol
Normal file
|
@ -0,0 +1,6 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogDeposit(address indexed vault, uint256 shareAmt, uint256 depositAmt, uint256 getId, uint256 setId);
|
||||
event LogWithdraw(address indexed recipient, uint256 shareAmt, uint256 withdrawAmt, uint256 getId, uint256 setId);
|
||||
}
|
12
contracts/mainnet/connectors/yearn_v2/interface.sol
Normal file
12
contracts/mainnet/connectors/yearn_v2/interface.sol
Normal file
|
@ -0,0 +1,12 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
interface YearnV2Interface {
|
||||
function deposit(uint256 amount, address recipient) external returns (uint256);
|
||||
|
||||
function withdraw(uint256 maxShares, address recipient) external returns (uint256);
|
||||
|
||||
function token() external view returns (address);
|
||||
|
||||
function balanceOf(address owner) external view returns (uint256);
|
||||
}
|
||||
|
86
contracts/mainnet/connectors/yearn_v2/main.sol
Normal file
86
contracts/mainnet/connectors/yearn_v2/main.sol
Normal file
|
@ -0,0 +1,86 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Yearn V2.
|
||||
* @dev Vaults & yield.
|
||||
*/
|
||||
|
||||
import { TokenInterface } from "../../common/interfaces.sol";
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import { Events } from "./events.sol";
|
||||
import { YearnV2Interface } from "./interface.sol";
|
||||
|
||||
abstract contract YearnResolver is Events, Basic {
|
||||
/**
|
||||
* @dev Deposit funds in the vault, issuing shares to recipient.
|
||||
* @notice This will deposit funds to a specific Yearn Vault.
|
||||
* @param vault The address of the vault to deposit funds into.
|
||||
* @param amt The amount of tokens to deposit.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of shares received.
|
||||
*/
|
||||
function deposit(
|
||||
address vault,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
|
||||
YearnV2Interface yearn = YearnV2Interface(vault);
|
||||
|
||||
address want = yearn.token();
|
||||
bool iswETH = want == wethAddr;
|
||||
TokenInterface tokenContract = TokenInterface(want);
|
||||
|
||||
if (iswETH) {
|
||||
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
||||
convertEthToWeth(iswETH, tokenContract, _amt);
|
||||
} else {
|
||||
_amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt;
|
||||
}
|
||||
|
||||
approve(tokenContract, vault, _amt);
|
||||
|
||||
uint256 _shares = yearn.deposit(_amt, address(this));
|
||||
setUint(setId, _shares);
|
||||
|
||||
_eventName = "LogDeposit(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(vault, _shares, _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw shares from the vault.
|
||||
* @notice This will withdraw the share from a specific Yearn Vault.
|
||||
* @param vault The address of the vault to withdraw shares from.
|
||||
* @param amt The amount of shares to withdraw.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount want token redeemed.
|
||||
*/
|
||||
function withdraw(
|
||||
address vault,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
|
||||
YearnV2Interface vault = YearnV2Interface(vault);
|
||||
|
||||
|
||||
_amt = _amt == uint(-1) ? vault.balanceOf(address(this)) : _amt;
|
||||
uint256 _wantRedeemed = vault.withdraw(_amt, address(this));
|
||||
setUint(setId, _wantRedeemed);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(vault.token());
|
||||
bool isWEth = vault.token() == wethAddr;
|
||||
convertWethToEth(isWEth, tokenContract, _amt);
|
||||
|
||||
_eventName = "LogWithdraw(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(vault, _amt, _wantRedeemed, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2YearnV2 is YearnResolver {
|
||||
string public constant name = "YearnV2-v1.0";
|
||||
}
|
114
contracts/test/implementation_default.sol
Normal file
114
contracts/test/implementation_default.sol
Normal file
|
@ -0,0 +1,114 @@
|
|||
pragma solidity ^0.7.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import { Variables } from "./variables.sol";
|
||||
|
||||
interface IndexInterface {
|
||||
function list() external view returns (address);
|
||||
}
|
||||
|
||||
interface ListInterface {
|
||||
function addAuth(address user) external;
|
||||
|
||||
function removeAuth(address user) external;
|
||||
}
|
||||
|
||||
contract Constants is Variables {
|
||||
uint256 public constant implementationVersion = 1;
|
||||
// InstaIndex Address.
|
||||
address public immutable instaIndex;
|
||||
// The Account Module Version.
|
||||
uint256 public constant version = 2;
|
||||
|
||||
constructor(address _instaIndex) {
|
||||
instaIndex = _instaIndex;
|
||||
}
|
||||
}
|
||||
|
||||
contract Record is Constants {
|
||||
constructor(address _instaIndex) Constants(_instaIndex) {}
|
||||
|
||||
event LogEnableUser(address indexed user);
|
||||
event LogDisableUser(address indexed user);
|
||||
|
||||
/**
|
||||
* @dev Check for Auth if enabled.
|
||||
* @param user address/user/owner.
|
||||
*/
|
||||
function isAuth(address user) public view returns (bool) {
|
||||
return _auth[user];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Enable New User.
|
||||
* @param user Owner address
|
||||
*/
|
||||
function enable(address user) public {
|
||||
require(
|
||||
msg.sender == address(this) || msg.sender == instaIndex,
|
||||
"not-self-index"
|
||||
);
|
||||
require(user != address(0), "not-valid");
|
||||
require(!_auth[user], "already-enabled");
|
||||
_auth[user] = true;
|
||||
ListInterface(IndexInterface(instaIndex).list()).addAuth(user);
|
||||
emit LogEnableUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable User.
|
||||
* @param user Owner address
|
||||
*/
|
||||
function disable(address user) public {
|
||||
require(msg.sender == address(this), "not-self");
|
||||
require(user != address(0), "not-valid");
|
||||
require(_auth[user], "already-disabled");
|
||||
delete _auth[user];
|
||||
ListInterface(IndexInterface(instaIndex).list()).removeAuth(user);
|
||||
emit LogDisableUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev ERC721 token receiver
|
||||
*/
|
||||
function onERC721Received(
|
||||
address,
|
||||
address,
|
||||
uint256,
|
||||
bytes calldata
|
||||
) external returns (bytes4) {
|
||||
return 0x150b7a02; // bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev ERC1155 token receiver
|
||||
*/
|
||||
function onERC1155Received(
|
||||
address,
|
||||
address,
|
||||
uint256,
|
||||
uint256,
|
||||
bytes memory
|
||||
) external returns (bytes4) {
|
||||
return 0xf23a6e61; // bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev ERC1155 token receiver
|
||||
*/
|
||||
function onERC1155BatchReceived(
|
||||
address,
|
||||
address,
|
||||
uint256[] calldata,
|
||||
uint256[] calldata,
|
||||
bytes calldata
|
||||
) external returns (bytes4) {
|
||||
return 0xbc197c81; // bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
|
||||
}
|
||||
}
|
||||
|
||||
contract InstaDefaultImplementation is Record {
|
||||
constructor(address _instaIndex) public Record(_instaIndex) {}
|
||||
|
||||
receive() external payable {}
|
||||
}
|
6
contracts/test/variables.sol
Normal file
6
contracts/test/variables.sol
Normal file
|
@ -0,0 +1,6 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Variables {
|
||||
// Auth Module(Address of Auth => bool).
|
||||
mapping (address => bool) internal _auth;
|
||||
}
|
|
@ -63,7 +63,7 @@ module.exports = {
|
|||
hardhat: {
|
||||
forking: {
|
||||
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`,
|
||||
blockNumber: 13180514,
|
||||
blockNumber: 12796965,
|
||||
},
|
||||
blockGasLimit: 12000000,
|
||||
gasPrice: parseInt(utils.parseUnits("300", "gwei"))
|
||||
|
@ -85,4 +85,4 @@ module.exports = {
|
|||
mocha: {
|
||||
timeout: 100 * 1000,
|
||||
},
|
||||
};
|
||||
};
|
|
@ -6,6 +6,7 @@
|
|||
"scripts": {
|
||||
"test": "hardhat test",
|
||||
"coverage": "./node_modules/.bin/solidity-coverage",
|
||||
"check": "node status-checks/huskyCheck.js",
|
||||
"check-husky": "node status-checks/huskyCheck.js",
|
||||
"deploy": "node scripts/deployConnectorsFromCmd.js",
|
||||
"build-contracts": "sol-merger \"./contracts/connectors/mock.sol\" ./contracts/build"
|
||||
|
|
206
scripts/constant/abi/core/InstaImplementations.json
Normal file
206
scripts/constant/abi/core/InstaImplementations.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -3,13 +3,11 @@ const path = require('path')
|
|||
|
||||
const forbiddenStrings = ['selfdestruct']
|
||||
|
||||
const getConnectorsList = async () => {
|
||||
const getConnectorsList = async (connectorsRootsDirs) => {
|
||||
try {
|
||||
const connectors = []
|
||||
const connectorsRootsDirs = ['mainnet', 'polygon']
|
||||
for (let index = 0; index < connectorsRootsDirs.length; index++) {
|
||||
const root = `contracts/${connectorsRootsDirs[index]}/connectors`
|
||||
const dirs = [root]
|
||||
const dirs = [connectorsRootsDirs[index]]
|
||||
while (dirs.length) {
|
||||
const currentDir = dirs.pop()
|
||||
const subs = fs.readdirSync(currentDir, { withFileTypes: true })
|
||||
|
@ -326,9 +324,14 @@ const checkHeadComments = async (connector) => {
|
|||
|
||||
async function checkMain () {
|
||||
try {
|
||||
const connectorsRootsDirsDefault = ['mainnet', 'polygon'].map(v=> `contracts/${v}/connectors`)
|
||||
const customPathArg = process.argv.find(a => a.startsWith('connector='))
|
||||
const connectorsRootsDirs = customPathArg
|
||||
? [customPathArg.slice(10)]
|
||||
: connectorsRootsDirsDefault
|
||||
const errors = []
|
||||
const warnings = []
|
||||
const connectors = await getConnectorsList()
|
||||
const connectors = await getConnectorsList(connectorsRootsDirs)
|
||||
for (let index = 0; index < connectors.length; index++) {
|
||||
const { forbiddenErrors, code } = await checkForbidden(connectors[index].path)
|
||||
connectors[index].code = code
|
||||
|
|
7
status-checks/readme.md
Normal file
7
status-checks/readme.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
# Check run
|
||||
|
||||
use
|
||||
`npm run check`
|
||||
to check `connectors` directory. Use `connector=$` argument to check specific connector:
|
||||
`npm run check connector=contracts/mainnet/common`
|
127
test/basic-ERC1155/ERC1155-transfer.js
Normal file
127
test/basic-ERC1155/ERC1155-transfer.js
Normal file
|
@ -0,0 +1,127 @@
|
|||
const { expect } = require("chai");
|
||||
const hre = require("hardhat");
|
||||
const { web3, deployments, waffle, ethers } = hre;
|
||||
const { provider, deployContract } = waffle
|
||||
const {abi: implementationsABI} = require("../../scripts/constant/abi/core/InstaImplementations.json")
|
||||
|
||||
const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js")
|
||||
const buildDSAv2 = require("../../scripts/buildDSAv2")
|
||||
const encodeSpells = require("../../scripts/encodeSpells.js")
|
||||
const getMasterSigner = require("../../scripts/getMasterSigner")
|
||||
|
||||
const addresses = require("../../scripts/constant/addresses");
|
||||
const abis = require("../../scripts/constant/abis");
|
||||
const constants = require("../../scripts/constant/constant");
|
||||
const tokens = require("../../scripts/constant/tokens");
|
||||
|
||||
const connectV2BasicERC1155Artifacts = require("../../artifacts/contracts/mainnet/connectors/basic-ERC1155/main.sol/ConnectV2BasicERC1155.json")
|
||||
const erc1155Artifacts = require("../../artifacts/@openzeppelin/contracts/token/ERC1155/IERC1155.sol/IERC1155.json")
|
||||
|
||||
const TOKEN_CONTRACT_ADDR = "0x1ca3262009b21F944e6b92a2a88D039D06F1acFa";
|
||||
const TOKEN_OWNER_ADDR = "0x1ca3262009b21F944e6b92a2a88D039D06F1acFa";
|
||||
const TOKEN_ID = "1";
|
||||
|
||||
const implementationsMappingAddr = "0xCBA828153d3a85b30B5b912e1f2daCac5816aE9D"
|
||||
|
||||
describe("BASIC-ERC1155", function () {
|
||||
const connectorName = "BASIC-ERC1155-A"
|
||||
|
||||
let dsaWallet0
|
||||
let masterSigner;
|
||||
let instaConnectorsV2;
|
||||
let connector;
|
||||
let nftContract;
|
||||
let tokenOwner;
|
||||
let instaImplementationsMapping;
|
||||
|
||||
|
||||
const wallets = provider.getWallets()
|
||||
const [wallet0, wallet1, wallet2, wallet3] = wallets
|
||||
before(async () => {
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: [TOKEN_OWNER_ADDR],
|
||||
});
|
||||
|
||||
await network.provider.send("hardhat_setBalance", [
|
||||
TOKEN_OWNER_ADDR,
|
||||
"0x1000000000000000",
|
||||
]);
|
||||
|
||||
// get tokenOwner
|
||||
tokenOwner = await ethers.getSigner(
|
||||
TOKEN_OWNER_ADDR
|
||||
);
|
||||
nftContract = await ethers.getContractAt(erc1155Artifacts.abi, TOKEN_CONTRACT_ADDR)
|
||||
masterSigner = await getMasterSigner(wallet3)
|
||||
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
|
||||
|
||||
instaImplementationsMapping = await ethers.getContractAt(implementationsABI, implementationsMappingAddr);
|
||||
InstaAccountV2DefaultImpl = await ethers.getContractFactory("InstaDefaultImplementation")
|
||||
instaAccountV2DefaultImpl = await InstaAccountV2DefaultImpl.deploy(addresses.core.instaIndex);
|
||||
await instaAccountV2DefaultImpl.deployed()
|
||||
connector = await deployAndEnableConnector({
|
||||
connectorName,
|
||||
contractArtifact: connectV2BasicERC1155Artifacts,
|
||||
signer: masterSigner,
|
||||
connectors: instaConnectorsV2
|
||||
})
|
||||
console.log("Connector address", connector.address)
|
||||
})
|
||||
|
||||
it("Should have contracts deployed.", async function () {
|
||||
expect(!!instaConnectorsV2.address).to.be.true;
|
||||
expect(!!connector.address).to.be.true;
|
||||
expect(!!masterSigner.address).to.be.true;
|
||||
});
|
||||
|
||||
describe("Implementations", function () {
|
||||
|
||||
it("Should add default implementation to mapping.", async function () {
|
||||
const tx = await instaImplementationsMapping.connect(masterSigner).setDefaultImplementation(instaAccountV2DefaultImpl.address);
|
||||
await tx.wait()
|
||||
expect(await instaImplementationsMapping.defaultImplementation()).to.be.equal(instaAccountV2DefaultImpl.address);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("DSA wallet setup", function () {
|
||||
it("Should build DSA v2", async function () {
|
||||
dsaWallet0 = await buildDSAv2(tokenOwner.address)
|
||||
expect(!!dsaWallet0.address).to.be.true;
|
||||
});
|
||||
|
||||
it("Deposit ETH into DSA wallet", async function () {
|
||||
await wallet0.sendTransaction({
|
||||
to: dsaWallet0.address,
|
||||
value: ethers.utils.parseEther("10")
|
||||
});
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Main", function () {
|
||||
it("should deposit successfully", async () => {
|
||||
console.log("DSA wallet address", dsaWallet0.address)
|
||||
await nftContract.connect(tokenOwner).setApprovalForAll(dsaWallet0.address, true);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "depositERC1155",
|
||||
args: [
|
||||
TOKEN_CONTRACT_ADDR,
|
||||
TOKEN_ID,
|
||||
1,
|
||||
"0",
|
||||
"0"
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const tx = await dsaWallet0
|
||||
.connect(tokenOwner)
|
||||
.cast(...encodeSpells(spells), tokenOwner.address);
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
})
|
||||
})
|
126
test/basic-ERC721/ERC721-transfer.js
Normal file
126
test/basic-ERC721/ERC721-transfer.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
const { expect } = require("chai");
|
||||
const hre = require("hardhat");
|
||||
const { web3, deployments, waffle, ethers } = hre;
|
||||
const { provider, deployContract } = waffle
|
||||
const {abi: implementationsABI} = require("../../scripts/constant/abi/core/InstaImplementations.json")
|
||||
|
||||
const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js")
|
||||
const buildDSAv2 = require("../../scripts/buildDSAv2")
|
||||
const encodeSpells = require("../../scripts/encodeSpells.js")
|
||||
const getMasterSigner = require("../../scripts/getMasterSigner")
|
||||
|
||||
const addresses = require("../../scripts/constant/addresses");
|
||||
const abis = require("../../scripts/constant/abis");
|
||||
const constants = require("../../scripts/constant/constant");
|
||||
const tokens = require("../../scripts/constant/tokens");
|
||||
|
||||
const connectV2BasicERC721Artifacts = require("../../artifacts/contracts/mainnet/connectors/basic-ERC721/main.sol/ConnectV2BasicERC721.json")
|
||||
const erc721Artifacts = require("../../artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json")
|
||||
|
||||
const TOKEN_CONTRACT_ADDR = "0x4d695c615a7aacf2d7b9c481b66045bb2457dfde";
|
||||
const TOKEN_OWNER_ADDR = "0x8c6b10d42ff08e56133fca0dac75e1931b1fcc23";
|
||||
const TOKEN_ID = "38";
|
||||
|
||||
const implementationsMappingAddr = "0xCBA828153d3a85b30B5b912e1f2daCac5816aE9D"
|
||||
|
||||
describe("BASIC-ERC721", function () {
|
||||
const connectorName = "BASIC-ERC721-A"
|
||||
|
||||
let dsaWallet0
|
||||
let masterSigner;
|
||||
let instaConnectorsV2;
|
||||
let connector;
|
||||
let nftContract;
|
||||
let tokenOwner;
|
||||
let instaImplementationsMapping;
|
||||
|
||||
|
||||
const wallets = provider.getWallets()
|
||||
const [wallet0, wallet1, wallet2, wallet3] = wallets
|
||||
before(async () => {
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: [TOKEN_OWNER_ADDR],
|
||||
});
|
||||
|
||||
await network.provider.send("hardhat_setBalance", [
|
||||
TOKEN_OWNER_ADDR,
|
||||
"0x1000000000000000",
|
||||
]);
|
||||
|
||||
// get tokenOwner
|
||||
tokenOwner = await ethers.getSigner(
|
||||
TOKEN_OWNER_ADDR
|
||||
);
|
||||
nftContract = await ethers.getContractAt(erc721Artifacts.abi, TOKEN_CONTRACT_ADDR)
|
||||
masterSigner = await getMasterSigner(wallet3)
|
||||
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
|
||||
|
||||
instaImplementationsMapping = await ethers.getContractAt(implementationsABI, implementationsMappingAddr);
|
||||
InstaAccountV2DefaultImpl = await ethers.getContractFactory("InstaDefaultImplementation")
|
||||
instaAccountV2DefaultImpl = await InstaAccountV2DefaultImpl.deploy(addresses.core.instaIndex);
|
||||
await instaAccountV2DefaultImpl.deployed()
|
||||
connector = await deployAndEnableConnector({
|
||||
connectorName,
|
||||
contractArtifact: connectV2BasicERC721Artifacts,
|
||||
signer: masterSigner,
|
||||
connectors: instaConnectorsV2
|
||||
})
|
||||
console.log("Connector address", connector.address)
|
||||
})
|
||||
|
||||
it("Should have contracts deployed.", async function () {
|
||||
expect(!!instaConnectorsV2.address).to.be.true;
|
||||
expect(!!connector.address).to.be.true;
|
||||
expect(!!masterSigner.address).to.be.true;
|
||||
});
|
||||
|
||||
describe("Implementations", function () {
|
||||
|
||||
it("Should add default implementation to mapping.", async function () {
|
||||
const tx = await instaImplementationsMapping.connect(masterSigner).setDefaultImplementation(instaAccountV2DefaultImpl.address);
|
||||
await tx.wait()
|
||||
expect(await instaImplementationsMapping.defaultImplementation()).to.be.equal(instaAccountV2DefaultImpl.address);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("DSA wallet setup", function () {
|
||||
it("Should build DSA v2", async function () {
|
||||
dsaWallet0 = await buildDSAv2(tokenOwner.address)
|
||||
expect(!!dsaWallet0.address).to.be.true;
|
||||
});
|
||||
|
||||
it("Deposit ETH into DSA wallet", async function () {
|
||||
await wallet0.sendTransaction({
|
||||
to: dsaWallet0.address,
|
||||
value: ethers.utils.parseEther("10")
|
||||
});
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Main", function () {
|
||||
it("should deposit successfully", async () => {
|
||||
console.log("DSA wallet address", dsaWallet0.address)
|
||||
await nftContract.connect(tokenOwner).setApprovalForAll(dsaWallet0.address, true);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "depositERC721",
|
||||
args: [
|
||||
TOKEN_CONTRACT_ADDR,
|
||||
TOKEN_ID,
|
||||
"0",
|
||||
"0"
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const tx = await dsaWallet0
|
||||
.connect(tokenOwner)
|
||||
.cast(...encodeSpells(spells), tokenOwner.address);
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
})
|
||||
})
|
142
test/yearn/yearn.test.js
Normal file
142
test/yearn/yearn.test.js
Normal file
|
@ -0,0 +1,142 @@
|
|||
const { expect } = require("chai");
|
||||
const hre = require("hardhat");
|
||||
const { waffle, ethers } = hre;
|
||||
const { provider } = waffle
|
||||
|
||||
const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js")
|
||||
const buildDSAv2 = require("../../scripts/buildDSAv2")
|
||||
const encodeSpells = require("../../scripts/encodeSpells.js")
|
||||
const getMasterSigner = require("../../scripts/getMasterSigner")
|
||||
|
||||
const tokens = require("../../scripts/constant/tokens");
|
||||
const addresses = require("../../scripts/constant/addresses");
|
||||
const abis = require("../../scripts/constant/abis");
|
||||
const connectV2YearnArtifacts = require("../../artifacts/contracts/mainnet/connectors/yearn_v2/main.sol/ConnectV2YearnV2.json")
|
||||
|
||||
const toBytes32 = (bn) => {
|
||||
return ethers.utils.hexlify(ethers.utils.zeroPad(bn.toHexString(), 32));
|
||||
};
|
||||
const setStorageAt = async (address, index, value) => {
|
||||
await ethers.provider.send("hardhat_setStorageAt", [address, index, value]);
|
||||
await ethers.provider.send("evm_mine", []); // Just mines to the next block
|
||||
};
|
||||
|
||||
describe("Yearn", function () {
|
||||
const connectorName = "YEARN-TEST-A"
|
||||
|
||||
let dsaWallet0
|
||||
let masterSigner;
|
||||
let instaConnectorsV2;
|
||||
let connector;
|
||||
|
||||
const wallets = provider.getWallets()
|
||||
const [wallet0, wallet1, wallet2, wallet3] = wallets
|
||||
before(async () => {
|
||||
masterSigner = await getMasterSigner(wallet3)
|
||||
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
|
||||
connector = await deployAndEnableConnector({
|
||||
connectorName,
|
||||
contractArtifact: connectV2YearnArtifacts,
|
||||
signer: masterSigner,
|
||||
connectors: instaConnectorsV2
|
||||
})
|
||||
console.log("Connector address", connector.address)
|
||||
})
|
||||
|
||||
it("Should have contracts deployed.", async function () {
|
||||
expect(!!instaConnectorsV2.address).to.be.true;
|
||||
expect(!!connector.address).to.be.true;
|
||||
expect(!!masterSigner.address).to.be.true;
|
||||
});
|
||||
|
||||
describe("DSA wallet setup", function () {
|
||||
it("Should build DSA v2", async function () {
|
||||
dsaWallet0 = await buildDSAv2(wallet0.address)
|
||||
expect(!!dsaWallet0.address).to.be.true;
|
||||
});
|
||||
|
||||
it("Deposit ETH into DSA wallet", async function () {
|
||||
await wallet0.sendTransaction({
|
||||
to: dsaWallet0.address,
|
||||
value: ethers.utils.parseEther("10")
|
||||
});
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Main", function () {
|
||||
|
||||
it("Should increase the DAI balance to 100 DAI", async function () {
|
||||
const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider);
|
||||
const DAI_SLOT = 2;
|
||||
const locallyManipulatedBalance = ethers.utils.parseEther("100");
|
||||
|
||||
// Get storage slot index
|
||||
const index = ethers.utils.solidityKeccak256(
|
||||
["uint256", "uint256"],
|
||||
[dsaWallet0.address, DAI_SLOT]
|
||||
);
|
||||
// Manipulate local balance (needs to be bytes32 string)
|
||||
await setStorageAt(
|
||||
tokens.dai.address,
|
||||
index.toString(),
|
||||
toBytes32(locallyManipulatedBalance).toString()
|
||||
);
|
||||
|
||||
// Get DAI balance
|
||||
const balance = await DAI.balanceOf(dsaWallet0.address);
|
||||
expect(await ethers.BigNumber.from(balance).eq(ethers.utils.parseEther("100")));
|
||||
});
|
||||
|
||||
it("Should deposit and withdraw 50 DAI in/out the Yearn Vault", async function () {
|
||||
const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider);
|
||||
const DAI_VAULT = '0xdA816459F1AB5631232FE5e97a05BBBb94970c95';
|
||||
const amount = ethers.utils.parseEther("50") // 50 DAI
|
||||
const setId = "132456";
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "deposit",
|
||||
args: [DAI_VAULT, amount, 0, setId]
|
||||
},
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "withdraw",
|
||||
args: [DAI_VAULT, amount, setId, 0]
|
||||
}
|
||||
]
|
||||
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address);
|
||||
await tx.wait();
|
||||
|
||||
// Get DAI balance
|
||||
const balance = await DAI.balanceOf(dsaWallet0.address);
|
||||
expect(await ethers.BigNumber.from(balance).eq(ethers.utils.parseEther("100")));
|
||||
});
|
||||
|
||||
it("Should deposit 70 DAI in the Yearn Vault", async function () {
|
||||
const DAI_VAULT = '0xdA816459F1AB5631232FE5e97a05BBBb94970c95';
|
||||
const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider);
|
||||
const YVDAI = new ethers.Contract(DAI_VAULT, abis.basic.erc20, ethers.provider);
|
||||
const amount = ethers.utils.parseEther("70") // 70 DAI
|
||||
const setId = "568445";
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "deposit",
|
||||
args: [DAI_VAULT, amount, 0, setId]
|
||||
}
|
||||
]
|
||||
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address);
|
||||
await tx.wait();
|
||||
|
||||
// Get DAI balance
|
||||
const yvDAIBalance = await YVDAI.balanceOf(dsaWallet0.address);
|
||||
const daiBalance = await DAI.balanceOf(dsaWallet0.address);
|
||||
const correctDaiBalance = await ethers.BigNumber.from(daiBalance).eq(ethers.utils.parseEther("30"));
|
||||
const correctYVDaiBalance = await ethers.BigNumber.from(yvDAIBalance).lte(ethers.utils.parseEther("70"));
|
||||
expect(correctDaiBalance && correctYVDaiBalance);
|
||||
});
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user