@ -10,7 +10,7 @@ import { faBullhorn, faExclamationTriangle, faUsers } from '@fortawesome/free-so
import { DataService } from '../../../shared/services/data.service' ;
import { LoggerService } from '../../../shared/services/logger.service' ;
import { CommonService } from '../../../shared/services/common.service' ;
import { AlertTypeEnum , APICallStatusEnum , DataTypeEnum , getPaginatorLabel , PAGE_SIZE , PAGE_SIZE_OPTIONS , ScreenSizeEnum , NODE_FEATURES_CLN } from '../../../shared/services/consts-enums-functions' ;
import { AlertTypeEnum , APICallStatusEnum , DataTypeEnum , getPaginatorLabel , PAGE_SIZE , PAGE_SIZE_OPTIONS , ScreenSizeEnum , NODE_FEATURES_CLN , SortOrderEnum , CLN_DEFAULT_PAGE_SETTINGS } from '../../../shared/services/consts-enums-functions' ;
import { GetInfo , LookupNode } from '../../../shared/models/clnModels' ;
import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload' ;
import { openAlert , openConfirmation } from '../../../store/rtl.actions' ;
@ -18,8 +18,9 @@ import { openAlert, openConfirmation } from '../../../store/rtl.actions';
import { RTLState } from '../../../store/rtl.state' ;
import { RTLEffects } from '../../../store/rtl.effects' ;
import { CLNOpenLiquidityChannelComponent } from '../open-liquidity-channel-modal/open-liquidity-channel-modal.component' ;
import { nodeInfoAndNodeSettingsAndBalance } from '../../store/cln.selector' ;
import { clnPageSettings, nodeInfoAndNodeSettingsAndBalance } from '../../store/cln.selector' ;
import { DecimalPipe } from '@angular/common' ;
import { PageSettingsCLN , TableSetting } from '../../../shared/models/pageSettings' ;
@Component ( {
selector : 'rtl-cln-liquidity-ads-list' ,
@ -33,6 +34,8 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
@ViewChild ( MatSort , { static : false } ) sort : MatSort | undefined ;
@ViewChild ( MatPaginator , { static : false } ) paginator : MatPaginator | undefined ;
public PAGE_ID = 'liquidity_ads' ;
public tableSetting : TableSetting = { tableId : 'liquidity_ads' , recordsPerPage : PAGE_SIZE , sortBy : 'channel_opening_fee' , sortOrder : SortOrderEnum.ASCENDING } ;
public askTooltipMsg = '' ;
public nodesTooltipMsg = '' ;
public displayedColumns : any [ ] = [ ] ;
@ -42,9 +45,9 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
public totalBalance = 0 ;
public information : GetInfo ;
public channelAmount = 100000 ;
public channel OpeningF eeRate = 10 ;
public node C apacity = 500000 ;
public channel C ount = 5 ;
public channel _opening_f eeRate = 10 ;
public node _c apacity = 500000 ;
public channel _c ount = 5 ;
public liquidityNodesData : LookupNode [ ] = [ ] ;
public liquidityNodes : any ;
public pageSize = PAGE_SIZE ;
@ -55,26 +58,34 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
public selFilter = '' ;
public apiCallStatus : ApiCallStatusPayload = { status : APICallStatusEnum.INITIATED } ;
public apiCallStatusEnum = APICallStatusEnum ;
private unSubs : Array < Subject < void > > = [ new Subject ( ) , new Subject ( ) , new Subject ( ) , new Subject ( ) ];
private unSubs : Array < Subject < void > > = [ new Subject ( ) , new Subject ( ) , new Subject ( ) , new Subject ( ) , new Subject ( ) , new Subject ( ) ];
constructor ( private logger : LoggerService , private store : Store < RTLState > , private dataService : DataService , private commonService : CommonService , private rtlEffects : RTLEffects , private decimalPipe : DecimalPipe ) {
this . askTooltipMsg = 'Specify the liquidity requirements for your node: \n 1. Channel Amount - Amount in Sats you need on the channel opened to your node \n 2. Channel opening fee rate - Rate in Sats/vByte that you are willing to pay to open the channel to you' ;
this . nodesTooltipMsg = 'These nodes are advertising their liquidity offering on the network.\nYou should pay attention to the following aspects to evaluate each node offer: \n- The total bitcoin deployed on the node, the more the better\n' ;
this . nodesTooltipMsg = this . nodesTooltipMsg + '- The number of channels open on the node, the more the better\n- The channel open fee which the node will charge from you\n- The routing fee which the node will charge on the payments, the lesser the better\n- The reliability of the node, ideally uptime. Refer to the information being provided by the node explorers' ;
this . screenSize = this . commonService . getScreenSize ( ) ;
if ( this . screenSize === ScreenSizeEnum . XS ) {
this . displayedColumns = [ 'alias' , 'channelOpeningFee' , 'actions' ] ;
} else if ( this . screenSize === ScreenSizeEnum . SM ) {
this . displayedColumns = [ 'alias' , 'leaseFee' , 'routingFee' , 'channelOpeningFee' , 'actions' ] ;
} else if ( this . screenSize === ScreenSizeEnum . MD ) {
this . displayedColumns = [ 'alias' , 'leaseFee' , 'routingFee' , 'channelOpeningFee' , 'actions' ] ;
} else {
this . displayedColumns = [ 'alias' , 'leaseFee' , 'routingFee' , 'channelOpeningFee' , 'actions' ] ;
}
}
ngOnInit ( ) : void {
combineLatest ( [ this . store . select ( nodeInfoAndNodeSettingsAndBalance ) , this . dataService . listNetworkNodes ( '?liquidity_ads=yes' ) ] ) . pipe ( takeUntil ( this . unSubs [ 0 ] ) ) .
this . store . select ( clnPageSettings ) . pipe ( takeUntil ( this . unSubs [ 0 ] ) ) .
subscribe ( ( settings : { pageSettings : PageSettingsCLN [ ] , apiCallStatus : ApiCallStatusPayload } ) = > {
this . errorMessage = '' ;
this . apiCallStatus = settings . apiCallStatus ;
if ( this . apiCallStatus . status === APICallStatusEnum . ERROR ) {
this . errorMessage = this . apiCallStatus . message || '' ;
}
this . tableSetting = settings . pageSettings . find ( ( page ) = > page . pageId === this . PAGE_ID ) ? . tables . find ( ( table ) = > table . tableId === this . tableSetting . tableId ) || CLN_DEFAULT_PAGE_SETTINGS . find ( ( page ) = > page . pageId === this . PAGE_ID ) ? . tables . find ( ( table ) = > table . tableId === this . tableSetting . tableId ) ! ;
if ( this . screenSize === ScreenSizeEnum . XS || this . screenSize === ScreenSizeEnum . SM ) {
this . displayedColumns = JSON . parse ( JSON . stringify ( this . tableSetting . columnSelectionSM ) ) ;
} else {
this . displayedColumns = JSON . parse ( JSON . stringify ( this . tableSetting . columnSelection ) ) ;
}
this . displayedColumns . push ( 'actions' ) ;
this . pageSize = this . tableSetting . recordsPerPage ? + this . tableSetting.recordsPerPage : PAGE_SIZE ;
this . logger . info ( this . displayedColumns ) ;
} ) ;
combineLatest ( [ this . store . select ( nodeInfoAndNodeSettingsAndBalance ) , this . dataService . listNetworkNodes ( '?liquidity_ads=yes' ) ] ) . pipe ( takeUntil ( this . unSubs [ 1 ] ) ) .
subscribe ( {
next : ( [ infoSettingsBalSelector , nodeListRes ] ) = > {
this . information = infoSettingsBalSelector . information ;
@ -106,7 +117,7 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
onCalculateOpeningFee() {
this . liquidityNodesData . forEach ( ( lqNode ) = > {
if ( lqNode . option_will_fund ) {
lqNode . channel OpeningF ee = ( + ( lqNode . option_will_fund . lease_fee_base_msat || 0 ) / 1000 ) + ( this . channelAmount * ( + ( lqNode . option_will_fund . lease_fee_basis || 0 ) ) / 10000 ) + ( ( + ( lqNode . option_will_fund . funding_weight || 0 ) / 4 ) * this . channel OpeningF eeRate) ;
lqNode . channel _opening_f ee = ( + ( lqNode . option_will_fund . lease_fee_base_msat || 0 ) / 1000 ) + ( this . channelAmount * ( + ( lqNode . option_will_fund . lease_fee_basis || 0 ) ) / 10000 ) + ( ( + ( lqNode . option_will_fund . funding_weight || 0 ) / 4 ) * this . channel _opening_f eeRate) ;
}
} ) ;
if ( this . paginator ) { this . paginator . firstPage ( ) ; }
@ -124,17 +135,17 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
this . liquidityNodes = new MatTableDataSource < LookupNode > ( [ . . . liqNodes ] ) ;
this . liquidityNodes . sortingDataAccessor = ( data : any , sortHeaderId : string ) = > ( ( data [ sortHeaderId ] && isNaN ( data [ sortHeaderId ] ) ) ? data [ sortHeaderId ] . toLocaleLowerCase ( ) : data [ sortHeaderId ] ? + data [ sortHeaderId ] : null ) ;
this . liquidityNodes . sort = this . sort ;
this . liquidityNodes . paginator = this . paginator ;
if ( this . sort ) { this . sort ? . sort ( { id : 'channelOpeningFee' , start : 'asc' , disableClear : true } ) ; }
this . liquidityNodes . sort ? . sort ( { id : this.tableSetting.sortBy , start : this.tableSetting.sortOrder , disableClear : true } ) ;
this . liquidityNodes . filterPredicate = ( node : LookupNode , fltr : string ) = > {
const newNode = ( ( node . alias ) ? node . alias . toLocaleLowerCase ( ) : '' ) + ( node . channel OpeningFee ? node . channelOpeningF ee + ' Sats' : '' ) +
const newNode = ( ( node . alias ) ? node . alias . toLocaleLowerCase ( ) : '' ) + ( node . channel _opening_fee ? node . channel_opening_f ee + ' Sats' : '' ) +
( node . option_will_fund ? . lease_fee_base_msat ? ( node . option_will_fund ? . lease_fee_base_msat / 1000 ) + ' Sats' : '' ) + ( node . option_will_fund ? . lease_fee_basis ? ( this . decimalPipe . transform ( node . option_will_fund ? . lease_fee_basis / 100 , '1.2-2' ) + '%' ) : '' ) +
( node . option_will_fund ? . channel_fee_max_base_msat ? ( node . option_will_fund ? . channel_fee_max_base_msat / 1000 ) + ' Sats' : '' ) + ( node . option_will_fund ? . channel_fee_max_proportional_thousandths ? ( node . option_will_fund ? . channel_fee_max_proportional_thousandths * 1000 ) + ' ppm' : '' ) +
( node . address_types ? node . address_types . reduce ( ( acc , curr ) = > acc + ( curr === 'tor' ? ' tor' : curr === 'ipv' ? ' clearnet' : ( ' ' + curr . toLowerCase ( ) ) ) , '' ) : '' ) ;
return newNode . includes ( fltr ) ;
} ;
this . applyFilter ( ) ;
// this.liquidityNodes.filterPredicate = (node: LookupNode, fltr: string) => node.channelCount >= this.channelCount && node.nodeCapacity >= this.nodeCapacity;
this . liquidityNodes . paginator = this . paginator ;
// this.liquidityNodes.filterPredicate = (node: LookupNode, fltr: string) => node.channel_count >= this.channel_count && node.node_capacity >= this.node_capacity;
// this.onFilter();
}
@ -151,7 +162,7 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
node : lqNode ,
balance : this.totalBalance ,
requestedAmount : this.channelAmount ,
feeRate : this.channel OpeningF eeRate,
feeRate : this.channel _opening_f eeRate,
localAmount : 20000
} ;
this . store . dispatch ( openAlert ( {
@ -203,7 +214,7 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
}
}
} ) ) ;
this . rtlEffects . closeConfirm . pipe ( takeUntil ( this . unSubs [ 1 ] ) ) . subscribe ( ( confirmRes ) = > {
this . rtlEffects . closeConfirm . pipe ( takeUntil ( this . unSubs [ 2 ] ) ) . subscribe ( ( confirmRes ) = > {
if ( confirmRes ) {
this . onOpenChannel ( lqNode ) ;
}
@ -217,8 +228,8 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
}
onFilterReset() {
this . node C apacity = 0 ;
this . channel C ount = 0 ;
this . node _c apacity = 0 ;
this . channel _c ount = 0 ;
}
ngOnDestroy() {