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

Add stellar expert release #224

Closed
wants to merge 3 commits into from
Closed
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
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Stellar Expert WASM Release
on:
push:
tags:
- 'v*' # triggered whenever a new tag (previxed with "v") is pushed to the repository
jobs:
release-contract-backstop:
uses: stellar-expert/soroban-build-workflow/.github/workflows/release.yml@main
with:
release_name: ${{ github.ref_name }}
release_description: 'Blend Backstop Release'
package: 'backstop'
make_target: 'build'
secrets:
release_token: ${{ secrets.GITHUB_TOKEN }}

release-contract-pool:
uses: stellar-expert/soroban-build-workflow/.github/workflows/release.yml@main
with:
release_name: ${{ github.ref_name }}
release_description: 'Blend Pool Release'
package: 'pool'
make_target: 'build'
secrets:
release_token: ${{ secrets.GITHUB_TOKEN }}

release-contract-emitter:
uses: stellar-expert/soroban-build-workflow/.github/workflows/release.yml@main
with:
release_name: ${{ github.ref_name }}
release_description: 'Blend Emitter Release'
package: 'emitter'
secrets:
release_token: ${{ secrets.GITHUB_TOKEN }}

release-contract-pool-factory:
uses: stellar-expert/soroban-build-workflow/.github/workflows/release.yml@main
with:
release_name: ${{ github.ref_name }}
release_description: 'Blend Pool Factory Release'
package: 'pool-factory'
make_target: 'build'
secrets:
release_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Cargo.lock

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

54 changes: 27 additions & 27 deletions backstop/src/emissions/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ mod tests {
assert_eq!(result, 75_3145677 + 6_2904190);
assert_eq!(
lp_client.balance(&backstop_address),
backstop_lp_balance + 6_5244800
backstop_lp_balance + 6_4729326
);
assert_eq!(
blnd_token_client.balance(&backstop_address),
Expand All @@ -221,18 +221,18 @@ mod tests {
let sam_balance_1 = storage::get_user_balance(&e, &pool_1_id, &samwise);
assert_eq!(sam_balance_1.shares, 9_0000000);
let frodo_balance_1 = storage::get_user_balance(&e, &pool_1_id, &frodo);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_5761820);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_5400274);
let sam_balance_2 = storage::get_user_balance(&e, &pool_2_id, &samwise);
assert_eq!(sam_balance_2.shares, 7_5000000);
let frodo_balance_2 = storage::get_user_balance(&e, &pool_2_id, &frodo);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 0_3947102);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 0_3915917);

let pool_balance_1 = storage::get_pool_balance(&e, &pool_1_id);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 6_1015761);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_5761820);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 6_0533699);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_5400274);
let pool_balance_2 = storage::get_pool_balance(&e, &pool_2_id);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 0_4229038);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 0_3947102);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 0_4195626);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 0_3915917);

let new_backstop_1_data =
storage::get_backstop_emis_data(&e, &pool_1_id).unwrap_optimized();
Expand Down Expand Up @@ -371,7 +371,7 @@ mod tests {
assert_eq!(result, 75_3145677 + 6_2904190);
assert_eq!(
lp_client.balance(&backstop_address),
backstop_lp_balance + 6_5244800
backstop_lp_balance + 6_4729326
);
assert_eq!(
blnd_token_client.balance(&backstop_address),
Expand All @@ -380,18 +380,18 @@ mod tests {
let sam_balance_1 = storage::get_user_balance(&e, &pool_1_id, &samwise);
assert_eq!(sam_balance_1.shares, 9_0000000);
let frodo_balance_1 = storage::get_user_balance(&e, &pool_1_id, &frodo);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_5761820);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_5400274);
let sam_balance_2 = storage::get_user_balance(&e, &pool_2_id, &samwise);
assert_eq!(sam_balance_2.shares, 7_5000000);
let frodo_balance_2 = storage::get_user_balance(&e, &pool_2_id, &frodo);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 0_3947102);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 0_3915917);

