From 05ef9dd79e045dc5163abc206e387ccd048d018f Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Wed, 20 Nov 2024 19:03:16 +0800 Subject: [PATCH] Add comments --- apps/sdks-playground/src/App.tsx | 3 +++ packages/sdk-bridge/src/lnbridge-v2-default.ts | 18 ++++++++++++++++++ .../sdk-bridge/src/lnbridge-v2-opposite.ts | 7 +++++++ packages/sdk-bridge/src/lnbridge-v3.ts | 17 +++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/apps/sdks-playground/src/App.tsx b/apps/sdks-playground/src/App.tsx index 521b2eec..c71d2d78 100644 --- a/apps/sdks-playground/src/App.tsx +++ b/apps/sdks-playground/src/App.tsx @@ -184,6 +184,8 @@ function App() { } }; + const handleLnV3Register = async () => {}; + return ( <>
@@ -204,6 +206,7 @@ function App() {

Click on the Vite and React logos to learn more

+ ); } diff --git a/packages/sdk-bridge/src/lnbridge-v2-default.ts b/packages/sdk-bridge/src/lnbridge-v2-default.ts index 20ef191e..73acf639 100644 --- a/packages/sdk-bridge/src/lnbridge-v2-default.ts +++ b/packages/sdk-bridge/src/lnbridge-v2-default.ts @@ -46,6 +46,11 @@ export class LnBridgeV2Default extends LnBridgeV2 { return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Deposit margin + * @param margin - Amount in target token + * @returns TransactionReceipt + */ async depositMargin(margin: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; @@ -62,6 +67,12 @@ export class LnBridgeV2Default extends LnBridgeV2 { return this.targetPublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Update fee and rate + * @param baseFee - Base fee in source token + * @param feeRate - Fee rate in percentage (0-100) + * @returns TransactionReceipt + */ async updateFeeAndRate(baseFee: bigint, feeRate: number) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; @@ -77,6 +88,13 @@ export class LnBridgeV2Default extends LnBridgeV2 { return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Withdraw margin + * @param recipientOrParams - Recipient address or params + * @param amount - Amount in source token + * @param fee - Fee in source native token + * @returns TransactionReceipt + */ async withdrawMargin(recipientOrParams: Address | Hash, amount: bigint, fee: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; diff --git a/packages/sdk-bridge/src/lnbridge-v2-opposite.ts b/packages/sdk-bridge/src/lnbridge-v2-opposite.ts index 16dc4c5f..c03b7c13 100644 --- a/packages/sdk-bridge/src/lnbridge-v2-opposite.ts +++ b/packages/sdk-bridge/src/lnbridge-v2-opposite.ts @@ -46,6 +46,13 @@ export class LnBridgeV2Opposite extends LnBridgeV2 { return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Update fee rate and margin + * @param baseFee - Base fee in source token + * @param feeRate - Fee rate in percentage (0-100) + * @param margin - Margin in source token + * @returns TransactionReceipt + */ async updateFeeRateMargin(baseFee: bigint, feeRate: number, margin: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; diff --git a/packages/sdk-bridge/src/lnbridge-v3.ts b/packages/sdk-bridge/src/lnbridge-v3.ts index 4a6fba3c..ff3475a2 100644 --- a/packages/sdk-bridge/src/lnbridge-v3.ts +++ b/packages/sdk-bridge/src/lnbridge-v3.ts @@ -55,6 +55,13 @@ export class LnBridgeV3 extends LnBridge { return { value, token: this.sourceToken }; } + /** + * Register LnProvider + * @param baseFee - Base fee in source token + * @param feeRate - Fee rate in percentage (0-100) + * @param transferLimit - Transfer limit in source token + * @returns TransactionReceipt + */ async register(baseFee: bigint, feeRate: number, transferLimit: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; @@ -77,6 +84,11 @@ export class LnBridgeV3 extends LnBridge { return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Deposit penalty reserve + * @param amount - Amount in source token + * @returns TransactionReceipt + */ async depositPenaltyReserve(amount: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0]; @@ -93,6 +105,11 @@ export class LnBridgeV3 extends LnBridge { return this.sourcePublicClient.waitForTransactionReceipt({ hash, confirmations: DEFAULT_CONFIRMATIONS }); } + /** + * Withdraw penalty reserve + * @param amount - Amount in source token + * @returns TransactionReceipt + */ async withdrawPenaltyReserve(amount: bigint) { assert(this.walletClient, "Wallet client is required"); const signer = (await this.walletClient.getAddresses())[0];