mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fluidity
This commit is contained in:
parent
43f5371b83
commit
54d2d3a364
15
contracts/polygon/connectors/fluidity/events.sol
Normal file
15
contracts/polygon/connectors/fluidity/events.sol
Normal file
|
@ -0,0 +1,15 @@
|
|||
pragma solidity ^0.8.0;
|
||||
|
||||
|
||||
contract Events {
|
||||
|
||||
event LogSupply(address token_, uint amount_,uint itokenAmount_,uint getId,uint setId);
|
||||
|
||||
event LogWithdraw(address token_, uint amt_,uint itokenAmount_,uint getId,uint setId);
|
||||
|
||||
event LogWithdrawItoken(address token_, uint amt_,uint amount_,uint getId,uint setId);
|
||||
|
||||
event LogClaimReward(address user_, address token_,uint[] updatedRewards_)
|
||||
|
||||
|
||||
}
|
15
contracts/polygon/connectors/fluidity/helper.sol
Normal file
15
contracts/polygon/connectors/fluidity/helper.sol
Normal file
|
@ -0,0 +1,15 @@
|
|||
pragma solidity ^0.8.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import { DSMath } from "../../common/math.sol";
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "./interface.sol";
|
||||
|
||||
abstract contract Helpers is DSMath, Basic {
|
||||
|
||||
P1M2 internal constant p1m2 = P1M2("0xf40c01Adc86CF5d534Ff5CaFaA451694FdD2b08C");
|
||||
|
||||
}
|
||||
|
9
contracts/polygon/connectors/fluidity/interface.sol
Normal file
9
contracts/polygon/connectors/fluidity/interface.sol
Normal file
|
@ -0,0 +1,9 @@
|
|||
pragma solidity ^0.8.0;
|
||||
|
||||
interface P1M2 {
|
||||
|
||||
function supply(address token_, uint amount_) external returns (uint itokenAmount_);
|
||||
function withdraw(address token_, uint amount_) external returns (uint itokenAmount_);
|
||||
function withdrawItoken(address token_, uint itokenAmount_) external returns (uint amount_);
|
||||
function claim(address user_, address token_) external returns (uint[] memory updatedRewards_);
|
||||
}
|
79
contracts/polygon/connectors/fluidity/main.sol
Normal file
79
contracts/polygon/connectors/fluidity/main.sol
Normal file
|
@ -0,0 +1,79 @@
|
|||
pragma solidity ^0.8.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
import "./events.sol";
|
||||
import "./helpers.sol";
|
||||
import { TokenInterface } from "../../common/interfaces.sol";
|
||||
abstract contract FluidityP1M2 is Events, Helpers {
|
||||
|
||||
|
||||
function supply(address token_,
|
||||
uint amt,
|
||||
uint getId,
|
||||
uint setId
|
||||
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
|
||||
uint amt_ = getUint(getId, amt);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(token_);
|
||||
amt_ = amt_ == type(uint).max ? tokenContract.balanceOf(address(this)) : amt_;
|
||||
|
||||
(uint itokenAmount_ )= p1m2.supply(token_,amt_ );
|
||||
|
||||
setUint(setId, amt_ );
|
||||
|
||||
_eventName = "LogSupply(address,uint,uint,uint,uint)";
|
||||
_eventParam = abi.encode(address(token_) , amt_ , itokenAmount_ , getId , setId);
|
||||
}
|
||||
|
||||
|
||||
function withdraw(address token_ , uint amount_, uint getId , uint setId) public payable returns (string memory _eventName , bytes memory _eventParam){
|
||||
|
||||
uint amt_ = getUint(getId, amount_);
|
||||
TokenInterface tokenContract = TokenInterface(token_);
|
||||
amt_ = amt_ == type(uint).max ? tokenContract.balanceOf(address(this)) : amt_;
|
||||
|
||||
(uint itokenAmount_) = p1m2.withdraw(token_,amt_);
|
||||
|
||||
setUint(setId, amt_ );
|
||||
|
||||
|
||||
|
||||
_eventName = "LogWithdraw(address,uint,uint,uint,uint)";
|
||||
_eventParam = abi.encode(address(token_) , amt_ , itokenAmount_ , getId , setId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function withdrawItoken(address token_, uint itokenAmount_ , uint getId,uint setId) public payable returns (string memory _eventName , bytes memory _eventParam){
|
||||
|
||||
uint amt_ = getUint(getId, itokenAmount_);
|
||||
TokenInterface tokenContract = TokenInterface(token_);
|
||||
amt_ = amt_ == type(uint).max ? tokenContract.balanceOf(address(this)) : amt_;
|
||||
|
||||
(uint amount_) = p1m2.withdrawItoken(token_,amt_);
|
||||
|
||||
setUint(setId, amt_ );
|
||||
|
||||
|
||||
|
||||
_eventName = "LogWithdrawItoken(address,uint,uint,uint,uint)";
|
||||
_eventParam = abi.encode(address(token_) ,amt_, amount_ , getId , setId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function claim(address user_, address token_, uint getId,uint setId) public payable returns (string memory _eventName , bytes memory _eventParam){
|
||||
|
||||
|
||||
uint[] memory updatedRewards_ = p1m2.claim(user_,token_);
|
||||
|
||||
|
||||
_eventName = "LogClaimReward(address,address,uint[])";
|
||||
_eventParam = abi.encode(address(user_),address(token_) , updatedRewards_);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user