DHCP relaying is no hack, it's specified in RFC 3046. When forwarding, the agent puts its own IP address in the GIADDR field, so the DHCP server knows that a gateway is required.
The DHCP lease is associated with the client's MAC address. The gateway's MAC is only used for hop-to-hop delivery.