-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deployment): auto top up custodial deployment with available amount
closes #524
- Loading branch information
1 parent
70abd0d
commit a782dc0
Showing
4 changed files
with
151 additions
and
39 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
.../api/src/deployment/services/top-up-custodial-balance/top-up-custodial-balance.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
interface Balances { | ||
denom: string; | ||
feesLimit: number; | ||
deploymentLimit: number; | ||
balance: number; | ||
feesBalance?: number; | ||
} | ||
|
||
export class TopUpCustodialBalanceService { | ||
constructor(readonly balances: Balances) {} | ||
|
||
recordTx(amount: number, fees: number) { | ||
this.balances.deploymentLimit -= amount; | ||
this.balances.balance -= amount; | ||
this.balances.feesLimit -= fees; | ||
|
||
if (this.balances.denom === "uakt") { | ||
this.balances.balance -= fees; | ||
} else { | ||
this.balances.feesBalance -= fees; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters