mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
feat: maker-import-to-fluid
This commit is contained in:
parent
ab3d5dc02d
commit
1a62787a04
6
contracts/mainnet/connectors/maker-import/events.sol
Normal file
6
contracts/mainnet/connectors/maker-import/events.sol
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
contract Events {
|
||||
event LogTransferToFluid(uint256 indexed vault, bytes32 indexed ilk, address indexed fluidAddress);
|
||||
}
|
||||
34
contracts/mainnet/connectors/maker-import/helpers.sol
Normal file
34
contracts/mainnet/connectors/maker-import/helpers.sol
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { DSMath } from "../../common/math.sol";
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import { TokenInterface } from "../../common/interfaces.sol";
|
||||
import { IMakerManager, IFluidWalletFactory } from "./interface.sol";
|
||||
|
||||
abstract contract Helpers is DSMath, Basic {
|
||||
IMakerManager internal constant managerContract = IMakerManager(0x5ef30b9986345249bc32d8928B7ee64DE9435E39);
|
||||
IFluidWalletFactory internal constant fluidWalletFactory = IFluidWalletFactory(0xd8Ae986159e350B6535539B8A1e488658452f25E);
|
||||
|
||||
function getVaultData(uint vault) internal view returns (bytes32 ilk, address urn) {
|
||||
ilk = managerContract.ilks(vault);
|
||||
urn = managerContract.urns(vault);
|
||||
}
|
||||
|
||||
function stringToBytes32(string memory str) internal pure returns (bytes32 result) {
|
||||
require(bytes(str).length != 0, "string-empty");
|
||||
assembly {
|
||||
result := mload(add(str, 32))
|
||||
}
|
||||
}
|
||||
|
||||
function getVault(uint vault) internal view returns (uint _vault) {
|
||||
if (vault == 0) {
|
||||
require(managerContract.count(address(this)) > 0, "no-vault-opened");
|
||||
_vault = managerContract.last(address(this));
|
||||
} else {
|
||||
_vault = vault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
contracts/mainnet/connectors/maker-import/interface.sol
Normal file
23
contracts/mainnet/connectors/maker-import/interface.sol
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import { TokenInterface } from "../../common/interfaces.sol";
|
||||
|
||||
interface IMakerManager {
|
||||
function cdpCan(address, uint, address) external view returns (uint);
|
||||
function ilks(uint) external view returns (bytes32);
|
||||
function last(address) external view returns (uint);
|
||||
function count(address) external view returns (uint);
|
||||
function owns(uint) external view returns (address);
|
||||
function urns(uint) external view returns (address);
|
||||
function vat() external view returns (address);
|
||||
function open(bytes32, address) external returns (uint);
|
||||
function give(uint, address) external;
|
||||
function frob(uint, int, int) external;
|
||||
function flux(uint, address, uint) external;
|
||||
function move(uint, address, uint) external;
|
||||
}
|
||||
|
||||
interface IFluidWalletFactory {
|
||||
function computeWallet(address owner_) external view returns (address);
|
||||
}
|
||||
26
contracts/mainnet/connectors/maker-import/main.sol
Normal file
26
contracts/mainnet/connectors/maker-import/main.sol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import "./helpers.sol";
|
||||
import "./events.sol";
|
||||
|
||||
contract MakerImport is Helpers, Events {
|
||||
function transferMakerToFluid(
|
||||
uint256 vaultId
|
||||
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint256 _vault = getVault(vaultId);
|
||||
(bytes32 ilk,) = getVaultData(_vault);
|
||||
|
||||
require(managerContract.owns(_vault) == address(this), "not-owner");
|
||||
|
||||
address fluidAddress = fluidWalletFactory.computeWallet(msg.sender);
|
||||
managerContract.give(_vault, fluidAddress);
|
||||
|
||||
_eventName = "LogTransferToAvo(uint256,bytes32,address)";
|
||||
_eventParam = abi.encode(_vault, ilk, fluidAddress);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2FluidMakerImport is MakerImport {
|
||||
string public constant name = "Fluid-Maker-Import-v1.0";
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user