Question about Tinyman and margin protocol

So I want to leverage Tinyman to create a decentralized margin/leverage protocol on Algorand. The idea is the following: a user can borrow money to trade on Tinyman, but the user can only borrow algos if collateral has already been sent to a contract account (say a stateless logic signature account).

This is what it would look like:

Unfortunately, this cannot be done through an atomic grouped transaction because Tinyman pool contracts check for GroupSize, indexes, etc. It can also not be achieved through inner transactions because of the same reason.

I was also thinking about doing this in three separate transactions. The first two transactions would be in an atomic group, and the transactions from collateral contract account to Tinyman would happen later (only if the first two were successful).

The first would send a transaction with collateral from Borrower to Collateral Contract Account, and the second would be a transaction made to a stateful app that will store the amount of collateral sent in the Borrower’s local storage. The idea is that the collateral contract account would only send a swap transaction to Tinyman with borrowed money if there is local storage for the Borrower in the stateful validator app. For this, I wanted to use app_local_get or localGetEx in Pyteal. Unfortunately, this opcode is not allowed in stateless logic signatures.

I was wondering if you had any ideas or comments on how I should restructure my code to accomplish this.

Sorry for the lengthy question, but I wanted to ensure that you understood my thought process.

Best,

Javier