Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update oracle interface #138

Merged
merged 7 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions Cargo.lock

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

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ members = [
"blend-interfaces",
"emitter",
"pool",
"mocks/mock-oracle",
"mocks/mock-pool",
"mocks/mock-pool-factory",
"oracle",
"pool-factory",
"test-suites"
]
Expand Down Expand Up @@ -37,3 +34,12 @@ version = "0.0.2"
[workspace.dependencies.cast]
version = "0.3.0"
default-features = false

[workspace.dependencies.sep-40-oracle]
version = "0.1.1"

[workspace.dependencies.sep-41-token]
version = "0.2.1"

[workspace.dependencies.blend-interfaces]
path = "./blend-interfaces"
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ test: build
cargo test --all --tests

build:
cargo rustc --manifest-path=mocks/mock-pool/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path=mocks/mock-oracle/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path=pool-factory/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path=backstop/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path=emitter/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
Expand Down
2 changes: 2 additions & 0 deletions backstop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ testutils = [
soroban-sdk = { workspace = true }
fixed-point-math = { workspace = true }
cast = { workspace = true }
sep-41-token = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
mock-pool-factory = { path = "../mocks/mock-pool-factory", features = ["testutils"] }
sep-41-token = { workspace = true, features = ["testutils"] }
5 changes: 3 additions & 2 deletions backstop/src/backstop/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{contract::require_nonnegative, dependencies::TokenClient, emissions, storage};
use crate::{contract::require_nonnegative, emissions, storage};
use sep_41_token::TokenClient;
use soroban_sdk::{Address, Env};

/// Perform a deposit into the backstop module
Expand Down Expand Up @@ -87,7 +88,7 @@ mod tests {
}

#[test]
#[should_panic(expected = "Error(WasmVm, InvalidAction)")]
#[should_panic]
fn test_execute_deposit_too_many_tokens() {
let e = Env::default();
e.mock_all_auths_allowing_non_root_auth();
Expand Down
6 changes: 2 additions & 4 deletions backstop/src/backstop/fund_management.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::{
constants::SCALAR_7,
contract::require_nonnegative,
dependencies::{CometClient, TokenClient},
storage,
constants::SCALAR_7, contract::require_nonnegative, dependencies::CometClient, storage,
};
use fixed_point_math::FixedPoint;
use sep_41_token::TokenClient;
use soroban_sdk::{unwrap::UnwrapOptimized, Address, Env};

use super::require_is_from_pool_factory;
Expand Down
8 changes: 2 additions & 6 deletions backstop/src/backstop/withdrawal.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use crate::{
contract::require_nonnegative,
dependencies::TokenClient,
emissions::{self},
storage,
};
use crate::{contract::require_nonnegative, emissions, storage};
use sep_41_token::TokenClient;
use soroban_sdk::{unwrap::UnwrapOptimized, Address, Env};

use super::Q4W;
Expand Down
5 changes: 0 additions & 5 deletions backstop/src/dependencies/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
mod token;
pub use token::Client as TokenClient;
#[cfg(any(test, feature = "testutils"))]
pub use token::WASM as TOKEN_WASM;

mod pool_factory;
pub use pool_factory::Client as PoolFactoryClient;

Expand Down
3 changes: 0 additions & 3 deletions backstop/src/dependencies/token.rs

This file was deleted.

3 changes: 2 additions & 1 deletion backstop/src/emissions/claim.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{dependencies::TokenClient, errors::BackstopError, storage};
use crate::{errors::BackstopError, storage};
use sep_41_token::TokenClient;
use soroban_sdk::{panic_with_error, Address, Env, Vec};

use super::update_emissions;
Expand Down
2 changes: 1 addition & 1 deletion backstop/src/emissions/manager.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cast::{i128, u64};
use fixed_point_math::FixedPoint;
use sep_41_token::TokenClient;
use soroban_sdk::{panic_with_error, unwrap::UnwrapOptimized, vec, Address, Env, Vec};

use crate::{
constants::{BACKSTOP_EPOCH, SCALAR_7},
dependencies::TokenClient,
errors::BackstopError,
storage::{self, BackstopEmissionConfig, BackstopEmissionsData},
};
Expand Down
20 changes: 11 additions & 9 deletions backstop/src/testutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
backstop::Q4W,
dependencies::{CometClient, TokenClient, COMET_WASM, TOKEN_WASM},
dependencies::{CometClient, COMET_WASM},
storage::{self},
BackstopContract,
};
Expand All @@ -11,16 +11,18 @@ use soroban_sdk::{
testutils::Address as _, unwrap::UnwrapOptimized, vec, Address, Env, IntoVal, Vec,
};

use sep_41_token::testutils::{MockTokenClient, MockTokenWASM};

use mock_pool_factory::{MockPoolFactory, MockPoolFactoryClient};

pub(crate) fn create_backstop(e: &Env) -> Address {
e.register_contract(None, BackstopContract {})
}

pub(crate) fn create_token<'a>(e: &Env, admin: &Address) -> (Address, TokenClient<'a>) {
pub(crate) fn create_token<'a>(e: &Env, admin: &Address) -> (Address, MockTokenClient<'a>) {
let contract_address = Address::random(e);
e.register_contract_wasm(&contract_address, TOKEN_WASM);
let client = TokenClient::new(e, &contract_address);
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));
(contract_address, client)
}
Expand All @@ -29,7 +31,7 @@ pub(crate) fn create_blnd_token<'a>(
e: &Env,
backstop: &Address,
admin: &Address,
) -> (Address, TokenClient<'a>) {
) -> (Address, MockTokenClient<'a>) {
let (contract_address, client) = create_token(e, admin);

e.as_contract(backstop, || {
Expand All @@ -42,7 +44,7 @@ pub(crate) fn create_usdc_token<'a>(
e: &Env,
backstop: &Address,
admin: &Address,
) -> (Address, TokenClient<'a>) {
) -> (Address, MockTokenClient<'a>) {
let (contract_address, client) = create_token(e, admin);

e.as_contract(backstop, || {
Expand All @@ -55,7 +57,7 @@ pub(crate) fn create_backstop_token<'a>(
e: &Env,
backstop: &Address,
admin: &Address,
) -> (Address, TokenClient<'a>) {
) -> (Address, MockTokenClient<'a>) {
let (contract_address, client) = create_token(e, admin);

e.as_contract(backstop, || {
Expand Down Expand Up @@ -95,8 +97,8 @@ pub(crate) fn create_comet_lp_pool<'a>(
e.register_contract_wasm(&contract_address, COMET_WASM);
let client = CometClient::new(e, &contract_address);

let blnd_client = TokenClient::new(e, blnd_token);
let usdc_client = TokenClient::new(e, usdc_token);
let blnd_client = MockTokenClient::new(e, blnd_token);
let usdc_client = MockTokenClient::new(e, usdc_token);
blnd_client.mint(&admin, &1_000_0000000);
usdc_client.mint(&admin, &25_0000000);
let exp_ledger = e.ledger().sequence() + 100;
Expand Down
2 changes: 1 addition & 1 deletion blend-interfaces/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blend-interfaces"
version = "0.0.1"
version = "0.0.2"
description = "Traits, clients, and types for the Blend Protocol"
homepage = "https://github.com/blend-capital/blend-contracts"
repository = "https://github.com/blend-capital/blend-contracts"
Expand Down
2 changes: 2 additions & 0 deletions blend-interfaces/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

pub mod backstop;
pub mod emitter;
pub mod pool;
Expand Down
2 changes: 2 additions & 0 deletions emitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = { workspace = true }
sep-41-token = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
backstop = { path = "../backstop", features = ["testutils"] }
sep-41-token = { workspace = true, features = ["testutils"] }
5 changes: 0 additions & 5 deletions emitter/src/dependencies/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
mod token;
pub use token::Client as TokenClient;
#[cfg(any(test, feature = "testutils"))]
pub use token::WASM as TOKEN_WASM;

mod backstop;
pub use backstop::Client as BackstopClient;
#[cfg(any(test, feature = "testutils"))]
Expand Down
3 changes: 0 additions & 3 deletions emitter/src/dependencies/token.rs

This file was deleted.

Loading