( farmingDataBefore: FarmingData, farmingDataUpdated: FarmingData, sdexToSplit: SdexByEndBlock[], campaignIndex: number[], blockExec: number, currentBlock: number, )
| 66 | } |
| 67 | |
| 68 | export function getDataForTxMultiple( |
| 69 | farmingDataBefore: FarmingData, |
| 70 | farmingDataUpdated: FarmingData, |
| 71 | sdexToSplit: SdexByEndBlock[], |
| 72 | campaignIndex: number[], |
| 73 | blockExec: number, |
| 74 | currentBlock: number, |
| 75 | ): DataForTxMultiple { |
| 76 | const dataForTx: DataForTxMultiple = { |
| 77 | campaignId: campaignIndex, |
| 78 | rewardIndex: [], |
| 79 | endBlock: [], |
| 80 | rewardPerBlock: [], |
| 81 | }; |
| 82 | |
| 83 | for (let i = 0; i < campaignIndex.length; i++) { |
| 84 | const data = getDataForTx( |
| 85 | farmingDataBefore, |
| 86 | farmingDataUpdated, |
| 87 | sdexToSplit, |
| 88 | campaignIndex[i], |
| 89 | blockExec, |
| 90 | currentBlock, |
| 91 | ); |
| 92 | dataForTx.rewardIndex[i] = data.rewardIndex; |
| 93 | dataForTx.endBlock[i] = data.endBlock; |
| 94 | dataForTx.rewardPerBlock[i] = data.rewardPerBlock; |
| 95 | } |
| 96 | |
| 97 | console.log("----update value by block end "); |
| 98 | sdexToSplit.forEach(byEndBlock => { |
| 99 | let amount: BigNumber = constants.Zero; |
| 100 | for (let i = 0; i < dataForTx.campaignId.length; i++) { |
| 101 | const currentIndex: number = dataForTx.endBlock[i].findIndex(x => x.eq(byEndBlock.endBlock)); |
| 102 | if (currentIndex === -1) { |
| 103 | console.log("didnt found index for " + byEndBlock.endBlock + " in campaign id " + dataForTx.campaignId[i]); |
| 104 | } else { |
| 105 | const blockLength = |
| 106 | currentIndex === 0 |
| 107 | ? dataForTx.endBlock[i][currentIndex].sub(blockExec) |
| 108 | : dataForTx.endBlock[i][currentIndex].sub(dataForTx.endBlock[i][currentIndex - 1]); |
| 109 | |
| 110 | amount = amount.add(blockLength.mul(dataForTx.rewardPerBlock[i][currentIndex])); |
| 111 | } |
| 112 | } |
| 113 | console.log("end block :", byEndBlock.endBlock); |
| 114 | console.log("amount :", formatEther(amount)); |
| 115 | }); |
| 116 | |
| 117 | return dataForTx; |
| 118 | } |
| 119 | |
| 120 | export function getDataForTx( |
| 121 | farmingDataBefore: FarmingData, |
nothing calls this directly
no test coverage detected