Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts separation p.1 #103

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Conversation

fenris85
Copy link
Contributor

No description provided.

Copy link
Contributor

@adamskrodzki adamskrodzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like general idea, but it can be refined

const dsproxy_calldata = system.operationRunner.interface.encodeFunctionData("executeOperation",
[{
name: 'openVaultOperation',
callData: [[openVaultCalldata],[openVaultCalldata]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why twice ?

string name;
bytes[][] callData;
bytes32[] actionIds;
address serviceRegistryAddr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serviceRegistryAddress can be immutable instead I guess it will be allways the same

Operation memory operation,
uint256 _index,
bytes32[] memory returnValues
) internal returns (bytes32 response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are about to support return values, i think it should be bytes not bytes32

import "./ActionBase.sol";
import "hardhat/console.sol";

contract Deposit is ActionBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a right name ? looks like open empty vault to me


struct Operation {
string name;
bytes[][] callData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it is multidimentional? I'm quite sure we can get away with one dimention and then do abi.decode
similar trick like:

) = abi.decode(params, (uint256, ExchangeData, CdpData, GuniAddressRegistry));

generally it is reasonable to assume that action knows format of its parameters, so You pass bytes to action and it decodes it in any way it wants

return "";
}

function isFlashLoanAction(address actionAddr) internal pure returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it used after all?

import "hardhat/console.sol";
import "../ServiceRegistry.sol";

struct Operation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 0.8+ solc and in 0.7 with abie encoder v2 pragma constructs like:

pragma solidity ^0.7.6;
pragma abicoder v2;

struct Action{
    bytes32 id;
    bytes data;
}
struct Operation{
    Action[] actions;

}

contract Silly {
    function execute(Operation calldata op) public returns (bool){

    }
}

are possible


abstract contract ActionBase {
enum ActionType {
FLASHLOAN,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what You tried to do with this,
I think there ate two kinds of operations

  1. with callbacks
  2. without callbacks

but maybe there is really only one, and fact that operaation makes a callback is its internal detail as long as valle address is passed as parameter

import "./ActionBase.sol";
import "hardhat/console.sol";

contract Flashloan is ActionBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is just placeholder,

flashloan can be (I think ) just and Operation like any other, it takes some some parameters that describes flash loan and then another operation which it executes on a runner.

gasPrice: 1000000000,
})

const lastCDP = await getLastCDP(provider, signer, system.userProxyAddress)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add at least assertion for a vault owner, to prove, that context is used correctly

@@ -0,0 +1,179 @@
//SPDX-License-Identifier: Unlicense
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try defaulting to external visibility where possible. see https://ethereum.stackexchange.com/questions/19380/external-vs-public-best-practices

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a pending PR on automation repo to change all ServiceRegistry visibility as well

Copy link
Contributor

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the general direction where this is going, will give additional comments when the PR is ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants