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

Test/remove liquidity #4

Merged
merged 4 commits into from
Aug 21, 2024
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
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[workspace.package]
name = "mira-v1-periphery"
authors = ["Mira AMM"]
version = "0.1.0"
edition = "2021"

[workspace]
resolver = "2"
members = ["./scripts/add_liquidity_script", "./test-harness"]
members = [
"./scripts/add_liquidity_script",
"./test-harness",
"./scripts/remove_liquidity_script",
]

[workspace.dependencies]
fuels = { version = "0.62.0", features = ["fuel-core-lib"] }
Expand Down
140 changes: 102 additions & 38 deletions fixtures/mira-amm/mira_amm_contract-abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
"type": 0,
"typeArguments": null
},
{
"name": "CannotAddLessThanMinimumLiquidity",
"type": 0,
"typeArguments": null
},
{
"name": "CurveInvariantViolation",
"type": 2,
Expand Down Expand Up @@ -184,6 +189,16 @@
"name": "LPTokenHashCollision",
"type": 0,
"typeArguments": null
},
{
"name": "NotAdmin",
"type": 0,
"typeArguments": null
},
{
"name": "ProtocolFeesAreTooHigh",
"type": 0,
"typeArguments": null
}
],
"typeParameters": null
Expand All @@ -203,7 +218,9 @@
"typeArguments": null
}
],
"typeParameters": [12]
"typeParameters": [
12
]
},
{
"typeId": 11,
Expand Down Expand Up @@ -439,7 +456,9 @@
"typeArguments": null
}
],
"typeParameters": [12]
"typeParameters": [
12
]
},
{
"typeId": 25,
Expand Down Expand Up @@ -511,7 +530,9 @@
"typeArguments": null
}
],
"typeParameters": [12]
"typeParameters": [
12
]
},
{
"typeId": 28,
Expand Down Expand Up @@ -556,7 +577,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand All @@ -583,7 +606,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand All @@ -610,7 +635,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand All @@ -625,7 +652,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand All @@ -652,7 +681,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand Down Expand Up @@ -682,7 +713,10 @@
},
{
"name": "storage",
"arguments": ["read", "write"]
"arguments": [
"read",
"write"
]
}
]
},
Expand Down Expand Up @@ -723,7 +757,10 @@
"attributes": [
{
"name": "storage",
"arguments": ["read", "write"]
"arguments": [
"read",
"write"
]
}
]
},
Expand All @@ -735,7 +772,14 @@
"type": 3,
"typeArguments": null
},
"attributes": null
"attributes": [
{
"name": "storage",
"arguments": [
"read"
]
}
]
},
{
"inputs": [
Expand All @@ -759,7 +803,10 @@
"attributes": [
{
"name": "storage",
"arguments": ["read", "write"]
"arguments": [
"read",
"write"
]
}
]
},
Expand All @@ -786,7 +833,9 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
Expand All @@ -807,7 +856,37 @@
"attributes": [
{
"name": "storage",
"arguments": ["read"]
"arguments": [
"read"
]
}
]
},
{
"inputs": [
{
"name": "volatile_fee",
"type": 29,
"typeArguments": null
},
{
"name": "stable_fee",
"type": 29,
"typeArguments": null
}
],
"name": "set_protocol_fees",
"output": {
"name": "",
"type": 0,
"typeArguments": null
},
"attributes": [
{
"name": "storage",
"arguments": [
"write"
]
}
]
},
Expand Down Expand Up @@ -852,7 +931,10 @@
},
{
"name": "storage",
"arguments": ["read", "write"]
"arguments": [
"read",
"write"
]
}
]
}
Expand Down Expand Up @@ -924,7 +1006,7 @@
"type": 29,
"typeArguments": null
},
"offset": 55712
"offset": 58056
},
{
"name": "LP_FEE_STABLE",
Expand All @@ -933,34 +1015,16 @@
"type": 29,
"typeArguments": null
},
"offset": 55704
},
{
"name": "PROTOCOL_FEE_VOLATILE",
"configurableType": {
"name": "",
"type": 29,
"typeArguments": null
},
"offset": 55768
},
{
"name": "PROTOCOL_FEE_STABLE",
"configurableType": {
"name": "",
"type": 29,
"typeArguments": null
},
"offset": 55760
"offset": 58048
},
{
"name": "PROTOCOL_FEES_COLLECTOR",
"name": "ADMIN",
"configurableType": {
"name": "",
"type": 8,
"typeArguments": []
},
"offset": 55720
"offset": 58008
}
]
}
}
Binary file modified fixtures/mira-amm/mira_amm_contract.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions libraries/utils/src/blockchain_utils.sw
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub fn check_deadline(deadline: u32) {
}

/// Builds and returns an LP sub id and asset id for the provided pool id
pub fn get_lp_asset(pool_id: PoolId) -> (b256, AssetId) {
pub fn get_lp_asset(contract_id: ContractId, pool_id: PoolId) -> (b256, AssetId) {
let lp_sub_id = sha256(pool_id);
(lp_sub_id, AssetId::new(ContractId::this(), lp_sub_id))
(lp_sub_id, AssetId::new(contract_id, lp_sub_id))
}

pub fn is_stable(pool_id: PoolId) -> bool {
Expand Down
Loading