biatec-concentrated-liquidity-amm 0.9.34 โ†’ 0.9.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,108 +1,226 @@
1
- # Biatec
2
-
3
- First gold and silver coins in usage at 500 BC to 100 BC around Bratislava area were minted with label BIATEC. Slovak National Bank used the Biatec coin image on the official slovak fiat currency before EUR was adopted.
4
-
5
- We believe that Algorand and whole AVM ecosystem provides new form of digital identity and payments solutions. The brand name Biatec creates for us historic narrative as we live now the historic moments of early crypto adoption.
6
-
7
- Algorand is novel distributed ledger technology (DLT) which does not fork because of efficiency of PPoS. It provides instant transaction finality, sub 3 second economic finality and has highest AMM swap throughput. Users do not pay for failed transactions and each transfer of value even in milions costs less then a penny.
8
-
9
- [www.biatec.io](https://www.biatec.io)
10
-
11
- ## Biatec DEX
12
-
13
- We are building DEX like solution which will utilize the Automated Market Maker smart contracts, mainly the Concentrated liquidity AMM algorithm.
14
-
15
- This work has been performed with support from the Algorand Foundation xGov Grants Program - [xGov#80](https://github.com/algorandfoundation/xGov/blob/main/Proposals/xgov-80.md).
16
-
17
- ## Biatec Concentrated Liquidity Smart Contract
18
-
19
- This repo is dedicated to Biatec CL AMM Smart contract.
20
-
21
- ## Tests
22
-
23
- ![Tests](https://raw.githubusercontent.com/scholtz/BiatecCLAMM/main/img/tests.png)
24
-
25
- ## NPM package
26
-
27
- ```
28
- npm i biatec-concentrated-liquidity-amm
29
- ```
30
-
31
- ## Examples
32
-
33
- ## Add liquidity
34
-
35
- ```
36
- import {clientBiatecClammPool, clammAddLiquiditySender} from "biatec-concentrated-liquidity-amm"
37
-
38
- const client = clientBiatecClammPool({
39
- appId: .. ,
40
- sender: ..;
41
- algod: ..;
42
- })
43
- const txId = await clammAddLiquiditySender({
44
- clientBiatecClammPool,
45
- account: TransactionSignerAccount,
46
- algod: algosdk.Algodv2,
47
-
48
- appBiatecConfigProvider: bigint,
49
- appBiatecIdentityProvider: bigint,
50
- assetA: bigint,
51
- assetB: bigint,
52
- assetLP: bigint,
53
-
54
- assetADeposit: bigint,
55
- assetBDeposit: bigint,
56
- })
57
- ```
58
-
59
- ## SWAP
60
-
61
- ```
62
- import {clientBiatecClammPool, clammSwapSender} from "biatec-concentrated-liquidity-amm"
63
-
64
- const client = clientBiatecClammPool({
65
- appId: .. ,
66
- sender: ..;
67
- algod: ..;
68
- })
69
- const txId = await clammSwapSender({
70
- clientBiatecClammPool: BiatecClammPoolClient;
71
- account: TransactionSignerAccount;
72
- algod: algosdk.Algodv2;
73
-
74
- appBiatecConfigProvider: bigint;
75
- appBiatecIdentityProvider: bigint;
76
- assetA: bigint;
77
- assetB: bigint;
78
- assetLP: bigint;
79
-
80
- assetADeposit: bigint;
81
- assetBDeposit: bigint;
82
- })
83
- ```
84
-
85
- ## Remove liquidity and collect fees
86
-
87
- ```
88
- import {clientBiatecClammPool, clammRemoveLiquiditySender} from "biatec-concentrated-liquidity-amm"
89
-
90
- const client = clientBiatecClammPool({
91
- appId: .. ,
92
- sender: ..;
93
- algod: ..;
94
- })
95
- const txId = await clammRemoveLiquiditySender({
96
- clientBiatecClammPool: BiatecClammPoolClient;
97
- account: TransactionSignerAccount;
98
- algod: algosdk.Algodv2;
99
-
100
- appBiatecConfigProvider: bigint;
101
- appBiatecIdentityProvider: bigint;
102
- assetA: bigint;
103
- assetB: bigint;
104
- assetLP: bigint;
105
-
106
- lpToSend: bigint;
107
- })
108
- ```
1
+ # Biatec
2
+
3
+ First gold and silver coins in usage at 500 BC to 100 BC around Bratislava area were minted with label BIATEC. Slovak National Bank used the Biatec coin image on the official slovak fiat currency before EUR was adopted.
4
+
5
+ We believe that Algorand and whole AVM ecosystem provides new form of digital identity and payments solutions. The brand name Biatec creates for us historic narrative as we live now the historic moments of early crypto adoption.
6
+
7
+ Algorand is novel distributed ledger technology (DLT) which does not fork because of efficiency of PPoS. It provides instant transaction finality, sub 3 second economic finality and has highest AMM swap throughput. Users do not pay for failed transactions and each transfer of value even in milions costs less then a penny.
8
+
9
+ [www.biatec.io](https://www.biatec.io)
10
+
11
+ ## Biatec DEX
12
+
13
+ We are building DEX like solution which will utilize the Automated Market Maker smart contracts, mainly the Concentrated liquidity AMM algorithm.
14
+
15
+ This work has been performed with support from the Algorand Foundation xGov Grants Program - [xGov#80](https://github.com/algorandfoundation/xGov/blob/main/Proposals/xgov-80.md).
16
+
17
+ ## Biatec Concentrated Liquidity Smart Contract
18
+
19
+ This repo is dedicated to Biatec CL AMM Smart contract.
20
+
21
+ ## Tests
22
+
23
+ ![Tests](https://raw.githubusercontent.com/scholtz/BiatecCLAMM/main/img/tests.png)
24
+
25
+ ## NPM package
26
+
27
+ ```
28
+ npm i biatec-concentrated-liquidity-amm
29
+ ```
30
+
31
+ ## Examples
32
+
33
+ ### Retrieve deployed app IDs
34
+
35
+ ```ts
36
+ import { getConfig } from 'biatec-concentrated-liquidity-amm';
37
+
38
+ const { configAppId, identityAppId, poolProviderAppId } = getConfig('testnet-v1.0');
39
+ ```
40
+
41
+ Supported genesis IDs are `mainnet-v1.0`, `voimain-v1.0`, and `testnet-v1.0`. The helper throws if you pass an unsupported network so deployments stay explicit.
42
+
43
+ ## Add liquidity
44
+
45
+ ```
46
+ import {clientBiatecClammPool, clammAddLiquiditySender} from "biatec-concentrated-liquidity-amm"
47
+
48
+ const client = clientBiatecClammPool({
49
+ appId: .. ,
50
+ sender: ..;
51
+ algod: ..;
52
+ })
53
+ const txId = await clammAddLiquiditySender({
54
+ clientBiatecClammPool,
55
+ account: TransactionSignerAccount,
56
+ algod: algosdk.Algodv2,
57
+
58
+ appBiatecConfigProvider: bigint,
59
+ appBiatecIdentityProvider: bigint,
60
+ assetA: bigint,
61
+ assetB: bigint,
62
+ assetLP: bigint,
63
+
64
+ assetADeposit: bigint,
65
+ assetBDeposit: bigint,
66
+ })
67
+ ```
68
+
69
+ ## SWAP
70
+
71
+ ```
72
+ import {clientBiatecClammPool, clammSwapSender} from "biatec-concentrated-liquidity-amm"
73
+
74
+ const client = clientBiatecClammPool({
75
+ appId: .. ,
76
+ sender: ..;
77
+ algod: ..;
78
+ })
79
+ const txId = await clammSwapSender({
80
+ clientBiatecClammPool: BiatecClammPoolClient;
81
+ account: TransactionSignerAccount;
82
+ algod: algosdk.Algodv2;
83
+
84
+ appBiatecConfigProvider: bigint;
85
+ appBiatecIdentityProvider: bigint;
86
+ assetA: bigint;
87
+ assetB: bigint;
88
+ assetLP: bigint;
89
+
90
+ assetADeposit: bigint;
91
+ assetBDeposit: bigint;
92
+ })
93
+ ```
94
+
95
+ ## Remove liquidity and collect fees
96
+
97
+ ```
98
+ import {clientBiatecClammPool, clammRemoveLiquiditySender} from "biatec-concentrated-liquidity-amm"
99
+
100
+ const client = clientBiatecClammPool({
101
+ appId: .. ,
102
+ sender: ..;
103
+ algod: ..;
104
+ })
105
+ const txId = await clammRemoveLiquiditySender({
106
+ clientBiatecClammPool: BiatecClammPoolClient;
107
+ account: TransactionSignerAccount;
108
+ algod: algosdk.Algodv2;
109
+
110
+ appBiatecConfigProvider: bigint;
111
+ appBiatecIdentityProvider: bigint;
112
+ assetA: bigint;
113
+ assetB: bigint;
114
+ assetLP: bigint;
115
+
116
+ lpToSend: bigint;
117
+ })
118
+ ```
119
+
120
+ ## Staking Pools (NEW)
121
+
122
+ BiatecCLAMM now supports staking pools where asset A and asset B are the same token. This enables creation of interest-bearing tokens like B-ALGO, B-USDC, etc.
123
+
124
+ ### Creating a Native Token Staking Pool (B-ALGO)
125
+
126
+ ```typescript
127
+ import { clammCreateSender } from 'biatec-concentrated-liquidity-amm';
128
+
129
+ await poolProviderClient.send.setNativeTokenName({
130
+ args: {
131
+ appBiatecConfigProvider: configAppId,
132
+ nativeTokenName: 'Algo',
133
+ },
134
+ appReferences: [configAppId],
135
+ });
136
+
137
+ const poolClient = await clammCreateSender({
138
+ transactionSigner: signerAccount,
139
+ clientBiatecPoolProvider: poolProviderClient,
140
+ appBiatecConfigProvider: configAppId,
141
+ assetA: 0n, // Native token (ALGO)
142
+ assetB: 0n, // Same as asset A
143
+ fee: 0n, // No fee
144
+ verificationClass: 0,
145
+ priceMin: BigInt(SCALE),
146
+ priceMax: BigInt(SCALE),
147
+ currentPrice: BigInt(SCALE),
148
+ });
149
+ ```
150
+
151
+ ### Distributing Staking Rewards
152
+
153
+ ```typescript
154
+ import { clammDistributeExcessAssetsSender } from 'biatec-concentrated-liquidity-amm';
155
+
156
+ // After rewards accrue to the pool (e.g., from consensus rewards)
157
+ // Note: rewardsAmount should already be in asset decimals (e.g., microAlgos)
158
+ // Convert to base scale (9 decimals) by multiplying with scale factor
159
+ const rewardsInBaseScale = (rewardsAmount * BigInt(SCALE)) / BigInt(assetDecimals);
160
+
161
+ const txId = await clammDistributeExcessAssetsSender({
162
+ algod,
163
+ account: executiveSigner,
164
+ amountA: rewardsInBaseScale, // Amount in base scale (9 decimals)
165
+ amountB: 0n,
166
+ appBiatecConfigProvider: configAppId,
167
+ assetA: 0n,
168
+ assetB: 0n,
169
+ clientBiatecClammPool: poolClient,
170
+ });
171
+ ```
172
+
173
+ For complete documentation, see [docs/staking-pools.md](docs/staking-pools.md).
174
+
175
+ ### Key Features:
176
+
177
+ - **Create Interest-Bearing Tokens**: Build B-ALGO, B-USDC, or any B-{TOKEN}
178
+ - **Support Multi-Chain Networks**: Works with ALGO, VOI, ARAMID chains
179
+ - **Distribute Rewards to LP Holders**: Share staking rewards, interest, or fees
180
+ - **Enable Flexible Use Cases**: Power lending protocols, yield aggregation, revenue sharing
181
+
182
+ ### Use Cases:
183
+
184
+ 1. **Native Token Staking**: B-ALGO pools for staking ALGO with consensus rewards
185
+ 2. **Asset Staking**: B-USDC pools for lending protocol interest
186
+ 3. **Revenue Sharing**: Distribute protocol fees to token holders
187
+ 4. **Yield Aggregation**: Combine multiple yield sources
188
+
189
+ ## Documentation
190
+
191
+ Comprehensive documentation is available in the `docs/` folder:
192
+
193
+ ### Core Documentation
194
+
195
+ - **[Basic Use Cases](docs/basic-use-cases.md)** - Getting started with pools, swaps, and liquidity
196
+ - **[Staking Pools](docs/staking-pools.md)** - Create B-ALGO, B-USDC interest-bearing tokens
197
+ - **[Integration Guide](docs/integration-guide.md)** - Best practices for integrating CLAMM into your application
198
+
199
+ ### Technical Details
200
+
201
+ - **[Liquidity Fee Protection](docs/liquidity-fee-protection.md)** - How fee accounting protects LPs
202
+ - **[Liquidity Rounding](docs/liquidity-rounding.md)** - Rounding behavior and user expectations
203
+ - **[Error Codes](docs/error-codes.md)** - Complete reference of all error messages
204
+
205
+ ### Security
206
+
207
+ - **[Security Audits](audits/)** - Multiple AI-powered security audit reports
208
+ - **[Integration Security](docs/integration-guide.md#security-considerations)** - Critical warnings for developers
209
+
210
+ ### Key Resources
211
+
212
+ - ๐Ÿ“– **Error Troubleshooting**: See [error-codes.md](docs/error-codes.md) for solutions
213
+ - ๐Ÿ” **Security Best Practices**: Review [integration-guide.md](docs/integration-guide.md) before deployment
214
+ - ๐Ÿงช **Testing**: Examples in `__test__/` folder show proper usage patterns
215
+ - ๐Ÿ›ก๏ธ **Audit Reports**: Six AI security audits in `audits/` folder
216
+
217
+ ## Security Considerations
218
+
219
+ โš ๏ธ **Important Security Notices**:
220
+
221
+ 1. **Price Oracle Usage**: Never use single pool VWAP as sole price source. See [integration guide](docs/integration-guide.md#using-clamm-as-price-oracle) for safe patterns.
222
+ 2. **Slippage Protection**: Always enforce minimum slippage (โ‰ฅ0.5%). Never use `minimumToReceive = 0`.
223
+ 3. **Identity Verification**: All operations require proper KYC verification class.
224
+ 4. **LP Token Rounding**: Small rounding losses (< 0.0001%) are expected. See [liquidity-rounding.md](docs/liquidity-rounding.md).
225
+
226
+ Multiple security audits have been conducted. Review the `audits/` folder before mainnet deployment.