Skip to content

Commit

Permalink
removed custom names for LP coins, updated to devnet (really to mainn…
Browse files Browse the repository at this point in the history
…et) (#90)
  • Loading branch information
borispovod authored Sep 16, 2022
1 parent 66bfbb3 commit 3b8c884
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 159 deletions.
12 changes: 1 addition & 11 deletions Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@ test_coin_admin = "0x11"
test_pool_owner = "0x12"
test_helpers = "0x12"

[dependencies.MoveStdlib]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "8f634bcd2e48c4972868d0053d3532f4f760ae19"
subdir = "aptos-move/framework/move-stdlib"

[dependencies.AptosStdlib]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "8f634bcd2e48c4972868d0053d3532f4f760ae19"
subdir = "aptos-move/framework/aptos-stdlib"

[dependencies.AptosFramework]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "8f634bcd2e48c4972868d0053d3532f4f760ae19"
rev = "devnet"
subdir = "aptos-move/framework/aptos-framework"

[dependencies.UQ64x64]
Expand Down
13 changes: 0 additions & 13 deletions sources/libs/coin_helper.move
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// The `CoinHelper` module contains helper funcs to work with `AptosFramework::Coin` module.
module liquidswap::coin_helper {
use std::option;
use std::string::{Self, String, bytes};
use std::vector;

use aptos_framework::coin;
use aptos_std::comparator::{Self, Result};
Expand Down Expand Up @@ -50,15 +48,4 @@ module liquidswap::coin_helper {
public fun supply<CoinType>(): u128 {
option::extract(&mut coin::supply<CoinType>())
}

/// Generate LP coin name for pair `X`/`Y`.
/// Returns generated symbol and name (`symbol<X>()` + "-" + `symbol<Y>()`).
public fun generate_lp_name<X, Y>(): (String, String) {
let symbol = b"LP-";
vector::append(&mut symbol, *bytes(&coin::symbol<X>()));
vector::push_back(&mut symbol, 0x2d);
vector::append(&mut symbol, *bytes(&coin::symbol<Y>()));

(string::utf8(b"Liquidswap LP"), string::utf8(symbol))
}
}
8 changes: 3 additions & 5 deletions sources/swap/liquidity_pool.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Liquidswap liquidity pool module.
/// Implements mint/burn liquidity, swap of coins.
module liquidswap::liquidity_pool {
use std::string::String;
use std::string::utf8;
use std::signer;

use uq64x64::uq64x64;
Expand Down Expand Up @@ -92,8 +92,6 @@ module liquidswap::liquidity_pool {
/// * `curve_type` - pool curve type: 1 = stable, 2 = uncorrelated (uniswap like).
public fun register<X, Y, LP>(
owner: &signer,
lp_name: String,
lp_symbol: String,
curve_type: u8
) {
assert_no_emergency();
Expand All @@ -111,8 +109,8 @@ module liquidswap::liquidity_pool {

let (lp_burn_cap, lp_freeze_cap, lp_mint_cap) = coin::initialize<LP>(
owner,
lp_name,
lp_symbol,
utf8(b"Liquidswap LP"),
utf8(b"LP"),
6,
true
);
Expand Down
6 changes: 2 additions & 4 deletions sources/swap/router.move
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ module liquidswap::router {
/// * `curve_type` - pool curve type: 1 = stable, 2 = uncorrelated (uniswap like).
public fun register_pool<X, Y, LP>(account: &signer, curve_type: u8) {
if (coin_helper::is_sorted<X, Y>()) {
let (lp_name, lp_symbol) = coin_helper::generate_lp_name<X, Y>();
liquidity_pool::register<X, Y, LP>(account, lp_name, lp_symbol, curve_type);
liquidity_pool::register<X, Y, LP>(account, curve_type);
} else {
let (lp_name, lp_symbol) = coin_helper::generate_lp_name<Y, X>();
liquidity_pool::register<Y, X, LP>(account, lp_name, lp_symbol, curve_type);
liquidity_pool::register<Y, X, LP>(account, curve_type);
}
}

Expand Down
14 changes: 0 additions & 14 deletions tests/coin_helper_tests.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[test_only]
module liquidswap::coin_helper_tests {
use std::string::utf8;

use aptos_std::comparator;
use aptos_framework::genesis;

Expand Down Expand Up @@ -59,16 +57,4 @@ module liquidswap::coin_helper_tests {
coin_helper::assert_is_coin<USDT>();
let _ = coin_helper::is_sorted<USDT, USDT>();
}

#[test(coin_admin = @test_coin_admin)]
fun generate_lp_name(coin_admin: signer) {
genesis::setup();
create_account(&coin_admin);

test_coins::register_coins(&coin_admin);

let (lp_name, lp_symbol) = coin_helper::generate_lp_name<BTC, USDT>();
assert!(lp_name == utf8(b"Liquidswap LP"), 0);
assert!(lp_symbol == utf8(b"LP-BTC-USDT"), 1);
}
}
Loading

0 comments on commit 3b8c884

Please sign in to comment.