Skip to content

Commit

Permalink
Merge pull request #28 from aldrin-labs/disable-deletion-and-republish
Browse files Browse the repository at this point in the history
Disable RAMM deletion and republish package
  • Loading branch information
rockbmb authored Apr 25, 2024
2 parents 8bbf676 + 6de7c67 commit 9ef2d61
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 122 deletions.
16 changes: 8 additions & 8 deletions deployment_cfgs/mainnet/sui_usdc_usdt.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# The target network to which the RAMM will be published.
target_env = "mainnet"
#ramm_pkg_addr_or_path = "../ramm-sui"
ramm_pkg_addr_or_path = "0xcb6640194b37023f6bed705f40ff22883eb6007d4c69e72c317c64671f9f6b29"
ramm_pkg_addr_or_path = "0x5b05e2c12f617b33b64ea2b004d89cc18c46b270bc0c214ddd32654fa9a8c84c"
asset_count = 3
fee_collection_address = "0x0ddc7eb2a5559eefbdf1ca734a289d9b7b838ec6705a4d0efabe72973f5f8523"

[[assets]]
asset_type = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
aggregator_address = "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594"
# This is a minimum trade size of 0.5 `SUI`
minimum_trade_amount = 500_000_000
# This is a minimum trade size of 0.01`SUI`
minimum_trade_amount = 10_000_000
decimal_places = 9

# This is USDC
[[assets]]
asset_type = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN"
aggregator_address = "0x456efc067f5b4d7fe4a4c561f6937e14b95969d3b4cecd7ee94eedd01499f94a"
# This is a minimum trade size of 0.5 `USDC`
minimum_trade_amount = 500_000
aggregator_address = "0xfa4e1ec7867c4654c3f1a9980178bac51555751d9343f34dedeb60d294f7ec8a"
# This is a minimum trade size of 0.01 `USDC`
minimum_trade_amount = 10_000
decimal_places = 6

# This is USDT
[[assets]]
asset_type = "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN"
aggregator_address = "0xbe4fcb111eaeb7abb698063c47566447f921e3cc76b33b48265f4c91cf1c645a"
# This is a minimum trade size of 0.5 `USDT`
minimum_trade_amount = 500_000
# This is a minimum trade size of 0.01 `USDT`
minimum_trade_amount = 10_000
decimal_places = 6
12 changes: 6 additions & 6 deletions ramm-sui-deploy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions ramm-sui/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

[move]
version = 1
manifest_digest = "DEB875FBA47B190BDFA78409585FBEF193587B3C4165F49EA7519C7C45116102"
deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3"
manifest_digest = "2BEC985E9E63F1C20BCECBCA4D6B2655FAD7B840E721F99C2BC47C79AB21D278"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ name = "MoveStdlib" },
{ name = "Sui" },
{ name = "SwitchboardStdLib" },
]
Expand All @@ -32,6 +31,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.22.0"
edition = "legacy"
compiler-version = "1.23.1"
edition = "2024.beta"
flavor = "sui"
12 changes: 2 additions & 10 deletions ramm-sui/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,17 @@ edition = "2024.beta"
#published-at = "0xb93c139768a9dfdb6898475052be3ac1d93b92dccf2288c96a8e227f3e511ef6"

# First version of package published in mainnet with ID:
#published-at = "0xd4e097d82d73dc5d152f277bd17ba7980cad4c0b238c3609517cbd0cf686ddd1"
# Upgraded to ID:
#published-at = "0xcb6640194b37023f6bed705f40ff22883eb6007d4c69e72c317c64671f9f6b29"
# Upgraded to ID:
# published-at = "0xce6fe657125970687c9065815974a351fe7c0389589308816740bd5197c220a4"
# The above ID was done in the `imbr-ratio-event` branch, as otherwise it would not be possible
# to upgrade the package - a public function's signature was altered since that branch's PR was
# merged to `main`: `ramm_sui::math::{check_imbalance_ratios, imbalance_ratios}`
published-at = "0x5b05e2c12f617b33b64ea2b004d89cc18c46b270bc0c214ddd32654fa9a8c84c"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet" }
MoveStdlib = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "mainnet" }
SwitchboardStdLib = { git = "https://github.com/switchboard-xyz/sbv2-sui.git", subdir = "move/mainnet/switchboard_std/", rev = "main" }

