Skip to content
Merged
Changes from all 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
35 changes: 32 additions & 3 deletions src/domain/participant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ const getLimitsForAllParticipants = async ({ currency = null, type = null }) =>
* "currency": "USD",
* "limit": {
* "type": "NET_DEBIT_CAP",
* "value": 10000000
* "value": 10000000,
* "thresholdAlarmPercentage": 10
* }
* }
*
Expand All @@ -449,14 +450,42 @@ const getLimitsForAllParticipants = async ({ currency = null, type = null }) =>

const adjustLimits = async (name, payload) => {
try {
const participant = await ParticipantFacade.getByNameAndCurrency(name, payload.currency, Enum.LedgerAccountType.POSITION)
let { limit, currency } = payload
const participant = await ParticipantFacade.getByNameAndCurrency(name, currency, Enum.LedgerAccountType.POSITION)
participantExists(participant)
return ParticipantFacade.adjustLimits(participant.participantCurrencyId, payload.limit)
let result = await ParticipantFacade.adjustLimits(participant.participantCurrencyId, limit)
payload.name = name
await Utility.produceGeneralMessage(TransferEventType.NOTIFICATION, TransferEventAction.EVENT, createLimitAdjustmentMessageProtocol(payload), Utility.ENUMS.STATE.SUCCESS)
return result
} catch (err) {
throw err
}
}

const createLimitAdjustmentMessageProtocol = (payload, action = 'limitAdjustment', state = '', pp = '') => {
return {
id: Uuid(),
from: payload.name,
to: 'SYSTEM',
type: 'application/json',
content: {
header: {},
payload
},
metadata: {
event: {
id: Uuid(),
responseTo: '',
type: 'notification',
action,
createdAt: new Date(),
state
}
},
pp
}
}

/**
* @function GetPositions
*
Expand Down