feat(redemption-controller): implement initialize and update functions for redemption rate feedback controller

- Added `initialize_redemption_controller` and `update_redemption_controller` functions to manage redemption rate feedback.
- Introduced `RedemptionController` struct to maintain state for redemption rates.
- Updated `Cargo.toml` and `Cargo.lock` to include `twap_oracle_core` dependency.
- Modified integration tests to cover new redemption controller functionality.
This commit is contained in:
Ricardo Guilherme Schmidt
2026-07-03 09:42:45 -03:00
parent 4a6192d84f
commit d2f3e1d8fb
9 changed files with 1032 additions and 4 deletions
+140
View File
@@ -112,6 +112,86 @@
"type": "u128"
}
]
},
{
"name": "initialize_redemption_controller",
"accounts": [
{
"name": "controller",
"writable": false,
"signer": false,
"init": false
},
{
"name": "stablecoin_definition",
"writable": false,
"signer": false,
"init": false
},
{
"name": "price_feed",
"writable": false,
"signer": false,
"init": false
}
],
"args": [
{
"name": "reference_asset_id",
"type": "account_id"
},
{
"name": "initial_redemption_price",
"type": "u128"
},
{
"name": "proportional_gain",
"type": "u128"
},
{
"name": "integral_gain",
"type": "u128"
},
{
"name": "max_integral_error",
"type": "u128"
},
{
"name": "max_redemption_rate",
"type": "u128"
},
{
"name": "max_price_feed_age",
"type": "u64"
},
{
"name": "current_timestamp",
"type": "u64"
}
]
},
{
"name": "update_redemption_controller",
"accounts": [
{
"name": "controller",
"writable": false,
"signer": false,
"init": false
},
{
"name": "price_feed",
"writable": false,
"signer": false,
"init": false
}
],
"args": [
{
"name": "current_timestamp",
"type": "u64"
}
]
}
],
"accounts": [
@@ -139,6 +219,66 @@
]
}
},
{
"name": "RedemptionController",
"type": {
"kind": "struct",
"fields": [
{
"name": "stablecoin_definition_id",
"type": "account_id"
},
{
"name": "reference_asset_id",
"type": "account_id"
},
{
"name": "price_feed_id",
"type": "account_id"
},
{
"name": "oracle_program_id",
"type": "program_id"
},
{
"name": "redemption_price",
"type": "u128"
},
{
"name": "redemption_rate",
"type": "i128"
},
{
"name": "accumulated_error",
"type": "i128"
},
{
"name": "proportional_gain",
"type": "u128"
},
{
"name": "integral_gain",
"type": "u128"
},
{
"name": "max_integral_error",
"type": "u128"
},
{
"name": "max_redemption_rate",
"type": "u128"
},
{
"name": "max_price_feed_age",
"type": "u64"
},
{
"name": "last_update_timestamp",
"type": "u64"
}
]
}
},
{
"name": "TokenDefinition",
"type": {