Hi all!
After moving some of the storage handling logic to Env extension, I am now getting missing value errors that I can't solve. There is no errors and everything builds, but it doesn't work. The error comes after calling function deposit() and the error states that the key accessed that doesn't have a value is Positions, Address.
fn deposit(e: Env, user: Address, amount: i128) -> Positions {
user.require_auth(); // Depositor needs to authorize the deposit
assert!(amount > 0, "Amount must be positive!");
e.extend_instance_rent();
let client = token::Client::new(&e, &e.get_currency().token_address);
client.transfer(&user, &e.current_contract_address(), &amount);
// TODO: these need to be replaced with increase rather than write so that it wont overwrite the values.
e.set_total_balance(amount);
e.set_total_shares(amount);
e.set_total_balance(amount);
// Increase users position in pool as they deposit
// as this is deposit amount is added to receivables and
// liabilities & collateral stays intact
let input = PositionsInput {
receivables: Some(amount),
liabilities: None,
collateral: None,
};
positions::update_positions(&e, &user, input)
}
^this is the deposit function it calls update_positions() that looks like this: