I think it's like this;
Sabbe dhamma amatogadham
means all dhamma gain a footing in the deathless.
Commentary is wrong in asserting that an10.58 refers only to kusala dhammā.
The expression is connected to analogies of reaching the other shore and crossing the flood.
One's been afloat [transmigating] from an inconstruable beginning.
From an inconstruable beginning comes transmigration. A beginning point is not evident, though beings hindered by ignorance and fettered by craving are transmigrating & wandering on.
Sn15.14-19
Fettered by ignorance the Deathless has remained overlooked.
mv1.23.1-10
the Sorrowless (asoka) State
unseen, overlooked (by us)
for many myriads of aeons.
When one attains Deathless one gains a footing in the dhamma.
Further drawing on the analogy one gets out of the water completely, based on that very footing.
Attaining Arahantship one has reached the other shore.
Sabbe dhammā manopubbangama, manoseṭṭhā, manomayā, sabbe dhammā amatogadham, nibbānapariyosanā sabbe dhammā
Explained;
All dhammas are preceeded, made & led by mind (this has no beginning), and this construing [sankhara] of percipience [analogical 'striving afloat'] goes on potentially indefinitely lest the Deathless is attained [gaining a footing].
Having gained a footing one develops those same qualities for the final attainment of the truth, one gets to the other shore, becomes an Arahant.
For him, dhammā are still construed by which he experiences pleasant & unplesant feelings;
However, his five sense faculties remain unimpaired, by which he still experiences what is agreeable and disagreeable and feels pleasure and pain. It is the extinction of attachment, hate, and delusion in him that is called the Nibbana-element with residue left.
iti2.42-49
Their attainment of Parinibbana is the End of this construing of dhammā, extinguishment is their end [pariyosana] where all modes of being are abandoned with no residue[fuel] for a future
These two Nibbana-elements were made known By the Seeing One, stable and unattached: One is the element seen here and now With residue, but with the cord of being destroyed; The other, having no residue for the future, Is that wherein all modes of being utterly cease.