Skip to content

Instantly share code, notes, and snippets.

@shapeshed
Last active May 9, 2024 16:42
Show Gist options
  • Save shapeshed/3ff6ada16386165741f645a20b2a287d to your computer and use it in GitHub Desktop.
Save shapeshed/3ff6ada16386165741f645a20b2a287d to your computer and use it in GitHub Desktop.
no claimable_spread_rewards / test-tube
// Setup
pub const TICK_SPACING: u64 = 100;
pub const SPREAD_FACTOR: &str = "1";
pub const BASE_DENOM: &str = "uosmo";
pub const QUOTE_DENOM: &str = "usdc";
gov.propose_and_execute(
CreateConcentratedLiquidityPoolsProposal::TYPE_URL.to_string(),
CreateConcentratedLiquidityPoolsProposal {
title: "Create concentrated uosmo:usdc pool".to_string(),
description: "Create concentrated uosmo:usdc pool, so that we can trade it"
.to_string(),
pool_records: vec![PoolRecord {
denom0: BASE_DENOM.to_string(),
denom1: QUOTE_DENOM.to_string(),
tick_spacing: TICK_SPACING,
spread_factor: SPREAD_FACTOR.to_string(),
}],
},
signer.address(),
&signer,
)
.unwrap();
// Create Initial CL position
concentrated_liquidity
.create_position(
MsgCreatePosition {
pool_id: pool.id,
sender: signer.address(),
lower_tick: -108000000i64,
upper_tick: 342000000i64,
tokens_provided: vec![
OsmosisCoin {
// uosmo
denom: BASE_DENOM.to_string(),
// 10,000 @ 6dp
amount: "10000000000".to_string(),
},
OsmosisCoin {
// usdc
denom: QUOTE_DENOM.to_string(),
// 12,500 @ 6dp
amount: "12500000000".to_string(),
},
],
token_min_amount0: "0".to_string(),
token_min_amount1: "0".to_string(),
},
&signer,
)
.unwrap();
// In the test another position is created using this message
let msg = MsgCreatePosition {
pool_id: env.pool.id,
sender: contract_addr.clone(),
lower_tick: -108000000i64,
upper_tick: 342000000i64,
tokens_provided: vec![
OsmosisCoin {
denom: BASE_DENOM.to_string(),
amount: "100000000".to_string(),
},
OsmosisCoin {
denom: QUOTE_DENOM.to_string(),
amount: "12500000".to_string(),
},
],
token_min_amount0: "0".to_string(),
token_min_amount1: "0".to_string(),
};
// Then we do some swaps
// Pool State before swaps
Pool {
address: "osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7",
incentives_address: "osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf",
spread_rewards_address: "osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv",
id: 1,
current_tick_liquidity: "11180339887498948491250000000",
token0: "uosmo",
token1: "usdc",
current_sqrt_price: "1118033988749894849000000000000000000",
current_tick: 250000,
tick_spacing: 100,
exponent_at_price_one: -6,
spread_factor: "1",
last_liquidity_update: Some(
Timestamp {
seconds: 1715442610,
nanos: 413194868,
},
),
}
// Pool state After swaps (note current tick is different)
Pool {
address: "osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7",
incentives_address: "osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf",
spread_rewards_address: "osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv",
id: 1,
current_tick_liquidity: "11191520237386456384004001728",
token0: "uosmo",
token1: "usdc",
current_sqrt_price: "1117721314262361825912908749422868144",
current_tick: 249300,
tick_spacing: 100,
exponent_at_price_one: -6,
spread_factor: "1",
last_liquidity_update: Some(
Timestamp {
seconds: 1715442645,
nanos: 413194868,
},
),
}
// After swaps there is nothing in `claimable_spread_rewards`, even with moving time forward 48 hours
FullPositionBreakdown {
position: Some(
Position {
position_id: 2,
address: "osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9",
pool_id: 1,
lower_tick: -108000000,
upper_tick: 342000000,
join_time: Some(
Timestamp {
seconds: 1715442645,
nanos: 413194868,
},
),
liquidity: "11180349887507892754001728",
},
),
asset0: Some(
Coin {
denom: "uosmo",
amount: "10002807",
},
),
asset1: Some(
Coin {
denom: "usdc",
amount: "12496505",
},
),
claimable_spread_rewards: [],
claimable_incentives: [
Coin {
denom: "uosmo",
amount: "57223",
},
],
forfeited_incentives: [],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment