Skip to content

Commit 5808049

Browse files
authored
script: deploy receptor (#602)
This PR adds a script to deploy receptor on mainnet. It does not yet grant permission yet for the Receptor to call `shrine.update_yin_spot_price()`. Sepolia is not included because the prices of CASH against {DAI, USDC, USDT} are too far off peg to be a meaningful simulation.
1 parent a91d145 commit 5808049

7 files changed

+82
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Once you kill your Devnet instance, the state is lost unless the latest `devnet_
3636
| Gate[WSTETH] | `0x02d1e95661e7726022071c06a95cdae092595954096c373cde24a34bb3984cbf` |
3737
| Pragma | `0x0734abeebd842926c860f3f82d23a7d2e0a24c8756d7f6b88a7456dc95a7e0fd` |
3838
| Purger | `0x0149c1539f39945ce1f63917ff6076845888ab40e9327640cb78dcaebfed42e4` |
39+
| Receptor | `0x11ded1ba51cd7fd7dff2ad5e92ed6c1bc7b5c905b7d5961a803f069a195341a` |
3940
| Seer | `0x07b4d65be7415812cea9edcfce5cf169217f4a53fce84e693fe8efb5be9f0437` |
4041
| Sentinel | `0x06428ec3221f369792df13e7d59580902f1bfabd56a81d30224f4f282ba380cd` |
4142
| Shrine | `0x0498edfaf50ca5855666a700c25dd629d577eb9afccdf3b5977aec79aee55ada` |

scripts/deployment/Scarb.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ build-external-contracts = [
2626
"opus::core::flash_mint::flash_mint",
2727
"opus::core::gate::gate",
2828
"opus::core::purger::purger",
29+
"opus::core::receptor::receptor",
2930
"opus::core::seer::seer",
3031
"opus::core::sentinel::sentinel",
3132
"opus::core::shrine::shrine",

scripts/deployment/deploy_mainnet_alpha-mainnet_state.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,28 @@
10041004
"status": "Success",
10051005
"timestamp": 1719851246,
10061006
"misc": null
1007+
},
1008+
"9fd28df144c99f124f3073ec264f4dfc262383fd0d7dc7cceb146566b7332a8a": {
1009+
"name": "declare",
1010+
"output": {
1011+
"type": "DeclareResponse",
1012+
"class_hash": "0x57bd7a6dbd72ec03094ac473b62c97e24f7244d7e622a42a3ec7d86ef2cd0b5",
1013+
"transaction_hash": "0x175f42b42cf1bafb788415944b768ca17970b759588f0d2eca0ede75b759379"
1014+
},
1015+
"status": "Success",
1016+
"timestamp": 1727965110,
1017+
"misc": null
1018+
},
1019+
"8452980510542669c3c0d25b7a2f58058f2bc0eedf6e76aa627b64885e909371": {
1020+
"name": "deploy",
1021+
"output": {
1022+
"type": "DeployResponse",
1023+
"contract_address": "0x11ded1ba51cd7fd7dff2ad5e92ed6c1bc7b5c905b7d5961a803f069a195341a",
1024+
"transaction_hash": "0x77d94ce478d41aac063bab7b5809c8098840295522ce615def5cc8365f8276e"
1025+
},
1026+
"status": "Success",
1027+
"timestamp": 1727965117,
1028+
"misc": null
10071029
}
10081030
}
10091031
}

scripts/deployment/snfoundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ url = "http://127.0.0.1:5050"
66
[sncast.mainnet]
77
account = "../mainnet_admin.json"
88
keystore = "../mainnet_admin_keystore.json"
9-
url = ""
9+
url = "https://free-rpc.nethermind.io/mainnet-juno"
1010

1111
[sncast.sepolia]
1212
account = "../sepolia_admin.json"

scripts/deployment/src/core_deployment.cairo

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use scripts::addresses;
12
use scripts::constants::MAX_FEE;
23
use sncast_std::{
34
declare, DeclareResult, deploy, DeployResult, DisplayClassHash, DisplayContractAddress, invoke, InvokeResult,
@@ -14,6 +15,10 @@ const BETA_P: u8 = 8;
1415
const ALPHA_I: u8 = 1;
1516
const BETA_I: u8 = 2;
1617

18+
// Constants for Receptor
19+
const RECEPTOR_UPDATE_FREQUENCY: u64 = 1000;
20+
const RECEPTOR_TWAP_DURATION: u64 = 10800; // 3 hours
21+
1722
// Constants for Seer
1823
const SEER_UPDATE_FREQUENCY: u64 = 1000;
1924

@@ -189,6 +194,29 @@ pub fn deploy_controller(admin: ContractAddress, shrine: ContractAddress) -> Con
189194
deploy_controller.contract_address
190195
}
191196

197+
pub fn deploy_receptor(admin: ContractAddress, shrine: ContractAddress) -> ContractAddress {
198+
let declare_receptor = declare("receptor", Option::Some(MAX_FEE), Option::None).expect('failed receptor declare');
199+
200+
let num_quote_tokens: felt252 = 3;
201+
let receptor_calldata: Array<felt252> = array![
202+
admin.into(),
203+
shrine.into(),
204+
addresses::mainnet::ekubo_oracle_extension().into(),
205+
RECEPTOR_UPDATE_FREQUENCY.into(),
206+
RECEPTOR_TWAP_DURATION.into(),
207+
num_quote_tokens,
208+
addresses::mainnet::dai().into(),
209+
addresses::mainnet::usdc().into(),
210+
addresses::mainnet::usdt().into(),
211+
];
212+
let deploy_receptor = deploy(
213+
declare_receptor.class_hash, receptor_calldata, Option::None, true, Option::Some(MAX_FEE), Option::None
214+
)
215+
.expect('failed receptor deploy');
216+
217+
deploy_receptor.contract_address
218+
}
219+
192220
pub fn declare_gate() -> ClassHash {
193221
declare("gate", Option::Some(MAX_FEE), Option::None).expect('failed gate declare').class_hash
194222
}

scripts/deployment/src/deploy_mainnet.cairo

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717

1818
println!("Deploying contracts");
1919

20-
// Deploy core contracts
20+
// Deploy core contracts for launch
2121
let shrine: ContractAddress = core_deployment::deploy_shrine(admin);
2222
let flash_mint: ContractAddress = core_deployment::deploy_flash_mint(shrine);
2323
let sentinel: ContractAddress = core_deployment::deploy_sentinel(admin, shrine);
@@ -30,6 +30,9 @@ fn main() {
3030
let caretaker: ContractAddress = core_deployment::deploy_caretaker(admin, shrine, abbot, sentinel, equalizer);
3131
let controller: ContractAddress = core_deployment::deploy_controller(admin, shrine);
3232

33+
// Deploy core contracts after launch
34+
let receptor: ContractAddress = core_deployment::deploy_receptor(addresses::mainnet::multisig(), shrine);
35+
3336
// Deploy transmuter
3437
let usdc_transmuter_restricted: ContractAddress = core_deployment::deploy_transmuter_restricted(
3538
admin, shrine, addresses::mainnet::usdc(), admin, constants::USDC_TRANSMUTER_RESTRICTED_DEBT_CEILING
@@ -221,6 +224,7 @@ fn main() {
221224
println!("Gate[WSTETH]: {}", wsteth_gate);
222225
println!("Pragma: {}", pragma);
223226
println!("Purger: {}", purger);
227+
println!("Receptor: {}", receptor);
224228
println!("Seer: {}", seer);
225229
println!("Sentinel: {}", sentinel);
226230
println!("Shrine: {}", shrine);

scripts/src/addresses.cairo

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,39 @@ pub mod mainnet {
211211
}
212212

213213
// Tokens
214-
214+
//
215+
// Unless otherwise stated, token's address is available at:
215216
// https://github.com/starknet-io/starknet-addresses/blob/master/bridged_tokens/mainnet.json
217+
218+
pub fn dai() -> ContractAddress {
219+
0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad.try_into().expect('invalid DAI address')
220+
}
221+
216222
pub fn usdc() -> ContractAddress {
217223
0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8.try_into().expect('invalid USDC address')
218224
}
219225

220-
// https://github.com/starknet-io/starknet-addresses/blob/master/bridged_tokens/mainnet.json
226+
pub fn usdt() -> ContractAddress {
227+
0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8.try_into().expect('invalid USDC address')
228+
}
229+
221230
pub fn wbtc() -> ContractAddress {
222231
0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac.try_into().expect('invalid WBTC address')
223232
}
224233

225-
// https://research.lido.fi/t/wsteth-deployment-on-starknet/6335
226234
pub fn wsteth() -> ContractAddress {
227235
0x042b8f0484674ca266ac5d08e4ac6a3fe65bd3129795def2dca5c34ecc5f96d2.try_into().expect('invalid WSTETH address')
228236
}
229237

238+
// External
239+
240+
// https://docs.ekubo.org/integration-guides/reference/contract-addresses
241+
pub fn ekubo_oracle_extension() -> ContractAddress {
242+
0x005e470ff654d834983a46b8f29dfa99963d5044b993cb7b9c92243a69dab38f
243+
.try_into()
244+
.expect('invalid ekubo oracle addr')
245+
}
246+
230247
// https://github.com/Astraly-Labs/pragma-oracle?tab=readme-ov-file#deployment-addresses
231248
pub fn pragma_spot_oracle() -> ContractAddress {
232249
0x2a85bd616f912537c50a49a4076db02c00b29b2cdc8a197ce92ed1837fa875b
@@ -285,6 +302,10 @@ pub mod mainnet {
285302
0x0149c1539f39945ce1f63917ff6076845888ab40e9327640cb78dcaebfed42e4.try_into().unwrap()
286303
}
287304

305+
pub fn receptor() -> ContractAddress {
306+
0x11ded1ba51cd7fd7dff2ad5e92ed6c1bc7b5c905b7d5961a803f069a195341a.try_into().unwrap()
307+
}
308+
288309
pub fn seer() -> ContractAddress {
289310
0x07b4d65be7415812cea9edcfce5cf169217f4a53fce84e693fe8efb5be9f0437.try_into().unwrap()
290311
}

0 commit comments

Comments
 (0)