Maximum trophies(multiplayer) that can be obtained
Upon the dark spell update Clash increased the regular raid search radius. You used to only find raids within a 200 trophy range going up and down. The maximum trophies per regular raid used to be 34 where the minimum used to be 8. Now that search span is larger (I don't know exact). The maximum trophies from a regular raid is 59 and the minimum is 1.
This system was put in place for high trophy players as once you hit the 4,000+ there are only a handful of players within the 200 trophy radius so players would often see the clouds for up to a half hour before finding a single raid.
The amount of trophies you can receive is depending on your trophy count and the other players. This goes for revenge raids and regular raids.
The maximum trophies available when raiding is actually 59 as per this video. I don't think anybody but the developpers know the actual algorithm for matchmaking, but the odds to get matched up with a base having more than 400 trophies more than your own base are really low.
Is that a bug that you got a 40 trophy offer? No. Did the system change recently? Maybe.
The trivia part of the wikia mentions a maximum of 59 trophies on revenge and a maximum of 34 on a regular raid, which I don't believe is correct; I have found trophy offers above 34 quite a few times myself, and even more so now that I'm in Master 3 league (I sometimes also get attacks from champion 3 league players losing 1 trophy on the defense).