Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run generate prisma
run: pnpm run prisma:generate
- name: Run build
run: pnpm run build
- name: Run test
Expand Down
9 changes: 3 additions & 6 deletions docs/dex-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ This documentation provides details on how to interact with the **Stableswap** a
- All utility functions are located in the [Calculate](../src/calculate.ts) file. These functions provide the necessary calculations for operations such as trades, deposits, and withdrawals related to the DEX V2 and Stable Liquidity Pool.
- You can combine these utility functions with the [Slippage](../src/utils/slippage.internal.ts) file to manage volatile liquidity pools efficiently.

### Batcher Fee Discount
### Batcher Fee

Currently, everyone who swaps on the Minswap DEX pays a 2 $ADA fee to execute the DEX order. To increase the utility of the $MIN token within the platform, $MIN holders are entitled to a discount on this 2 $ADA Batcher Fee. More details about this can be found in the [Minswap Official Docs](https://docs.minswap.org/min-token/usdmin-tokenomics/trading-fee-discount).

Technically, the Batcher Fee Discount is calculated based on the ADA-MIN LP Tokens and MIN tokens that users are holding. This calculation is handled by the [BatcherFee.finalizeFee](../src/batcher-fee-reduction/calculate.ts#L11) function.

If you are transacting through the `Stableswap` or `DexV2` classes, the transaction is automatically constructed with the Batcher Fee Discount if you are eligible for it.
- Currently, every swap on the Minswap DEX incurs a 2 ADA fee for store UTXO order. It will be refunded after the transaction is completed.

- Additionally, building a transaction requires a Batcher Fee, which is defined in [BatcherFee](../src/batcher-fee/configs.internal.ts).
---

## Example Usage
Expand Down
28 changes: 5 additions & 23 deletions examples/build-tx-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ export async function _createPoolV2(
assetA: ADA,
assetB: {
// Replace with your asset
policyId: "997322483e052b1c2e42447fca9261427c6214bb14288a0ac4651fa7",
tokenName: "6c7031",
policyId: "a99569ec232f6b5ce2d81045417af541addca3c44de01be882b394ee",
tokenName: "4c505f544f4b454e",
},
amountA: 10_000000n,
amountB: 30_000n,
Expand All @@ -343,7 +343,6 @@ export async function _swapExactInV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand All @@ -368,7 +367,6 @@ export async function _swapExactInV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos: availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.SWAP_EXACT_IN,
Expand All @@ -388,7 +386,6 @@ export async function _swapExactOutV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand All @@ -413,7 +410,6 @@ export async function _swapExactOutV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos: availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.SWAP_EXACT_OUT,
Expand All @@ -432,7 +428,6 @@ export async function _depositV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand All @@ -457,7 +452,6 @@ export async function _depositV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.DEPOSIT,
Expand All @@ -477,7 +471,6 @@ export async function _withdrawV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
// ADA-MIN Lp Asset
const lpAsset = {
Expand Down Expand Up @@ -510,7 +503,6 @@ export async function _withdrawV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.WITHDRAW,
Expand All @@ -528,7 +520,6 @@ export async function _stopV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand All @@ -552,7 +543,6 @@ export async function _stopV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.STOP,
Expand All @@ -570,7 +560,6 @@ export async function _ocoV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand Down Expand Up @@ -611,15 +600,13 @@ export async function _ocoV2TxExample(
direction: OrderV2.Direction.A_TO_B,
},
],
availableUtxos,
});
}

export async function _zapOutV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
// ADA-MIN Lp Asset
const lpAsset = {
Expand All @@ -644,7 +631,6 @@ export async function _zapOutV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.ZAP_OUT,
Expand All @@ -662,7 +648,6 @@ export async function _partialSwapV2TxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = ADA;
const assetB = MIN;
Expand All @@ -689,7 +674,6 @@ export async function _partialSwapV2TxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.PARTIAL_SWAP,
Expand All @@ -714,7 +698,6 @@ export async function _multiRoutingTxExample(
lucid: Lucid,
adapter: Adapter,
address: string,
availableUtxos: Utxo[]
): Promise<TxComplete> {
const assetA = MIN;
const amountA = 10_000n;
Expand Down Expand Up @@ -771,7 +754,6 @@ export async function _multiRoutingTxExample(

return new DexV2(lucid, adapter).createBulkOrdersTx({
sender: address,
availableUtxos,
orderOptions: [
{
type: OrderV2.StepType.SWAP_ROUTING,
Expand Down Expand Up @@ -882,7 +864,7 @@ export async function _depositStableExample(

// This pool has 2 assets in its config. They are [tDJED, tiUSD].
// This order deposits 100_000n tDJED and 1_000n tiUSD into the pool.
const amountIns = [20_000n, 20_000n];
const amountIns = [1_000n, 1_000n];

const lpAmount = StableswapCalculation.calculateDeposit({
amountIns: amountIns,
Expand All @@ -903,8 +885,8 @@ export async function _depositStableExample(
lpAsset: lpAsset,
type: StableOrder.StepType.DEPOSIT,
assetsAmount: [
[Asset.fromString(pool.assets[0]), 20_000n],
[Asset.fromString(pool.assets[1]), 20_000n],
[Asset.fromString(pool.assets[0]), 1_000n],
[Asset.fromString(pool.assets[1]), 1_000n],
],
minimumLPReceived: lpAmount,
totalLiquidity: pool.totalLiquidity,
Expand Down
114 changes: 0 additions & 114 deletions src/batcher-fee-reduction/calculate.ts

This file was deleted.

Loading
Loading