feat: build transaction to update pool Fee#1
Conversation
| function assetToDottedString(asset: { policyId: string; tokenName: string }): string { | ||
| if (asset.policyId === "" && asset.tokenName === "") { | ||
| return "lovelace" | ||
| } | ||
| if (asset.tokenName === "") { | ||
| return asset.policyId; | ||
| } | ||
| return `${asset.policyId}.${asset.tokenName}`; | ||
| } |
There was a problem hiding this comment.
This should utilise the toUnit from the @lucid-evolution package
| const seed = | ||
| 'mouse carpet zebra giant just pizza very song simple state rebel lunar above naive bundle accuse buffalo hurry mango scorpion country silly layer average'; |
There was a problem hiding this comment.
Let's move this out of source control into a gitignored .env
| const walletAddr = | ||
| 'addr_test1qz280luwccrquk3lk4ykjjsexl840ppsy2u6vtq4wflwa2c279l7xk8kwpt4zc27c4dsngvpyuqn700m3s8e0k6fw9nsdudnqx'; |
There was a problem hiding this comment.
This should be derived from the seed. I.e. after lucid initialisation from the seed, get the address from the lucid instance.
| const poolLPAsset = { | ||
| policyId: 'd6aae2059baee188f74917493cf7637e679cd219bdfbbf4dcbeb1d0b', | ||
| tokenName: | ||
| '0c9dfded2857d530ce2cc536d4517a6e4c54e280f5e89b4f315fe0d81cabbcf5', | ||
| }; |
There was a problem hiding this comment.
Let's pass only the token name to the tx building, and let the tx building pick the right LP policy from the constant there.
| poolLPAsset: { | ||
| policyId: string, | ||
| tokenName: string | ||
| }; |
There was a problem hiding this comment.
As mentioned above, this should be only a token name.
| }; | ||
|
|
||
| export type RequestPoolFeeOptions = { | ||
| request: Omit<PoolFeeRequest, "version">; |
There was a problem hiding this comment.
I'm curious what the reason is for omitting the version field?
| @@ -0,0 +1,110 @@ | |||
| import { getAddressDetails, LucidEvolution, TxBuilder } from "@lucid-evolution/lucid"; | |||
| import JSONBig from "json-bigint" | |||
There was a problem hiding this comment.
Aaa, this is nice, didn't know about this package, thanks.
| newFeeA: 0.9, | ||
| newFeeB: 0.3, |
There was a problem hiding this comment.
Let's maybe rename these parameters to newFeeAPercent and newFeeBPercent so it's semantically clear. AFAIK these parameters set the fee for A and B to 0.9% and 0.3% respectively.
| `Liquidity Pool Fee A must be in 0.05% - 20%, actual: ${newFeeA}%` | ||
| ); | ||
| } | ||
| if (newFeeBBps < MIN_TRADING_FEE || newFeeBBps > MAX_TRADING_FEE) { | ||
| throw new Error( | ||
| `Liquidity Pool Fee B must be in 0.05% - 20%, actual: ${newFeeB}%` |
There was a problem hiding this comment.
Ideally, use the MIN_TRADING_FEE and MAX_TRADING_FEE constants in both of those error logs.
| return lucid | ||
| .newTx() | ||
| .addSigner(managerAddress) | ||
| .attachMetadata(674, { | ||
| ["msg"]: ["Minswap: Request of Pool Fee Manager"], | ||
| ["extraData"]: feeRequestJSON, | ||
| }); |
No description provided.