@@ -221,13 +221,13 @@ describe('element bridge data', () => {
221
221
expect ( expiration ) . toBe ( BigInt ( endDate ) ) ;
222
222
} ) ;
223
223
224
- it ( 'should return the correct yearly output of the tranche' , async ( ) => {
224
+ it ( 'should return the correct yield of the tranche' , async ( ) => {
225
225
const now = Math . floor ( Date . now ( ) / 1000 ) ;
226
226
const expiry = BigInt ( now + 86400 * 30 ) ;
227
227
const trancheAddress = '0x90ca5cef5b29342b229fb8ae2db5d8f4f894d652' ;
228
228
const poolId = '0x90ca5cef5b29342b229fb8ae2db5d8f4f894d6520002000000000000000000b5' ;
229
- const interest = 100000n ;
230
- const inputValue = 10e18 ,
229
+ const interest = BigInt ( 1e16 ) ;
230
+ const inputValue = BigInt ( 10e18 ) ,
231
231
elementBridge = {
232
232
hashAssetAndExpiry : jest . fn ( ) . mockResolvedValue ( '0xa' ) ,
233
233
pools : jest . fn ( ) . mockResolvedValue ( [ trancheAddress , '' , poolId ] ) ,
@@ -240,9 +240,7 @@ describe('element bridge data', () => {
240
240
balancerContract = {
241
241
...balancerContract ,
242
242
queryBatchSwap : jest . fn ( ) . mockImplementation ( ( ...args ) => {
243
- const amount = args [ 1 ] [ 0 ] . amount ;
244
-
245
- return Promise . resolve ( [ BigNumber . from ( BigInt ( amount ) ) , BigNumber . from ( - BigInt ( BigInt ( amount ) + interest ) ) ] ) ;
243
+ return Promise . resolve ( [ BigNumber . from ( inputValue ) , BigNumber . from ( - BigInt ( inputValue + interest ) ) ] ) ;
246
244
} ) ,
247
245
} ;
248
246
@@ -279,8 +277,11 @@ describe('element bridge data', () => {
279
277
const timeToExpiration = expiry - BigInt ( now ) ;
280
278
const scaledOut = ( BigInt ( interest ) * elementBridgeData . scalingFactor ) / timeToExpiration ;
281
279
const yearlyOut = ( scaledOut * BigInt ( YEAR ) ) / elementBridgeData . scalingFactor ;
280
+ const scaledPercentage = ( yearlyOut * elementBridgeData . scalingFactor ) / inputValue ;
281
+ const percentage2sf = scaledPercentage / ( elementBridgeData . scalingFactor / 10000n ) ;
282
+ const percent = Number ( percentage2sf ) / 100 ;
282
283
283
- expect ( output [ 0 ] ) . toBe ( Number ( ( BigInt ( inputValue ) / ( yearlyOut + BigInt ( inputValue ) ) ) * 100n ) ) ;
284
+ expect ( output [ 0 ] ) . toBe ( percent ) ;
284
285
} ) ;
285
286
286
287
it ( 'should return the correct market size for a given tranche' , async ( ) => {
0 commit comments