Skip to content

Commit

Permalink
remove price feed on finance
Browse files Browse the repository at this point in the history
  • Loading branch information
JP Angelle committed Aug 31, 2023
1 parent 3a17887 commit 26e7429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 38 deletions.
22 changes: 3 additions & 19 deletions centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CurrencyBalance, ExternalPricingInfo, findBalance, Loan as LoanType } from '@centrifuge/centrifuge-js'
import { CurrencyBalance, findBalance, Loan as LoanType } from '@centrifuge/centrifuge-js'
import { useBalances, useCentrifugeTransaction } from '@centrifuge/centrifuge-react'
import { Box, Button, Card, CurrencyInput, IconInfo, InlineFeedback, Shelf, Stack, Text } from '@centrifuge/fabric'
import BN from 'bn.js'
Expand Down Expand Up @@ -63,14 +63,7 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
const price = CurrencyBalance.fromFloat(values.price, pool.currency.decimals)
const faceValue = CurrencyBalance.fromFloat(values.faceValue, 18)

doFinanceTransaction([
loan.poolId,
loan.id,
faceValue,
price,
(loan.pricing as ExternalPricingInfo).Isin,
account.actingAddress,
])
doFinanceTransaction([loan.poolId, loan.id, faceValue, price, account.actingAddress])
actions.setSubmitting(false)
},
validateOnMount: true,
Expand All @@ -88,16 +81,7 @@ export function ExternalFinanceForm({ loan }: { loan: LoanType }) {
pool.currency.decimals
)

doRepayTransaction([
loan.poolId,
loan.id,
quantity,
new BN(0),
new BN(0),
price,
(loan.pricing as ExternalPricingInfo).Isin,
account.actingAddress,
])
doRepayTransaction([loan.poolId, loan.id, quantity, new BN(0), new BN(0), price, account.actingAddress])
actions.setSubmitting(false)
},
validateOnMount: true,
Expand Down
25 changes: 6 additions & 19 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1341,10 +1341,10 @@ export function getPoolsModule(inst: Centrifuge) {
}

function financeExternalLoan(
args: [poolId: string, loanId: string, quantity: BN, price: BN, isin: string, aoProxy: string],
args: [poolId: string, loanId: string, quantity: BN, price: BN, aoProxy: string],
options?: TransactionOptions
) {
const [poolId, loanId, quantity, price, isin, aoProxy] = args
const [poolId, loanId, quantity, price, aoProxy] = args
const $api = inst.getApi()
return $api.pipe(
switchMap((api) => {
Expand All @@ -1355,9 +1355,7 @@ export function getPoolsModule(inst: Centrifuge) {
external: { quantity: quantity.toString(), settlementPrice: price.toString() },
})
)
const oracleFeedSubmittable = api.tx.priceOracle.feedValues([[{ Isin: isin }, price]])
const batchSubmittable = api.tx.utility.batchAll([oracleFeedSubmittable, borrowSubmittable])
return inst.wrapSignAndSend(api, batchSubmittable, options)
return inst.wrapSignAndSend(api, borrowSubmittable, options)
})
)
}
Expand Down Expand Up @@ -1393,19 +1391,10 @@ export function getPoolsModule(inst: Centrifuge) {
}

function repayExternalLoanPartially(
args: [
poolId: string,
loanId: string,
quantity: BN,
interest: BN,
unscheduled: BN,
price: BN,
isin: string,
aoProxy: string
],
args: [poolId: string, loanId: string, quantity: BN, interest: BN, unscheduled: BN, price: BN, aoProxy: string],
options?: TransactionOptions
) {
const [poolId, loanId, quantity, interest, unscheduled, price, isin, aoProxy] = args
const [poolId, loanId, quantity, interest, unscheduled, price, aoProxy] = args
const $api = inst.getApi()

return $api.pipe(
Expand All @@ -1419,9 +1408,7 @@ export function getPoolsModule(inst: Centrifuge) {
unscheduled: unscheduled.toString(),
})
)
const oracleFeedSubmittable = api.tx.priceOracle.feedValues([[{ Isin: isin }, price]])
const batchSubmittable = api.tx.utility.batchAll([oracleFeedSubmittable, repaySubmittable])
return inst.wrapSignAndSend(api, batchSubmittable, options)
return inst.wrapSignAndSend(api, repaySubmittable, options)
})
)
}
Expand Down

0 comments on commit 26e7429

Please sign in to comment.