Skip to content

Commit 03ffd13

Browse files
committed
Merge branch 'release-v0.2' of github.com:pontem-network/multi-swap into release-v0.2
2 parents 0b1955a + 6604523 commit 03ffd13

File tree

10 files changed

+448
-444
lines changed

10 files changed

+448
-444
lines changed

Move.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ test_helpers = "0x12"
1414

1515
[dependencies.MoveStdlib]
1616
git = "https://github.com/aptos-labs/aptos-core.git"
17-
rev = "1570509e746b6626264cb6e9c0c8371683253961"
17+
rev = "a58060f88d66b90a0548a506e22270b04a328db3"
1818
subdir = "aptos-move/framework/move-stdlib"
1919

2020
[dependencies.AptosStdlib]
2121
git = "https://github.com/aptos-labs/aptos-core.git"
22-
rev = "1570509e746b6626264cb6e9c0c8371683253961"
22+
rev = "a58060f88d66b90a0548a506e22270b04a328db3"
2323
subdir = "aptos-move/framework/aptos-stdlib"
2424

2525
[dependencies.AptosFramework]
2626
git = "https://github.com/aptos-labs/aptos-core.git"
27-
rev = "1570509e746b6626264cb6e9c0c8371683253961"
27+
rev = "a58060f88d66b90a0548a506e22270b04a328db3"
2828
subdir = "aptos-move/framework/aptos-framework"
2929

3030
[dependencies.UQ64x64]
3131
git = "https://github.com/pontem-network/UQ64x64.git"
32-
rev = "v0.3.3"
32+
rev = "v0.3.4"
3333

3434
[dependencies.U256]
3535
git = "https://github.com/pontem-network/U256.git"
36-
rev = "v0.3.3"
36+
rev = "v0.3.4"

sources/libs/math.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module liquidswap::math {
7171
}
7272

7373
/// Returns 10^degree.
74-
public fun pow_10(degree: u64): u64 {
74+
public fun pow_10(degree: u8): u64 {
7575
let res = 1;
7676
let i = 0;
7777
while (i < degree) {

sources/swap/liquidity_pool.move

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ module liquidswap::liquidity_pool {
108108
ERR_INVALID_CURVE
109109
);
110110

111-
let (lp_mint_cap, lp_burn_cap) = coin::initialize<LP>(
111+
let (lp_burn_cap, lp_freeze_cap, lp_mint_cap) = coin::initialize<LP>(
112112
owner,
113113
lp_name,
114114
lp_symbol,
115115
6,
116116
true
117117
);
118+
coin::destroy_freeze_cap(lp_freeze_cap);
118119

119120
let x_scale = 0;
120121
let y_scale = 0;

sources/test_helpers/test_coins.move

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ module test_coin_admin::test_coins {
1717
}
1818

1919
// Register one coin with custom details.
20-
public fun register_coin<CoinType>(coin_admin: &signer, name: vector<u8>, symbol: vector<u8>, decimals: u64) {
21-
let (mint_cap, burn_cap) = coin::initialize<CoinType>(
20+
public fun register_coin<CoinType>(coin_admin: &signer, name: vector<u8>, symbol: vector<u8>, decimals: u8) {
21+
let (burn_cap, freeze_cap, mint_cap, ) = coin::initialize<CoinType>(
2222
coin_admin,
2323
utf8(name),
2424
utf8(symbol),
2525
decimals,
2626
true,
2727
);
28+
coin::destroy_freeze_cap(freeze_cap);
2829

2930
move_to(coin_admin, Capabilities<CoinType> {
3031
mint_cap,
@@ -34,7 +35,7 @@ module test_coin_admin::test_coins {
3435

3536
// Register all known coins in one func.
3637
public fun register_coins(coin_admin: &signer) {
37-
let (usdt_mint_cap, usdt_burn_cap) =
38+
let (usdt_burn_cap, usdt_freeze_cap, usdt_mint_cap) =
3839
coin::initialize<USDT>(
3940
coin_admin,
4041
utf8(b"USDT"),
@@ -43,7 +44,7 @@ module test_coin_admin::test_coins {
4344
true
4445
);
4546

46-
let (btc_mint_cap, btc_burn_cap) =
47+
let (btc_burn_cap, btc_freeze_cap, btc_mint_cap) =
4748
coin::initialize<BTC>(
4849
coin_admin,
4950
utf8(b"BTC"),
@@ -52,7 +53,7 @@ module test_coin_admin::test_coins {
5253
true
5354
);
5455

55-
let (usdc_mint_cap, usdc_burn_cap) =
56+
let (usdc_burn_cap, usdc_freeze_cap, usdc_mint_cap) =
5657
coin::initialize<USDC>(
5758
coin_admin,
5859
utf8(b"USDC"),
@@ -75,6 +76,10 @@ module test_coin_admin::test_coins {
7576
mint_cap: usdc_mint_cap,
7677
burn_cap: usdc_burn_cap,
7778
});
79+
80+
coin::destroy_freeze_cap(usdt_freeze_cap);
81+
coin::destroy_freeze_cap(usdc_freeze_cap);
82+
coin::destroy_freeze_cap(btc_freeze_cap);
7883
}
7984

8085
public fun mint<CoinType>(coin_admin: &signer, amount: u64): Coin<CoinType> acquires Capabilities {

sources/test_helpers/test_lp.move

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ module test_pool_owner::test_lp {
2020
}
2121

2222
public fun register_lp_for_fails(pool_owner: &signer) {
23-
let (mint_cap, burn_cap) =
23+
let (burn_cap, freeze_cap, mint_cap) =
2424
coin::initialize<LP>(
2525
pool_owner,
2626
utf8(b"LP"),
2727
utf8(b"LP"),
2828
6,
2929
true
3030
);
31+
coin::destroy_freeze_cap(freeze_cap);
3132

3233
move_to(pool_owner, Capabilities<LP> { mint_cap, burn_cap });
3334
}

tests/coin_helper_tests.move

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module liquidswap::coin_helper_tests {
99
use test_helpers::test_account::create_account;
1010
use test_coin_admin::test_coins::{Self, BTC, USDT};
1111

12-
#[test(core = @core_resources, coin_admin = @test_coin_admin)]
13-
fun test_end_to_end(core: signer, coin_admin: signer) {
14-
genesis::setup(&core);
12+
#[test(coin_admin = @test_coin_admin)]
13+
fun test_end_to_end(coin_admin: signer) {
14+
genesis::setup();
1515
create_account(&coin_admin);
1616

1717
test_coins::register_coins(&coin_admin);
@@ -47,10 +47,10 @@ module liquidswap::coin_helper_tests {
4747
coin_helper::assert_is_coin<USDT>();
4848
}
4949

50-
#[test(core = @core_resources, coin_admin = @test_coin_admin)]
50+
#[test(coin_admin = @test_coin_admin)]
5151
#[expected_failure(abort_code = 3000)]
52-
fun test_cant_be_same_coin_failure(core: signer, coin_admin: signer) {
53-
genesis::setup(&core);
52+
fun test_cant_be_same_coin_failure(coin_admin: signer) {
53+
genesis::setup();
5454
create_account(&coin_admin);
5555

5656
test_coins::register_coins(&coin_admin);
@@ -59,9 +59,9 @@ module liquidswap::coin_helper_tests {
5959
let _ = coin_helper::is_sorted<USDT, USDT>();
6060
}
6161

62-
#[test(core = @core_resources, coin_admin = @test_coin_admin)]
63-
fun generate_lp_name(core: signer, coin_admin: signer) {
64-
genesis::setup(&core);
62+
#[test(coin_admin = @test_coin_admin)]
63+
fun generate_lp_name(coin_admin: signer) {
64+
genesis::setup();
6565
create_account(&coin_admin);
6666

6767
test_coins::register_coins(&coin_admin);

tests/dao_storage_tests.move

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ module liquidswap::dao_storage_tests {
1515
use test_pool_owner::test_lp::LP;
1616
use test_helpers::test_account::create_account;
1717

18-
#[test(core = @core_resources, pool_owner = @test_pool_owner)]
19-
fun test_register(core: signer, pool_owner: signer) {
20-
genesis::setup(&core);
18+
#[test(pool_owner = @test_pool_owner)]
19+
fun test_register(pool_owner: signer) {
20+
genesis::setup();
2121

2222
create_account(&pool_owner);
2323

@@ -28,9 +28,9 @@ module liquidswap::dao_storage_tests {
2828
assert!(y_val == 0, 1);
2929
}
3030

31-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner)]
32-
fun test_deposit(core: signer, coin_admin: signer, pool_owner: signer) {
33-
genesis::setup(&core);
31+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner)]
32+
fun test_deposit(coin_admin: signer, pool_owner: signer) {
33+
genesis::setup();
3434

3535
create_account(&coin_admin);
3636
create_account(&pool_owner);
@@ -52,10 +52,10 @@ module liquidswap::dao_storage_tests {
5252
assert!(y_val == 1000000, 3);
5353
}
5454

55-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner)]
55+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner)]
5656
#[expected_failure(abort_code = 401)]
57-
fun test_deposit_fail_if_not_registered(core: signer, coin_admin: signer, pool_owner: signer) {
58-
genesis::setup(&core);
57+
fun test_deposit_fail_if_not_registered(coin_admin: signer, pool_owner: signer) {
58+
genesis::setup();
5959

6060
create_account(&coin_admin);
6161
create_account(&pool_owner);
@@ -69,9 +69,9 @@ module liquidswap::dao_storage_tests {
6969
dao_storage::deposit_for_test<BTC, USDT, LP>(pool_owner_addr, btc_coins, usdt_coins);
7070
}
7171

72-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
73-
fun test_withdraw(core: signer, coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
74-
genesis::setup(&core);
72+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
73+
fun test_withdraw(coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
74+
genesis::setup();
7575

7676
create_account(&coin_admin);
7777
create_account(&pool_owner);
@@ -99,10 +99,10 @@ module liquidswap::dao_storage_tests {
9999
test_coins::burn(&coin_admin, y);
100100
}
101101

102-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
103-
#[expected_failure(abort_code = 65541)]
104-
fun test_withdraw_fail_if_more_deposited(core: signer, coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
105-
genesis::setup(&core);
102+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
103+
#[expected_failure(abort_code = 65542)]
104+
fun test_withdraw_fail_if_more_deposited(coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
105+
genesis::setup();
106106

107107
create_account(&coin_admin);
108108
create_account(&pool_owner);
@@ -124,10 +124,10 @@ module liquidswap::dao_storage_tests {
124124
test_coins::burn(&coin_admin, y);
125125
}
126126

127-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @0x09)]
127+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @0x09)]
128128
#[expected_failure(abort_code = 402)]
129-
fun test_withdraw_fail_if_not_dao_admin(core: signer, coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
130-
genesis::setup(&core);
129+
fun test_withdraw_fail_if_not_dao_admin(coin_admin: signer, pool_owner: signer, dao_admin_acc: signer) {
130+
genesis::setup();
131131

132132
create_account(&coin_admin);
133133
create_account(&pool_owner);
@@ -149,14 +149,13 @@ module liquidswap::dao_storage_tests {
149149
test_coins::burn(&coin_admin, y);
150150
}
151151

152-
#[test(core = @core_resources, coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
152+
#[test(coin_admin = @test_coin_admin, pool_owner = @test_pool_owner, dao_admin_acc = @dao_admin)]
153153
fun test_split_third_of_fees_into_dao_storage_account(
154-
core: signer,
155154
coin_admin: signer,
156155
pool_owner: signer,
157156
dao_admin_acc: signer,
158157
) {
159-
genesis::setup(&core);
158+
genesis::setup();
160159

161160
create_account(&coin_admin);
162161
create_account(&pool_owner);

0 commit comments

Comments
 (0)