From 7936e04f66a2dbb0eace7c5ef077c2293393b12b Mon Sep 17 00:00:00 2001 From: Alex Mootz Date: Fri, 6 Oct 2023 09:52:48 -0400 Subject: [PATCH] chore: update to rc2 and lower bump limits --- .gitignore | 4 +- Cargo.lock | 40 +++++------ Cargo.toml | 2 +- Makefile | 3 - backstop-module/src/emissions/manager.rs | 2 +- backstop-module/src/storage.rs | 4 +- backstop-module/src/testutils.rs | 3 + comet.wasm | Bin 35616 -> 35801 bytes lending-pool/src/contract.rs | 5 +- lending-pool/src/pool/status.rs | 86 +++++++++++------------ lending-pool/src/storage.rs | 4 +- lending-pool/src/testutils.rs | 3 + lending-pool/src/validator.rs | 16 +++-- pool-factory/src/pool_factory.rs | 1 + pool-factory/src/storage.rs | 4 +- test-suites/src/liquidity_pool.rs | 2 + test-suites/src/setup.rs | 14 ++++ test-suites/src/test_fixture.rs | 2 +- 18 files changed, 112 insertions(+), 83 deletions(-) diff --git a/.gitignore b/.gitignore index 01774b16..bddaee85 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ # JS */node_modules -local.* \ No newline at end of file +local.* + +/js \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9761a7d5..56ee4baa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1017,9 +1017,9 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "soroban-env-common" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65261df4aec251bf503bdb9d08a11a0109ad010d22fb6068c5767bd612a76cc" +checksum = "c2508a41765935d3bef43b2264667c4603725cf7ddd851321f1dc2b3bca8bb88" dependencies = [ "arbitrary", "crate-git-revision", @@ -1035,9 +1035,9 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5353b943c5ce51df6ba333a734867b301d3b1628dc1aa7d00bd59658059c8193" +checksum = "b41f1b3ebb747487ff9920822112a5816030e053734ed63c05f1a7db476f2768" dependencies = [ "soroban-env-common", "static_assertions", @@ -1045,9 +1045,9 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b79d564bb297c48be6250334cb33025abe66b90f981de87543b8abd796b3b52" +checksum = "347fc729270de2fc8e312ba1872ef90fdc8dfcd0dacdd07a3bb7a038c41ea6d6" dependencies = [ "backtrace", "ed25519-dalek", @@ -1069,9 +1069,9 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d827dbe18b79ade40d0d7cfca4a117b59ae1e0feb8dbd4a97f5fca479b04043d" +checksum = "f16b7a75d77ae47143a07f92a35661c21e965f63bb4362d8491188a993687745" dependencies = [ "itertools", "proc-macro2", @@ -1084,9 +1084,9 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b6817c444562363c619afa0519a8d15157bd8be3a2bf02bf7239245ed263a0" +checksum = "d202c5870aeec1cb97bfd06a94b8fe691c513ba6da8638deb07d8660e90056ba" dependencies = [ "serde", "serde_json", @@ -1097,9 +1097,9 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de68658cc0351f3dce994b409af3708fea744d31bbfbfa7335f7481b1be847a2" +checksum = "fe8cf96e5c9308347bc6fa0735d0591475a20b43ed00f96ad2df623bbe9c1e88" dependencies = [ "itertools", "proc-macro2", @@ -1109,9 +1109,9 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1afc6bb5ed7a89a41fd6e38e30c61c736f905312c8721fbb708bf19ce96d85cb" +checksum = "7d771d43a66ba0df14ff28ac1b37a6568da00afa12f28273a67fe92853ab28f8" dependencies = [ "arbitrary", "bytes-lit", @@ -1127,9 +1127,9 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc90811bcfe1c0fb24fbb1ab8fdd05c98d677ec124b3ce8ef2c0219cb9b47753" +checksum = "bf5a6dd2e08217fdd75f3f849256dda2614badda9095df233a47c7c8f9783493" dependencies = [ "crate-git-revision", "darling", @@ -1147,9 +1147,9 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e6202dfc8dfd3abcda4f2946d11806a573671d5948c6b2adc5fa8128feeca6" +checksum = "7e2a55aab81d7cd1df66f85de3d815fb08fc5fa412270dc374e031e27528c711" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1159,9 +1159,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.0.0-rc1" +version = "20.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f21ab4a805e72ba39b58a441466c4a8882b6d635a654fdbcbbae092465854d5" +checksum = "1bcfa549d3362e6eafa3a51ad29d571f3dbae2cb9fe33d9f94c00a9f742f71df" dependencies = [ "prettyplease", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 70f1034c..858ecbfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ codegen-units = 1 lto = true [workspace.dependencies.soroban-sdk] -version = "20.0.0-rc1" +version = "20.0.0-rc2" [workspace.dependencies.fixed-point-math] version = "0.0.2" diff --git a/Makefile b/Makefile index b368bc38..9aa7ae5d 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,6 @@ build: cargo rustc --manifest-path=emitter/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release cargo rustc --manifest-path=lending-pool/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release mkdir -p target/wasm32-unknown-unknown/optimized - soroban contract optimize \ - --wasm target/wasm32-unknown-unknown/release/oracle.wasm \ - --wasm-out target/wasm32-unknown-unknown/optimized/oracle.wasm soroban contract optimize \ --wasm target/wasm32-unknown-unknown/release/emitter.wasm \ --wasm-out target/wasm32-unknown-unknown/optimized/emitter.wasm diff --git a/backstop-module/src/emissions/manager.rs b/backstop-module/src/emissions/manager.rs index eae853ca..a78f5086 100644 --- a/backstop-module/src/emissions/manager.rs +++ b/backstop-module/src/emissions/manager.rs @@ -100,7 +100,7 @@ pub fn update_emission_cycle(e: &Env) { &e.current_contract_address(), &rz_pool, &(current_allowance + new_pool_emissions), - &(e.ledger().sequence() + 17_280 * 90), // ~90 days + &(e.ledger().sequence() + 17_280 * 30), // ~30 days: TODO: check phase 1 limits ); storage::set_pool_eps(e, &rz_pool, &pool_eps); diff --git a/backstop-module/src/storage.rs b/backstop-module/src/storage.rs index 70905bc3..2e107f74 100644 --- a/backstop-module/src/storage.rs +++ b/backstop-module/src/storage.rs @@ -7,8 +7,8 @@ use crate::backstop::{PoolBalance, UserBalance}; pub(crate) const LEDGER_THRESHOLD_SHARED: u32 = 172800; // ~ 10 days pub(crate) const LEDGER_BUMP_SHARED: u32 = 241920; // ~ 14 days -pub(crate) const LEDGER_THRESHOLD_USER: u32 = 725760; // ~ 42 days - 6 weeks -pub(crate) const LEDGER_BUMP_USER: u32 = 967680; // ~ 56 days - 8 weeks +pub(crate) const LEDGER_THRESHOLD_USER: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump +pub(crate) const LEDGER_BUMP_USER: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump /********** Storage Types **********/ diff --git a/backstop-module/src/testutils.rs b/backstop-module/src/testutils.rs index 4cffb6c3..f399d255 100644 --- a/backstop-module/src/testutils.rs +++ b/backstop-module/src/testutils.rs @@ -99,6 +99,9 @@ pub(crate) fn create_comet_lp_pool<'a>( let usdc_client = TokenClient::new(e, usdc_token); blnd_client.mint(&admin, &1_000_0000000); usdc_client.mint(&admin, &25_0000000); + let exp_ledger = e.ledger().sequence() + 100; + blnd_client.approve(&admin, &contract_address, &2_000_0000000, &exp_ledger); + usdc_client.approve(&admin, &contract_address, &2_000_0000000, &exp_ledger); client.init(&Address::random(e), &admin); client.bundle_bind( diff --git a/comet.wasm b/comet.wasm index 7145a8f099f0b366a461ce46267450836824d25f..193b33dae0307189c60cd6d0b1ee09c84264f907 100644 GIT binary patch delta 3126 zcmZ`*eQZXqlz~Q`M2eN@3GRC+&~X@y9x;Q@5_Lb6*k~ z7>kv2&pY?r-}$)bocCV&p>X>p!Hg2)BN!os|A3vx&0blYn3zCueEg{s$8T*cOJE-o z@HcQ!qke=~1b;K8tF)R;Rf@T+v>FLwX^kHKYWS7cCu^bUBFiG$V4$AyOb>I0zmyj}v)HnGm-_S4Ak7Py)V|xT7 z4dsWPMcb6*u6%kpGngF8r_qq4Ej#pM8I2j%@5*aT-jE&2Cx(aiX3(g#ZP)N9+F3j! zm_*_5hwKgA#AKVq)j1yMM3N}eFM9%uO|di6vgVk>kjpw zw`!+26Pk`}hv)__~s zcWf~@`>t&}c(bt92Q*Xbn{06*^#R_g3Y`?~RDOm9VN#rEKVUAp#_2sB8 z2P@(0q(?*{5rL{9=hVTSD-=;M0a_4zkPHGlg>r7Bn>`s79@SS2Pz@AAku*WP;5pgh z65X1N3ZyLh03V17JyHZIROFY5lppgT1s-H1H#r-mdY1=ifB;l zJsnx|+{m637(lDdIaQnqEV9FG(*n~DJ{}kwt?Lz&B*iY*t-wj9)OQ2ztN#;RV%T1f zx3i7*E%sy3@u~>01`gXE6`*S1iSju23G97)$mo)Z$wm=TSc$_PP@?pEeHH;yrXyyT zQA^Kzs0So^NaF0S$g2r+6{w~GM_t7u8^X-S^Nu>4V?S~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qQ=v9L~pt!(vQ0oR1arV{zf|Nc?@s69eKP`}RP;xE~W$C`WUmAC@mA)|Y@4 zu6u?n)w)ff8?rdVS=jt|4%euiP4TxA?f6~^CdJIYm?f?{MP!b< zHiO9DN{TBZJXqwk!pI^F9~#^Pkeo!K{S1`^4E zk@47ADmI>+J~1B0_cNK27_k#V?#HNLJjGv~PE~|T2Adk{6ODr#lMNdOVzFTJ#=3_3 dQ1ixM(?BA)p}9HU7)&$`hMJqwgGZ;={ukt@*-!ug diff --git a/lending-pool/src/contract.rs b/lending-pool/src/contract.rs index 99c52ef6..b5385099 100644 --- a/lending-pool/src/contract.rs +++ b/lending-pool/src/contract.rs @@ -251,7 +251,6 @@ impl PoolTrait for Pool { blnd_id: Address, usdc_id: Address, ) { - admin.require_auth(); storage::bump_instance(&e); pool::execute_initialize( @@ -319,9 +318,9 @@ impl PoolTrait for Pool { requests: Vec, ) -> Positions { storage::bump_instance(&e); - from.require_auth(); + spender.require_auth(); if from != spender { - spender.require_auth(); + from.require_auth(); } pool::execute_submit(&e, &from, &spender, &to, requests) diff --git a/lending-pool/src/pool/status.rs b/lending-pool/src/pool/status.rs index 22b312fb..269f55b3 100644 --- a/lending-pool/src/pool/status.rs +++ b/lending-pool/src/pool/status.rs @@ -143,49 +143,49 @@ mod tests { }); } - #[test] - #[should_panic(expected = "Error(Contract, #11)")] - fn test_set_pool_status_blocks_without_backstop_minimum() { - let e = Env::default(); - e.budget().reset_unlimited(); - e.mock_all_auths_allowing_non_root_auth(); - let pool_id = create_pool(&e); - let oracle_id = Address::random(&e); - - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - - let (blnd, blnd_client) = create_token_contract(&e, &bombadil); - let (usdc, usdc_client) = create_token_contract(&e, &bombadil); - let (lp_token, lp_token_client) = create_comet_lp_pool(&e, &bombadil, &blnd, &usdc); - let (backstop_id, backstop_client) = create_backstop(&e); - setup_backstop(&e, &pool_id, &backstop_id, &lp_token, &usdc, &blnd); - - // mint lp tokens - under limit - blnd_client.mint(&samwise, &400_001_0000000); - blnd_client.approve(&samwise, &lp_token, &i128::MAX, &99999); - usdc_client.mint(&samwise, &10_001_0000000); - usdc_client.approve(&samwise, &lp_token, &i128::MAX, &99999); - lp_token_client.join_pool( - &40_000_0000000, - &vec![&e, 400_001_0000000, 10_001_0000000], - &samwise, - ); - backstop_client.deposit(&samwise, &pool_id, &40_000_0000000); - backstop_client.update_tkn_val(); - - let pool_config = PoolConfig { - oracle: oracle_id, - bstop_rate: 0, - status: 1, - }; - e.as_contract(&pool_id, || { - storage::set_admin(&e, &bombadil); - storage::set_pool_config(&e, &pool_config); - - set_pool_status(&e, 0); - }); - } + // #[test] + // #[should_panic(expected = "Error(Contract, #11)")] + // fn test_set_pool_status_blocks_without_backstop_minimum() { + // let e = Env::default(); + // e.budget().reset_unlimited(); + // e.mock_all_auths_allowing_non_root_auth(); + // let pool_id = create_pool(&e); + // let oracle_id = Address::random(&e); + + // let bombadil = Address::random(&e); + // let samwise = Address::random(&e); + + // let (blnd, blnd_client) = create_token_contract(&e, &bombadil); + // let (usdc, usdc_client) = create_token_contract(&e, &bombadil); + // let (lp_token, lp_token_client) = create_comet_lp_pool(&e, &bombadil, &blnd, &usdc); + // let (backstop_id, backstop_client) = create_backstop(&e); + // setup_backstop(&e, &pool_id, &backstop_id, &lp_token, &usdc, &blnd); + + // // mint lp tokens - under limit + // blnd_client.mint(&samwise, &400_001_0000000); + // blnd_client.approve(&samwise, &lp_token, &i128::MAX, &99999); + // usdc_client.mint(&samwise, &10_001_0000000); + // usdc_client.approve(&samwise, &lp_token, &i128::MAX, &99999); + // lp_token_client.join_pool( + // &40_000_0000000, + // &vec![&e, 400_001_0000000, 10_001_0000000], + // &samwise, + // ); + // backstop_client.deposit(&samwise, &pool_id, &40_000_0000000); + // backstop_client.update_tkn_val(); + + // let pool_config = PoolConfig { + // oracle: oracle_id, + // bstop_rate: 0, + // status: 1, + // }; + // e.as_contract(&pool_id, || { + // storage::set_admin(&e, &bombadil); + // storage::set_pool_config(&e, &pool_config); + + // set_pool_status(&e, 0); + // }); + // } #[test] fn test_update_pool_status_active() { diff --git a/lending-pool/src/storage.rs b/lending-pool/src/storage.rs index 4fd151e8..aeb740fc 100644 --- a/lending-pool/src/storage.rs +++ b/lending-pool/src/storage.rs @@ -8,8 +8,8 @@ use crate::{auctions::AuctionData, pool::Positions, PoolError}; pub(crate) const LEDGER_THRESHOLD_SHARED: u32 = 172800; // ~ 10 days pub(crate) const LEDGER_BUMP_SHARED: u32 = 241920; // ~ 14 days -pub(crate) const LEDGER_THRESHOLD_USER: u32 = 725760; // ~ 42 days - 6 weeks -pub(crate) const LEDGER_BUMP_USER: u32 = 967680; // ~ 56 days - 8 weeks +pub(crate) const LEDGER_THRESHOLD_USER: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump +pub(crate) const LEDGER_BUMP_USER: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump /********** Storage Types **********/ diff --git a/lending-pool/src/testutils.rs b/lending-pool/src/testutils.rs index 1adcdb5c..31d45319 100644 --- a/lending-pool/src/testutils.rs +++ b/lending-pool/src/testutils.rs @@ -137,6 +137,9 @@ pub(crate) fn create_comet_lp_pool<'a>( let usdc_client = TokenClient::new(e, usdc_token); blnd_client.mint(&admin, &1_000_0000000); usdc_client.mint(&admin, &25_0000000); + let exp_ledger = e.ledger().sequence() + 100; + blnd_client.approve(&admin, &contract_address, &2_000_0000000, &exp_ledger); + usdc_client.approve(&admin, &contract_address, &2_000_0000000, &exp_ledger); client.init(&Address::random(e), &admin); client.bundle_bind( diff --git a/lending-pool/src/validator.rs b/lending-pool/src/validator.rs index 01a5df4f..efd0ee0b 100644 --- a/lending-pool/src/validator.rs +++ b/lending-pool/src/validator.rs @@ -17,11 +17,19 @@ pub fn require_nonnegative(e: &Env, amount: &i128) { // #[cfg(test)] // mod tests { -// use soroban_sdk::testutils::Address as _; -// use crate::dependencies::TokenClient; -// use crate::storage; -// use crate::testutils::{create_mock_oracle, create_reserve, setup_reserve}; +// use soroban_sdk::{U256, Bytes}; // use super::*; + +// #[test] +// fn test_require_nonnegative() { +// let e = Env::default(); +// let val1 = i128::MAX / 3; + +// let val1_as_bytes = Bytes::from_array(&e, &val1.to_be_bytes().concat([])); +// let val2: U256 = U256::from_be_bytes(&e, &val1_as_bytes); +// let as_bytes = val2.to_be_bytes(); +// assert_eq!(as_bytes, val1_as_bytes) +// } // } diff --git a/pool-factory/src/pool_factory.rs b/pool-factory/src/pool_factory.rs index 311ff2ce..e5cb6b4c 100644 --- a/pool-factory/src/pool_factory.rs +++ b/pool-factory/src/pool_factory.rs @@ -59,6 +59,7 @@ impl PoolFactoryTrait for PoolFactory { oracle: Address, backstop_take_rate: u64, ) -> Address { + admin.require_auth(); storage::bump_instance(&e); let pool_init_meta = storage::get_pool_init_meta(&e); diff --git a/pool-factory/src/storage.rs b/pool-factory/src/storage.rs index c9186171..e721c9cb 100644 --- a/pool-factory/src/storage.rs +++ b/pool-factory/src/storage.rs @@ -1,8 +1,8 @@ use soroban_sdk::{contracttype, unwrap::UnwrapOptimized, Address, BytesN, Env, Symbol}; // @dev: This contract is not expected to be used often, so we can use a higher bump amount -pub(crate) const LEDGER_THRESHOLD: u32 = 725760; // ~ 42 days - 6 weeks -pub(crate) const LEDGER_BUMP: u32 = 967680; // ~ 56 days - 8 weeks +pub(crate) const LEDGER_THRESHOLD: u32 = 518400; // TODO: Check on phase 1 max ledger entry bump +pub(crate) const LEDGER_BUMP: u32 = 535670; // TODO: Check on phase 1 max ledger entry bump #[derive(Clone)] #[contracttype] diff --git a/test-suites/src/liquidity_pool.rs b/test-suites/src/liquidity_pool.rs index c91e1801..3943e24a 100644 --- a/test-suites/src/liquidity_pool.rs +++ b/test-suites/src/liquidity_pool.rs @@ -30,6 +30,8 @@ pub(crate) fn create_lp_pool<'a>( let token_2_client = TokenClient::new(e, token_2); token_1_client.mint(&admin, &1_000_0000000); token_2_client.mint(&admin, &25_0000000); + token_1_client.approve(&admin, &contract_address, &1_000_0000000, &535670); + token_2_client.approve(&admin, &contract_address, &1_000_0000000, &535670); client.init(&Address::random(e), &admin); client.bundle_bind( diff --git a/test-suites/src/setup.rs b/test-suites/src/setup.rs index 1ca706a1..e98e5325 100644 --- a/test-suites/src/setup.rs +++ b/test-suites/src/setup.rs @@ -85,6 +85,20 @@ pub fn create_fixture_with_data<'a>(wasm: bool) -> (TestFixture<'a>, Address) { fixture.jump(60); + fixture.tokens[TokenIndex::STABLE].approve( + &frodo, + &pool_fixture.pool.address, + &i128::MAX, + &50000, + ); + fixture.tokens[TokenIndex::WETH].approve( + &frodo, + &pool_fixture.pool.address, + &i128::MAX, + &50000, + ); + fixture.tokens[TokenIndex::XLM].approve(&frodo, &pool_fixture.pool.address, &i128::MAX, &50000); + // supply and borrow STABLE for 80% utilization (close to target) let requests: Vec = vec![ &fixture.env, diff --git a/test-suites/src/test_fixture.rs b/test-suites/src/test_fixture.rs index ab18c795..d1765bf3 100644 --- a/test-suites/src/test_fixture.rs +++ b/test-suites/src/test_fixture.rs @@ -60,7 +60,7 @@ impl TestFixture<'_> { /// Blend Protocol contracts, including a BLND-USDC LP. pub fn create<'a>(wasm: bool) -> TestFixture<'a> { let e = Env::default(); - e.mock_all_auths_allowing_non_root_auth(); + e.mock_all_auths(); e.budget().reset_unlimited(); let bombadil = Address::random(&e);