Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ packages:
PeginStatusUseCase:
PegoutStatusUseCase:
SetGeneralConfigUseCase:
SetLiquidityRatioUseCase:
GetPegoutReportUseCase:
GetPeginReportUseCase:
RecommendedPegoutUseCase:
RecommendedPeginUseCase:
GetRevenueReportUseCase:
GetLiquidityRatioUseCase:
GetSummariesReportUseCase:
GetTrustedAccountsUseCase:
ServerInfoUseCase:
Expand Down
96 changes: 96 additions & 0 deletions OpenApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,31 @@ components:
format: date-time
type: string
type: object
ExcessToleranceDTO:
properties:
fixedValue:
type: string
isFixed:
type: boolean
percentageValue:
type: number
type: object
GeneralConfigurationDTO:
properties:
btcConfirmations:
properties:
key:
type: integer
type: object
excessTolerance:
$ref: '#/components/schemas/ExcessToleranceDTO'
type: object
maxLiquidity:
type: string
publicLiquidityCheck:
type: boolean
reimbursementWindowBlocks:
type: integer
rskConfirmations:
properties:
key:
Expand Down Expand Up @@ -293,6 +309,48 @@ components:
- status
- providerType
type: object
LiquidityRatioResponse:
properties:
btcCurrentBalance:
$ref: '#/components/schemas/'
btcImpact:
$ref: '#/components/schemas/NetworkImpact'
type: object
btcPercentage:
type: integer
btcTarget:
$ref: '#/components/schemas/'
btcThreshold:
$ref: '#/components/schemas/'
cooldownActive:
type: boolean
cooldownDurationSeconds:
type: integer
cooldownEndTimestamp:
type: integer
isPreview:
type: boolean
maxLiquidity:
$ref: '#/components/schemas/'
rbtcCurrentBalance:
$ref: '#/components/schemas/'
rbtcImpact:
$ref: '#/components/schemas/NetworkImpact'
type: object
rbtcPercentage:
type: integer
rbtcTarget:
$ref: '#/components/schemas/'
rbtcThreshold:
$ref: '#/components/schemas/'
type: object
NetworkImpact:
properties:
amount:
$ref: '#/components/schemas/'
type:
type: string
type: object
PaginationMetadata:
properties:
page:
Expand Down Expand Up @@ -845,6 +903,11 @@ components:
rsk:
type: string
type: object
SetLiquidityRatioRequest:
properties:
btcPercentage:
type: integer
type: object
TrustedAccountRequest:
properties:
address:
Expand Down Expand Up @@ -1019,6 +1082,39 @@ paths:
"200":
description: ""
summary: Set Login Credentials
/management/liquidity-ratio:
get:
description: ' Get the current liquidity ratio status. Optionally pass btcPercentage
query param to preview a change. Included in the management API.'
parameters:
- description: Proposed BTC percentage for preview
in: query
name: btcPercentage
schema:
description: Proposed BTC percentage for preview
format: int64
type: integer
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/LiquidityRatioResponse'
description: ""
summary: Get Liquidity Ratio
post:
description: ' Set the BTC/RBTC liquidity ratio. Included in the management
API.'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SetLiquidityRatioRequest'
required: true
responses:
"204":
description: ""
summary: Set Liquidity Ratio
/management/login:
post:
description: ' Authenticate to start a Management API session'
Expand Down
1 change: 0 additions & 1 deletion docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ services:
- COLD_WALLET_FORCE_TRANSFER_AFTER_SECONDS
- HOT_WALLET_LOW_LIQUIDITY_WARNING
- HOT_WALLET_LOW_LIQUIDITY_CRITICAL
- BTC_LIQUIDITY_TARGET_PERCENTAGE
ports:
- "8080:8080"
volumes:
Expand Down
1 change: 0 additions & 1 deletion docker-compose/local/docker-compose.lps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ services:
- COLD_WALLET_FORCE_TRANSFER_AFTER_SECONDS
- HOT_WALLET_LOW_LIQUIDITY_WARNING
- HOT_WALLET_LOW_LIQUIDITY_CRITICAL
- BTC_LIQUIDITY_TARGET_PERCENTAGE
ports:
- "8080:8080"
volumes:
Expand Down
1 change: 0 additions & 1 deletion docker-compose/mainnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ services:
- COLD_WALLET_FORCE_TRANSFER_AFTER_SECONDS
- HOT_WALLET_LOW_LIQUIDITY_WARNING
- HOT_WALLET_LOW_LIQUIDITY_CRITICAL
- BTC_LIQUIDITY_TARGET_PERCENTAGE
ports:
- "8080:8080"
volumes:
Expand Down
1 change: 0 additions & 1 deletion docs/Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ These are the environment variables required by the liquidity provider server (L
| `COLD_WALLET_FORCE_TRANSFER_AFTER_SECONDS` | Number of seconds after which excess liquidity will be transferred to cold wallet even if below threshold | `1209600` (2 weeks) | No |
| `HOT_WALLET_LOW_LIQUIDITY_WARNING` | Hot wallet liquidity threshold in whole coins (BTC/RBTC) below which a warning alert is emitted every check cycle | `3` | No |
| `HOT_WALLET_LOW_LIQUIDITY_CRITICAL` | Hot wallet liquidity threshold in whole coins (BTC/RBTC) below which a critical alert is emitted every check cycle. Must be less than `HOT_WALLET_LOW_LIQUIDITY_WARNING` | `1` | No |
| `BTC_LIQUIDITY_TARGET_PERCENTAGE` | Percentage of MaxLiquidity allocated to BTC in the hot wallet (RBTC gets the remainder). Must be between 10 and 90 | `50` | No |

## AWS variables
You may notice that in [`sample-config.env`](https://github.com/rsksmart/liquidity-provider-server/blob/master/sample-config.env) there are some environment variables that are related to AWS. These variables are required to use AWS services, however, they are not listed in the table as the AWS SDK has the functionality to load them from multiple sources. For that reason, they are not accessed directly from the code and are not listed in the table above.
Expand Down
83 changes: 83 additions & 0 deletions internal/adapters/entrypoints/rest/assets/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,45 @@ <h5 class="card-title">Accounts List</h5>
<div class="loading-bar" id="trustedAccountsLoadingBar"></div>
</div>
</div>
<div class="card">
<div class="card-header">Liquidity Ratio</div>
<div class="card-body">
<div class="alert alert-info d-none" id="ratioCooldownBanner" role="alert">
<strong>Cooldown active</strong> &mdash; reimbursement sweeps are suppressed until <span id="ratioCooldownEnd"></span>
</div>
<p class="text-muted small mb-3">Match your expected flow. Peg-ins dominate &rarr; allocate more to RBTC.</p>
<div class="mb-3">
<label class="form-label" style="font-weight: bold;">BTC / RBTC Split</label>
<input type="range" class="form-range" id="ratioSlider" min="10" max="90" step="1" value="50">
<div class="d-flex justify-content-between">
<span class="fw-bold" id="ratioSliderBtcLabel">BTC:</span>
<span class="fw-bold" id="ratioSliderRbtcLabel">RBTC:</span>
</div>
</div>
<div id="ratioImpact" class="d-none">
<hr>
<div class="row">
<div class="col-6">
<h6 class="fw-bold">BTC</h6>
<p class="mb-1 small">Target: <span id="ratioImpactBtcTarget">--</span></p>
<p class="mb-1 small">Threshold: <span id="ratioImpactBtcThreshold">--</span></p>
<p class="mb-1 small">Balance: <span id="ratioImpactBtcBalance">--</span></p>
<p class="mb-0"><span class="badge" id="ratioImpactBtcBadge">--</span></p>
</div>
<div class="col-6">
<h6 class="fw-bold">RBTC</h6>
<p class="mb-1 small">Target: <span id="ratioImpactRbtcTarget">--</span></p>
<p class="mb-1 small">Threshold: <span id="ratioImpactRbtcThreshold">--</span></p>
<p class="mb-1 small">Balance: <span id="ratioImpactRbtcBalance">--</span></p>
<p class="mb-0"><span class="badge" id="ratioImpactRbtcBadge">--</span></p>
</div>
</div>
</div>
<div class="mt-3">
<button type="button" class="btn btn-primary" id="saveRatio">Save Ratio</button>
</div>
</div>
</div>
</div>

<div class="col-md-6">
Expand Down Expand Up @@ -238,6 +277,50 @@ <h5 class="modal-title" id="addTrustedAccountModalLabel">Add Trusted Account</h5
</div>
</div>

<div class="modal fade" id="confirmRatioModal" tabindex="-1" aria-labelledby="confirmRatioModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmRatioModalLabel">Confirm Ratio Change</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>You are about to change the liquidity ratio to:</p>
<p class="fw-bold text-center" id="confirmRatioSummary"></p>
<hr>
<div class="row">
<div class="col-6">
<h6 class="fw-bold">BTC</h6>
<p class="mb-1 small">Target: <span id="confirmBtcTarget">--</span></p>
<p class="mb-1 small">Balance: <span id="confirmBtcBalance">--</span></p>
<p class="mb-0"><span class="badge" id="confirmBtcBadge">--</span></p>
</div>
<div class="col-6">
<h6 class="fw-bold">RBTC</h6>
<p class="mb-1 small">Target: <span id="confirmRbtcTarget">--</span></p>
<p class="mb-1 small">Balance: <span id="confirmRbtcBalance">--</span></p>
<p class="mb-0"><span class="badge" id="confirmRbtcBadge">--</span></p>
</div>
</div>
<div class="mt-3 d-none" id="confirmDeficitWarning">
<div class="alert alert-warning mb-0">
<strong>Deficit detected.</strong> One or more networks will be below target after save.
</div>
</div>
<div class="mt-3 d-none" id="confirmExcessWarning">
<div class="alert alert-info mb-0">
<strong>Excess detected.</strong> Funds above target will be swept to cold wallet after the cooldown period.
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmRatioSave">Confirm Save</button>
</div>
</div>
</div>
</div>

<div class="toast-container">
<div id="successToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
Expand Down
14 changes: 14 additions & 0 deletions internal/adapters/entrypoints/rest/assets/static/management.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,17 @@ pre {
#pegoutSummary th {
width: 60%;
}

.badge-deficit {
background-color: #ffc107;
color: #212529;
}

.badge-excess {
background-color: #ffc107;
color: #212529;
}

.badge-withinTolerance {
background-color: #198754;
}
Loading
Loading