[addresses]
ramm_sui = "0x0"
std = "0x1"
sui = "0x2"
# mainnet
switchboard = "0x08d79f4d920b03d88faca1e421af023a87fbb1e4a6fd200248e6e9998d09e470"
switchboard_std = "0x08d79f4d920b03d88faca1e421af023a87fbb1e4a6fd200248e6e9998d09e470"
# testnet
#switchboard = "0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e"
1 change: 0 additions & 1 deletion ramm-sui/sources/events.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module ramm_sui::events {
use std::type_name::TypeName;

use sui::event;
use sui::object::ID;
use sui::vec_map::VecMap;

/* friend ramm_sui::ramm; */
Expand Down
16 changes: 3 additions & 13 deletions ramm-sui/sources/interface2.move
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,15 @@ module ramm_sui::interface2 {
use sui::balance::{Self, Balance};
use sui::clock::{Self, Clock};
use sui::coin::{Self, Coin};
use sui::object;
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use sui::vec_map::{Self, VecMap};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

use ramm_sui::events::{Self, TradeIn, TradeOut};
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap, TradeOutput, WithdrawalOutput};

const TWO: u8 = 2;

/// Amounts of LP tokens are considered to have 9 decimal places.
///
/// Sui Move does not allow the export of `const`s, so this is a redefinition from `ramm.move`.
///
/// This `const` factor is used when performing calculations with LP tokens.
const FACTOR_LPT: u256 = 1_000_000_000_000 / 1_000_000_000; // FACTOR_LPT = 10**(PRECISION_DECIMAL_PLACES-LP_TOKENS_DECIMAL_PLACES)

const ERAMMInvalidSize: u64 = 0;
const EDepositsDisabled: u64 = 1;
const EInvalidDeposit: u64 = 2;
Expand Down Expand Up @@ -602,11 +592,11 @@ module ramm_sui::interface2 {
*lpt_amount =
ramm::div(
ramm::mul(
lpt_u256 * FACTOR_LPT,
lpt_u256 * factor_o,
(ramm::value(&withdrawal_output) - ramm::remaining(&withdrawal_output)) * factor_o
),
ramm::value(&withdrawal_output) * factor_o
) / FACTOR_LPT;
) / factor_o;
};

let burn_amount: u64 = (*lpt_amount as u64);
Expand Down
16 changes: 3 additions & 13 deletions ramm-sui/sources/interface3.move
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,15 @@ module ramm_sui::interface3 {
use sui::balance::{Self, Balance};
use sui::clock::{Self, Clock};
use sui::coin::{Self, Coin};
use sui::object;
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use sui::vec_map::{Self, VecMap};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

use ramm_sui::events::{Self, TradeIn, TradeOut};
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap, TradeOutput};

const THREE: u8 = 3;

/// Amounts of LP tokens are considered to have 9 decimal places.
///
/// Sui Move does not allow the export of `const`s, so this is a redefinition from `ramm.move`.
///
/// This `const` factor is used when performing calculations with LP tokens.
const FACTOR_LPT: u256 = 1_000_000_000_000 / 1_000_000_000; // FACTOR_LPT = 10**(PRECISION_DECIMAL_PLACES-LP_TOKENS_DECIMAL_PLACES)

const ERAMMInvalidSize: u64 = 0;
const EDepositsDisabled: u64 = 1;
const EInvalidDeposit: u64 = 2;
Expand Down Expand Up @@ -826,11 +816,11 @@ module ramm_sui::interface3 {
*lpt_amount =
ramm::div(
ramm::mul(
lpt_u256 * FACTOR_LPT,
lpt_u256 * factor_o,
(ramm::value(&withdrawal_output) - ramm::remaining(&withdrawal_output)) * factor_o
),
ramm::value(&withdrawal_output) * factor_o
) / FACTOR_LPT;
) / factor_o;
};

