Skip to content

Commit

Permalink
feat: add fee claim to multicall contract
Browse files Browse the repository at this point in the history
  • Loading branch information
panukettu committed Nov 19, 2023
1 parent dfe6593 commit 312e2ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
26 changes: 16 additions & 10 deletions src/contracts/core/periphery/KrMulticall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ contract KrMulticall {
}

enum OpAction {
Deposit,
Withdraw,
Repay,
Borrow,
MinterDeposit,
MinterWithdraw,
MinterRepay,
MinterBorrow,
SCDPDeposit,
Trade,
SCDPTrade,
SCDPWithdraw,
SCDPClaim,
VaultDeposit,
VaultRedeem,
AMMIn,
Expand Down Expand Up @@ -108,7 +109,7 @@ contract KrMulticall {
}

function _handleOp(Op calldata _op, bytes calldata rsPayload) internal returns (bool success, bytes memory returndata) {
if (_op.action == OpAction.Deposit) {
if (_op.action == OpAction.MinterDeposit) {
_approve(_op.data.tokenIn, _op.data.amountIn, address(kresko));
return
kresko.call(
Expand All @@ -120,7 +121,7 @@ contract KrMulticall {
rsPayload
)
);
} else if (_op.action == OpAction.Withdraw) {
} else if (_op.action == OpAction.MinterWithdraw) {
return
kresko.call(
abi.encodePacked(
Expand All @@ -131,7 +132,7 @@ contract KrMulticall {
rsPayload
)
);
} else if (_op.action == OpAction.Repay) {
} else if (_op.action == OpAction.MinterRepay) {
return
kresko.call(
abi.encodePacked(
Expand All @@ -142,7 +143,7 @@ contract KrMulticall {
rsPayload
)
);
} else if (_op.action == OpAction.Borrow) {
} else if (_op.action == OpAction.MinterBorrow) {
return
kresko.call(
abi.encodePacked(
Expand All @@ -159,7 +160,7 @@ contract KrMulticall {
rsPayload
)
);
} else if (_op.action == OpAction.Trade) {
} else if (_op.action == OpAction.SCDPTrade) {
_approve(_op.data.tokenIn, _op.data.amountIn, address(kresko));
return
kresko.call(
Expand All @@ -179,6 +180,11 @@ contract KrMulticall {
rsPayload
)
);
} else if (_op.action == OpAction.SCDPClaim) {
return
kresko.call(
abi.encodePacked(abi.encodeCall(ISCDPFacet.claimFeesSCDP, (msg.sender, _op.data.tokenOut)), rsPayload)
);
} else if (_op.action == OpAction.VaultDeposit) {
_approve(_op.data.tokenIn, _op.data.amountIn, kiss);
IVaultExtender(kiss).vaultDeposit(_op.data.tokenIn, _op.data.amountIn, msg.sender);
Expand Down
14 changes: 7 additions & 7 deletions src/contracts/test/Periphery.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,31 @@ contract PeripheryTest is TestBase("MNEMONIC_DEVNET"), KreskoForgeUtils {
assertTrue(address(mc) != address(0), "mc-address");
KrMulticall.Op[] memory ops = new KrMulticall.Op[](7);
ops[0] = KrMulticall.Op({
action: KrMulticall.OpAction.Borrow,
action: KrMulticall.OpAction.MinterBorrow,
data: KrMulticall.OpData(address(0), 0, krJPY.addr, 10000e18, 0, 0)
});
ops[1] = KrMulticall.Op({
action: KrMulticall.OpAction.Borrow,
action: KrMulticall.OpAction.MinterBorrow,
data: KrMulticall.OpData(address(0), 0, krJPY.addr, 10000e18, 0, 0)
});
ops[2] = KrMulticall.Op({
action: KrMulticall.OpAction.Borrow,
action: KrMulticall.OpAction.MinterBorrow,
data: KrMulticall.OpData(address(0), 0, krJPY.addr, 10000e18, 0, 0)
});
ops[3] = KrMulticall.Op({
action: KrMulticall.OpAction.Deposit,
action: KrMulticall.OpAction.MinterDeposit,
data: KrMulticall.OpData(krJPY.addr, 10000e18, address(0), 0, 0, 0)
});
ops[4] = KrMulticall.Op({
action: KrMulticall.OpAction.Deposit,
action: KrMulticall.OpAction.MinterDeposit,
data: KrMulticall.OpData(krJPY.addr, 10000e18, address(0), 0, 0, 0)
});
ops[5] = KrMulticall.Op({
action: KrMulticall.OpAction.Deposit,
action: KrMulticall.OpAction.MinterDeposit,
data: KrMulticall.OpData(krJPY.addr, 10000e18, address(0), 0, 0, 0)
});
ops[6] = KrMulticall.Op({
action: KrMulticall.OpAction.Deposit,
action: KrMulticall.OpAction.MinterDeposit,
data: KrMulticall.OpData(krJPY.addr, 10000e18, address(0), 0, 0, 0)
});

Expand Down

0 comments on commit 312e2ea

Please sign in to comment.