Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions src/orders/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4

[*.tree]
indent_size = 1
37 changes: 37 additions & 0 deletions src/orders/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# RPC endpoint URL for the target blockchain network
# Example: https://evm.chiado.wardenprotocol.org
RPC_URL=""

# Chain ID of the target network
# Example: 10010 (Warden chiado), 1337 (Local)
CHAIN_ID=""

# Address of the create2 proxy contract
# Format: 0x{40 hex characters}
CREATE2_ADDRESS=""

# Address of the scheduler
# Format: 0x{40 hex characters}
SCHEDULER_ADDRESS=""

# Address of the factory contract owner
# Format: 0x{40 hex characters}
FACTORY_OWNER_ADDRESS=""

# Address of the registry contract
# Format: 0x{40 hex characters}
REGISTRY_ADDRESS=""

# WARNING: This is a sensitive value that provides access to funds.
# Never commit the actual mnemonic to version control.
# Format: 12 or 24 word seed phrase
MNEMONIC=""


# Salt used to deploy registry contract
# Format: 0 to 309485009821345068724781055 random integer
REGISTRY_SALT=""

# Salt used to deploy factory contract
# Format: 0 to 309485009821345068724781055 random integer
FACTORY_SALT=""
22 changes: 22 additions & 0 deletions src/orders/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# directories
cache
coverage
node_modules
out

# files
*.env
*.log
.DS_Store
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock

# broadcasts
broadcast/**
!broadcast/Deploy.s.sol
!broadcast/Deploy.s.sol/12345
!broadcast/Deploy.s.sol/12345/latest.json
!broadcast/Deploy.s.sol/12345/run-latest.json
18 changes: 18 additions & 0 deletions src/orders/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# directories
broadcast
cache
coverage
node_modules
out
lib

# files
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
7 changes: 7 additions & 0 deletions src/orders/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false
14 changes: 14 additions & 0 deletions src/orders/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "solhint:recommended",
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.25"],
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"one-contract-per-file": "off"
}
}
1 change: 1 addition & 0 deletions src/orders/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/RLPEncode.sol
10 changes: 10 additions & 0 deletions src/orders/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"solidity.formatter": "forge",
"editor.formatOnSave": true
}
21 changes: 21 additions & 0 deletions src/orders/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Automated uniswap contracts

### Commands

Before using commands install dependencies with `yarn install`.

#### Build

```sh
yarn build
```

#### Tests

```sh
yarn test
```

### Order

### Factory
4 changes: 4 additions & 0 deletions src/orders/broadcast/Deploy.s.sol/12345/latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"orderFactory": "0x7f64E16EC2557FC17150883C7DeDc7E9AD936CDF",
"registry": "0x3565F2c0C305BbEEB0A433FeAaFaCC4E8F1Dca83"
}
238 changes: 238 additions & 0 deletions src/orders/broadcast/Deploy.s.sol/12345/run-latest.json

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions src/orders/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config

[profile.default]
auto_detect_solc = false
block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT
bytecode_hash = "none"
evm_version = "paris"
fuzz = { runs = 1_000 }
gas_reports = ["*"]
optimizer = true
optimizer_runs = 10_000
out = "out"
script = "script"
solc = "0.8.25"
src = "src"
test = "test"
fs_permissions = [
{ access = "read-write", path = "./broadcast/Deploy.s.sol/"}
]

[profile.ci]
fuzz = { runs = 10_000 }
verbosity = 4

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
52 changes: 52 additions & 0 deletions src/orders/mocks/MockAsyncPrecompile.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.25 <0.9.0;

import {
Future,
FutureByIdResponse,
FutureResponse,
FuturesResponse,
FutureResult,
FutureVote,
IAsync,
PendingFuturesResponse
} from "../precompiles/async/IAsync.sol";
import { Types } from "../precompiles/async/IAsync.sol";

contract MockAsyncPrecompile is IAsync {
uint64 public futuresCount = 0;
mapping(uint64 id => FutureByIdResponse output) public _futures;
mapping(address orderAddress => address orderCreator) public orders;

function addFuture(string calldata handler, bytes calldata input) external returns (uint64 futureId) {
futureId = uint64(++futuresCount);
Future memory future = Future({
id: futureId,
// solhint-disable-next-line
creator: tx.origin,
handler: handler,
input: input
});

FutureVote[] memory emptyVotes = new FutureVote[](0);
bytes memory emptySubmitter;
FutureResult memory futureResult = FutureResult({ id: futureId, output: input, submitter: emptySubmitter });
FutureResponse memory futureResponse =
FutureResponse({ future: future, votes: emptyVotes, result: futureResult });
_futures[futureId] = FutureByIdResponse({ futureResponse: futureResponse });
}

function futureById(uint64 futureId) external view returns (FutureByIdResponse memory response) {
response = _futures[futureId];
}

function futures(Types.PageRequest calldata, address) external pure returns (FuturesResponse memory) {
// solhint-disable-next-line
revert("Unimplemented");
}

function pendingFutures(Types.PageRequest calldata) external pure returns (PendingFuturesResponse memory) {
// solhint-disable-next-line
revert("Unimplemented");
}
}
34 changes: 34 additions & 0 deletions src/orders/mocks/MockSlinkyPrecompile.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.25 <0.9.0;

import { GetPriceResponse, QuotePrice, ISlinky } from "../precompiles/slinky/ISlinky.sol";

contract MockSlinkyPrecompile is ISlinky {
mapping(string base => mapping(string quote => uint256 price)) private prices;

function getPrice(
string calldata base,
string calldata quote
)
external
view
returns (GetPriceResponse memory response)
{
uint256 price = prices[base][quote];
if (price == 0) {
string memory s1 = string.concat("no price / nonce reported for CurrencyPair: ", base);
string memory s2 = string.concat(s1, "/");
string memory s3 = string.concat(s2, quote);
string memory s4 = string.concat(s3, ", the module is not tracking this CurrencyPair");
revert(s4);
}

QuotePrice memory quotePrice = QuotePrice({ blockHeight: 0, blockTimestamp: 0, price: price });

response = GetPriceResponse({ id: 0, nonce: 0, decimals: 9, price: quotePrice });
}

function setPrice(string calldata base, string calldata quote, uint256 price) external {
prices[base][quote] = price;
}
}
43 changes: 43 additions & 0 deletions src/orders/mocks/MockWardenPrecompile.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.25 <0.9.0;

import { AddressesResponse, AddressType, BroadcastType, Key, KeyResponse } from "../precompiles/warden/IWarden.sol";
import { Types } from "../precompiles/common/Types.sol";

contract MockWardenPrecompile {
mapping(uint64 keyId => KeyResponse keyResponse) private keys;
mapping(uint64 keyId => bool isGood) private goodKeys;

function keyById(uint64, int32[] calldata) external pure returns (KeyResponse memory keyResponse) {
Key memory key;
AddressesResponse[] memory addresses = new AddressesResponse[](1);
addresses[0] = AddressesResponse({
addressValue: "0x0000000000000000000000000000000000000000",
addressType: AddressType.Ethereum
});
keyResponse = KeyResponse({ key: key, addresses: addresses });
}

function newSignRequest(
uint64 keyId,
bytes calldata,
bytes[] calldata,
bytes calldata,
Types.Coin[] calldata,
uint64,
uint64,
string calldata,
string calldata,
BroadcastType
)
external
view
returns (bool isGood)
{
isGood = goodKeys[keyId];
}

function addKey(uint64 keyId, bool isGood) external {
goodKeys[keyId] = isGood;
}
}
27 changes: 27 additions & 0 deletions src/orders/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@wardenprotocol/orders",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^3.0.0",
"solhint": "^3.6.2"
},
"dependencies": {
"@0xsequence/create3": "https://github.com/0xsequence/create3#acc4703a21ec1d71dc2a99db088c4b1f467530fd",
"@openzeppelin/contracts": "^5.0.1"
},
"scripts": {
"clean": "rm -rf cache out",
"build": "forge build src --via-ir",
"lint": "yarn run lint:sol && yarn run prettier:check",
"lint:sol": "forge fmt --check && yarn solhint \"{script,src,test}/**/*.sol\"",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"",
"test": "forge test --via-ir",
"test:coverage": "forge coverage",
"test:coverage:report": "forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage",
"deploy": "forge script script/Deploy.s.sol:Deploy --chain $CHAIN_ID --rpc-url $RPC_URL --broadcast -vvvv --via-ir --slow"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
Loading
Loading