Skip to content

Commit

Permalink
Merge pull request #4 from haiko-xyz/feat/reversion-solver
Browse files Browse the repository at this point in the history
fix: token symbol
  • Loading branch information
parketh authored Jul 7, 2024
2 parents c7ec21c + 35f8780 commit 80fb8e7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/contracts/solver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,9 @@ pub mod SolverComponent {
let base_symbol = erc20_versioned_call::get_symbol(market_info.base_token);
let quote_symbol = erc20_versioned_call::get_symbol(market_info.quote_token);
let name: ByteArray = format!("Haiko {} {}-{}", self.name(), base_symbol, quote_symbol);
let symbol: ByteArray = format!("HAIKO-{}-{}-{}", self.symbol(), base_symbol, quote_symbol);
let symbol: ByteArray = format!(
"HAIKO-{}-{}-{}", self.symbol(), base_symbol, quote_symbol
);
let decimals: u8 = 18;
let owner = get_contract_address();

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tests/solver/test_create_market.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn test_create_public_market_initialises_immutables_and_deploys_vault_token() {
let vault_token = ERC20ABIDispatcher { contract_address: vault_token_opt.unwrap() };
let vault_token_alt = IVaultTokenDispatcher { contract_address: vault_token_opt.unwrap() };
assert(vault_token.name() == "Haiko Mock ETH-USDC", 'Vault token: name');
assert(vault_token.symbol() == "MOCK-ETH-USDC", 'Vault token: name');
assert(vault_token.symbol() == "HAIKO-MOCK-ETH-USDC", 'Vault token: name');
assert(vault_token.decimals() == 18, 'Vault token: decimal');
assert(vault_token_alt.owner() == solver.contract_address, 'Vault token: owner');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tests/solver/test_deploy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn test_deploy_vault_token_initialises_immutables() {
let vault_token_alt = IVaultTokenDispatcher { contract_address: vault_token_opt.unwrap() };

assert(vault_token.name() == "Haiko Mock ETH-USDC", 'Vault token: name');
assert(vault_token.symbol() == "MOCK-ETH-USDC", 'Vault token: name');
assert(vault_token.symbol() == "HAIKO-MOCK-ETH-USDC", 'Vault token: name');
assert(vault_token.decimals() == 18, 'Vault token: decimal');
assert(vault_token_alt.owner() == solver.contract_address, 'Vault token: owner');
}
15 changes: 7 additions & 8 deletions packages/core/src/tests/solver/test_deposit.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,13 @@ fn test_deposit_public_vault_multiple_lps_capped_at_available() {

// Spy on events.
let mut spy = spy_events(SpyOn::One(solver.contract_address));

// Deposit.
start_prank(CheatTarget::One(solver.contract_address), alice());
let base_deposit = to_e18(40000);
let quote_deposit = to_e18(20);
let (base_amount, quote_amount, shares) = solver.deposit(market_id, base_deposit, quote_deposit);
let (base_amount, quote_amount, shares) = solver
.deposit(market_id, base_deposit, quote_deposit);
assert(base_amount == base_available, 'Base deposit');
assert(quote_amount == quote_available, 'Quote deposit');

Expand All @@ -276,7 +277,9 @@ fn test_deposit_public_vault_multiple_lps_capped_at_available() {
let vault_token = ERC20ABIDispatcher { contract_address: vault_token_addr };
let owner_vault_bal = vault_token.balanceOf(owner());
let lp_vault_bal = vault_token.balanceOf(alice());
assert(approx_eq(lp_vault_bal, math::mul_div(owner_vault_bal, 3, 2, false), 1000), 'Vault shares');
assert(
approx_eq(lp_vault_bal, math::mul_div(owner_vault_bal, 3, 2, false), 1000), 'Vault shares'
);

// Check events emitted with correct amounts
spy
Expand All @@ -286,11 +289,7 @@ fn test_deposit_public_vault_multiple_lps_capped_at_available() {
solver.contract_address,
SolverComponent::Event::Deposit(
SolverComponent::Deposit {
market_id,
caller: alice(),
base_amount,
quote_amount,
shares
market_id, caller: alice(), base_amount, quote_amount, shares
}
)
)
Expand Down

0 comments on commit 80fb8e7

Please sign in to comment.