Ok so I need to write a smart contract, and inside it need to be a bunch of different pools. Each pool has its own unique ASA and about 15 global variables in it (like pool owner, pool interest rate, … , etc)
One implementation is to just have a smart contract hold all these pools. The issue is that i am going to have to store their variables (recall that each pool has 15 variables) in global storage. From my understanding, there is a max of 64 key-values for global storage in algorand so we could really only have like 4 pools (64 // 15) in the smart contract.
Another implementation might be to have a bunch of logic sigs representing the pools tied to the smart contract. We could store the addresses of these logic sigs in global storage (total of 64 pools), and the logic sigs could check for the contract ID that is being called (this could be done simultaneously in a grouped transaction). Even with this implementation, we can only have a total of 64 pools because that is the max number of key-value pairs in global storage.
Is the second implementation with 64 logic sigs the way to go? Is there a better way to implement this where I can have more than 64 pools?
Constraint: A pool cannot be opened by anyone, it has to be created and approved by myself.
Your second implementation with logicsigs should work: just do not keep the list of addresses in global storage.
If you want to keep this list, you can easily store 3*64 of them since each key/value in TEAL can store 128byte total (between key and value). So you can store easily 3 addresses of 32 bytes in each key/value.
(You can even do more if you use key = 1 byte and see all the 64 key/values as a big array but it’s much less convenient to use.)
Note that with AVM 1.0 and inner transactions, you don’t need logicsigs, you can just create a fresh account, opt-in to the smart contract, and rekey to the application account of your smart contract (and use inner transactions).
If I want to send a transaction from an account that has been rekeyed to a smart contract, how do I sign transactions from it? To my knowledge, smart contracts do not have private keys to sign transactions.
Is it by creating an inner transaction and setting the sender as the rekeyed account?
Also, if a LogicSig is rekeyed to an application account, does an inner transaction override the logic inside the LogicSig? Meaning, the only way for assets/algos to leave the LogicSig is by inner transactions inside the application account? ( Regardless of the logic in the LogicSig evaluating to a 0 or 1 )
If you rekey any account whether logicsig, normal sig, or multisig, the only way to authorize transaction is to use the rekeyed address. The original way of authorizing transactions become irrelevant.
In your case, the logicsig would not even be known by the blockchain, let alone be evaluated.