zetamarkets / sdk

SDK for accessing the Zeta program
Other
85 stars 29 forks source link

Auto fee upper limit #240

Closed filipzeta closed 1 year ago

filipzeta commented 1 year ago

Add an optional upper limit for auto fees so it doesn't blow up and rug you without notice, defaulting to the default fee (1000).

filipzeta commented 1 year ago

Quick local test. Code:

Exchange.toggleAutoPriorityFee();

await utils.sleep(60_000);
console.log("Set max fee to 345");
Exchange.updateAutoPriorityFeeUpperLimit(345);

await utils.sleep(60_000);
console.log("Set max fee to 123");
Exchange.updateAutoPriorityFeeUpperLimit(123);

await utils.sleep(60_000);
console.log("Set max fee to 100_000");
Exchange.updateAutoPriorityFeeUpperLimit(100_000);

logs:

AutoUpdate priority fee. New fee = 1000 microlamports per compute unit
AutoUpdate priority fee. New fee = 1000 microlamports per compute unit
Set max fee to 345
AutoUpdate priority fee. New fee = 345 microlamports per compute unit
AutoUpdate priority fee. New fee = 345 microlamports per compute unit
Set max fee to 123
AutoUpdate priority fee. New fee = 123 microlamports per compute unit
AutoUpdate priority fee. New fee = 123 microlamports per compute unit
Set max fee to 100_000
AutoUpdate priority fee. New fee = 1000 microlamports per compute unit
AutoUpdate priority fee. New fee = 1000 microlamports per compute unit