diff --git a/.gitignore b/.gitignore index 16598fd1..13c27d08 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ node_modules .env scripts/.env.instantiate scripts/.env.upload -neutron/data/ \ No newline at end of file +neutron/data/ diff --git a/contracts/core/src/contract.rs b/contracts/core/src/contract.rs index 0c83c5d3..e1ecd597 100644 --- a/contracts/core/src/contract.rs +++ b/contracts/core/src/contract.rs @@ -180,19 +180,19 @@ fn query_exchange_rate(deps: Deps, config: &Config) -> ContractRes let mut unprocessed_unbonded_amount = Uint128::zero(); let batch = unbond_batches_map().load(deps.storage, batch_id)?; if batch.status == UnbondBatchStatus::New { - unprocessed_unbonded_amount += batch.total_amount; + unprocessed_unbonded_amount += batch.expected_native_asset_amount; } if batch_id > 0 { batch_id -= 1; let batch = unbond_batches_map().load(deps.storage, batch_id)?; if batch.status == UnbondBatchStatus::UnbondRequested { - unprocessed_unbonded_amount += batch.total_amount; + unprocessed_unbonded_amount += batch.expected_native_asset_amount; } } let failed_batch_id = FAILED_BATCH_ID.may_load(deps.storage)?; if let Some(failed_batch_id) = failed_batch_id { let failed_batch = unbond_batches_map().load(deps.storage, failed_batch_id)?; - unprocessed_unbonded_amount += failed_batch.total_amount; + unprocessed_unbonded_amount += failed_batch.expected_native_asset_amount; } let staker_balance: Uint128 = deps.querier.query_wasm_smart( &config.staker_contract, @@ -328,11 +328,11 @@ fn execute_process_emergency_batch( ContractError::BatchNotWithdrawnEmergency {} ); ensure!( - batch.expected_amount >= unbonded_amount, + batch.expected_native_asset_amount >= unbonded_amount, ContractError::UnbondedAmountTooHigh {} ); - let slashing_effect = Decimal::from_ratio(unbonded_amount, batch.expected_amount); + let slashing_effect = Decimal::from_ratio(unbonded_amount, batch.expected_native_asset_amount); batch.status = UnbondBatchStatus::Withdrawn; batch.unbonded_amount = Some(unbonded_amount); batch.slashing_effect = Some(slashing_effect); @@ -577,8 +577,8 @@ fn execute_tick_idle( unbonding_batches .into_iter() .filter(|(_id, batch)| { - batch.expected_release <= env.block.time.seconds() - && batch.expected_release < ica_balance_local_time + batch.expected_release_time <= env.block.time.seconds() + && batch.expected_release_time < ica_balance_local_time }) .collect::>() } else { @@ -596,13 +596,16 @@ fn execute_tick_idle( .unwrap(); let (unbonded_amount, slashing_effect) = - if ica_balance < unbonding_batch.expected_amount { + if ica_balance < unbonding_batch.expected_native_asset_amount { ( ica_balance, - Decimal::from_ratio(ica_balance, unbonding_batch.expected_amount), + Decimal::from_ratio( + ica_balance, + unbonding_batch.expected_native_asset_amount, + ), ) } else { - (unbonding_batch.expected_amount, Decimal::one()) + (unbonding_batch.expected_native_asset_amount, Decimal::one()) }; unbonding_batch.unbonded_amount = Some(unbonded_amount); unbonding_batch.slashing_effect = Some(slashing_effect); @@ -617,22 +620,23 @@ fn execute_tick_idle( }) } _ => { - let total_expected_amount: Uint128 = unbonded_batches + let total_native_asset_expected_amount: Uint128 = unbonded_batches .iter() - .map(|(_id, batch)| batch.expected_amount) + .map(|(_id, batch)| batch.expected_native_asset_amount) .sum(); - let (emergency, recipient, amount) = if ica_balance < total_expected_amount { - ( - true, - config - .emergency_address - .clone() - .ok_or(ContractError::EmergencyAddressIsNotSet {})?, - ica_balance, - ) - } else { - (false, pump_ica_address, total_expected_amount) - }; + let (emergency, recipient, amount) = + if ica_balance < total_native_asset_expected_amount { + ( + true, + config + .emergency_address + .clone() + .ok_or(ContractError::EmergencyAddressIsNotSet {})?, + ica_balance, + ) + } else { + (false, pump_ica_address, total_native_asset_expected_amount) + }; let mut batch_ids = vec![]; for (id, mut batch) in unbonded_batches { batch_ids.push(id); @@ -643,7 +647,7 @@ fn execute_tick_idle( batch.status_timestamps.withdrawing_emergency = Some(env.block.time.seconds()); } else { - batch.unbonded_amount = Some(batch.expected_amount); + batch.unbonded_amount = Some(batch.expected_native_asset_amount); batch.slashing_effect = Some(Decimal::one()); batch.status = UnbondBatchStatus::Withdrawing; batch.status_timestamps.withdrawing = Some(env.block.time.seconds()); @@ -888,7 +892,8 @@ fn execute_tick_unbonding( let mut unbond = unbond_batches_map().load(deps.storage, batch_id)?; unbond.status = UnbondBatchStatus::Unbonding; unbond.status_timestamps.unbonding = Some(env.block.time.seconds()); - unbond.expected_release = env.block.time.seconds() + config.unbonding_period; + unbond.expected_release_time = + env.block.time.seconds() + config.unbonding_period; unbond_batches_map().save(deps.storage, batch_id, &unbond)?; FAILED_BATCH_ID.remove(deps.storage); attrs.push(attr("unbonding", "success")); @@ -1122,24 +1127,24 @@ fn execute_unbond( let unbond_batch_id = UNBOND_BATCH_ID.load(deps.storage)?; let config = CONFIG.load(deps.storage)?; let ld_denom = LD_DENOM.load(deps.storage)?; - let amount = cw_utils::must_pay(&info, &ld_denom)?; - BONDED_AMOUNT.update(deps.storage, |total| StdResult::Ok(total - amount))?; + let dasset_amount = cw_utils::must_pay(&info, &ld_denom)?; + BONDED_AMOUNT.update(deps.storage, |total| StdResult::Ok(total - dasset_amount))?; let mut unbond_batch = unbond_batches_map().load(deps.storage, unbond_batch_id)?; let exchange_rate = query_exchange_rate(deps.as_ref(), &config)?; attrs.push(attr("exchange_rate", exchange_rate.to_string())); - let expected_amount = amount * exchange_rate; + let native_asset_amount = dasset_amount * exchange_rate; unbond_batch.total_unbond_items += 1; - unbond_batch.total_amount += amount; - unbond_batch.expected_amount += expected_amount; + unbond_batch.total_dasset_amount_to_withdraw += dasset_amount; + unbond_batch.expected_native_asset_amount += native_asset_amount; - attrs.push(attr("expected_amount", expected_amount.to_string())); + attrs.push(attr("expected_amount", native_asset_amount.to_string())); unbond_batches_map().save(deps.storage, unbond_batch_id, &unbond_batch)?; let extension = Some(Metadata { description: Some("Withdrawal voucher".into()), name: "LDV voucher".to_string(), batch_id: unbond_batch_id.to_string(), - amount, - expected_amount, + amount: dasset_amount, + expected_amount: native_asset_amount, attributes: Some(vec![ Trait { display_type: None, @@ -1149,12 +1154,12 @@ fn execute_unbond( Trait { display_type: None, trait_type: "received_amount".to_string(), - value: amount.to_string(), + value: dasset_amount.to_string(), }, Trait { display_type: None, trait_type: "expected_amount".to_string(), - value: expected_amount.to_string(), + value: native_asset_amount.to_string(), }, Trait { display_type: None, @@ -1183,7 +1188,7 @@ fn execute_unbond( msg: to_json_binary(&TokenExecuteMsg::Burn {})?, funds: vec![Coin { denom: ld_denom, - amount, + amount: dasset_amount, }], }), ]; @@ -1321,13 +1326,13 @@ fn get_unbonding_msg( let mut unbond = unbond_batches_map().load(deps.storage, batch_id)?; if (unbond.status_timestamps.new + config.unbond_batch_switch_time < env.block.time.seconds()) && unbond.total_unbond_items != 0 - && !unbond.total_amount.is_zero() + && !unbond.expected_native_asset_amount.is_zero() { let calc_withdraw_query_result: Result, StdError> = deps.querier.query_wasm_smart( config.strategy_contract.to_string(), &drop_staking_base::msg::strategy::QueryMsg::CalcWithdraw { - withdraw: unbond.total_amount, + withdraw: unbond.expected_native_asset_amount, }, ); @@ -1382,7 +1387,7 @@ fn is_unbonding_time_close( safe_period: u64, ) -> bool { for (_id, unbond_batch) in unbonding_batches { - let expected = unbond_batch.expected_release; + let expected = unbond_batch.expected_release_time; if (now < expected) && (now > expected - safe_period) { return true; } @@ -1432,11 +1437,11 @@ fn get_ica_balance_by_denom( fn new_unbond(now: u64) -> UnbondBatch { UnbondBatch { - total_amount: Uint128::zero(), - expected_amount: Uint128::zero(), + total_dasset_amount_to_withdraw: Uint128::zero(), + expected_native_asset_amount: Uint128::zero(), total_unbond_items: 0, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, diff --git a/contracts/core/src/tests.rs b/contracts/core/src/tests.rs index 0d4a6691..a018d17d 100644 --- a/contracts/core/src/tests.rs +++ b/contracts/core/src/tests.rs @@ -1180,11 +1180,11 @@ fn test_tick_idle_unbonding_close() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::Unbonding, - expected_release: 10001, + expected_release_time: 10001, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -1319,11 +1319,11 @@ fn test_tick_idle_claim_wo_unbond() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::Unbonding, - expected_release: 9000, + expected_release_time: 9000, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -1473,11 +1473,11 @@ fn test_tick_idle_claim_with_unbond_transfer() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::Unbonding, - expected_release: 90000, + expected_release_time: 90000, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -1933,11 +1933,11 @@ fn test_tick_idle_unbonding() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -2272,11 +2272,11 @@ fn test_tick_claiming_wo_transfer_unbonding() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -2432,11 +2432,11 @@ fn test_tick_claiming_wo_idle() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -2788,11 +2788,11 @@ fn test_tick_staking_to_unbonding() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -2921,11 +2921,11 @@ fn test_tick_staking_to_idle() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -3283,11 +3283,11 @@ fn test_bond_lsm_share_increase_exchange_rate() { &mut deps.storage, 0, &UnbondBatch { - total_amount: Uint128::zero(), - expected_amount: Uint128::zero(), + total_dasset_amount_to_withdraw: Uint128::zero(), + expected_native_asset_amount: Uint128::zero(), total_unbond_items: 0, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -3497,11 +3497,11 @@ fn test_unbond() { deps.as_mut().storage, 0, &UnbondBatch { - total_amount: Uint128::from(0u128), - expected_amount: Uint128::from(0u128), + total_dasset_amount_to_withdraw: Uint128::from(0u128), + expected_native_asset_amount: Uint128::from(0u128), total_unbond_items: 0, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -3594,11 +3594,11 @@ fn test_unbond() { assert_eq!( unbond_batch, UnbondBatch { - total_amount: Uint128::from(1000u128), - expected_amount: Uint128::from(1000u128), + total_dasset_amount_to_withdraw: Uint128::from(1000u128), + expected_native_asset_amount: Uint128::from(1000u128), total_unbond_items: 1, status: UnbondBatchStatus::New, - expected_release: 0, + expected_release_time: 0, slashing_effect: None, unbonded_amount: None, withdrawed_amount: None, @@ -3640,9 +3640,9 @@ mod process_emergency_batch { deps.as_mut().storage, 2, &UnbondBatch { - total_amount: Uint128::new(100), - expected_amount: Uint128::new(100), - expected_release: 200, + total_dasset_amount_to_withdraw: Uint128::new(100), + expected_native_asset_amount: Uint128::new(100), + expected_release_time: 200, total_unbond_items: 0, status, slashing_effect: None, @@ -3742,9 +3742,9 @@ mod process_emergency_batch { assert_eq!( batch, UnbondBatch { - total_amount: Uint128::new(100), - expected_amount: Uint128::new(100), - expected_release: 200, + total_dasset_amount_to_withdraw: Uint128::new(100), + expected_native_asset_amount: Uint128::new(100), + expected_release_time: 200, total_unbond_items: 0, status: UnbondBatchStatus::Withdrawn, slashing_effect: Some(Decimal::one()), @@ -3783,9 +3783,9 @@ mod process_emergency_batch { assert_eq!( batch, UnbondBatch { - total_amount: Uint128::new(100), - expected_amount: Uint128::new(100), - expected_release: 200, + total_dasset_amount_to_withdraw: Uint128::new(100), + expected_native_asset_amount: Uint128::new(100), + expected_release_time: 200, total_unbond_items: 0, status: UnbondBatchStatus::Withdrawn, slashing_effect: Some(Decimal::from_ratio(70u128, 100u128)), diff --git a/integration_tests/src/testSuite.ts b/integration_tests/src/testSuite.ts index 89fb35d7..ff38f6b5 100644 --- a/integration_tests/src/testSuite.ts +++ b/integration_tests/src/testSuite.ts @@ -183,8 +183,17 @@ type Keys = (typeof keys)[number]; const awaitFirstBlock = (rpc: string): Promise => waitFor(async () => { try { + const controller = new AbortController(); + setTimeout(() => controller.abort(), 5000); + await fetch(rpc, { + method: 'GET', + signal: controller.signal, + }); + console.log(`Connecting to ${rpc}`); const client = await StargateClient.connect(rpc); + console.log(`Connected to ${rpc}`); const block = await client.getBlock(); + console.log(`Got block ${block.header.height}`); if (block.header.height > 1) { return true; } diff --git a/integration_tests/src/testcases/auto-withdrawer.test.ts b/integration_tests/src/testcases/auto-withdrawer.test.ts index 9803a8ea..b5cffcba 100644 --- a/integration_tests/src/testcases/auto-withdrawer.test.ts +++ b/integration_tests/src/testcases/auto-withdrawer.test.ts @@ -1515,8 +1515,9 @@ describe('Auto withdrawer', () => { batch_id: '0', }); const currentTime = Math.floor(Date.now() / 1000); - if (batchInfo.expected_release > currentTime) { - const diffMs = (batchInfo.expected_release - currentTime + 1) * 1000; + if (batchInfo.expected_release_time > currentTime) { + const diffMs = + (batchInfo.expected_release_time - currentTime + 1) * 1000; await sleep(diffMs); } }); @@ -1538,8 +1539,8 @@ describe('Auto withdrawer', () => { }, })) as any; const icaTs = Math.floor(res[2] / 1e9); - return icaTs > batchInfo.expected_release; - }, 50_000); + return icaTs > batchInfo.expected_release_time; + }, 500_000); }); it('tick', async () => { const { coreContractClient, neutronUserAddress } = context; @@ -1558,7 +1559,7 @@ describe('Auto withdrawer', () => { // } return !!response; - }, 100_000); + }, 200_000); expect(response).toBeTruthy(); expect(response).toHaveProperty('success'); }); @@ -1604,7 +1605,7 @@ describe('Auto withdrawer', () => { context.withdrawalManagerContractClient.contractAddress, ); return balances.data.balances.length > 0; - }); + }, 200_000); }); it('withdraw', async () => { const { diff --git a/integration_tests/src/testcases/core-slashing.test.ts b/integration_tests/src/testcases/core-slashing.test.ts index 3427d3ca..608e023d 100644 --- a/integration_tests/src/testcases/core-slashing.test.ts +++ b/integration_tests/src/testcases/core-slashing.test.ts @@ -905,9 +905,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'unbonding', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '500', - expected_amount: '500', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '500', + expected_native_asset_amount: '500', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, @@ -1133,9 +1133,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'unbonding', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '3000', - expected_amount: '3000', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '3000', + expected_native_asset_amount: '3000', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, @@ -1157,8 +1157,8 @@ describe('Core Slashing', () => { batch_id: '0', }); const currentTime = Math.floor(Date.now() / 1000); - if (batchInfo.expected_release > currentTime) { - const diffMs = (batchInfo.expected_release - currentTime + 1) * 1000; + if (batchInfo.expected_release_time > currentTime) { + const diffMs = (batchInfo.expected_release_time - currentTime + 1) * 1000; await sleep(diffMs); } }); @@ -1167,8 +1167,8 @@ describe('Core Slashing', () => { batch_id: '1', }); const currentTime = Math.floor(Date.now() / 1000); - if (batchInfo.expected_release > currentTime) { - const diffMs = (batchInfo.expected_release - currentTime + 1) * 1000; + if (batchInfo.expected_release_time > currentTime) { + const diffMs = (batchInfo.expected_release_time - currentTime + 1) * 1000; await sleep(diffMs); } }); @@ -1186,7 +1186,7 @@ describe('Core Slashing', () => { })) as any )[2] / 1e9, ); - return icaTs > batchInfo.expected_release; + return icaTs > batchInfo.expected_release_time; }, 50_000); }); it('wait until fresh ICA balance for unbonding batch 1 is delivered', async () => { @@ -1203,7 +1203,7 @@ describe('Core Slashing', () => { })) as any )[2] / 1e9, ); - return icaTs > batchInfo.expected_release; + return icaTs > batchInfo.expected_release_time; }, 50_000); }); it('tick (claiming)', async () => { @@ -1259,9 +1259,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'withdrawing_emergency', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '1000', - expected_amount: '1000', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '1000', + expected_native_asset_amount: '1000', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, @@ -1276,9 +1276,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'withdrawing_emergency', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '3000', - expected_amount: '3499', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '3000', + expected_native_asset_amount: '3499', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, @@ -1311,9 +1311,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'withdrawn_emergency', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '1000', - expected_amount: '1000', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '1000', + expected_native_asset_amount: '1000', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, @@ -1328,9 +1328,9 @@ describe('Core Slashing', () => { slashing_effect: null, status: 'withdrawn_emergency', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '3000', - expected_amount: '3499', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '3000', + expected_native_asset_amount: '3499', total_unbond_items: 1, unbonded_amount: null, withdrawed_amount: null, diff --git a/integration_tests/src/testcases/core.test.ts b/integration_tests/src/testcases/core.test.ts index 0335c5a5..dc1400e1 100644 --- a/integration_tests/src/testcases/core.test.ts +++ b/integration_tests/src/testcases/core.test.ts @@ -999,10 +999,10 @@ describe('Core', () => { expect(batch).toEqual({ slashing_effect: null, status_timestamps: expect.any(Object), - expected_release: 0, + expected_release_time: 0, status: 'new', - total_amount: '500000', - expected_amount: '500000', + total_dasset_amount_to_withdraw: '500000', + expected_native_asset_amount: '500000', total_unbond_items: 2, unbonded_amount: null, withdrawed_amount: null, @@ -1265,9 +1265,9 @@ describe('Core', () => { slashing_effect: null, status: 'unbond_requested', status_timestamps: expect.any(Object), - expected_release: 0, - total_amount: '500000', - expected_amount: '500000', + expected_release_time: 0, + total_dasset_amount_to_withdraw: '500000', + expected_native_asset_amount: '500000', total_unbond_items: 2, unbonded_amount: null, withdrawed_amount: null, @@ -1319,9 +1319,9 @@ describe('Core', () => { slashing_effect: null, status: 'unbonding', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '500000', - expected_amount: '500000', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '500000', + expected_native_asset_amount: '500000', total_unbond_items: 2, unbonded_amount: null, withdrawed_amount: null, @@ -2255,8 +2255,9 @@ describe('Core', () => { batch_id: '0', }); const currentTime = Math.floor(Date.now() / 1000); - if (batchInfo.expected_release > currentTime) { - const diffMs = (batchInfo.expected_release - currentTime + 1) * 1000; + if (batchInfo.expected_release_time > currentTime) { + const diffMs = + (batchInfo.expected_release_time - currentTime + 1) * 1000; await sleep(diffMs); } }); @@ -2274,7 +2275,7 @@ describe('Core', () => { })) as any )[2] / 1e9, ); - return icaTs > batchInfo.expected_release; + return icaTs > batchInfo.expected_release_time; }, 50_000); }); it('tick to idle', async () => { @@ -2343,9 +2344,9 @@ describe('Core', () => { slashing_effect: '1', status: 'withdrawn', status_timestamps: expect.any(Object), - expected_release: expect.any(Number), - total_amount: '500000', - expected_amount: '500000', + expected_release_time: expect.any(Number), + total_dasset_amount_to_withdraw: '500000', + expected_native_asset_amount: '500000', total_unbond_items: 2, unbonded_amount: '500000', withdrawed_amount: null, diff --git a/integration_tests/vite.config.mts b/integration_tests/vite.config.mts index 13fa5153..3c7e64d1 100644 --- a/integration_tests/vite.config.mts +++ b/integration_tests/vite.config.mts @@ -2,8 +2,8 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { - hookTimeout: 500_000, - testTimeout: 500_000, + hookTimeout: 1_500_000, + testTimeout: 1_500_000, watchExclude: ['**/node_modules/**', '**/*.yml', '**/.__cosmopark'], maxThreads: process.env.MAX_THREADS ? parseInt(process.env.MAX_THREADS) : 2, minThreads: 2, diff --git a/packages/base/src/state/core.rs b/packages/base/src/state/core.rs index e46be581..572ca08b 100644 --- a/packages/base/src/state/core.rs +++ b/packages/base/src/state/core.rs @@ -89,9 +89,9 @@ pub struct UnbondBatchStatusTimestamps { #[cw_serde] pub struct UnbondBatch { - pub total_amount: Uint128, - pub expected_amount: Uint128, - pub expected_release: u64, + pub total_dasset_amount_to_withdraw: Uint128, + pub expected_native_asset_amount: Uint128, + pub expected_release_time: u64, pub total_unbond_items: u64, pub status: UnbondBatchStatus, pub slashing_effect: Option, diff --git a/scripts/generate_activity_script/.gitignore b/scripts/generate_activity_script/.gitignore index 2eea525d..b9690d5f 100644 --- a/scripts/generate_activity_script/.gitignore +++ b/scripts/generate_activity_script/.gitignore @@ -1 +1 @@ -.env \ No newline at end of file +./.env \ No newline at end of file diff --git a/ts-client/lib/contractLib/dropCore.d.ts b/ts-client/lib/contractLib/dropCore.d.ts index 3e768d3c..e2cf6d51 100644 --- a/ts-client/lib/contractLib/dropCore.d.ts +++ b/ts-client/lib/contractLib/dropCore.d.ts @@ -257,7 +257,6 @@ export interface Config { min_stake_amount: Uint128; pump_ica_address?: string | null; puppeteer_contract: Addr; - puppeteer_timeout: number; remote_denom: string; staker_contract: Addr; strategy_contract: Addr; @@ -356,14 +355,25 @@ export interface NonNativeRewardsItem { min_amount: Uint128; } export interface UnbondBatch { - created: number; - expected_amount: Uint128; - expected_release: number; + expected_native_asset_amount: Uint128; + expected_release_time: number; slashing_effect?: Decimal | null; status: UnbondBatchStatus; - total_amount: Uint128; + status_timestamps: UnbondBatchStatusTimestamps; + total_dasset_amount_to_withdraw: Uint128; total_unbond_items: number; unbonded_amount?: Uint128 | null; + withdrawed_amount?: Uint128 | null; +} +export interface UnbondBatchStatusTimestamps { + new: number; + unbond_failed?: number | null; + unbond_requested?: number | null; + unbonding?: number | null; + withdrawing?: number | null; + withdrawing_emergency?: number | null; + withdrawn?: number | null; + withdrawn_emergency?: number | null; } export interface UnbondBatchArgs { batch_id: Uint128; @@ -388,7 +398,6 @@ export interface ConfigOptional { min_stake_amount?: Uint128 | null; pump_ica_address?: string | null; puppeteer_contract?: string | null; - puppeteer_timeout?: number | null; remote_denom?: string | null; staker_contract?: string | null; strategy_contract?: string | null; @@ -435,7 +444,6 @@ export interface InstantiateMsg { owner: string; pump_ica_address?: string | null; puppeteer_contract: string; - puppeteer_timeout: number; remote_denom: string; staker_contract: string; strategy_contract: string; diff --git a/ts-client/lib/contractLib/dropFactory.d.ts b/ts-client/lib/contractLib/dropFactory.d.ts index d1e2aec1..66b5ddc8 100644 --- a/ts-client/lib/contractLib/dropFactory.d.ts +++ b/ts-client/lib/contractLib/dropFactory.d.ts @@ -715,7 +715,6 @@ export interface ConfigOptional { min_stake_amount?: Uint128 | null; pump_ica_address?: string | null; puppeteer_contract?: string | null; - puppeteer_timeout?: number | null; remote_denom?: string | null; staker_contract?: string | null; strategy_contract?: string | null; @@ -1113,6 +1112,7 @@ export interface InstantiateMsg { base_denom: string; code_ids: CodeIds; core_params: CoreParams; + puppeteer_params: PuppeteerParams; remote_opts: RemoteOpts; salt: string; sdk_version: string; @@ -1140,11 +1140,13 @@ export interface CoreParams { lsm_redeem_max_interval: number; lsm_redeem_threshold: number; min_stake_amount: Uint128; - puppeteer_timeout: number; unbond_batch_switch_time: number; unbonding_period: number; unbonding_safe_period: number; } +export interface PuppeteerParams { + timeout: number; +} export interface RemoteOpts { connection_id: string; denom: string; @@ -1155,6 +1157,7 @@ export interface RemoteOpts { export interface StakerParams { min_ibc_transfer: Uint128; min_stake_amount: Uint128; + timeout: number; } export interface DenomMetadata { /** diff --git a/ts-client/lib/contractLib/dropHookTester.d.ts b/ts-client/lib/contractLib/dropHookTester.d.ts index 995f31fa..b6309c17 100644 --- a/ts-client/lib/contractLib/dropHookTester.d.ts +++ b/ts-client/lib/contractLib/dropHookTester.d.ts @@ -195,29 +195,24 @@ export interface SetConfigArgs { } export interface DelegateArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface UndelegateArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface RedelegateArgs { amount: Uint128; - timeout?: number | null; validator_from: string; validator_to: string; } export interface TokenizeShareArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface RedeemShareArgs { amount: Uint128; denom: string; - timeout?: number | null; validator: string; } export interface InstantiateMsg { diff --git a/ts-client/lib/contractLib/dropPuppeteer.d.ts b/ts-client/lib/contractLib/dropPuppeteer.d.ts index 282faf8d..3d905135 100644 --- a/ts-client/lib/contractLib/dropPuppeteer.d.ts +++ b/ts-client/lib/contractLib/dropPuppeteer.d.ts @@ -201,49 +201,40 @@ export interface DelegateArgs { fee?: [string, Uint128] | null; items: [string, Uint128][]; reply_to: string; - timeout?: number | null; } export interface GrantDelegateArgs { grantee: string; - timeout?: number | null; } export interface UndelegateArgs { batch_id: number; items: [string, Uint128][]; reply_to: string; - timeout?: number | null; } export interface RedelegateArgs { amount: Uint128; reply_to: string; - timeout?: number | null; validator_from: string; validator_to: string; } export interface TokenizeShareArgs { amount: Uint128; reply_to: string; - timeout?: number | null; validator: string; } export interface RedeemSharesArgs { items: RedeemShareItem[]; reply_to: string; - timeout?: number | null; } export interface IBCTransferArgs { reason: IBCTransferReason; reply_to: string; - timeout: number; } export interface TransferArgs { items: [string, Coin][]; reply_to: string; - timeout?: number | null; } export interface ClaimRewardsAndOptionalyTransferArgs { reply_to: string; - timeout?: number | null; transfer?: TransferReadyBatchesMsg | null; validators: string[]; } @@ -256,6 +247,7 @@ export interface ConfigOptional { port_id?: string | null; remote_denom?: string | null; sdk_version?: string | null; + timeout?: number | null; transfer_channel_id?: string | null; update_period?: number | null; } @@ -266,6 +258,7 @@ export interface InstantiateMsg { port_id: string; remote_denom: string; sdk_version: string; + timeout: number; transfer_channel_id: string; update_period: number; } diff --git a/ts-client/src/contractLib/dropCore.ts b/ts-client/src/contractLib/dropCore.ts index cfa33a09..bb696537 100644 --- a/ts-client/src/contractLib/dropCore.ts +++ b/ts-client/src/contractLib/dropCore.ts @@ -330,7 +330,6 @@ export interface Config { min_stake_amount: Uint128; pump_ica_address?: string | null; puppeteer_contract: Addr; - puppeteer_timeout: number; remote_denom: string; staker_contract: Addr; strategy_contract: Addr; @@ -425,14 +424,25 @@ export interface NonNativeRewardsItem { min_amount: Uint128; } export interface UnbondBatch { - created: number; - expected_amount: Uint128; - expected_release: number; + expected_native_asset_amount: Uint128; + expected_release_time: number; slashing_effect?: Decimal | null; status: UnbondBatchStatus; - total_amount: Uint128; + status_timestamps: UnbondBatchStatusTimestamps; + total_dasset_amount_to_withdraw: Uint128; total_unbond_items: number; unbonded_amount?: Uint128 | null; + withdrawed_amount?: Uint128 | null; +} +export interface UnbondBatchStatusTimestamps { + new: number; + unbond_failed?: number | null; + unbond_requested?: number | null; + unbonding?: number | null; + withdrawing?: number | null; + withdrawing_emergency?: number | null; + withdrawn?: number | null; + withdrawn_emergency?: number | null; } export interface UnbondBatchArgs { batch_id: Uint128; @@ -457,7 +467,6 @@ export interface ConfigOptional { min_stake_amount?: Uint128 | null; pump_ica_address?: string | null; puppeteer_contract?: string | null; - puppeteer_timeout?: number | null; remote_denom?: string | null; staker_contract?: string | null; strategy_contract?: string | null; @@ -504,7 +513,6 @@ export interface InstantiateMsg { owner: string; pump_ica_address?: string | null; puppeteer_contract: string; - puppeteer_timeout: number; remote_denom: string; staker_contract: string; strategy_contract: string; diff --git a/ts-client/src/contractLib/dropFactory.ts b/ts-client/src/contractLib/dropFactory.ts index 5139ab0e..9b741b43 100644 --- a/ts-client/src/contractLib/dropFactory.ts +++ b/ts-client/src/contractLib/dropFactory.ts @@ -790,7 +790,6 @@ export interface ConfigOptional { min_stake_amount?: Uint128 | null; pump_ica_address?: string | null; puppeteer_contract?: string | null; - puppeteer_timeout?: number | null; remote_denom?: string | null; staker_contract?: string | null; strategy_contract?: string | null; @@ -1188,6 +1187,7 @@ export interface InstantiateMsg { base_denom: string; code_ids: CodeIds; core_params: CoreParams; + puppeteer_params: PuppeteerParams; remote_opts: RemoteOpts; salt: string; sdk_version: string; @@ -1215,11 +1215,13 @@ export interface CoreParams { lsm_redeem_max_interval: number; lsm_redeem_threshold: number; min_stake_amount: Uint128; - puppeteer_timeout: number; unbond_batch_switch_time: number; unbonding_period: number; unbonding_safe_period: number; } +export interface PuppeteerParams { + timeout: number; +} export interface RemoteOpts { connection_id: string; denom: string; @@ -1230,6 +1232,7 @@ export interface RemoteOpts { export interface StakerParams { min_ibc_transfer: Uint128; min_stake_amount: Uint128; + timeout: number; } export interface DenomMetadata { /** diff --git a/ts-client/src/contractLib/dropHookTester.ts b/ts-client/src/contractLib/dropHookTester.ts index 1fd04a90..7ee3e8f7 100644 --- a/ts-client/src/contractLib/dropHookTester.ts +++ b/ts-client/src/contractLib/dropHookTester.ts @@ -221,29 +221,24 @@ export interface SetConfigArgs { } export interface DelegateArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface UndelegateArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface RedelegateArgs { amount: Uint128; - timeout?: number | null; validator_from: string; validator_to: string; } export interface TokenizeShareArgs { amount: Uint128; - timeout?: number | null; validator: string; } export interface RedeemShareArgs { amount: Uint128; denom: string; - timeout?: number | null; validator: string; } export interface InstantiateMsg {} diff --git a/ts-client/src/contractLib/dropPuppeteer.ts b/ts-client/src/contractLib/dropPuppeteer.ts index 6bad5879..3099e9ea 100644 --- a/ts-client/src/contractLib/dropPuppeteer.ts +++ b/ts-client/src/contractLib/dropPuppeteer.ts @@ -239,49 +239,40 @@ export interface DelegateArgs { fee?: [string, Uint128] | null; items: [string, Uint128][]; reply_to: string; - timeout?: number | null; } export interface GrantDelegateArgs { grantee: string; - timeout?: number | null; } export interface UndelegateArgs { batch_id: number; items: [string, Uint128][]; reply_to: string; - timeout?: number | null; } export interface RedelegateArgs { amount: Uint128; reply_to: string; - timeout?: number | null; validator_from: string; validator_to: string; } export interface TokenizeShareArgs { amount: Uint128; reply_to: string; - timeout?: number | null; validator: string; } export interface RedeemSharesArgs { items: RedeemShareItem[]; reply_to: string; - timeout?: number | null; } export interface IBCTransferArgs { reason: IBCTransferReason; reply_to: string; - timeout: number; } export interface TransferArgs { items: [string, Coin][]; reply_to: string; - timeout?: number | null; } export interface ClaimRewardsAndOptionalyTransferArgs { reply_to: string; - timeout?: number | null; transfer?: TransferReadyBatchesMsg | null; validators: string[]; } @@ -294,6 +285,7 @@ export interface ConfigOptional { port_id?: string | null; remote_denom?: string | null; sdk_version?: string | null; + timeout?: number | null; transfer_channel_id?: string | null; update_period?: number | null; } @@ -304,6 +296,7 @@ export interface InstantiateMsg { port_id: string; remote_denom: string; sdk_version: string; + timeout: number; transfer_channel_id: string; update_period: number; }