From e687fe6abbb2691993d2bcc399c91de3c72d9a27 Mon Sep 17 00:00:00 2001 From: kstasi Date: Wed, 23 Jun 2021 10:50:17 +0300 Subject: [PATCH] simplify entrypoint names --- contracts/partials/ITTDex.ligo | 8 +++--- contracts/partials/TTDex.ligo | 8 +++--- contracts/partials/TTMethodDex.ligo | 32 +++++++++++------------ migrations/2_deploy_token_to_token_dex.js | 6 ++--- test/helpers/ttdexFA2.ts | 10 +++---- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/contracts/partials/ITTDex.ligo b/contracts/partials/ITTDex.ligo index b06e58ed..e7562a11 100644 --- a/contracts/partials/ITTDex.ligo +++ b/contracts/partials/ITTDex.ligo @@ -108,10 +108,10 @@ type divest_liquidity_params is ] type dex_action is -| InitializeExchange of invest_liquidity_params (* sets initial liquidity *) -| TokenToTokenRoutePayment of token_to_token_route_params (* exchanges token to another token and sends them to receiver *) -| InvestLiquidity of invest_liquidity_params (* mints min shares after investing tokens *) -| DivestLiquidity of divest_liquidity_params (* burns shares and sends tokens to the owner *) +| AddPair of invest_liquidity_params (* sets initial liquidity *) +| Swap of token_to_token_route_params (* exchanges token to another token and sends them to receiver *) +| Invest of invest_liquidity_params (* mints min shares after investing tokens *) +| Divest of divest_liquidity_params (* burns shares and sends tokens to the owner *) type use_params is dex_action type get_reserves_params is record [ diff --git a/contracts/partials/TTDex.ligo b/contracts/partials/TTDex.ligo index 202a96c8..7f0de231 100644 --- a/contracts/partials/TTDex.ligo +++ b/contracts/partials/TTDex.ligo @@ -15,10 +15,10 @@ based on the argument type. const s : full_dex_storage) : full_return is block { const idx : nat = case p of - | InitializeExchange(n) -> 0n - | TokenToTokenRoutePayment(n) -> 1n - | InvestLiquidity(n) -> 2n - | DivestLiquidity(n) -> 3n + | AddPair(n) -> 0n + | Swap(n) -> 1n + | Invest(n) -> 2n + | Divest(n) -> 3n end; const res : return = case s.dex_lambdas[idx] of Some(f) -> f(p, s.storage, this) diff --git a/contracts/partials/TTMethodDex.ligo b/contracts/partials/TTMethodDex.ligo index 18d795a7..2db8e171 100644 --- a/contracts/partials/TTMethodDex.ligo +++ b/contracts/partials/TTMethodDex.ligo @@ -195,7 +195,7 @@ function initialize_exchange( block { var operations: list(operation) := list[]; case p of - InitializeExchange(params) -> { + AddPair(params) -> { if s.entered then failwith("Dex/reentrancy") else s.entered := True; @@ -269,9 +269,9 @@ function initialize_exchange( params.pair.token_b_type ) # operations; } - | TokenToTokenRoutePayment(n) -> skip - | InvestLiquidity(n) -> skip - | DivestLiquidity(n) -> skip + | Swap(n) -> skip + | Invest(n) -> skip + | Divest(n) -> skip end } with (operations, s) @@ -350,8 +350,8 @@ function token_to_token_route( block { var operations: list(operation) := list[]; case p of - | InitializeExchange(n) -> skip - | TokenToTokenRoutePayment(params) -> { + | AddPair(n) -> skip + | Swap(params) -> { if s.entered then failwith("Dex/reentrancy") else s.entered := True; @@ -431,8 +431,8 @@ function token_to_token_route( end; operations := last_operation # operations; } - | InvestLiquidity(n) -> skip - | DivestLiquidity(n) -> skip + | Invest(n) -> skip + | Divest(n) -> skip end } with (operations, s) @@ -445,9 +445,9 @@ function invest_liquidity( block { var operations: list(operation) := list[]; case p of - | InitializeExchange(n) -> skip - | TokenToTokenRoutePayment(n) -> skip - | InvestLiquidity(params) -> { + | AddPair(n) -> skip + | Swap(n) -> skip + | Invest(params) -> { if s.entered then failwith("Dex/reentrancy") else s.entered := True; @@ -539,7 +539,7 @@ function invest_liquidity( params.pair.token_b_type ) # operations; } - | DivestLiquidity(n) -> skip + | Divest(n) -> skip end } with (operations, s) @@ -551,10 +551,10 @@ function divest_liquidity( block { var operations: list(operation) := list[]; case p of - | InitializeExchange(token_amount) -> skip - | TokenToTokenRoutePayment(n) -> skip - | InvestLiquidity(n) -> skip - | DivestLiquidity(params) -> { + | AddPair(token_amount) -> skip + | Swap(n) -> skip + | Invest(n) -> skip + | Divest(params) -> { if s.entered then failwith("Dex/reentrancy") else s.entered := True; diff --git a/migrations/2_deploy_token_to_token_dex.js b/migrations/2_deploy_token_to_token_dex.js index d435509e..9608a4dc 100644 --- a/migrations/2_deploy_token_to_token_dex.js +++ b/migrations/2_deploy_token_to_token_dex.js @@ -107,7 +107,7 @@ module.exports = async (deployer, network, accounts) => { operation = await dex.methods .use( - "initializeExchange", + "addPair", ordered ? token0Instance.address.toString() : token1Instance.address.toString(), @@ -154,7 +154,7 @@ module.exports = async (deployer, network, accounts) => { if (standard === "MIXED") { operation = await dex.methods .use( - "initializeExchange", + "addPair", ordered ? token0Instance.address.toString() : token1Instance.address.toString(), @@ -171,7 +171,7 @@ module.exports = async (deployer, network, accounts) => { } else { operation = await dex.methods .use( - "initializeExchange", + "addPair", ordered ? token0Instance.address.toString() : token1Instance.address.toString(), diff --git a/test/helpers/ttdexFA2.ts b/test/helpers/ttdexFA2.ts index 3f486421..45d195cf 100644 --- a/test/helpers/ttdexFA2.ts +++ b/test/helpers/ttdexFA2.ts @@ -119,7 +119,7 @@ export class TTDex extends TokenFA2 { const operation = await this.contract.methods .use( - "initializeExchange", + "addPair", tokenAAddress, tokenAid, standard.toLowerCase() == "mixed" ? "fa2" : standard.toLowerCase(), @@ -177,7 +177,7 @@ export class TTDex extends TokenFA2 { } } const operation = await this.contract.methods - .use("tokenToTokenRoutePayment", swaps, amountIn, minAmountOut, receiver) + .use("swap", swaps, amountIn, minAmountOut, receiver) .send(); await confirmOperation(tezos, operation.hash); return operation; @@ -246,7 +246,7 @@ export class TTDex extends TokenFA2 { }, ]; const operation = await this.contract.methods - .use("tokenToTokenRoutePayment", swaps, amountIn, minAmountOut, receiver) + .use("swap", swaps, amountIn, minAmountOut, receiver) .send(); await confirmOperation(tezos, operation.hash); return operation; @@ -291,7 +291,7 @@ export class TTDex extends TokenFA2 { } const operation = await this.contract.methods .use( - "investLiquidity", + "invest", pair.token_a_address, pair.token_a_id, standard.toLowerCase() == "mixed" ? "fa2" : standard.toLowerCase(), @@ -319,7 +319,7 @@ export class TTDex extends TokenFA2 { let pair = this.storage.tokens[pairId]; const operation = await this.contract.methods .use( - "divestLiquidity", + "divest", pair.token_a_address, pair.token_a_id, standard.toLowerCase() == "mixed" ? "fa2" : standard.toLowerCase(),