Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Former-commit-id: c8c4740
  • Loading branch information
1010adigupta committed Mar 29, 2024
1 parent 05c2676 commit f2f1899
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ sol!(
);

// Positions of crypto pool immutables in the bytecode
const PRICE_SCALE_PACKED_RANGE: std::ops::Range<usize> = "4542..4542 + 40";
const FUTURE_A_GAMMA_TIME_RANGE: std::ops::Range<usize> = "9128..9128 + 40";
const PRICE_SCALE_PACKED_RANGE: std::ops::Range<usize> = "";
const FUTURE_A_GAMMA_TIME_RANGE: std::ops::Range<usize> = "";

pub fn extract_curve_crypto_pool_immutables(bytecode: Bytes) -> (U256, U256) {
// Slices
Expand Down Expand Up @@ -70,7 +70,7 @@ pub async fn get_curve_crypto_pool_data_batch_request<M: TracingProvider>(
) -> Result<(), AmmError> {

// Pool Storage Slots
let d_value_slot: FixedBytes<32> = FixedBytes::new(["0u8; 32"]);
let d_value_slot: FixedBytes<32> = FixedBytes::new([""]);

// Fetch from db
let d_value: Option<StorageValue> = middleware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,17 @@ sol!(
);

// Positions of stable pool immutables in the bytecode
const BASE_POOL_RANGE: std::ops::Range<usize> = "4542..4542 + 40";
const ORIGINAL_RATES_RANGE: std::ops::Range<usize> = "9128..9128 + 40";
const BASE_POOL_RANGE: std::ops::Range<usize> = "";

pub fn extract_curve_stable_pool_immutables(bytecode: Bytes) -> (Address, Vec<U256>) {
pub fn extract_curve_stable_pool_immutables(bytecode: Bytes) -> Address {
// Slices
let base_pool_slice = &bytecode[BASE_POOL_RANGE];
let original_rates_slice = &bytecode[ORIGINAL_RATES_RANGE];

let base_pool = from_utf8(base_pool_slice).unwrap();
let original_rates = from_utf8(original_rates_slice).unwrap();

let base_pool = Address::from_str(base_pool).unwrap();
//original rates are of type Vec<U256>

(base_pool, original_rates)
base_pool
}

fn populate_pool_data(mut pool: CurvePool, pool_data: PoolData) -> CurvePool {
Expand All @@ -79,9 +75,8 @@ pub async fn get_curve_pool_data_batch_request<M: TracingProvider>(
// Extract base_pool, original_pool_rates from bytecode
if let Some(pool_bytecode) = pool_bytecode {
let pool_bytecode = Bytes::from(hex::encode_prefixed(pool_bytecode.bytecode.as_ref()));
let (base_pool, original_pool_rates) = extract_curve_stable_pool_immutables(pool_bytecode);
let base_pool = extract_curve_stable_pool_immutables(pool_bytecode);
pool.base_pool = base_pool;
pool.rates = original_pool_rates;
}
let mut bytecode = IGetCurveV2MetapoolDataBatchRequest::BYTECODE.to_vec();
data_constructorCall::new((
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ use crate::{
errors::{AmmError, ArithmeticError, EventLogError},
UpdatableProtocol,
};

pub const RATES: [U256; 2] = [
U256::from_limbs([1_000_000_000_000_000_000, 0, 0, 0]),
U256::from_limbs([
4003012203950112768,
542101086242752,
0,
0,
])
];
sol!(
#[derive(Debug)]
interface ICurvePool {
Expand Down Expand Up @@ -174,7 +184,7 @@ impl CurvePool {
fee: U256::ZERO,
admin_fee: U256::ZERO,
a_value: U256::ZERO,
rates: Vec::new(),
rates: RATES.to_vec(),
..Default::default()
};

Expand Down

0 comments on commit f2f1899

Please sign in to comment.