Skip to content

Commit

Permalink
Peckshield audit fixes + other changes (#37)
Browse files Browse the repository at this point in the history
Changelog:
1. Added new built artifacts (till this branch's code changes) using the
CW Optimizer docker script.
2. Added generated cw schema for all the contracts.
3. Added peckshield fixes
4. Added support for inilitiazing LP Token code id later i.e. skipping
it during vault initialization. This is kinda needed in new
instantiation method.
  • Loading branch information
betterclever committed Dec 15, 2022
1 parent d2db2ab commit 5947d7a
Show file tree
Hide file tree
Showing 40 changed files with 2,152 additions and 373 deletions.
Binary file modified artifacts/anchor_staking.wasm
Binary file not shown.
25 changes: 13 additions & 12 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
0738f3d3a72ca8185e93d135de005f738cce9c53c2608fa631bbc640ec8ab7a1 anchor_staking.wasm
859c11c9b16490a39c5ac2193ea887baa20699f041a75138e2f1d6d083acc035 dexter_generator.wasm
f2a67524ada8957d979471090e94ac9c157a80fb359b91ea870a046385b113f2 dexter_generator_proxy.wasm
9dba4d26aef61ff28d45f7f7beea68aa14adf9efd270aeaebdac1713e5fc2646 dexter_keeper.wasm
712d320459fd7ed6ef35ad00369b03957a1b23305385b3f376c7db41f68b4ca7 dexter_router.wasm
2818aff7ab84d2c9e6f2330508768328db24e025664872ffa860dd62442d56f2 dexter_vault.wasm
9cdf5cf2e02cff632ea84b4f33c8d15db15c4a38ae10e22ac72be723b848da0b dexter_vesting.wasm
dbf58fa3e5450fc4fea96ee6d04d42ebd8e4d73c86c3c64a12bb2ed0d139320e lp_token.wasm
967e31f071b906ba2aec99b73fc696be4e44b7bffba2ce4b0c76721bac868903 stable5pool.wasm
7f9ae916a14ffe815125561197905a86c2ca8e6f17e6495b3c19098702ea0e48 stableswap_pool.wasm
5d4072a56490b6c6234a5fb35a9cbbdb8f923cfdb998d1ef882073273ae4a01b weighted_pool.wasm
1c8226732d6c597caf289001c4f199eb8a50dc7328885064a2c92c80882e6f63 xyk_pool.wasm
480fe5850a73cf97deb0a89f7ece84738983c3071eb2c428b71a6549b16d23e3 anchor_staking.wasm
c36dcdad3c9fc1fb1d67ddd3d2094d5cd0a1e144b2e1255581be8bcd394d3fd4 dexter_generator.wasm
92df0790fc578be36cdd0d4e530a36ff9c18ac8afe2040ab200e54d8c5b90df1 dexter_generator_proxy.wasm
05513a2e692c30ce3fa61f2a912bd5a928d095f99f773c2309cb1e3ca83598bd dexter_keeper.wasm
b7c87d521400462face9cc26be2c86f6d8228d21f67133a819d5e1b6469bc15b dexter_multi_staking.wasm
35d8233b2c46fc3383dd07c0457a0c94590cedf58c7a8c84a28ea81697a86a61 dexter_router.wasm
4d1523e887aa2873d8eeee95b7fa6051420e9ee2f7fccdcb4cb9b57ee20bf93a dexter_vault.wasm
7369217a8016c622bba91a673d9e4790f76a5512cf7628423a1082942e67a172 dexter_vesting.wasm
e90853a602ca96c63f6fb01dae786d05a36e3df59f82aba3505d874dd73eed85 lp_token.wasm
d4f82437887f3cf1728120e0ecf40941c80f1063e724d3bd1eb988f6a93ddad9 stable5pool.wasm
c611c54d637caec8424df72184449d8fa5e6fdef38163d05897fe7bfdcdbffd1 stableswap_pool.wasm
dd59496a064c596fcaf9593517ac4ff1236dbbab2cad65da9013afa0844fe1ae weighted_pool.wasm
29a3f8294d3b1474555c3bd7bc4174c34df6654e1646ef8ce14874a3a9f657bb xyk_pool.wasm
25 changes: 13 additions & 12 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
a618432d06c712d8908d6e1b8d688dfe17732fc133115ffb194e139be563956b target/wasm32-unknown-unknown/release/anchor_staking.wasm
2814707cb554c1026e36857f4662253920fc09b41701ad99d160b07684fdea92 target/wasm32-unknown-unknown/release/dexter_generator.wasm
a6ead4da0a19fbdea6fb7fdb6cdad119b2f6bda9713bb182ec5ce00cc0a4b00f target/wasm32-unknown-unknown/release/dexter_generator_proxy.wasm
8c9c9b382bd2f0cc0cf0b82bab7faaadd7dd4837cff1b7ad6cdd64c9e1ba4c5a target/wasm32-unknown-unknown/release/dexter_keeper.wasm
423bdb4e8dd9b0d5f3d3a45664765220b245499b1c9613757029609d3ce5cb38 target/wasm32-unknown-unknown/release/dexter_router.wasm
3f40c911c37a8b4f02a80f9cbb86c6afa533b1f0107ddb142a93ae0532a86343 target/wasm32-unknown-unknown/release/dexter_vault.wasm
4056bc3411bb32fe51556a5df0199ae488f8f08257b51342d318dfa8f083f853 target/wasm32-unknown-unknown/release/dexter_vesting.wasm
3e25ab748c54bd61fee18b0519c8ad299970ffd10a7af6017949a223a3168916 target/wasm32-unknown-unknown/release/lp_token.wasm
86304c8a5d210b8f9a6b095cab289fee7f79abe81ab625bd5ac540b2cf8f8bc3 target/wasm32-unknown-unknown/release/stable5pool.wasm
cf8b20947e54ca448d764ef8c342c3769905719fd81de9fc45dc30b20e0a54a5 target/wasm32-unknown-unknown/release/stableswap_pool.wasm
2ff5e7a0882a993ecb2c252b1ed08a91816c874f37d75589606091567897a085 target/wasm32-unknown-unknown/release/weighted_pool.wasm
9bfe39746e23a7ff3bb33618c5fe76d522a1984ae5c6b44ad438abcae19e6d71 target/wasm32-unknown-unknown/release/xyk_pool.wasm
75da4420791ef66573b77a6c2b9fcd89741f5822432a32b8ffb738e1d6149c2f ./target/wasm32-unknown-unknown/release/anchor_staking.wasm
3c6abbbd8f605382d80aa8ac3062d443af93c112230b7f98441a364afc210abe ./target/wasm32-unknown-unknown/release/dexter_generator.wasm
4f20d0c54fc0ac3eb937c57aabfce92431859da05c5d5789f54694078b4e8b73 ./target/wasm32-unknown-unknown/release/dexter_generator_proxy.wasm
e61d61225daeea4c505b6a4b36e6d7e5ab7c0b3889a853157b763b28d9c5e1b6 ./target/wasm32-unknown-unknown/release/dexter_keeper.wasm
9c92cf00a449e79c5e02bdd12199cf81a67daefc069301b8d10545c86d75e708 ./target/wasm32-unknown-unknown/release/dexter_multi_staking.wasm
817c3c677203ee0e56b852b0940f032b77b5e21c5f58fe8e31715d10ce991cf4 ./target/wasm32-unknown-unknown/release/dexter_router.wasm
4dbaf916cc3d01a29e23d49daf91cc98b32cc6f6966f2341465b977963cf06e6 ./target/wasm32-unknown-unknown/release/dexter_vault.wasm
4d0d402d89383a03cc45940c2759feb080a235ebd47ec17e233eab90b9428ec1 ./target/wasm32-unknown-unknown/release/dexter_vesting.wasm
2a2d1eb8cb8e888524fba919fd656daf90336ad7d646930c9a3a1a1f1a5d764e ./target/wasm32-unknown-unknown/release/lp_token.wasm
15e134d88ca2a7b7c8810fefd077c24ab9f032d48eb8d8d4fab363ffb32043ab ./target/wasm32-unknown-unknown/release/stable5pool.wasm
cf404c3f07ea6905e15c831aaca8732adb10efb5dad1a601d87266c889e7d8fe ./target/wasm32-unknown-unknown/release/stableswap_pool.wasm
e244dab721c72a370856b1a988205f53f0b3523930c5cb63f60c1963223e42b5 ./target/wasm32-unknown-unknown/release/weighted_pool.wasm
efeeecdfb0590caad3226ec7fb48ddba4d51114a0916b733cc0e6e507b56c58e ./target/wasm32-unknown-unknown/release/xyk_pool.wasm
Binary file modified artifacts/dexter_generator.wasm
Binary file not shown.
Binary file modified artifacts/dexter_generator_proxy.wasm
Binary file not shown.
Binary file modified artifacts/dexter_keeper.wasm
Binary file not shown.
Binary file added artifacts/dexter_multi_staking.wasm
Binary file not shown.
Binary file modified artifacts/dexter_router.wasm
Binary file not shown.
Binary file modified artifacts/dexter_vault.wasm
Binary file not shown.
Binary file modified artifacts/dexter_vesting.wasm
Binary file not shown.
Binary file modified artifacts/lp_token.wasm
Binary file not shown.
Binary file modified artifacts/stable5pool.wasm
Binary file not shown.
Binary file modified artifacts/stableswap_pool.wasm
Binary file not shown.
Binary file modified artifacts/weighted_pool.wasm
Binary file not shown.
Binary file modified artifacts/xyk_pool.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/dexter_generator/generator/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn instantiate_contracts(app: &mut App, owner: Addr) -> (Addr, Addr) {
}];
let vault_init_msg = VaultInstantiateMsg {
pool_configs: pool_configs.clone(),
lp_token_code_id: token_code_id,
lp_token_code_id: Some(token_code_id),
fee_collector: Some("fee_collector".to_string()),
owner: owner.to_string(),
pool_creation_fee: None,
Expand Down
181 changes: 179 additions & 2 deletions contracts/keeper/schema/dexter-keeper.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@
"description": "This struct describes the Msg used to instantiate in this contract.",
"type": "object",
"required": [
"owner",
"vault_contract"
],
"properties": {
"owner": {
"description": "Owner address",
"allOf": [
{
"$ref": "#/definitions/Addr"
}
]
},
"vault_contract": {
"description": "The vault contract address",
"type": "string"
}
},
"additionalProperties": false
"additionalProperties": false,
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
}
}
},
"execute": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down Expand Up @@ -52,8 +67,170 @@
}
},
"additionalProperties": false
},
{
"description": "Withdraws an asset from the contract This is used to withdraw the fees collected by the contract by the owner",
"type": "object",
"required": [
"withdraw"
],
"properties": {
"withdraw": {
"type": "object",
"required": [
"amount",
"asset"
],
"properties": {
"amount": {
"description": "The amount to withdraw",
"allOf": [
{
"$ref": "#/definitions/Uint128"
}
]
},
"asset": {
"description": "The asset to withdraw",
"allOf": [
{
"$ref": "#/definitions/AssetInfo"
}
]
},
"recipient": {
"description": "The recipient address. If None, the owner address will be used",
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "ProposeNewOwner creates an offer for a new owner. The validity period of the offer is set in the `expires_in` variable.",
"type": "object",
"required": [
"propose_new_owner"
],
"properties": {
"propose_new_owner": {
"type": "object",
"required": [
"expires_in",
"owner"
],
"properties": {
"expires_in": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"owner": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "DropOwnershipProposal removes the existing offer for the new owner.",
"type": "object",
"required": [
"drop_ownership_proposal"
],
"properties": {
"drop_ownership_proposal": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Used to claim(approve) new owner proposal, thus changing contract's owner",
"type": "object",
"required": [
"claim_ownership"
],
"properties": {
"claim_ownership": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"AssetInfo": {
"description": "This enum describes available Token types.",
"oneOf": [
{
"description": "Non-native Token",
"type": "object",
"required": [
"token"
],
"properties": {
"token": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"$ref": "#/definitions/Addr"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Native token",
"type": "object",
"required": [
"native_token"
],
"properties": {
"native_token": {
"type": "object",
"required": [
"denom"
],
"properties": {
"denom": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
]
}
},
"query": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/keeper/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn instantiate_contracts(
allow_instantiation: dexter::vault::AllowPoolInstantiation::Everyone,
is_generator_disabled: false,
}],
lp_token_code_id: 1u64,
lp_token_code_id: Some(1u64),
fee_collector: None,
owner: owner.to_string(),
pool_creation_fee: None,
Expand Down
6 changes: 6 additions & 0 deletions contracts/multi_staking/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example multi_staking"
1 change: 1 addition & 0 deletions contracts/multi_staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cosmwasm-schema = "1.1"
serde-json-wasm = "0.4.1"

[dev-dependencies]
cosmwasm-schema = "1.1"
lp-token = {path = "../lp_token"}
cw-multi-test = "0.13.2"
cw20-base = "0.15.0"
Expand Down
11 changes: 11 additions & 0 deletions contracts/multi_staking/examples/multi_staking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;
use dexter::multi_staking::{InstantiateMsg, QueryMsg, ExecuteMsg, MigrateMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg,
}
}
Loading

0 comments on commit 5947d7a

Please sign in to comment.