let burn_amount: u64 = (*lpt_amount as u64);
Expand Down
4 changes: 2 additions & 2 deletions ramm-sui/sources/oracles.move
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ramm_sui::oracles {
use switchboard::aggregator::{Self, Aggregator};
use switchboard::math as sb_math;
use switchboard_std::aggregator::{Self, Aggregator};
use switchboard_std::math as sb_math;

use ramm_sui::math;

Expand Down
40 changes: 18 additions & 22 deletions ramm-sui/sources/ramm.move
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
module ramm_sui::ramm {
use std::type_name::{Self, TypeName};
use std::vector;

use sui::bag::{Self, Bag};
use sui::balance::{Self, Balance, Supply};
use sui::coin::{Self, Coin};
use sui::object::{Self, ID, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use sui::vec_map::{Self, VecMap};

use switchboard::aggregator::{Self, Aggregator};
use switchboard_std::aggregator::{Self, Aggregator};

use ramm_sui::events;
use ramm_sui::oracles;
Expand Down Expand Up @@ -763,7 +759,7 @@ module ramm_sui::ramm {
///
/// * If the wrong admin capability is provided.
/// * If the RAMM does not have *exactly* 3 assets.
public fun delete_ramm_3<Asset1, Asset2, Asset3>(
public(package) fun delete_ramm_3<Asset1, Asset2, Asset3>(
self: RAMM,
admin_cap: RAMMAdminCap,
ctx: &mut TxContext
Expand All @@ -787,29 +783,29 @@ module ramm_sui::ramm {
let RAMM {
id: ramm_uid,

admin_cap_id,
new_asset_cap_id,
is_initialized,
admin_cap_id: _,
new_asset_cap_id: _,
is_initialized: _,

mut collected_protocol_fees,
fee_collector,

asset_count,
deposits_enabled,
factors_for_balances,
minimum_trade_amounts,
types_to_indexes,

aggregator_addrs,
previous_prices,
previous_price_timestamps,
volatility_indices,
volatility_timestamps,

balances,
deposits_enabled: _,
factors_for_balances: _,
minimum_trade_amounts: _,
types_to_indexes: _,

aggregator_addrs: _,
previous_prices: _,
previous_price_timestamps: _,
volatility_indices: _,
volatility_timestamps: _,

balances: _,
mut typed_balances,

lp_tokens_issued,
lp_tokens_issued: _,
mut typed_lp_tokens_issued,
} = self;

Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface2_oracle_safety_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ramm_sui::interface2_oracle_safety_tests {
use ramm_sui::ramm::{LP, RAMM};
use ramm_sui::test_util::{Self, BTC, ETH};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

/// ------------------------
/// Structure of this module
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface2_safety_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ramm_sui::interface2_safety_tests {
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap};
use ramm_sui::test_util::{Self, BTC, ETH, USDC};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

/// ------------------------
/// Structure of this module
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface2_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ramm_sui::interface2_tests {
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap};
use ramm_sui::test_util::{Self, ETH, USDT};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

const ADMIN: address = @0xFACE;
const ALICE: address = @0xACE;
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface3_oracle_safety_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ramm_sui::interface3_oracle_safety_tests {
use ramm_sui::ramm::{LP, RAMM};
use ramm_sui::test_util::{Self, BTC, ETH, SOL};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

/// ------------------------
/// Structure of this module
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface3_safety_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ramm_sui::interface3_safety_tests {
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap};
use ramm_sui::test_util::{Self, BTC, ETH, SOL, USDC};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

/// ------------------------
/// Structure of this module
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/interface3_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ramm_sui::interface3_tests {
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap};
use ramm_sui::test_util::{Self, ETH, MATIC, USDT};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

const ADMIN: address = @0xFACE;
const ALICE: address = @0xACE;
Expand Down
4 changes: 1 addition & 3 deletions ramm-sui/tests/liquidity_provision_fees_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ module ramm_sui::liquidity_provision_fees_tests {
use ramm_sui::ramm::{Self, LP, RAMM, RAMMAdminCap};
use ramm_sui::test_util::{Self, ETH, USDT};

use switchboard::aggregator::Aggregator;
use switchboard_std::aggregator::Aggregator;

const ADMIN: address = @0xFACE;
const ALICE: address = @0xACE;

const ETraderShouldHaveAsset: u64 = 0;

/// Returns true iff `\exists n: u64: x = 2^n`, false otherwise.
fun is_power_of_two(x: u64): bool {
if ((x & (x - 1)) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion ramm-sui/tests/math_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ramm_sui::math_tests {
use sui::test_utils;
use sui::vec_map::{Self, VecMap};

use switchboard::math as sb_math;
use switchboard_std::math as sb_math;

use ramm_sui::oracles;
use ramm_sui::ramm;
Expand Down
Loading

0 comments on commit 9ef2d61

Please sign in to comment.