let pool_balance_1 = storage::get_pool_balance(&e, &pool_1_id);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 6_1015761);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_5761820);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 6_0533699);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_5400274);
let pool_balance_2 = storage::get_pool_balance(&e, &pool_2_id);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 0_4229038);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 0_3947102);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 0_4195626);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 0_3915917);

let new_backstop_1_data =
storage::get_backstop_emis_data(&e, &pool_1_id).unwrap_optimized();
Expand Down Expand Up @@ -435,47 +435,47 @@ mod tests {
&vec![&e, pool_1_id.clone(), pool_2_id.clone()],
&frodo,
);
assert_eq!(result_1, 1005009202);
assert_eq!(result_1, 1005194703);
assert_eq!(
blnd_token_client.balance(&backstop_address),
200_0000000 - (75_3145677 + 6_2904190) - (1005009202)
200_0000000 - (75_3145677 + 6_2904190) - (1005194703)
);
assert_eq!(
lp_client.balance(&backstop_address),
backstop_lp_balance + 7_9137036
backstop_lp_balance + 7_7889107
);
let sam_balance_1 = storage::get_user_balance(&e, &pool_1_id, &samwise);
assert_eq!(sam_balance_1.shares, 9_0000000);
let frodo_balance_1 = storage::get_user_balance(&e, &pool_1_id, &frodo);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_3004891);
assert_eq!(frodo_balance_1.shares, pre_frodo_balance_1 + 4_2609092);
let sam_balance_2 = storage::get_user_balance(&e, &pool_2_id, &samwise);
assert_eq!(sam_balance_2.shares, 7_5000000);
let frodo_balance_2 = storage::get_user_balance(&e, &pool_2_id, &frodo);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 2_0344033);
assert_eq!(frodo_balance_2.shares, pre_frodo_balance_2 + 2_0152958);

let pool_balance_1 = storage::get_pool_balance(&e, &pool_1_id);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 5_7339856);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_3004891);
assert_eq!(pool_balance_1.tokens, pre_pool_tokens_1 + 5_6812124);
assert_eq!(pool_balance_1.shares, pre_pool_shares_1 + 4_2609092);
let pool_balance_2 = storage::get_pool_balance(&e, &pool_2_id);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 2_1797179);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 2_0344033);
assert_eq!(pool_balance_2.tokens, pre_pool_tokens_2 + 2_1592456);
assert_eq!(pool_balance_2.shares, pre_pool_shares_2 + 2_0152958);
let new_backstop_1_data =
storage::get_backstop_emis_data(&e, &pool_1_id).unwrap_optimized();
let new_user_1_data =
storage::get_user_emis_data(&e, &pool_1_id, &samwise).unwrap_optimized();
assert_eq!(new_backstop_1_data.last_time, block_timestamp_1);
assert_eq!(new_backstop_1_data.index, 164344784);
assert_eq!(new_backstop_1_data.index, 164363961);
assert_eq!(new_user_1_data.accrued, 0);
assert_eq!(new_user_1_data.index, 164344784);
assert_eq!(new_user_1_data.index, 164363961);

let new_backstop_2_data =
storage::get_backstop_emis_data(&e, &pool_2_id).unwrap_optimized();
let new_user_2_data =
storage::get_user_emis_data(&e, &pool_2_id, &samwise).unwrap_optimized();
assert_eq!(new_backstop_2_data.last_time, block_timestamp_1);
assert_eq!(new_backstop_2_data.index, 43961378);
assert_eq!(new_backstop_2_data.index, 43963099);
assert_eq!(new_user_2_data.accrued, 0);
assert_eq!(new_user_2_data.index, 43961378);
assert_eq!(new_user_2_data.index, 43963099);
});
}

Expand Down
14 changes: 4 additions & 10 deletions backstop/src/testutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,15 @@ pub(crate) fn create_comet_lp_pool<'a>(
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;
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::generate(e), &admin);
client.bundle_bind(
client.init(
admin,
&vec![e, blnd_token.clone(), usdc_token.clone()],
&vec![e, 0_8000000, 0_2000000],
&vec![e, 1_000_0000000, 25_0000000],
&vec![e, 8_0000000, 2_0000000],
&0_0030000,
);

client.set_swap_fee(&0_0030000, &admin);
client.set_public_swap(&admin, &true);
client.finalize();

(contract_address, client)
}

Expand Down
2 changes: 1 addition & 1 deletion blend-contract-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blend-contract-sdk"
version = "0.2.0"
version = "0.3.0"
description = "Traits, clients, types, and WASMs for the Blend Protocol for use in Soroban contract development."
homepage = "https://github.com/blend-capital/blend-contracts"
repository = "https://github.com/blend-capital/blend-contracts"
Expand Down
21 changes: 6 additions & 15 deletions blend-contract-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,12 @@ pool_client.mock_all_auths().update_status(); // update status based on backstop

## WASM Verification

The WASM files included will align with the GitHub release the SDK was published with (the version numbers will match). The WASM files were generated with the Makefile.
The WASM files included will align with the GitHub release the SDK was published with (the version numbers will match).

Since WASM builds can vary based on factors like OS, here are the details of the machine that built the WASMs included in this package:

* Ubuntu 22.04.4 LTS
* stable-x86_64-unknown-linux-gnu (default)
* rustc 1.77.1 (7cf61ebde 2024-03-27)
* soroban 20.3.1 (ae5446f63ca8a275e61912019199254d598f3bd5)
* soroban-env 20.2.1 (18a10592853d9edf4e341b565b0b1638f95f0393)
* soroban-env interface version 85899345920
* stellar-xdr 20.1.0 (8b9d623ef40423a8462442b86997155f2c04d3a1)
* xdr curr (b96148cd4acc372cc9af17b909ffe4b12c43ecb6)
The WASMs are generated with the [Stellar Expert WASM Release Action](https://github.com/stellar-expert/soroban-build-workflow)

The SHA256 Checksums:
* backstop - `8dfbc6ba300cde6ebe747cf985cf9221bf3594981595b9c26bbd108ff19a5598`
* emitter - `b1555702a4cca7c44e02beb5aa82b0271c0367471c68f2ec9246c31b202e38ee`
* pool_factory - `8bc7894d8a4e46b085d0579e233e3c436bb34e18f9a2a83d4bde8526cde18cb6`
* pool - `76ebcea354d5959c5b0d38818ddf1524c5af16970231b532f5caa63121930861`
* backstop - `8ed2a58d4b71e3d8f15b74bae8287a825f7bb78ba72663a920141d9d1c1d8bb2`
* emitter - `ce85c955b135e08e055b157fc96c371c9107b4f3a16d920668f5529d7c616b9c`
* pool_factory - `0287f4ad7350935b83d94e046c0bcabc960b233dbce1531008c021b71d406a1d`
* pool - `baf978f10efdbcd85747868bef8832845ea6809f7643b67a4ac0cd669327fc2c`
23 changes: 5 additions & 18 deletions blend-contract-sdk/src/testutils.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use soroban_sdk::{testutils::Address as _, token::StellarAssetClient, vec, Address, Env, Map};
use soroban_sdk::{token::StellarAssetClient, vec, Address, Env, Map};

use crate::{backstop, emitter, pool, pool_factory};

pub mod comet {
soroban_sdk::contractimport!(file = "./wasm/comet.wasm");
}

pub mod comet_factory {
soroban_sdk::contractimport!(file = "./wasm/comet_factory.wasm");
}

/// Create a "good enough" ReserveConfig for most testing usecases
///
/// Can be used when creating reserves for a pool.
Expand Down Expand Up @@ -70,22 +66,13 @@ impl<'a> BlendFixture<'a> {
.mint(deployer, &(25_0000000 * 2001));

let comet_client: comet::Client<'a> = comet::Client::new(env, &comet);
comet_client
.mock_all_auths()
.init(&Address::generate(env), deployer);

comet_client.mock_all_auths().bundle_bind(
comet_client.mock_all_auths().init(
&deployer,
&vec![env, blnd.clone(), usdc.clone()],
&vec![env, 0_8000000, 0_2000000],
&vec![env, 1_000_0000000, 25_0000000],
&vec![env, 8_0000000, 2_0000000],
&0_0030000,
);
comet_client
.mock_all_auths()
.set_swap_fee(&30000_i128, deployer);
comet_client
.mock_all_auths()
.set_public_swap(deployer, &true);
comet_client.mock_all_auths().finalize();

comet_client.mock_all_auths().join_pool(
&199_900_0000000, // finalize mints 100
Expand Down
Binary file modified blend-contract-sdk/wasm/backstop.wasm
100644 → 100755
Binary file not shown.
Binary file modified blend-contract-sdk/wasm/comet.wasm
100644 → 100755
Binary file not shown.
Binary file modified blend-contract-sdk/wasm/comet_factory.wasm
100644 → 100755
Binary file not shown.
Binary file modified blend-contract-sdk/wasm/emitter.wasm
100644 → 100755
Binary file not shown.
Binary file modified blend-contract-sdk/wasm/pool.wasm
100644 → 100755
Binary file not shown.
Binary file modified blend-contract-sdk/wasm/pool_factory.wasm
100644 → 100755
Binary file not shown.
Binary file modified comet.wasm
100644 → 100755
Binary file not shown.
14 changes: 4 additions & 10 deletions pool/src/testutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,15 @@ pub(crate) fn create_comet_lp_pool<'a>(
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;
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::generate(e), &admin);
client.bundle_bind(
client.init(
admin,
&vec![e, blnd_token.clone(), usdc_token.clone()],
&vec![e, 0_8000000, 0_2000000],
&vec![e, 1_000_0000000, 25_0000000],
&vec![e, 8_0000000, 2_0000000],
&0_0030000,
);

client.set_swap_fee(&0_0030000, &admin);
client.set_public_swap(&admin, &true);
client.finalize();

(contract_address, client)
}

Expand Down
13 changes: 4 additions & 9 deletions test-suites/src/liquidity_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ pub(crate) fn create_lp_pool<'a>(
let token_2_client = MockTokenClient::new(e, token_2);
token_1_client.mint(&admin, &1_000_0000000);
token_2_client.mint(&admin, &25_0000000);
token_1_client.approve(&admin, &contract_address, &1_000_0000000, &5356700);
token_2_client.approve(&admin, &contract_address, &1_000_0000000, &5356700);

client.init(&Address::generate(e), &admin);
client.bundle_bind(
client.init(
admin,
&vec![e, token_1.clone(), token_2.clone()],
&vec![e, 0_8000000, 0_2000000],
&vec![e, 1_000_0000000, 25_0000000],
&vec![e, 8_0000000, 2_0000000],
&0_0030000,
);

client.set_swap_fee(&0_0030000, &admin);
client.set_public_swap(&admin, &true);
client.finalize();

(contract_address, client)
}
6 changes: 3 additions & 3 deletions test-suites/tests/test_wasm_happy_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ fn test_wasm_happy_path() {
&vec![&fixture.env, pool_fixture.pool.address.clone()],
&frodo,
);
assert_eq!(claim_amount, 420798_0000000);
assert_eq!(claim_amount, 420797_9966204);
backstop_blnd_balance -= claim_amount;
assert_eq!(
fixture.tokens[TokenIndex::BLND].balance(&fixture.backstop.address),
Expand Down Expand Up @@ -433,8 +433,8 @@ fn test_wasm_happy_path() {
&vec![&fixture.env, pool_fixture.pool.address.clone()],
&frodo,
);
assert_eq!(claim_amount, 22014719_9998450); //actual amount is 22014720_0000000 but get's rounded down // 22014719_9998450
backstop_blnd_balance -= 22014719_9998450;
assert_eq!(claim_amount, 22014719_9894996); //actual amount is 22014720_0000000 but get's rounded down
backstop_blnd_balance -= 22014719_9894996;
assert_eq!(
fixture.tokens[TokenIndex::BLND].balance(&fixture.backstop.address),
backstop_blnd_balance
Expand Down
Loading