From 2ab0b61a859df58e47d61a9b6fc093157efb8706 Mon Sep 17 00:00:00 2001 From: mootz12 Date: Thu, 7 Dec 2023 10:24:53 -0500 Subject: [PATCH] chore: upgrade to sdk version 20.0.0 --- .gitignore | 2 + Cargo.lock | 250 +++++++++------ Cargo.toml | 10 +- backstop/Cargo.toml | 2 +- backstop/src/backstop/deposit.rs | 28 +- backstop/src/backstop/fund_management.rs | 82 ++--- backstop/src/backstop/pool.rs | 12 +- backstop/src/backstop/user.rs | 60 ++-- backstop/src/backstop/withdrawal.rs | 96 +++--- backstop/src/contract.rs | 38 +-- backstop/src/emissions/claim.rs | 58 ++-- backstop/src/emissions/distributor.rs | 62 ++-- backstop/src/emissions/manager.rs | 302 +++++++++--------- backstop/src/storage.rs | 22 +- backstop/src/testutils.rs | 18 +- comet.wasm | Bin 34381 -> 34229 bytes emitter/src/backstop_manager.rs | 140 ++++---- emitter/src/contract.rs | 12 +- emitter/src/emitter.rs | 58 ++-- emitter/src/storage.rs | 10 +- mocks/mock-pool-factory/src/pool_factory.rs | 2 +- mocks/mock-pool-factory/src/storage.rs | 12 +- pool-factory/src/pool_factory.rs | 6 +- pool-factory/src/storage.rs | 10 +- pool-factory/src/test.rs | 15 +- pool/Cargo.toml | 2 +- pool/src/auctions/auction.rs | 206 ++++++------ .../src/auctions/backstop_interest_auction.rs | 62 ++-- pool/src/auctions/bad_debt_auction.rs | 78 ++--- pool/src/auctions/user_liquidation_auction.rs | 86 ++--- pool/src/contract.rs | 22 +- pool/src/emissions/distributor.rs | 140 ++++---- pool/src/emissions/manager.rs | 50 +-- pool/src/pool/actions.rs | 180 +++++------ pool/src/pool/bad_debt.rs | 68 ++-- pool/src/pool/config.rs | 46 +-- pool/src/pool/health_factor.rs | 10 +- pool/src/pool/interest.rs | 38 +-- pool/src/pool/pool.rs | 52 +-- pool/src/pool/reserve.rs | 42 +-- pool/src/pool/status.rs | 42 +-- pool/src/pool/submit.rs | 28 +- pool/src/pool/user.rs | 66 ++-- pool/src/storage.rs | 26 +- pool/src/testutils.rs | 10 +- test-suites/Cargo.toml | 2 +- .../fuzz/fuzz_targets/fuzz_pool_general.rs | 6 +- test-suites/fuzz/lib.rs | 2 +- test-suites/src/assertions.rs | 2 +- test-suites/src/backstop.rs | 2 +- test-suites/src/emitter.rs | 2 +- test-suites/src/liquidity_pool.rs | 4 +- test-suites/src/oracle.rs | 2 +- test-suites/src/pool_factory.rs | 2 +- test-suites/src/setup.rs | 4 +- test-suites/src/test_fixture.rs | 20 +- test-suites/src/token.rs | 2 +- test-suites/tests/test_backstop.rs | 14 +- test-suites/tests/test_emitter.rs | 8 +- test-suites/tests/test_liquidation.rs | 14 +- test-suites/tests/test_pool.rs | 16 +- test-suites/tests/test_wasm_happy_path.rs | 6 +- 62 files changed, 1348 insertions(+), 1321 deletions(-) diff --git a/.gitignore b/.gitignore index bddaee85..17eaa901 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .DS_Store /emitter/.DS_Store +test_snapshots/ + # JS */node_modules local.* diff --git a/Cargo.lock b/Cargo.lock index 3815a667..11068a87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" dependencies = [ "derive_arbitrary", ] @@ -53,17 +53,17 @@ version = "0.0.1" dependencies = [ "cast", "emitter", - "fixed-point-math", "mock-pool-factory", "sep-41-token", + "soroban-fixed-point-math", "soroban-sdk", ] [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ "cfg-if", "cpufeatures", @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", @@ -406,11 +406,23 @@ dependencies = [ "soroban-sdk", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "escape-bytes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfcf67fea2815c2fc3b90873fae90957be12ff417335dfadc7f52927feb03b2" + [[package]] name = "ethnum" -version = "1.3.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0198b9d0078e0f30dedc7acbb21c974e838fc8fae3ee170128658a98cb2c1c04" +checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "ff" @@ -424,15 +436,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" - -[[package]] -name = "fixed-point-math" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d8c494ccd0b270d97dc51d5f0de703b9d18a489c26f0328e409f6feba55a640" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "fnv" @@ -464,9 +470,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -477,9 +483,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "group" @@ -498,6 +504,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "hex" version = "0.4.3" @@ -507,6 +519,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hmac" version = "0.12.1" @@ -552,7 +570,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", "serde", ] @@ -564,9 +593,9 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "itertools" -version = "0.10.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ "either", ] @@ -611,9 +640,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -664,9 +693,9 @@ dependencies = [ [[package]] name = "num-derive" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6a0fd4f737c707bd9086cc16c925f294943eb62eb71499e9fd4cf71f8b9f4e" +checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", @@ -685,18 +714,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -736,10 +765,10 @@ dependencies = [ "backstop", "cast", "emitter", - "fixed-point-math", "mock-pool-factory", "sep-40-oracle", "sep-41-token", + "soroban-fixed-point-math", "soroban-sdk", ] @@ -769,18 +798,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -844,7 +873,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -909,36 +938,36 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "sep-40-oracle" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa589e8db60e397c7a7af90908eab64ca46cc5628957a554a24efb36235b34d2" +checksum = "ea393e9867e2a2a73a32be6e7a7b81c78ee3779dc1cdf7b2343b23a16739a181" dependencies = [ "soroban-sdk", ] [[package]] name = "sep-41-token" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0edb6a114daf783364bf705d27f97a4f49ae858518eb46d46e4161cd75b9678" +checksum = "8832c57dd6d2ad1d31f9ac8434bd84677ab4f7ca0e2369fd57df49f42f2567ff" dependencies = [ "soroban-sdk", ] [[package]] name = "serde" -version = "1.0.171" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -947,9 +976,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.103" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -958,14 +987,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.1.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e47d95bc83ed33b2ecf84f4187ad1ab9685d18ff28db000c99deac8ce180e3" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ "base64 0.21.2", "chrono", "hex", - "indexmap", + "indexmap 1.9.3", + "indexmap 2.1.0", "serde", "serde_json", "serde_with_macros", @@ -974,9 +1004,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.1.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3cee93715c2e266b9338b7544da68a9f24e227722ba482bd1c024367c77c65" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ "darling", "proc-macro2", @@ -986,9 +1016,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -1021,11 +1051,23 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +[[package]] +name = "soroban-builtin-sdk-macros" +version = "20.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42487d6b0268748f753feeb579c6f7908dbb002faf20b703e6a7185b12f0527" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "soroban-env-common" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2508a41765935d3bef43b2264667c4603725cf7ddd851321f1dc2b3bca8bb88" +checksum = "5bb493483fa3e3ebfb4c081472495d14b0abcfbe04ba142a56ff63056cc62700" dependencies = [ "arbitrary", "crate-git-revision", @@ -1041,9 +1083,9 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41f1b3ebb747487ff9920822112a5816030e053734ed63c05f1a7db476f2768" +checksum = "3f31a738ef5faf4084c4b1824a8e3f93dfff0261a3909e86060f818e728479a3" dependencies = [ "soroban-env-common", "static_assertions", @@ -1051,13 +1093,16 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347fc729270de2fc8e312ba1872ef90fdc8dfcd0dacdd07a3bb7a038c41ea6d6" +checksum = "bdd1172a76c0bc2ce67ec7f28ca37dddbe9fefabe583f80434f5f60aaee3547e" dependencies = [ "backtrace", + "curve25519-dalek", "ed25519-dalek", - "getrandom 0.2.10", + "getrandom 0.2.11", + "hex-literal", + "hmac", "k256", "num-derive", "num-integer", @@ -1066,8 +1111,8 @@ dependencies = [ "rand_chacha 0.3.1", "sha2", "sha3", + "soroban-builtin-sdk-macros", "soroban-env-common", - "soroban-native-sdk-macros", "soroban-wasmi", "static_assertions", "stellar-strkey", @@ -1075,9 +1120,9 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16b7a75d77ae47143a07f92a35661c21e965f63bb4362d8491188a993687745" +checksum = "5c0536648cea69ab3bae1801d35f92c0a31e7449cd2c7d14a18fb5e413f43279" dependencies = [ "itertools", "proc-macro2", @@ -1088,42 +1133,42 @@ dependencies = [ "syn", ] +[[package]] +name = "soroban-fixed-point-math" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230e5902daf9de6e7591aa7864dcf763ff96914a4460a0294a5dfd62b3181e0f" +dependencies = [ + "soroban-sdk", +] + [[package]] name = "soroban-ledger-snapshot" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d202c5870aeec1cb97bfd06a94b8fe691c513ba6da8638deb07d8660e90056ba" +checksum = "37960eec21d7dc5dbd976fa16e38c056429663a89243798486b07afbb263c9b5" dependencies = [ "serde", "serde_json", + "serde_with", "soroban-env-common", "soroban-env-host", "thiserror", ] -[[package]] -name = "soroban-native-sdk-macros" -version = "20.0.0-rc2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe8cf96e5c9308347bc6fa0735d0591475a20b43ed00f96ad2df623bbe9c1e88" -dependencies = [ - "itertools", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "soroban-sdk" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d771d43a66ba0df14ff28ac1b37a6568da00afa12f28273a67fe92853ab28f8" +checksum = "f08e1fdb18dbee88160ea6640962faf021a49f22eb1bd212c4d8b0cef32c582c" dependencies = [ "arbitrary", "bytes-lit", "ctor", "ed25519-dalek", "rand 0.8.5", + "serde", + "serde_json", "soroban-env-guest", "soroban-env-host", "soroban-ledger-snapshot", @@ -1133,9 +1178,9 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5a6dd2e08217fdd75f3f849256dda2614badda9095df233a47c7c8f9783493" +checksum = "6c5cae44f304f2fd32f9cfa9a31a9b58eb1c10aa07a7d5b591921cf7fa649e44" dependencies = [ "crate-git-revision", "darling", @@ -1153,9 +1198,9 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e2a55aab81d7cd1df66f85de3d815fb08fc5fa412270dc374e031e27528c711" +checksum = "7539cfa0abe36f3d33c49fe1253f6b652c91c9a9841fe83dedc1799b7f4bb55f" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1165,9 +1210,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.0.0-rc2" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bcfa549d3362e6eafa3a51ad29d571f3dbae2cb9fe33d9f94c00a9f742f71df" +checksum = "eb6189ef3ede0061db14b0cf9fa2692a2cb6c6e8d941689f0c9ca82b68c47ab2" dependencies = [ "prettyplease", "proc-macro2", @@ -1181,9 +1226,9 @@ dependencies = [ [[package]] name = "soroban-wasmi" -version = "0.31.0-soroban1" +version = "0.31.1-soroban.20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6e3e79c1f227ec98ea1e8fbf43d0267b9ca748616c9c8c0162fa2a8ca4d5d2" +checksum = "c1aaa682a67cbd2173f1d60cb1e7b951d490d7c4e0b7b6f5387cbb952e963c46" dependencies = [ "smallvec", "spin", @@ -1216,26 +1261,29 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.7" +version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0689070126ca7f2effc2c5726584446db52190f0cef043c02eb4040a711c11" +checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" dependencies = [ "base32", + "crate-git-revision", "thiserror", ] [[package]] name = "stellar-xdr" -version = "20.0.0-rc1" +version = "20.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09a3734914a7427dbcd4f06b6dcd2b1cf38e934202f6abe4d73658f718b6113" +checksum = "9595b775539e475da4179fa46212b11e4575f526d57b13308989a8c1dd59238c" dependencies = [ "arbitrary", "base64 0.13.1", "crate-git-revision", + "escape-bytes", "hex", "serde", "serde_with", + "stellar-strkey", ] [[package]] @@ -1252,9 +1300,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.26" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -1268,13 +1316,13 @@ dependencies = [ "backstop", "cast", "emitter", - "fixed-point-math", "mock-pool-factory", "pool", "pool-factory", "rand 0.7.3", "sep-40-oracle", "sep-41-token", + "soroban-fixed-point-math", "soroban-sdk", ] @@ -1433,7 +1481,7 @@ version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e" dependencies = [ - "indexmap", + "indexmap 1.9.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f018e664..7bdd0f10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,20 +26,20 @@ codegen-units = 1 lto = true [workspace.dependencies.soroban-sdk] -version = "20.0.0-rc2" +version = "20.0.0" -[workspace.dependencies.fixed-point-math] -version = "0.0.2" +[workspace.dependencies.soroban-fixed-point-math] +version = "1.0.0" [workspace.dependencies.cast] version = "0.3.0" default-features = false [workspace.dependencies.sep-40-oracle] -version = "0.1.1" +version = "0.2.0" [workspace.dependencies.sep-41-token] -version = "0.2.1" +version = "0.3.0" [workspace.dependencies.blend-interfaces] path = "./blend-interfaces" \ No newline at end of file diff --git a/backstop/Cargo.toml b/backstop/Cargo.toml index 76726cd0..64ee986f 100644 --- a/backstop/Cargo.toml +++ b/backstop/Cargo.toml @@ -17,7 +17,7 @@ testutils = [ [dependencies] soroban-sdk = { workspace = true } -fixed-point-math = { workspace = true } +soroban-fixed-point-math = { workspace = true } cast = { workspace = true } sep-41-token = { workspace = true } diff --git a/backstop/src/backstop/deposit.rs b/backstop/src/backstop/deposit.rs index 664a3201..482cea65 100644 --- a/backstop/src/backstop/deposit.rs +++ b/backstop/src/backstop/deposit.rs @@ -44,11 +44,11 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); - let pool_0_id = Address::random(&e); - let pool_1_id = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); + let pool_0_id = Address::generate(&e); + let pool_1_id = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -101,9 +101,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -126,9 +126,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -148,9 +148,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); diff --git a/backstop/src/backstop/fund_management.rs b/backstop/src/backstop/fund_management.rs index 777aace9..148b0598 100644 --- a/backstop/src/backstop/fund_management.rs +++ b/backstop/src/backstop/fund_management.rs @@ -1,8 +1,8 @@ use crate::{ constants::SCALAR_7, contract::require_nonnegative, dependencies::CometClient, storage, }; -use fixed_point_math::FixedPoint; use sep_41_token::TokenClient; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{unwrap::UnwrapOptimized, Address, Env}; use super::require_is_from_pool_factory; @@ -116,10 +116,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_id, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -150,10 +150,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_id, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -180,10 +180,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_id, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -203,10 +203,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_address = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&frodo, &100_0000000); @@ -238,11 +238,11 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let pool_1_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let pool_1_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_id, &bombadil); backstop_token_client.mint(&frodo, &100_0000000); @@ -270,10 +270,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_id, &bombadil); backstop_token_client.mint(&frodo, &100_0000000); @@ -298,10 +298,10 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, usdc_token_client) = create_usdc_token(&e, &backstop_id, &bombadil); usdc_token_client.mint(&samwise, &100_0000000); @@ -333,9 +333,9 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, usdc_token_client) = create_usdc_token(&e, &backstop_id, &bombadil); usdc_token_client.mint(&samwise, &100_0000000); @@ -356,9 +356,9 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, usdc_token_client) = create_usdc_token(&e, &backstop_id, &bombadil); usdc_token_client.mint(&samwise, &100_0000000); @@ -377,9 +377,9 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let pool_0_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_0_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (usdc_token, usdc_token_client) = create_usdc_token(&e, &backstop_id, &bombadil); usdc_token_client.mint(&samwise, &100_0000000); @@ -424,8 +424,8 @@ mod tests { e.budget().reset_unlimited(); let backstop_id = create_backstop(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (usdc_token, usdc_token_client) = create_usdc_token(&e, &backstop_id, &bombadil); usdc_token_client.mint(&samwise, &100_0000000); diff --git a/backstop/src/backstop/pool.rs b/backstop/src/backstop/pool.rs index 0b1d8c01..82b7d0aa 100644 --- a/backstop/src/backstop/pool.rs +++ b/backstop/src/backstop/pool.rs @@ -1,4 +1,4 @@ -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{contracttype, panic_with_error, unwrap::UnwrapOptimized, Address, Env}; use crate::{constants::SCALAR_7, dependencies::PoolFactoryClient, errors::BackstopError, storage}; @@ -191,7 +191,7 @@ mod tests { let e = Env::default(); let backstop_address = create_backstop(&e); - let pool = Address::random(&e); + let pool = Address::generate(&e); e.as_contract(&backstop_address, || { storage::set_pool_balance( @@ -221,7 +221,7 @@ mod tests { let e = Env::default(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); + let pool_address = Address::generate(&e); let (_, mock_pool_factory) = create_mock_pool_factory(&e, &backstop_address); mock_pool_factory.set_pool(&pool_address); @@ -237,7 +237,7 @@ mod tests { let e = Env::default(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); + let pool_address = Address::generate(&e); // don't initialize factory to force failure if pool_address is checked @@ -253,8 +253,8 @@ mod tests { let e = Env::default(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let not_pool_address = Address::random(&e); + let pool_address = Address::generate(&e); + let not_pool_address = Address::generate(&e); let (_, mock_pool_factory) = create_mock_pool_factory(&e, &backstop_address); mock_pool_factory.set_pool(&pool_address); diff --git a/backstop/src/backstop/user.rs b/backstop/src/backstop/user.rs index 28b6488b..1773929b 100644 --- a/backstop/src/backstop/user.rs +++ b/backstop/src/backstop/user.rs @@ -155,9 +155,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_queue = 500; @@ -196,9 +196,9 @@ mod tests { timestamp: 11000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_queue = 500; @@ -233,9 +233,9 @@ mod tests { timestamp: 11000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_queue = 801; @@ -258,9 +258,9 @@ mod tests { timestamp: 11000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_wd = 1; @@ -289,9 +289,9 @@ mod tests { timestamp: 12592000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_wd = 200; @@ -323,9 +323,9 @@ mod tests { timestamp: 12592000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_wd = 150; @@ -372,9 +372,9 @@ mod tests { timestamp: 22592000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_wd = 300; @@ -426,9 +426,9 @@ mod tests { timestamp: 11192000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_wd = 300; @@ -466,9 +466,9 @@ mod tests { timestamp: 11192000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_dequeue = 300; // verify exp is respected when specified @@ -505,9 +505,9 @@ mod tests { timestamp: 11192000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let to_dequeue = 376; diff --git a/backstop/src/backstop/withdrawal.rs b/backstop/src/backstop/withdrawal.rs index 502e7ebf..fd68dcb9 100644 --- a/backstop/src/backstop/withdrawal.rs +++ b/backstop/src/backstop/withdrawal.rs @@ -89,9 +89,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -110,9 +110,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { @@ -149,9 +149,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -170,9 +170,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { @@ -186,9 +186,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -207,9 +207,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); execute_queue_withdrawal(&e, &samwise, &pool_address, 40_0000000); @@ -221,9 +221,9 @@ mod tests { timestamp: 20000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { @@ -253,9 +253,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &100_0000000); @@ -274,9 +274,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); execute_queue_withdrawal(&e, &samwise, &pool_address, 40_0000000); @@ -288,9 +288,9 @@ mod tests { timestamp: 20000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { @@ -304,9 +304,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &150_0000000); @@ -320,9 +320,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); // setup pool with queue for withdrawal and allow the backstop to incur a profit @@ -338,9 +338,9 @@ mod tests { timestamp: 10000 + 30 * 24 * 60 * 60 + 1, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { @@ -370,9 +370,9 @@ mod tests { e.mock_all_auths_allowing_non_root_auth(); let backstop_address = create_backstop(&e); - let pool_address = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let pool_address = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (_, backstop_token_client) = create_backstop_token(&e, &backstop_address, &bombadil); backstop_token_client.mint(&samwise, &150_0000000); @@ -386,9 +386,9 @@ mod tests { timestamp: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); // setup pool with queue for withdrawal and allow the backstop to incur a profit @@ -404,9 +404,9 @@ mod tests { timestamp: 10000 + 30 * 24 * 60 * 60 + 1, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(&backstop_address, || { diff --git a/backstop/src/contract.rs b/backstop/src/contract.rs index cdfb9f6a..39434b90 100644 --- a/backstop/src/contract.rs +++ b/backstop/src/contract.rs @@ -206,7 +206,7 @@ impl Backstop for BackstopContract { pool_factory: Address, drop_list: Map, ) { - storage::bump_instance(&e); + storage::extend_instance(&e); if storage::has_backstop_token(&e) { panic_with_error!(e, BackstopError::AlreadyInitialized); } @@ -229,7 +229,7 @@ impl Backstop for BackstopContract { /********** Core **********/ fn deposit(e: Env, from: Address, pool_address: Address, amount: i128) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); let to_mint = backstop::execute_deposit(&e, &from, &pool_address, amount); @@ -242,7 +242,7 @@ impl Backstop for BackstopContract { } fn queue_withdrawal(e: Env, from: Address, pool_address: Address, amount: i128) -> Q4W { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); let to_queue = backstop::execute_queue_withdrawal(&e, &from, &pool_address, amount); @@ -255,7 +255,7 @@ impl Backstop for BackstopContract { } fn dequeue_withdrawal(e: Env, from: Address, pool_address: Address, amount: i128) { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); backstop::execute_dequeue_withdrawal(&e, &from, &pool_address, amount); @@ -267,7 +267,7 @@ impl Backstop for BackstopContract { } fn withdraw(e: Env, from: Address, pool_address: Address, amount: i128) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); let to_withdraw = backstop::execute_withdraw(&e, &from, &pool_address, amount); @@ -294,7 +294,7 @@ impl Backstop for BackstopContract { /********** Emissions **********/ fn gulp_emissions(e: Env) { - storage::bump_instance(&e); + storage::extend_instance(&e); let new_tokens_emitted = emissions::gulp_emissions(&e); e.events() @@ -302,7 +302,7 @@ impl Backstop for BackstopContract { } fn add_reward(e: Env, to_add: Address, to_remove: Address) { - storage::bump_instance(&e); + storage::extend_instance(&e); emissions::add_to_reward_zone(&e, to_add.clone(), to_remove.clone()); e.events() @@ -310,13 +310,13 @@ impl Backstop for BackstopContract { } fn gulp_pool_emissions(e: Env, pool_address: Address) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); pool_address.require_auth(); emissions::gulp_pool_emissions(&e, &pool_address) } fn claim(e: Env, from: Address, pool_addresses: Vec
, to: Address) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); let amount = emissions::execute_claim(&e, &from, &pool_addresses, &to); @@ -332,7 +332,7 @@ impl Backstop for BackstopContract { /********** Fund Management *********/ fn draw(e: Env, pool_address: Address, amount: i128, to: Address) { - storage::bump_instance(&e); + storage::extend_instance(&e); pool_address.require_auth(); backstop::execute_draw(&e, &pool_address, amount, &to); @@ -342,7 +342,7 @@ impl Backstop for BackstopContract { } fn donate(e: Env, from: Address, pool_address: Address, amount: i128) { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); backstop::execute_donate(&e, &from, &pool_address, amount); @@ -351,7 +351,7 @@ impl Backstop for BackstopContract { } fn donate_usdc(e: Env, from: Address, pool_address: Address, amount: i128) { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); backstop::execute_donate_usdc(&e, &from, &pool_address, amount); @@ -360,21 +360,15 @@ impl Backstop for BackstopContract { } fn gulp_usdc(e: Env, pool_address: Address) { - storage::bump_instance(&e); + storage::extend_instance(&e); backstop::execute_gulp_usdc(&e, &pool_address); - e.events().publish( - ( - Symbol::new(&e, "gulp_usdc"), - pool_address, - e.call_stack().last_unchecked().0, - ), - (), - ); + e.events() + .publish((Symbol::new(&e, "gulp_usdc"), pool_address), ()); } fn update_tkn_val(e: Env) -> (i128, i128) { - storage::bump_instance(&e); + storage::extend_instance(&e); let backstop_token = storage::get_backstop_token(&e); let blnd_token = storage::get_blnd_token(&e); diff --git a/backstop/src/emissions/claim.rs b/backstop/src/emissions/claim.rs index f7e5b5e1..e9019a7b 100644 --- a/backstop/src/emissions/claim.rs +++ b/backstop/src/emissions/claim.rs @@ -1,5 +1,5 @@ use crate::{dependencies::CometClient, errors::BackstopError, storage}; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ auth::{ContractContext, InvokerContractAuthEntry, SubContractInvocation}, panic_with_error, vec, Address, Env, IntoVal, Map, Symbol, Val, Vec, @@ -7,8 +7,6 @@ use soroban_sdk::{ use super::update_emissions; -// TODO: Deposit emissions back into the backstop automatically after 80/20 BLND deposit function added - /// Perform a claim for backstop deposit emissions by a user from the backstop module pub fn execute_claim(e: &Env, from: &Address, pool_addresses: &Vec
, to: &Address) -> i128 { if pool_addresses.is_empty() { @@ -106,18 +104,18 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.budget().reset_unlimited(); let backstop_address = create_backstop(&e); - let pool_1_id = Address::random(&e); - let pool_2_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_1_id = Address::generate(&e); + let pool_2_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (blnd_address, blnd_token_client) = create_blnd_token(&e, &backstop_address, &bombadil); let (usdc_address, _) = create_usdc_token(&e, &backstop_address, &bombadil); @@ -267,17 +265,17 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_address = create_backstop(&e); - let pool_1_id = Address::random(&e); - let pool_2_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_1_id = Address::generate(&e); + let pool_2_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (blnd_address, blnd_token_client) = create_blnd_token(&e, &backstop_address, &bombadil); let (usdc_address, _) = create_usdc_token(&e, &backstop_address, &bombadil); @@ -418,9 +416,9 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_lp_balance = backstop_lp_balance + 6_5244800; let pre_frodo_balance_1 = storage::get_user_balance(&e, &pool_1_id, &frodo).shares; @@ -490,17 +488,17 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_address = create_backstop(&e); - let pool_1_id = Address::random(&e); - let pool_2_id = Address::random(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let pool_1_id = Address::generate(&e); + let pool_2_id = Address::generate(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let (_, blnd_token_client) = create_blnd_token(&e, &backstop_address, &bombadil); blnd_token_client.mint(&backstop_address, &100_0000000); diff --git a/backstop/src/emissions/distributor.rs b/backstop/src/emissions/distributor.rs index d99a722d..1af1fb6b 100644 --- a/backstop/src/emissions/distributor.rs +++ b/backstop/src/emissions/distributor.rs @@ -1,7 +1,7 @@ //! Methods for distributing backstop emissions to depositors use cast::i128; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{unwrap::UnwrapOptimized, Address, Env}; use crate::{ @@ -155,14 +155,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); let backstop_emissions_config = BackstopEmissionConfig { expiration: BACKSTOP_EPOCH + 7 * 24 * 60 * 60, @@ -216,14 +216,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); e.as_contract(&backstop_id, || { storage::set_last_distribution_time(&e, &BACKSTOP_EPOCH); @@ -259,14 +259,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); let backstop_emissions_config = BackstopEmissionConfig { expiration: BACKSTOP_EPOCH + 7 * 24 * 60 * 60, @@ -320,14 +320,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); let backstop_emissions_config = BackstopEmissionConfig { expiration: BACKSTOP_EPOCH + 7 * 24 * 60 * 60, @@ -376,14 +376,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); let backstop_emissions_config = BackstopEmissionConfig { expiration: BACKSTOP_EPOCH + 7 * 24 * 60 * 60, @@ -431,14 +431,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let pool_1 = Address::random(&e); - let samwise = Address::random(&e); + let pool_1 = Address::generate(&e); + let samwise = Address::generate(&e); let backstop_emissions_config = BackstopEmissionConfig { expiration: BACKSTOP_EPOCH + 7 * 24 * 60 * 60, diff --git a/backstop/src/emissions/manager.rs b/backstop/src/emissions/manager.rs index 755d80e4..58a53a3e 100644 --- a/backstop/src/emissions/manager.rs +++ b/backstop/src/emissions/manager.rs @@ -1,6 +1,6 @@ use cast::{i128, u64}; -use fixed_point_math::FixedPoint; use sep_41_token::TokenClient; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{panic_with_error, unwrap::UnwrapOptimized, vec, Address, Env, Vec}; use crate::{ @@ -188,7 +188,7 @@ mod tests { use super::*; use soroban_sdk::{ testutils::{Address as _, Ledger, LedgerInfo}, - vec, BytesN, Vec, + vec, Vec, }; use crate::{ @@ -210,9 +210,9 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop = create_backstop(&e); @@ -220,13 +220,13 @@ mod tests { create_emitter( &e, &backstop, - &Address::random(&e), - &Address::random(&e), + &Address::generate(&e), + &Address::generate(&e), emitter_distro_time, ); - let pool_1 = Address::random(&e); - let pool_2 = Address::random(&e); - let pool_3 = Address::random(&e); + let pool_1 = Address::generate(&e); + let pool_2 = Address::generate(&e); + let pool_3 = Address::generate(&e); let reward_zone: Vec
= vec![&e, pool_1.clone(), pool_2.clone(), pool_3.clone()]; // setup pool 1 to have ongoing emissions @@ -353,9 +353,9 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop = create_backstop(&e); @@ -363,13 +363,13 @@ mod tests { create_emitter( &e, &backstop, - &Address::random(&e), - &Address::random(&e), + &Address::generate(&e), + &Address::generate(&e), emitter_distro_time, ); - let pool_1 = Address::random(&e); - let pool_2 = Address::random(&e); - let pool_3 = Address::random(&e); + let pool_1 = Address::generate(&e); + let pool_2 = Address::generate(&e); + let pool_3 = Address::generate(&e); let reward_zone: Vec
= vec![&e, pool_1.clone(), pool_2.clone(), pool_3.clone()]; // setup pool 1 to have ongoing emissions @@ -445,14 +445,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let backstop = create_backstop(&e); - let pool_1 = Address::random(&e); + let pool_1 = Address::generate(&e); let (_, blnd_token_client) = create_blnd_token(&e, &backstop, &bombadil); e.as_contract(&backstop, || { @@ -479,14 +479,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let backstop = create_backstop(&e); - let pool_1 = Address::random(&e); + let pool_1 = Address::generate(&e); let (_, blnd_token_client) = create_blnd_token(&e, &backstop, &bombadil); e.as_contract(&backstop, || { @@ -516,14 +516,14 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let backstop = create_backstop(&e); - let pool_1 = Address::random(&e); + let pool_1 = Address::generate(&e); create_blnd_token(&e, &backstop, &bombadil); e.as_contract(&backstop, || { @@ -542,13 +542,13 @@ mod tests { sequence_number: 0, base_reserve: 10, network_id: Default::default(), - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); + let to_add = Address::generate(&e); e.as_contract(&backstop_id, || { storage::set_pool_balance( @@ -562,11 +562,7 @@ mod tests { ); storage::set_lp_token_val(&e, &(5_0000000, 0_1000000)); - add_to_reward_zone( - &e, - to_add.clone(), - Address::from_contract_id(&BytesN::from_array(&e, &[0u8; 32])), - ); + add_to_reward_zone(&e, to_add.clone(), Address::generate(&e)); let actual_rz = storage::get_reward_zone(&e); let expected_rz: Vec
= vec![&e, to_add]; assert_eq!(actual_rz, expected_rz); @@ -583,13 +579,13 @@ mod tests { sequence_number: 0, base_reserve: 10, network_id: Default::default(), - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); + let to_add = Address::generate(&e); e.as_contract(&backstop_id, || { storage::set_pool_balance( @@ -603,11 +599,7 @@ mod tests { ); storage::set_lp_token_val(&e, &(5_0000000, 0_1000000)); - add_to_reward_zone( - &e, - to_add.clone(), - Address::from_contract_id(&BytesN::from_array(&e, &[0u8; 32])), - ); + add_to_reward_zone(&e, to_add.clone(), Address::generate(&e)); let actual_rz = storage::get_reward_zone(&e); let expected_rz: Vec
= vec![&e, to_add]; assert_eq!(actual_rz, expected_rz); @@ -623,25 +615,25 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); + let to_add = Address::generate(&e); let mut reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -657,11 +649,7 @@ mod tests { ); storage::set_lp_token_val(&e, &(5_0000000, 0_1000000)); - add_to_reward_zone( - &e, - to_add.clone(), - Address::from_contract_id(&BytesN::from_array(&e, &[0u8; 32])), - ); + add_to_reward_zone(&e, to_add.clone(), Address::generate(&e)); let actual_rz = storage::get_reward_zone(&e); reward_zone.push_front(to_add); assert_eq!(actual_rz, reward_zone); @@ -677,25 +665,25 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); + let to_add = Address::generate(&e); let reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -711,11 +699,7 @@ mod tests { ); storage::set_lp_token_val(&e, &(5_0000000, 0_1000000)); - add_to_reward_zone( - &e, - to_add.clone(), - Address::from_contract_id(&BytesN::from_array(&e, &[0u8; 32])), - ); + add_to_reward_zone(&e, to_add.clone(), Address::generate(&e)); }); } @@ -728,26 +712,26 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); - let to_remove = Address::random(&e); + let to_add = Address::generate(&e); + let to_remove = Address::generate(&e); let mut reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), to_remove.clone(), // index 7 - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -795,26 +779,26 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); - let to_remove = Address::random(&e); + let to_add = Address::generate(&e); + let to_remove = Address::generate(&e); let reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), to_remove.clone(), // index 7 - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -855,26 +839,26 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); - let to_remove = Address::random(&e); + let to_add = Address::generate(&e); + let to_remove = Address::generate(&e); let reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), to_remove.clone(), // index 7 - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -915,26 +899,26 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); - let to_remove = Address::random(&e); + let to_add = Address::generate(&e); + let to_remove = Address::generate(&e); let reward_zone: Vec
= vec![ &e, - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { @@ -975,26 +959,26 @@ mod tests { sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let backstop_id = create_backstop(&e); - let to_add = Address::random(&e); - let to_remove = Address::random(&e); + let to_add = Address::generate(&e); + let to_remove = Address::generate(&e); let reward_zone: Vec
= vec![ &e, - Address::random(&e), + Address::generate(&e), to_remove.clone(), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), + Address::generate(&e), to_add.clone(), - Address::random(&e), - Address::random(&e), + Address::generate(&e), + Address::generate(&e), ]; e.as_contract(&backstop_id, || { diff --git a/backstop/src/storage.rs b/backstop/src/storage.rs index f282b939..4179eb9a 100644 --- a/backstop/src/storage.rs +++ b/backstop/src/storage.rs @@ -73,10 +73,10 @@ pub enum BackstopDataKey { ****************************/ /// Bump the instance rent for the contract -pub fn bump_instance(e: &Env) { +pub fn extend_instance(e: &Env) { e.storage() .instance() - .bump(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Fetch an entry in persistent storage that has a default value if it doesn't exist @@ -90,7 +90,7 @@ fn get_persistent_default, V: TryFromVal>( if let Some(result) = e.storage().persistent().get::(key) { e.storage() .persistent() - .bump(key, bump_threshold, bump_amount); + .extend_ttl(key, bump_threshold, bump_amount); result } else { default @@ -269,7 +269,7 @@ pub fn set_pool_balance(e: &Env, pool: &Address, balance: &PoolBalance) { .set::(&key, balance); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Fetch the balances for a given pool @@ -293,7 +293,7 @@ pub fn set_pool_usdc(e: &Env, pool: &Address, balance: &i128) { .set::(&key, balance); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /********** Distribution / Reward Zone **********/ @@ -317,7 +317,7 @@ pub fn set_last_distribution_time(e: &Env, timestamp: &u64) { e.storage() .persistent() .set::(&Symbol::new(e, LAST_DISTRO_KEY), timestamp); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, LAST_DISTRO_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -345,7 +345,7 @@ pub fn set_reward_zone(e: &Env, reward_zone: &Vec
) { e.storage() .persistent() .set::>(&Symbol::new(e, REWARD_ZONE_KEY), reward_zone); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, REWARD_ZONE_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -373,7 +373,7 @@ pub fn set_pool_emissions(e: &Env, pool: &Address, emissions: i128) { .set::(&key, &emissions); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /********** Backstop Depositor Emissions **********/ @@ -494,7 +494,7 @@ pub fn set_drop_list(e: &Env, drop_list: &Map) { e.storage() .temporary() .set::>(&Symbol::new(&e, DROP_LIST_KEY), drop_list); - e.storage().temporary().bump( + e.storage().temporary().extend_ttl( &Symbol::new(&e, DROP_LIST_KEY), LEDGER_THRESHOLD_USER, LEDGER_BUMP_USER, @@ -505,7 +505,7 @@ pub fn set_drop_list(e: &Env, drop_list: &Map) { /// Get the last updated token value for the LP pool pub fn get_lp_token_val(e: &Env) -> (i128, i128) { - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(&e, LP_TOKEN_VAL_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -524,7 +524,7 @@ pub fn set_lp_token_val(e: &Env, share_val: &(i128, i128)) { e.storage() .persistent() .set::(&Symbol::new(&e, LP_TOKEN_VAL_KEY), share_val); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(&e, LP_TOKEN_VAL_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, diff --git a/backstop/src/testutils.rs b/backstop/src/testutils.rs index bcb945c4..e21967f7 100644 --- a/backstop/src/testutils.rs +++ b/backstop/src/testutils.rs @@ -23,7 +23,7 @@ pub(crate) fn create_backstop(e: &Env) -> Address { } pub(crate) fn create_token<'a>(e: &Env, admin: &Address) -> (Address, MockTokenClient<'a>) { - let contract_address = Address::random(e); + let contract_address = Address::generate(e); e.register_contract_wasm(&contract_address, MockTokenWASM); let client = MockTokenClient::new(e, &contract_address); client.initialize(&admin, &7, &"unit".into_val(e), &"test".into_val(e)); @@ -99,9 +99,9 @@ pub(crate) fn create_emitter<'a>( sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); e.as_contract(backstop, || { storage::set_emitter(e, &contract_address); @@ -114,9 +114,9 @@ pub(crate) fn create_emitter<'a>( sequence_number: 0, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); (contract_address.clone(), client) } @@ -134,7 +134,7 @@ pub(crate) fn create_comet_lp_pool<'a>( blnd_token: &Address, usdc_token: &Address, ) -> (Address, CometClient<'a>) { - let contract_address = Address::random(e); + let contract_address = Address::generate(e); e.register_contract_wasm(&contract_address, COMET_WASM); let client = CometClient::new(e, &contract_address); @@ -146,7 +146,7 @@ pub(crate) fn create_comet_lp_pool<'a>( 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.init(&Address::generate(e), &admin); client.bundle_bind( &vec![e, blnd_token.clone(), usdc_token.clone()], &vec![e, 1_000_0000000, 25_0000000], diff --git a/comet.wasm b/comet.wasm index a6a1434544c1d84e89865545756c825407709e50..bd2bc139170616c7d255910b5ee637235a3e2359 100644 GIT binary patch delta 7414 zcmb7J3vg7|dA{e~tGkb@m9E}z>Fi3Zb{DH13$T zF-r`%%!Fc`GZRyrxXdJRoRUyc#ghk31~P8qF?FJ}Q>SB(Tk1~T+Nm8oop|D=sr&us z?nArC9vf!Po_n7E`M>XfoTC>{tIvKxU2riL6K*!ndc_p$?(0z$c7&}_7`u;A{XVu% zwnPw$gPw(xR~0j**b9p>^?lXzckD=`!WD~) zgGCdmj$*HA|LO6oitV*JianEKF&*~hLo+sFRC#R`~BBv~tGT>Vyp zKa$W-a4lW2lzQ=PBg#6&n?~zQm(@)hzDtWiSgwRMH=3~TZ>gy$*M#kVU(f_89zNlW zf)Je9)_j{{`W&SU8ucE|brQh}io1;|Z=A8CYFuh;-u3-@&e^vTAF$&I)nfH#F=o+N ze612sxzCH!o&7)ujw z<65#IV2t_{Ymn>XJ|%G+8(h_`VMRP%5%aWSIVrOEMMZmeS3-eixS_|b!GOW_ZF*cW zc@eanptBi=0yq({M$?iq-zGLyUV;R_sqABZ5vm%hZ{?cpo_7G?T3E9ZjMmdFzerX6 z!zd4cGFC_jBKTGDMPOXVshF)>EnF!zEv?j4%rXVvT#jP()MfTcB*6|Y9Ykc#Q5$M4B33gbTU}`VlbY>Ct3bpS@za{mmcK{j za$AS|F6c#r;6bso_D`cWwV29$3|u_i{Lc#5v^J`7Yg51j^12d?aL-m%S#|r} zTAZ6Mn~y=Eh8;g77S>ma(+%E~%H8&jhj9`>hIS}$11h0;ZiKbC6{eq1a@42Vj2oTG z=77sq#%%TgciC)H1HRNvU|VKFa@hoK^eWQ{eG=Umdl;;ehdkzpj48DsN@7ZZ1z->E zccaNoO|peMNBzukIER=v&5Z<$X`8vhVIepHO|fF2JPukQewXF3#>8WdttrbI20#A8 z1*N-5>F<0Jr9-0`wXdXf&4k5#@XgosDGmfDxtj zpDM03cVphW&Gi+`K~9rolXXk%Z+WdEjU1Rkmh70o3?E`$;&HyAk;7SrMt#oYcN7VR zt-$zHt4+Mk?odq~ z3KThnpU~stpIf6i-oLL3p)3hDpqyz71+jQoJH-MnM`4pb4NeDKT&^MA6i>F%wCCCe zQL4ySzQrWu$3+lPp8D#UgZ=co6*Ew!A9s8;>Z066l9Pk+y@u)XTebp zila%|4;c#vaX(yh)_laTgWa{#4giW5Hd4$@;Hrky&tT<&_J}y#Uc(geSo@6mH2EY$ z`XrIsT_e1qi1D5LUPnqT-W7R7O;A;iy3o z3lD}JDHt3cB3VK$&CwO6shDo?0a$mK|013UPll}901YqAcYyG3WQme@H;4xiMvH_P z6CIKEO2*51#ffCP|AI>W;+{x9^m{&12c3FxcIg#0aV|6L^11Qu|uQ#lyW)9y@{ z?#v)}riu9K)-pgH){X?Kvdj?=tZu{XKVKbAX*i%Se^1?%2O(C>N|xck@cbUj2Tft6 zJeMz__20RYFxT^R6oM;q+4qB8&+U)veb0mhOz+Bvxj23i<@ZZ80U znd0@%u381_(J|dL1#UaawUD~Ur-+WOU<*2>tD>w%30V2s!U6}nx~t&H6<#(;F&@Wo zbcZaetF9PPiF+N`RI$`G03iuB^&?Jf0cMkF-0mAmW~Oo zj6xwjK}`$D*%`n+Xb0exyaIS0=y3pdJAglb<#&+`;IvdwJlE6K(Pfp_!yrf;mo-g! z(C7RL{Hh7RKZezgv9y&c<||^lcj0!&AX)yAK~ivcd5(e>Z()nIGh?*J=x}g>w zcU(5IIB{zqS>w;vM^IkwYef0ezDT)@PB&PfE`y*Zyla|@RG7IcelQT#H0}{UUr!GE za$k)h6A(@O<(kO)%*^`iOr$miehh-%6e1A--doezDW@+n?wdt8`zJO}wDoW{Lspyv z>a24XG15QKhOERs=L{_7-rZ1aac_jv~2lNzk`HSz{)Alq_0>c_0FMcX18FQeGK!~&)hzae1B417RIZePhHUA!J` z%Wh)vQn`tY>~fRVwOdnk%>Pv6F*RO113{Kaf5DL+`_)WS4B1UZZj*P?-OeF=P*L6? zc&#JmGy+dnmjw#yI+oreapujZpDF=YoiqfCIT_)!pC-o-$)$thgSC`b48{CT*0Ih{ zSqIOs|8Q)miK3!`>j%eqoh52%5U=J{p#SyQh7l(iK~$Vev-&Xl9U^=>DBYkOO3ei* z*hMzCf_HqqMAcFi;?CZLC?2@?LoK5qc!6*Q89oeQMa$4~mhruTfjpX%ZERSdvyB|X z#e?g~Hjp`pWFKWf8FR{7M$LwtWi)(p%b44cvkYsQW#C#vmZ9Z1k+F=04SAMP!u8#t z`7(y4E#r%WWEg7(J5cT!B*RDzQh@#HAkqEDgVJCIgR;GLtrvi0jU;OZUN}^;Q;nAr zLrZhgEJ%imyM}URfFuaiU`~Q7&EUzQts~3K;AUgWnL+I|4gs%?BDYD}3`EIr%}$Ni zWk_EFVx=8O;n`Q_JRMHv($jvL3(k|ALGj=)asJui)(q$Ajt0(G@N)G2a(IJ3%X!N1 zJOJXSgxh*RO0t75izT4Ldb2T)O+b_+L`@iB8 z&4YFrWzud$dA}VF%Fy}@3sht%s^Z4PxE{Be;95#}U znDKl20JfM*tVa20q8a6-L_5ltWc@dZo;s{&pM@_j0Y40`f@XS1JPt^ExJaGiy<2kQ^IO`%jW29$!Arx%jdi8@&g#6V8_j@r z6GXVvQzWSxhDpJ)fe3&VbrP(<)6)cnH5{9TJ6RDHngm`OnZ6J-H3&~SHf~CBK zT6mf8Y>bGBEma?aq_GUiZ){l^$*+i!t$)0+5HehajeHPUq2-~0EH4cr-I0H}bpV&9 zYsm=8ci=1=z-+XGev!qTuBDB?0vB(Z4ilTCx&)$ zE&HN%RlbjiU)@&2EYUP&8$d6m#>G#jI>ebNqdRjY%e<#4*xJH7V)k(b^uz0qGG^^c zsOGS^d#YRf_f!-yCcJwc3oh>4Z7_V?JNeDOh^B4772IduB8KNP8%X7QzIzqmTX z#V@9P;;oqmXwNg-5M`J`=7sm7bZ(A@=U+#>ZoOTJfiv zXZIXM*}r!;MxEaKq{_}MhW58;>i-yG%RR3YL$lm9Ma4ve=snme?l}0+pbLM|ptrnZ zi1fzMhx|qO^O$U5)WWDG!ThGvYAjy@p0WDg=)eqME#e-GBif#TbJ3DGwdTjl?!+yR zAg5xdPWW;6#4m0zZu)WKHX`cg8}ShQ%)Psoui?sD1A!rL4ZM7v!XGH|*3eb6SY4c& zHyPt%-=Q;XLA-ltAA50e*L{q!PcKg0U&6$Lp9+_qR4v7&D9UO4>i9jo_}8CWRii1& zr^U-BgREb$M{0WU2g@$}Z(Y~dH+Nv|+}xT2{cC&Y=H>?aqJ6RGzW!L>{#b0^+PS@J MqWk*h_75ok557ng2LJ#7 delta 7709 zcmd5>dvILUdB5l0yZ7GRySuuwENLZK(%IE>Wv{f7B}=j;OLt|-Hh!%h7Pg5KVF$KLgU6|Y6dc)C7y~t2!S#+E|c;otw}Q(m_F$5 zJNMp|{G#oDm1fRDFk(b{{x?L2)BaYcy=TkCJRcwruw_ z$u?xucE1zIhV4E>at!q$+dWS*jn!@U$3Y*>c4vcn)pp+?*+L&?yO&8eoL1Xuw_{2Z zDZ&|79ad>CQQ0)RzfN(T11Y^;>d1B3*dQY2q*!KjvQ}}xsN3G=WNE#RXfEi=m9%D| z3d?>>RiU{mtp1Z z@U7ln!`L*G%z8@d7*35&1J~19BB?-Sm1|Ceh(;=`4A zil1B6T81;RE_^%7h%@2jOl#!4%Kk*WAKk9ylrgb3wsN^#_h|4peey(}hq!S(H$8gz zu9)h}V=+&^pxaUEH}k{TvpQ=Odlvjh`gO)s(t1`okP6i+*r}T5SYw=P`IJ#LtPeVU zTwfPs;&e%OxDnHOn|QsXX-!*B0X#GWI?8S(WBBHc(fu)K4aT6!PJ3g> z3SKO0GL!0{%jEcUs18z6)Ry)oGnLehEMr5(qt~Y}E%< z`ANGc49nmINW(|AD)NzqDL+8{Swz8csVZnMaD zlulcc#B?ShZn>9^L1Dn;Ht)yLt$^^dvY#7it=UP_$C~_bEaWn7WRz^mbd}XE`!Z%^ zBUSjOj$n?$h@N>PxY4c*=5$&EoevMkG>Q39=1i}IkC0!uvl1pNMF*nhiBB@fs*PzA zU=VoLKx*)$g&M0+!@XlTbUde@=*Aw69P8Gy+~8KX){GAfak{l0I)!VtXtp_FXEnFQ zp+$AmPyqz`zyt&qL2xC2z&rb(4aZCmNDZr7o+gB&IVT#PNRawKOGtgB z&yw0c)E7Lc<%Du;%*HV>U~^0D&q{pUK|S&ao-K9qe%2=L;w#_@p5c|OPW%PmQ}i?$ zody?b?RPb&ZDt_ZqOucWe_guKLy$9PZAy3cN)HvSlmL#TLV?{d@nT&U)5Rxs%}oDB zV->`e_05&=+G*`UmNGpY#t2uB%i`gB^c2t4_bri~j*zRusXD8$ijm_F{!vPkYe|`# zRI?!#5;YA~C2$KaJCLIN$kt7$U*C{mAu-jEDl<^+gt%@y!{o<3yAFwOHT0qb=@%mX zLSj*4a}*A_U3rj6D--#~ML01iJeY(^ux1|TF}RrN#$gV|qpDy|=){v4Trel`PGeib zGYbvChk2CS;Dg$%9)fagX-vPshkC3W}MN%7~+wYiK_3@3v6!F-JQi~0*;Tmpds9tjdi zP6ysV-#IqSh$1G=t3i~c`#_O=dQp)jLp1V=%ciPN7mLql2F3H~Sh>duXEV%@7x@-F z98<+F(*$Z&OVdJ~FW@C7^7^2p=94N>SxmNcGDAGnQV}(9NVW%!A1hM{$F5$}v^k{_M3ZeX zj75Z?&=_`NI3&!p1HM^Kxi?RlhLVa?^p5A@ZvHm|V>HL!Nvw;(V&#%-4SX0e2L!;; zqA?4vtI@HS^D-Rm!%K!1fhNgF?$qTU{ODV!&%f8^bf5#yKE_RS_+Uvr&fdwSz|f_c zRAXT1YT@!J+}-Ak4kPuL&9q{!PcvmG%UT=BdZcUg z_UoL;1Gn2++kh#8fWnIrCGipU&&(80v{pn-c*BSXmnmLq?PaEf3vubDaG7GLt*#iy zL2xYy;4;NMZS~W#c5lkY#;+**Q}W?HZtcRlIq4@Ioe{Ts; zq^TOjn^~avjrPQ?lKmHm{f3PQu^O`+Wk}(2YSEm#_x-xWH3;D}#K&72&sBJTAQrcu zT@~Pc^`~c)Od2I8HY1&l(1+%XgX>_$NNPdgwsoXPg8a)Y78mVZ*@~bOVilMXb~+2K zU+JpHL{D@jQNGYsUmfSg-ZUv2K7iaun8(Lq{Bf)+ik8(E=5lzEoJ*z%a;5dlZkeXd zyes`Mf>{)|2B~lqvtloZBb%wfRIzz#U!@UGcK{ajvrr@W(T@(&a4+t~UWOy1W|R`b*1w+x(vl>7(UyhE#QPL)yGz z&XAmWhJ?Em8ImRq>Dd)m8B(0(M2ofd`iFrx1w2&Y4-;$nZA@fX&EF^)O z0f#?FK^7w1mE~h`UJ=*>8L{stf(?A8Jw)hrfd+3$(omQKDbpanx01}^y_I#IvGgEQ zlIBpt7ofFvV8xsnP|7E#@XVl;FGP=f1_Cp{3Q#-z|G*5+s!sK1nZX<4%D{aq0>0Dd zRh$pYphC%oE~80NKz5)i$*zj84>#GWBqCjsE%C2|X=aHJh8Lk+=B6tximgwvR7pTq z3vU~A#|?>-ZU)H)nol!sP2i>HNzbF39!X7rZHRwxr!W&+QzEwH5|9q(YUKAOl;@=U zvs|_U)3}eo+s8pI1F@=;>&@yT4Epe)dRj!bdP{}CO#}?nSvIdzLfkhLt?{)o%-c7zyH>2-(~Q_ zI^`3VB-x?0O(5Ae4*C~H@@q1?2(1|=U#EU|!I z01PI&7B_0{@^PcVP0fXG*LNn%EzAWDHOZCA#K0P>MJjokrErG~c*l^J;xU9flW>vd zW-27?Ut3d2czaBxw!(-)CriA#rVc5Ac&dCd?0zmxv=iUu69a(oT4Z0$(VgB0iq6!58t)+TX~|=LazY_YFKCff#t& z!Aq6&3k71RoQTnlOT*TDi$#|PJ)=A&xLb-UzOJQGCiUl7s=y6A{YiJAi$m*=bc_Vj=B zCFDN>Uoz`);}_&h;^a#%z?X;**S3onH}ypWqBx`apm6eQa8)M~&_%yM0z>>kzNJ!{ z(tHvaJ_%IuQ9k2Y+EYmPZw!|v){RbK^6!r>MoEa1ED@)nK9q6|OhR7V3kSf(5JRAp zA@+{Zpa-P5?>uJ$H2$N zTNWEPK)L`+K52VM%kUxIA19>w1SvBxk-i3HnQH@O*SQv9@zaUKU=R>)X5a+Yjqa6X z>@e`3h<7IjCIiesytVShk2%pwJoI~hA8+JJ9%-DOi^zvsJ$K$MO^36*Zr#6>Y6VI-H@yg1@SBS6kD)AGX-yLG(WLqcVinqLi<>6NR{7r5RuiGlF zl+HxqB2A0fida9n8^00EO!lybnSY)%=m&#;yY&;4A8x5)7esh#jj9d`z9lKvY~@T9 z`?fZrd~|D78hFTud%TCyGdw+$;c*DH{xiHPU*G6OEQ)O^zjPuhy8L;dG~@Ibez3-rH3@j-R*iBL_MXV^6@}XnFZAk~E`CME5NM z0YBVZZ73i{R1@ia6Z40dR}W$S5Ka8vzG@9aW?tK8GrTch-hYa{Bn}_g$=;s%+XIZT zV>7QEjI)y4@4kELt}pNV(ii#e+xH!ux??%tDc-p=y+ApwI*O?%$`kn1@%f#ZnlCn# zYrV?dV&r5aTPp56S>Cm@BioAq%w4-W>axAP9i8n i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); let backstop_address = storage::get_backstop(&e); let distribution_amount = emitter::execute_distribute(&e, &backstop_address); @@ -108,7 +108,7 @@ impl Emitter for EmitterContract { } fn queue_swap_backstop(e: Env, new_backstop: Address, new_backstop_token: Address) { - storage::bump_instance(&e); + storage::extend_instance(&e); let swap = backstop_manager::execute_queue_swap_backstop(&e, &new_backstop, &new_backstop_token); @@ -120,21 +120,21 @@ impl Emitter for EmitterContract { } fn cancel_swap_backstop(e: Env) { - storage::bump_instance(&e); + storage::extend_instance(&e); let swap = backstop_manager::execute_cancel_swap_backstop(&e); e.events().publish((Symbol::new(&e, "del_swap"),), swap); } fn swap_backstop(e: Env) { - storage::bump_instance(&e); + storage::extend_instance(&e); let swap = backstop_manager::execute_swap_backstop(&e); e.events().publish((Symbol::new(&e, "swap"),), swap); } fn drop(e: Env, list: Map) { - storage::bump_instance(&e); + storage::extend_instance(&e); emitter::execute_drop(&e, &list); e.events().publish((Symbol::new(&e, "drop"),), list); diff --git a/emitter/src/emitter.rs b/emitter/src/emitter.rs index c9fddf85..ddffa380 100644 --- a/emitter/src/emitter.rs +++ b/emitter/src/emitter.rs @@ -70,13 +70,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let emitter = create_emitter(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let blnd_id = e.register_stellar_asset_contract(emitter.clone()); let blnd_client = MockTokenClient::new(&e, &blnd_id); @@ -104,15 +104,15 @@ mod tests { sequence_number: 5000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let frodo = Address::random(&e); - let samwise = Address::random(&e); + let frodo = Address::generate(&e); + let samwise = Address::generate(&e); let emitter = create_emitter(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let blnd_id = e.register_stellar_asset_contract(emitter.clone()); let blnd_client = MockTokenClient::new(&e, &blnd_id); @@ -147,15 +147,15 @@ mod tests { sequence_number: 5000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let frodo = Address::random(&e); - let samwise = Address::random(&e); + let frodo = Address::generate(&e); + let samwise = Address::generate(&e); let emitter = create_emitter(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let blnd_id = e.register_stellar_asset_contract(emitter.clone()); let drop_list = map![ @@ -188,15 +188,15 @@ mod tests { sequence_number: 5000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let frodo = Address::random(&e); - let samwise = Address::random(&e); + let frodo = Address::generate(&e); + let samwise = Address::generate(&e); let emitter = create_emitter(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let blnd_id = e.register_stellar_asset_contract(emitter.clone()); let drop_list = map![ @@ -228,16 +228,16 @@ mod tests { sequence_number: 5000000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let frodo = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let frodo = Address::generate(&e); + let samwise = Address::generate(&e); let emitter = create_emitter(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let blnd_id = e.register_stellar_asset_contract(bombadil.clone()); let drop_list = map![ diff --git a/emitter/src/storage.rs b/emitter/src/storage.rs index e3366849..59c07249 100644 --- a/emitter/src/storage.rs +++ b/emitter/src/storage.rs @@ -24,10 +24,10 @@ pub enum EmitterDataKey { } /// Bump the instance rent for the contract. Bumps for 10 days due to the 7-day cycle window of this contract -pub fn bump_instance(e: &Env) { +pub fn extend_instance(e: &Env) { e.storage() .instance() - .bump(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /********** Backstop **********/ @@ -75,7 +75,7 @@ pub fn set_backstop_token(e: &Env, new_backstop_token: &Address) { /// Fetch the current queued backstop swap, or None pub fn get_queued_swap(e: &Env) -> Option { if let Some(result) = e.storage().persistent().get(&Symbol::new(e, SWAP_KEY)) { - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, SWAP_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -94,7 +94,7 @@ pub fn set_queued_swap(e: &Env, swap: &Swap) { e.storage() .persistent() .set::(&Symbol::new(e, SWAP_KEY), swap); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, SWAP_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -163,7 +163,7 @@ pub fn set_last_distro_time(e: &Env, backstop: &Address, last_distro: u64) { .set::(&key, &last_distro); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Get whether the emitter has performed the drop distribution or not for the current backstop diff --git a/mocks/mock-pool-factory/src/pool_factory.rs b/mocks/mock-pool-factory/src/pool_factory.rs index cdc1d31b..dc7e2a11 100644 --- a/mocks/mock-pool-factory/src/pool_factory.rs +++ b/mocks/mock-pool-factory/src/pool_factory.rs @@ -66,7 +66,7 @@ impl MockPoolFactoryTrait for MockPoolFactory { oracle: Address, backstop_take_rate: u64, ) -> Address { - storage::bump_instance(&e); + storage::extend_instance(&e); let pool_init_meta = storage::get_pool_init_meta(&e); // verify backstop take rate is within [0,1) with 9 decimals diff --git a/mocks/mock-pool-factory/src/storage.rs b/mocks/mock-pool-factory/src/storage.rs index acb9597f..4a22190d 100644 --- a/mocks/mock-pool-factory/src/storage.rs +++ b/mocks/mock-pool-factory/src/storage.rs @@ -21,14 +21,16 @@ pub struct PoolInitMeta { } /// Bump the instance rent for the contract -pub fn bump_instance(e: &Env) { - e.storage().instance().bump(LEDGER_THRESHOLD, LEDGER_BUMP); +pub fn extend_instance(e: &Env) { + e.storage() + .instance() + .extend_ttl(LEDGER_THRESHOLD, LEDGER_BUMP); } /// Fetch the pool initialization metadata pub fn get_pool_init_meta(e: &Env) -> PoolInitMeta { // TODO: Change to instance - https://github.com/stellar/rs-soroban-sdk/issues/1040 - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &PoolFactoryDataKey::PoolInitMeta, LEDGER_THRESHOLD, LEDGER_BUMP, @@ -69,7 +71,7 @@ pub fn is_deployed(e: &Env, contract_id: &Address) -> bool { { e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); result } else { false @@ -87,5 +89,5 @@ pub fn set_deployed(e: &Env, contract_id: &Address) { .set::(&key, &true); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); } diff --git a/pool-factory/src/pool_factory.rs b/pool-factory/src/pool_factory.rs index fcc462cc..f8fbdea8 100644 --- a/pool-factory/src/pool_factory.rs +++ b/pool-factory/src/pool_factory.rs @@ -46,7 +46,7 @@ pub trait PoolFactory { #[contractimpl] impl PoolFactory for PoolFactoryContract { fn initialize(e: Env, pool_init_meta: PoolInitMeta) { - storage::bump_instance(&e); + storage::extend_instance(&e); if storage::has_pool_init_meta(&e) { panic_with_error!(&e, PoolFactoryError::AlreadyInitialized); } @@ -62,7 +62,7 @@ impl PoolFactory for PoolFactoryContract { backstop_take_rate: u64, ) -> Address { admin.require_auth(); - storage::bump_instance(&e); + storage::extend_instance(&e); let pool_init_meta = storage::get_pool_init_meta(&e); // verify backstop take rate is within [0,1) with 9 decimals @@ -92,7 +92,7 @@ impl PoolFactory for PoolFactoryContract { } fn is_pool(e: Env, pool_address: Address) -> bool { - storage::bump_instance(&e); + storage::extend_instance(&e); storage::is_deployed(&e, &pool_address) } } diff --git a/pool-factory/src/storage.rs b/pool-factory/src/storage.rs index e721c9cb..ad726e96 100644 --- a/pool-factory/src/storage.rs +++ b/pool-factory/src/storage.rs @@ -20,8 +20,10 @@ pub struct PoolInitMeta { } /// Bump the instance rent for the contract -pub fn bump_instance(e: &Env) { - e.storage().instance().bump(LEDGER_THRESHOLD, LEDGER_BUMP); +pub fn extend_instance(e: &Env) { + e.storage() + .instance() + .extend_ttl(LEDGER_THRESHOLD, LEDGER_BUMP); } /// Fetch the pool initialization metadata @@ -60,7 +62,7 @@ pub fn is_deployed(e: &Env, contract_id: &Address) -> bool { { e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); result } else { false @@ -78,5 +80,5 @@ pub fn set_deployed(e: &Env, contract_id: &Address) { .set::(&key, &true); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD, LEDGER_BUMP); + .extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_BUMP); } diff --git a/pool-factory/src/test.rs b/pool-factory/src/test.rs index c7d0746a..a2aa2249 100644 --- a/pool-factory/src/test.rs +++ b/pool-factory/src/test.rs @@ -25,13 +25,13 @@ fn test_pool_factory() { let wasm_hash = e.deployer().upload_contract_wasm(pool::WASM); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); - let oracle = Address::random(&e); - let backstop_id = Address::random(&e); + let oracle = Address::generate(&e); + let backstop_id = Address::generate(&e); let backstop_rate: u64 = 100000; - let blnd_id = Address::random(&e); - let usdc_id = Address::random(&e); + let blnd_id = Address::generate(&e); + let usdc_id = Address::generate(&e); let pool_init_meta = PoolInitMeta { backstop: backstop_id.clone(), @@ -68,7 +68,6 @@ fn test_pool_factory() { let deployed_pool_address_2 = pool_factory_client.deploy(&bombadil, &name2, &salt, &oracle, &backstop_rate); - let zero_address = Address::from_contract_id(&BytesN::from_array(&e, &[0; 32])); e.as_contract(&deployed_pool_address_1, || { assert_eq!( e.storage() @@ -110,10 +109,8 @@ fn test_pool_factory() { usdc_id.clone() ); }); - assert_ne!(deployed_pool_address_1, zero_address); - assert_ne!(deployed_pool_address_2, zero_address); assert_ne!(deployed_pool_address_1, deployed_pool_address_2); assert!(pool_factory_client.is_pool(&deployed_pool_address_1)); assert!(pool_factory_client.is_pool(&deployed_pool_address_2)); - assert!(!pool_factory_client.is_pool(&zero_address)); + assert!(!pool_factory_client.is_pool(&Address::generate(&e))); } diff --git a/pool/Cargo.toml b/pool/Cargo.toml index 6f1f3012..799ddf65 100644 --- a/pool/Cargo.toml +++ b/pool/Cargo.toml @@ -16,7 +16,7 @@ testutils = [ [dependencies] soroban-sdk = { workspace = true } -fixed-point-math = { workspace = true } +soroban-fixed-point-math = { workspace = true } cast = { workspace = true } sep-40-oracle = { workspace = true } sep-41-token = { workspace = true} diff --git a/pool/src/auctions/auction.rs b/pool/src/auctions/auction.rs index f3e07ce5..605cb2fa 100644 --- a/pool/src/auctions/auction.rs +++ b/pool/src/auctions/auction.rs @@ -5,7 +5,7 @@ use crate::{ storage, }; use cast::i128; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ contracttype, map, panic_with_error, unwrap::UnwrapOptimized, Address, Env, Map, }; @@ -275,13 +275,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -409,12 +409,12 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool_address = create_pool(&e); let (usdc_id, _) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -423,9 +423,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), - &Address::random(&e), - &Address::random(&e), + &Address::generate(&e), + &Address::generate(&e), + &Address::generate(&e), ); let (oracle_id, oracle_client) = testutils::create_mock_oracle(&e); @@ -513,13 +513,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (oracle_address, oracle_client) = testutils::create_mock_oracle(&e); @@ -613,7 +613,7 @@ mod tests { fn test_create_user_liquidation_errors() { let e = Env::default(); let pool_id = create_pool(&e); - let backstop_id = Address::random(&e); + let backstop_id = Address::generate(&e); e.as_contract(&pool_id, || { storage::set_backstop(&e, &backstop_id); @@ -628,7 +628,7 @@ mod tests { e.mock_all_auths(); let pool_id = create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let auction_data = AuctionData { bid: map![&e], @@ -659,7 +659,7 @@ mod tests { e.mock_all_auths(); let pool_id = create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.as_contract(&pool_id, || { delete_liquidation(&e, &samwise); @@ -677,14 +677,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -760,9 +760,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); @@ -784,14 +784,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -867,9 +867,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); @@ -904,14 +904,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -988,9 +988,9 @@ mod tests { sequence_number: 176 + 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let mut pool = Pool::load(&e); let mut frodo_state = User::load(&e, &frodo); @@ -1018,9 +1018,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let mut pool = Pool::load(&e); let mut frodo_state = User::load(&e, &frodo); @@ -1047,9 +1047,9 @@ mod tests { sequence_number: 176 + 300, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let mut pool = Pool::load(&e); let mut frodo_state = User::load(&e, &frodo); @@ -1093,14 +1093,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -1175,9 +1175,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); @@ -1212,14 +1212,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -1296,9 +1296,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); @@ -1325,8 +1325,8 @@ mod tests { fn test_scale_auction_100_fill_pct() { // 0 blocks let e = Env::default(); - let underlying_0 = Address::random(&e); - let underlying_1 = Address::random(&e); + let underlying_0 = Address::generate(&e); + let underlying_1 = Address::generate(&e); let base_auction_data = AuctionData { bid: map![&e, (underlying_0.clone(), 100_0000000)], @@ -1341,9 +1341,9 @@ mod tests { sequence_number: 1000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction) = scale_auction(&e, &base_auction_data, 100); assert_eq!( @@ -1360,9 +1360,9 @@ mod tests { sequence_number: 1100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction) = scale_auction(&e, &base_auction_data, 100); assert_eq!( @@ -1382,9 +1382,9 @@ mod tests { sequence_number: 1200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction) = scale_auction(&e, &base_auction_data, 100); assert_eq!( @@ -1404,9 +1404,9 @@ mod tests { sequence_number: 1300, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction) = scale_auction(&e, &base_auction_data, 100); assert_eq!( @@ -1426,9 +1426,9 @@ mod tests { sequence_number: 1400, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction) = scale_auction(&e, &base_auction_data, 100); assert_eq!(scaled_auction.bid.len(), 0); @@ -1444,8 +1444,8 @@ mod tests { // @dev: bids always round up, lots always round down // the remaining is exact based on scaled auction let e = Env::default(); - let underlying_0 = Address::random(&e); - let underlying_1 = Address::random(&e); + let underlying_0 = Address::generate(&e); + let underlying_1 = Address::generate(&e); let base_auction_data = AuctionData { bid: map![&e, (underlying_0.clone(), 25_0000005)], @@ -1460,9 +1460,9 @@ mod tests { sequence_number: 1000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction_option) = scale_auction(&e, &base_auction_data, 50); let remaining_auction = remaining_auction_option.unwrap(); @@ -1487,9 +1487,9 @@ mod tests { sequence_number: 1100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction_option) = scale_auction(&e, &base_auction_data, 60); @@ -1518,9 +1518,9 @@ mod tests { sequence_number: 1300, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction_option) = scale_auction(&e, &base_auction_data, 60); @@ -1549,9 +1549,9 @@ mod tests { sequence_number: 1400, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 172800, - min_persistent_entry_expiration: 172800, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 172800, + min_persistent_entry_ttl: 172800, + max_entry_ttl: 9999999, }); let (scaled_auction, remaining_auction_option) = scale_auction(&e, &base_auction_data, 50); let remaining_auction = remaining_auction_option.unwrap(); diff --git a/pool/src/auctions/backstop_interest_auction.rs b/pool/src/auctions/backstop_interest_auction.rs index 1b050de4..1245264c 100644 --- a/pool/src/auctions/backstop_interest_auction.rs +++ b/pool/src/auctions/backstop_interest_auction.rs @@ -2,8 +2,8 @@ use crate::{ constants::SCALAR_7, dependencies::BackstopClient, errors::PoolError, pool::Pool, storage, }; use cast::i128; -use fixed_point_math::FixedPoint; use sep_41_token::TokenClient; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{map, panic_with_error, unwrap::UnwrapOptimized, Address, Env}; use super::{AuctionData, AuctionType}; @@ -108,7 +108,7 @@ mod tests { let e = Env::default(); let pool_address = create_pool(&e); - let backstop_address = Address::random(&e); + let backstop_address = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 12345, @@ -116,9 +116,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let auction_data = AuctionData { @@ -151,12 +151,12 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool_address = create_pool(&e); let (usdc_id, _) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -165,9 +165,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), + &Address::generate(&e), &usdc_id, - &Address::random(&e), + &Address::generate(&e), ); let (oracle_id, oracle_client) = testutils::create_mock_oracle(&e); @@ -262,12 +262,12 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool_address = create_pool(&e); let (usdc_id, _) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -276,9 +276,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), + &Address::generate(&e), &usdc_id, - &Address::random(&e), + &Address::generate(&e), ); let (oracle_id, oracle_client) = testutils::create_mock_oracle(&e); @@ -373,12 +373,12 @@ mod tests { sequence_number: 150, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool_address = create_pool(&e); let (usdc_id, _) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -387,9 +387,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), + &Address::generate(&e), &usdc_id, - &Address::random(&e), + &Address::generate(&e), ); let (oracle_id, oracle_client) = testutils::create_mock_oracle(&e); @@ -486,13 +486,13 @@ mod tests { sequence_number: 301, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); @@ -502,9 +502,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), + &Address::generate(&e), &usdc_id, - &Address::random(&e), + &Address::generate(&e), ); let (underlying_0, underlying_0_client) = testutils::create_token_contract(&e, &bombadil); @@ -542,7 +542,7 @@ mod tests { underlying_1_client.mint(&pool_address, &1_000_0000000); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; diff --git a/pool/src/auctions/bad_debt_auction.rs b/pool/src/auctions/bad_debt_auction.rs index 62c7e29f..af541f9f 100644 --- a/pool/src/auctions/bad_debt_auction.rs +++ b/pool/src/auctions/bad_debt_auction.rs @@ -6,7 +6,7 @@ use crate::{ storage, }; use cast::i128; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{map, panic_with_error, unwrap::UnwrapOptimized, Address, Env}; use super::{AuctionData, AuctionType}; @@ -131,8 +131,8 @@ mod tests { e.budget().reset_unlimited(); // setup exhausts budget let pool_address = create_pool(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); let (usdc, usdc_client) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -166,9 +166,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let auction_data = AuctionData { @@ -200,13 +200,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -333,13 +333,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -467,13 +467,13 @@ mod tests { sequence_number: 150, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -601,13 +601,13 @@ mod tests { sequence_number: 51, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); @@ -676,7 +676,7 @@ mod tests { &reserve_data_2, ); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -745,13 +745,13 @@ mod tests { sequence_number: 51, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -819,7 +819,7 @@ mod tests { &reserve_data_2, ); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -895,13 +895,13 @@ mod tests { sequence_number: 51, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (blnd, blnd_client) = testutils::create_blnd_token(&e, &pool_address, &bombadil); @@ -969,7 +969,7 @@ mod tests { &reserve_data_2, ); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; diff --git a/pool/src/auctions/user_liquidation_auction.rs b/pool/src/auctions/user_liquidation_auction.rs index 381366b7..e3c04944 100644 --- a/pool/src/auctions/user_liquidation_auction.rs +++ b/pool/src/auctions/user_liquidation_auction.rs @@ -1,5 +1,5 @@ use cast::i128; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::unwrap::UnwrapOptimized; use soroban_sdk::{map, panic_with_error, Address, Env}; @@ -157,7 +157,7 @@ mod tests { let pool_address = create_pool(&e); let (oracle, _) = testutils::create_mock_oracle(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 12345, @@ -165,9 +165,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let liq_pct = 50; @@ -205,13 +205,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (oracle_address, oracle_client) = testutils::create_mock_oracle(&e); @@ -317,13 +317,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); @@ -424,13 +424,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); @@ -532,13 +532,13 @@ mod tests { sequence_number: 50, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); @@ -639,14 +639,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 17280, - min_persistent_entry_expiration: 17280, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 17280, + min_persistent_entry_ttl: 17280, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -748,9 +748,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 17280, - min_persistent_entry_expiration: 17280, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 17280, + min_persistent_entry_ttl: 17280, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); @@ -814,14 +814,14 @@ mod tests { sequence_number: 175, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 17280, - min_persistent_entry_expiration: 17280, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 17280, + min_persistent_entry_ttl: 17280, + max_entry_ttl: 9999999, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -923,9 +923,9 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 17280, - min_persistent_entry_expiration: 17280, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 17280, + min_persistent_entry_ttl: 17280, + max_entry_ttl: 9999999, }); e.budget().reset_unlimited(); let mut pool = Pool::load(&e); diff --git a/pool/src/contract.rs b/pool/src/contract.rs index 808cc750..49822f93 100644 --- a/pool/src/contract.rs +++ b/pool/src/contract.rs @@ -218,7 +218,7 @@ impl Pool for PoolContract { blnd_id: Address, usdc_id: Address, ) { - storage::bump_instance(&e); + storage::extend_instance(&e); pool::execute_initialize( &e, @@ -233,7 +233,7 @@ impl Pool for PoolContract { } fn set_admin(e: Env, new_admin: Address) { - storage::bump_instance(&e); + storage::extend_instance(&e); let admin = storage::get_admin(&e); admin.require_auth(); @@ -244,7 +244,7 @@ impl Pool for PoolContract { } fn update_pool(e: Env, backstop_take_rate: u64) { - storage::bump_instance(&e); + storage::extend_instance(&e); let admin = storage::get_admin(&e); admin.require_auth(); @@ -255,7 +255,7 @@ impl Pool for PoolContract { } fn init_reserve(e: Env, asset: Address, config: ReserveConfig) -> u32 { - storage::bump_instance(&e); + storage::extend_instance(&e); let admin = storage::get_admin(&e); admin.require_auth(); @@ -267,7 +267,7 @@ impl Pool for PoolContract { } fn update_reserve(e: Env, asset: Address, config: ReserveConfig) { - storage::bump_instance(&e); + storage::extend_instance(&e); let admin = storage::get_admin(&e); admin.require_auth(); @@ -288,7 +288,7 @@ impl Pool for PoolContract { to: Address, requests: Vec, ) -> Positions { - storage::bump_instance(&e); + storage::extend_instance(&e); spender.require_auth(); if from != spender { from.require_auth(); @@ -302,7 +302,7 @@ impl Pool for PoolContract { } fn update_status(e: Env) -> u32 { - storage::bump_instance(&e); + storage::extend_instance(&e); let new_status = pool::execute_update_pool_status(&e); e.events() @@ -311,7 +311,7 @@ impl Pool for PoolContract { } fn set_status(e: Env, pool_status: u32) { - storage::bump_instance(&e); + storage::extend_instance(&e); let admin = storage::get_admin(&e); admin.require_auth(); @@ -324,7 +324,7 @@ impl Pool for PoolContract { /********* Emission Functions **********/ fn gulp_emissions(e: Env) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); let next_expiration = emissions::gulp_emissions(&e); e.events() @@ -340,7 +340,7 @@ impl Pool for PoolContract { } fn claim(e: Env, from: Address, reserve_token_ids: Vec, to: Address) -> i128 { - storage::bump_instance(&e); + storage::extend_instance(&e); from.require_auth(); let amount_claimed = emissions::execute_claim(&e, &from, &reserve_token_ids, &to); @@ -370,7 +370,7 @@ impl Pool for PoolContract { } fn new_auction(e: Env, auction_type: u32) -> AuctionData { - storage::bump_instance(&e); + storage::extend_instance(&e); let auction_data = auctions::create(&e, auction_type); e.events().publish( diff --git a/pool/src/emissions/distributor.rs b/pool/src/emissions/distributor.rs index 0c43cf0c..b7478e7d 100644 --- a/pool/src/emissions/distributor.rs +++ b/pool/src/emissions/distributor.rs @@ -1,6 +1,6 @@ use cast::i128; -use fixed_point_math::FixedPoint; use sep_41_token::TokenClient; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{panic_with_error, unwrap::UnwrapOptimized, Address, Env, Vec}; use crate::{ @@ -239,7 +239,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1501000000, // 10^6 seconds have passed @@ -247,9 +247,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply: i128 = 50_0000000; @@ -303,7 +303,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1501000000, // 10^6 seconds have passed @@ -311,9 +311,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply: i128 = 100_0000000; @@ -355,9 +355,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 50_0000000; @@ -394,9 +394,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 50_0000000; @@ -445,9 +445,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 50_0000000; @@ -496,9 +496,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 50_0000000; @@ -547,9 +547,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 0; @@ -598,9 +598,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 100_0000000; @@ -646,9 +646,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply = 100_0001111; @@ -689,7 +689,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -697,9 +697,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -735,7 +735,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -743,9 +743,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -781,7 +781,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -789,9 +789,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -834,7 +834,7 @@ mod tests { let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -842,9 +842,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -886,7 +886,7 @@ mod tests { e.mock_all_auths(); let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -894,9 +894,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -939,7 +939,7 @@ mod tests { let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -947,9 +947,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -993,7 +993,7 @@ mod tests { let pool = testutils::create_pool(&e); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1500000000, @@ -1001,9 +1001,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let supply_scalar = 1_0000000; @@ -1042,9 +1042,9 @@ mod tests { e.budget().reset_unlimited(); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let merry = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let merry = Address::generate(&e); let (_, blnd_token_client) = testutils::create_blnd_token(&e, &pool, &bombadil); let (backstop, _) = testutils::create_backstop(&e); @@ -1060,9 +1060,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); @@ -1168,9 +1168,9 @@ mod tests { e.budget().reset_unlimited(); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let merry = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let merry = Address::generate(&e); let (backstop, _) = testutils::create_backstop(&e); let (_, blnd_token_client) = testutils::create_blnd_token(&e, &pool, &bombadil); @@ -1187,9 +1187,9 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); diff --git a/pool/src/emissions/manager.rs b/pool/src/emissions/manager.rs index 98a8e7d7..0fe5efaf 100644 --- a/pool/src/emissions/manager.rs +++ b/pool/src/emissions/manager.rs @@ -5,7 +5,7 @@ use crate::{ storage::{self, ReserveEmissionsConfig, ReserveEmissionsData}, }; use cast::{i128, u64}; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ contracttype, map, panic_with_error, unwrap::UnwrapOptimized, Address, Env, Map, Symbol, Vec, }; @@ -163,13 +163,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let new_emissions: i128 = 302_400_0000000; let pool_emissions: Map = map![&e]; @@ -202,13 +202,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let new_emissions: i128 = 302_400_0000000; let pool_emissions: Map = map![ @@ -298,13 +298,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let new_emissions: i128 = 1000000; let pool_emissions: Map = map![ @@ -368,13 +368,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); @@ -423,13 +423,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); @@ -474,13 +474,13 @@ mod tests { sequence_number: 20100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); diff --git a/pool/src/pool/actions.rs b/pool/src/pool/actions.rs index 9b00bc08..deeec137 100644 --- a/pool/src/pool/actions.rs +++ b/pool/src/pool/actions.rs @@ -310,8 +310,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -324,12 +324,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -378,8 +378,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -392,12 +392,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -451,8 +451,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -465,12 +465,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -521,8 +521,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -535,12 +535,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -592,8 +592,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -606,12 +606,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -664,8 +664,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -678,12 +678,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -734,8 +734,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -747,12 +747,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -797,8 +797,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -811,12 +811,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -870,8 +870,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -884,12 +884,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -942,8 +942,8 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); @@ -963,12 +963,12 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_200_000_000, status: 0, }; @@ -1050,14 +1050,14 @@ mod tests { sequence_number: 176 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -1185,14 +1185,14 @@ mod tests { sequence_number: 51 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); let pool_address = create_pool(&e); @@ -1208,8 +1208,8 @@ mod tests { &pool_address, &backstop_address, &backstop_token_id, - &Address::random(&e), - &Address::random(&e), + &Address::generate(&e), + &Address::generate(&e), ); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); let (mut reserve_config_0, mut reserve_data_0) = testutils::default_reserve_meta(); @@ -1307,13 +1307,13 @@ mod tests { sequence_number: 51 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let pool_address = create_pool(&e); let (usdc_id, usdc_client) = testutils::create_usdc_token(&e, &pool_address, &bombadil); @@ -1322,9 +1322,9 @@ mod tests { &e, &pool_address, &backstop_address, - &Address::random(&e), + &Address::generate(&e), &usdc_id, - &Address::random(&e), + &Address::generate(&e), ); let (underlying_0, underlying_0_client) = testutils::create_token_contract(&e, &bombadil); @@ -1370,7 +1370,7 @@ mod tests { underlying_2_client.mint(&pool_address, &1_000_0000000); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -1441,19 +1441,19 @@ mod tests { sequence_number: 51 + 200, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let samwise = Address::random(&e); - let underlying_0 = Address::random(&e); - let underlying_1 = Address::random(&e); + let samwise = Address::generate(&e); + let underlying_0 = Address::generate(&e); + let underlying_1 = Address::generate(&e); let pool_address = create_pool(&e); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -1483,7 +1483,7 @@ mod tests { &e, Request { request_type: 9, - address: Address::random(&e), + address: Address::generate(&e), amount: 0, }, ]; diff --git a/pool/src/pool/bad_debt.rs b/pool/src/pool/bad_debt.rs index aabd6eb0..0e1279a7 100644 --- a/pool/src/pool/bad_debt.rs +++ b/pool/src/pool/bad_debt.rs @@ -92,16 +92,16 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); - let samwise = Address::random(&e); - let bombadil = Address::random(&e); + let samwise = Address::generate(&e); + let bombadil = Address::generate(&e); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -113,7 +113,7 @@ mod tests { testutils::create_reserve(&e, &pool, &underlying_1, &reserve_config, &reserve_data); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -158,16 +158,16 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); - let samwise = Address::random(&e); - let bombadil = Address::random(&e); + let samwise = Address::generate(&e); + let bombadil = Address::generate(&e); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -179,7 +179,7 @@ mod tests { testutils::create_reserve(&e, &pool, &underlying_1, &reserve_config, &reserve_data); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -210,16 +210,16 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); - let samwise = Address::random(&e); - let bombadil = Address::random(&e); + let samwise = Address::generate(&e); + let bombadil = Address::generate(&e); let (underlying_1, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -231,7 +231,7 @@ mod tests { testutils::create_reserve(&e, &pool, &underlying_2, &reserve_config, &reserve_data); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -258,16 +258,16 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); - let samwise = Address::random(&e); - let bombadil = Address::random(&e); + let samwise = Address::generate(&e); + let bombadil = Address::generate(&e); let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -279,7 +279,7 @@ mod tests { testutils::create_reserve(&e, &pool, &underlying_1, &reserve_config, &reserve_data); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -309,14 +309,14 @@ mod tests { sequence_number: 123, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let backstop = Address::random(&e); + let backstop = Address::generate(&e); let (_, blnd_client) = testutils::create_blnd_token(&e, &pool, &bombadil); @@ -334,7 +334,7 @@ mod tests { blnd_client.mint(&backstop, &123); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; diff --git a/pool/src/pool/config.rs b/pool/src/pool/config.rs index c986103a..c560db04 100644 --- a/pool/src/pool/config.rs +++ b/pool/src/pool/config.rs @@ -136,13 +136,13 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let admin = Address::random(&e); + let admin = Address::generate(&e); let name = Symbol::new(&e, "pool_name"); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let bstop_rate = 0_100_000_000u64; - let backstop_address = Address::random(&e); - let blnd_id = Address::random(&e); - let usdc_id = Address::random(&e); + let backstop_address = Address::generate(&e); + let blnd_id = Address::generate(&e); + let usdc_id = Address::generate(&e); e.as_contract(&pool, || { execute_initialize( @@ -173,7 +173,7 @@ mod tests { let pool = testutils::create_pool(&e); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -196,7 +196,7 @@ mod tests { let pool = testutils::create_pool(&e); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -211,7 +211,7 @@ mod tests { fn test_initialize_reserve() { let e = Env::default(); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (asset_id_0, _) = testutils::create_token_contract(&e, &bombadil); let (asset_id_1, _) = testutils::create_token_contract(&e, &bombadil); @@ -253,7 +253,7 @@ mod tests { fn test_initialize_reserve_blocks_duplicates() { let e = Env::default(); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (asset_id, _) = testutils::create_token_contract(&e, &bombadil); let metadata = ReserveConfig { @@ -281,7 +281,7 @@ mod tests { fn test_initialize_reserve_validates_metadata() { let e = Env::default(); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (asset_id, _) = testutils::create_token_contract(&e, &bombadil); let metadata = ReserveConfig { @@ -314,13 +314,13 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -345,13 +345,13 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; @@ -392,13 +392,13 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool = testutils::create_pool(&e); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -418,7 +418,7 @@ mod tests { }; let pool_config = PoolConfig { - oracle: Address::random(&e), + oracle: Address::generate(&e), bstop_rate: 0_100_000_000, status: 0, }; diff --git a/pool/src/pool/health_factor.rs b/pool/src/pool/health_factor.rs index 4b31e920..c2f5c37d 100644 --- a/pool/src/pool/health_factor.rs +++ b/pool/src/pool/health_factor.rs @@ -1,4 +1,4 @@ -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{panic_with_error, unwrap::UnwrapOptimized, Env}; use crate::{constants::SCALAR_7, errors::PoolError, storage}; @@ -122,7 +122,7 @@ mod tests { e.budget().reset_unlimited(); e.mock_all_auths(); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); @@ -172,9 +172,9 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { oracle, diff --git a/pool/src/pool/interest.rs b/pool/src/pool/interest.rs index 98741c26..4bb57743 100644 --- a/pool/src/pool/interest.rs +++ b/pool/src/pool/interest.rs @@ -1,5 +1,5 @@ use cast::i128; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{unwrap::UnwrapOptimized, Env}; use crate::{ @@ -142,9 +142,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_6565656, ir_mod, 0); @@ -177,9 +177,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_7979797, ir_mod, 0); @@ -212,9 +212,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_9696969, ir_mod, 0); @@ -247,9 +247,9 @@ mod tests { sequence_number: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (_accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_9696969, ir_mod, 0); @@ -281,9 +281,9 @@ mod tests { sequence_number: 10000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (_accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_2020202, ir_mod, 0); @@ -315,9 +315,9 @@ mod tests { sequence_number: 100, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let (accrual, ir_mod) = calc_accrual(&e, &reserve_config, 0_0500000, ir_mod, 500); diff --git a/pool/src/pool/pool.rs b/pool/src/pool/pool.rs index 230dbba9..682e1f08 100644 --- a/pool/src/pool/pool.rs +++ b/pool/src/pool/pool.rs @@ -132,14 +132,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -192,14 +192,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, reserve_data) = testutils::default_reserve_meta(); @@ -263,7 +263,7 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let pool_config = PoolConfig { oracle, bstop_rate: 0_200_000_000, @@ -282,7 +282,7 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let pool_config = PoolConfig { oracle, bstop_rate: 0_200_000_000, @@ -302,7 +302,7 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let pool_config = PoolConfig { oracle, bstop_rate: 0_200_000_000, @@ -322,7 +322,7 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let pool_config = PoolConfig { oracle, bstop_rate: 0_200_000_000, @@ -341,7 +341,7 @@ mod tests { let e = Env::default(); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let pool_config = PoolConfig { oracle, bstop_rate: 0_200_000_000, @@ -367,9 +367,9 @@ mod tests { let pool = testutils::create_pool(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); oracle_client.set_data( - &Address::random(&e), - &Asset::Stellar(Address::random(&e)), - &vec![&e, Asset::Stellar(Address::random(&e))], + &Address::generate(&e), + &Asset::Stellar(Address::generate(&e)), + &vec![&e, Asset::Stellar(Address::generate(&e))], &7, &300, ); @@ -392,10 +392,10 @@ mod tests { let e = Env::default(); e.mock_all_auths_allowing_non_root_auth(); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let asset_0 = Address::random(&e); - let asset_1 = Address::random(&e); + let asset_0 = Address::generate(&e); + let asset_1 = Address::generate(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); oracle_client.set_data( @@ -445,14 +445,14 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let asset = Address::random(&e); + let asset = Address::generate(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); oracle_client.set_data( &bombadil, diff --git a/pool/src/pool/reserve.rs b/pool/src/pool/reserve.rs index e67e82f7..6533a41c 100644 --- a/pool/src/pool/reserve.rs +++ b/pool/src/pool/reserve.rs @@ -1,6 +1,6 @@ use cast::i128; -use fixed_point_math::FixedPoint; use sep_41_token::TokenClient; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{contracttype, panic_with_error, unwrap::UnwrapOptimized, Address, Env}; use crate::{ @@ -248,14 +248,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, mut reserve_data) = testutils::default_reserve_meta(); @@ -296,14 +296,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, mut reserve_data) = testutils::default_reserve_meta(); @@ -344,14 +344,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, mut reserve_data) = testutils::default_reserve_meta(); @@ -392,14 +392,14 @@ mod tests { sequence_number: 123456, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); let pool = testutils::create_pool(&e); - let oracle = Address::random(&e); + let oracle = Address::generate(&e); let (underlying, _) = testutils::create_token_contract(&e, &bombadil); let (reserve_config, mut reserve_data) = testutils::default_reserve_meta(); diff --git a/pool/src/pool/status.rs b/pool/src/pool/status.rs index e08432f1..865f2d92 100644 --- a/pool/src/pool/status.rs +++ b/pool/src/pool/status.rs @@ -103,10 +103,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -150,10 +150,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -193,10 +193,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -240,10 +240,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -287,10 +287,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -335,10 +335,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); @@ -384,10 +384,10 @@ mod tests { 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 oracle_id = Address::generate(&e); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); let (blnd, blnd_client) = create_token_contract(&e, &bombadil); let (usdc, usdc_client) = create_token_contract(&e, &bombadil); diff --git a/pool/src/pool/submit.rs b/pool/src/pool/submit.rs index a3c49779..bd8464a8 100644 --- a/pool/src/pool/submit.rs +++ b/pool/src/pool/submit.rs @@ -79,15 +79,15 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); - let merry = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); + let merry = Address::generate(&e); let pool = testutils::create_pool(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); @@ -167,10 +167,10 @@ mod tests { let e = Env::default(); e.mock_all_auths(); - let bombadil = Address::random(&e); - let samwise = Address::random(&e); - let frodo = Address::random(&e); - let merry = Address::random(&e); + let bombadil = Address::generate(&e); + let samwise = Address::generate(&e); + let frodo = Address::generate(&e); + let merry = Address::generate(&e); let pool = testutils::create_pool(&e); let (oracle, oracle_client) = testutils::create_mock_oracle(&e); @@ -203,9 +203,9 @@ mod tests { sequence_number: 1234, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let pool_config = PoolConfig { oracle, diff --git a/pool/src/pool/user.rs b/pool/src/pool/user.rs index b23c92a0..d755ce2f 100644 --- a/pool/src/pool/user.rs +++ b/pool/src/pool/user.rs @@ -211,7 +211,7 @@ mod tests { use crate::{ storage, testutils, ReserveEmissionsConfig, ReserveEmissionsData, UserEmissionData, }; - use fixed_point_math::FixedPoint; + use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ map, testutils::{Address as _, Ledger, LedgerInfo}, @@ -220,7 +220,7 @@ mod tests { #[test] fn test_load_and_store() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let user = User { @@ -245,7 +245,7 @@ mod tests { #[test] fn test_liabilities() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -285,7 +285,7 @@ mod tests { #[test] fn test_add_liabilities_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -294,9 +294,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -354,7 +354,7 @@ mod tests { #[test] fn test_remove_liabilities_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -363,9 +363,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -422,7 +422,7 @@ mod tests { #[should_panic(expected = "Error(Contract, #4)")] fn test_remove_liabilities_over_balance_panics() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -441,7 +441,7 @@ mod tests { #[test] fn test_collateral() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -481,7 +481,7 @@ mod tests { #[test] fn test_add_collateral_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -490,9 +490,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -549,7 +549,7 @@ mod tests { #[test] fn test_remove_collateral_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -558,9 +558,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -618,7 +618,7 @@ mod tests { #[should_panic(expected = "Error(Contract, #4)")] fn test_remove_collateral_over_balance_panics() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -638,7 +638,7 @@ mod tests { #[test] fn test_supply() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -678,7 +678,7 @@ mod tests { #[test] fn test_add_supply_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -687,9 +687,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -746,7 +746,7 @@ mod tests { #[test] fn test_remove_supply_accrues_emissions() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); e.ledger().set(LedgerInfo { @@ -755,9 +755,9 @@ mod tests { timestamp: 10001000, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 10, - min_persistent_entry_expiration: 10, - max_entry_expiration: 2000000, + min_temp_entry_ttl: 10, + min_persistent_entry_ttl: 10, + max_entry_ttl: 2000000, }); let mut reserve_0 = testutils::default_reserve(&e); @@ -815,7 +815,7 @@ mod tests { #[should_panic(expected = "Error(Contract, #4)")] fn test_remove_supply_over_balance_panics() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); @@ -835,7 +835,7 @@ mod tests { #[test] fn test_total_supply() { let e = Env::default(); - let samwise = Address::random(&e); + let samwise = Address::generate(&e); let pool = testutils::create_pool(&e); let mut reserve_0 = testutils::default_reserve(&e); diff --git a/pool/src/storage.rs b/pool/src/storage.rs index e7901ab7..bf4e8ac1 100644 --- a/pool/src/storage.rs +++ b/pool/src/storage.rs @@ -135,10 +135,10 @@ pub enum PoolDataKey { /********** Storage **********/ /// Bump the instance rent for the contract -pub fn bump_instance(e: &Env) { +pub fn extend_instance(e: &Env) { e.storage() .instance() - .bump(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Fetch an entry in persistent storage that has a default value if it doesn't exist @@ -152,7 +152,7 @@ fn get_persistent_default, V: TryFromVal>( if let Some(result) = e.storage().persistent().get::(key) { e.storage() .persistent() - .bump(key, bump_threshold, bump_amount); + .extend_ttl(key, bump_threshold, bump_amount); result } else { default @@ -188,7 +188,7 @@ pub fn set_user_positions(e: &Env, user: &Address, positions: &Positions) { .set::(&key, positions); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_USER, LEDGER_BUMP_USER); + .extend_ttl(&key, LEDGER_THRESHOLD_USER, LEDGER_BUMP_USER); } /********** Admin **********/ @@ -328,7 +328,7 @@ pub fn get_res_config(e: &Env, asset: &Address) -> ReserveConfig { let key = PoolDataKey::ResConfig(asset.clone()); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); e.storage() .persistent() .get::(&key) @@ -347,7 +347,7 @@ pub fn set_res_config(e: &Env, asset: &Address, config: &ReserveConfig) { .set::(&key, config); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Checks if a reserve exists for an asset @@ -372,7 +372,7 @@ pub fn get_res_data(e: &Env, asset: &Address) -> ReserveData { let key = PoolDataKey::ResData(asset.clone()); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); e.storage() .persistent() .get::(&key) @@ -391,7 +391,7 @@ pub fn set_res_data(e: &Env, asset: &Address, data: &ReserveData) { .set::(&key, data); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /********** Reserve List (ResList) **********/ @@ -426,7 +426,7 @@ pub fn push_res_list(e: &Env, asset: &Address) -> u32 { e.storage() .persistent() .set::>(&Symbol::new(e, RES_LIST_KEY), &res_list); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, RES_LIST_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -467,7 +467,7 @@ pub fn set_res_emis_config( .set::(&key, res_emis_config); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Fetch the emission data for the reserve b or d token @@ -497,7 +497,7 @@ pub fn set_res_emis_data(e: &Env, res_token_index: &u32, res_emis_data: &Reserve .set::(&key, res_emis_data); e.storage() .persistent() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /********** User Emissions **********/ @@ -563,7 +563,7 @@ pub fn set_pool_emissions(e: &Env, emissions: &Map) { e.storage() .persistent() .set::>(&Symbol::new(e, POOL_EMIS_KEY), emissions); - e.storage().persistent().bump( + e.storage().persistent().extend_ttl( &Symbol::new(e, POOL_EMIS_KEY), LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED, @@ -620,7 +620,7 @@ pub fn set_auction(e: &Env, auction_type: &u32, user: &Address, auction_data: &A .set::(&key, auction_data); e.storage() .temporary() - .bump(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); + .extend_ttl(&key, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED); } /// Remove an auction diff --git a/pool/src/testutils.rs b/pool/src/testutils.rs index d40da87c..db27867b 100644 --- a/pool/src/testutils.rs +++ b/pool/src/testutils.rs @@ -7,9 +7,9 @@ use crate::{ PoolContract, }; use emitter::{EmitterClient, EmitterContract}; -use fixed_point_math::FixedPoint; use sep_40_oracle::testutils::{MockPriceOracleClient, MockPriceOracleWASM}; use sep_41_token::testutils::{MockTokenClient, MockTokenWASM}; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ map, testutils::Address as _, unwrap::UnwrapOptimized, vec, Address, Env, IntoVal, }; @@ -31,7 +31,7 @@ pub(crate) fn create_token_contract<'a>( e: &Env, admin: &Address, ) -> (Address, MockTokenClient<'a>) { - let contract_address = Address::random(e); + let contract_address = Address::generate(e); e.register_contract_wasm(&contract_address, MockTokenWASM); let client = MockTokenClient::new(e, &contract_address); client.initialize(admin, &7, &"unit".into_val(e), &"test".into_val(e)); @@ -149,7 +149,7 @@ pub(crate) fn create_comet_lp_pool<'a>( blnd_token: &Address, usdc_token: &Address, ) -> (Address, comet::Client<'a>) { - let contract_address = Address::random(e); + let contract_address = Address::generate(e); e.register_contract_wasm(&contract_address, comet::WASM); let client = comet::Client::new(e, &contract_address); @@ -161,7 +161,7 @@ pub(crate) fn create_comet_lp_pool<'a>( 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.init(&Address::generate(e), &admin); client.bundle_bind( &vec![e, blnd_token.clone(), usdc_token.clone()], &vec![e, 1_000_0000000, 25_0000000], @@ -183,7 +183,7 @@ pub(crate) fn create_comet_lp_pool<'a>( pub(crate) fn default_reserve(e: &Env) -> Reserve { Reserve { - asset: Address::random(e), + asset: Address::generate(e), index: 0, l_factor: 0_7500000, c_factor: 0_7500000, diff --git a/test-suites/Cargo.toml b/test-suites/Cargo.toml index dcd39dee..769426b1 100644 --- a/test-suites/Cargo.toml +++ b/test-suites/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] soroban-sdk = { workspace = true, features = ["testutils"] } rand = { version = "0.7.3" } -fixed-point-math = { workspace = true } +soroban-fixed-point-math = { workspace = true } pool = { path = "../pool", features = ["testutils"] } backstop = { path = "../backstop", features = ["testutils"] } pool-factory = { path = "../pool-factory", features = ["testutils"] } diff --git a/test-suites/fuzz/fuzz_targets/fuzz_pool_general.rs b/test-suites/fuzz/fuzz_targets/fuzz_pool_general.rs index 7952c18d..9bae2005 100644 --- a/test-suites/fuzz/fuzz_targets/fuzz_pool_general.rs +++ b/test-suites/fuzz/fuzz_targets/fuzz_pool_general.rs @@ -1,7 +1,7 @@ #![allow(unused)] #![no_main] -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use fuzz_common::{ verify_contract_result, Borrow, ClaimPool, NatI128, PassTime, Repay, Supply, Withdraw, }; @@ -51,9 +51,9 @@ fuzz_target!(|input: Input| { let mut fixture = create_fixture_with_data(false); // Create two new users - let sam = Address::random(&fixture.env); + let sam = Address::generate(&fixture.env); fixture.users.push(sam.clone()); - let merry = Address::random(&fixture.env); + let merry = Address::generate(&fixture.env); fixture.users.push(merry.clone()); // Mint users tokens diff --git a/test-suites/fuzz/lib.rs b/test-suites/fuzz/lib.rs index 3cd48d64..18de93d0 100644 --- a/test-suites/fuzz/lib.rs +++ b/test-suites/fuzz/lib.rs @@ -2,7 +2,7 @@ #![allow(unused)] #![no_main] -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use lending_pool::{PoolState, PositionData, Request}; use libfuzzer_sys::fuzz_target; use soroban_sdk::arbitrary::arbitrary::{self, Arbitrary, Unstructured}; diff --git a/test-suites/src/assertions.rs b/test-suites/src/assertions.rs index 63f192d6..718a8ccb 100644 --- a/test-suites/src/assertions.rs +++ b/test-suites/src/assertions.rs @@ -1,5 +1,5 @@ use crate::test_fixture::SCALAR_7; -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; pub fn assert_approx_eq_abs(a: i128, b: i128, delta: i128) { assert!( diff --git a/test-suites/src/backstop.rs b/test-suites/src/backstop.rs index ee40b1f4..6515285e 100644 --- a/test-suites/src/backstop.rs +++ b/test-suites/src/backstop.rs @@ -6,7 +6,7 @@ mod backstop_contract_wasm { use backstop::{BackstopClient, BackstopContract}; pub fn create_backstop<'a>(e: &Env, wasm: bool) -> (Address, BackstopClient<'a>) { - let contract_id = Address::random(e); + let contract_id = Address::generate(e); if wasm { e.register_contract_wasm(&contract_id, backstop_contract_wasm::WASM); } else { diff --git a/test-suites/src/emitter.rs b/test-suites/src/emitter.rs index 54d4246a..3d6effaa 100644 --- a/test-suites/src/emitter.rs +++ b/test-suites/src/emitter.rs @@ -7,7 +7,7 @@ mod emitter_contract { use emitter::{EmitterClient, EmitterContract}; pub fn create_emitter<'a>(e: &Env, wasm: bool) -> (Address, EmitterClient<'a>) { - let contract_id = Address::random(e); + let contract_id = Address::generate(e); if wasm { e.register_contract_wasm(&contract_id, emitter_contract::WASM); } else { diff --git a/test-suites/src/liquidity_pool.rs b/test-suites/src/liquidity_pool.rs index ba078a2e..9fcbe8b8 100644 --- a/test-suites/src/liquidity_pool.rs +++ b/test-suites/src/liquidity_pool.rs @@ -22,7 +22,7 @@ pub(crate) fn create_lp_pool<'a>( token_1: &Address, token_2: &Address, ) -> (Address, LPClient<'a>) { - let contract_address = Address::random(e); + let contract_address = Address::generate(e); e.register_contract_wasm(&contract_address, LP_WASM); let client = LPClient::new(e, &contract_address); @@ -33,7 +33,7 @@ pub(crate) fn create_lp_pool<'a>( token_1_client.approve(&admin, &contract_address, &1_000_0000000, &5356700); token_2_client.approve(&admin, &contract_address, &1_000_0000000, &5356700); - client.init(&Address::random(e), &admin); + client.init(&Address::generate(e), &admin); client.bundle_bind( &vec![e, token_1.clone(), token_2.clone()], &vec![e, 1_000_0000000, 25_0000000], diff --git a/test-suites/src/oracle.rs b/test-suites/src/oracle.rs index 15a760c9..f9b43814 100644 --- a/test-suites/src/oracle.rs +++ b/test-suites/src/oracle.rs @@ -3,7 +3,7 @@ use soroban_sdk::{testutils::Address as _, Address, Env}; use sep_40_oracle::testutils::{MockPriceOracleClient, MockPriceOracleWASM}; pub fn create_mock_oracle<'a>(e: &Env) -> (Address, MockPriceOracleClient<'a>) { - let contract_id = Address::random(e); + let contract_id = Address::generate(e); e.register_contract_wasm(&contract_id, MockPriceOracleWASM); ( contract_id.clone(), diff --git a/test-suites/src/pool_factory.rs b/test-suites/src/pool_factory.rs index cf0cccfa..c90d05fb 100644 --- a/test-suites/src/pool_factory.rs +++ b/test-suites/src/pool_factory.rs @@ -10,7 +10,7 @@ use pool_factory::PoolFactoryClient; use mock_pool_factory::MockPoolFactory; pub fn create_pool_factory<'a>(e: &Env, wasm: bool) -> (Address, PoolFactoryClient<'a>) { - let contract_id = Address::random(e); + let contract_id = Address::generate(e); if wasm { e.register_contract_wasm(&contract_id, pool_factory_contract::WASM); } else { diff --git a/test-suites/src/setup.rs b/test-suites/src/setup.rs index 2141266c..9c012c06 100644 --- a/test-suites/src/setup.rs +++ b/test-suites/src/setup.rs @@ -52,7 +52,7 @@ pub fn create_fixture_with_data<'a>(wasm: bool) -> TestFixture<'a> { pool_fixture.pool.set_emissions_config(&reserve_emissions); // mint whale tokens - let frodo = Address::random(&fixture.env); + let frodo = Address::generate(&fixture.env); fixture.users.push(frodo.clone()); fixture.tokens[TokenIndex::STABLE].mint(&frodo, &(100_000 * 10i128.pow(6))); fixture.tokens[TokenIndex::XLM].mint(&frodo, &(1_000_000 * SCALAR_7)); @@ -80,7 +80,7 @@ pub fn create_fixture_with_data<'a>(wasm: bool) -> TestFixture<'a> { fixture.backstop.update_tkn_val(); fixture .backstop - .add_reward(&pool_fixture.pool.address, &Address::random(&fixture.env)); + .add_reward(&pool_fixture.pool.address, &Address::generate(&fixture.env)); pool_fixture.pool.update_status(); // enable emissions diff --git a/test-suites/src/test_fixture.rs b/test-suites/src/test_fixture.rs index a3a6d17e..f53fef33 100644 --- a/test-suites/src/test_fixture.rs +++ b/test-suites/src/test_fixture.rs @@ -68,7 +68,7 @@ impl TestFixture<'_> { e.mock_all_auths(); e.budget().reset_unlimited(); - let bombadil = Address::random(&e); + let bombadil = Address::generate(&e); e.ledger().set(LedgerInfo { timestamp: 1441065600, // Sept 1st, 2015 (backstop epoch) @@ -76,9 +76,9 @@ impl TestFixture<'_> { sequence_number: 150, network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 999999, - min_persistent_entry_expiration: 999999, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 500000, + min_persistent_entry_ttl: 500000, + max_entry_ttl: 9999999, }); // deploy tokens @@ -281,9 +281,9 @@ impl TestFixture<'_> { sequence_number: self.env.ledger().sequence(), network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 999999, - min_persistent_entry_expiration: 999999, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 999999, + min_persistent_entry_ttl: 999999, + max_entry_ttl: 9999999, }); } @@ -295,9 +295,9 @@ impl TestFixture<'_> { sequence_number: self.env.ledger().sequence().saturating_add(blocks as u32), network_id: Default::default(), base_reserve: 10, - min_temp_entry_expiration: 999999, - min_persistent_entry_expiration: 999999, - max_entry_expiration: u32::MAX, + min_temp_entry_ttl: 999999, + min_persistent_entry_ttl: 999999, + max_entry_ttl: 9999999, }); } } diff --git a/test-suites/src/token.rs b/test-suites/src/token.rs index 8984d809..f4382c94 100644 --- a/test-suites/src/token.rs +++ b/test-suites/src/token.rs @@ -15,7 +15,7 @@ pub fn create_token<'a>( decimals: u32, symbol: &str, ) -> (Address, MockTokenClient<'a>) { - let contract_id = Address::random(e); + let contract_id = Address::generate(e); e.register_contract_wasm(&contract_id, MockTokenWASM); let client = MockTokenClient::new(e, &contract_id); client.initialize( diff --git a/test-suites/tests/test_backstop.rs b/test-suites/tests/test_backstop.rs index 4f7f9df1..427fa1c8 100644 --- a/test-suites/tests/test_backstop.rs +++ b/test-suites/tests/test_backstop.rs @@ -1,6 +1,6 @@ #![cfg(test)] -use fixed_point_math::FixedPoint; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation, Events}, vec, Address, IntoVal, Map, Symbol, Val, Vec, @@ -20,15 +20,15 @@ fn test_backstop() { let pool = &fixture.pools[0].pool; let bstop_token = &fixture.lp; - let sam = Address::random(&fixture.env); + let sam = Address::generate(&fixture.env); // Verify initialization can't be re-run let result = fixture.backstop.try_initialize( - &Address::random(&fixture.env), - &Address::random(&fixture.env), - &Address::random(&fixture.env), - &Address::random(&fixture.env), - &Address::random(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), &Map::new(&fixture.env), ); assert!(result.is_err()); diff --git a/test-suites/tests/test_emitter.rs b/test-suites/tests/test_emitter.rs index 6387c58c..766e5334 100644 --- a/test-suites/tests/test_emitter.rs +++ b/test-suites/tests/test_emitter.rs @@ -24,9 +24,9 @@ fn test_emitter() { // Verify initialization can't be re-run let result = fixture.emitter.try_initialize( - &Address::random(&fixture.env), - &Address::random(&fixture.env), - &Address::random(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), ); assert!(result.is_err()); assert_eq!( @@ -69,7 +69,7 @@ fn test_emitter() { // Mint enough tokens to a new backstop address to perform a swap, then queue the swap let old_backstop_balance = bstop_token.balance(&fixture.backstop.address); - let new_backstop = Address::random(&fixture.env); + let new_backstop = Address::generate(&fixture.env); fixture.tokens[TokenIndex::BLND].mint(&new_backstop, &(600_001 * SCALAR_7)); fixture.tokens[TokenIndex::USDC].mint(&new_backstop, &(20_501 * SCALAR_7)); fixture.lp.join_pool( diff --git a/test-suites/tests/test_liquidation.rs b/test-suites/tests/test_liquidation.rs index 3ca6c6b1..705f2720 100644 --- a/test-suites/tests/test_liquidation.rs +++ b/test-suites/tests/test_liquidation.rs @@ -1,7 +1,7 @@ #![cfg(test)] use cast::i128; -use fixed_point_math::FixedPoint; use pool::{PoolDataKey, Positions, Request, ReserveConfig, ReserveData}; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ testutils::{Address as AddressTestTrait, Events}, vec, Address, Error, IntoVal, Symbol, Val, Vec, @@ -36,7 +36,7 @@ fn test_liquidations() { .update_reserve(&fixture.tokens[TokenIndex::WETH].address, &weth_config); // Create a user - let samwise = Address::random(&fixture.env); //sam will be supplying XLM and borrowing STABLE + let samwise = Address::generate(&fixture.env); //sam will be supplying XLM and borrowing STABLE // Mint users tokens fixture.tokens[TokenIndex::XLM].mint(&samwise, &(500_000 * SCALAR_7)); @@ -938,7 +938,7 @@ fn test_user_restore_position_and_delete_liquidation() { let xlm_pool_index = pool_fixture.reserves[&TokenIndex::XLM]; // Create a user that is supply STABLE (cf = 90%, $1) and borrowing XLM (lf = 75%, $0.10) - let samwise = Address::random(&fixture.env); + let samwise = Address::generate(&fixture.env); fixture.tokens[TokenIndex::STABLE].mint(&samwise, &(1100 * 10i128.pow(6))); // deposit $1k stable and borrow to 90% borrow limit ($810) @@ -978,7 +978,7 @@ fn test_user_restore_position_and_delete_liquidation() { &fixture.env, Request { request_type: 9, - address: Address::random(&fixture.env), + address: Address::generate(&fixture.env), amount: i128::MAX, }, ]; @@ -998,7 +998,7 @@ fn test_user_restore_position_and_delete_liquidation() { }, Request { request_type: 9, - address: Address::random(&fixture.env), + address: Address::generate(&fixture.env), amount: i128::MAX, }, ]; @@ -1015,7 +1015,7 @@ fn test_user_restore_position_and_delete_liquidation() { &fixture.env, Request { request_type: 9, - address: Address::random(&fixture.env), + address: Address::generate(&fixture.env), amount: i128::MAX, }, Request { @@ -1043,7 +1043,7 @@ fn test_user_restore_position_and_delete_liquidation() { }, Request { request_type: 9, - address: Address::random(&fixture.env), + address: Address::generate(&fixture.env), amount: i128::MAX, }, Request { diff --git a/test-suites/tests/test_pool.rs b/test-suites/tests/test_pool.rs index e2a46440..3fe00764 100644 --- a/test-suites/tests/test_pool.rs +++ b/test-suites/tests/test_pool.rs @@ -1,7 +1,7 @@ #![cfg(test)] -use fixed_point_math::FixedPoint; use pool::{Request, ReserveEmissionMetadata}; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{ testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation, Events}, vec, Address, IntoVal, Symbol, Val, @@ -25,7 +25,7 @@ fn test_pool_user() { let weth = &fixture.tokens[TokenIndex::WETH]; let weth_scalar: i128 = 10i128.pow(weth.decimals()); - let sam = Address::random(&fixture.env); + let sam = Address::generate(&fixture.env); // Mint sam tokens let mut sam_xlm_balance = 10_000 * SCALAR_7; @@ -541,13 +541,13 @@ fn test_pool_config() { // Verify initialize can't be run again let result = pool_fixture.pool.try_initialize( - &Address::random(&fixture.env), + &Address::generate(&fixture.env), &Symbol::new(&fixture.env, "teapot"), - &Address::random(&fixture.env), + &Address::generate(&fixture.env), &10000, - &Address::random(&fixture.env), - &Address::random(&fixture.env), - &Address::random(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), + &Address::generate(&fixture.env), ); assert!(result.is_err()); @@ -683,7 +683,7 @@ fn test_pool_config() { ); // Set admin (admin only) - let new_admin = Address::random(&fixture.env); + let new_admin = Address::generate(&fixture.env); pool_fixture.pool.set_admin(&new_admin); assert_eq!( fixture.env.auths()[0], diff --git a/test-suites/tests/test_wasm_happy_path.rs b/test-suites/tests/test_wasm_happy_path.rs index df6256fb..8897951e 100644 --- a/test-suites/tests/test_wasm_happy_path.rs +++ b/test-suites/tests/test_wasm_happy_path.rs @@ -1,7 +1,7 @@ #![cfg(test)] -use fixed_point_math::FixedPoint; use pool::Request; +use soroban_fixed_point_math::FixedPoint; use soroban_sdk::{testutils::Address as _, vec, Address}; use test_suites::{ assertions::assert_approx_eq_abs, @@ -19,8 +19,8 @@ fn test_wasm_happy_path() { let xlm_pool_index = pool_fixture.reserves[&TokenIndex::XLM]; // Create two new users - let sam = Address::random(&fixture.env); // sam will be supplying XLM and borrowing STABLE - let merry = Address::random(&fixture.env); // merry will be supplying STABLE and borrowing XLM + let sam = Address::generate(&fixture.env); // sam will be supplying XLM and borrowing STABLE + let merry = Address::generate(&fixture.env); // merry will be supplying STABLE and borrowing XLM // Mint users tokens let stable = &fixture.tokens[TokenIndex::STABLE];